diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 5d95315006..5ff88b6664 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -8,6 +8,7 @@ "license": "GPL-3.0", "scripts": { "build": "rimraf dist/ && tsc -p tsconfig.build.json", + "dev:builder": "rimraf dist/ && tsc -p tsconfig.build.json --watch", "test": "jest", "test:watch": "jest --watchAll" }, diff --git a/packages/backend-core/src/index.ts b/packages/backend-core/src/index.ts index 0003af280c..dab77d130a 100644 --- a/packages/backend-core/src/index.ts +++ b/packages/backend-core/src/index.ts @@ -1,6 +1,7 @@ import db from "./db" import errors from "./errors" import * as events from "./events" +import * as migrations from "./migrations" export = { init(opts: any = {}) { @@ -17,7 +18,7 @@ export = { cache: require("../cache"), auth: require("../auth"), constants: require("../constants"), - migrations: require("../migrations"), + migrations, errors, ...errors.errors, env: require("./environment"), diff --git a/packages/backend-core/tsconfig.build.json b/packages/backend-core/tsconfig.build.json index 9c67698e91..57783aab7a 100644 --- a/packages/backend-core/tsconfig.build.json +++ b/packages/backend-core/tsconfig.build.json @@ -3,6 +3,7 @@ "extends": "./tsconfig.json", "exclude": [ "node_modules", + "dist/**/*", "**/*.json", "**/*.spec.js", "**/*.spec.ts" diff --git a/packages/backend-core/tsconfig.json b/packages/backend-core/tsconfig.json index 5f9000c18f..373b8440f7 100644 --- a/packages/backend-core/tsconfig.json +++ b/packages/backend-core/tsconfig.json @@ -29,6 +29,7 @@ ], "exclude": [ "node_modules", + "dist/**/*", "**/*.spec.js", // "**/*.spec.ts" // don't exclude spec.ts files for editor support ] diff --git a/packages/server/nodemon.json b/packages/server/nodemon.json index a979dfb1cb..c27f3aeaf3 100644 --- a/packages/server/nodemon.json +++ b/packages/server/nodemon.json @@ -1,6 +1,6 @@ { "watch": ["src", "../backend-core", "../../../budibase-pro/packages/pro"], "ext": "js,ts,json", - "ignore": ["src/**/*.spec.ts", "src/**/*.spec.js"], + "ignore": ["src/**/*.spec.ts", "src/**/*.spec.js", "../backend-core/dist/**/*"], "exec": "ts-node src/index.ts" } \ No newline at end of file diff --git a/packages/server/src/migrations/functions/backfill/app/account.ts b/packages/server/src/migrations/functions/backfill/app/account.ts new file mode 100644 index 0000000000..2fe7003437 --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/app/account.ts @@ -0,0 +1,4 @@ +// TODO: Add migrations to account portal + +// ACCOUNT_CREATED = "account:created", +// ACCOUNT_VERIFIED = "account:verified", diff --git a/packages/server/src/migrations/functions/backfill/app/app.ts b/packages/server/src/migrations/functions/backfill/app/app.ts new file mode 100644 index 0000000000..6ebfc48297 --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/app/app.ts @@ -0,0 +1,10 @@ +export const backfillAppCreated = () => {} + +export const backfillAppPublished = () => {} + +// APP_CREATED = "app:created", +// APP_PUBLISHED = "app:published", + +// Maybe +// APP_TEMPLATE_IMPORTED = "app:template:imported", +// APP_FILE_IMPORTED = "app:file:imported", diff --git a/packages/server/src/migrations/functions/backfill/app/automation.ts b/packages/server/src/migrations/functions/backfill/app/automation.ts new file mode 100644 index 0000000000..a1f908b8b5 --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/app/automation.ts @@ -0,0 +1,2 @@ +// AUTOMATION_CREATED = "automation:created", +// AUTOMATION_STEP_CREATED = "automation:step:created", diff --git a/packages/server/src/migrations/functions/backfill/app/datasource.ts b/packages/server/src/migrations/functions/backfill/app/datasource.ts new file mode 100644 index 0000000000..1830d54924 --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/app/datasource.ts @@ -0,0 +1 @@ +// DATASOURCE_CREATED = "datasource:created", diff --git a/packages/server/src/migrations/functions/backfill/app/layout.ts b/packages/server/src/migrations/functions/backfill/app/layout.ts new file mode 100644 index 0000000000..e69d79238b --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/app/layout.ts @@ -0,0 +1 @@ +// LAYOUT_CREATED = "layout:created", diff --git a/packages/server/src/migrations/functions/backfill/app/query.ts b/packages/server/src/migrations/functions/backfill/app/query.ts new file mode 100644 index 0000000000..79b56466e3 --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/app/query.ts @@ -0,0 +1,3 @@ +// QUERY_CREATED = "query:created", +// +// QUERY_IMPORT = "query:import", diff --git a/packages/server/src/migrations/functions/backfill/app/role.ts b/packages/server/src/migrations/functions/backfill/app/role.ts new file mode 100644 index 0000000000..34cbd19569 --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/app/role.ts @@ -0,0 +1,2 @@ +// ROLE_CREATED = "role:created", +// ROLE_ASSIGNED = "role:assigned", diff --git a/packages/server/src/migrations/functions/backfill/app/row.ts b/packages/server/src/migrations/functions/backfill/app/row.ts new file mode 100644 index 0000000000..52b0664231 --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/app/row.ts @@ -0,0 +1 @@ +// ROW_IMPORT = "row:import", diff --git a/packages/server/src/migrations/functions/backfill/app/screen.ts b/packages/server/src/migrations/functions/backfill/app/screen.ts new file mode 100644 index 0000000000..d000321625 --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/app/screen.ts @@ -0,0 +1 @@ +// SCREEN_CREATED = "screen:created", diff --git a/packages/server/src/migrations/functions/backfill/app/table.ts b/packages/server/src/migrations/functions/backfill/app/table.ts new file mode 100644 index 0000000000..116e7bbbdf --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/app/table.ts @@ -0,0 +1,3 @@ +// TABLE_CREATED = "table:created", +// +// TABLE_DATA_IMPORTED = "table:data:imported", diff --git a/packages/server/src/migrations/functions/backfill/app/view.ts b/packages/server/src/migrations/functions/backfill/app/view.ts new file mode 100644 index 0000000000..f9f4544f0d --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/app/view.ts @@ -0,0 +1,3 @@ +// VIEW_CREATED = "view:created", +// VIEW_FILTER_CREATED = "view:filter:created", +// VIEW_CALCULATION_CREATED = "view:calculation:created", diff --git a/packages/server/src/migrations/functions/backfill/event_app_backfill.ts b/packages/server/src/migrations/functions/backfill/event_app_backfill.ts new file mode 100644 index 0000000000..5b46959b5b --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/event_app_backfill.ts @@ -0,0 +1,11 @@ +import * as app from "./app/app" + +/** + * Date: + * May 2022 + * + * Description: + * Backfill app events. + */ + +export const run = async (db: any) => {} diff --git a/packages/server/src/migrations/functions/backfill/event_backfill.ts b/packages/server/src/migrations/functions/backfill/event_backfill.ts new file mode 100644 index 0000000000..d010c1c149 --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/event_backfill.ts @@ -0,0 +1,11 @@ +import * as syncPublishedApps from "../usageQuotas/syncPublishedApps" + +/** + * Date: + * May 2022 + * + * Description: + * Backfill global events. + */ + +export const run = async (db: any) => {} diff --git a/packages/server/src/migrations/functions/backfill/global/config.ts b/packages/server/src/migrations/functions/backfill/global/config.ts new file mode 100644 index 0000000000..2c058952ca --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/global/config.ts @@ -0,0 +1,7 @@ +// EMAIL_SMTP_CREATED = "email:smtp:created", +// AUTH_SSO_CREATED = "auth:sso:created", +// AUTH_SSO_ACTIVATED = "auth:sso:activated", +// AUTH_SSO_DEACTIVATED = "auth:sso:deactivated", +// ORG_NAME_UPDATED = "org:info:name:updated", +// ORG_LOGO_UPDATED = "org:info:logo:updated", +// ORG_PLATFORM_URL_UPDATED = "org:platformurl:updated", diff --git a/packages/server/src/migrations/functions/backfill/global/user.ts b/packages/server/src/migrations/functions/backfill/global/user.ts new file mode 100644 index 0000000000..52eadeb3be --- /dev/null +++ b/packages/server/src/migrations/functions/backfill/global/user.ts @@ -0,0 +1,3 @@ +// USER_CREATED = "user:created", +// USER_PERMISSION_ADMIN_ASSIGNED = "user:admin:assigned", +// USER_PERMISSION_BUILDER_ASSIGNED = "user:builder:assigned", diff --git a/packages/server/src/migrations/index.ts b/packages/server/src/migrations/index.ts index 6d63d81544..bf2e8f6aca 100644 --- a/packages/server/src/migrations/index.ts +++ b/packages/server/src/migrations/index.ts @@ -1,7 +1,4 @@ -const { - MIGRATION_TYPES, - runMigrations, -} = require("@budibase/backend-core/migrations") +import { migrations } from "@budibase/backend-core" // migration functions import * as userEmailViewCasing from "./functions/userEmailViewCasing" @@ -35,33 +32,43 @@ export interface MigrationOptions { export const MIGRATIONS: Migration[] = [ { - type: MIGRATION_TYPES.GLOBAL, + type: migrations.MIGRATION_TYPES.GLOBAL, name: "user_email_view_casing", fn: userEmailViewCasing.run, }, { - type: MIGRATION_TYPES.GLOBAL, + type: migrations.MIGRATION_TYPES.GLOBAL, name: "quotas_1", fn: quota1.run, }, { - type: MIGRATION_TYPES.APP, + type: migrations.MIGRATION_TYPES.APP, name: "app_urls", opts: { all: true }, fn: appUrls.run, }, { - type: MIGRATION_TYPES.GLOBAL, + type: migrations.MIGRATION_TYPES.GLOBAL, name: "developer_quota", fn: developerQuota.run, }, { - type: MIGRATION_TYPES.GLOBAL, + type: migrations.MIGRATION_TYPES.GLOBAL, name: "published_apps_quota", fn: publishedAppsQuota.run, }, + { + type: migrations.MIGRATION_TYPES.GLOBAL, + name: "event_backfill", + fn: publishedAppsQuota.run, + }, + { + type: migrations.MIGRATION_TYPES.APP, + name: "event_app_backfill", + fn: publishedAppsQuota.run, + }, ] export const migrate = async (options?: MigrationOptions) => { - await runMigrations(MIGRATIONS, options) + await migrations.runMigrations(MIGRATIONS, options) } diff --git a/packages/worker/nodemon.json b/packages/worker/nodemon.json index 3b941c4d0f..e5184939ff 100644 --- a/packages/worker/nodemon.json +++ b/packages/worker/nodemon.json @@ -1,6 +1,6 @@ { "watch": ["src", "../backend-core", "../../../budibase-pro/packages/pro"], "ext": "js,ts,json", - "ignore": ["src/**/*.spec.ts", "src/**/*.spec.js"], + "ignore": ["src/**/*.spec.ts", "src/**/*.spec.js", "../backend-core/dist/**/*"], "exec": "ts-node src/index.ts" }