1
0
Fork 0
mirror of synced 2024-06-14 08:24:48 +12:00

Add ts watch support for backend-core + stub out migrations

This commit is contained in:
Rory Powell 2022-05-04 11:22:50 +01:00
parent 606d21b313
commit 23cbd217cd
22 changed files with 87 additions and 13 deletions

View file

@ -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"
},

View file

@ -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"),

View file

@ -3,6 +3,7 @@
"extends": "./tsconfig.json",
"exclude": [
"node_modules",
"dist/**/*",
"**/*.json",
"**/*.spec.js",
"**/*.spec.ts"

View file

@ -29,6 +29,7 @@
],
"exclude": [
"node_modules",
"dist/**/*",
"**/*.spec.js",
// "**/*.spec.ts" // don't exclude spec.ts files for editor support
]

View file

@ -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"
}

View file

@ -0,0 +1,4 @@
// TODO: Add migrations to account portal
// ACCOUNT_CREATED = "account:created",
// ACCOUNT_VERIFIED = "account:verified",

View file

@ -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",

View file

@ -0,0 +1,2 @@
// AUTOMATION_CREATED = "automation:created",
// AUTOMATION_STEP_CREATED = "automation:step:created",

View file

@ -0,0 +1 @@
// DATASOURCE_CREATED = "datasource:created",

View file

@ -0,0 +1 @@
// LAYOUT_CREATED = "layout:created",

View file

@ -0,0 +1,3 @@
// QUERY_CREATED = "query:created",
// <!-- maybe -->
// QUERY_IMPORT = "query:import",

View file

@ -0,0 +1,2 @@
// ROLE_CREATED = "role:created",
// ROLE_ASSIGNED = "role:assigned",

View file

@ -0,0 +1 @@
// ROW_IMPORT = "row:import",

View file

@ -0,0 +1 @@
// SCREEN_CREATED = "screen:created",

View file

@ -0,0 +1,3 @@
// TABLE_CREATED = "table:created",
// <!-- maybe -->
// TABLE_DATA_IMPORTED = "table:data:imported",

View file

@ -0,0 +1,3 @@
// VIEW_CREATED = "view:created",
// VIEW_FILTER_CREATED = "view:filter:created",
// VIEW_CALCULATION_CREATED = "view:calculation:created",

View file

@ -0,0 +1,11 @@
import * as app from "./app/app"
/**
* Date:
* May 2022
*
* Description:
* Backfill app events.
*/
export const run = async (db: any) => {}

View file

@ -0,0 +1,11 @@
import * as syncPublishedApps from "../usageQuotas/syncPublishedApps"
/**
* Date:
* May 2022
*
* Description:
* Backfill global events.
*/
export const run = async (db: any) => {}

View file

@ -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",

View file

@ -0,0 +1,3 @@
// USER_CREATED = "user:created",
// USER_PERMISSION_ADMIN_ASSIGNED = "user:admin:assigned",
// USER_PERMISSION_BUILDER_ASSIGNED = "user:builder:assigned",

View file

@ -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)
}

View file

@ -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"
}