@budibase/server 2.0.30-alpha.14 → 2.0.30-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builder/assets/backups-default.8c011f1b.png +0 -0
- package/builder/assets/{index.099ad307.js → index.7ebb4fb6.js} +333 -329
- package/builder/assets/{index.acdbfe62.css → index.b15ffe95.css} +1 -1
- package/builder/index.html +2 -2
- package/coverage/clover.xml +254 -313
- package/coverage/coverage-final.json +15 -17
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +74 -62
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +17 -32
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +12 -9
- package/coverage/lcov-report/api/controllers/table/external.js.html +10 -10
- package/coverage/lcov-report/api/controllers/table/index.html +16 -16
- package/coverage/lcov-report/api/controllers/table/index.js.html +5 -5
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +3 -3
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +3 -3
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +5 -20
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +6 -6
- package/coverage/lcov-report/automations/bullboard.js.html +17 -92
- package/coverage/lcov-report/automations/index.html +18 -18
- package/coverage/lcov-report/automations/index.js.html +5 -5
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +5 -5
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +6 -18
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +19 -19
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +35 -308
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +62 -62
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/plugins.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +52 -52
- package/coverage/lcov-report/utilities/queue/index.html +21 -21
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +451 -564
- package/dist/api/controllers/application.js +2 -5
- package/dist/api/controllers/backup.js +19 -13
- package/dist/api/controllers/cloud.js +38 -35
- package/dist/api/controllers/deploy/index.js +11 -2
- package/dist/api/controllers/static/index.js +2 -2
- package/dist/api/controllers/table/bulkFormula.js +4 -3
- package/dist/api/controllers/table/external.js +5 -4
- package/dist/api/controllers/table/index.js +4 -4
- package/dist/api/controllers/table/internal.js +2 -1
- package/dist/api/controllers/table/utils.js +4 -48
- package/dist/api/controllers/view/index.js +2 -2
- package/dist/api/routes/backup.js +34 -7
- package/dist/api/routes/index.js +9 -4
- package/dist/app.js +14 -0
- package/dist/automations/automationUtils.js +2 -2
- package/dist/automations/bullboard.js +5 -33
- package/dist/automations/index.js +4 -4
- package/dist/automations/triggers.js +4 -4
- package/dist/automations/utils.js +13 -9
- package/dist/constants/index.js +2 -5
- package/dist/db/utils.js +10 -75
- package/dist/migrations/functions/backfill/app/tables.js +5 -8
- package/dist/package.json +11 -11
- package/dist/sdk/app/backups/constants.js +5 -0
- package/dist/sdk/app/backups/exports.js +172 -0
- package/dist/sdk/app/backups/imports.js +162 -0
- package/dist/sdk/app/backups/index.js +29 -0
- package/dist/sdk/app/backups/statistics.js +73 -0
- package/dist/sdk/app/tables/index.js +61 -0
- package/dist/sdk/index.js +15 -0
- package/dist/tests/utilities/TestConfiguration.js +4 -2
- package/dist/threads/automation.js +12 -17
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +3 -95
- package/dist/utilities/fileSystem/utilities.js +2 -1
- package/package.json +12 -12
- package/src/api/controllers/application.ts +3 -10
- package/src/api/controllers/{backup.js → backup.ts} +7 -7
- package/src/api/controllers/cloud.js +44 -40
- package/src/api/controllers/deploy/index.ts +20 -7
- package/src/api/controllers/static/index.ts +2 -2
- package/src/api/controllers/table/bulkFormula.js +4 -3
- package/src/api/controllers/table/external.js +4 -4
- package/src/api/controllers/table/index.js +4 -4
- package/src/api/controllers/table/internal.ts +3 -7
- package/src/api/controllers/table/utils.ts +1 -52
- package/src/api/controllers/view/index.js +2 -2
- package/src/api/routes/backup.ts +10 -0
- package/src/api/routes/index.ts +11 -5
- package/src/api/routes/tests/backup.spec.js +1 -1
- package/src/api/routes/tests/{deployment.spec.js → deployment.spec.ts} +4 -4
- package/src/app.ts +15 -0
- package/src/automations/automationUtils.js +2 -2
- package/src/automations/bullboard.js +8 -33
- package/src/automations/index.js +4 -4
- package/src/automations/triggers.js +4 -4
- package/src/automations/utils.ts +12 -8
- package/src/constants/index.js +2 -6
- package/src/db/utils.js +17 -108
- package/src/definitions/automations.ts +0 -12
- package/src/migrations/functions/backfill/app/tables.ts +6 -13
- package/src/sdk/app/backups/constants.ts +2 -0
- package/src/sdk/app/backups/exports.ts +171 -0
- package/src/sdk/app/backups/imports.ts +168 -0
- package/src/sdk/app/backups/index.ts +9 -0
- package/src/sdk/app/backups/statistics.ts +77 -0
- package/src/sdk/app/tables/index.ts +60 -0
- package/src/sdk/index.ts +13 -0
- package/src/tests/utilities/TestConfiguration.js +5 -2
- package/src/threads/automation.ts +20 -27
- package/src/utilities/fileSystem/index.js +2 -119
- package/src/utilities/fileSystem/utilities.js +2 -0
- package/coverage/lcov-report/api/controllers/backup.js.html +0 -142
- package/coverage/lcov-report/api/routes/backup.js.html +0 -115
- package/dist/automations/listeners.js +0 -102
- package/src/api/routes/backup.js +0 -10
- package/src/automations/listeners.ts +0 -78
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { transform } from "../../../utilities/csvParser"
|
|
2
|
-
import {
|
|
3
|
-
getRowParams,
|
|
4
|
-
generateRowID,
|
|
5
|
-
InternalTables,
|
|
6
|
-
getTableParams,
|
|
7
|
-
BudibaseInternalDB,
|
|
8
|
-
} from "../../../db/utils"
|
|
2
|
+
import { getRowParams, generateRowID, InternalTables } from "../../../db/utils"
|
|
9
3
|
import { isEqual } from "lodash"
|
|
10
4
|
import { AutoFieldSubTypes, FieldTypes } from "../../../constants"
|
|
11
5
|
import {
|
|
@@ -17,11 +11,6 @@ import {
|
|
|
17
11
|
SwitchableTypes,
|
|
18
12
|
CanSwitchTypes,
|
|
19
13
|
} from "../../../constants"
|
|
20
|
-
import {
|
|
21
|
-
isExternalTable,
|
|
22
|
-
breakExternalTableId,
|
|
23
|
-
isSQL,
|
|
24
|
-
} from "../../../integrations/utils"
|
|
25
14
|
import { getViews, saveView } from "../view/utils"
|
|
26
15
|
import viewTemplate from "../view/viewBuilder"
|
|
27
16
|
const { getAppDB } = require("@budibase/backend-core/context")
|
|
@@ -256,46 +245,6 @@ class TableSaveFunctions {
|
|
|
256
245
|
}
|
|
257
246
|
}
|
|
258
247
|
|
|
259
|
-
export async function getAllInternalTables() {
|
|
260
|
-
const db = getAppDB()
|
|
261
|
-
const internalTables = await db.allDocs(
|
|
262
|
-
getTableParams(null, {
|
|
263
|
-
include_docs: true,
|
|
264
|
-
})
|
|
265
|
-
)
|
|
266
|
-
return internalTables.rows.map((tableDoc: any) => ({
|
|
267
|
-
...tableDoc.doc,
|
|
268
|
-
type: "internal",
|
|
269
|
-
sourceId: BudibaseInternalDB._id,
|
|
270
|
-
}))
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export async function getAllExternalTables(datasourceId: any) {
|
|
274
|
-
const db = getAppDB()
|
|
275
|
-
const datasource = await db.get(datasourceId)
|
|
276
|
-
if (!datasource || !datasource.entities) {
|
|
277
|
-
throw "Datasource is not configured fully."
|
|
278
|
-
}
|
|
279
|
-
return datasource.entities
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export async function getExternalTable(datasourceId: any, tableName: any) {
|
|
283
|
-
const entities = await getAllExternalTables(datasourceId)
|
|
284
|
-
return entities[tableName]
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export async function getTable(tableId: any) {
|
|
288
|
-
const db = getAppDB()
|
|
289
|
-
if (isExternalTable(tableId)) {
|
|
290
|
-
let { datasourceId, tableName } = breakExternalTableId(tableId)
|
|
291
|
-
const datasource = await db.get(datasourceId)
|
|
292
|
-
const table = await getExternalTable(datasourceId, tableName)
|
|
293
|
-
return { ...table, sql: isSQL(datasource) }
|
|
294
|
-
} else {
|
|
295
|
-
return db.get(tableId)
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
248
|
export async function checkForViewUpdates(
|
|
300
249
|
table: any,
|
|
301
250
|
rename: any,
|
|
@@ -3,12 +3,12 @@ const { apiFileReturn } = require("../../../utilities/fileSystem")
|
|
|
3
3
|
const exporters = require("./exporters")
|
|
4
4
|
const { saveView, getView, getViews, deleteView } = require("./utils")
|
|
5
5
|
const { fetchView } = require("../row")
|
|
6
|
-
const { getTable } = require("../table/utils")
|
|
7
6
|
const { FieldTypes } = require("../../../constants")
|
|
8
7
|
const { getAppDB } = require("@budibase/backend-core/context")
|
|
9
8
|
const { events } = require("@budibase/backend-core")
|
|
10
9
|
const { DocumentType } = require("../../../db/utils")
|
|
11
10
|
const { cloneDeep, isEqual } = require("lodash")
|
|
11
|
+
const sdk = require("../../../sdk")
|
|
12
12
|
|
|
13
13
|
exports.fetch = async ctx => {
|
|
14
14
|
ctx.body = await getViews()
|
|
@@ -144,7 +144,7 @@ exports.exportView = async ctx => {
|
|
|
144
144
|
|
|
145
145
|
let schema = view && view.meta && view.meta.schema
|
|
146
146
|
const tableId = ctx.params.tableId || view.meta.tableId
|
|
147
|
-
const table = await getTable(tableId)
|
|
147
|
+
const table = await sdk.tables.getTable(tableId)
|
|
148
148
|
if (!schema) {
|
|
149
149
|
schema = table.schema
|
|
150
150
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Router from "@koa/router"
|
|
2
|
+
import * as controller from "../controllers/backup"
|
|
3
|
+
import authorized from "../../middleware/authorized"
|
|
4
|
+
import { BUILDER } from "@budibase/backend-core/permissions"
|
|
5
|
+
|
|
6
|
+
const router = new Router()
|
|
7
|
+
|
|
8
|
+
router.get("/api/backups/export", authorized(BUILDER), controller.exportAppDump)
|
|
9
|
+
|
|
10
|
+
export default router
|
package/src/api/routes/index.ts
CHANGED
|
@@ -25,11 +25,17 @@ import devRoutes from "./dev"
|
|
|
25
25
|
import cloudRoutes from "./cloud"
|
|
26
26
|
import migrationRoutes from "./migrations"
|
|
27
27
|
import pluginRoutes from "./plugin"
|
|
28
|
+
import Router from "@koa/router"
|
|
29
|
+
import { api } from "@budibase/pro"
|
|
28
30
|
|
|
29
31
|
export { default as staticRoutes } from "./static"
|
|
30
32
|
export { default as publicRoutes } from "./public"
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
const appBackupRoutes = api.appBackups
|
|
35
|
+
const scheduleRoutes = api.schedules
|
|
36
|
+
export const mainRoutes: Router[] = [
|
|
37
|
+
appBackupRoutes,
|
|
38
|
+
backupRoutes,
|
|
33
39
|
authRoutes,
|
|
34
40
|
deployRoutes,
|
|
35
41
|
layoutRoutes,
|
|
@@ -49,14 +55,14 @@ export const mainRoutes = [
|
|
|
49
55
|
permissionRoutes,
|
|
50
56
|
datasourceRoutes,
|
|
51
57
|
queryRoutes,
|
|
52
|
-
backupRoutes,
|
|
53
58
|
metadataRoutes,
|
|
54
59
|
devRoutes,
|
|
55
60
|
cloudRoutes,
|
|
56
|
-
// these need to be handled last as they still use /api/:tableId
|
|
57
|
-
// this could be breaking as koa may recognise other routes as this
|
|
58
|
-
tableRoutes,
|
|
59
61
|
rowRoutes,
|
|
60
62
|
migrationRoutes,
|
|
61
63
|
pluginRoutes,
|
|
64
|
+
scheduleRoutes,
|
|
65
|
+
// these need to be handled last as they still use /api/:tableId
|
|
66
|
+
// this could be breaking as koa may recognise other routes as this
|
|
67
|
+
tableRoutes,
|
|
62
68
|
]
|
|
@@ -21,7 +21,7 @@ describe("/backups", () => {
|
|
|
21
21
|
.set(config.defaultHeaders())
|
|
22
22
|
.expect(200)
|
|
23
23
|
expect(res.text).toBeDefined()
|
|
24
|
-
expect(res.
|
|
24
|
+
expect(res.headers["content-type"]).toEqual("application/gzip")
|
|
25
25
|
expect(events.app.exported.mock.calls.length).toBe(1)
|
|
26
26
|
})
|
|
27
27
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import setup from "./utilities"
|
|
2
|
+
import { events } from "@budibase/backend-core"
|
|
3
3
|
|
|
4
4
|
describe("/deployments", () => {
|
|
5
5
|
let request = setup.getRequest()
|
|
@@ -19,7 +19,7 @@ describe("/deployments", () => {
|
|
|
19
19
|
.set(config.defaultHeaders())
|
|
20
20
|
.expect("Content-Type", /json/)
|
|
21
21
|
.expect(200)
|
|
22
|
-
expect(events.app.published.mock.calls.length).toBe(1)
|
|
22
|
+
expect((events.app.published as jest.Mock).mock.calls.length).toBe(1)
|
|
23
23
|
})
|
|
24
24
|
})
|
|
25
|
-
})
|
|
25
|
+
})
|
package/src/app.ts
CHANGED
|
@@ -37,6 +37,8 @@ import {
|
|
|
37
37
|
} from "./utilities/workerRequests"
|
|
38
38
|
import { watch } from "./watch"
|
|
39
39
|
import { initialise as initialiseWebsockets } from "./websocket"
|
|
40
|
+
import sdk from "./sdk"
|
|
41
|
+
import * as pro from "@budibase/pro"
|
|
40
42
|
|
|
41
43
|
const app = new Koa()
|
|
42
44
|
|
|
@@ -102,12 +104,25 @@ server.on("close", async () => {
|
|
|
102
104
|
}
|
|
103
105
|
})
|
|
104
106
|
|
|
107
|
+
const initPro = async () => {
|
|
108
|
+
await pro.init({
|
|
109
|
+
backups: {
|
|
110
|
+
processing: {
|
|
111
|
+
exportAppFn: sdk.backups.exportApp,
|
|
112
|
+
importAppFn: sdk.backups.importApp,
|
|
113
|
+
statsFn: sdk.backups.calculateBackupStats,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
|
|
105
119
|
module.exports = server.listen(env.PORT || 0, async () => {
|
|
106
120
|
console.log(`Budibase running on ${JSON.stringify(server.address())}`)
|
|
107
121
|
env._set("PORT", server.address().port)
|
|
108
122
|
eventEmitter.emitPort(env.PORT)
|
|
109
123
|
fileSystem.init()
|
|
110
124
|
await redis.init()
|
|
125
|
+
await initPro()
|
|
111
126
|
|
|
112
127
|
// run migrations on startup if not done via http
|
|
113
128
|
// not recommended in a clustered environment
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const { getTable } = require("../api/controllers/table/utils")
|
|
2
1
|
const {
|
|
3
2
|
findHBSBlocks,
|
|
4
3
|
decodeJSBinding,
|
|
5
4
|
isJSBinding,
|
|
6
5
|
encodeJSBinding,
|
|
7
6
|
} = require("@budibase/string-templates")
|
|
7
|
+
const sdk = require("../sdk")
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* When values are input to the system generally they will be of type string as this is required for template strings.
|
|
@@ -64,7 +64,7 @@ exports.cleanInputValues = (inputs, schema) => {
|
|
|
64
64
|
* @returns {Promise<Object>} The cleaned up rows object, will should now have all the required primitive types.
|
|
65
65
|
*/
|
|
66
66
|
exports.cleanUpRow = async (tableId, row) => {
|
|
67
|
-
let table = await getTable(tableId)
|
|
67
|
+
let table = await sdk.tables.getTable(tableId)
|
|
68
68
|
return exports.cleanInputValues(row, { properties: table.schema })
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -1,37 +1,17 @@
|
|
|
1
1
|
const { createBullBoard } = require("@bull-board/api")
|
|
2
2
|
const { BullAdapter } = require("@bull-board/api/bullAdapter")
|
|
3
3
|
const { KoaAdapter } = require("@bull-board/koa")
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
? require("../utilities/queue/inMemoryQueue")
|
|
7
|
-
: require("bull")
|
|
8
|
-
const { JobQueues } = require("../constants")
|
|
9
|
-
const { utils } = require("@budibase/backend-core/redis")
|
|
10
|
-
const { opts, redisProtocolUrl } = utils.getRedisOptions()
|
|
11
|
-
const listeners = require("./listeners")
|
|
4
|
+
const { queue } = require("@budibase/backend-core")
|
|
5
|
+
const automation = require("../threads/automation")
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let automationQueue = new Queue(JobQueues.AUTOMATIONS, queueConfig)
|
|
18
|
-
listeners.addListeners(automationQueue)
|
|
19
|
-
|
|
20
|
-
async function cleanup() {
|
|
21
|
-
await automationQueue.clean(CLEANUP_PERIOD_MS, "completed")
|
|
22
|
-
}
|
|
7
|
+
let automationQueue = queue.createQueue(
|
|
8
|
+
queue.JobQueue.AUTOMATION,
|
|
9
|
+
automation.removeStalled
|
|
10
|
+
)
|
|
23
11
|
|
|
24
12
|
const PATH_PREFIX = "/bulladmin"
|
|
25
13
|
|
|
26
14
|
exports.init = () => {
|
|
27
|
-
// cleanup the events every 5 minutes
|
|
28
|
-
if (!cleanupInternal) {
|
|
29
|
-
cleanupInternal = setInterval(cleanup, CLEANUP_PERIOD_MS)
|
|
30
|
-
// fire off an initial cleanup
|
|
31
|
-
cleanup().catch(err => {
|
|
32
|
-
console.error(`Unable to cleanup automation queue initially - ${err}`)
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
15
|
// Set up queues for bull board admin
|
|
36
16
|
const queues = [automationQueue]
|
|
37
17
|
const adapters = []
|
|
@@ -48,12 +28,7 @@ exports.init = () => {
|
|
|
48
28
|
}
|
|
49
29
|
|
|
50
30
|
exports.shutdown = async () => {
|
|
51
|
-
|
|
52
|
-
clearInterval(cleanupInternal)
|
|
53
|
-
await automationQueue.close()
|
|
54
|
-
automationQueue = null
|
|
55
|
-
}
|
|
56
|
-
console.log("Bull shutdown")
|
|
31
|
+
await queue.shutdown()
|
|
57
32
|
}
|
|
58
33
|
|
|
59
|
-
exports.
|
|
34
|
+
exports.automationQueue = automationQueue
|
package/src/automations/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { processEvent } = require("./utils")
|
|
2
|
-
const {
|
|
2
|
+
const { automationQueue, shutdown } = require("./bullboard")
|
|
3
3
|
const { TRIGGER_DEFINITIONS, rebootTrigger } = require("./triggers")
|
|
4
4
|
const { ACTION_DEFINITIONS } = require("./actions")
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ const { ACTION_DEFINITIONS } = require("./actions")
|
|
|
8
8
|
*/
|
|
9
9
|
exports.init = async function () {
|
|
10
10
|
// this promise will not complete
|
|
11
|
-
const promise =
|
|
11
|
+
const promise = automationQueue.process(async job => {
|
|
12
12
|
await processEvent(job)
|
|
13
13
|
})
|
|
14
14
|
// on init we need to trigger any reboot automations
|
|
@@ -17,13 +17,13 @@ exports.init = async function () {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
exports.getQueues = () => {
|
|
20
|
-
return [
|
|
20
|
+
return [automationQueue]
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
exports.shutdown = () => {
|
|
24
24
|
return shutdown()
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
exports.
|
|
27
|
+
exports.automationQueue = automationQueue
|
|
28
28
|
exports.TRIGGER_DEFINITIONS = TRIGGER_DEFINITIONS
|
|
29
29
|
exports.ACTION_DEFINITIONS = ACTION_DEFINITIONS
|
|
@@ -4,7 +4,7 @@ const { coerce } = require("../utilities/rowProcessor")
|
|
|
4
4
|
const { definitions } = require("./triggerInfo")
|
|
5
5
|
const { isDevAppID } = require("../db/utils")
|
|
6
6
|
// need this to call directly, so we can get a response
|
|
7
|
-
const {
|
|
7
|
+
const { automationQueue } = require("./bullboard")
|
|
8
8
|
const { checkTestFlag } = require("../utilities/redis")
|
|
9
9
|
const utils = require("./utils")
|
|
10
10
|
const env = require("../environment")
|
|
@@ -56,7 +56,7 @@ async function queueRelevantRowAutomations(event, eventType) {
|
|
|
56
56
|
automationTrigger.inputs &&
|
|
57
57
|
automationTrigger.inputs.tableId === event.row.tableId
|
|
58
58
|
) {
|
|
59
|
-
await
|
|
59
|
+
await automationQueue.add({ automation, event }, JOB_OPTS)
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
})
|
|
@@ -110,7 +110,7 @@ exports.externalTrigger = async function (
|
|
|
110
110
|
if (getResponses) {
|
|
111
111
|
return utils.processEvent({ data })
|
|
112
112
|
} else {
|
|
113
|
-
return
|
|
113
|
+
return automationQueue.add(data, JOB_OPTS)
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -136,7 +136,7 @@ exports.rebootTrigger = async () => {
|
|
|
136
136
|
timestamp: Date.now(),
|
|
137
137
|
},
|
|
138
138
|
}
|
|
139
|
-
rebootEvents.push(
|
|
139
|
+
rebootEvents.push(automationQueue.add(job, JOB_OPTS))
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
await Promise.all(rebootEvents)
|
package/src/automations/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Thread, ThreadType } from "../threads"
|
|
2
2
|
import { definitions } from "./triggerInfo"
|
|
3
3
|
import * as webhooks from "../api/controllers/webhook"
|
|
4
|
-
import {
|
|
4
|
+
import { automationQueue } from "./bullboard"
|
|
5
5
|
import newid from "../db/newid"
|
|
6
6
|
import { updateEntityMetadata } from "../utilities"
|
|
7
7
|
import { MetadataTypes, WebhookType } from "../constants"
|
|
@@ -79,21 +79,25 @@ export function removeDeprecated(definitions: any) {
|
|
|
79
79
|
// end the repetition and the job itself
|
|
80
80
|
export async function disableAllCrons(appId: any) {
|
|
81
81
|
const promises = []
|
|
82
|
-
const jobs = await
|
|
82
|
+
const jobs = await automationQueue.getRepeatableJobs()
|
|
83
83
|
for (let job of jobs) {
|
|
84
84
|
if (job.key.includes(`${appId}_cron`)) {
|
|
85
|
-
promises.push(
|
|
85
|
+
promises.push(automationQueue.removeRepeatableByKey(job.key))
|
|
86
86
|
if (job.id) {
|
|
87
|
-
promises.push(
|
|
87
|
+
promises.push(automationQueue.removeJobs(job.id))
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
return Promise.all(promises)
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export async function
|
|
95
|
-
await
|
|
96
|
-
|
|
94
|
+
export async function disableCronById(jobId: number | string) {
|
|
95
|
+
const repeatJobs = await automationQueue.getRepeatableJobs()
|
|
96
|
+
for (let repeatJob of repeatJobs) {
|
|
97
|
+
if (repeatJob.id === jobId) {
|
|
98
|
+
await automationQueue.removeRepeatableByKey(repeatJob.key)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
97
101
|
console.log(`jobId=${jobId} disabled`)
|
|
98
102
|
}
|
|
99
103
|
|
|
@@ -141,7 +145,7 @@ export async function enableCronTrigger(appId: any, automation: Automation) {
|
|
|
141
145
|
) {
|
|
142
146
|
// make a job id rather than letting Bull decide, makes it easier to handle on way out
|
|
143
147
|
const jobId = `${appId}_cron_${newid()}`
|
|
144
|
-
const job: any = await
|
|
148
|
+
const job: any = await automationQueue.add(
|
|
145
149
|
{
|
|
146
150
|
automation,
|
|
147
151
|
event: { appId, timestamp: Date.now() },
|
package/src/constants/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
2
2
|
const { UserStatus } = require("@budibase/backend-core/constants")
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
exports.JobQueues = {
|
|
6
|
-
AUTOMATIONS: "automationQueue",
|
|
7
|
-
}
|
|
3
|
+
const { objectStore } = require("@budibase/backend-core")
|
|
8
4
|
|
|
9
5
|
const FilterTypes = {
|
|
10
6
|
STRING: "string",
|
|
@@ -211,6 +207,6 @@ exports.AutomationErrors = {
|
|
|
211
207
|
}
|
|
212
208
|
|
|
213
209
|
// pass through the list from the auth/core lib
|
|
214
|
-
exports.ObjectStoreBuckets = ObjectStoreBuckets
|
|
210
|
+
exports.ObjectStoreBuckets = objectStore.ObjectStoreBuckets
|
|
215
211
|
|
|
216
212
|
exports.MAX_AUTOMATION_RECURRING_ERRORS = 5
|
package/src/db/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const newid = require("./newid")
|
|
2
2
|
const {
|
|
3
|
-
DocumentType:
|
|
3
|
+
DocumentType: CoreDocType,
|
|
4
|
+
InternalTable,
|
|
4
5
|
getRoleParams,
|
|
5
6
|
generateRoleID,
|
|
6
7
|
APP_DEV_PREFIX,
|
|
@@ -13,6 +14,12 @@ const {
|
|
|
13
14
|
generateAppID,
|
|
14
15
|
getQueryIndex,
|
|
15
16
|
ViewName,
|
|
17
|
+
getDocParams,
|
|
18
|
+
getRowParams,
|
|
19
|
+
generateRowID,
|
|
20
|
+
getUserMetadataParams,
|
|
21
|
+
generateUserMetadataID,
|
|
22
|
+
getGlobalIDFromUserMetadataID,
|
|
16
23
|
} = require("@budibase/backend-core/db")
|
|
17
24
|
|
|
18
25
|
const UNICODE_MAX = "\ufff0"
|
|
@@ -23,28 +30,7 @@ const AppStatus = {
|
|
|
23
30
|
DEPLOYED: "published",
|
|
24
31
|
}
|
|
25
32
|
|
|
26
|
-
const DocumentType =
|
|
27
|
-
...CoreDocTypes,
|
|
28
|
-
TABLE: "ta",
|
|
29
|
-
ROW: "ro",
|
|
30
|
-
USER: "us",
|
|
31
|
-
AUTOMATION: "au",
|
|
32
|
-
LINK: "li",
|
|
33
|
-
WEBHOOK: "wh",
|
|
34
|
-
INSTANCE: "inst",
|
|
35
|
-
LAYOUT: "layout",
|
|
36
|
-
SCREEN: "screen",
|
|
37
|
-
QUERY: "query",
|
|
38
|
-
DEPLOYMENTS: "deployments",
|
|
39
|
-
METADATA: "metadata",
|
|
40
|
-
MEM_VIEW: "view",
|
|
41
|
-
USER_FLAG: "flag",
|
|
42
|
-
AUTOMATION_METADATA: "meta_au",
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const InternalTables = {
|
|
46
|
-
USER_METADATA: "ta_users",
|
|
47
|
-
}
|
|
33
|
+
const DocumentType = CoreDocType
|
|
48
34
|
|
|
49
35
|
const SearchIndexes = {
|
|
50
36
|
ROWS: "rows",
|
|
@@ -64,11 +50,11 @@ exports.APP_PREFIX = APP_PREFIX
|
|
|
64
50
|
exports.APP_DEV_PREFIX = APP_DEV_PREFIX
|
|
65
51
|
exports.isDevAppID = isDevAppID
|
|
66
52
|
exports.isProdAppID = isProdAppID
|
|
67
|
-
exports.USER_METDATA_PREFIX = `${DocumentType.ROW}${SEPARATOR}${
|
|
68
|
-
exports.LINK_USER_METADATA_PREFIX = `${DocumentType.LINK}${SEPARATOR}${
|
|
53
|
+
exports.USER_METDATA_PREFIX = `${DocumentType.ROW}${SEPARATOR}${InternalTable.USER_METADATA}${SEPARATOR}`
|
|
54
|
+
exports.LINK_USER_METADATA_PREFIX = `${DocumentType.LINK}${SEPARATOR}${InternalTable.USER_METADATA}${SEPARATOR}`
|
|
69
55
|
exports.TABLE_ROW_PREFIX = `${DocumentType.ROW}${SEPARATOR}${DocumentType.TABLE}`
|
|
70
56
|
exports.ViewName = ViewName
|
|
71
|
-
exports.InternalTables =
|
|
57
|
+
exports.InternalTables = InternalTable
|
|
72
58
|
exports.DocumentType = DocumentType
|
|
73
59
|
exports.SEPARATOR = SEPARATOR
|
|
74
60
|
exports.UNICODE_MAX = UNICODE_MAX
|
|
@@ -77,36 +63,15 @@ exports.AppStatus = AppStatus
|
|
|
77
63
|
exports.BudibaseInternalDB = BudibaseInternalDB
|
|
78
64
|
exports.generateAppID = generateAppID
|
|
79
65
|
exports.generateDevAppID = getDevelopmentAppID
|
|
80
|
-
|
|
81
66
|
exports.generateRoleID = generateRoleID
|
|
82
67
|
exports.getRoleParams = getRoleParams
|
|
83
|
-
|
|
84
68
|
exports.getQueryIndex = getQueryIndex
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* If creating DB allDocs/query params with only a single top level ID this can be used, this
|
|
88
|
-
* is usually the case as most of our docs are top level e.g. tables, automations, users and so on.
|
|
89
|
-
* More complex cases such as link docs and rows which have multiple levels of IDs that their
|
|
90
|
-
* ID consists of need their own functions to build the allDocs parameters.
|
|
91
|
-
* @param {string} docType The type of document which input params are being built for, e.g. user,
|
|
92
|
-
* link, app, table and so on.
|
|
93
|
-
* @param {string|null} docId The ID of the document minus its type - this is only needed if looking
|
|
94
|
-
* for a singular document.
|
|
95
|
-
* @param {object} otherProps Add any other properties onto the request, e.g. include_docs.
|
|
96
|
-
* @returns {object} Parameters which can then be used with an allDocs request.
|
|
97
|
-
*/
|
|
98
|
-
function getDocParams(docType, docId = null, otherProps = {}) {
|
|
99
|
-
if (docId == null) {
|
|
100
|
-
docId = ""
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
...otherProps,
|
|
104
|
-
startkey: `${docType}${SEPARATOR}${docId}`,
|
|
105
|
-
endkey: `${docType}${SEPARATOR}${docId}${UNICODE_MAX}`,
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
69
|
exports.getDocParams = getDocParams
|
|
70
|
+
exports.getRowParams = getRowParams
|
|
71
|
+
exports.generateRowID = generateRowID
|
|
72
|
+
exports.getUserMetadataParams = getUserMetadataParams
|
|
73
|
+
exports.generateUserMetadataID = generateUserMetadataID
|
|
74
|
+
exports.getGlobalIDFromUserMetadataID = getGlobalIDFromUserMetadataID
|
|
110
75
|
|
|
111
76
|
/**
|
|
112
77
|
* Gets parameters for retrieving tables, this is a utility function for the getDocParams function.
|
|
@@ -123,24 +88,6 @@ exports.generateTableID = () => {
|
|
|
123
88
|
return `${DocumentType.TABLE}${SEPARATOR}${newid()}`
|
|
124
89
|
}
|
|
125
90
|
|
|
126
|
-
/**
|
|
127
|
-
* Gets the DB allDocs/query params for retrieving a row.
|
|
128
|
-
* @param {string|null} tableId The table in which the rows have been stored.
|
|
129
|
-
* @param {string|null} rowId The ID of the row which is being specifically queried for. This can be
|
|
130
|
-
* left null to get all the rows in the table.
|
|
131
|
-
* @param {object} otherProps Any other properties to add to the request.
|
|
132
|
-
* @returns {object} Parameters which can then be used with an allDocs request.
|
|
133
|
-
*/
|
|
134
|
-
exports.getRowParams = (tableId = null, rowId = null, otherProps = {}) => {
|
|
135
|
-
if (tableId == null) {
|
|
136
|
-
return getDocParams(DocumentType.ROW, null, otherProps)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const endOfKey = rowId == null ? `${tableId}${SEPARATOR}` : rowId
|
|
140
|
-
|
|
141
|
-
return getDocParams(DocumentType.ROW, endOfKey, otherProps)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
91
|
/**
|
|
145
92
|
* Given a row ID this will find the table ID within it (only works for internal tables).
|
|
146
93
|
* @param {string} rowId The ID of the row.
|
|
@@ -153,44 +100,6 @@ exports.getTableIDFromRowID = rowId => {
|
|
|
153
100
|
return `${DocumentType.TABLE}${SEPARATOR}${components[0]}`
|
|
154
101
|
}
|
|
155
102
|
|
|
156
|
-
/**
|
|
157
|
-
* Gets a new row ID for the specified table.
|
|
158
|
-
* @param {string} tableId The table which the row is being created for.
|
|
159
|
-
* @param {string|null} id If an ID is to be used then the UUID can be substituted for this.
|
|
160
|
-
* @returns {string} The new ID which a row doc can be stored under.
|
|
161
|
-
*/
|
|
162
|
-
exports.generateRowID = (tableId, id = null) => {
|
|
163
|
-
id = id || newid()
|
|
164
|
-
return `${DocumentType.ROW}${SEPARATOR}${tableId}${SEPARATOR}${id}`
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Gets parameters for retrieving users, this is a utility function for the getDocParams function.
|
|
169
|
-
*/
|
|
170
|
-
exports.getUserMetadataParams = (userId = null, otherProps = {}) => {
|
|
171
|
-
return exports.getRowParams(InternalTables.USER_METADATA, userId, otherProps)
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Generates a new user ID based on the passed in global ID.
|
|
176
|
-
* @param {string} globalId The ID of the global user.
|
|
177
|
-
* @returns {string} The new user ID which the user doc can be stored under.
|
|
178
|
-
*/
|
|
179
|
-
exports.generateUserMetadataID = globalId => {
|
|
180
|
-
return exports.generateRowID(InternalTables.USER_METADATA, globalId)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Breaks up the ID to get the global ID.
|
|
185
|
-
*/
|
|
186
|
-
exports.getGlobalIDFromUserMetadataID = id => {
|
|
187
|
-
const prefix = `${DocumentType.ROW}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}`
|
|
188
|
-
if (!id || !id.includes(prefix)) {
|
|
189
|
-
return id
|
|
190
|
-
}
|
|
191
|
-
return id.split(prefix)[1]
|
|
192
|
-
}
|
|
193
|
-
|
|
194
103
|
/**
|
|
195
104
|
* Gets parameters for retrieving automations, this is a utility function for the getDocParams function.
|
|
196
105
|
*/
|
|
@@ -27,18 +27,6 @@ export interface TriggerOutput {
|
|
|
27
27
|
timestamp?: number
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export interface AutomationEvent {
|
|
31
|
-
data: {
|
|
32
|
-
automation: Automation
|
|
33
|
-
event: any
|
|
34
|
-
}
|
|
35
|
-
opts?: {
|
|
36
|
-
repeat?: {
|
|
37
|
-
jobId: string
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
30
|
export interface AutomationContext extends AutomationResults {
|
|
43
31
|
steps: any[]
|
|
44
32
|
trigger: any
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import { events } from "@budibase/backend-core"
|
|
2
|
-
import
|
|
3
|
-
import { Table } from "@budibase/types"
|
|
2
|
+
import sdk from "../../../../sdk"
|
|
4
3
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
)
|
|
11
|
-
return response.rows.map((row: any) => row.doc)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const backfill = async (appDb: any, timestamp: string | number) => {
|
|
15
|
-
const tables = await getTables(appDb)
|
|
4
|
+
export const backfill = async (
|
|
5
|
+
appDb: PouchDB.Database,
|
|
6
|
+
timestamp: string | number
|
|
7
|
+
) => {
|
|
8
|
+
const tables = await sdk.tables.getAllInternalTables(appDb)
|
|
16
9
|
|
|
17
10
|
for (const table of tables) {
|
|
18
11
|
await events.table.created(table, timestamp)
|