From e1a656b76faf81cc0917635c840eda36b2c26506 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 3 May 2022 17:13:13 +0100 Subject: [PATCH] Add @budibase/types package --- packages/backend-core/package.json | 1 + packages/backend-core/src/events/constants.js | 141 ----------------- packages/backend-core/src/events/events.js | 8 +- .../src/events/handlers/account.js | 17 -- .../src/events/handlers/account.ts | 17 ++ .../backend-core/src/events/handlers/app.js | 59 ------- .../backend-core/src/events/handlers/app.ts | 73 +++++++++ .../backend-core/src/events/handlers/auth.js | 42 ----- .../backend-core/src/events/handlers/auth.ts | 52 +++++++ .../src/events/handlers/automation.js | 38 ----- .../src/events/handlers/automation.ts | 52 +++++++ .../src/events/handlers/datasource.js | 17 -- .../src/events/handlers/datasource.ts | 23 +++ .../backend-core/src/events/handlers/email.js | 12 -- .../backend-core/src/events/handlers/email.ts | 17 ++ .../backend-core/src/events/handlers/index.js | 37 ----- .../backend-core/src/events/handlers/index.ts | 17 ++ .../src/events/handlers/layout.js | 12 -- .../src/events/handlers/layout.ts | 17 ++ .../src/events/handlers/license.js | 35 ----- .../src/events/handlers/license.ts | 43 ++++++ .../backend-core/src/events/handlers/org.js | 30 ---- .../backend-core/src/events/handlers/org.ts | 30 ++++ .../backend-core/src/events/handlers/query.js | 35 ----- .../backend-core/src/events/handlers/query.ts | 48 ++++++ .../backend-core/src/events/handlers/role.js | 29 ---- .../backend-core/src/events/handlers/role.ts | 38 +++++ .../backend-core/src/events/handlers/row.js | 14 -- .../backend-core/src/events/handlers/row.ts | 23 +++ .../src/events/handlers/screen.js | 12 -- .../src/events/handlers/screen.ts | 17 ++ .../backend-core/src/events/handlers/serve.js | 19 --- .../backend-core/src/events/handlers/serve.ts | 25 +++ .../backend-core/src/events/handlers/table.js | 35 ----- .../backend-core/src/events/handlers/table.ts | 45 ++++++ .../backend-core/src/events/handlers/user.js | 75 --------- .../backend-core/src/events/handlers/user.ts | 89 +++++++++++ .../backend-core/src/events/handlers/view.js | 54 ------- .../backend-core/src/events/handlers/view.ts | 66 ++++++++ packages/backend-core/src/events/index.js | 6 +- packages/backend-core/src/index.js | 3 +- packages/types/.gitignore | 3 + packages/types/package.json | 18 +++ packages/types/src/api/public/.keep | 0 packages/types/src/api/web/.keep | 0 .../types/src/documents/account/account.ts | 1 + packages/types/src/documents/account/index.ts | 1 + packages/types/src/documents/app/app.ts | 1 + .../types/src/documents/app/automation.ts | 5 + .../types/src/documents/app/datasource.ts | 1 + packages/types/src/documents/app/index.ts | 9 ++ packages/types/src/documents/app/layout.ts | 1 + packages/types/src/documents/app/query.ts | 1 + packages/types/src/documents/app/role.ts | 1 + packages/types/src/documents/app/screen.ts | 1 + packages/types/src/documents/app/table.ts | 1 + packages/types/src/documents/app/view.ts | 1 + packages/types/src/documents/global/config.ts | 1 + packages/types/src/documents/global/index.ts | 2 + packages/types/src/documents/global/user.ts | 1 + packages/types/src/documents/index.ts | 4 + .../types/src/documents/platform/index.ts | 1 + packages/types/src/documents/platform/info.ts | 1 + packages/types/src/events/app.ts | 21 +++ packages/types/src/events/auth.ts | 16 ++ packages/types/src/events/automation.ts | 11 ++ packages/types/src/events/config.ts | 3 + packages/types/src/events/datasource.ts | 5 + packages/types/src/events/events.ts | 145 ++++++++++++++++++ packages/types/src/events/index.ts | 17 ++ packages/types/src/events/layout.ts | 3 + packages/types/src/events/license.ts | 9 ++ packages/types/src/events/org.ts | 1 + packages/types/src/events/query.ts | 9 ++ packages/types/src/events/role.ts | 9 ++ packages/types/src/events/row.ts | 1 + packages/types/src/events/screen.ts | 3 + packages/types/src/events/serve.ts | 5 + packages/types/src/events/table.ts | 9 ++ packages/types/src/events/user.ts | 21 +++ packages/types/src/events/view.ts | 19 +++ packages/types/src/index.ts | 3 + packages/types/src/licensing/index.ts | 1 + packages/types/src/licensing/license.ts | 1 + packages/types/tsconfig.json | 17 ++ packages/types/yarn.lock | 13 ++ 86 files changed, 1097 insertions(+), 723 deletions(-) delete mode 100644 packages/backend-core/src/events/constants.js delete mode 100644 packages/backend-core/src/events/handlers/account.js create mode 100644 packages/backend-core/src/events/handlers/account.ts delete mode 100644 packages/backend-core/src/events/handlers/app.js create mode 100644 packages/backend-core/src/events/handlers/app.ts delete mode 100644 packages/backend-core/src/events/handlers/auth.js create mode 100644 packages/backend-core/src/events/handlers/auth.ts delete mode 100644 packages/backend-core/src/events/handlers/automation.js create mode 100644 packages/backend-core/src/events/handlers/automation.ts delete mode 100644 packages/backend-core/src/events/handlers/datasource.js create mode 100644 packages/backend-core/src/events/handlers/datasource.ts delete mode 100644 packages/backend-core/src/events/handlers/email.js create mode 100644 packages/backend-core/src/events/handlers/email.ts delete mode 100644 packages/backend-core/src/events/handlers/index.js create mode 100644 packages/backend-core/src/events/handlers/index.ts delete mode 100644 packages/backend-core/src/events/handlers/layout.js create mode 100644 packages/backend-core/src/events/handlers/layout.ts delete mode 100644 packages/backend-core/src/events/handlers/license.js create mode 100644 packages/backend-core/src/events/handlers/license.ts delete mode 100644 packages/backend-core/src/events/handlers/org.js create mode 100644 packages/backend-core/src/events/handlers/org.ts delete mode 100644 packages/backend-core/src/events/handlers/query.js create mode 100644 packages/backend-core/src/events/handlers/query.ts delete mode 100644 packages/backend-core/src/events/handlers/role.js create mode 100644 packages/backend-core/src/events/handlers/role.ts delete mode 100644 packages/backend-core/src/events/handlers/row.js create mode 100644 packages/backend-core/src/events/handlers/row.ts delete mode 100644 packages/backend-core/src/events/handlers/screen.js create mode 100644 packages/backend-core/src/events/handlers/screen.ts delete mode 100644 packages/backend-core/src/events/handlers/serve.js create mode 100644 packages/backend-core/src/events/handlers/serve.ts delete mode 100644 packages/backend-core/src/events/handlers/table.js create mode 100644 packages/backend-core/src/events/handlers/table.ts delete mode 100644 packages/backend-core/src/events/handlers/user.js create mode 100644 packages/backend-core/src/events/handlers/user.ts delete mode 100644 packages/backend-core/src/events/handlers/view.js create mode 100644 packages/backend-core/src/events/handlers/view.ts create mode 100644 packages/types/.gitignore create mode 100644 packages/types/package.json create mode 100644 packages/types/src/api/public/.keep create mode 100644 packages/types/src/api/web/.keep create mode 100644 packages/types/src/documents/account/account.ts create mode 100644 packages/types/src/documents/account/index.ts create mode 100644 packages/types/src/documents/app/app.ts create mode 100644 packages/types/src/documents/app/automation.ts create mode 100644 packages/types/src/documents/app/datasource.ts create mode 100644 packages/types/src/documents/app/index.ts create mode 100644 packages/types/src/documents/app/layout.ts create mode 100644 packages/types/src/documents/app/query.ts create mode 100644 packages/types/src/documents/app/role.ts create mode 100644 packages/types/src/documents/app/screen.ts create mode 100644 packages/types/src/documents/app/table.ts create mode 100644 packages/types/src/documents/app/view.ts create mode 100644 packages/types/src/documents/global/config.ts create mode 100644 packages/types/src/documents/global/index.ts create mode 100644 packages/types/src/documents/global/user.ts create mode 100644 packages/types/src/documents/index.ts create mode 100644 packages/types/src/documents/platform/index.ts create mode 100644 packages/types/src/documents/platform/info.ts create mode 100644 packages/types/src/events/app.ts create mode 100644 packages/types/src/events/auth.ts create mode 100644 packages/types/src/events/automation.ts create mode 100644 packages/types/src/events/config.ts create mode 100644 packages/types/src/events/datasource.ts create mode 100644 packages/types/src/events/events.ts create mode 100644 packages/types/src/events/index.ts create mode 100644 packages/types/src/events/layout.ts create mode 100644 packages/types/src/events/license.ts create mode 100644 packages/types/src/events/org.ts create mode 100644 packages/types/src/events/query.ts create mode 100644 packages/types/src/events/role.ts create mode 100644 packages/types/src/events/row.ts create mode 100644 packages/types/src/events/screen.ts create mode 100644 packages/types/src/events/serve.ts create mode 100644 packages/types/src/events/table.ts create mode 100644 packages/types/src/events/user.ts create mode 100644 packages/types/src/events/view.ts create mode 100644 packages/types/src/index.ts create mode 100644 packages/types/src/licensing/index.ts create mode 100644 packages/types/src/licensing/license.ts create mode 100644 packages/types/tsconfig.json create mode 100644 packages/types/yarn.lock diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 7074031b9b..3b22bd5b2e 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -44,6 +44,7 @@ "@types/jest": "^27.4.1", "@types/node": "^15.12.4", "@types/node-fetch": "^2.6.1", + "@budibase/types": "^1.0.126-alpha.0", "typescript": "^4.5.5", "@shopify/jest-koa-mocks": "^3.1.5", "ioredis-mock": "^5.5.5", diff --git a/packages/backend-core/src/events/constants.js b/packages/backend-core/src/events/constants.js deleted file mode 100644 index 99bd8a6ada..0000000000 --- a/packages/backend-core/src/events/constants.js +++ /dev/null @@ -1,141 +0,0 @@ -exports.Events = { - // USER - USER_CREATED: "user:created", - USER_UPDATED: "user:updated", - USER_DELETED: "user:deleted", - - // USER / PERMISSIONS - USER_PERMISSION_ADMIN_ASSIGNED: "user:admin:assigned", - USER_PERMISSION_ADMIN_REMOVED: "user:admin:removed", - USER_PERMISSION_BUILDER_ASSIGNED: "user:builder:assigned", - USER_PERMISSION_BUILDER_REMOVED: "userbuilder:removed", - - // USER / INVITE - USER_INVITED: "user:invited", - USER_INVITED_ACCEPTED: "user:invite:accepted", - - // USER / PASSWORD - USER_PASSWORD_FORCE_RESET: "user:password:force:reset", - USER_PASSWORD_UPDATED: "user:password:updated", - USER_PASSWORD_RESET_REQUESTED: "user:password:reset:requested", - USER_PASSWORD_RESET: "user:password:reset", - - // EMAIL - EMAIL_SMTP_CREATED: "email:smtp:created", - EMAIL_SMTP_UPDATED: "email:smtp:updated", - - // AUTH - AUTH_SSO_CREATED: "auth:sso:created", - AUTH_SSO_UPDATED: "auth:sso:updated", - AUTH_SSO_ACTIVATED: "auth:sso:activated", - AUTH_SSO_DEACTIVATED: "auth:sso:deactivated", - AUTH_LOGIN: "auth:login", - AUTH_LOGOUT: "auth:logout", - - // ORG - ORG_NAME_UPDATED: "org:info:name:updated", - ORG_LOGO_UPDATED: "org:info:logo:updated", - ORG_PLATFORM_URL_UPDATED: "org:platformurl:updated", - - // ORG / UPDATE - UPDATE_VERSION_CHECKED: "version:checked", - - // ORG / ANALYTICS - ANALYTICS_OPT_OUT: "analytics:opt:out", - - // APP - APP_CREATED: "app:created", - APP_UPDATED: "app:updated", - APP_DELETED: "app:deleted", - APP_PUBLISHED: "app:published", - APP_UNPUBLISHED: "app:unpublished", - APP_TEMPLATE_IMPORTED: "app:template:imported", - APP_FILE_IMPORTED: "app:file:imported", - APP_VERSION_UPDATED: "app:version:updated", - APP_VERSION_REVERTED: "app:version:reverted", - APP_REVERTED: "app:reverted", - APP_EXPORTED: "app:exported", - - // ROLE - ROLE_CREATED: "role:created", - ROLE_UPDATED: "role:updated", - ROLE_DELETED: "role:deleted", - ROLE_ASSIGNED: "role:assigned", - ROLE_UNASSIGNED: "role:unassigned", - - // SERVE - SERVED_BUILDER: "served:builder", - SERVED_APP: "served:app", - SERVED_APP_PREVIEW: "served:app:preview", - - // DATASOURCE - DATASOURCE_CREATED: "datasource:created", - DATASOURCE_UPDATED: "datasource:updated", - DATASOURCE_DELETED: "datasource:deleted", - - // QUERY - QUERY_CREATED: "query:created", - QUERY_UPDATED: "query:updated", - QUERY_DELETED: "query:deleted", - QUERY_IMPORT: "query:import", - // QUERY_RUN: "query:run", - QUERY_PREVIEWED: "query:previewed", - - // TABLE - TABLE_CREATED: "table:created", - TABLE_UPDATED: "table:updated", - TABLE_DELETED: "table:deleted", - TABLE_EXPORTED: "table:exported", - TABLE_IMPORTED: "table:imported", - TABLE_DATA_IMPORTED: "table:data:imported", - TABLE_PERMISSION_UPDATED: "table:permission:updated", - - // VIEW - VIEW_CREATED: "view:created", - VIEW_UPDATED: "view:updated", - VIEW_DELETED: "view:deleted", - VIEW_EXPORTED: "view:exported", - VIEW_FILTER_CREATED: "view:filter:created", - VIEW_FILTER_UPDATED: "view:filter:updated", - VIEW_FILTER_DELETED: "view:filter:deleted", - VIEW_CALCULATION_CREATED: "view:calculation:created", - VIEW_CALCULATION_UPDATED: "view:calculation:updated", - VIEW_CALCULATION_DELETED: "view:calculation:deleted", - - // ROW - // ROW_CREATED: "row:created", - ROW_IMPORT: "row:import", - - // COMPONENT - COMPONENT_CREATED: "component:created", - COMPONENT_DELETED: "component:deleted", - - // SCREEN - SCREEN_CREATED: "screen:created", - SCREEN_DELETED: "screen:deleted", - - // LAYOUT - LAYOUT_CREATED: "layout:created", - LAYOUT_DELETED: "layout:deleted", - - // AUTOMATION - AUTOMATION_CREATED: "automation:created", - AUTOMATION_DELETED: "automation:deleted", - AUTOMATION_TESTED: "automation:tested", - // AUTOMATION_RUN: "automation:run", - AUTOMATION_STEP_CREATED: "automation:step:created", - AUTOMATION_STEP_DELETED: "automation:step:deleted", - AUTOMATION_TRIGGER_UPDATED: "automation:trigger:updated", - - // LICENSE - LICENSE_UPGRADED: "license:upgraded", - LICENSE_DOWNGRADED: "license:downgraded", - LICENSE_UPDATED: "license:updated", - LICENSE_ACTIVATED: "license:activated", - LICENSE_QUOTA_EXCEEDED: "license:quota:exceeded", - - // ACCOUNT - ACCOUNT_CREATED: "account:created", - ACCOUNT_DELETED: "account:deleted", - ACCOUNT_VERIFIED: "account:verified", -} diff --git a/packages/backend-core/src/events/events.js b/packages/backend-core/src/events/events.js index 56fe069c7e..eb00fc5d47 100644 --- a/packages/backend-core/src/events/events.js +++ b/packages/backend-core/src/events/events.js @@ -1,5 +1,5 @@ -const { getTenantId } = require("../context") -const analytics = require("../analytics") +import { getTenantId } from "../context" +import { captureEvent } from "../analytics" const logEvent = messsage => { const tenantId = getTenantId() @@ -7,10 +7,10 @@ const logEvent = messsage => { console.log(`[audit] [tenant=${tenantId}] [user=${userId}] ${messsage}`) } -exports.processEvent = (event, properties) => { +export const processEvent = (event, properties) => { // logging logEvent(event) // analytics - analytics.captureEvent(event, properties) + captureEvent(event, properties) } diff --git a/packages/backend-core/src/events/handlers/account.js b/packages/backend-core/src/events/handlers/account.js deleted file mode 100644 index e1d1eb8d35..0000000000 --- a/packages/backend-core/src/events/handlers/account.js +++ /dev/null @@ -1,17 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -exports.created = () => { - const properties = {} - events.processEvent(Events.ACCOUNT_CREATED, properties) -} - -exports.deleted = () => { - const properties = {} - events.processEvent(Events.ACCOUNT_DELETED, properties) -} - -exports.verified = () => { - const properties = {} - events.processEvent(Events.ACCOUNT_VERIFIED, properties) -} diff --git a/packages/backend-core/src/events/handlers/account.ts b/packages/backend-core/src/events/handlers/account.ts new file mode 100644 index 0000000000..9577edc43b --- /dev/null +++ b/packages/backend-core/src/events/handlers/account.ts @@ -0,0 +1,17 @@ +import { processEvent } from "../events" +import { Events, Account } from "@budibase/types" + +export function created(account: Account) { + const properties = {} + processEvent(Events.ACCOUNT_CREATED, properties) +} + +export function deleted(account: Account) { + const properties = {} + processEvent(Events.ACCOUNT_DELETED, properties) +} + +export function verified(account: Account) { + const properties = {} + processEvent(Events.ACCOUNT_VERIFIED, properties) +} diff --git a/packages/backend-core/src/events/handlers/app.js b/packages/backend-core/src/events/handlers/app.js deleted file mode 100644 index 17c86d9a6d..0000000000 --- a/packages/backend-core/src/events/handlers/app.js +++ /dev/null @@ -1,59 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -exports.created = () => { - const properties = {} - events.processEvent(Events.APP_CREATED, properties) -} - -exports.updated = () => { - const properties = {} - events.processEvent(Events.APP_UPDATED, properties) -} - -exports.deleted = () => { - const properties = {} - events.processEvent(Events.APP_DELETED, properties) -} - -exports.published = () => { - const properties = {} - events.processEvent(Events.APP_PUBLISHED, properties) -} - -exports.unpublished = () => { - const properties = {} - events.processEvent(Events.APP_UNPUBLISHED, properties) -} - -exports.fileImported = () => { - const properties = {} - events.processEvent(Events.APP_FILE_IMPORTED, properties) -} - -exports.templateImported = templateKey => { - const properties = { - templateKey, - } - events.processEvent(Events.APP_TEMPLATE_IMPORTED, properties) -} - -exports.versionUpdated = () => { - const properties = {} - events.processEvent(Events.APP_VERSION_UPDATED, properties) -} - -exports.versionReverted = () => { - const properties = {} - events.processEvent(Events.APP_VERSION_REVERTED, properties) -} - -exports.reverted = () => { - const properties = {} - events.processEvent(Events.APP_REVERTED, properties) -} - -exports.exported = () => { - const properties = {} - events.processEvent(Events.APP_EXPORTED, properties) -} diff --git a/packages/backend-core/src/events/handlers/app.ts b/packages/backend-core/src/events/handlers/app.ts new file mode 100644 index 0000000000..904f8efeda --- /dev/null +++ b/packages/backend-core/src/events/handlers/app.ts @@ -0,0 +1,73 @@ +import { processEvent } from "../events" +import { + Events, + App, + AppCreatedEvent, + AppUpdatedEvent, + AppDeletedEvent, + AppPublishedEvent, + AppUnpublishedEvent, + AppFileImportedEvent, + AppTemplateImportedEvent, + AppVersionUpdatedEvent, + AppVersionRevertedEvent, + AppRevertedEvent, + AppExportedEvent, +} from "@budibase/types" + +export function created(app: App) { + const properties: AppCreatedEvent = {} + processEvent(Events.APP_CREATED, properties) +} + +export function updated(app: App) { + const properties: AppUpdatedEvent = {} + processEvent(Events.APP_UPDATED, properties) +} + +export function deleted(app: App) { + const properties: AppDeletedEvent = {} + processEvent(Events.APP_DELETED, properties) +} + +export function published(app: App) { + const properties: AppPublishedEvent = {} + processEvent(Events.APP_PUBLISHED, properties) +} + +export function unpublished(app: App) { + const properties: AppUnpublishedEvent = {} + processEvent(Events.APP_UNPUBLISHED, properties) +} + +export function fileImported(app: App) { + const properties: AppFileImportedEvent = {} + processEvent(Events.APP_FILE_IMPORTED, properties) +} + +export function templateImported(templateKey: string) { + const properties: AppTemplateImportedEvent = { + templateKey, + } + processEvent(Events.APP_TEMPLATE_IMPORTED, properties) +} + +export function versionUpdated(app: App) { + const properties: AppVersionUpdatedEvent = {} + processEvent(Events.APP_VERSION_UPDATED, properties) +} + +export function versionReverted(app: App) { + const properties: AppVersionRevertedEvent = {} + processEvent(Events.APP_VERSION_REVERTED, properties) +} + +export function reverted(app: App) { + const properties: AppRevertedEvent = {} + processEvent(Events.APP_REVERTED, properties) +} + +export function exported(app: App) { + const properties: AppExportedEvent = {} + processEvent(Events.APP_EXPORTED, properties) +} diff --git a/packages/backend-core/src/events/handlers/auth.js b/packages/backend-core/src/events/handlers/auth.js deleted file mode 100644 index 98bbbd2994..0000000000 --- a/packages/backend-core/src/events/handlers/auth.js +++ /dev/null @@ -1,42 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -exports.login = source => { - const properties = { - source, - } - events.processEvent(Events.AUTH_LOGIN, properties) -} - -exports.logout = () => { - const properties = {} - events.processEvent(Events.AUTH_LOGOUT, properties) -} - -exports.SSOCreated = type => { - const properties = { - type, - } - events.processEvent(Events.AUTH_SSO_CREATED, properties) -} - -exports.SSOUpdated = type => { - const properties = { - type, - } - events.processEvent(Events.AUTH_SSO_UPDATED, properties) -} - -exports.SSOActivated = type => { - const properties = { - type, - } - events.processEvent(Events.AUTH_SSO_ACTIVATED, properties) -} - -exports.SSODeactivated = type => { - const properties = { - type, - } - events.processEvent(Events.AUTH_SSO_DEACTIVATED, properties) -} diff --git a/packages/backend-core/src/events/handlers/auth.ts b/packages/backend-core/src/events/handlers/auth.ts new file mode 100644 index 0000000000..8d74a9a103 --- /dev/null +++ b/packages/backend-core/src/events/handlers/auth.ts @@ -0,0 +1,52 @@ +import { processEvent } from "../events" +import { + Events, + LoginEvent, + LoginSource, + LogoutEvent, + SSOActivatedEvent, + SSOCreatedEvent, + SSODeactivatedEvent, + SSOType, + SSOUpdatedEvent, +} from "@budibase/types" + +export function login(source: LoginSource) { + const properties: LoginEvent = { + source, + } + processEvent(Events.AUTH_LOGIN, properties) +} + +export function logout() { + const properties: LogoutEvent = {} + processEvent(Events.AUTH_LOGOUT, properties) +} + +export function SSOCreated(type: SSOType) { + const properties: SSOCreatedEvent = { + type, + } + processEvent(Events.AUTH_SSO_CREATED, properties) +} + +export function SSOUpdated(type: SSOType) { + const properties: SSOUpdatedEvent = { + type, + } + processEvent(Events.AUTH_SSO_UPDATED, properties) +} + +export function SSOActivated(type: SSOType) { + const properties: SSOActivatedEvent = { + type, + } + processEvent(Events.AUTH_SSO_ACTIVATED, properties) +} + +export function SSODeactivated(type: SSOType) { + const properties: SSODeactivatedEvent = { + type, + } + processEvent(Events.AUTH_SSO_DEACTIVATED, properties) +} diff --git a/packages/backend-core/src/events/handlers/automation.js b/packages/backend-core/src/events/handlers/automation.js deleted file mode 100644 index 2a978b4645..0000000000 --- a/packages/backend-core/src/events/handlers/automation.js +++ /dev/null @@ -1,38 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -exports.created = () => { - const properties = {} - events.processEvent(Events.AUTOMATION_CREATED, properties) -} - -exports.deleted = () => { - const properties = {} - events.processEvent(Events.AUTOMATION_DELETED, properties) -} - -exports.tested = () => { - const properties = {} - events.processEvent(Events.AUTOMATION_TESTED, properties) -} - -// TODO -// exports.run = () => { -// const properties = {} -// events.processEvent(Events.AUTOMATION_RUN, properties) -// } - -exports.stepCreated = () => { - const properties = {} - events.processEvent(Events.AUTOMATION_STEP_CREATED, properties) -} - -exports.stepDeleted = () => { - const properties = {} - events.processEvent(Events.AUTOMATION_STEP_DELETED, properties) -} - -exports.triggerUpdated = () => { - const properties = {} - events.processEvent(Events.AUTOMATION_TRIGGER_UPDATED, properties) -} diff --git a/packages/backend-core/src/events/handlers/automation.ts b/packages/backend-core/src/events/handlers/automation.ts new file mode 100644 index 0000000000..22986bf935 --- /dev/null +++ b/packages/backend-core/src/events/handlers/automation.ts @@ -0,0 +1,52 @@ +import { processEvent } from "../events" +import { + Automation, + Events, + AutomationStep, + AutomationTrigger, + AutomationCreatedEvent, + AutomationDeletedEvent, + AutomationTestedEvent, + AutomationStepCreatedEvent, + AutomationStepDeletedEvent, + AutomationTriggerUpdatedEvent, +} from "@budibase/types" + +export function created(automation: Automation) { + const properties: AutomationCreatedEvent = {} + processEvent(Events.AUTOMATION_CREATED, properties) +} + +export function deleted(automation: Automation) { + const properties: AutomationDeletedEvent = {} + processEvent(Events.AUTOMATION_DELETED, properties) +} + +export function tested(automation: Automation) { + const properties: AutomationTestedEvent = {} + processEvent(Events.AUTOMATION_TESTED, properties) +} + +// TODO +// exports.run = () => { +// const properties = {} +// events.processEvent(Events.AUTOMATION_RUN, properties) +// } + +export function stepCreated(automation: Automation, step: AutomationStep) { + const properties: AutomationStepCreatedEvent = {} + processEvent(Events.AUTOMATION_STEP_CREATED, properties) +} + +export function stepDeleted(automation: Automation, step: AutomationStep) { + const properties: AutomationStepDeletedEvent = {} + processEvent(Events.AUTOMATION_STEP_DELETED, properties) +} + +export function triggerUpdated( + automation: Automation, + trigger: AutomationTrigger +) { + const properties: AutomationTriggerUpdatedEvent = {} + processEvent(Events.AUTOMATION_TRIGGER_UPDATED, properties) +} diff --git a/packages/backend-core/src/events/handlers/datasource.js b/packages/backend-core/src/events/handlers/datasource.js deleted file mode 100644 index 512a6cc28e..0000000000 --- a/packages/backend-core/src/events/handlers/datasource.js +++ /dev/null @@ -1,17 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -exports.created = () => { - const properties = {} - events.processEvent(Events.DATASOURCE_CREATED, properties) -} - -exports.updated = () => { - const properties = {} - events.processEvent(Events.DATASOURCE_UPDATED, properties) -} - -exports.deleted = () => { - const properties = {} - events.processEvent(Events.DATASOURCE_DELETED, properties) -} diff --git a/packages/backend-core/src/events/handlers/datasource.ts b/packages/backend-core/src/events/handlers/datasource.ts new file mode 100644 index 0000000000..c32d4292ba --- /dev/null +++ b/packages/backend-core/src/events/handlers/datasource.ts @@ -0,0 +1,23 @@ +import { processEvent } from "../events" +import { + Events, + Datasource, + DatasourceCreatedEvent, + DatasourceUpdatedEvent, + DatasourceDeletedEvent, +} from "@budibase/types" + +export function created(datasource: Datasource) { + const properties: DatasourceCreatedEvent = {} + processEvent(Events.DATASOURCE_CREATED, properties) +} + +export function updated(datasource: Datasource) { + const properties: DatasourceUpdatedEvent = {} + processEvent(Events.DATASOURCE_UPDATED, properties) +} + +export function deleted(datasource: Datasource) { + const properties: DatasourceDeletedEvent = {} + processEvent(Events.DATASOURCE_DELETED, properties) +} diff --git a/packages/backend-core/src/events/handlers/email.js b/packages/backend-core/src/events/handlers/email.js deleted file mode 100644 index 189f82dec7..0000000000 --- a/packages/backend-core/src/events/handlers/email.js +++ /dev/null @@ -1,12 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -exports.SMTPCreated = () => { - const properties = {} - events.processEvent(Events.EMAIL_SMTP_CREATED, properties) -} - -exports.SMTPUpdated = () => { - const properties = {} - events.processEvent(Events.EMAIL_SMTP_UPDATED, properties) -} diff --git a/packages/backend-core/src/events/handlers/email.ts b/packages/backend-core/src/events/handlers/email.ts new file mode 100644 index 0000000000..d9f0320540 --- /dev/null +++ b/packages/backend-core/src/events/handlers/email.ts @@ -0,0 +1,17 @@ +import { processEvent } from "../events" +import { + Events, + SMTPConfig, + SMTPCreatedEvent, + SMTPUpdatedEvent, +} from "@budibase/types" + +export function SMTPCreated(config: SMTPConfig) { + const properties: SMTPCreatedEvent = {} + processEvent(Events.EMAIL_SMTP_CREATED, properties) +} + +export function SMTPUpdated(config: SMTPConfig) { + const properties: SMTPUpdatedEvent = {} + processEvent(Events.EMAIL_SMTP_UPDATED, properties) +} diff --git a/packages/backend-core/src/events/handlers/index.js b/packages/backend-core/src/events/handlers/index.js deleted file mode 100644 index a1b92b0332..0000000000 --- a/packages/backend-core/src/events/handlers/index.js +++ /dev/null @@ -1,37 +0,0 @@ -const account = require("./account") -const app = require("./app") -const auth = require("./auth") -const automation = require("./automation") -const datasource = require("./datasource") -const email = require("./email") -const license = require("./license") -const layout = require("./layout") -const org = require("./org") -const query = require("./query") -const role = require("./role") -const screen = require("./screen") -const row = require("./row") -const table = require("./table") -const serve = require("./serve") -const user = require("./user") -const view = require("./view") - -module.exports = { - account, - app, - auth, - automation, - datasource, - email, - license, - layout, - org, - query, - role, - screen, - row, - table, - serve, - user, - view, -} diff --git a/packages/backend-core/src/events/handlers/index.ts b/packages/backend-core/src/events/handlers/index.ts new file mode 100644 index 0000000000..b8381622b7 --- /dev/null +++ b/packages/backend-core/src/events/handlers/index.ts @@ -0,0 +1,17 @@ +export * as account from "./account" +export * as app from "./app" +export * as auth from "./auth" +export * as automation from "./automation" +export * as datasource from "./datasource" +export * as email from "./email" +export * as license from "./license" +export * as layout from "./layout" +export * as org from "./org" +export * as query from "./query" +export * as role from "./role" +export * as screen from "./screen" +export * as row from "./row" +export * as table from "./table" +export * as serve from "./serve" +export * as user from "./user" +export * as view from "./view" diff --git a/packages/backend-core/src/events/handlers/layout.js b/packages/backend-core/src/events/handlers/layout.js deleted file mode 100644 index fdeda28d60..0000000000 --- a/packages/backend-core/src/events/handlers/layout.js +++ /dev/null @@ -1,12 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -exports.created = () => { - const properties = {} - events.processEvent(Events.LAYOUT_CREATED, properties) -} - -exports.deleted = () => { - const properties = {} - events.processEvent(Events.LAYOUT_DELETED, properties) -} diff --git a/packages/backend-core/src/events/handlers/layout.ts b/packages/backend-core/src/events/handlers/layout.ts new file mode 100644 index 0000000000..325f4dda50 --- /dev/null +++ b/packages/backend-core/src/events/handlers/layout.ts @@ -0,0 +1,17 @@ +import { processEvent } from "../events" +import { + Events, + Layout, + LayoutCreatedEvent, + LayoutDeletedEvent, +} from "@budibase/types" + +export function created(layout: Layout) { + const properties: LayoutCreatedEvent = {} + processEvent(Events.LAYOUT_CREATED, properties) +} + +export function deleted(layout: Layout) { + const properties: LayoutDeletedEvent = {} + processEvent(Events.LAYOUT_DELETED, properties) +} diff --git a/packages/backend-core/src/events/handlers/license.js b/packages/backend-core/src/events/handlers/license.js deleted file mode 100644 index 68107e8fd9..0000000000 --- a/packages/backend-core/src/events/handlers/license.js +++ /dev/null @@ -1,35 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -// TODO -exports.updgraded = () => { - const properties = {} - events.processEvent(Events.LICENSE_UPGRADED, properties) -} - -// TODO -exports.downgraded = () => { - const properties = {} - events.processEvent(Events.LICENSE_DOWNGRADED, properties) -} - -// TODO -exports.updated = () => { - const properties = {} - events.processEvent(Events.LICENSE_UPDATED, properties) -} - -// TODO -exports.activated = () => { - const properties = {} - events.processEvent(Events.LICENSE_ACTIVATED, properties) -} - -// TODO -exports.quotaExceeded = (quotaName, value) => { - const properties = { - name: quotaName, - value, - } - events.processEvent(Events.LICENSE_QUOTA_EXCEEDED, properties) -} diff --git a/packages/backend-core/src/events/handlers/license.ts b/packages/backend-core/src/events/handlers/license.ts new file mode 100644 index 0000000000..f33deb2018 --- /dev/null +++ b/packages/backend-core/src/events/handlers/license.ts @@ -0,0 +1,43 @@ +import { processEvent } from "../events" +import { + Events, + License, + LicenseActivatedEvent, + LicenseDowngradedEvent, + LicenseQuotaExceededEvent, + LicenseUpdatedEvent, + LicenseUpgradedEvent, +} from "@budibase/types" + +// TODO +export function updgraded(license: License) { + const properties: LicenseUpgradedEvent = {} + processEvent(Events.LICENSE_UPGRADED, properties) +} + +// TODO +export function downgraded(license: License) { + const properties: LicenseDowngradedEvent = {} + processEvent(Events.LICENSE_DOWNGRADED, properties) +} + +// TODO +export function updated(license: License) { + const properties: LicenseUpdatedEvent = {} + processEvent(Events.LICENSE_UPDATED, properties) +} + +// TODO +export function activated(license: License) { + const properties: LicenseActivatedEvent = {} + processEvent(Events.LICENSE_ACTIVATED, properties) +} + +// TODO +export function quotaExceeded(quotaName: string, value: number) { + const properties: LicenseQuotaExceededEvent = { + name: quotaName, + value, + } + processEvent(Events.LICENSE_QUOTA_EXCEEDED, properties) +} diff --git a/packages/backend-core/src/events/handlers/org.js b/packages/backend-core/src/events/handlers/org.js deleted file mode 100644 index fc5ad13c64..0000000000 --- a/packages/backend-core/src/events/handlers/org.js +++ /dev/null @@ -1,30 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -exports.nameUpdated = () => { - const properties = {} - events.processEvent(Events.ORG_NAME_UPDATED, properties) -} - -exports.logoUpdated = () => { - const properties = {} - events.processEvent(Events.ORG_LOGO_UPDATED, properties) -} - -exports.platformURLUpdated = () => { - const properties = {} - events.processEvent(Events.ORG_PLATFORM_URL_UPDATED, properties) -} - -exports.versionChecked = version => { - const properties = { - version, - } - events.processEvent(Events.UPDATE_VERSION_CHECKED, properties) -} - -// TODO -exports.analyticsOptOut = () => { - const properties = {} - events.processEvent(Events.ANALYTICS_OPT_OUT, properties) -} diff --git a/packages/backend-core/src/events/handlers/org.ts b/packages/backend-core/src/events/handlers/org.ts new file mode 100644 index 0000000000..3f8658f2f6 --- /dev/null +++ b/packages/backend-core/src/events/handlers/org.ts @@ -0,0 +1,30 @@ +import { processEvent } from "../events" +import { Events, VersionCheckedEvent } from "@budibase/types" + +export function nameUpdated() { + const properties = {} + processEvent(Events.ORG_NAME_UPDATED, properties) +} + +export function logoUpdated() { + const properties = {} + processEvent(Events.ORG_LOGO_UPDATED, properties) +} + +export function platformURLUpdated() { + const properties = {} + processEvent(Events.ORG_PLATFORM_URL_UPDATED, properties) +} + +export function versionChecked(version: number) { + const properties: VersionCheckedEvent = { + version, + } + processEvent(Events.UPDATE_VERSION_CHECKED, properties) +} + +// TODO +export function analyticsOptOut() { + const properties = {} + processEvent(Events.ANALYTICS_OPT_OUT, properties) +} diff --git a/packages/backend-core/src/events/handlers/query.js b/packages/backend-core/src/events/handlers/query.js deleted file mode 100644 index d878c79610..0000000000 --- a/packages/backend-core/src/events/handlers/query.js +++ /dev/null @@ -1,35 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -/* eslint-disable */ - -exports.created = (datasource, query) => { - const properties = {} - events.processEvent(Events.QUERY_CREATED, properties) -} - -exports.updated = (datasource, query) => { - const properties = {} - events.processEvent(Events.QUERY_UPDATED, properties) -} - -exports.deleted = (datasource, query) => { - const properties = {} - events.processEvent(Events.QUERY_DELETED, properties) -} - -exports.import = (datasource, importSource, count) => { - const properties = {} - events.processEvent(Events.QUERY_IMPORT, properties) -} - -// TODO -// exports.run = () => { -// const properties = {} -// events.processEvent(Events.QUERY_RUN, properties) -// } - -exports.previewed = datasource => { - const properties = {} - events.processEvent(Events.QUERY_PREVIEWED, properties) -} diff --git a/packages/backend-core/src/events/handlers/query.ts b/packages/backend-core/src/events/handlers/query.ts new file mode 100644 index 0000000000..bc173008bd --- /dev/null +++ b/packages/backend-core/src/events/handlers/query.ts @@ -0,0 +1,48 @@ +import { processEvent } from "../events" +import { + Events, + Datasource, + Query, + QueryCreatedEvent, + QueryUpdatedEvent, + QueryDeletedEvent, + QueryImportedEvent, + QueryPreviewedEvent, +} from "@budibase/types" + +/* eslint-disable */ + +export const created = (datasource: Datasource, query: Query) => { + const properties: QueryCreatedEvent = {} + processEvent(Events.QUERY_CREATED, properties) +} + +export const updated = (datasource: Datasource, query: Query) => { + const properties: QueryUpdatedEvent = {} + processEvent(Events.QUERY_UPDATED, properties) +} + +export const deleted = (datasource: Datasource, query: Query) => { + const properties: QueryDeletedEvent = {} + processEvent(Events.QUERY_DELETED, properties) +} + +export const imported = ( + datasource: Datasource, + importSource: any, + count: any +) => { + const properties: QueryImportedEvent = {} + processEvent(Events.QUERY_IMPORT, properties) +} + +// TODO +// exports.run = () => { +// const properties = {} +// events.processEvent(Events.QUERY_RUN, properties) +// } + +export const previewed = (datasource: Datasource) => { + const properties: QueryPreviewedEvent = {} + processEvent(Events.QUERY_PREVIEWED, properties) +} diff --git a/packages/backend-core/src/events/handlers/role.js b/packages/backend-core/src/events/handlers/role.js deleted file mode 100644 index 1181af01ed..0000000000 --- a/packages/backend-core/src/events/handlers/role.js +++ /dev/null @@ -1,29 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -/* eslint-disable */ - -exports.created = role => { - const properties = {} - events.processEvent(Events.ROLE_CREATED, properties) -} - -exports.updated = role => { - const properties = {} - events.processEvent(Events.ROLE_UPDATED, properties) -} - -exports.deleted = role => { - const properties = {} - events.processEvent(Events.ROLE_DELETED, properties) -} - -exports.assigned = (user, role) => { - const properties = {} - events.processEvent(Events.ROLE_ASSIGNED, properties) -} - -exports.unassigned = (user, role) => { - const properties = {} - events.processEvent(Events.ROLE_UNASSIGNED, properties) -} diff --git a/packages/backend-core/src/events/handlers/role.ts b/packages/backend-core/src/events/handlers/role.ts new file mode 100644 index 0000000000..e41b50389b --- /dev/null +++ b/packages/backend-core/src/events/handlers/role.ts @@ -0,0 +1,38 @@ +import { processEvent } from "../events" +import { + Events, + Role, + RoleAssignedEvent, + RoleCreatedEvent, + RoleDeletedEvent, + RoleUnassignedEvent, + RoleUpdatedEvent, + User, +} from "@budibase/types" + +/* eslint-disable */ + +export function created(role: Role) { + const properties: RoleCreatedEvent = {} + processEvent(Events.ROLE_CREATED, properties) +} + +export function updated(role: Role) { + const properties: RoleUpdatedEvent = {} + processEvent(Events.ROLE_UPDATED, properties) +} + +export function deleted(role: Role) { + const properties: RoleDeletedEvent = {} + processEvent(Events.ROLE_DELETED, properties) +} + +export function assigned(user: User, role: Role) { + const properties: RoleAssignedEvent = {} + processEvent(Events.ROLE_ASSIGNED, properties) +} + +export function unassigned(user: User, role: Role) { + const properties: RoleUnassignedEvent = {} + processEvent(Events.ROLE_UNASSIGNED, properties) +} diff --git a/packages/backend-core/src/events/handlers/row.js b/packages/backend-core/src/events/handlers/row.js deleted file mode 100644 index 28cb45645a..0000000000 --- a/packages/backend-core/src/events/handlers/row.js +++ /dev/null @@ -1,14 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -/* eslint-disable */ - -// exports.created = () => { -// const properties = {} -// events.processEvent(Events.ROW_CREATED, properties) -// } - -exports.import = (table, format, count) => { - const properties = {} - events.processEvent(Events.ROW_IMPORT, properties) -} diff --git a/packages/backend-core/src/events/handlers/row.ts b/packages/backend-core/src/events/handlers/row.ts new file mode 100644 index 0000000000..c5e34f786d --- /dev/null +++ b/packages/backend-core/src/events/handlers/row.ts @@ -0,0 +1,23 @@ +import { processEvent } from "../events" +import { + Events, + RowImportedEvent, + RowImportFormat, + Table, +} from "@budibase/types" + +/* eslint-disable */ + +// exports.created = () => { +// const properties = {} +// events.processEvent(Events.ROW_CREATED, properties) +// } + +export const imported = ( + table: Table, + format: RowImportFormat, + count: number +) => { + const properties: RowImportedEvent = {} + processEvent(Events.ROW_IMPORT, properties) +} diff --git a/packages/backend-core/src/events/handlers/screen.js b/packages/backend-core/src/events/handlers/screen.js deleted file mode 100644 index 0e2b4d268d..0000000000 --- a/packages/backend-core/src/events/handlers/screen.js +++ /dev/null @@ -1,12 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -exports.created = () => { - const properties = {} - events.processEvent(Events.SCREEN_CREATED, properties) -} - -exports.deleted = () => { - const properties = {} - events.processEvent(Events.SCREEN_DELETED, properties) -} diff --git a/packages/backend-core/src/events/handlers/screen.ts b/packages/backend-core/src/events/handlers/screen.ts new file mode 100644 index 0000000000..eade48bf30 --- /dev/null +++ b/packages/backend-core/src/events/handlers/screen.ts @@ -0,0 +1,17 @@ +import { processEvent } from "../events" +import { + Events, + Screen, + ScreenCreatedEvent, + ScreenDeletedEvent, +} from "@budibase/types" + +export function created(screen: Screen) { + const properties: ScreenCreatedEvent = {} + processEvent(Events.SCREEN_CREATED, properties) +} + +export function deleted(screen: Screen) { + const properties: ScreenDeletedEvent = {} + processEvent(Events.SCREEN_DELETED, properties) +} diff --git a/packages/backend-core/src/events/handlers/serve.js b/packages/backend-core/src/events/handlers/serve.js deleted file mode 100644 index 169d7338c2..0000000000 --- a/packages/backend-core/src/events/handlers/serve.js +++ /dev/null @@ -1,19 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -/* eslint-disable */ - -exports.servedBuilder = version => { - const properties = {} - events.processEvent(Events.SERVED_BUILDER, properties) -} - -exports.servedApp = appMetadata => { - const properties = {} - events.processEvent(Events.SERVED_APP, properties) -} - -exports.servedAppPreview = appMetadata => { - const properties = {} - events.processEvent(Events.SERVED_APP_PREVIEW, properties) -} diff --git a/packages/backend-core/src/events/handlers/serve.ts b/packages/backend-core/src/events/handlers/serve.ts new file mode 100644 index 0000000000..e7563432d7 --- /dev/null +++ b/packages/backend-core/src/events/handlers/serve.ts @@ -0,0 +1,25 @@ +import { AppServedEvent } from "./../../../../types/src/events/serve" +import { processEvent } from "../events" +import { + App, + BuilderServedEvent, + Events, + AppPreviewServedEvent, +} from "@budibase/types" + +/* eslint-disable */ + +export function servedBuilder(version: number) { + const properties: BuilderServedEvent = {} + processEvent(Events.SERVED_BUILDER, properties) +} + +export function servedApp(app: App) { + const properties: AppServedEvent = {} + processEvent(Events.SERVED_APP, properties) +} + +export function servedAppPreview(app: App) { + const properties: AppPreviewServedEvent = {} + processEvent(Events.SERVED_APP_PREVIEW, properties) +} diff --git a/packages/backend-core/src/events/handlers/table.js b/packages/backend-core/src/events/handlers/table.js deleted file mode 100644 index e212faad15..0000000000 --- a/packages/backend-core/src/events/handlers/table.js +++ /dev/null @@ -1,35 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -/* eslint-disable */ - -exports.created = table => { - const properties = {} - events.processEvent(Events.TABLE_CREATED, properties) -} - -exports.updated = table => { - const properties = {} - events.processEvent(Events.TABLE_UPDATED, properties) -} - -exports.deleted = table => { - const properties = {} - events.processEvent(Events.TABLE_DELETED, properties) -} - -exports.exported = (table, format) => { - const properties = {} - events.processEvent(Events.TABLE_EXPORTED, properties) -} - -exports.imported = (table, format) => { - const properties = {} - events.processEvent(Events.TABLE_IMPORTED, properties) -} - -// TODO -exports.permissionUpdated = () => { - const properties = {} - events.processEvent(Events.TABLE_PERMISSION_UPDATED, properties) -} diff --git a/packages/backend-core/src/events/handlers/table.ts b/packages/backend-core/src/events/handlers/table.ts new file mode 100644 index 0000000000..5ebadd14fd --- /dev/null +++ b/packages/backend-core/src/events/handlers/table.ts @@ -0,0 +1,45 @@ +import { processEvent } from "../events" +import { + Events, + TableExportFormat, + TableImportFormat, + Table, + TableCreatedEvent, + TableUpdatedEvent, + TableDeletedEvent, + TableExportedEvent, + TableImportedEvent, +} from "@budibase/types" + +/* eslint-disable */ + +export function created(table: Table) { + const properties: TableCreatedEvent = {} + processEvent(Events.TABLE_CREATED, properties) +} + +export function updated(table: Table) { + const properties: TableUpdatedEvent = {} + processEvent(Events.TABLE_UPDATED, properties) +} + +export function deleted(table: Table) { + const properties: TableDeletedEvent = {} + processEvent(Events.TABLE_DELETED, properties) +} + +export function exported(table: Table, format: TableExportFormat) { + const properties: TableExportedEvent = {} + processEvent(Events.TABLE_EXPORTED, properties) +} + +export function imported(table: Table, format: TableImportFormat) { + const properties: TableImportedEvent = {} + processEvent(Events.TABLE_IMPORTED, properties) +} + +// TODO +export function permissionUpdated() { + const properties = {} + processEvent(Events.TABLE_PERMISSION_UPDATED, properties) +} diff --git a/packages/backend-core/src/events/handlers/user.js b/packages/backend-core/src/events/handlers/user.js deleted file mode 100644 index ca6d541a7d..0000000000 --- a/packages/backend-core/src/events/handlers/user.js +++ /dev/null @@ -1,75 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -/* eslint-disable */ - -exports.created = user => { - const properties = {} - events.processEvent(Events.USER_CREATED, properties) -} - -exports.updated = user => { - const properties = {} - events.processEvent(Events.USER_UPDATED, properties) -} - -exports.deleted = user => { - const properties = {} - events.processEvent(Events.USER_DELETED, properties) -} - -// PERMISSIONS - -exports.permissionAdminAssigned = user => { - const properties = {} - events.processEvent(Events.USER_PERMISSION_ADMIN_ASSIGNED, properties) -} - -exports.permissionAdminRemoved = user => { - const properties = {} - events.processEvent(Events.USER_PERMISSION_ADMIN_REMOVED, properties) -} - -exports.permissionBuilderAssigned = user => { - const properties = {} - events.processEvent(Events.USER_PERMISSION_BUILDER_ASSIGNED, properties) -} - -exports.permissionBuilderRemoved = user => { - const properties = {} - events.processEvent(Events.USER_PERMISSION_BUILDER_REMOVED, properties) -} - -// INVITE - -exports.invited = userInfo => { - const properties = {} - events.processEvent(Events.USER_INVITED, properties) -} - -exports.inviteAccepted = user => { - const properties = {} - events.processEvent(Events.USER_INVITED_ACCEPTED, properties) -} - -// PASSWORD - -exports.passwordForceReset = user => { - const properties = {} - events.processEvent(Events.USER_PASSWORD_FORCE_RESET, properties) -} - -exports.passwordUpdated = user => { - const properties = {} - events.processEvent(Events.USER_PASSWORD_UPDATED, properties) -} - -exports.passwordResetRequested = user => { - const properties = {} - events.processEvent(Events.USER_PASSWORD_RESET_REQUESTED, properties) -} - -exports.passwordReset = user => { - const properties = {} - events.processEvent(Events.USER_PASSWORD_RESET, properties) -} diff --git a/packages/backend-core/src/events/handlers/user.ts b/packages/backend-core/src/events/handlers/user.ts new file mode 100644 index 0000000000..6328059cb1 --- /dev/null +++ b/packages/backend-core/src/events/handlers/user.ts @@ -0,0 +1,89 @@ +import { processEvent } from "../events" +import { + Events, + User, + UserCreatedEvent, + UserDeletedEvent, + UserInviteAcceptedEvent, + UserInvitedEvent, + UserPasswordForceResetEvent, + UserPasswordResetEvent, + UserPasswordResetRequestedEvent, + UserPasswordUpdatedEvent, + UserPermissionAssignedEvent, + UserPermissionRemovedEvent, + UserUpdatedEvent, +} from "@budibase/types" + +/* eslint-disable */ + +export function created(user: User) { + const properties: UserCreatedEvent = {} + processEvent(Events.USER_CREATED, properties) +} + +export function updated(user: User) { + const properties: UserUpdatedEvent = {} + processEvent(Events.USER_UPDATED, properties) +} + +export function deleted(user: User) { + const properties: UserDeletedEvent = {} + processEvent(Events.USER_DELETED, properties) +} + +// PERMISSIONS + +export function permissionAdminAssigned(user: User) { + const properties: UserPermissionAssignedEvent = {} + processEvent(Events.USER_PERMISSION_ADMIN_ASSIGNED, properties) +} + +export function permissionAdminRemoved(user: User) { + const properties: UserPermissionRemovedEvent = {} + processEvent(Events.USER_PERMISSION_ADMIN_REMOVED, properties) +} + +export function permissionBuilderAssigned(user: User) { + const properties: UserPermissionAssignedEvent = {} + processEvent(Events.USER_PERMISSION_BUILDER_ASSIGNED, properties) +} + +export function permissionBuilderRemoved(user: User) { + const properties: UserPermissionRemovedEvent = {} + processEvent(Events.USER_PERMISSION_BUILDER_REMOVED, properties) +} + +// INVITE + +export function invited(userInfo: any) { + const properties: UserInvitedEvent = {} + processEvent(Events.USER_INVITED, properties) +} + +export function inviteAccepted(user: User) { + const properties: UserInviteAcceptedEvent = {} + processEvent(Events.USER_INVITED_ACCEPTED, properties) +} + +// PASSWORD + +export function passwordForceReset(user: User) { + const properties: UserPasswordForceResetEvent = {} + processEvent(Events.USER_PASSWORD_FORCE_RESET, properties) +} + +export function passwordUpdated(user: User) { + const properties: UserPasswordUpdatedEvent = {} + processEvent(Events.USER_PASSWORD_UPDATED, properties) +} + +export function passwordResetRequested(user: User) { + const properties: UserPasswordResetRequestedEvent = {} + processEvent(Events.USER_PASSWORD_RESET_REQUESTED, properties) +} + +export function passwordReset(user: User) { + const properties: UserPasswordResetEvent = {} + processEvent(Events.USER_PASSWORD_RESET, properties) +} diff --git a/packages/backend-core/src/events/handlers/view.js b/packages/backend-core/src/events/handlers/view.js deleted file mode 100644 index 9c1c77ad63..0000000000 --- a/packages/backend-core/src/events/handlers/view.js +++ /dev/null @@ -1,54 +0,0 @@ -const events = require("../events") -const { Events } = require("../constants") - -/* eslint-disable */ - -exports.created = () => { - const properties = {} - events.processEvent(Events.VIEW_CREATED, properties) -} - -exports.updated = () => { - const properties = {} - events.processEvent(Events.VIEW_UPDATED, properties) -} - -exports.deleted = () => { - const properties = {} - events.processEvent(Events.VIEW_DELETED, properties) -} - -exports.exported = (table, format) => { - const properties = {} - events.processEvent(Events.VIEW_EXPORTED, properties) -} - -exports.filterCreated = () => { - const properties = {} - events.processEvent(Events.VIEW_FILTER_CREATED, properties) -} - -exports.filterUpdated = () => { - const properties = {} - events.processEvent(Events.VIEW_FILTER_UPDATED, properties) -} - -exports.filterDeleted = () => { - const properties = {} - events.processEvent(Events.VIEW_FILTER_DELETED, properties) -} - -exports.calculationCreated = () => { - const properties = {} - events.processEvent(Events.VIEW_CALCULATION_CREATED, properties) -} - -exports.calculationUpdated = () => { - const properties = {} - events.processEvent(Events.VIEW_CALCULATION_UPDATED, properties) -} - -exports.calculationDeleted = () => { - const properties = {} - events.processEvent(Events.VIEW_CALCULATION_DELETED, properties) -} diff --git a/packages/backend-core/src/events/handlers/view.ts b/packages/backend-core/src/events/handlers/view.ts new file mode 100644 index 0000000000..33975e64f8 --- /dev/null +++ b/packages/backend-core/src/events/handlers/view.ts @@ -0,0 +1,66 @@ +import { processEvent } from "../events" +import { + Events, + ViewCalculationCreatedEvent, + ViewCalculationDeletedEvent, + ViewCalculationUpdatedEvent, + ViewCreatedEvent, + ViewDeletedEvent, + ViewExportedEvent, + ViewFilterCreatedEvent, + ViewFilterDeletedEvent, + ViewFilterUpdatedEvent, + ViewUpdatedEvent, +} from "@budibase/types" + +/* eslint-disable */ + +export function created(view: View) { + const properties: ViewCreatedEvent = {} + processEvent(Events.VIEW_CREATED, properties) +} + +export function updated(view: View) { + const properties: ViewUpdatedEvent = {} + processEvent(Events.VIEW_UPDATED, properties) +} + +export function deleted() { + const properties: ViewDeletedEvent = {} + processEvent(Events.VIEW_DELETED, properties) +} + +export function exported(table, format) { + const properties: ViewExportedEvent = {} + processEvent(Events.VIEW_EXPORTED, properties) +} + +export function filterCreated() { + const properties: ViewFilterCreatedEvent = {} + processEvent(Events.VIEW_FILTER_CREATED, properties) +} + +export function filterUpdated() { + const properties: ViewFilterUpdatedEvent = {} + processEvent(Events.VIEW_FILTER_UPDATED, properties) +} + +export function filterDeleted() { + const properties: ViewFilterDeletedEvent = {} + processEvent(Events.VIEW_FILTER_DELETED, properties) +} + +export function calculationCreated() { + const properties: ViewCalculationCreatedEvent = {} + processEvent(Events.VIEW_CALCULATION_CREATED, properties) +} + +export function calculationUpdated() { + const properties: ViewCalculationUpdatedEvent = {} + processEvent(Events.VIEW_CALCULATION_UPDATED, properties) +} + +export function calculationDeleted() { + const properties: ViewCalculationDeletedEvent = {} + processEvent(Events.VIEW_CALCULATION_DELETED, properties) +} diff --git a/packages/backend-core/src/events/index.js b/packages/backend-core/src/events/index.js index 024194081b..92fa300a33 100644 --- a/packages/backend-core/src/events/index.js +++ b/packages/backend-core/src/events/index.js @@ -1,5 +1 @@ -const handlers = require("./handlers") - -module.exports = { - ...handlers, -} +export * from "./handlers" diff --git a/packages/backend-core/src/index.js b/packages/backend-core/src/index.js index b255567639..2752312c45 100644 --- a/packages/backend-core/src/index.js +++ b/packages/backend-core/src/index.js @@ -1,5 +1,6 @@ const db = require("./db") const errors = require("./errors") +import * as events from "./events" module.exports = { init(opts = {}) { @@ -23,7 +24,7 @@ module.exports = { accounts: require("./cloud/accounts"), tenancy: require("./tenancy"), featureFlags: require("./featureFlags"), - events: require("./events"), + events, analytics: require("./analytics"), sessions: require("./security/sessions"), deprovisioning: require("./context/deprovision"), diff --git a/packages/types/.gitignore b/packages/types/.gitignore new file mode 100644 index 0000000000..b4773960f9 --- /dev/null +++ b/packages/types/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +dist +coverage/ diff --git a/packages/types/package.json b/packages/types/package.json new file mode 100644 index 0000000000..248f18708a --- /dev/null +++ b/packages/types/package.json @@ -0,0 +1,18 @@ +{ + "name": "@budibase/types", + "version": "1.0.126-alpha.0", + "description": "Budibase types", + "main": "src/index.ts", + "types": "src/index.ts", + "author": "Budibase", + "license": "GPL-3.0", + "scripts": { + "build": "rimraf dist/ && tsc -p tsconfig.json" + }, + "jest": { + }, + "devDependencies": { + "@types/node": "^15.12.4", + "typescript": "^4.5.5" + } +} diff --git a/packages/types/src/api/public/.keep b/packages/types/src/api/public/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/types/src/api/web/.keep b/packages/types/src/api/web/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/types/src/documents/account/account.ts b/packages/types/src/documents/account/account.ts new file mode 100644 index 0000000000..bfafd9fd85 --- /dev/null +++ b/packages/types/src/documents/account/account.ts @@ -0,0 +1 @@ +export interface Account {} diff --git a/packages/types/src/documents/account/index.ts b/packages/types/src/documents/account/index.ts new file mode 100644 index 0000000000..20b4e77def --- /dev/null +++ b/packages/types/src/documents/account/index.ts @@ -0,0 +1 @@ +export * from "./account" diff --git a/packages/types/src/documents/app/app.ts b/packages/types/src/documents/app/app.ts new file mode 100644 index 0000000000..a27344a799 --- /dev/null +++ b/packages/types/src/documents/app/app.ts @@ -0,0 +1 @@ +export interface App {} diff --git a/packages/types/src/documents/app/automation.ts b/packages/types/src/documents/app/automation.ts new file mode 100644 index 0000000000..80a2afa543 --- /dev/null +++ b/packages/types/src/documents/app/automation.ts @@ -0,0 +1,5 @@ +export interface Automation {} + +export interface AutomationStep {} + +export interface AutomationTrigger {} diff --git a/packages/types/src/documents/app/datasource.ts b/packages/types/src/documents/app/datasource.ts new file mode 100644 index 0000000000..03e8ce7fe8 --- /dev/null +++ b/packages/types/src/documents/app/datasource.ts @@ -0,0 +1 @@ +export interface Datasource {} diff --git a/packages/types/src/documents/app/index.ts b/packages/types/src/documents/app/index.ts new file mode 100644 index 0000000000..9db35940bd --- /dev/null +++ b/packages/types/src/documents/app/index.ts @@ -0,0 +1,9 @@ +export * from "./app" +export * from "./automation" +export * from "./datasource" +export * from "./layout" +export * from "./query" +export * from "./role" +export * from "./table" +export * from "./screen" +export * from "./view" diff --git a/packages/types/src/documents/app/layout.ts b/packages/types/src/documents/app/layout.ts new file mode 100644 index 0000000000..4f0f85bd87 --- /dev/null +++ b/packages/types/src/documents/app/layout.ts @@ -0,0 +1 @@ +export interface Layout {} diff --git a/packages/types/src/documents/app/query.ts b/packages/types/src/documents/app/query.ts new file mode 100644 index 0000000000..ba038af326 --- /dev/null +++ b/packages/types/src/documents/app/query.ts @@ -0,0 +1 @@ +export interface Query {} diff --git a/packages/types/src/documents/app/role.ts b/packages/types/src/documents/app/role.ts new file mode 100644 index 0000000000..304e11b799 --- /dev/null +++ b/packages/types/src/documents/app/role.ts @@ -0,0 +1 @@ +export interface Role {} diff --git a/packages/types/src/documents/app/screen.ts b/packages/types/src/documents/app/screen.ts new file mode 100644 index 0000000000..1a88fe8db3 --- /dev/null +++ b/packages/types/src/documents/app/screen.ts @@ -0,0 +1 @@ +export interface Screen {} diff --git a/packages/types/src/documents/app/table.ts b/packages/types/src/documents/app/table.ts new file mode 100644 index 0000000000..74923f6554 --- /dev/null +++ b/packages/types/src/documents/app/table.ts @@ -0,0 +1 @@ +export interface Table {} diff --git a/packages/types/src/documents/app/view.ts b/packages/types/src/documents/app/view.ts new file mode 100644 index 0000000000..038e718355 --- /dev/null +++ b/packages/types/src/documents/app/view.ts @@ -0,0 +1 @@ +export interface View {} diff --git a/packages/types/src/documents/global/config.ts b/packages/types/src/documents/global/config.ts new file mode 100644 index 0000000000..6828cabc30 --- /dev/null +++ b/packages/types/src/documents/global/config.ts @@ -0,0 +1 @@ +export interface SMTPConfig {} diff --git a/packages/types/src/documents/global/index.ts b/packages/types/src/documents/global/index.ts new file mode 100644 index 0000000000..da01c73304 --- /dev/null +++ b/packages/types/src/documents/global/index.ts @@ -0,0 +1,2 @@ +export * from "./config" +export * from "./user" diff --git a/packages/types/src/documents/global/user.ts b/packages/types/src/documents/global/user.ts new file mode 100644 index 0000000000..e918b910d0 --- /dev/null +++ b/packages/types/src/documents/global/user.ts @@ -0,0 +1 @@ +export interface User {} diff --git a/packages/types/src/documents/index.ts b/packages/types/src/documents/index.ts new file mode 100644 index 0000000000..7938052425 --- /dev/null +++ b/packages/types/src/documents/index.ts @@ -0,0 +1,4 @@ +export * from "./account" +export * from "./app" +export * from "./global" +export * from "./platform" diff --git a/packages/types/src/documents/platform/index.ts b/packages/types/src/documents/platform/index.ts new file mode 100644 index 0000000000..ba329f1bd0 --- /dev/null +++ b/packages/types/src/documents/platform/index.ts @@ -0,0 +1 @@ +export * from "./info" diff --git a/packages/types/src/documents/platform/info.ts b/packages/types/src/documents/platform/info.ts new file mode 100644 index 0000000000..782ce5dd09 --- /dev/null +++ b/packages/types/src/documents/platform/info.ts @@ -0,0 +1 @@ +export interface GlobalInfo {} diff --git a/packages/types/src/events/app.ts b/packages/types/src/events/app.ts new file mode 100644 index 0000000000..429fb50114 --- /dev/null +++ b/packages/types/src/events/app.ts @@ -0,0 +1,21 @@ +export interface AppCreatedEvent {} + +export interface AppUpdatedEvent {} + +export interface AppDeletedEvent {} + +export interface AppPublishedEvent {} + +export interface AppUnpublishedEvent {} + +export interface AppFileImportedEvent {} + +export interface AppTemplateImportedEvent {} + +export interface AppVersionUpdatedEvent {} + +export interface AppVersionRevertedEvent {} + +export interface AppRevertedEvent {} + +export interface AppExportedEvent {} diff --git a/packages/types/src/events/auth.ts b/packages/types/src/events/auth.ts new file mode 100644 index 0000000000..aaa2cdd834 --- /dev/null +++ b/packages/types/src/events/auth.ts @@ -0,0 +1,16 @@ +export type LoginSource = "local" | "sso" +export type SSOType = "oidc" | "google" + +export interface LoginEvent { + source: LoginSource +} + +export interface LogoutEvent {} + +export interface SSOCreatedEvent {} + +export interface SSOUpdatedEvent {} + +export interface SSOActivatedEvent {} + +export interface SSODeactivatedEvent {} diff --git a/packages/types/src/events/automation.ts b/packages/types/src/events/automation.ts new file mode 100644 index 0000000000..699d130618 --- /dev/null +++ b/packages/types/src/events/automation.ts @@ -0,0 +1,11 @@ +export interface AutomationCreatedEvent {} + +export interface AutomationDeletedEvent {} + +export interface AutomationTestedEvent {} + +export interface AutomationStepCreatedEvent {} + +export interface AutomationStepDeletedEvent {} + +export interface AutomationTriggerUpdatedEvent {} diff --git a/packages/types/src/events/config.ts b/packages/types/src/events/config.ts new file mode 100644 index 0000000000..de3c5dc2dd --- /dev/null +++ b/packages/types/src/events/config.ts @@ -0,0 +1,3 @@ +export interface SMTPCreatedEvent {} + +export interface SMTPUpdatedEvent {} diff --git a/packages/types/src/events/datasource.ts b/packages/types/src/events/datasource.ts new file mode 100644 index 0000000000..2eca9e30f5 --- /dev/null +++ b/packages/types/src/events/datasource.ts @@ -0,0 +1,5 @@ +export interface DatasourceCreatedEvent {} + +export interface DatasourceUpdatedEvent {} + +export interface DatasourceDeletedEvent {} diff --git a/packages/types/src/events/events.ts b/packages/types/src/events/events.ts new file mode 100644 index 0000000000..9c6a6031e2 --- /dev/null +++ b/packages/types/src/events/events.ts @@ -0,0 +1,145 @@ +export enum Events { + // USER + USER_CREATED = "user:created", + USER_UPDATED = "user:updated", + USER_DELETED = "user:deleted", + + // USER / PERMISSIONS + USER_PERMISSION_ADMIN_ASSIGNED = "user:admin:assigned", + USER_PERMISSION_ADMIN_REMOVED = "user:admin:removed", + USER_PERMISSION_BUILDER_ASSIGNED = "user:builder:assigned", + USER_PERMISSION_BUILDER_REMOVED = "userbuilder:removed", + + // USER / INVITE + USER_INVITED = "user:invited", + USER_INVITED_ACCEPTED = "user:invite:accepted", + + // USER / PASSWORD + USER_PASSWORD_FORCE_RESET = "user:password:force:reset", + USER_PASSWORD_UPDATED = "user:password:updated", + USER_PASSWORD_RESET_REQUESTED = "user:password:reset:requested", + USER_PASSWORD_RESET = "user:password:reset", + + // EMAIL + EMAIL_SMTP_CREATED = "email:smtp:created", + EMAIL_SMTP_UPDATED = "email:smtp:updated", + + // AUTH + AUTH_SSO_CREATED = "auth:sso:created", + AUTH_SSO_UPDATED = "auth:sso:updated", + AUTH_SSO_ACTIVATED = "auth:sso:activated", + AUTH_SSO_DEACTIVATED = "auth:sso:deactivated", + AUTH_LOGIN = "auth:login", + AUTH_LOGOUT = "auth:logout", + + // ORG + ORG_NAME_UPDATED = "org:info:name:updated", + ORG_LOGO_UPDATED = "org:info:logo:updated", + ORG_PLATFORM_URL_UPDATED = "org:platformurl:updated", + + // ORG / UPDATE + UPDATE_VERSION_CHECKED = "version:checked", + + // ORG / ANALYTICS + ANALYTICS_OPT_OUT = "analytics:opt:out", + + // APP + APP_CREATED = "app:created", + APP_UPDATED = "app:updated", + APP_DELETED = "app:deleted", + APP_PUBLISHED = "app:published", + APP_UNPUBLISHED = "app:unpublished", + APP_TEMPLATE_IMPORTED = "app:template:imported", + APP_FILE_IMPORTED = "app:file:imported", + APP_VERSION_UPDATED = "app:version:updated", + APP_VERSION_REVERTED = "app:version:reverted", + APP_REVERTED = "app:reverted", + APP_EXPORTED = "app:exported", + + // ROLE + ROLE_CREATED = "role:created", + ROLE_UPDATED = "role:updated", + ROLE_DELETED = "role:deleted", + ROLE_ASSIGNED = "role:assigned", + ROLE_UNASSIGNED = "role:unassigned", + + // SERVE + SERVED_BUILDER = "served:builder", + SERVED_APP = "served:app", + SERVED_APP_PREVIEW = "served:app:preview", + + // DATASOURCE + DATASOURCE_CREATED = "datasource:created", + DATASOURCE_UPDATED = "datasource:updated", + DATASOURCE_DELETED = "datasource:deleted", + + // QUERY + QUERY_CREATED = "query:created", + QUERY_UPDATED = "query:updated", + QUERY_DELETED = "query:deleted", + QUERY_IMPORT = "query:import", + // QUERY_RUN = "query:run", + QUERY_PREVIEWED = "query:previewed", + + // TABLE + TABLE_CREATED = "table:created", + TABLE_UPDATED = "table:updated", + TABLE_DELETED = "table:deleted", + TABLE_EXPORTED = "table:exported", + TABLE_IMPORTED = "table:imported", + TABLE_DATA_IMPORTED = "table:data:imported", + TABLE_PERMISSION_UPDATED = "table:permission:updated", + + // VIEW + VIEW_CREATED = "view:created", + VIEW_UPDATED = "view:updated", + VIEW_DELETED = "view:deleted", + VIEW_EXPORTED = "view:exported", + VIEW_FILTER_CREATED = "view:filter:created", + VIEW_FILTER_UPDATED = "view:filter:updated", + VIEW_FILTER_DELETED = "view:filter:deleted", + VIEW_CALCULATION_CREATED = "view:calculation:created", + VIEW_CALCULATION_UPDATED = "view:calculation:updated", + VIEW_CALCULATION_DELETED = "view:calculation:deleted", + + // ROW + // ROW_CREATED = "row:created", + ROW_IMPORT = "row:import", + + // COMPONENT + COMPONENT_CREATED = "component:created", + COMPONENT_DELETED = "component:deleted", + + // SCREEN + SCREEN_CREATED = "screen:created", + SCREEN_DELETED = "screen:deleted", + + // LAYOUT + LAYOUT_CREATED = "layout:created", + LAYOUT_DELETED = "layout:deleted", + + // AUTOMATION + AUTOMATION_CREATED = "automation:created", + AUTOMATION_DELETED = "automation:deleted", + AUTOMATION_TESTED = "automation:tested", + // AUTOMATION_RUN = "automation:run", + AUTOMATION_STEP_CREATED = "automation:step:created", + AUTOMATION_STEP_DELETED = "automation:step:deleted", + AUTOMATION_TRIGGER_UPDATED = "automation:trigger:updated", + + // LICENSE + LICENSE_UPGRADED = "license:upgraded", + LICENSE_DOWNGRADED = "license:downgraded", + LICENSE_UPDATED = "license:updated", + LICENSE_ACTIVATED = "license:activated", + LICENSE_QUOTA_EXCEEDED = "license:quota:exceeded", + + // ACCOUNT + ACCOUNT_CREATED = "account:created", + ACCOUNT_DELETED = "account:deleted", + ACCOUNT_VERIFIED = "account:verified", +} + +export type RowImportFormat = "csv" +export type TableExportFormat = "json" | "csv" +export type TableImportFormat = "csv" diff --git a/packages/types/src/events/index.ts b/packages/types/src/events/index.ts new file mode 100644 index 0000000000..22a3f9af8d --- /dev/null +++ b/packages/types/src/events/index.ts @@ -0,0 +1,17 @@ +export * from "./app" +export * from "./auth" +export * from "./automation" +export * from "./config" +export * from "./datasource" +export * from "./events" +export * from "./layout" +export * from "./license" +export * from "./org" +export * from "./query" +export * from "./role" +export * from "./row" +export * from "./screen" +export * from "./serve" +export * from "./table" +export * from "./user" +export * from "./view" diff --git a/packages/types/src/events/layout.ts b/packages/types/src/events/layout.ts new file mode 100644 index 0000000000..fbfac2c411 --- /dev/null +++ b/packages/types/src/events/layout.ts @@ -0,0 +1,3 @@ +export interface LayoutCreatedEvent {} + +export interface LayoutDeletedEvent {} diff --git a/packages/types/src/events/license.ts b/packages/types/src/events/license.ts new file mode 100644 index 0000000000..2fa1f0b6cf --- /dev/null +++ b/packages/types/src/events/license.ts @@ -0,0 +1,9 @@ +export interface LicenseUpgradedEvent {} + +export interface LicenseDowngradedEvent {} + +export interface LicenseUpdatedEvent {} + +export interface LicenseActivatedEvent {} + +export interface LicenseQuotaExceededEvent {} diff --git a/packages/types/src/events/org.ts b/packages/types/src/events/org.ts new file mode 100644 index 0000000000..8d0243366e --- /dev/null +++ b/packages/types/src/events/org.ts @@ -0,0 +1 @@ +export interface VersionCheckedEvent {} diff --git a/packages/types/src/events/query.ts b/packages/types/src/events/query.ts new file mode 100644 index 0000000000..4a89c38f79 --- /dev/null +++ b/packages/types/src/events/query.ts @@ -0,0 +1,9 @@ +export interface QueryCreatedEvent {} + +export interface QueryUpdatedEvent {} + +export interface QueryDeletedEvent {} + +export interface QueryImportedEvent {} + +export interface QueryPreviewedEvent {} diff --git a/packages/types/src/events/role.ts b/packages/types/src/events/role.ts new file mode 100644 index 0000000000..45e6c84938 --- /dev/null +++ b/packages/types/src/events/role.ts @@ -0,0 +1,9 @@ +export interface RoleCreatedEvent {} + +export interface RoleUpdatedEvent {} + +export interface RoleDeletedEvent {} + +export interface RoleAssignedEvent {} + +export interface RoleUnassignedEvent {} diff --git a/packages/types/src/events/row.ts b/packages/types/src/events/row.ts new file mode 100644 index 0000000000..3d4d093e80 --- /dev/null +++ b/packages/types/src/events/row.ts @@ -0,0 +1 @@ +export interface RowImportedEvent {} diff --git a/packages/types/src/events/screen.ts b/packages/types/src/events/screen.ts new file mode 100644 index 0000000000..5c7e2952e7 --- /dev/null +++ b/packages/types/src/events/screen.ts @@ -0,0 +1,3 @@ +export interface ScreenCreatedEvent {} + +export interface ScreenDeletedEvent {} diff --git a/packages/types/src/events/serve.ts b/packages/types/src/events/serve.ts new file mode 100644 index 0000000000..f3fd21dd15 --- /dev/null +++ b/packages/types/src/events/serve.ts @@ -0,0 +1,5 @@ +export interface BuilderServedEvent {} + +export interface AppServedEvent {} + +export interface AppPreviewServedEvent {} diff --git a/packages/types/src/events/table.ts b/packages/types/src/events/table.ts new file mode 100644 index 0000000000..2a3c5ef2aa --- /dev/null +++ b/packages/types/src/events/table.ts @@ -0,0 +1,9 @@ +export interface TableCreatedEvent {} + +export interface TableUpdatedEvent {} + +export interface TableDeletedEvent {} + +export interface TableExportedEvent {} + +export interface TableImportedEvent {} diff --git a/packages/types/src/events/user.ts b/packages/types/src/events/user.ts new file mode 100644 index 0000000000..df75dd1158 --- /dev/null +++ b/packages/types/src/events/user.ts @@ -0,0 +1,21 @@ +export interface UserCreatedEvent {} + +export interface UserUpdatedEvent {} + +export interface UserDeletedEvent {} + +export interface UserPermissionAssignedEvent {} + +export interface UserPermissionRemovedEvent {} + +export interface UserInvitedEvent {} + +export interface UserInviteAcceptedEvent {} + +export interface UserPasswordForceResetEvent {} + +export interface UserPasswordUpdatedEvent {} + +export interface UserPasswordResetRequestedEvent {} + +export interface UserPasswordResetEvent {} diff --git a/packages/types/src/events/view.ts b/packages/types/src/events/view.ts new file mode 100644 index 0000000000..eec8992002 --- /dev/null +++ b/packages/types/src/events/view.ts @@ -0,0 +1,19 @@ +export interface ViewCreatedEvent {} + +export interface ViewUpdatedEvent {} + +export interface ViewDeletedEvent {} + +export interface ViewExportedEvent {} + +export interface ViewFilterCreatedEvent {} + +export interface ViewFilterUpdatedEvent {} + +export interface ViewFilterDeletedEvent {} + +export interface ViewCalculationCreatedEvent {} + +export interface ViewCalculationUpdatedEvent {} + +export interface ViewCalculationDeletedEvent {} diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts new file mode 100644 index 0000000000..b6c01a2fe5 --- /dev/null +++ b/packages/types/src/index.ts @@ -0,0 +1,3 @@ +export * from "./documents" +export * from "./events" +export * from "./licensing" diff --git a/packages/types/src/licensing/index.ts b/packages/types/src/licensing/index.ts new file mode 100644 index 0000000000..e6080073b7 --- /dev/null +++ b/packages/types/src/licensing/index.ts @@ -0,0 +1 @@ +export * from "./license" diff --git a/packages/types/src/licensing/license.ts b/packages/types/src/licensing/license.ts new file mode 100644 index 0000000000..ed2e0a0245 --- /dev/null +++ b/packages/types/src/licensing/license.ts @@ -0,0 +1 @@ +export interface License {} diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json new file mode 100644 index 0000000000..86a066fec8 --- /dev/null +++ b/packages/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "lib": ["es2020"], + "outDir": "dist", + "strict": true, + "noImplicitAny": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "incremental": true, + "types": [ "node"], + }, + "include": [ + "**/*.ts", + ] +} diff --git a/packages/types/yarn.lock b/packages/types/yarn.lock new file mode 100644 index 0000000000..536b5c836c --- /dev/null +++ b/packages/types/yarn.lock @@ -0,0 +1,13 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/node@^15.12.4": + version "15.14.9" + resolved "https://registry.yarnpkg.com/@types/node/-/node-15.14.9.tgz#bc43c990c3c9be7281868bbc7b8fdd6e2b57adfa" + integrity sha512-qjd88DrCxupx/kJD5yQgZdcYKZKSIGBVDIBE1/LTGcNm3d2Np/jxojkdePDdfnBHJc5W7vSMpbJ1aB7p/Py69A== + +typescript@^4.5.5: + version "4.6.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9" + integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==