@budibase/server 0.9.136 → 0.9.140-alpha.0
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/discord.c14881e9.svg +10 -0
- package/builder/assets/{index.a0ab7774.js → index.0d1fa670.js} +35 -35
- package/builder/assets/{index.121692c9.css → index.79907e5c.css} +5 -5
- package/builder/assets/integromat.42212f11.png +0 -0
- package/builder/assets/slack.1e1f7cfb.svg +33 -0
- package/builder/assets/{vendor.7177f366.js → vendor.d39b3c1e.js} +2 -2
- package/builder/assets/zapier.3fbd8f5c.png +0 -0
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2142 -2095
- package/coverage/coverage-final.json +120 -106
- package/coverage/lcov-report/api/controllers/analytics.js.html +3 -3
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/application.js.html +84 -84
- package/coverage/lcov-report/api/controllers/auth.js.html +6 -6
- package/coverage/lcov-report/api/controllers/automation.js.html +182 -356
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +12 -12
- package/coverage/lcov-report/api/controllers/dev.js.html +15 -15
- package/coverage/lcov-report/api/controllers/hosting.js.html +8 -8
- package/coverage/lcov-report/api/controllers/index.html +47 -32
- package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- package/coverage/lcov-report/api/controllers/metadata.js.html +218 -0
- package/coverage/lcov-report/api/controllers/permission.js.html +14 -14
- package/coverage/lcov-report/api/controllers/query.js.html +17 -23
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +15 -15
- package/coverage/lcov-report/api/controllers/row/index.html +29 -44
- package/coverage/lcov-report/api/controllers/row/index.js.html +48 -45
- package/coverage/lcov-report/api/controllers/row/internal.js.html +159 -126
- package/coverage/lcov-report/api/controllers/row/utils.js.html +17 -17
- package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
- package/coverage/lcov-report/api/controllers/script.js.html +5 -5
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +40 -40
- package/coverage/lcov-report/api/controllers/table/utils.js.html +48 -48
- package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
- package/coverage/lcov-report/api/controllers/user.js.html +14 -11
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +3 -3
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +9 -9
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +6 -6
- package/coverage/lcov-report/api/controllers/webhook.js.html +14 -14
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +23 -23
- package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/application.js.html +8 -8
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +41 -26
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +13 -13
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +11 -11
- package/coverage/lcov-report/api/routes/hosting.js.html +8 -8
- package/coverage/lcov-report/api/routes/index.html +24 -9
- package/coverage/lcov-report/api/routes/index.js.html +36 -30
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +194 -0
- package/coverage/lcov-report/api/routes/permission.js.html +12 -12
- package/coverage/lcov-report/api/routes/query.js.html +13 -13
- package/coverage/lcov-report/api/routes/role.js.html +12 -12
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +10 -10
- package/coverage/lcov-report/api/routes/screen.js.html +11 -11
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +13 -16
- package/coverage/lcov-report/api/routes/table.js.html +12 -12
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +9 -9
- package/coverage/lcov-report/api/routes/view.js.html +11 -11
- package/coverage/lcov-report/api/routes/webhook.js.html +11 -11
- package/coverage/lcov-report/automations/actions.js.html +57 -117
- package/coverage/lcov-report/automations/automationUtils.js.html +7 -7
- package/coverage/lcov-report/automations/bullboard.js.html +49 -16
- package/coverage/lcov-report/automations/index.html +67 -67
- package/coverage/lcov-report/automations/index.js.html +27 -129
- package/coverage/lcov-report/automations/steps/bash.js.html +37 -16
- package/coverage/lcov-report/automations/steps/createRow.js.html +15 -15
- package/coverage/lcov-report/automations/steps/delay.js.html +48 -9
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +14 -14
- package/coverage/lcov-report/automations/steps/discord.js.html +329 -0
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +22 -34
- package/coverage/lcov-report/automations/steps/executeScript.js.html +21 -33
- package/coverage/lcov-report/automations/steps/filter.js.html +28 -25
- package/coverage/lcov-report/automations/steps/index.html +140 -65
- package/coverage/lcov-report/automations/steps/integromat.js.html +341 -0
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +44 -38
- package/coverage/lcov-report/automations/steps/queryRows.js.html +437 -0
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +13 -13
- package/coverage/lcov-report/automations/steps/serverLog.js.html +23 -11
- package/coverage/lcov-report/automations/steps/{sendgridEmail.js.html → slack.js.html} +58 -88
- package/coverage/lcov-report/automations/steps/updateRow.js.html +12 -12
- package/coverage/lcov-report/automations/steps/utils.js.html +188 -0
- package/coverage/lcov-report/automations/steps/zapier.js.html +332 -0
- package/coverage/lcov-report/automations/thread.js.html +81 -78
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +173 -0
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +173 -0
- package/coverage/lcov-report/automations/triggerInfo/index.html +201 -0
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +125 -0
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +176 -0
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +200 -0
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +200 -0
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +188 -0
- package/coverage/lcov-report/automations/triggers.js.html +67 -838
- package/coverage/lcov-report/automations/utils.js.html +557 -0
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +32 -17
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/index.html +19 -19
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +79 -79
- package/coverage/lcov-report/db/linkedRows/index.html +18 -18
- package/coverage/lcov-report/db/linkedRows/index.js.html +107 -149
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +43 -43
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +127 -76
- package/coverage/lcov-report/events/AutomationEmitter.js.html +7 -7
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +6 -6
- package/coverage/lcov-report/events/utils.js.html +3 -3
- package/coverage/lcov-report/index.html +116 -101
- 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/{automations/logic.js.html → middleware/appInfo.js.html} +35 -38
- package/coverage/lcov-report/middleware/authorized.js.html +16 -16
- package/coverage/lcov-report/middleware/builder.js.html +15 -15
- package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
- package/coverage/lcov-report/middleware/index.html +23 -8
- package/coverage/lcov-report/middleware/joi-validator.js.html +6 -6
- package/coverage/lcov-report/middleware/resourceId.js.html +28 -28
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +8 -8
- package/coverage/lcov-report/utilities/bcrypt.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 +6 -6
- package/coverage/lcov-report/utilities/global.js.html +33 -33
- package/coverage/lcov-report/utilities/index.html +28 -28
- package/coverage/lcov-report/utilities/index.js.html +178 -25
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +18 -18
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +14 -14
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +87 -51
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
- package/coverage/lcov-report/utilities/security.js.html +9 -9
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +52 -52
- package/coverage/lcov.info +3250 -3213
- package/dist/api/controllers/automation.js +60 -127
- package/dist/api/controllers/deploy/index.js +17 -1
- package/dist/api/controllers/metadata.js +49 -0
- package/dist/api/controllers/query.js +0 -2
- package/dist/api/controllers/row/ExternalRequest.js +1 -1
- package/dist/api/controllers/row/index.js +1 -0
- package/dist/api/controllers/row/internal.js +33 -23
- package/dist/api/controllers/static/index.js +1 -28
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +4 -1
- package/dist/api/controllers/user.js +1 -1
- package/dist/api/routes/automation.js +4 -5
- package/dist/api/routes/index.js +2 -0
- package/dist/api/routes/metadata.js +13 -0
- package/dist/api/routes/static.js +0 -1
- package/dist/api/routes/tests/utilities/TestFunctions.js +13 -0
- package/dist/app.js +1 -1
- package/dist/automations/actions.js +29 -46
- package/dist/automations/bullboard.js +11 -2
- package/dist/automations/index.js +11 -48
- package/dist/automations/steps/bash.js +12 -6
- package/dist/automations/steps/createRow.js +5 -5
- package/dist/automations/steps/delay.js +16 -3
- package/dist/automations/steps/deleteRow.js +5 -5
- package/dist/automations/steps/discord.js +91 -0
- package/dist/automations/steps/executeQuery.js +12 -15
- package/dist/automations/steps/executeScript.js +12 -15
- package/dist/automations/steps/filter.js +19 -18
- package/dist/automations/steps/integromat.js +94 -0
- package/dist/automations/steps/outgoingWebhook.js +19 -20
- package/dist/automations/steps/queryRows.js +129 -0
- package/dist/automations/steps/sendSmtpEmail.js +4 -4
- package/dist/automations/steps/serverLog.js +7 -3
- package/dist/automations/steps/slack.js +73 -0
- package/dist/automations/steps/updateRow.js +4 -4
- package/dist/automations/steps/utils.js +46 -0
- package/dist/automations/steps/zapier.js +91 -0
- package/dist/automations/tests/utilities/index.js +2 -12
- package/dist/automations/thread.js +23 -25
- package/dist/automations/triggerInfo/app.js +32 -0
- package/dist/automations/triggerInfo/cron.js +32 -0
- package/dist/automations/triggerInfo/index.js +15 -0
- package/dist/automations/triggerInfo/rowDeleted.js +33 -0
- package/dist/automations/triggerInfo/rowSaved.js +41 -0
- package/dist/automations/triggerInfo/rowUpdated.js +41 -0
- package/dist/automations/triggerInfo/webhook.js +37 -0
- package/dist/automations/triggers.js +27 -285
- package/dist/automations/utils.js +143 -0
- package/dist/constants/index.js +4 -0
- package/dist/db/linkedRows/index.js +20 -34
- package/dist/db/utils.js +14 -1
- package/dist/environment.js +2 -1
- package/dist/integrations/mysql.js +14 -2
- package/dist/middleware/appInfo.js +17 -0
- package/dist/middleware/usageQuota.js +1 -1
- package/dist/package.json +12 -11
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/appDirectoryTemplate/package.json +1 -1
- package/dist/utilities/fileSystem/clientLibrary.js +2 -2
- package/dist/utilities/fileSystem/index.js +2 -27
- package/dist/utilities/index.js +54 -0
- package/dist/utilities/redis.js +16 -1
- package/dist/utilities/rowProcessor/index.js +7 -4
- package/package.json +13 -12
- package/scripts/jestSetup.js +1 -0
- package/scripts/selfhost.js +8 -0
- package/src/api/controllers/automation.js +87 -145
- package/src/api/controllers/deploy/index.js +23 -1
- package/src/api/controllers/metadata.js +46 -0
- package/src/api/controllers/query.js +0 -2
- package/src/api/controllers/row/ExternalRequest.ts +1 -1
- package/src/api/controllers/row/index.js +1 -0
- package/src/api/controllers/row/internal.js +34 -23
- package/src/api/controllers/static/index.js +1 -39
- package/src/api/controllers/static/templates/BudibaseApp.svelte +4 -1
- package/src/api/controllers/user.js +1 -0
- package/src/api/routes/automation.js +16 -11
- package/src/api/routes/index.js +2 -0
- package/src/api/routes/metadata.js +38 -0
- package/src/api/routes/static.js +0 -1
- package/src/api/routes/tests/automation.spec.js +4 -26
- package/src/api/routes/tests/metadata.spec.js +65 -0
- package/src/api/routes/tests/utilities/TestFunctions.js +14 -0
- package/src/app.ts +1 -1
- package/src/automations/actions.js +29 -49
- package/src/automations/bullboard.js +13 -2
- package/src/automations/index.js +11 -45
- package/src/automations/steps/bash.js +13 -6
- package/src/automations/steps/createRow.js +5 -5
- package/src/automations/steps/delay.js +16 -3
- package/src/automations/steps/deleteRow.js +5 -5
- package/src/automations/steps/discord.js +83 -0
- package/src/automations/steps/executeQuery.js +12 -16
- package/src/automations/steps/executeScript.js +12 -16
- package/src/automations/steps/filter.js +19 -18
- package/src/automations/steps/integromat.js +87 -0
- package/src/automations/steps/outgoingWebhook.js +20 -18
- package/src/automations/steps/queryRows.js +119 -0
- package/src/automations/steps/sendSmtpEmail.js +4 -4
- package/src/automations/steps/serverLog.js +7 -3
- package/src/automations/steps/slack.js +64 -0
- package/src/automations/steps/updateRow.js +4 -4
- package/src/automations/steps/utils.js +36 -0
- package/src/automations/steps/zapier.js +84 -0
- package/src/automations/tests/automation.spec.js +4 -67
- package/src/automations/tests/delay.spec.js +2 -2
- package/src/automations/tests/filter.spec.js +14 -14
- package/src/automations/tests/queryRows.spec.js +51 -0
- package/src/automations/tests/utilities/index.js +2 -13
- package/src/automations/thread.js +27 -26
- package/src/automations/triggerInfo/app.js +31 -0
- package/src/automations/triggerInfo/cron.js +31 -0
- package/src/automations/triggerInfo/index.js +15 -0
- package/src/automations/triggerInfo/rowDeleted.js +32 -0
- package/src/automations/triggerInfo/rowSaved.js +40 -0
- package/src/automations/triggerInfo/rowUpdated.js +40 -0
- package/src/automations/triggerInfo/webhook.js +36 -0
- package/src/automations/triggers.js +33 -290
- package/src/automations/utils.js +159 -0
- package/src/constants/index.js +5 -0
- package/src/db/linkedRows/index.js +21 -35
- package/src/db/tests/linkTests.spec.js +0 -12
- package/src/db/utils.js +17 -0
- package/src/environment.js +2 -1
- package/src/integrations/mysql.ts +15 -2
- package/src/middleware/appInfo.js +19 -0
- package/src/middleware/usageQuota.js +1 -1
- package/src/utilities/appDirectoryTemplate/package.json +1 -1
- package/src/utilities/fileSystem/clientLibrary.js +2 -2
- package/src/utilities/fileSystem/index.js +2 -36
- package/src/utilities/index.js +51 -0
- package/src/utilities/redis.js +18 -1
- package/src/utilities/rowProcessor/index.js +16 -4
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +0 -1244
- package/dist/automations/logic.js +0 -17
- package/dist/automations/steps/sendgridEmail.js +0 -85
- package/src/automations/logic.js +0 -20
- package/src/automations/steps/sendgridEmail.js +0 -74
- package/src/automations/tests/sendEmail.spec.js +0 -36
|
@@ -140,7 +140,7 @@ module MySQLModule {
|
|
|
140
140
|
this.client = mysql.createConnection(config)
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
async buildSchema(datasourceId: string) {
|
|
143
|
+
async buildSchema(datasourceId: string, entities: Record<string, Table>) {
|
|
144
144
|
const tables: { [key: string]: Table } = {}
|
|
145
145
|
const database = this.config.database
|
|
146
146
|
this.client.connect()
|
|
@@ -152,7 +152,7 @@ module MySQLModule {
|
|
|
152
152
|
false
|
|
153
153
|
)
|
|
154
154
|
const tableNames = tablesResp.map(
|
|
155
|
-
(obj: any) => obj[`Tables_in_${database}`]
|
|
155
|
+
(obj: any) => obj[`Tables_in_${database.toLowerCase()}`]
|
|
156
156
|
)
|
|
157
157
|
for (let tableName of tableNames) {
|
|
158
158
|
const primaryKeys = []
|
|
@@ -193,6 +193,19 @@ module MySQLModule {
|
|
|
193
193
|
schema,
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
+
|
|
197
|
+
// add the existing relationships from the entities if they exist, to prevent them from being overridden
|
|
198
|
+
if (entities && entities[tableName]) {
|
|
199
|
+
const existingTableSchema = entities[tableName].schema
|
|
200
|
+
for (let key in existingTableSchema) {
|
|
201
|
+
if (!existingTableSchema.hasOwnProperty(key)) {
|
|
202
|
+
continue
|
|
203
|
+
}
|
|
204
|
+
if (existingTableSchema[key].type === "link") {
|
|
205
|
+
tables[tableName].schema[key] = existingTableSchema[key]
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
196
209
|
}
|
|
197
210
|
|
|
198
211
|
this.client.end()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const { isDevAppID, isProdAppID } = require("../db/utils")
|
|
2
|
+
|
|
3
|
+
exports.AppType = {
|
|
4
|
+
DEV: "dev",
|
|
5
|
+
PROD: "prod",
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
exports.middleware =
|
|
9
|
+
({ appType } = {}) =>
|
|
10
|
+
(ctx, next) => {
|
|
11
|
+
const appId = ctx.appId
|
|
12
|
+
if (appType === exports.AppType.DEV && appId && !isDevAppID(appId)) {
|
|
13
|
+
ctx.throw(400, "Only apps in development support this endpoint")
|
|
14
|
+
}
|
|
15
|
+
if (appType === exports.AppType.PROD && appId && !isProdAppID(appId)) {
|
|
16
|
+
ctx.throw(400, "Only apps in production support this endpoint")
|
|
17
|
+
}
|
|
18
|
+
return next()
|
|
19
|
+
}
|
|
@@ -14,7 +14,7 @@ const DOMAIN_MAP = {
|
|
|
14
14
|
views: usageQuota.Properties.VIEW,
|
|
15
15
|
users: usageQuota.Properties.USER,
|
|
16
16
|
// this will not be updated by endpoint calls
|
|
17
|
-
// instead it will be updated by
|
|
17
|
+
// instead it will be updated by triggerInfo
|
|
18
18
|
automationRuns: usageQuota.Properties.AUTOMATION,
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -8,7 +8,7 @@ const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..")
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Client library paths in the object store:
|
|
11
|
-
* Previously, the entire
|
|
11
|
+
* Previously, the entire client library package was downloaded from NPM
|
|
12
12
|
* as a tarball and extracted to the object store, even though only the manifest
|
|
13
13
|
* was ever needed. Therefore we need to support old apps which may still have
|
|
14
14
|
* the manifest at this location for the first update.
|
|
@@ -90,7 +90,7 @@ exports.updateClientLibrary = async appId => {
|
|
|
90
90
|
|
|
91
91
|
if (env.isDev()) {
|
|
92
92
|
// Load the symlinked version in dev which is always the newest
|
|
93
|
-
manifest = require.resolve("@budibase/
|
|
93
|
+
manifest = require.resolve("@budibase/client/manifest.json")
|
|
94
94
|
client = require.resolve("@budibase/client")
|
|
95
95
|
} else {
|
|
96
96
|
// Load the bundled version in prod
|
|
@@ -14,18 +14,12 @@ const {
|
|
|
14
14
|
downloadTarball,
|
|
15
15
|
} = require("./utilities")
|
|
16
16
|
const { updateClientLibrary } = require("./clientLibrary")
|
|
17
|
-
const download = require("download")
|
|
18
17
|
const env = require("../../environment")
|
|
19
|
-
const { homedir } = require("os")
|
|
20
|
-
const fetch = require("node-fetch")
|
|
21
18
|
const {
|
|
22
19
|
USER_METDATA_PREFIX,
|
|
23
20
|
LINK_USER_METADATA_PREFIX,
|
|
24
21
|
} = require("../../db/utils")
|
|
25
22
|
|
|
26
|
-
const DEFAULT_AUTOMATION_BUCKET =
|
|
27
|
-
"https://prod-budi-automations.s3-eu-west-1.amazonaws.com"
|
|
28
|
-
const DEFAULT_AUTOMATION_DIRECTORY = ".budibase-automations"
|
|
29
23
|
const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..")
|
|
30
24
|
const NODE_MODULES_PATH = join(TOP_LEVEL_PATH, "node_modules")
|
|
31
25
|
|
|
@@ -180,16 +174,12 @@ exports.getComponentLibraryManifest = async (appId, library) => {
|
|
|
180
174
|
// when testing in cypress and so on we need to get the package
|
|
181
175
|
// as the environment may not be fully fleshed out for dev or prod
|
|
182
176
|
if (env.isTest()) {
|
|
177
|
+
library = library.replace("standard-components", "client")
|
|
183
178
|
const lib = library.split("/")[1]
|
|
184
179
|
const path = require.resolve(library).split(lib)[0]
|
|
185
180
|
return require(join(path, lib, filename))
|
|
186
181
|
} else if (env.isDev()) {
|
|
187
|
-
const path = join(
|
|
188
|
-
NODE_MODULES_PATH,
|
|
189
|
-
"@budibase",
|
|
190
|
-
"standard-components",
|
|
191
|
-
filename
|
|
192
|
-
)
|
|
182
|
+
const path = join(NODE_MODULES_PATH, "@budibase", "client", filename)
|
|
193
183
|
// always load from new so that updates are refreshed
|
|
194
184
|
delete require.cache[require.resolve(path)]
|
|
195
185
|
return require(path)
|
|
@@ -211,30 +201,6 @@ exports.getComponentLibraryManifest = async (appId, library) => {
|
|
|
211
201
|
return JSON.parse(resp)
|
|
212
202
|
}
|
|
213
203
|
|
|
214
|
-
exports.automationInit = async () => {
|
|
215
|
-
const directory =
|
|
216
|
-
env.AUTOMATION_DIRECTORY || join(homedir(), DEFAULT_AUTOMATION_DIRECTORY)
|
|
217
|
-
const bucket = env.AUTOMATION_BUCKET || DEFAULT_AUTOMATION_BUCKET
|
|
218
|
-
if (!fs.existsSync(directory)) {
|
|
219
|
-
fs.mkdirSync(directory, { recursive: true })
|
|
220
|
-
}
|
|
221
|
-
// env setup to get async packages
|
|
222
|
-
let response = await fetch(`${bucket}/manifest.json`)
|
|
223
|
-
return response.json()
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
exports.getExternalAutomationStep = async (name, version, bundleName) => {
|
|
227
|
-
const directory =
|
|
228
|
-
env.AUTOMATION_DIRECTORY || join(homedir(), DEFAULT_AUTOMATION_DIRECTORY)
|
|
229
|
-
const bucket = env.AUTOMATION_BUCKET || DEFAULT_AUTOMATION_BUCKET
|
|
230
|
-
try {
|
|
231
|
-
return require(join(directory, bundleName))
|
|
232
|
-
} catch (err) {
|
|
233
|
-
await download(`${bucket}/${name}/${version}/${bundleName}`, directory)
|
|
234
|
-
return require(join(directory, bundleName))
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
204
|
/**
|
|
239
205
|
* All file reads come through here just to make sure all of them make sense
|
|
240
206
|
* allows a centralised location to check logic is all good.
|
package/src/utilities/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const env = require("../environment")
|
|
2
2
|
const { OBJ_STORE_DIRECTORY } = require("../constants")
|
|
3
3
|
const { sanitizeKey } = require("@budibase/auth/src/objectStore")
|
|
4
|
+
const CouchDB = require("../db")
|
|
5
|
+
const { generateMetadataID } = require("../db/utils")
|
|
4
6
|
|
|
5
7
|
const BB_CDN = "https://cdn.budi.live"
|
|
6
8
|
|
|
@@ -55,3 +57,52 @@ exports.attachmentsRelativeURL = attachmentKey => {
|
|
|
55
57
|
`${exports.objectStoreUrl()}/${attachmentKey}`
|
|
56
58
|
)
|
|
57
59
|
}
|
|
60
|
+
|
|
61
|
+
exports.updateEntityMetadata = async (appId, type, entityId, updateFn) => {
|
|
62
|
+
const db = new CouchDB(appId)
|
|
63
|
+
const id = generateMetadataID(type, entityId)
|
|
64
|
+
// read it to see if it exists, we'll overwrite it no matter what
|
|
65
|
+
let rev,
|
|
66
|
+
metadata = {}
|
|
67
|
+
try {
|
|
68
|
+
const oldMetadata = await db.get(id)
|
|
69
|
+
rev = oldMetadata._rev
|
|
70
|
+
metadata = updateFn(oldMetadata)
|
|
71
|
+
} catch (err) {
|
|
72
|
+
rev = null
|
|
73
|
+
metadata = updateFn({})
|
|
74
|
+
}
|
|
75
|
+
metadata._id = id
|
|
76
|
+
if (rev) {
|
|
77
|
+
metadata._rev = rev
|
|
78
|
+
}
|
|
79
|
+
const response = await db.put(metadata)
|
|
80
|
+
return {
|
|
81
|
+
...metadata,
|
|
82
|
+
_id: id,
|
|
83
|
+
_rev: response.rev,
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
exports.saveEntityMetadata = async (appId, type, entityId, metadata) => {
|
|
88
|
+
return exports.updateEntityMetadata(appId, type, entityId, () => {
|
|
89
|
+
return metadata
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
exports.deleteEntityMetadata = async (appId, type, entityId) => {
|
|
94
|
+
const db = new CouchDB(appId)
|
|
95
|
+
const id = generateMetadataID(type, entityId)
|
|
96
|
+
let rev
|
|
97
|
+
try {
|
|
98
|
+
const metadata = await db.get(id)
|
|
99
|
+
if (metadata) {
|
|
100
|
+
rev = metadata._rev
|
|
101
|
+
}
|
|
102
|
+
} catch (err) {
|
|
103
|
+
// don't need to error if it doesn't exist
|
|
104
|
+
}
|
|
105
|
+
if (id && rev) {
|
|
106
|
+
await db.remove(id, rev)
|
|
107
|
+
}
|
|
108
|
+
}
|
package/src/utilities/redis.js
CHANGED
|
@@ -2,20 +2,24 @@ const { Client, utils } = require("@budibase/auth/redis")
|
|
|
2
2
|
const { getGlobalIDFromUserMetadataID } = require("../db/utils")
|
|
3
3
|
|
|
4
4
|
const APP_DEV_LOCK_SECONDS = 600
|
|
5
|
-
|
|
5
|
+
const AUTOMATION_TEST_FLAG_SECONDS = 60
|
|
6
|
+
let devAppClient, debounceClient, flagClient
|
|
6
7
|
|
|
7
8
|
// we init this as we want to keep the connection open all the time
|
|
8
9
|
// reduces the performance hit
|
|
9
10
|
exports.init = async () => {
|
|
10
11
|
devAppClient = new Client(utils.Databases.DEV_LOCKS)
|
|
11
12
|
debounceClient = new Client(utils.Databases.DEBOUNCE)
|
|
13
|
+
flagClient = new Client(utils.Databases.FLAGS)
|
|
12
14
|
await devAppClient.init()
|
|
13
15
|
await debounceClient.init()
|
|
16
|
+
await flagClient.init()
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
exports.shutdown = async () => {
|
|
17
20
|
if (devAppClient) await devAppClient.finish()
|
|
18
21
|
if (debounceClient) await debounceClient.finish()
|
|
22
|
+
if (flagClient) await flagClient.finish()
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
exports.doesUserHaveLock = async (devAppId, user) => {
|
|
@@ -67,3 +71,16 @@ exports.checkDebounce = async id => {
|
|
|
67
71
|
exports.setDebounce = async (id, seconds) => {
|
|
68
72
|
await debounceClient.store(id, "debouncing", seconds)
|
|
69
73
|
}
|
|
74
|
+
|
|
75
|
+
exports.setTestFlag = async id => {
|
|
76
|
+
await flagClient.store(id, { testing: true }, AUTOMATION_TEST_FLAG_SECONDS)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.checkTestFlag = async id => {
|
|
80
|
+
const flag = await flagClient.get(id)
|
|
81
|
+
return !!(flag && flag.testing)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
exports.clearTestFlag = async id => {
|
|
85
|
+
await devAppClient.delete(id)
|
|
86
|
+
}
|
|
@@ -185,10 +185,16 @@ exports.inputProcessing = (user = {}, table, row) => {
|
|
|
185
185
|
* @param {object} ctx the request which is looking for enriched rows.
|
|
186
186
|
* @param {object} table the table from which these rows came from originally, this is used to determine
|
|
187
187
|
* the schema of the rows and then enrich.
|
|
188
|
-
* @param {object[]} rows the rows which are to be enriched.
|
|
189
|
-
* @
|
|
188
|
+
* @param {object[]|object} rows the rows which are to be enriched.
|
|
189
|
+
* @param {object} opts used to set some options for the output, such as disabling relationship squashing.
|
|
190
|
+
* @returns {object[]|object} the enriched rows will be returned.
|
|
190
191
|
*/
|
|
191
|
-
exports.outputProcessing = async (
|
|
192
|
+
exports.outputProcessing = async (
|
|
193
|
+
ctx,
|
|
194
|
+
table,
|
|
195
|
+
rows,
|
|
196
|
+
opts = { squash: true }
|
|
197
|
+
) => {
|
|
192
198
|
const appId = ctx.appId
|
|
193
199
|
let wasArray = true
|
|
194
200
|
if (!(rows instanceof Array)) {
|
|
@@ -214,6 +220,12 @@ exports.outputProcessing = async (ctx, table, rows) => {
|
|
|
214
220
|
}
|
|
215
221
|
}
|
|
216
222
|
}
|
|
217
|
-
|
|
223
|
+
if (opts.squash) {
|
|
224
|
+
enriched = await linkRows.squashLinksToPrimaryDisplay(
|
|
225
|
+
appId,
|
|
226
|
+
table,
|
|
227
|
+
enriched
|
|
228
|
+
)
|
|
229
|
+
}
|
|
218
230
|
return wasArray ? enriched : enriched[0]
|
|
219
231
|
}
|