@budibase/server 1.0.136 → 1.0.139
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builder/assets/{index.05ef6162.js → index.6db89ad9.js} +121 -121
- package/builder/index.html +1 -1
- package/coverage/clover.xml +76 -62
- package/coverage/coverage-final.json +3 -3
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/api/index.js.html +1 -1
- 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 +1 -1
- 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 +46 -10
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +19 -19
- 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 +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +1 -1
- 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 +28 -28
- 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 +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/threads/automation.js.html +67 -34
- package/coverage/lcov-report/threads/index.html +26 -26
- package/coverage/lcov-report/threads/query.js.html +16 -19
- package/coverage/lcov-report/threads/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- 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 +1 -1
- 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 +132 -114
- package/dist/automations/automationUtils.js +12 -0
- package/dist/integrations/microsoftSqlServer.js +1 -6
- package/dist/integrations/mysql.js +16 -14
- package/dist/integrations/oracle.js +2 -6
- package/dist/integrations/postgres.js +1 -6
- package/dist/integrations/utils.js +15 -5
- package/dist/package.json +5 -5
- package/dist/threads/automation.js +25 -16
- package/dist/threads/query.js +7 -7
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +11 -7
- package/package.json +6 -6
- package/src/automations/automationUtils.js +12 -0
- package/src/integrations/microsoftSqlServer.ts +1 -3
- package/src/integrations/mysql.ts +18 -12
- package/src/integrations/oracle.ts +3 -3
- package/src/integrations/postgres.ts +1 -2
- package/src/integrations/utils.ts +16 -5
- package/src/threads/automation.js +28 -17
- package/src/threads/query.js +7 -8
- package/src/utilities/fileSystem/index.js +16 -8
|
@@ -12,7 +12,7 @@ const { budibaseTempDir } = require("../budibaseDir");
|
|
|
12
12
|
const fs = require("fs");
|
|
13
13
|
const { join } = require("path");
|
|
14
14
|
const uuid = require("uuid/v4");
|
|
15
|
-
const { doWithDB } = require("@budibase/backend-core/db");
|
|
15
|
+
const { doWithDB, dangerousGetDB, closeDB, } = require("@budibase/backend-core/db");
|
|
16
16
|
const { ObjectStoreBuckets } = require("../../constants");
|
|
17
17
|
const { upload, retrieve, retrieveToTmp, streamUpload, deleteFolder, downloadTarball, } = require("./utilities");
|
|
18
18
|
const { updateClientLibrary } = require("./clientLibrary");
|
|
@@ -135,13 +135,17 @@ exports.streamBackup = (appId) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
135
135
|
* @return {*} either a readable stream or a string
|
|
136
136
|
*/
|
|
137
137
|
exports.exportDB = (dbName, { stream, filter, exportName } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
+
// streaming a DB dump is a bit more complicated, can't close DB
|
|
139
|
+
if (stream) {
|
|
140
|
+
const db = dangerousGetDB(dbName);
|
|
141
|
+
const memStream = new MemoryStream();
|
|
142
|
+
memStream.on("end", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
|
+
yield closeDB(db);
|
|
144
|
+
}));
|
|
145
|
+
db.dump(memStream, { filter });
|
|
146
|
+
return memStream;
|
|
147
|
+
}
|
|
138
148
|
return doWithDB(dbName, (db) => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
-
// Stream the dump if required
|
|
140
|
-
if (stream) {
|
|
141
|
-
const memStream = new MemoryStream();
|
|
142
|
-
db.dump(memStream, { filter });
|
|
143
|
-
return memStream;
|
|
144
|
-
}
|
|
145
149
|
// Write the dump to file if required
|
|
146
150
|
if (exportName) {
|
|
147
151
|
const path = join(budibaseTempDir(), exportName);
|
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.
|
|
4
|
+
"version": "1.0.139",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
"license": "GPL-3.0",
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
71
|
-
"@budibase/backend-core": "^1.0.
|
|
72
|
-
"@budibase/client": "^1.0.
|
|
73
|
-
"@budibase/pro": "1.0.
|
|
74
|
-
"@budibase/string-templates": "^1.0.
|
|
71
|
+
"@budibase/backend-core": "^1.0.139",
|
|
72
|
+
"@budibase/client": "^1.0.139",
|
|
73
|
+
"@budibase/pro": "1.0.138",
|
|
74
|
+
"@budibase/string-templates": "^1.0.139",
|
|
75
75
|
"@bull-board/api": "^3.7.0",
|
|
76
76
|
"@bull-board/koa": "^3.7.0",
|
|
77
77
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -180,5 +180,5 @@
|
|
|
180
180
|
"optionalDependencies": {
|
|
181
181
|
"oracledb": "^5.3.0"
|
|
182
182
|
},
|
|
183
|
-
"gitHead": "
|
|
183
|
+
"gitHead": "075cd99f94b0a9a696aeab48ae0ba1a386d2a322"
|
|
184
184
|
}
|
|
@@ -86,3 +86,15 @@ exports.substituteLoopStep = (hbsString, substitute) => {
|
|
|
86
86
|
|
|
87
87
|
return hbsString
|
|
88
88
|
}
|
|
89
|
+
|
|
90
|
+
exports.stringSplit = value => {
|
|
91
|
+
if (value == null) {
|
|
92
|
+
return []
|
|
93
|
+
}
|
|
94
|
+
if (value.split("\n").length > 1) {
|
|
95
|
+
value = value.split("\n")
|
|
96
|
+
} else {
|
|
97
|
+
value = value.split(",")
|
|
98
|
+
}
|
|
99
|
+
return value
|
|
100
|
+
}
|
|
@@ -242,12 +242,10 @@ module MSSQLModule {
|
|
|
242
242
|
if (typeof name !== "string") {
|
|
243
243
|
continue
|
|
244
244
|
}
|
|
245
|
-
const type: string = convertSqlType(def.DATA_TYPE)
|
|
246
|
-
|
|
247
245
|
schema[name] = {
|
|
248
246
|
autocolumn: !!autoColumns.find((col: string) => col === name),
|
|
249
247
|
name: name,
|
|
250
|
-
|
|
248
|
+
...convertSqlType(def.DATA_TYPE),
|
|
251
249
|
}
|
|
252
250
|
}
|
|
253
251
|
tables[tableName] = {
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "./utils"
|
|
16
16
|
import { DatasourcePlus } from "./base/datasourcePlus"
|
|
17
17
|
import dayjs from "dayjs"
|
|
18
|
+
import { FieldTypes } from "../constants"
|
|
18
19
|
const { NUMBER_REGEX } = require("../utilities")
|
|
19
20
|
|
|
20
21
|
module MySQLModule {
|
|
@@ -101,7 +102,7 @@ module MySQLModule {
|
|
|
101
102
|
}
|
|
102
103
|
// if not a number, see if it is a date - important to do in this order as any
|
|
103
104
|
// integer will be considered a valid date
|
|
104
|
-
else if (dayjs(binding).isValid()) {
|
|
105
|
+
else if (/^\d/.test(binding) && dayjs(binding).isValid()) {
|
|
105
106
|
bindings[i] = dayjs(binding).toDate()
|
|
106
107
|
}
|
|
107
108
|
}
|
|
@@ -151,20 +152,24 @@ module MySQLModule {
|
|
|
151
152
|
|
|
152
153
|
async internalQuery(
|
|
153
154
|
query: SqlQuery,
|
|
154
|
-
|
|
155
|
+
opts: { connect?: boolean; disableCoercion?: boolean } = {
|
|
156
|
+
connect: true,
|
|
157
|
+
disableCoercion: false,
|
|
158
|
+
}
|
|
155
159
|
): Promise<any[] | any> {
|
|
156
160
|
try {
|
|
157
|
-
if (connect) {
|
|
161
|
+
if (opts?.connect) {
|
|
158
162
|
await this.connect()
|
|
159
163
|
}
|
|
164
|
+
const baseBindings = query.bindings || []
|
|
165
|
+
const bindings = opts?.disableCoercion
|
|
166
|
+
? baseBindings
|
|
167
|
+
: bindingTypeCoerce(baseBindings)
|
|
160
168
|
// Node MySQL is callback based, so we must wrap our call in a promise
|
|
161
|
-
const response = await this.client.query(
|
|
162
|
-
query.sql,
|
|
163
|
-
bindingTypeCoerce(query.bindings || [])
|
|
164
|
-
)
|
|
169
|
+
const response = await this.client.query(query.sql, bindings)
|
|
165
170
|
return response[0]
|
|
166
171
|
} finally {
|
|
167
|
-
if (connect) {
|
|
172
|
+
if (opts?.connect) {
|
|
168
173
|
await this.disconnect()
|
|
169
174
|
}
|
|
170
175
|
}
|
|
@@ -179,7 +184,7 @@ module MySQLModule {
|
|
|
179
184
|
// get the tables first
|
|
180
185
|
const tablesResp = await this.internalQuery(
|
|
181
186
|
{ sql: "SHOW TABLES;" },
|
|
182
|
-
false
|
|
187
|
+
{ connect: false }
|
|
183
188
|
)
|
|
184
189
|
const tableNames = tablesResp.map(
|
|
185
190
|
(obj: any) =>
|
|
@@ -191,7 +196,7 @@ module MySQLModule {
|
|
|
191
196
|
const schema: TableSchema = {}
|
|
192
197
|
const descResp = await this.internalQuery(
|
|
193
198
|
{ sql: `DESCRIBE \`${tableName}\`;` },
|
|
194
|
-
false
|
|
199
|
+
{ connect: false }
|
|
195
200
|
)
|
|
196
201
|
for (let column of descResp) {
|
|
197
202
|
const columnName = column.Field
|
|
@@ -211,8 +216,8 @@ module MySQLModule {
|
|
|
211
216
|
schema[columnName] = {
|
|
212
217
|
name: columnName,
|
|
213
218
|
autocolumn: isAuto,
|
|
214
|
-
type: convertSqlType(column.Type),
|
|
215
219
|
constraints,
|
|
220
|
+
...convertSqlType(column.Type),
|
|
216
221
|
}
|
|
217
222
|
}
|
|
218
223
|
if (!tables[tableName]) {
|
|
@@ -254,7 +259,8 @@ module MySQLModule {
|
|
|
254
259
|
async query(json: QueryJson) {
|
|
255
260
|
await this.connect()
|
|
256
261
|
try {
|
|
257
|
-
const queryFn = (query: any) =>
|
|
262
|
+
const queryFn = (query: any) =>
|
|
263
|
+
this.internalQuery(query, { connect: false, disableCoercion: true })
|
|
258
264
|
return await this.queryWithReturning(json, queryFn)
|
|
259
265
|
} finally {
|
|
260
266
|
await this.disconnect()
|
|
@@ -279,9 +279,9 @@ module OracleModule {
|
|
|
279
279
|
)
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
private internalConvertType(column: OracleColumn): string {
|
|
282
|
+
private internalConvertType(column: OracleColumn): { type: string } {
|
|
283
283
|
if (this.isBooleanType(column)) {
|
|
284
|
-
return FieldTypes.BOOLEAN
|
|
284
|
+
return { type: FieldTypes.BOOLEAN }
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
return convertSqlType(column.type)
|
|
@@ -328,7 +328,7 @@ module OracleModule {
|
|
|
328
328
|
fieldSchema = {
|
|
329
329
|
autocolumn: OracleIntegration.isAutoColumn(oracleColumn),
|
|
330
330
|
name: columnName,
|
|
331
|
-
|
|
331
|
+
...this.internalConvertType(oracleColumn),
|
|
332
332
|
}
|
|
333
333
|
table.schema[columnName] = fieldSchema
|
|
334
334
|
}
|
|
@@ -227,7 +227,6 @@ module PostgresModule {
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
const type: string = convertSqlType(column.data_type)
|
|
231
230
|
const identity = !!(
|
|
232
231
|
column.identity_generation ||
|
|
233
232
|
column.identity_start ||
|
|
@@ -242,7 +241,7 @@ module PostgresModule {
|
|
|
242
241
|
tables[tableName].schema[columnName] = {
|
|
243
242
|
autocolumn: isAuto,
|
|
244
243
|
name: columnName,
|
|
245
|
-
|
|
244
|
+
...convertSqlType(column.data_type),
|
|
246
245
|
}
|
|
247
246
|
}
|
|
248
247
|
|
|
@@ -35,6 +35,9 @@ const SQL_DATE_TYPE_MAP = {
|
|
|
35
35
|
date: FieldTypes.DATETIME,
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
const SQL_DATE_ONLY_TYPES = ["date"]
|
|
39
|
+
const SQL_TIME_ONLY_TYPES = ["time"]
|
|
40
|
+
|
|
38
41
|
const SQL_STRING_TYPE_MAP = {
|
|
39
42
|
varchar: FieldTypes.STRING,
|
|
40
43
|
char: FieldTypes.STRING,
|
|
@@ -85,9 +88,9 @@ export function breakExternalTableId(tableId: string | undefined) {
|
|
|
85
88
|
return {}
|
|
86
89
|
}
|
|
87
90
|
const parts = tableId.split(DOUBLE_SEPARATOR)
|
|
88
|
-
let
|
|
91
|
+
let datasourceId = parts.shift()
|
|
89
92
|
// if they need joined
|
|
90
|
-
let
|
|
93
|
+
let tableName = parts.join(DOUBLE_SEPARATOR)
|
|
91
94
|
return { datasourceId, tableName }
|
|
92
95
|
}
|
|
93
96
|
|
|
@@ -137,12 +140,20 @@ export function breakRowIdField(_id: string | { _id: string }): any[] {
|
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
export function convertSqlType(type: string) {
|
|
143
|
+
let foundType = FieldTypes.STRING
|
|
144
|
+
const lcType = type.toLowerCase()
|
|
140
145
|
for (let [external, internal] of Object.entries(SQL_TYPE_MAP)) {
|
|
141
|
-
if (
|
|
142
|
-
|
|
146
|
+
if (lcType.includes(external)) {
|
|
147
|
+
foundType = internal
|
|
148
|
+
break
|
|
143
149
|
}
|
|
144
150
|
}
|
|
145
|
-
|
|
151
|
+
const schema: any = { type: foundType }
|
|
152
|
+
if (foundType === FieldTypes.DATETIME) {
|
|
153
|
+
schema.dateOnly = SQL_DATE_ONLY_TYPES.includes(lcType)
|
|
154
|
+
schema.timeOnly = SQL_TIME_ONLY_TYPES.includes(lcType)
|
|
155
|
+
}
|
|
156
|
+
return schema
|
|
146
157
|
}
|
|
147
158
|
|
|
148
159
|
export function getSqlQuery(query: SqlQuery | string): SqlQuery {
|
|
@@ -100,10 +100,10 @@ class Orchestrator {
|
|
|
100
100
|
let automation = this._automation
|
|
101
101
|
const app = await this.getApp()
|
|
102
102
|
let stopped = false
|
|
103
|
-
let loopStep
|
|
103
|
+
let loopStep = null
|
|
104
104
|
|
|
105
105
|
let stepCount = 0
|
|
106
|
-
let loopStepNumber
|
|
106
|
+
let loopStepNumber = null
|
|
107
107
|
let loopSteps = []
|
|
108
108
|
for (let step of automation.definition.steps) {
|
|
109
109
|
stepCount++
|
|
@@ -117,15 +117,17 @@ class Orchestrator {
|
|
|
117
117
|
if (loopStep) {
|
|
118
118
|
input = await processObject(loopStep.inputs, this._context)
|
|
119
119
|
}
|
|
120
|
-
let iterations = loopStep
|
|
120
|
+
let iterations = loopStep
|
|
121
|
+
? Array.isArray(input.binding)
|
|
122
|
+
? input.binding.length
|
|
123
|
+
: automationUtils.stringSplit(input.binding).length
|
|
124
|
+
: 1
|
|
121
125
|
let iterationCount = 0
|
|
122
126
|
for (let index = 0; index < iterations; index++) {
|
|
123
127
|
let originalStepInput = cloneDeep(step.inputs)
|
|
124
128
|
|
|
125
129
|
// Handle if the user has set a max iteration count or if it reaches the max limit set by us
|
|
126
130
|
if (loopStep) {
|
|
127
|
-
// lets first of all handle the input
|
|
128
|
-
// if the input is array then use it, if it is a string then split it on every new line
|
|
129
131
|
let newInput = await processObject(
|
|
130
132
|
loopStep.inputs,
|
|
131
133
|
cloneDeep(this._context)
|
|
@@ -134,9 +136,6 @@ class Orchestrator {
|
|
|
134
136
|
newInput,
|
|
135
137
|
loopStep.schema.inputs
|
|
136
138
|
)
|
|
137
|
-
this._context.steps[loopStepNumber] = {
|
|
138
|
-
currentItem: newInput.binding[index],
|
|
139
|
-
}
|
|
140
139
|
|
|
141
140
|
let tempOutput = { items: loopSteps, iterations: iterationCount }
|
|
142
141
|
if (
|
|
@@ -154,6 +153,20 @@ class Orchestrator {
|
|
|
154
153
|
break
|
|
155
154
|
}
|
|
156
155
|
|
|
156
|
+
let item
|
|
157
|
+
if (
|
|
158
|
+
typeof loopStep.inputs.binding === "string" &&
|
|
159
|
+
loopStep.inputs.option === "String"
|
|
160
|
+
) {
|
|
161
|
+
item = automationUtils.stringSplit(newInput.binding)
|
|
162
|
+
} else {
|
|
163
|
+
item = loopStep.inputs.binding
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this._context.steps[loopStepNumber] = {
|
|
167
|
+
currentItem: item[index],
|
|
168
|
+
}
|
|
169
|
+
|
|
157
170
|
// The "Loop" binding in the front end is "fake", so replace it here so the context can understand it
|
|
158
171
|
// Pretty hacky because we need to account for the row object
|
|
159
172
|
for (let [key, value] of Object.entries(originalStepInput)) {
|
|
@@ -286,18 +299,16 @@ class Orchestrator {
|
|
|
286
299
|
|
|
287
300
|
module.exports = (input, callback) => {
|
|
288
301
|
const appId = input.data.event.appId
|
|
289
|
-
doInAppContext(appId, () => {
|
|
302
|
+
doInAppContext(appId, async () => {
|
|
290
303
|
const automationOrchestrator = new Orchestrator(
|
|
291
304
|
input.data.automation,
|
|
292
305
|
input.data.event
|
|
293
306
|
)
|
|
294
|
-
|
|
295
|
-
.execute()
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
callback(err)
|
|
301
|
-
})
|
|
307
|
+
try {
|
|
308
|
+
const response = await automationOrchestrator.execute()
|
|
309
|
+
callback(null, response)
|
|
310
|
+
} catch (err) {
|
|
311
|
+
callback(err)
|
|
312
|
+
}
|
|
302
313
|
})
|
|
303
314
|
}
|
package/src/threads/query.js
CHANGED
|
@@ -191,14 +191,13 @@ class QueryRunner {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
module.exports = (input, callback) => {
|
|
194
|
-
doInAppContext(input.appId, () => {
|
|
194
|
+
doInAppContext(input.appId, async () => {
|
|
195
195
|
const Runner = new QueryRunner(input)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
})
|
|
196
|
+
try {
|
|
197
|
+
const response = await Runner.execute()
|
|
198
|
+
callback(null, response)
|
|
199
|
+
} catch (err) {
|
|
200
|
+
callback(err)
|
|
201
|
+
}
|
|
203
202
|
})
|
|
204
203
|
}
|
|
@@ -2,7 +2,11 @@ const { budibaseTempDir } = require("../budibaseDir")
|
|
|
2
2
|
const fs = require("fs")
|
|
3
3
|
const { join } = require("path")
|
|
4
4
|
const uuid = require("uuid/v4")
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
doWithDB,
|
|
7
|
+
dangerousGetDB,
|
|
8
|
+
closeDB,
|
|
9
|
+
} = require("@budibase/backend-core/db")
|
|
6
10
|
const { ObjectStoreBuckets } = require("../../constants")
|
|
7
11
|
const {
|
|
8
12
|
upload,
|
|
@@ -151,14 +155,18 @@ exports.streamBackup = async appId => {
|
|
|
151
155
|
* @return {*} either a readable stream or a string
|
|
152
156
|
*/
|
|
153
157
|
exports.exportDB = async (dbName, { stream, filter, exportName } = {}) => {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
158
|
+
// streaming a DB dump is a bit more complicated, can't close DB
|
|
159
|
+
if (stream) {
|
|
160
|
+
const db = dangerousGetDB(dbName)
|
|
161
|
+
const memStream = new MemoryStream()
|
|
162
|
+
memStream.on("end", async () => {
|
|
163
|
+
await closeDB(db)
|
|
164
|
+
})
|
|
165
|
+
db.dump(memStream, { filter })
|
|
166
|
+
return memStream
|
|
167
|
+
}
|
|
161
168
|
|
|
169
|
+
return doWithDB(dbName, async db => {
|
|
162
170
|
// Write the dump to file if required
|
|
163
171
|
if (exportName) {
|
|
164
172
|
const path = join(budibaseTempDir(), exportName)
|