@budibase/server 1.0.219 → 1.0.220-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/__mocks__/node-fetch.ts +9 -0
- package/builder/assets/index.530f60fc.js +978 -0
- package/builder/assets/index.7786f497.css +6 -0
- package/builder/assets/{vendor.9bf2fcb4.js → vendor.001dcf8c.js} +163 -163
- package/builder/index.html +3 -3
- package/coverage/clover.xml +927 -832
- package/coverage/coverage-final.json +29 -29
- 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 +111 -12
- package/coverage/lcov-report/api/controllers/backup.js.html +9 -6
- 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 +47 -17
- package/coverage/lcov-report/api/controllers/row/index.html +33 -33
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +159 -21
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +17 -8
- 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 +22 -13
- 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 +32 -2
- 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 +5 -2
- 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 +57 -12
- 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 +2 -2
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +58 -34
- 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 +10 -7
- 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 +27 -51
- 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 +81 -81
- 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 +18 -9
- package/coverage/lcov-report/threads/index.html +25 -25
- package/coverage/lcov-report/threads/query.js.html +301 -79
- 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 +16 -16
- 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 +57 -9
- package/coverage/lcov.info +1656 -1489
- package/dist/api/controllers/application.js +18 -15
- package/dist/api/controllers/automation.js +28 -2
- package/dist/api/controllers/backup.js +3 -2
- package/dist/api/controllers/public/applications.js +1 -1
- package/dist/api/controllers/public/utils.js +8 -1
- package/dist/api/controllers/query/index.js +31 -3
- package/dist/api/controllers/row/external.js +19 -7
- package/dist/api/controllers/row/internalSearch.js +47 -10
- package/dist/api/controllers/row/utils.js +3 -0
- package/dist/api/index.js +4 -1
- package/dist/api/routes/automation.js +2 -0
- package/dist/api/routes/public/rows.js +7 -2
- package/dist/api/routes/utils/validators.js +1 -0
- package/dist/app.js +20 -0
- package/dist/automations/automationUtils.js +16 -4
- package/dist/automations/logging/index.js +70 -0
- package/dist/automations/steps/executeQuery.js +1 -1
- package/dist/automations/steps/filter.js +38 -29
- package/dist/automations/triggers.js +1 -1
- package/dist/db/linkedRows/index.js +1 -0
- package/dist/db/utils.js +4 -31
- package/dist/definitions/datasource.js +1 -0
- package/dist/environment.js +3 -0
- package/dist/integrations/airtable.js +1 -0
- package/dist/integrations/arangodb.js +1 -0
- package/dist/integrations/base/sql.js +22 -3
- package/dist/integrations/couchdb.js +1 -0
- package/dist/integrations/dynamodb.js +1 -0
- package/dist/integrations/elasticsearch.js +1 -0
- package/dist/integrations/firebase.js +1 -0
- package/dist/integrations/googlesheets.js +1 -0
- package/dist/integrations/index.js +4 -0
- package/dist/integrations/microsoftSqlServer.js +2 -1
- package/dist/integrations/mongodb.js +1 -0
- package/dist/integrations/mysql.js +2 -1
- package/dist/integrations/oracle.js +1 -0
- package/dist/integrations/postgres.js +2 -1
- package/dist/integrations/queries/sql.js +3 -0
- package/dist/integrations/redis.js +1 -0
- package/dist/integrations/rest.js +2 -1
- package/dist/integrations/s3.js +1 -0
- package/dist/integrations/snowflake.js +102 -0
- package/dist/package.json +7 -6
- package/dist/tests/utilities/TestConfiguration.js +19 -6
- package/dist/threads/automation.js +6 -3
- package/dist/threads/index.js +15 -1
- package/dist/threads/query.js +65 -12
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +16 -6
- package/dist/utilities/workerRequests.js +8 -0
- package/package.json +8 -7
- package/scripts/dev/manage.js +2 -0
- package/scripts/integrations/oracle/instantclient/linux/arm64/basiclite-19.10.zip +0 -0
- package/scripts/integrations/oracle/instantclient/linux/arm64/install.sh +23 -0
- package/scripts/integrations/oracle/instantclient/linux/install.sh +10 -0
- package/specs/openapi.json +9 -5
- package/specs/openapi.yaml +10 -4
- package/src/api/controllers/application.ts +18 -14
- package/src/api/controllers/automation.js +35 -2
- package/src/api/controllers/backup.js +3 -2
- package/src/api/controllers/public/applications.ts +2 -2
- package/src/api/controllers/public/utils.ts +8 -1
- package/src/api/controllers/query/index.ts +40 -4
- package/src/api/controllers/row/external.js +19 -9
- package/src/api/controllers/row/internalSearch.js +55 -9
- package/src/api/controllers/row/utils.js +3 -0
- package/src/api/index.js +4 -1
- package/src/api/routes/automation.js +10 -0
- package/src/api/routes/public/rows.ts +7 -2
- package/src/api/routes/tests/query.spec.js +166 -1
- package/src/api/routes/utils/validators.js +1 -0
- package/src/app.ts +30 -1
- package/src/automations/automationUtils.js +19 -4
- package/src/automations/logging/index.ts +35 -0
- package/src/automations/steps/executeQuery.js +1 -1
- package/src/automations/steps/filter.js +36 -28
- package/src/automations/tests/filter.spec.js +2 -1
- package/src/automations/triggers.js +1 -1
- package/src/db/linkedRows/index.js +1 -0
- package/src/db/utils.js +5 -13
- package/src/definitions/common.ts +1 -0
- package/src/definitions/datasource.ts +2 -0
- package/src/definitions/openapi.ts +471 -469
- package/src/environment.js +3 -0
- package/src/integrations/airtable.ts +1 -0
- package/src/integrations/arangodb.ts +1 -0
- package/src/integrations/base/sql.ts +29 -11
- package/src/integrations/couchdb.ts +1 -0
- package/src/integrations/dynamodb.ts +1 -0
- package/src/integrations/elasticsearch.ts +1 -0
- package/src/integrations/firebase.ts +1 -0
- package/src/integrations/googlesheets.ts +1 -0
- package/src/integrations/index.ts +4 -0
- package/src/integrations/microsoftSqlServer.ts +2 -0
- package/src/integrations/mongodb.ts +1 -0
- package/src/integrations/mysql.ts +2 -0
- package/src/integrations/oracle.ts +1 -0
- package/src/integrations/postgres.ts +2 -0
- package/src/integrations/queries/sql.ts +3 -1
- package/src/integrations/redis.ts +1 -0
- package/src/integrations/rest.ts +2 -1
- package/src/integrations/s3.ts +1 -0
- package/src/integrations/snowflake.ts +99 -0
- package/src/integrations/tests/rest.spec.js +16 -1
- package/src/migrations/tests/index.spec.ts +18 -2
- package/src/module.d.ts +2 -0
- package/src/tests/utilities/TestConfiguration.js +22 -3
- package/src/threads/automation.js +6 -3
- package/src/threads/index.ts +5 -1
- package/src/threads/query.js +88 -14
- package/src/utilities/fileSystem/index.js +22 -8
- package/src/utilities/workerRequests.js +16 -0
- package/builder/assets/index.1c640a53.js +0 -1316
- package/builder/assets/index.24307ca0.css +0 -6
|
@@ -26,6 +26,8 @@ const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db");
|
|
|
26
26
|
const { encrypt } = require("@budibase/backend-core/encryption");
|
|
27
27
|
const GLOBAL_USER_ID = "us_uuid1";
|
|
28
28
|
const EMAIL = "babs@babs.com";
|
|
29
|
+
const FIRSTNAME = "Barbara";
|
|
30
|
+
const LASTNAME = "Barbington";
|
|
29
31
|
const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306";
|
|
30
32
|
class TestConfiguration {
|
|
31
33
|
constructor(openServer = true) {
|
|
@@ -51,6 +53,14 @@ class TestConfiguration {
|
|
|
51
53
|
getProdAppId() {
|
|
52
54
|
return this.prodAppId;
|
|
53
55
|
}
|
|
56
|
+
getUserDetails() {
|
|
57
|
+
return {
|
|
58
|
+
globalId: GLOBAL_USER_ID,
|
|
59
|
+
email: EMAIL,
|
|
60
|
+
firstName: FIRSTNAME,
|
|
61
|
+
lastName: LASTNAME,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
54
64
|
doInContext(appId, task) {
|
|
55
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
66
|
if (!appId) {
|
|
@@ -109,7 +119,7 @@ class TestConfiguration {
|
|
|
109
119
|
});
|
|
110
120
|
}
|
|
111
121
|
// USER / AUTH
|
|
112
|
-
globalUser({ id = GLOBAL_USER_ID, builder = true, admin = false, email = EMAIL, roles, } = {}) {
|
|
122
|
+
globalUser({ id = GLOBAL_USER_ID, firstName = FIRSTNAME, lastName = LASTNAME, builder = true, admin = false, email = EMAIL, roles, } = {}) {
|
|
113
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
124
|
return doWithGlobalDB(TENANT_ID, (db) => __awaiter(this, void 0, void 0, function* () {
|
|
115
125
|
let existing;
|
|
@@ -119,7 +129,8 @@ class TestConfiguration {
|
|
|
119
129
|
catch (err) {
|
|
120
130
|
existing = { email };
|
|
121
131
|
}
|
|
122
|
-
const user = Object.assign(Object.assign({ _id: id }, existing), { roles: roles || {}, tenantId: TENANT_ID
|
|
132
|
+
const user = Object.assign(Object.assign({ _id: id }, existing), { roles: roles || {}, tenantId: TENANT_ID, firstName,
|
|
133
|
+
lastName });
|
|
123
134
|
yield createASession(id, {
|
|
124
135
|
sessionId: "sessionid",
|
|
125
136
|
tenantId: TENANT_ID,
|
|
@@ -142,11 +153,13 @@ class TestConfiguration {
|
|
|
142
153
|
}));
|
|
143
154
|
});
|
|
144
155
|
}
|
|
145
|
-
createUser(id = null, email = EMAIL, builder = true, admin = false, roles = {}) {
|
|
156
|
+
createUser(id = null, firstName = FIRSTNAME, lastName = LASTNAME, email = EMAIL, builder = true, admin = false, roles = {}) {
|
|
146
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
158
|
const globalId = !id ? `us_${Math.random()}` : `us_${id}`;
|
|
148
159
|
const resp = yield this.globalUser({
|
|
149
160
|
id: globalId,
|
|
161
|
+
firstName,
|
|
162
|
+
lastName,
|
|
150
163
|
email,
|
|
151
164
|
builder,
|
|
152
165
|
admin,
|
|
@@ -466,15 +479,15 @@ class TestConfiguration {
|
|
|
466
479
|
});
|
|
467
480
|
}
|
|
468
481
|
// QUERY
|
|
469
|
-
previewQuery(request, config, datasource, fields) {
|
|
482
|
+
previewQuery(request, config, datasource, fields, params, verb) {
|
|
470
483
|
return __awaiter(this, void 0, void 0, function* () {
|
|
471
484
|
return request
|
|
472
485
|
.post(`/api/queries/preview`)
|
|
473
486
|
.send({
|
|
474
487
|
datasourceId: datasource._id,
|
|
475
|
-
parameters: {},
|
|
488
|
+
parameters: params || {},
|
|
476
489
|
fields,
|
|
477
|
-
queryVerb: "read",
|
|
490
|
+
queryVerb: verb || "read",
|
|
478
491
|
name: datasource.name,
|
|
479
492
|
})
|
|
480
493
|
.set(config.defaultHeaders())
|
|
@@ -19,10 +19,11 @@ const { doInTenant } = require("@budibase/backend-core/tenancy");
|
|
|
19
19
|
const { definitions: triggerDefs } = require("../automations/triggerInfo");
|
|
20
20
|
const { doInAppContext, getAppDB } = require("@budibase/backend-core/context");
|
|
21
21
|
const { AutomationErrors, LoopStepTypes } = require("../constants");
|
|
22
|
+
const { storeLog } = require("../automations/logging");
|
|
22
23
|
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId;
|
|
23
24
|
const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId;
|
|
24
25
|
const CRON_STEP_ID = triggerDefs.CRON.stepId;
|
|
25
|
-
const STOPPED_STATUS = { success:
|
|
26
|
+
const STOPPED_STATUS = { success: true, status: "STOPPED" };
|
|
26
27
|
const { cloneDeep } = require("lodash/fp");
|
|
27
28
|
const env = require("../environment");
|
|
28
29
|
function typecastForLooping(loopStep, input) {
|
|
@@ -195,7 +196,7 @@ class Orchestrator {
|
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
|
-
if (index ===
|
|
199
|
+
if (index === env.AUTOMATION_MAX_ITERATION ||
|
|
199
200
|
index === parseInt(loopStep.inputs.iterations)) {
|
|
200
201
|
this.updateContextAndOutput(loopStepNumber, step, tempOutput, {
|
|
201
202
|
status: AutomationErrors.MAX_ITERATIONS,
|
|
@@ -248,7 +249,7 @@ class Orchestrator {
|
|
|
248
249
|
this._context.steps[stepCount] = outputs;
|
|
249
250
|
// if filter causes us to stop execution don't break the loop, set a var
|
|
250
251
|
// so that we can finish iterating through the steps and record that it stopped
|
|
251
|
-
if (step.stepId === FILTER_STEP_ID && !outputs.
|
|
252
|
+
if (step.stepId === FILTER_STEP_ID && !outputs.result) {
|
|
252
253
|
stopped = true;
|
|
253
254
|
this.updateExecutionOutput(step.id, step.stepId, step.inputs, Object.assign(Object.assign({}, outputs), STOPPED_STATUS));
|
|
254
255
|
continue;
|
|
@@ -289,6 +290,8 @@ class Orchestrator {
|
|
|
289
290
|
loopSteps = null;
|
|
290
291
|
}
|
|
291
292
|
}
|
|
293
|
+
// store the logs for the automation run
|
|
294
|
+
yield storeLog(this._automation, this.executionOutput);
|
|
292
295
|
return this.executionOutput;
|
|
293
296
|
});
|
|
294
297
|
}
|
package/dist/threads/index.js
CHANGED
|
@@ -22,6 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
25
34
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
36
|
};
|
|
@@ -92,7 +101,7 @@ class Thread {
|
|
|
92
101
|
});
|
|
93
102
|
});
|
|
94
103
|
}
|
|
95
|
-
static
|
|
104
|
+
static stopThreads() {
|
|
96
105
|
return new Promise(resolve => {
|
|
97
106
|
if (Thread.workerRefs.length === 0) {
|
|
98
107
|
resolve();
|
|
@@ -110,6 +119,11 @@ class Thread {
|
|
|
110
119
|
Thread.workerRefs = [];
|
|
111
120
|
});
|
|
112
121
|
}
|
|
122
|
+
static shutdown() {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
yield Thread.stopThreads();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
113
127
|
}
|
|
114
128
|
exports.Thread = Thread;
|
|
115
129
|
Thread.workerRefs = [];
|
package/dist/threads/query.js
CHANGED
|
@@ -14,6 +14,10 @@ const ScriptRunner = require("../utilities/scriptRunner");
|
|
|
14
14
|
const { integrations } = require("../integrations");
|
|
15
15
|
const { processStringSync } = require("@budibase/string-templates");
|
|
16
16
|
const { doInAppContext, getAppDB } = require("@budibase/backend-core/context");
|
|
17
|
+
const { refreshOAuthToken, updateUserOAuth, } = require("@budibase/backend-core/auth");
|
|
18
|
+
const { user: userCache } = require("@budibase/backend-core/cache");
|
|
19
|
+
const { getGlobalIDFromUserMetadataID } = require("../db/utils");
|
|
20
|
+
const { cloneDeep } = require("lodash/fp");
|
|
17
21
|
const { isSQL } = require("../integrations/utils");
|
|
18
22
|
const { enrichQueryFields, interpolateSQL, } = require("../integrations/queries/sql");
|
|
19
23
|
class QueryRunner {
|
|
@@ -27,29 +31,49 @@ class QueryRunner {
|
|
|
27
31
|
this.queryId = input.queryId;
|
|
28
32
|
this.noRecursiveQuery = flags.noRecursiveQuery;
|
|
29
33
|
this.cachedVariables = [];
|
|
34
|
+
// Additional context items for enrichment
|
|
35
|
+
this.ctx = input.ctx;
|
|
30
36
|
// allows the response from a query to be stored throughout this
|
|
31
37
|
// execution so that if it needs to be re-used for another variable
|
|
32
38
|
// it can be
|
|
33
39
|
this.queryResponse = {};
|
|
34
40
|
this.hasRerun = false;
|
|
41
|
+
this.hasRefreshedOAuth = false;
|
|
35
42
|
}
|
|
36
43
|
execute() {
|
|
44
|
+
var _a;
|
|
37
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
46
|
let { datasource, fields, queryVerb, transformer } = this;
|
|
39
|
-
|
|
47
|
+
let datasourceClone = cloneDeep(datasource);
|
|
48
|
+
let fieldsClone = cloneDeep(fields);
|
|
49
|
+
const Integration = integrations[datasourceClone.source];
|
|
40
50
|
if (!Integration) {
|
|
41
51
|
throw "Integration type does not exist.";
|
|
42
52
|
}
|
|
43
|
-
|
|
53
|
+
if (datasourceClone.config.authConfigs) {
|
|
54
|
+
datasourceClone.config.authConfigs =
|
|
55
|
+
datasourceClone.config.authConfigs.map(config => {
|
|
56
|
+
return enrichQueryFields(config, this.ctx);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const integration = new Integration(datasourceClone.config);
|
|
44
60
|
// pre-query, make sure datasource variables are added to parameters
|
|
45
61
|
const parameters = yield this.addDatasourceVariables();
|
|
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 = Object.assign(Object.assign({}, enrichedParameters), this.ctx);
|
|
66
|
+
// Parse global headers
|
|
67
|
+
if (datasourceClone.config.defaultHeaders) {
|
|
68
|
+
datasourceClone.config.defaultHeaders = enrichQueryFields(datasourceClone.config.defaultHeaders, enrichedContext);
|
|
69
|
+
}
|
|
46
70
|
let query;
|
|
47
71
|
// handle SQL injections by interpolating the variables
|
|
48
|
-
if (isSQL(
|
|
49
|
-
query = interpolateSQL(
|
|
72
|
+
if (isSQL(datasourceClone)) {
|
|
73
|
+
query = interpolateSQL(fieldsClone, enrichedParameters, integration);
|
|
50
74
|
}
|
|
51
75
|
else {
|
|
52
|
-
query = enrichQueryFields(
|
|
76
|
+
query = enrichQueryFields(fieldsClone, enrichedContext);
|
|
53
77
|
}
|
|
54
78
|
// Add pagination values for REST queries
|
|
55
79
|
if (this.pagination) {
|
|
@@ -67,17 +91,22 @@ class QueryRunner {
|
|
|
67
91
|
if (transformer) {
|
|
68
92
|
const runner = new ScriptRunner(transformer, {
|
|
69
93
|
data: rows,
|
|
70
|
-
params:
|
|
94
|
+
params: enrichedParameters,
|
|
71
95
|
});
|
|
72
96
|
rows = runner.execute();
|
|
73
97
|
}
|
|
74
98
|
// if the request fails we retry once, invalidating the cached value
|
|
75
|
-
if (info &&
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
99
|
+
if (info && info.code >= 400 && !this.hasRerun) {
|
|
100
|
+
if (((_a = this.ctx.user) === null || _a === void 0 ? void 0 : _a.provider) &&
|
|
101
|
+
info.code === 401 &&
|
|
102
|
+
!this.hasRefreshedOAuth) {
|
|
103
|
+
yield this.refreshOAuth2(this.ctx);
|
|
104
|
+
// Attempt to refresh the access token from the provider
|
|
105
|
+
this.hasRefreshedOAuth = true;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.hasRerun = true;
|
|
109
|
+
}
|
|
81
110
|
yield threadUtils.invalidateDynamicVariables(this.cachedVariables);
|
|
82
111
|
return this.execute();
|
|
83
112
|
}
|
|
@@ -115,6 +144,30 @@ class QueryRunner {
|
|
|
115
144
|
}, { noRecursiveQuery: true }).execute();
|
|
116
145
|
});
|
|
117
146
|
}
|
|
147
|
+
refreshOAuth2(ctx) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
const { oauth2, providerType, _id } = ctx.user;
|
|
150
|
+
const { configId } = ctx.auth;
|
|
151
|
+
if (!providerType || !(oauth2 === null || oauth2 === void 0 ? void 0 : oauth2.refreshToken)) {
|
|
152
|
+
throw new Error("No refresh token found for authenticated user");
|
|
153
|
+
}
|
|
154
|
+
const resp = yield refreshOAuthToken(oauth2.refreshToken, providerType, configId);
|
|
155
|
+
// Refresh session flow. Should be in same location as refreshOAuthToken
|
|
156
|
+
// There are several other properties available in 'resp'
|
|
157
|
+
if (!resp.err) {
|
|
158
|
+
const globalUserId = getGlobalIDFromUserMetadataID(_id);
|
|
159
|
+
yield updateUserOAuth(globalUserId, resp);
|
|
160
|
+
this.ctx.user = yield userCache.getUser(globalUserId);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
// In this event the user may have oAuth issues that
|
|
164
|
+
// could require re-authenticating with their provider.
|
|
165
|
+
let errorMessage = resp.err.data ? resp.err.data : resp.err.toString();
|
|
166
|
+
throw new Error("OAuth2 access token could not be refreshed: " + errorMessage);
|
|
167
|
+
}
|
|
168
|
+
return resp;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
118
171
|
getDynamicVariable(variable) {
|
|
119
172
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
173
|
let { parameters } = this;
|