@budibase/server 1.0.219 → 1.0.220-alpha.2
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/.yarnrc +1 -0
- package/__mocks__/node-fetch.ts +9 -0
- package/builder/assets/index.7786f497.css +6 -0
- package/builder/assets/index.e1885c5f.js +974 -0
- package/builder/assets/{vendor.9bf2fcb4.js → vendor.001dcf8c.js} +163 -163
- package/builder/index.html +3 -3
- package/coverage/clover.xml +1018 -950
- package/coverage/coverage-final.json +31 -31
- 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 +13 -166
- package/coverage/lcov-report/api/controllers/index.html +32 -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 +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 +2 -5
- 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 +83 -83
- 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 +26 -26
- package/coverage/lcov-report/utilities/index.js.html +17 -32
- 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 +1789 -1665
- package/dist/api/controllers/application.js +19 -16
- package/dist/api/controllers/automation.js +28 -2
- package/dist/api/controllers/backup.js +3 -2
- package/dist/api/controllers/dev.js +2 -40
- 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/controllers/static/index.js +1 -5
- package/dist/api/index.js +4 -1
- package/dist/api/routes/automation.js +2 -0
- package/dist/api/routes/dev.js +1 -2
- 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/index.js +1 -5
- 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 +19 -19
- package/src/api/controllers/automation.js +35 -2
- package/src/api/controllers/backup.js +3 -2
- package/src/api/controllers/dev.js +2 -53
- 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/controllers/static/index.js +1 -6
- package/src/api/index.js +4 -1
- package/src/api/routes/automation.js +10 -0
- package/src/api/routes/dev.js +0 -1
- 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/index.js +1 -6
- package/src/utilities/workerRequests.js +16 -0
- package/builder/assets/index.1c640a53.js +0 -1316
- package/builder/assets/index.24307ca0.css +0 -6
|
@@ -33,7 +33,8 @@ const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy")
|
|
|
33
33
|
const user_1 = require("./user");
|
|
34
34
|
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
35
35
|
const utils_2 = require("../../automations/utils");
|
|
36
|
-
const
|
|
36
|
+
const logging_1 = require("../../automations/logging");
|
|
37
|
+
const { getAppDB, getProdAppDB, updateAppId, doInAppContext, } = require("@budibase/backend-core/context");
|
|
37
38
|
const rows_1 = require("../../utilities/usageQuota/rows");
|
|
38
39
|
const pro_1 = require("@budibase/pro");
|
|
39
40
|
const backend_core_1 = require("@budibase/backend-core");
|
|
@@ -159,7 +160,7 @@ const fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
|
-
ctx.body = apps;
|
|
163
|
+
ctx.body = yield (0, logging_1.checkAppMetadata)(apps);
|
|
163
164
|
});
|
|
164
165
|
exports.fetch = fetch;
|
|
165
166
|
const fetchAppDefinition = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -189,7 +190,7 @@ const fetchAppPackage = (ctx) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
189
190
|
application,
|
|
190
191
|
screens,
|
|
191
192
|
layouts,
|
|
192
|
-
clientLibPath: (0, utilities_1.clientLibraryPath)(ctx.params.appId, application.version
|
|
193
|
+
clientLibPath: (0, utilities_1.clientLibraryPath)(ctx.params.appId, application.version),
|
|
193
194
|
};
|
|
194
195
|
});
|
|
195
196
|
exports.fetchAppPackage = fetchAppPackage;
|
|
@@ -486,19 +487,21 @@ const sync = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
486
487
|
});
|
|
487
488
|
exports.sync = sync;
|
|
488
489
|
const updateAppPackage = (appPackage, appId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
490
|
+
return doInAppContext(appId, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
491
|
+
const db = getAppDB();
|
|
492
|
+
const application = yield db.get(utils_1.DocumentTypes.APP_METADATA);
|
|
493
|
+
const newAppPackage = Object.assign(Object.assign({}, application), appPackage);
|
|
494
|
+
if (appPackage._rev !== application._rev) {
|
|
495
|
+
newAppPackage._rev = application._rev;
|
|
496
|
+
}
|
|
497
|
+
// the locked by property is attached by server but generated from
|
|
498
|
+
// Redis, shouldn't ever store it
|
|
499
|
+
delete newAppPackage.lockedBy;
|
|
500
|
+
yield db.put(newAppPackage);
|
|
501
|
+
// remove any cached metadata, so that it will be updated
|
|
502
|
+
yield appCache.invalidateAppMetadata(appId);
|
|
503
|
+
return newAppPackage;
|
|
504
|
+
}));
|
|
502
505
|
});
|
|
503
506
|
const createEmptyAppPackage = (ctx, app) => __awaiter(void 0, void 0, void 0, function* () {
|
|
504
507
|
const db = getAppDB();
|
|
@@ -10,13 +10,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const actions = require("../../automations/actions");
|
|
12
12
|
const triggers = require("../../automations/triggers");
|
|
13
|
-
const { getAutomationParams, generateAutomationID } = require("../../db/utils");
|
|
13
|
+
const { getAutomationParams, generateAutomationID, DocumentTypes, } = require("../../db/utils");
|
|
14
14
|
const { checkForWebhooks, updateTestHistory, removeDeprecated, } = require("../../automations/utils");
|
|
15
15
|
const { deleteEntityMetadata } = require("../../utilities");
|
|
16
16
|
const { MetadataTypes } = require("../../constants");
|
|
17
17
|
const { setTestFlag, clearTestFlag } = require("../../utilities/redis");
|
|
18
|
-
const { getAppDB } = require("@budibase/backend-core/context");
|
|
18
|
+
const { getAppDB, getProdAppDB, doInAppContext, } = require("@budibase/backend-core/context");
|
|
19
19
|
const { events } = require("@budibase/backend-core");
|
|
20
|
+
const { app } = require("@budibase/backend-core/cache");
|
|
21
|
+
const { automations } = require("@budibase/pro");
|
|
20
22
|
const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS);
|
|
21
23
|
const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS);
|
|
22
24
|
/*************************
|
|
@@ -162,6 +164,30 @@ exports.destroy = function (ctx) {
|
|
|
162
164
|
yield events.automation.deleted(oldAutomation);
|
|
163
165
|
});
|
|
164
166
|
};
|
|
167
|
+
exports.logSearch = function (ctx) {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
ctx.body = yield automations.logs.logSearch(ctx.request.body);
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
exports.clearLogError = function (ctx) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
const { automationId, appId } = ctx.request.body;
|
|
175
|
+
yield doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
176
|
+
const db = getProdAppDB();
|
|
177
|
+
const metadata = yield db.get(DocumentTypes.APP_METADATA);
|
|
178
|
+
if (!automationId) {
|
|
179
|
+
delete metadata.automationErrors;
|
|
180
|
+
}
|
|
181
|
+
else if (metadata.automationErrors &&
|
|
182
|
+
metadata.automationErrors[automationId]) {
|
|
183
|
+
delete metadata.automationErrors[automationId];
|
|
184
|
+
}
|
|
185
|
+
yield db.put(metadata);
|
|
186
|
+
yield app.invalidateAppMetadata(metadata.appId, metadata);
|
|
187
|
+
ctx.body = { message: `Error logs cleared.` };
|
|
188
|
+
}));
|
|
189
|
+
});
|
|
190
|
+
};
|
|
165
191
|
exports.getActionList = function (ctx) {
|
|
166
192
|
return __awaiter(this, void 0, void 0, function* () {
|
|
167
193
|
ctx.body = ACTION_DEFS;
|
|
@@ -13,11 +13,12 @@ const { events, context } = require("@budibase/backend-core");
|
|
|
13
13
|
const { DocumentTypes } = require("../../db/utils");
|
|
14
14
|
exports.exportAppDump = function (ctx) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
|
|
16
|
+
let { appId, excludeRows } = ctx.query;
|
|
17
17
|
const appName = decodeURI(ctx.query.appname);
|
|
18
|
+
excludeRows = excludeRows === "true";
|
|
18
19
|
const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt`;
|
|
19
20
|
ctx.attachment(backupIdentifier);
|
|
20
|
-
ctx.body = yield streamBackup(appId);
|
|
21
|
+
ctx.body = yield streamBackup(appId, excludeRows);
|
|
21
22
|
yield context.doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
22
23
|
const appDb = context.getAppDB();
|
|
23
24
|
const app = yield appDb.get(DocumentTypes.APP_METADATA);
|
|
@@ -13,8 +13,8 @@ const env = require("../../environment");
|
|
|
13
13
|
const { checkSlashesInUrl } = require("../../utilities");
|
|
14
14
|
const { request } = require("../../utilities/workerRequests");
|
|
15
15
|
const { clearLock } = require("../../utilities/redis");
|
|
16
|
-
const { Replication, getProdAppID
|
|
17
|
-
const { DocumentTypes
|
|
16
|
+
const { Replication, getProdAppID } = require("@budibase/backend-core/db");
|
|
17
|
+
const { DocumentTypes } = require("../../db/utils");
|
|
18
18
|
const { app: appCache } = require("@budibase/backend-core/cache");
|
|
19
19
|
const { getProdAppDB, getAppDB } = require("@budibase/backend-core/context");
|
|
20
20
|
const { events } = require("@budibase/backend-core");
|
|
@@ -129,41 +129,3 @@ exports.getBudibaseVersion = (ctx) => __awaiter(void 0, void 0, void 0, function
|
|
|
129
129
|
};
|
|
130
130
|
yield events.installation.versionChecked(version);
|
|
131
131
|
});
|
|
132
|
-
// TODO: remove as part of beta program
|
|
133
|
-
exports.checkBetaAccess = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
134
|
-
// go to the cloud platform if running self hosted
|
|
135
|
-
if (env.SELF_HOSTED || !env.MULTI_TENANCY) {
|
|
136
|
-
let baseUrl = "";
|
|
137
|
-
if (env.ACCOUNT_PORTAL_URL) {
|
|
138
|
-
baseUrl = env.ACCOUNT_PORTAL_URL.replace("account.", "");
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
baseUrl = "https://budibase.app";
|
|
142
|
-
}
|
|
143
|
-
const response = yield fetch(`${baseUrl}/api/beta/access?email=${ctx.query.email}`);
|
|
144
|
-
const json = yield response.json();
|
|
145
|
-
ctx.body = json;
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const userToCheck = ctx.query.email;
|
|
149
|
-
const BETA_USERS_DB = "app_bb_f9b77d06b9db4e3ca185476ab87a2364";
|
|
150
|
-
const BETA_USERS_TABLE = "ta_8c2c6df1c03f49cfb6340e85e066dd15";
|
|
151
|
-
try {
|
|
152
|
-
const db = dangerousGetDB(BETA_USERS_DB);
|
|
153
|
-
const betaUsers = (yield db.allDocs(getRowParams(BETA_USERS_TABLE, null, {
|
|
154
|
-
include_docs: true,
|
|
155
|
-
}))).rows.map(row => row.doc);
|
|
156
|
-
let access = false;
|
|
157
|
-
for (let betaUser of betaUsers) {
|
|
158
|
-
if (betaUser["Email address"].trim() === userToCheck) {
|
|
159
|
-
access = true;
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
ctx.body = { access };
|
|
164
|
-
}
|
|
165
|
-
catch (err) {
|
|
166
|
-
console.error(err);
|
|
167
|
-
ctx.body = { access: false };
|
|
168
|
-
}
|
|
169
|
-
});
|
|
@@ -84,7 +84,7 @@ function read(ctx, next) {
|
|
|
84
84
|
exports.read = read;
|
|
85
85
|
function update(ctx, next) {
|
|
86
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
ctx.request.body = fixAppID(ctx.request.body, ctx.params);
|
|
87
|
+
ctx.request.body = yield (0, utils_1.addRev)(fixAppID(ctx.request.body, ctx.params));
|
|
88
88
|
updateAppId(ctx.params.appId);
|
|
89
89
|
yield controller.update(ctx);
|
|
90
90
|
yield setResponseApp(ctx);
|
|
@@ -12,14 +12,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.search = exports.addRev = void 0;
|
|
13
13
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
14
14
|
const utils_1 = require("../../../integrations/utils");
|
|
15
|
+
const utils_2 = require("../../../db/utils");
|
|
15
16
|
function addRev(body, tableId) {
|
|
16
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
18
|
if (!body._id || (tableId && (0, utils_1.isExternalTable)(tableId))) {
|
|
18
19
|
return body;
|
|
19
20
|
}
|
|
21
|
+
let id = body._id;
|
|
22
|
+
if (body._id.startsWith(utils_2.APP_PREFIX)) {
|
|
23
|
+
id = utils_2.DocumentTypes.APP_METADATA;
|
|
24
|
+
}
|
|
20
25
|
const db = getAppDB();
|
|
21
|
-
const dbDoc = yield db.get(
|
|
26
|
+
const dbDoc = yield db.get(id);
|
|
22
27
|
body._rev = dbDoc._rev;
|
|
28
|
+
// update ID in case it is an app ID
|
|
29
|
+
body._id = id;
|
|
23
30
|
return body;
|
|
24
31
|
});
|
|
25
32
|
}
|
|
@@ -20,6 +20,8 @@ const environment_1 = require("../../../environment");
|
|
|
20
20
|
const context_1 = require("@budibase/backend-core/context");
|
|
21
21
|
const pro_1 = require("@budibase/pro");
|
|
22
22
|
const backend_core_1 = require("@budibase/backend-core");
|
|
23
|
+
const utils_3 = require("@budibase/backend-core/utils");
|
|
24
|
+
const constants_2 = require("@budibase/backend-core/constants");
|
|
23
25
|
const Runner = new threads_1.Thread(threads_1.ThreadType.QUERY, {
|
|
24
26
|
timeoutMs: environment_1.QUERY_THREAD_TIMEOUT || 10000,
|
|
25
27
|
});
|
|
@@ -111,6 +113,19 @@ function find(ctx) {
|
|
|
111
113
|
});
|
|
112
114
|
}
|
|
113
115
|
exports.find = find;
|
|
116
|
+
//Required to discern between OIDC OAuth config entries
|
|
117
|
+
function getOAuthConfigCookieId(ctx) {
|
|
118
|
+
if (ctx.user.providerType === constants_2.Configs.OIDC) {
|
|
119
|
+
return (0, utils_3.getCookie)(ctx, constants_2.Cookies.OIDC_CONFIG);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function getAuthConfig(ctx) {
|
|
123
|
+
const authCookie = (0, utils_3.getCookie)(ctx, constants_2.Cookies.Auth);
|
|
124
|
+
let authConfigCtx = {};
|
|
125
|
+
authConfigCtx["configId"] = getOAuthConfigCookieId(ctx);
|
|
126
|
+
authConfigCtx["sessionId"] = authCookie ? authCookie.sessionId : null;
|
|
127
|
+
return authConfigCtx;
|
|
128
|
+
}
|
|
114
129
|
function preview(ctx) {
|
|
115
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
116
131
|
const db = (0, context_1.getAppDB)();
|
|
@@ -119,6 +134,7 @@ function preview(ctx) {
|
|
|
119
134
|
// preview may not have a queryId as it hasn't been saved, but if it does
|
|
120
135
|
// this stops dynamic variables from calling the same query
|
|
121
136
|
const { fields, parameters, queryVerb, transformer, queryId } = query;
|
|
137
|
+
const authConfigCtx = getAuthConfig(ctx);
|
|
122
138
|
try {
|
|
123
139
|
const runFn = () => Runner.run({
|
|
124
140
|
appId: ctx.appId,
|
|
@@ -128,6 +144,10 @@ function preview(ctx) {
|
|
|
128
144
|
parameters,
|
|
129
145
|
transformer,
|
|
130
146
|
queryId,
|
|
147
|
+
ctx: {
|
|
148
|
+
user: ctx.user,
|
|
149
|
+
auth: Object.assign({}, authConfigCtx),
|
|
150
|
+
},
|
|
131
151
|
});
|
|
132
152
|
const { rows, keys, info, extra } = yield pro_1.quotas.addQuery(runFn);
|
|
133
153
|
yield backend_core_1.events.query.previewed(datasource, query);
|
|
@@ -144,11 +164,15 @@ function preview(ctx) {
|
|
|
144
164
|
});
|
|
145
165
|
}
|
|
146
166
|
exports.preview = preview;
|
|
147
|
-
function execute(ctx, opts = { rowsOnly: false }) {
|
|
167
|
+
function execute(ctx, opts = { rowsOnly: false, isAutomation: false }) {
|
|
148
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
169
|
const db = (0, context_1.getAppDB)();
|
|
150
170
|
const query = yield db.get(ctx.params.queryId);
|
|
151
171
|
const datasource = yield db.get(query.datasourceId);
|
|
172
|
+
let authConfigCtx = {};
|
|
173
|
+
if (!opts.isAutomation) {
|
|
174
|
+
authConfigCtx = getAuthConfig(ctx);
|
|
175
|
+
}
|
|
152
176
|
const enrichedParameters = ctx.request.body.parameters || {};
|
|
153
177
|
// make sure parameters are fully enriched with defaults
|
|
154
178
|
if (query && query.parameters) {
|
|
@@ -169,6 +193,10 @@ function execute(ctx, opts = { rowsOnly: false }) {
|
|
|
169
193
|
parameters: enrichedParameters,
|
|
170
194
|
transformer: query.transformer,
|
|
171
195
|
queryId: ctx.params.queryId,
|
|
196
|
+
ctx: {
|
|
197
|
+
user: ctx.user,
|
|
198
|
+
auth: Object.assign({}, authConfigCtx),
|
|
199
|
+
},
|
|
172
200
|
});
|
|
173
201
|
const { rows, pagination, extra } = yield pro_1.quotas.addQuery(runFn);
|
|
174
202
|
if (opts && opts.rowsOnly) {
|
|
@@ -189,9 +217,9 @@ function executeV1(ctx) {
|
|
|
189
217
|
});
|
|
190
218
|
}
|
|
191
219
|
exports.executeV1 = executeV1;
|
|
192
|
-
function executeV2(ctx) {
|
|
220
|
+
function executeV2(ctx, { isAutomation } = {}) {
|
|
193
221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
-
return execute(ctx, { rowsOnly: false });
|
|
222
|
+
return execute(ctx, { rowsOnly: false, isAutomation });
|
|
195
223
|
});
|
|
196
224
|
}
|
|
197
225
|
exports.executeV2 = executeV2;
|
|
@@ -155,29 +155,41 @@ exports.validate = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
155
155
|
return { valid: true };
|
|
156
156
|
});
|
|
157
157
|
exports.exportRows = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
158
|
-
const { datasourceId
|
|
158
|
+
const { datasourceId } = breakExternalTableId(ctx.params.tableId);
|
|
159
159
|
const db = getAppDB();
|
|
160
|
-
|
|
160
|
+
const format = ctx.query.format;
|
|
161
|
+
const { columns } = ctx.request.body;
|
|
161
162
|
const datasource = yield db.get(datasourceId);
|
|
162
163
|
if (!datasource || !datasource.entities) {
|
|
163
164
|
ctx.throw(400, "Datasource has not been configured for plus API.");
|
|
164
165
|
}
|
|
165
|
-
const tables = datasource.entities;
|
|
166
|
-
const table = tables[tableName];
|
|
167
166
|
ctx.request.body = {
|
|
168
167
|
query: {
|
|
169
168
|
oneOf: {
|
|
170
|
-
|
|
169
|
+
_id: ctx.request.body.rows.map(row => JSON.parse(decodeURI(row))[0]),
|
|
171
170
|
},
|
|
172
171
|
},
|
|
173
172
|
};
|
|
174
173
|
let result = yield exports.search(ctx);
|
|
175
|
-
let
|
|
174
|
+
let rows = [];
|
|
175
|
+
// Filter data to only specified columns if required
|
|
176
|
+
if (columns && columns.length) {
|
|
177
|
+
for (let i = 0; i < result.rows.length; i++) {
|
|
178
|
+
rows[i] = {};
|
|
179
|
+
for (let column of columns) {
|
|
180
|
+
rows[i][column] = result.rows[i][column];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
rows = result.rows;
|
|
186
|
+
}
|
|
187
|
+
let headers = Object.keys(rows[0]);
|
|
176
188
|
const exporter = exporters[format];
|
|
177
189
|
const filename = `export.${format}`;
|
|
178
190
|
// send down the file
|
|
179
191
|
ctx.attachment(filename);
|
|
180
|
-
return apiFileReturn(exporter(headers,
|
|
192
|
+
return apiFileReturn(exporter(headers, rows));
|
|
181
193
|
});
|
|
182
194
|
exports.fetchEnrichedRow = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
195
|
const id = ctx.params.rowId;
|
|
@@ -18,7 +18,7 @@ const { getAppId } = require("@budibase/backend-core/context");
|
|
|
18
18
|
*/
|
|
19
19
|
class QueryBuilder {
|
|
20
20
|
constructor(base) {
|
|
21
|
-
this.query = Object.assign({ string: {}, fuzzy: {}, range: {}, equal: {}, notEqual: {}, empty: {}, notEmpty: {} }, base);
|
|
21
|
+
this.query = Object.assign({ allOr: false, string: {}, fuzzy: {}, range: {}, equal: {}, notEqual: {}, empty: {}, notEmpty: {}, oneOf: {} }, base);
|
|
22
22
|
this.limit = 50;
|
|
23
23
|
this.sortOrder = "ascending";
|
|
24
24
|
this.sortType = "string";
|
|
@@ -96,6 +96,10 @@ class QueryBuilder {
|
|
|
96
96
|
this.query.notEmpty[key] = value;
|
|
97
97
|
return this;
|
|
98
98
|
}
|
|
99
|
+
addOneOf(key, value) {
|
|
100
|
+
this.query.oneOf[key] = value;
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
99
103
|
/**
|
|
100
104
|
* Preprocesses a value before going into a lucene search.
|
|
101
105
|
* Transforms strings to lowercase and wraps strings and bools in quotes.
|
|
@@ -123,8 +127,21 @@ class QueryBuilder {
|
|
|
123
127
|
}
|
|
124
128
|
buildSearchQuery() {
|
|
125
129
|
const builder = this;
|
|
126
|
-
let
|
|
130
|
+
let allOr = this.query && this.query.allOr;
|
|
131
|
+
let query = allOr ? "" : "*:*";
|
|
127
132
|
const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true };
|
|
133
|
+
let tableId;
|
|
134
|
+
if (this.query.equal.tableId) {
|
|
135
|
+
tableId = this.query.equal.tableId;
|
|
136
|
+
delete this.query.equal.tableId;
|
|
137
|
+
}
|
|
138
|
+
const equal = (key, value) => {
|
|
139
|
+
// 0 evaluates to false, which means we would return all rows if we don't check it
|
|
140
|
+
if (!value && value !== 0) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
144
|
+
};
|
|
128
145
|
function build(structure, queryFn) {
|
|
129
146
|
for (let [key, value] of Object.entries(structure)) {
|
|
130
147
|
key = builder.preprocess(key.replace(/ /g, "_"), {
|
|
@@ -134,7 +151,10 @@ class QueryBuilder {
|
|
|
134
151
|
if (expression == null) {
|
|
135
152
|
continue;
|
|
136
153
|
}
|
|
137
|
-
query
|
|
154
|
+
if (query.length > 0) {
|
|
155
|
+
query += ` ${allOr ? "OR" : "AND"} `;
|
|
156
|
+
}
|
|
157
|
+
query += expression;
|
|
138
158
|
}
|
|
139
159
|
}
|
|
140
160
|
// Construct the actual lucene search query string from JSON structure
|
|
@@ -179,13 +199,7 @@ class QueryBuilder {
|
|
|
179
199
|
});
|
|
180
200
|
}
|
|
181
201
|
if (this.query.equal) {
|
|
182
|
-
build(this.query.equal,
|
|
183
|
-
// 0 evaluates to false, which means we would return all rows if we don't check it
|
|
184
|
-
if (!value && value !== 0) {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`;
|
|
188
|
-
});
|
|
202
|
+
build(this.query.equal, equal);
|
|
189
203
|
}
|
|
190
204
|
if (this.query.notEqual) {
|
|
191
205
|
build(this.query.notEqual, (key, value) => {
|
|
@@ -201,6 +215,29 @@ class QueryBuilder {
|
|
|
201
215
|
if (this.query.notEmpty) {
|
|
202
216
|
build(this.query.notEmpty, key => `${key}:["" TO *]`);
|
|
203
217
|
}
|
|
218
|
+
if (this.query.oneOf) {
|
|
219
|
+
build(this.query.oneOf, (key, value) => {
|
|
220
|
+
if (!Array.isArray(value)) {
|
|
221
|
+
if (typeof value === "string") {
|
|
222
|
+
value = value.split(",");
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
return "";
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
let orStatement = `${builder.preprocess(value[0], allPreProcessingOpts)}`;
|
|
229
|
+
for (let i = 1; i < value.length; i++) {
|
|
230
|
+
orStatement += ` OR ${builder.preprocess(value[i], allPreProcessingOpts)}`;
|
|
231
|
+
}
|
|
232
|
+
return `${key}:(${orStatement})`;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
// make sure table ID is always added as an AND
|
|
236
|
+
if (tableId) {
|
|
237
|
+
query = `(${query})`;
|
|
238
|
+
allOr = false;
|
|
239
|
+
build({ tableId }, equal);
|
|
240
|
+
}
|
|
204
241
|
return query;
|
|
205
242
|
}
|
|
206
243
|
buildSearchBody() {
|
|
@@ -70,6 +70,9 @@ exports.validate = ({ tableId, row, table }) => __awaiter(void 0, void 0, void 0
|
|
|
70
70
|
// Validate.js doesn't seem to handle array
|
|
71
71
|
if (type === FieldTypes.ARRAY && row[fieldName]) {
|
|
72
72
|
if (row[fieldName].length) {
|
|
73
|
+
if (!Array.isArray(row[fieldName])) {
|
|
74
|
+
row[fieldName] = row[fieldName].split(",");
|
|
75
|
+
}
|
|
73
76
|
row[fieldName].map(val => {
|
|
74
77
|
if (!constraints.inclusion.includes(val) &&
|
|
75
78
|
constraints.inclusion.length !== 0) {
|
|
@@ -69,11 +69,7 @@ exports.toggleBetaUiFeature = function (ctx) {
|
|
|
69
69
|
};
|
|
70
70
|
exports.serveBuilder = function (ctx) {
|
|
71
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
|
|
73
|
-
const designUiCookie = ctx.cookies.get("beta:design_ui");
|
|
74
|
-
// TODO: get this from the tmp Dir that we downloaded from MinIO
|
|
75
|
-
const uiPath = designUiCookie ? "new_design_ui" : "builder";
|
|
76
|
-
let builderPath = resolve(TOP_LEVEL_PATH, uiPath);
|
|
72
|
+
const builderPath = resolve(TOP_LEVEL_PATH, "builder");
|
|
77
73
|
yield send(ctx, ctx.file, { root: builderPath });
|
|
78
74
|
if (!ctx.file.includes("assets/")) {
|
|
79
75
|
yield events.serve.servedBuilder();
|
package/dist/api/index.js
CHANGED
|
@@ -69,7 +69,10 @@ router.use((ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
69
69
|
error,
|
|
70
70
|
};
|
|
71
71
|
ctx.log.error(err);
|
|
72
|
-
|
|
72
|
+
// unauthorised errors don't provide a useful trace
|
|
73
|
+
if (!env.isTest()) {
|
|
74
|
+
console.trace(err);
|
|
75
|
+
}
|
|
73
76
|
}
|
|
74
77
|
}));
|
|
75
78
|
// authenticated routes
|
|
@@ -15,6 +15,8 @@ router
|
|
|
15
15
|
.get("/api/automations/:id", paramResource("id"), authorized(BUILDER), controller.find)
|
|
16
16
|
.put("/api/automations", bodyResource("_id"), authorized(BUILDER), automationValidator(true), controller.update)
|
|
17
17
|
.post("/api/automations", authorized(BUILDER), automationValidator(false), controller.create)
|
|
18
|
+
.post("/api/automations/logs/search", authorized(BUILDER), controller.logSearch)
|
|
19
|
+
.delete("/api/automations/logs", authorized(BUILDER), controller.clearLogError)
|
|
18
20
|
.delete("/api/automations/:id/:rev", paramResource("id"), authorized(BUILDER), controller.destroy)
|
|
19
21
|
.post("/api/automations/:id/trigger", appInfoMiddleware({ appType: AppType.PROD }), paramResource("id"), authorized(PermissionTypes.AUTOMATION, PermissionLevels.EXECUTE), controller.trigger)
|
|
20
22
|
.post("/api/automations/:id/test", appInfoMiddleware({ appType: AppType.DEV }), paramResource("id"), authorized(PermissionTypes.AUTOMATION, PermissionLevels.EXECUTE), controller.test);
|
package/dist/api/routes/dev.js
CHANGED
|
@@ -18,6 +18,5 @@ if (env.isDev() || env.isTest()) {
|
|
|
18
18
|
router
|
|
19
19
|
.get("/api/dev/version", authorized(BUILDER), controller.getBudibaseVersion)
|
|
20
20
|
.delete("/api/dev/:appId/lock", authorized(BUILDER), controller.clearLock)
|
|
21
|
-
.post("/api/dev/:appId/revert", authorized(BUILDER), controller.revert)
|
|
22
|
-
.get("/api/beta/access", controller.checkBetaAccess);
|
|
21
|
+
.post("/api/dev/:appId/revert", authorized(BUILDER), controller.revert);
|
|
23
22
|
module.exports = router;
|
|
@@ -144,6 +144,11 @@ read.push(new Endpoint_1.default("get", "/tables/:tableId/rows/:rowId", rows_1.d
|
|
|
144
144
|
* query:
|
|
145
145
|
* type: object
|
|
146
146
|
* properties:
|
|
147
|
+
* allOr:
|
|
148
|
+
* type: boolean
|
|
149
|
+
* description: Specifies that a row should be returned if it satisfies
|
|
150
|
+
* any of the specified options, rather than requiring it to fulfill all
|
|
151
|
+
* the search parameters. This defaults to false, meaning AND logic will be used.
|
|
147
152
|
* string:
|
|
148
153
|
* type: object
|
|
149
154
|
* example:
|
|
@@ -161,9 +166,9 @@ read.push(new Endpoint_1.default("get", "/tables/:tableId/rows/:rowId", rows_1.d
|
|
|
161
166
|
* range:
|
|
162
167
|
* type: object
|
|
163
168
|
* description: Searches within a range, the format of this must be
|
|
164
|
-
*
|
|
169
|
+
* in the format of an object with a "low" and "high" property.
|
|
165
170
|
* example:
|
|
166
|
-
* columnName1:
|
|
171
|
+
* columnName1: { low: 10, high: 20 }
|
|
167
172
|
* equal:
|
|
168
173
|
* type: object
|
|
169
174
|
* description: Searches for rows that have a column value that is
|
package/dist/app.js
CHANGED
|
@@ -54,6 +54,7 @@ const { Thread } = require("./threads");
|
|
|
54
54
|
const redis_1 = __importDefault(require("./utilities/redis"));
|
|
55
55
|
const migrations = __importStar(require("./migrations"));
|
|
56
56
|
const backend_core_1 = require("@budibase/backend-core");
|
|
57
|
+
const workerRequests_1 = require("./utilities/workerRequests");
|
|
57
58
|
const app = new Koa();
|
|
58
59
|
// set up top level koa middleware
|
|
59
60
|
app.use(koaBody({
|
|
@@ -112,6 +113,7 @@ server.on("close", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
112
113
|
}
|
|
113
114
|
}));
|
|
114
115
|
module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
+
var _a;
|
|
115
117
|
console.log(`Budibase running on ${JSON.stringify(server.address())}`);
|
|
116
118
|
env._set("PORT", server.address().port);
|
|
117
119
|
eventEmitter.emitPort(env.PORT);
|
|
@@ -128,6 +130,24 @@ module.exports = server.listen(env.PORT || 0, () => __awaiter(void 0, void 0, vo
|
|
|
128
130
|
shutdown();
|
|
129
131
|
}
|
|
130
132
|
}
|
|
133
|
+
// check and create admin user if required
|
|
134
|
+
if (env.SELF_HOSTED &&
|
|
135
|
+
!env.MULTI_TENANCY &&
|
|
136
|
+
env.BB_ADMIN_USER_EMAIL &&
|
|
137
|
+
env.BB_ADMIN_USER_PASSWORD) {
|
|
138
|
+
const checklist = yield (0, workerRequests_1.getChecklist)();
|
|
139
|
+
if (!((_a = checklist === null || checklist === void 0 ? void 0 : checklist.adminUser) === null || _a === void 0 ? void 0 : _a.checked)) {
|
|
140
|
+
try {
|
|
141
|
+
const tenantId = backend_core_1.tenancy.getTenantId();
|
|
142
|
+
yield (0, workerRequests_1.createAdminUser)(env.BB_ADMIN_USER_EMAIL, env.BB_ADMIN_USER_PASSWORD, tenantId);
|
|
143
|
+
console.log("Admin account automatically created for", env.BB_ADMIN_USER_EMAIL);
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
logAlert("Error creating initial admin user. Exiting.", e);
|
|
147
|
+
shutdown();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
131
151
|
// check for version updates
|
|
132
152
|
yield backend_core_1.installation.checkInstallVersion();
|
|
133
153
|
// done last - this will never complete
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
const { getTable } = require("../api/controllers/table/utils");
|
|
12
|
-
const { findHBSBlocks } = require("@budibase/string-templates");
|
|
12
|
+
const { findHBSBlocks, decodeJSBinding, isJSBinding, encodeJSBinding, } = require("@budibase/string-templates");
|
|
13
13
|
/**
|
|
14
14
|
* When values are input to the system generally they will be of type string as this is required for template strings.
|
|
15
15
|
* This can generate some odd scenarios as the Schema of the automation requires a number but the builder might supply
|
|
@@ -81,11 +81,23 @@ exports.getError = err => {
|
|
|
81
81
|
return typeof err !== "string" ? err.toString() : err;
|
|
82
82
|
};
|
|
83
83
|
exports.substituteLoopStep = (hbsString, substitute) => {
|
|
84
|
-
let blocks =
|
|
84
|
+
let blocks = [];
|
|
85
|
+
let checkForJS = isJSBinding(hbsString);
|
|
86
|
+
if (checkForJS) {
|
|
87
|
+
hbsString = decodeJSBinding(hbsString);
|
|
88
|
+
blocks.push(hbsString);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
blocks = findHBSBlocks(hbsString);
|
|
92
|
+
}
|
|
85
93
|
for (let block of blocks) {
|
|
86
|
-
let oldBlock = block;
|
|
87
94
|
block = block.replace(/loop/, substitute);
|
|
88
|
-
|
|
95
|
+
if (checkForJS) {
|
|
96
|
+
hbsString = encodeJSBinding(block);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
hbsString = block;
|
|
100
|
+
}
|
|
89
101
|
}
|
|
90
102
|
return hbsString;
|
|
91
103
|
};
|