@budibase/server 1.0.219-alpha.7 → 1.0.219
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/__mocks__/node-fetch.ts +0 -9
- package/builder/assets/index.1c640a53.js +1316 -0
- package/builder/assets/index.24307ca0.css +6 -0
- package/builder/assets/{vendor.001dcf8c.js → vendor.9bf2fcb4.js} +163 -163
- package/builder/index.html +3 -3
- package/coverage/clover.xml +794 -868
- package/coverage/coverage-final.json +26 -26
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +12 -111
- package/coverage/lcov-report/api/controllers/backup.js.html +6 -9
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +21 -21
- 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 +17 -47
- package/coverage/lcov-report/api/controllers/row/index.html +34 -34
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +11 -95
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +8 -17
- package/coverage/lcov-report/api/controllers/screen.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 +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- 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 +1 -1
- 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 +15 -15
- package/coverage/lcov-report/api/index.js.html +13 -22
- 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/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +2 -32
- package/coverage/lcov-report/api/routes/backup.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 +1 -1
- 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 +12 -57
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +17 -17
- package/coverage/lcov-report/automations/index.js.html +1 -1
- 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 +34 -58
- package/coverage/lcov-report/automations/steps/index.html +11 -11
- 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 +4 -4
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- 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 +14 -14
- 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 +13 -13
- package/coverage/lcov-report/db/linkedRows/index.js.html +7 -10
- 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 +51 -27
- 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 +74 -74
- 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 +12 -12
- package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +10 -10
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +9 -18
- package/coverage/lcov-report/threads/index.html +25 -25
- package/coverage/lcov-report/threads/query.js.html +76 -283
- package/coverage/lcov-report/threads/utils.js.html +4 -4
- 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 +14 -14
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +9 -9
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- 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 +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 +1425 -1553
- package/dist/api/controllers/application.js +15 -18
- package/dist/api/controllers/automation.js +2 -28
- package/dist/api/controllers/backup.js +2 -3
- package/dist/api/controllers/query/index.js +0 -25
- package/dist/api/controllers/row/external.js +7 -19
- package/dist/api/controllers/row/internalSearch.js +1 -22
- package/dist/api/controllers/row/utils.js +0 -3
- package/dist/api/index.js +1 -4
- package/dist/api/routes/automation.js +0 -2
- package/dist/automations/automationUtils.js +4 -16
- package/dist/automations/steps/filter.js +29 -38
- package/dist/automations/triggers.js +1 -1
- package/dist/db/linkedRows/index.js +0 -1
- package/dist/db/utils.js +31 -4
- package/dist/definitions/datasource.js +0 -1
- package/dist/environment.js +0 -1
- package/dist/integrations/airtable.js +0 -1
- package/dist/integrations/arangodb.js +0 -1
- package/dist/integrations/base/sql.js +3 -20
- package/dist/integrations/couchdb.js +0 -1
- package/dist/integrations/dynamodb.js +0 -1
- package/dist/integrations/elasticsearch.js +0 -1
- package/dist/integrations/firebase.js +0 -1
- package/dist/integrations/googlesheets.js +0 -1
- package/dist/integrations/index.js +0 -4
- package/dist/integrations/microsoftSqlServer.js +1 -2
- package/dist/integrations/mongodb.js +0 -1
- package/dist/integrations/mysql.js +1 -2
- package/dist/integrations/oracle.js +0 -1
- package/dist/integrations/postgres.js +1 -2
- package/dist/integrations/queries/sql.js +0 -3
- package/dist/integrations/redis.js +0 -1
- package/dist/integrations/rest.js +1 -2
- package/dist/integrations/s3.js +0 -1
- package/dist/package.json +6 -7
- package/dist/tests/utilities/TestConfiguration.js +6 -19
- package/dist/threads/automation.js +3 -6
- package/dist/threads/index.js +1 -15
- package/dist/threads/query.js +8 -54
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +6 -16
- package/package.json +7 -8
- package/src/api/controllers/application.ts +14 -18
- package/src/api/controllers/automation.js +2 -35
- package/src/api/controllers/backup.js +2 -3
- package/src/api/controllers/query/index.ts +1 -29
- package/src/api/controllers/row/external.js +9 -19
- package/src/api/controllers/row/internalSearch.js +0 -28
- package/src/api/controllers/row/utils.js +0 -3
- package/src/api/index.js +1 -4
- package/src/api/routes/automation.js +0 -10
- package/src/api/routes/tests/query.spec.js +0 -166
- package/src/automations/automationUtils.js +4 -19
- package/src/automations/steps/filter.js +28 -36
- package/src/automations/tests/filter.spec.js +1 -2
- package/src/automations/triggers.js +1 -1
- package/src/db/linkedRows/index.js +0 -1
- package/src/db/utils.js +13 -5
- package/src/definitions/common.ts +0 -1
- package/src/definitions/datasource.ts +0 -2
- package/src/environment.js +0 -1
- package/src/integrations/airtable.ts +0 -1
- package/src/integrations/arangodb.ts +0 -1
- package/src/integrations/base/sql.ts +11 -25
- package/src/integrations/couchdb.ts +0 -1
- package/src/integrations/dynamodb.ts +0 -1
- package/src/integrations/elasticsearch.ts +0 -1
- package/src/integrations/firebase.ts +0 -1
- package/src/integrations/googlesheets.ts +0 -1
- package/src/integrations/index.ts +0 -4
- package/src/integrations/microsoftSqlServer.ts +0 -2
- package/src/integrations/mongodb.ts +0 -1
- package/src/integrations/mysql.ts +0 -2
- package/src/integrations/oracle.ts +0 -1
- package/src/integrations/postgres.ts +0 -2
- package/src/integrations/queries/sql.ts +1 -3
- package/src/integrations/redis.ts +0 -1
- package/src/integrations/rest.ts +1 -2
- package/src/integrations/s3.ts +0 -1
- package/src/integrations/tests/rest.spec.js +1 -16
- package/src/migrations/tests/index.spec.ts +2 -18
- package/src/module.d.ts +0 -2
- package/src/tests/utilities/TestConfiguration.js +3 -22
- package/src/threads/automation.js +3 -6
- package/src/threads/index.ts +1 -5
- package/src/threads/query.js +10 -79
- package/src/utilities/fileSystem/index.js +8 -22
- package/builder/assets/index.5a233c3d.js +0 -977
- package/builder/assets/index.7786f497.css +0 -6
- package/dist/automations/logging/index.js +0 -70
- package/dist/integrations/snowflake.js +0 -102
- package/scripts/integrations/oracle/instantclient/linux/arm64/basiclite-19.10.zip +0 -0
- package/scripts/integrations/oracle/instantclient/linux/arm64/install.sh +0 -23
- package/scripts/integrations/oracle/instantclient/linux/install.sh +0 -10
- package/src/automations/logging/index.ts +0 -35
- package/src/integrations/snowflake.ts +0 -99
package/src/threads/index.ts
CHANGED
|
@@ -77,7 +77,7 @@ export class Thread {
|
|
|
77
77
|
})
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
static
|
|
80
|
+
static shutdown() {
|
|
81
81
|
return new Promise<void>(resolve => {
|
|
82
82
|
if (Thread.workerRefs.length === 0) {
|
|
83
83
|
resolve()
|
|
@@ -95,8 +95,4 @@ export class Thread {
|
|
|
95
95
|
Thread.workerRefs = []
|
|
96
96
|
})
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
static async shutdown() {
|
|
100
|
-
await Thread.stopThreads()
|
|
101
|
-
}
|
|
102
98
|
}
|
package/src/threads/query.js
CHANGED
|
@@ -4,13 +4,6 @@ const ScriptRunner = require("../utilities/scriptRunner")
|
|
|
4
4
|
const { integrations } = require("../integrations")
|
|
5
5
|
const { processStringSync } = require("@budibase/string-templates")
|
|
6
6
|
const { doInAppContext, getAppDB } = require("@budibase/backend-core/context")
|
|
7
|
-
const {
|
|
8
|
-
refreshOAuthToken,
|
|
9
|
-
updateUserOAuth,
|
|
10
|
-
} = require("@budibase/backend-core/auth")
|
|
11
|
-
const { user: userCache } = require("@budibase/backend-core/cache")
|
|
12
|
-
const { getGlobalIDFromUserMetadataID } = require("../db/utils")
|
|
13
|
-
|
|
14
7
|
const { isSQL } = require("../integrations/utils")
|
|
15
8
|
const {
|
|
16
9
|
enrichQueryFields,
|
|
@@ -28,56 +21,29 @@ class QueryRunner {
|
|
|
28
21
|
this.queryId = input.queryId
|
|
29
22
|
this.noRecursiveQuery = flags.noRecursiveQuery
|
|
30
23
|
this.cachedVariables = []
|
|
31
|
-
// Additional context items for enrichment
|
|
32
|
-
this.ctx = input.ctx
|
|
33
24
|
// allows the response from a query to be stored throughout this
|
|
34
25
|
// execution so that if it needs to be re-used for another variable
|
|
35
26
|
// it can be
|
|
36
27
|
this.queryResponse = {}
|
|
37
28
|
this.hasRerun = false
|
|
38
|
-
this.hasRefreshedOAuth = false
|
|
39
29
|
}
|
|
40
30
|
|
|
41
31
|
async execute() {
|
|
42
32
|
let { datasource, fields, queryVerb, transformer } = this
|
|
43
|
-
|
|
44
33
|
const Integration = integrations[datasource.source]
|
|
45
34
|
if (!Integration) {
|
|
46
35
|
throw "Integration type does not exist."
|
|
47
36
|
}
|
|
48
|
-
|
|
49
|
-
if (datasource.config.authConfigs) {
|
|
50
|
-
datasource.config.authConfigs = datasource.config.authConfigs.map(
|
|
51
|
-
config => {
|
|
52
|
-
return enrichQueryFields(config, this.ctx)
|
|
53
|
-
}
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
37
|
const integration = new Integration(datasource.config)
|
|
58
38
|
|
|
59
39
|
// pre-query, make sure datasource variables are added to parameters
|
|
60
40
|
const parameters = await this.addDatasourceVariables()
|
|
61
|
-
|
|
62
|
-
// Enrich the parameters with the addition context items.
|
|
63
|
-
// 'user' is now a reserved variable key in mapping parameters
|
|
64
|
-
const enrichedParameters = enrichQueryFields(parameters, this.ctx)
|
|
65
|
-
const enrichedContext = { ...enrichedParameters, ...this.ctx }
|
|
66
|
-
|
|
67
|
-
// Parse global headers
|
|
68
|
-
if (datasource.config.defaultHeaders) {
|
|
69
|
-
datasource.config.defaultHeaders = enrichQueryFields(
|
|
70
|
-
datasource.config.defaultHeaders,
|
|
71
|
-
enrichedContext
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
41
|
let query
|
|
76
42
|
// handle SQL injections by interpolating the variables
|
|
77
43
|
if (isSQL(datasource)) {
|
|
78
|
-
query = interpolateSQL(fields,
|
|
44
|
+
query = interpolateSQL(fields, parameters, integration)
|
|
79
45
|
} else {
|
|
80
|
-
query = enrichQueryFields(fields,
|
|
46
|
+
query = enrichQueryFields(fields, parameters)
|
|
81
47
|
}
|
|
82
48
|
|
|
83
49
|
// Add pagination values for REST queries
|
|
@@ -101,24 +67,20 @@ class QueryRunner {
|
|
|
101
67
|
if (transformer) {
|
|
102
68
|
const runner = new ScriptRunner(transformer, {
|
|
103
69
|
data: rows,
|
|
104
|
-
params:
|
|
70
|
+
params: parameters,
|
|
105
71
|
})
|
|
106
72
|
rows = runner.execute()
|
|
107
73
|
}
|
|
108
74
|
|
|
109
75
|
// if the request fails we retry once, invalidating the cached value
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
await this.refreshOAuth2(this.ctx)
|
|
117
|
-
// Attempt to refresh the access token from the provider
|
|
118
|
-
this.hasRefreshedOAuth = true
|
|
119
|
-
}
|
|
120
|
-
|
|
76
|
+
if (
|
|
77
|
+
info &&
|
|
78
|
+
info.code >= 400 &&
|
|
79
|
+
this.cachedVariables.length > 0 &&
|
|
80
|
+
!this.hasRerun
|
|
81
|
+
) {
|
|
121
82
|
this.hasRerun = true
|
|
83
|
+
// invalidate the cache value
|
|
122
84
|
await threadUtils.invalidateDynamicVariables(this.cachedVariables)
|
|
123
85
|
return this.execute()
|
|
124
86
|
}
|
|
@@ -164,37 +126,6 @@ class QueryRunner {
|
|
|
164
126
|
).execute()
|
|
165
127
|
}
|
|
166
128
|
|
|
167
|
-
async refreshOAuth2(ctx) {
|
|
168
|
-
const { oauth2, providerType, _id } = ctx.user
|
|
169
|
-
const { configId } = ctx.auth
|
|
170
|
-
|
|
171
|
-
if (!providerType || !oauth2?.refreshToken) {
|
|
172
|
-
throw new Error("No refresh token found for authenticated user")
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const resp = await refreshOAuthToken(
|
|
176
|
-
oauth2.refreshToken,
|
|
177
|
-
providerType,
|
|
178
|
-
configId
|
|
179
|
-
)
|
|
180
|
-
|
|
181
|
-
// Refresh session flow. Should be in same location as refreshOAuthToken
|
|
182
|
-
// There are several other properties available in 'resp'
|
|
183
|
-
if (!resp.err) {
|
|
184
|
-
const globalUserId = getGlobalIDFromUserMetadataID(_id)
|
|
185
|
-
await updateUserOAuth(globalUserId, resp)
|
|
186
|
-
this.ctx.user = await userCache.getUser(globalUserId)
|
|
187
|
-
} else {
|
|
188
|
-
// In this event the user may have oAuth issues that
|
|
189
|
-
// could require re-authenticating with their provider.
|
|
190
|
-
throw new Error(
|
|
191
|
-
"OAuth2 access token could not be refreshed: " + resp.err.toString()
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return resp
|
|
196
|
-
}
|
|
197
|
-
|
|
198
129
|
async getDynamicVariable(variable) {
|
|
199
130
|
let { parameters } = this
|
|
200
131
|
const queryId = variable.queryId,
|
|
@@ -21,7 +21,6 @@ const env = require("../../environment")
|
|
|
21
21
|
const {
|
|
22
22
|
USER_METDATA_PREFIX,
|
|
23
23
|
LINK_USER_METADATA_PREFIX,
|
|
24
|
-
TABLE_ROW_PREFIX,
|
|
25
24
|
} = require("../../db/utils")
|
|
26
25
|
const MemoryStream = require("memorystream")
|
|
27
26
|
const { getAppId } = require("@budibase/backend-core/context")
|
|
@@ -110,23 +109,6 @@ exports.apiFileReturn = contents => {
|
|
|
110
109
|
return fs.createReadStream(path)
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
exports.defineFilter = excludeRows => {
|
|
114
|
-
if (excludeRows) {
|
|
115
|
-
return doc =>
|
|
116
|
-
!(
|
|
117
|
-
doc._id.includes(USER_METDATA_PREFIX) ||
|
|
118
|
-
doc._id.includes(LINK_USER_METADATA_PREFIX) ||
|
|
119
|
-
doc._id.includes(TABLE_ROW_PREFIX)
|
|
120
|
-
)
|
|
121
|
-
} else if (!excludeRows) {
|
|
122
|
-
return doc =>
|
|
123
|
-
!(
|
|
124
|
-
doc._id.includes(USER_METDATA_PREFIX) ||
|
|
125
|
-
doc._id.includes(LINK_USER_METADATA_PREFIX)
|
|
126
|
-
)
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
112
|
/**
|
|
131
113
|
* Local utility to back up the database state for an app, excluding global user
|
|
132
114
|
* data or user relationships.
|
|
@@ -134,10 +116,14 @@ exports.defineFilter = excludeRows => {
|
|
|
134
116
|
* @param {object} config Config to send to export DB
|
|
135
117
|
* @returns {*} either a string or a stream of the backup
|
|
136
118
|
*/
|
|
137
|
-
const backupAppData = async (appId, config
|
|
119
|
+
const backupAppData = async (appId, config) => {
|
|
138
120
|
return await exports.exportDB(appId, {
|
|
139
121
|
...config,
|
|
140
|
-
filter:
|
|
122
|
+
filter: doc =>
|
|
123
|
+
!(
|
|
124
|
+
doc._id.includes(USER_METDATA_PREFIX) ||
|
|
125
|
+
doc._id.includes(LINK_USER_METADATA_PREFIX)
|
|
126
|
+
),
|
|
141
127
|
})
|
|
142
128
|
}
|
|
143
129
|
|
|
@@ -156,8 +142,8 @@ exports.performBackup = async (appId, backupName) => {
|
|
|
156
142
|
* @param {string} appId The ID of the app which is to be backed up.
|
|
157
143
|
* @returns {*} a readable stream of the backup which is written in real time
|
|
158
144
|
*/
|
|
159
|
-
exports.streamBackup = async
|
|
160
|
-
return await backupAppData(appId, { stream: true }
|
|
145
|
+
exports.streamBackup = async appId => {
|
|
146
|
+
return await backupAppData(appId, { stream: true })
|
|
161
147
|
}
|
|
162
148
|
|
|
163
149
|
/**
|