@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
|
@@ -17,7 +17,7 @@ const { ObjectStoreBuckets } = require("../../constants");
|
|
|
17
17
|
const { upload, retrieve, retrieveToTmp, streamUpload, deleteFolder, downloadTarball, } = require("./utilities");
|
|
18
18
|
const { updateClientLibrary } = require("./clientLibrary");
|
|
19
19
|
const env = require("../../environment");
|
|
20
|
-
const { USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX,
|
|
20
|
+
const { USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX, } = require("../../db/utils");
|
|
21
21
|
const MemoryStream = require("memorystream");
|
|
22
22
|
const { getAppId } = require("@budibase/backend-core/context");
|
|
23
23
|
const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..");
|
|
@@ -98,17 +98,6 @@ exports.apiFileReturn = contents => {
|
|
|
98
98
|
fs.writeFileSync(path, contents);
|
|
99
99
|
return fs.createReadStream(path);
|
|
100
100
|
};
|
|
101
|
-
exports.defineFilter = excludeRows => {
|
|
102
|
-
if (excludeRows) {
|
|
103
|
-
return doc => !(doc._id.includes(USER_METDATA_PREFIX) ||
|
|
104
|
-
doc._id.includes(LINK_USER_METADATA_PREFIX) ||
|
|
105
|
-
doc._id.includes(TABLE_ROW_PREFIX));
|
|
106
|
-
}
|
|
107
|
-
else if (!excludeRows) {
|
|
108
|
-
return doc => !(doc._id.includes(USER_METDATA_PREFIX) ||
|
|
109
|
-
doc._id.includes(LINK_USER_METADATA_PREFIX));
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
101
|
/**
|
|
113
102
|
* Local utility to back up the database state for an app, excluding global user
|
|
114
103
|
* data or user relationships.
|
|
@@ -116,8 +105,9 @@ exports.defineFilter = excludeRows => {
|
|
|
116
105
|
* @param {object} config Config to send to export DB
|
|
117
106
|
* @returns {*} either a string or a stream of the backup
|
|
118
107
|
*/
|
|
119
|
-
const backupAppData = (appId, config
|
|
120
|
-
return yield exports.exportDB(appId, Object.assign(Object.assign({}, config), { filter:
|
|
108
|
+
const backupAppData = (appId, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
|
+
return yield exports.exportDB(appId, Object.assign(Object.assign({}, config), { filter: doc => !(doc._id.includes(USER_METDATA_PREFIX) ||
|
|
110
|
+
doc._id.includes(LINK_USER_METADATA_PREFIX)) }));
|
|
121
111
|
});
|
|
122
112
|
/**
|
|
123
113
|
* Takes a copy of the database state for an app to the object store.
|
|
@@ -133,8 +123,8 @@ exports.performBackup = (appId, backupName) => __awaiter(void 0, void 0, void 0,
|
|
|
133
123
|
* @param {string} appId The ID of the app which is to be backed up.
|
|
134
124
|
* @returns {*} a readable stream of the backup which is written in real time
|
|
135
125
|
*/
|
|
136
|
-
exports.streamBackup = (appId
|
|
137
|
-
return yield backupAppData(appId, { stream: true }
|
|
126
|
+
exports.streamBackup = (appId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
|
+
return yield backupAppData(appId, { stream: true });
|
|
138
128
|
});
|
|
139
129
|
/**
|
|
140
130
|
* Exports a DB to either file or a variable (memory).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.219
|
|
4
|
+
"version": "1.0.219",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -77,11 +77,10 @@
|
|
|
77
77
|
"license": "GPL-3.0",
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
80
|
-
"@budibase/backend-core": "^1.0.219
|
|
81
|
-
"@budibase/client": "^1.0.219
|
|
82
|
-
"@budibase/pro": "1.0.
|
|
83
|
-
"@budibase/string-templates": "^1.0.219
|
|
84
|
-
"@budibase/types": "^1.0.219-alpha.7",
|
|
80
|
+
"@budibase/backend-core": "^1.0.219",
|
|
81
|
+
"@budibase/client": "^1.0.219",
|
|
82
|
+
"@budibase/pro": "1.0.218",
|
|
83
|
+
"@budibase/string-templates": "^1.0.219",
|
|
85
84
|
"@bull-board/api": "3.7.0",
|
|
86
85
|
"@bull-board/koa": "3.9.4",
|
|
87
86
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -136,7 +135,6 @@
|
|
|
136
135
|
"pouchdb-replication-stream": "1.2.9",
|
|
137
136
|
"redis": "4",
|
|
138
137
|
"server-destroy": "1.0.1",
|
|
139
|
-
"snowflake-promise": "^4.5.0",
|
|
140
138
|
"svelte": "3.44.1",
|
|
141
139
|
"swagger-parser": "10.0.3",
|
|
142
140
|
"to-json-schema": "0.2.5",
|
|
@@ -152,6 +150,7 @@
|
|
|
152
150
|
"@babel/core": "7.17.4",
|
|
153
151
|
"@babel/preset-env": "7.16.11",
|
|
154
152
|
"@budibase/standard-components": "^0.9.139",
|
|
153
|
+
"@budibase/types": "^1.0.219",
|
|
155
154
|
"@jest/test-sequencer": "24.9.0",
|
|
156
155
|
"@types/apidoc": "0.50.0",
|
|
157
156
|
"@types/bson": "4.2.0",
|
|
@@ -195,5 +194,5 @@
|
|
|
195
194
|
"optionalDependencies": {
|
|
196
195
|
"oracledb": "5.3.0"
|
|
197
196
|
},
|
|
198
|
-
"gitHead": "
|
|
197
|
+
"gitHead": "231b038a3c99f730dd27a595f870663dd84b7837"
|
|
199
198
|
}
|
|
@@ -45,12 +45,10 @@ const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy")
|
|
|
45
45
|
import { syncGlobalUsers } from "./user"
|
|
46
46
|
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
47
47
|
import { cleanupAutomations } from "../../automations/utils"
|
|
48
|
-
import { checkAppMetadata } from "../../automations/logging"
|
|
49
48
|
const {
|
|
50
49
|
getAppDB,
|
|
51
50
|
getProdAppDB,
|
|
52
51
|
updateAppId,
|
|
53
|
-
doInAppContext,
|
|
54
52
|
} = require("@budibase/backend-core/context")
|
|
55
53
|
import { getUniqueRows } from "../../utilities/usageQuota/rows"
|
|
56
54
|
import { quotas } from "@budibase/pro"
|
|
@@ -194,7 +192,7 @@ export const fetch = async (ctx: any) => {
|
|
|
194
192
|
}
|
|
195
193
|
}
|
|
196
194
|
|
|
197
|
-
ctx.body =
|
|
195
|
+
ctx.body = apps
|
|
198
196
|
}
|
|
199
197
|
|
|
200
198
|
export const fetchAppDefinition = async (ctx: any) => {
|
|
@@ -550,24 +548,22 @@ export const sync = async (ctx: any, next: any) => {
|
|
|
550
548
|
}
|
|
551
549
|
|
|
552
550
|
const updateAppPackage = async (appPackage: any, appId: any) => {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
const application = await db.get(DocumentTypes.APP_METADATA)
|
|
551
|
+
const db = getAppDB()
|
|
552
|
+
const application = await db.get(DocumentTypes.APP_METADATA)
|
|
556
553
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
554
|
+
const newAppPackage = { ...application, ...appPackage }
|
|
555
|
+
if (appPackage._rev !== application._rev) {
|
|
556
|
+
newAppPackage._rev = application._rev
|
|
557
|
+
}
|
|
561
558
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
559
|
+
// the locked by property is attached by server but generated from
|
|
560
|
+
// Redis, shouldn't ever store it
|
|
561
|
+
delete newAppPackage.lockedBy
|
|
565
562
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
})
|
|
563
|
+
await db.put(newAppPackage)
|
|
564
|
+
// remove any cached metadata, so that it will be updated
|
|
565
|
+
await appCache.invalidateAppMetadata(appId)
|
|
566
|
+
return newAppPackage
|
|
571
567
|
}
|
|
572
568
|
|
|
573
569
|
const createEmptyAppPackage = async (ctx: any, app: any) => {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
const actions = require("../../automations/actions")
|
|
2
2
|
const triggers = require("../../automations/triggers")
|
|
3
|
-
const {
|
|
4
|
-
getAutomationParams,
|
|
5
|
-
generateAutomationID,
|
|
6
|
-
DocumentTypes,
|
|
7
|
-
} = require("../../db/utils")
|
|
3
|
+
const { getAutomationParams, generateAutomationID } = require("../../db/utils")
|
|
8
4
|
const {
|
|
9
5
|
checkForWebhooks,
|
|
10
6
|
updateTestHistory,
|
|
@@ -13,14 +9,8 @@ const {
|
|
|
13
9
|
const { deleteEntityMetadata } = require("../../utilities")
|
|
14
10
|
const { MetadataTypes } = require("../../constants")
|
|
15
11
|
const { setTestFlag, clearTestFlag } = require("../../utilities/redis")
|
|
16
|
-
const {
|
|
17
|
-
getAppDB,
|
|
18
|
-
getProdAppDB,
|
|
19
|
-
doInAppContext,
|
|
20
|
-
} = require("@budibase/backend-core/context")
|
|
12
|
+
const { getAppDB } = require("@budibase/backend-core/context")
|
|
21
13
|
const { events } = require("@budibase/backend-core")
|
|
22
|
-
const { app } = require("@budibase/backend-core/cache")
|
|
23
|
-
const { automations } = require("@budibase/pro")
|
|
24
14
|
|
|
25
15
|
const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS)
|
|
26
16
|
const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS)
|
|
@@ -193,29 +183,6 @@ exports.destroy = async function (ctx) {
|
|
|
193
183
|
await events.automation.deleted(oldAutomation)
|
|
194
184
|
}
|
|
195
185
|
|
|
196
|
-
exports.logSearch = async function (ctx) {
|
|
197
|
-
ctx.body = await automations.logs.logSearch(ctx.request.body)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
exports.clearLogError = async function (ctx) {
|
|
201
|
-
const { automationId, appId } = ctx.request.body
|
|
202
|
-
await doInAppContext(appId, async () => {
|
|
203
|
-
const db = getProdAppDB()
|
|
204
|
-
const metadata = await db.get(DocumentTypes.APP_METADATA)
|
|
205
|
-
if (!automationId) {
|
|
206
|
-
delete metadata.automationErrors
|
|
207
|
-
} else if (
|
|
208
|
-
metadata.automationErrors &&
|
|
209
|
-
metadata.automationErrors[automationId]
|
|
210
|
-
) {
|
|
211
|
-
delete metadata.automationErrors[automationId]
|
|
212
|
-
}
|
|
213
|
-
await db.put(metadata)
|
|
214
|
-
await app.invalidateAppMetadata(metadata.appId, metadata)
|
|
215
|
-
ctx.body = { message: `Error logs cleared.` }
|
|
216
|
-
})
|
|
217
|
-
}
|
|
218
|
-
|
|
219
186
|
exports.getActionList = async function (ctx) {
|
|
220
187
|
ctx.body = ACTION_DEFS
|
|
221
188
|
}
|
|
@@ -3,12 +3,11 @@ const { events, context } = require("@budibase/backend-core")
|
|
|
3
3
|
const { DocumentTypes } = require("../../db/utils")
|
|
4
4
|
|
|
5
5
|
exports.exportAppDump = async function (ctx) {
|
|
6
|
-
|
|
6
|
+
const { appId } = ctx.query
|
|
7
7
|
const appName = decodeURI(ctx.query.appname)
|
|
8
|
-
excludeRows = excludeRows === "true"
|
|
9
8
|
const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt`
|
|
10
9
|
ctx.attachment(backupIdentifier)
|
|
11
|
-
ctx.body = await streamBackup(appId
|
|
10
|
+
ctx.body = await streamBackup(appId)
|
|
12
11
|
|
|
13
12
|
await context.doInAppContext(appId, async () => {
|
|
14
13
|
const appDb = context.getAppDB()
|
|
@@ -8,8 +8,6 @@ import { QUERY_THREAD_TIMEOUT } from "../../../environment"
|
|
|
8
8
|
import { getAppDB } from "@budibase/backend-core/context"
|
|
9
9
|
import { quotas } from "@budibase/pro"
|
|
10
10
|
import { events } from "@budibase/backend-core"
|
|
11
|
-
import { getCookie } from "@budibase/backend-core/utils"
|
|
12
|
-
import { Cookies, Configs } from "@budibase/backend-core/constants"
|
|
13
11
|
|
|
14
12
|
const Runner = new Thread(ThreadType.QUERY, {
|
|
15
13
|
timeoutMs: QUERY_THREAD_TIMEOUT || 10000,
|
|
@@ -112,21 +110,6 @@ export async function find(ctx: any) {
|
|
|
112
110
|
ctx.body = query
|
|
113
111
|
}
|
|
114
112
|
|
|
115
|
-
//Required to discern between OIDC OAuth config entries
|
|
116
|
-
function getOAuthConfigCookieId(ctx: any) {
|
|
117
|
-
if (ctx.user.providerType === Configs.OIDC) {
|
|
118
|
-
return getCookie(ctx, Cookies.OIDC_CONFIG)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function getAuthConfig(ctx: any) {
|
|
123
|
-
const authCookie = getCookie(ctx, Cookies.Auth)
|
|
124
|
-
let authConfigCtx: any = {}
|
|
125
|
-
authConfigCtx["configId"] = getOAuthConfigCookieId(ctx)
|
|
126
|
-
authConfigCtx["sessionId"] = authCookie ? authCookie.sessionId : null
|
|
127
|
-
return authConfigCtx
|
|
128
|
-
}
|
|
129
|
-
|
|
130
113
|
export async function preview(ctx: any) {
|
|
131
114
|
const db = getAppDB()
|
|
132
115
|
|
|
@@ -136,8 +119,6 @@ export async function preview(ctx: any) {
|
|
|
136
119
|
// this stops dynamic variables from calling the same query
|
|
137
120
|
const { fields, parameters, queryVerb, transformer, queryId } = query
|
|
138
121
|
|
|
139
|
-
const authConfigCtx: any = getAuthConfig(ctx)
|
|
140
|
-
|
|
141
122
|
try {
|
|
142
123
|
const runFn = () =>
|
|
143
124
|
Runner.run({
|
|
@@ -148,11 +129,8 @@ export async function preview(ctx: any) {
|
|
|
148
129
|
parameters,
|
|
149
130
|
transformer,
|
|
150
131
|
queryId,
|
|
151
|
-
ctx: {
|
|
152
|
-
user: ctx.user,
|
|
153
|
-
auth: { ...authConfigCtx },
|
|
154
|
-
},
|
|
155
132
|
})
|
|
133
|
+
|
|
156
134
|
const { rows, keys, info, extra } = await quotas.addQuery(runFn)
|
|
157
135
|
await events.query.previewed(datasource, query)
|
|
158
136
|
ctx.body = {
|
|
@@ -172,8 +150,6 @@ async function execute(ctx: any, opts = { rowsOnly: false }) {
|
|
|
172
150
|
const query = await db.get(ctx.params.queryId)
|
|
173
151
|
const datasource = await db.get(query.datasourceId)
|
|
174
152
|
|
|
175
|
-
const authConfigCtx: any = getAuthConfig(ctx)
|
|
176
|
-
|
|
177
153
|
const enrichedParameters = ctx.request.body.parameters || {}
|
|
178
154
|
// make sure parameters are fully enriched with defaults
|
|
179
155
|
if (query && query.parameters) {
|
|
@@ -196,10 +172,6 @@ async function execute(ctx: any, opts = { rowsOnly: false }) {
|
|
|
196
172
|
parameters: enrichedParameters,
|
|
197
173
|
transformer: query.transformer,
|
|
198
174
|
queryId: ctx.params.queryId,
|
|
199
|
-
ctx: {
|
|
200
|
-
user: ctx.user,
|
|
201
|
-
auth: { ...authConfigCtx },
|
|
202
|
-
},
|
|
203
175
|
})
|
|
204
176
|
|
|
205
177
|
const { rows, pagination, extra } = await quotas.addQuery(runFn)
|
|
@@ -155,44 +155,34 @@ exports.validate = async () => {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
exports.exportRows = async ctx => {
|
|
158
|
-
const { datasourceId } = breakExternalTableId(ctx.params.tableId)
|
|
158
|
+
const { datasourceId, tableName } = breakExternalTableId(ctx.params.tableId)
|
|
159
159
|
const db = getAppDB()
|
|
160
|
-
|
|
161
|
-
const { columns } = ctx.request.body
|
|
160
|
+
let format = ctx.query.format
|
|
162
161
|
const datasource = await db.get(datasourceId)
|
|
163
162
|
if (!datasource || !datasource.entities) {
|
|
164
163
|
ctx.throw(400, "Datasource has not been configured for plus API.")
|
|
165
164
|
}
|
|
165
|
+
const tables = datasource.entities
|
|
166
|
+
const table = tables[tableName]
|
|
166
167
|
ctx.request.body = {
|
|
167
168
|
query: {
|
|
168
169
|
oneOf: {
|
|
169
|
-
|
|
170
|
+
[table.primaryDisplay]: ctx.request.body.rows.map(
|
|
171
|
+
id => breakRowIdField(id)[0]
|
|
172
|
+
),
|
|
170
173
|
},
|
|
171
174
|
},
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
let result = await exports.search(ctx)
|
|
175
|
-
let rows = []
|
|
176
|
-
|
|
177
|
-
// Filter data to only specified columns if required
|
|
178
|
-
if (columns && columns.length) {
|
|
179
|
-
for (let i = 0; i < result.rows.length; i++) {
|
|
180
|
-
rows[i] = {}
|
|
181
|
-
for (let column of columns) {
|
|
182
|
-
rows[i][column] = result.rows[i][column]
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
} else {
|
|
186
|
-
rows = result.rows
|
|
187
|
-
}
|
|
188
178
|
|
|
189
|
-
let headers = Object.keys(rows[0])
|
|
179
|
+
let headers = Object.keys(result.rows[0])
|
|
190
180
|
const exporter = exporters[format]
|
|
191
181
|
const filename = `export.${format}`
|
|
192
182
|
|
|
193
183
|
// send down the file
|
|
194
184
|
ctx.attachment(filename)
|
|
195
|
-
return apiFileReturn(exporter(headers, rows))
|
|
185
|
+
return apiFileReturn(exporter(headers, result.rows))
|
|
196
186
|
}
|
|
197
187
|
|
|
198
188
|
exports.fetchEnrichedRow = async ctx => {
|
|
@@ -17,7 +17,6 @@ class QueryBuilder {
|
|
|
17
17
|
notEqual: {},
|
|
18
18
|
empty: {},
|
|
19
19
|
notEmpty: {},
|
|
20
|
-
oneOf: {},
|
|
21
20
|
...base,
|
|
22
21
|
}
|
|
23
22
|
this.limit = 50
|
|
@@ -113,11 +112,6 @@ class QueryBuilder {
|
|
|
113
112
|
return this
|
|
114
113
|
}
|
|
115
114
|
|
|
116
|
-
addOneOf(key, value) {
|
|
117
|
-
this.query.oneOf[key] = value
|
|
118
|
-
return this
|
|
119
|
-
}
|
|
120
|
-
|
|
121
115
|
/**
|
|
122
116
|
* Preprocesses a value before going into a lucene search.
|
|
123
117
|
* Transforms strings to lowercase and wraps strings and bools in quotes.
|
|
@@ -226,28 +220,6 @@ class QueryBuilder {
|
|
|
226
220
|
if (this.query.notEmpty) {
|
|
227
221
|
build(this.query.notEmpty, key => `${key}:["" TO *]`)
|
|
228
222
|
}
|
|
229
|
-
if (this.query.oneOf) {
|
|
230
|
-
build(this.query.oneOf, (key, value) => {
|
|
231
|
-
if (!Array.isArray(value)) {
|
|
232
|
-
if (typeof value === "string") {
|
|
233
|
-
value = value.split(",")
|
|
234
|
-
} else {
|
|
235
|
-
return ""
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
let orStatement = `${builder.preprocess(
|
|
239
|
-
value[0],
|
|
240
|
-
allPreProcessingOpts
|
|
241
|
-
)}`
|
|
242
|
-
for (let i = 1; i < value.length; i++) {
|
|
243
|
-
orStatement += ` OR ${builder.preprocess(
|
|
244
|
-
value[i],
|
|
245
|
-
allPreProcessingOpts
|
|
246
|
-
)}`
|
|
247
|
-
}
|
|
248
|
-
return `${key}:(${orStatement})`
|
|
249
|
-
})
|
|
250
|
-
}
|
|
251
223
|
return query
|
|
252
224
|
}
|
|
253
225
|
|
|
@@ -64,9 +64,6 @@ exports.validate = async ({ tableId, row, table }) => {
|
|
|
64
64
|
// Validate.js doesn't seem to handle array
|
|
65
65
|
if (type === FieldTypes.ARRAY && row[fieldName]) {
|
|
66
66
|
if (row[fieldName].length) {
|
|
67
|
-
if (!Array.isArray(row[fieldName])) {
|
|
68
|
-
row[fieldName] = row[fieldName].split(",")
|
|
69
|
-
}
|
|
70
67
|
row[fieldName].map(val => {
|
|
71
68
|
if (
|
|
72
69
|
!constraints.inclusion.includes(val) &&
|
package/src/api/index.js
CHANGED
|
@@ -51,16 +51,6 @@ router
|
|
|
51
51
|
automationValidator(false),
|
|
52
52
|
controller.create
|
|
53
53
|
)
|
|
54
|
-
.post(
|
|
55
|
-
"/api/automations/logs/search",
|
|
56
|
-
authorized(BUILDER),
|
|
57
|
-
controller.logSearch
|
|
58
|
-
)
|
|
59
|
-
.delete(
|
|
60
|
-
"/api/automations/logs",
|
|
61
|
-
authorized(BUILDER),
|
|
62
|
-
controller.clearLogError
|
|
63
|
-
)
|
|
64
54
|
.delete(
|
|
65
55
|
"/api/automations/:id/:rev",
|
|
66
56
|
paramResource("id"),
|
|
@@ -346,170 +346,4 @@ describe("/queries", () => {
|
|
|
346
346
|
expect(contents).toBe(null)
|
|
347
347
|
})
|
|
348
348
|
})
|
|
349
|
-
|
|
350
|
-
describe("Current User Request Mapping", () => {
|
|
351
|
-
|
|
352
|
-
async function previewGet(datasource, fields, params) {
|
|
353
|
-
return config.previewQuery(request, config, datasource, fields, params)
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
async function previewPost(datasource, fields, params) {
|
|
357
|
-
return config.previewQuery(request, config, datasource, fields, params, "create")
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
it("should parse global and query level header mappings", async () => {
|
|
361
|
-
const userDetails = config.getUserDetails()
|
|
362
|
-
|
|
363
|
-
const datasource = await config.restDatasource({
|
|
364
|
-
defaultHeaders: {
|
|
365
|
-
"test": "headerVal",
|
|
366
|
-
"emailHdr": "{{[user].[email]}}"
|
|
367
|
-
}
|
|
368
|
-
})
|
|
369
|
-
const res = await previewGet(datasource, {
|
|
370
|
-
path: "www.google.com",
|
|
371
|
-
queryString: "email={{[user].[email]}}",
|
|
372
|
-
headers: {
|
|
373
|
-
queryHdr : "{{[user].[firstName]}}",
|
|
374
|
-
secondHdr : "1234"
|
|
375
|
-
}
|
|
376
|
-
})
|
|
377
|
-
|
|
378
|
-
const parsedRequest = JSON.parse(res.body.extra.raw)
|
|
379
|
-
expect(parsedRequest.opts.headers).toEqual({
|
|
380
|
-
"test": "headerVal",
|
|
381
|
-
"emailHdr": userDetails.email,
|
|
382
|
-
"queryHdr": userDetails.firstName,
|
|
383
|
-
"secondHdr" : "1234"
|
|
384
|
-
})
|
|
385
|
-
expect(res.body.rows[0].url).toEqual("http://www.google.com?email=" + userDetails.email)
|
|
386
|
-
})
|
|
387
|
-
|
|
388
|
-
it("should bind the current user to query parameters", async () => {
|
|
389
|
-
const userDetails = config.getUserDetails()
|
|
390
|
-
|
|
391
|
-
const datasource = await config.restDatasource()
|
|
392
|
-
|
|
393
|
-
const res = await previewGet(datasource, {
|
|
394
|
-
path: "www.google.com",
|
|
395
|
-
queryString: "test={{myEmail}}&testName={{myName}}&testParam={{testParam}}",
|
|
396
|
-
}, {
|
|
397
|
-
"myEmail" : "{{[user].[email]}}",
|
|
398
|
-
"myName" : "{{[user].[firstName]}}",
|
|
399
|
-
"testParam" : "1234"
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
expect(res.body.rows[0].url).toEqual("http://www.google.com?test=" + userDetails.email +
|
|
403
|
-
"&testName=" + userDetails.firstName + "&testParam=1234")
|
|
404
|
-
})
|
|
405
|
-
|
|
406
|
-
it("should bind the current user the request body - plain text", async () => {
|
|
407
|
-
const userDetails = config.getUserDetails()
|
|
408
|
-
const datasource = await config.restDatasource()
|
|
409
|
-
|
|
410
|
-
const res = await previewPost(datasource, {
|
|
411
|
-
path: "www.google.com",
|
|
412
|
-
queryString: "testParam={{testParam}}",
|
|
413
|
-
requestBody: "This is plain text and this is my email: {{[user].[email]}}. This is a test param: {{testParam}}",
|
|
414
|
-
bodyType: "text"
|
|
415
|
-
}, {
|
|
416
|
-
"testParam" : "1234"
|
|
417
|
-
})
|
|
418
|
-
|
|
419
|
-
const parsedRequest = JSON.parse(res.body.extra.raw)
|
|
420
|
-
expect(parsedRequest.opts.body).toEqual(`This is plain text and this is my email: ${userDetails.email}. This is a test param: 1234`)
|
|
421
|
-
expect(res.body.rows[0].url).toEqual("http://www.google.com?testParam=1234")
|
|
422
|
-
})
|
|
423
|
-
|
|
424
|
-
it("should bind the current user the request body - json", async () => {
|
|
425
|
-
const userDetails = config.getUserDetails()
|
|
426
|
-
const datasource = await config.restDatasource()
|
|
427
|
-
|
|
428
|
-
const res = await previewPost(datasource, {
|
|
429
|
-
path: "www.google.com",
|
|
430
|
-
queryString: "testParam={{testParam}}",
|
|
431
|
-
requestBody: "{\"email\":\"{{[user].[email]}}\",\"queryCode\":{{testParam}},\"userRef\":\"{{userRef}}\"}",
|
|
432
|
-
bodyType: "json"
|
|
433
|
-
}, {
|
|
434
|
-
"testParam" : "1234",
|
|
435
|
-
"userRef" : "{{[user].[firstName]}}"
|
|
436
|
-
})
|
|
437
|
-
|
|
438
|
-
const parsedRequest = JSON.parse(res.body.extra.raw)
|
|
439
|
-
const test = `{"email":"${userDetails.email}","queryCode":1234,"userRef":"${userDetails.firstName}"}`
|
|
440
|
-
expect(parsedRequest.opts.body).toEqual(test)
|
|
441
|
-
expect(res.body.rows[0].url).toEqual("http://www.google.com?testParam=1234")
|
|
442
|
-
})
|
|
443
|
-
|
|
444
|
-
it("should bind the current user the request body - xml", async () => {
|
|
445
|
-
const userDetails = config.getUserDetails()
|
|
446
|
-
const datasource = await config.restDatasource()
|
|
447
|
-
|
|
448
|
-
const res = await previewPost(datasource, {
|
|
449
|
-
path: "www.google.com",
|
|
450
|
-
queryString: "testParam={{testParam}}",
|
|
451
|
-
requestBody: "<note> <email>{{[user].[email]}}</email> <code>{{testParam}}</code> " +
|
|
452
|
-
"<ref>{{userId}}</ref> <somestring>testing</somestring> </note>",
|
|
453
|
-
bodyType: "xml"
|
|
454
|
-
}, {
|
|
455
|
-
"testParam" : "1234",
|
|
456
|
-
"userId" : "{{[user].[firstName]}}"
|
|
457
|
-
})
|
|
458
|
-
|
|
459
|
-
const parsedRequest = JSON.parse(res.body.extra.raw)
|
|
460
|
-
const test = `<note> <email>${userDetails.email}</email> <code>1234</code> <ref>${userDetails.firstName}</ref> <somestring>testing</somestring> </note>`
|
|
461
|
-
|
|
462
|
-
expect(parsedRequest.opts.body).toEqual(test)
|
|
463
|
-
expect(res.body.rows[0].url).toEqual("http://www.google.com?testParam=1234")
|
|
464
|
-
})
|
|
465
|
-
|
|
466
|
-
it("should bind the current user the request body - form-data", async () => {
|
|
467
|
-
const userDetails = config.getUserDetails()
|
|
468
|
-
const datasource = await config.restDatasource()
|
|
469
|
-
|
|
470
|
-
const res = await previewPost(datasource, {
|
|
471
|
-
path: "www.google.com",
|
|
472
|
-
queryString: "testParam={{testParam}}",
|
|
473
|
-
requestBody: "{\"email\":\"{{[user].[email]}}\",\"queryCode\":{{testParam}},\"userRef\":\"{{userRef}}\"}",
|
|
474
|
-
bodyType: "form"
|
|
475
|
-
}, {
|
|
476
|
-
"testParam" : "1234",
|
|
477
|
-
"userRef" : "{{[user].[firstName]}}"
|
|
478
|
-
})
|
|
479
|
-
|
|
480
|
-
const parsedRequest = JSON.parse(res.body.extra.raw)
|
|
481
|
-
|
|
482
|
-
const emailData = parsedRequest.opts.body._streams[1]
|
|
483
|
-
expect(emailData).toEqual(userDetails.email)
|
|
484
|
-
|
|
485
|
-
const queryCodeData = parsedRequest.opts.body._streams[4]
|
|
486
|
-
expect(queryCodeData).toEqual("1234")
|
|
487
|
-
|
|
488
|
-
const userRef = parsedRequest.opts.body._streams[7]
|
|
489
|
-
expect(userRef).toEqual(userDetails.firstName)
|
|
490
|
-
|
|
491
|
-
expect(res.body.rows[0].url).toEqual("http://www.google.com?testParam=1234")
|
|
492
|
-
})
|
|
493
|
-
|
|
494
|
-
it("should bind the current user the request body - encoded", async () => {
|
|
495
|
-
const userDetails = config.getUserDetails()
|
|
496
|
-
const datasource = await config.restDatasource()
|
|
497
|
-
|
|
498
|
-
const res = await previewPost(datasource, {
|
|
499
|
-
path: "www.google.com",
|
|
500
|
-
queryString: "testParam={{testParam}}",
|
|
501
|
-
requestBody: "{\"email\":\"{{[user].[email]}}\",\"queryCode\":{{testParam}},\"userRef\":\"{{userRef}}\"}",
|
|
502
|
-
bodyType: "encoded"
|
|
503
|
-
}, {
|
|
504
|
-
"testParam" : "1234",
|
|
505
|
-
"userRef" : "{{[user].[firstName]}}"
|
|
506
|
-
})
|
|
507
|
-
const parsedRequest = JSON.parse(res.body.extra.raw)
|
|
508
|
-
|
|
509
|
-
expect(parsedRequest.opts.body.email).toEqual(userDetails.email)
|
|
510
|
-
expect(parsedRequest.opts.body.queryCode).toEqual("1234")
|
|
511
|
-
expect(parsedRequest.opts.body.userRef).toEqual(userDetails.firstName)
|
|
512
|
-
})
|
|
513
|
-
|
|
514
|
-
});
|
|
515
349
|
})
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
const { getTable } = require("../api/controllers/table/utils")
|
|
2
|
-
const {
|
|
3
|
-
findHBSBlocks,
|
|
4
|
-
decodeJSBinding,
|
|
5
|
-
isJSBinding,
|
|
6
|
-
encodeJSBinding,
|
|
7
|
-
} = require("@budibase/string-templates")
|
|
2
|
+
const { findHBSBlocks } = require("@budibase/string-templates")
|
|
8
3
|
|
|
9
4
|
/**
|
|
10
5
|
* When values are input to the system generally they will be of type string as this is required for template strings.
|
|
@@ -82,21 +77,11 @@ exports.getError = err => {
|
|
|
82
77
|
}
|
|
83
78
|
|
|
84
79
|
exports.substituteLoopStep = (hbsString, substitute) => {
|
|
85
|
-
let blocks =
|
|
86
|
-
let checkForJS = isJSBinding(hbsString)
|
|
87
|
-
if (checkForJS) {
|
|
88
|
-
hbsString = decodeJSBinding(hbsString)
|
|
89
|
-
blocks.push(hbsString)
|
|
90
|
-
} else {
|
|
91
|
-
blocks = findHBSBlocks(hbsString)
|
|
92
|
-
}
|
|
80
|
+
let blocks = findHBSBlocks(hbsString)
|
|
93
81
|
for (let block of blocks) {
|
|
82
|
+
let oldBlock = block
|
|
94
83
|
block = block.replace(/loop/, substitute)
|
|
95
|
-
|
|
96
|
-
hbsString = encodeJSBinding(block)
|
|
97
|
-
} else {
|
|
98
|
-
hbsString = block
|
|
99
|
-
}
|
|
84
|
+
hbsString = hbsString.replace(new RegExp(oldBlock, "g"), block)
|
|
100
85
|
}
|
|
101
86
|
|
|
102
87
|
return hbsString
|