@budibase/server 1.0.78 → 1.0.79-alpha.10
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 +1 -0
- package/builder/assets/index.1a081633.js +1288 -0
- package/builder/assets/{index.c8d1e8f0.css → index.c57242d4.css} +2 -2
- package/builder/assets/{vendor.20f80cec.js → vendor.a7c6ad0a.js} +190 -216
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2399 -2336
- package/coverage/coverage-final.json +138 -137
- package/coverage/lcov-report/api/controllers/analytics.js.html +6 -6
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/application.js.html +152 -149
- package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
- package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -11
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
- package/coverage/lcov-report/api/controllers/dev.js.html +19 -19
- package/coverage/lcov-report/api/controllers/index.html +16 -16
- package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
- package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
- package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +16 -16
- package/coverage/lcov-report/api/controllers/row/index.html +27 -27
- package/coverage/lcov-report/api/controllers/row/index.js.html +46 -46
- package/coverage/lcov-report/api/controllers/row/internal.js.html +94 -82
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +204 -204
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
- package/coverage/lcov-report/api/controllers/row/utils.js.html +29 -29
- package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +49 -49
- package/coverage/lcov-report/api/controllers/table/external.js.html +12 -12
- package/coverage/lcov-report/api/controllers/table/index.html +11 -11
- package/coverage/lcov-report/api/controllers/table/index.js.html +47 -44
- package/coverage/lcov-report/api/controllers/table/internal.js.html +50 -50
- package/coverage/lcov-report/api/controllers/table/utils.js.html +80 -80
- package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
- package/coverage/lcov-report/api/controllers/user.js.html +19 -19
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/view/utils.js.html +12 -12
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +18 -27
- package/coverage/lcov-report/api/index.html +10 -10
- package/coverage/lcov-report/api/index.js.html +37 -28
- package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/application.js.html +9 -9
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +19 -109
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +18 -156
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +13 -13
- package/coverage/lcov-report/api/routes/index.html +35 -35
- package/coverage/lcov-report/api/routes/index.js.html +38 -32
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
- package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
- package/coverage/lcov-report/api/routes/permission.js.html +16 -58
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +15 -78
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +17 -14
- package/coverage/lcov-report/api/routes/screen.js.html +14 -95
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +13 -13
- package/coverage/lcov-report/api/routes/table.js.html +17 -62
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +8 -8
- package/coverage/lcov-report/api/routes/utils/index.html +111 -0
- package/coverage/lcov-report/api/routes/utils/validators.js.html +737 -0
- package/coverage/lcov-report/api/routes/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +14 -62
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +7 -7
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +12 -9
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +11 -11
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +26 -26
- package/coverage/lcov-report/automations/utils.js.html +35 -35
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +40 -28
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +21 -21
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +30 -30
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +123 -87
- 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 +8 -8
- package/coverage/lcov-report/events/utils.js.html +18 -18
- package/coverage/lcov-report/index.html +89 -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 +5 -5
- package/coverage/lcov-report/middleware/authorized.js.html +29 -29
- package/coverage/lcov-report/middleware/builder.js.html +16 -16
- package/coverage/lcov-report/middleware/currentapp.js.html +44 -44
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
- package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +17 -17
- package/coverage/lcov-report/middleware/utils.js.html +4 -4
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +19 -19
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +123 -39
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +28 -28
- package/coverage/lcov-report/utilities/index.html +18 -18
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -9
- 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 +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +60 -60
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +13 -13
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- 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/index.js.html +12 -12
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +8 -8
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +200 -53
- package/coverage/lcov.info +3323 -3224
- package/dist/api/controllers/application.js +1 -0
- package/dist/api/controllers/public/applications.js +94 -0
- package/dist/api/controllers/public/mapping/applications.js +29 -0
- package/dist/api/controllers/public/mapping/index.js +11 -0
- package/dist/api/controllers/public/mapping/queries.js +36 -0
- package/dist/api/controllers/public/mapping/rows.js +24 -0
- package/dist/api/controllers/public/mapping/tables.js +23 -0
- package/dist/api/controllers/public/mapping/types.js +2 -0
- package/dist/api/controllers/public/mapping/users.js +29 -0
- package/dist/api/controllers/public/queries.js +38 -0
- package/dist/api/controllers/public/rows.js +97 -0
- package/dist/api/controllers/public/tables.js +75 -0
- package/dist/api/controllers/public/users.js +95 -0
- package/dist/api/controllers/public/utils.js +49 -0
- package/dist/api/controllers/row/internal.js +4 -1
- package/dist/api/controllers/table/index.js +2 -1
- package/dist/api/controllers/webhook.js +3 -5
- package/dist/api/index.js +3 -1
- package/dist/api/routes/automation.js +3 -31
- package/dist/api/routes/datasource.js +3 -50
- package/dist/api/routes/index.js +2 -0
- package/dist/api/routes/permission.js +4 -14
- package/dist/api/routes/public/applications.js +141 -0
- package/dist/api/routes/public/index.js +68 -0
- package/dist/api/routes/public/middleware/mapper.js +94 -0
- package/dist/api/routes/public/queries.js +77 -0
- package/dist/api/routes/public/rows.js +229 -0
- package/dist/api/routes/public/tables.js +154 -0
- package/dist/api/routes/public/users.js +137 -0
- package/dist/api/routes/public/utils/Endpoint.js +36 -0
- package/dist/api/routes/role.js +3 -19
- package/dist/api/routes/row.js +3 -4
- package/dist/api/routes/screen.js +2 -23
- package/dist/api/routes/table.js +3 -17
- package/dist/api/routes/tests/utilities/index.js +23 -0
- package/dist/api/routes/utils/validators.js +200 -0
- package/dist/api/routes/webhook.js +2 -17
- package/dist/automations/steps/filter.js +2 -2
- package/dist/automations/steps/queryRows.js +1 -1
- package/dist/automations/utils.js +2 -2
- package/dist/constants/index.js +3 -0
- package/dist/db/utils.js +11 -0
- package/dist/definitions/openapi.js +6 -0
- package/dist/integrations/googlesheets.js +3 -0
- package/dist/integrations/microsoftSqlServer.js +35 -29
- package/dist/integrations/mysql.js +30 -26
- package/dist/integrations/oracle.js +14 -19
- package/dist/integrations/postgres.js +34 -28
- package/dist/package.json +8 -7
- package/dist/tests/utilities/TestConfiguration.js +25 -8
- package/dist/threads/query.js +33 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +50 -15
- package/package.json +9 -8
- package/scripts/integrations/oracle/oracle.md +2 -2
- package/scripts/integrations/postgres/init.sql +5 -3
- package/scripts/likeCypress.ts +9 -6
- package/specs/generate.js +83 -0
- package/specs/openapi.json +2222 -0
- package/specs/openapi.yaml +1530 -0
- package/specs/parameters.js +59 -0
- package/specs/resources/application.js +101 -0
- package/specs/resources/index.js +24 -0
- package/specs/resources/misc.js +12 -0
- package/specs/resources/query.js +189 -0
- package/specs/resources/row.js +125 -0
- package/specs/resources/table.js +191 -0
- package/specs/resources/user.js +126 -0
- package/specs/resources/utils/Resource.js +26 -0
- package/specs/resources/utils/index.js +11 -0
- package/specs/security.js +7 -0
- package/src/api/controllers/application.js +1 -0
- package/src/api/controllers/public/applications.ts +74 -0
- package/src/api/controllers/public/mapping/applications.ts +32 -0
- package/src/api/controllers/public/mapping/index.ts +13 -0
- package/src/api/controllers/public/mapping/queries.ts +39 -0
- package/src/api/controllers/public/mapping/rows.ts +31 -0
- package/src/api/controllers/public/mapping/tables.ts +26 -0
- package/src/api/controllers/public/mapping/types.ts +13 -0
- package/src/api/controllers/public/mapping/users.ts +32 -0
- package/src/api/controllers/public/queries.ts +20 -0
- package/src/api/controllers/public/rows.ts +77 -0
- package/src/api/controllers/public/tables.ts +56 -0
- package/src/api/controllers/public/users.ts +82 -0
- package/src/api/controllers/public/utils.ts +38 -0
- package/src/api/controllers/row/internal.js +4 -0
- package/src/api/controllers/table/index.js +2 -1
- package/src/api/controllers/webhook.js +3 -6
- package/src/api/index.js +4 -1
- package/src/api/routes/automation.js +3 -33
- package/src/api/routes/datasource.js +6 -52
- package/src/api/routes/index.js +2 -0
- package/src/api/routes/permission.js +4 -18
- package/src/api/routes/public/applications.ts +156 -0
- package/src/api/routes/public/index.ts +82 -0
- package/src/api/routes/public/middleware/mapper.ts +81 -0
- package/src/api/routes/public/queries.ts +81 -0
- package/src/api/routes/public/rows.ts +242 -0
- package/src/api/routes/public/tables.ts +169 -0
- package/src/api/routes/public/tests/compare.spec.js +184 -0
- package/src/api/routes/public/users.ts +144 -0
- package/src/api/routes/public/utils/Endpoint.ts +51 -0
- package/src/api/routes/role.js +3 -24
- package/src/api/routes/row.js +3 -2
- package/src/api/routes/screen.js +2 -29
- package/src/api/routes/table.js +4 -19
- package/src/api/routes/tests/utilities/index.js +24 -0
- package/src/api/routes/utils/validators.js +219 -0
- package/src/api/routes/webhook.js +2 -18
- package/src/automations/steps/filter.js +3 -2
- package/src/automations/steps/queryRows.js +1 -1
- package/src/automations/utils.js +2 -2
- package/src/constants/index.js +4 -0
- package/src/db/utils.js +12 -0
- package/src/definitions/common.ts +4 -0
- package/src/definitions/openapi.ts +943 -0
- package/src/integrations/base/datasourcePlus.ts +3 -0
- package/src/integrations/googlesheets.ts +5 -2
- package/src/integrations/microsoftSqlServer.ts +38 -33
- package/src/integrations/mysql.ts +38 -36
- package/src/integrations/oracle.ts +27 -35
- package/src/integrations/postgres.ts +33 -26
- package/src/tests/utilities/TestConfiguration.js +23 -2
- package/src/threads/query.js +37 -9
- package/src/utilities/workerRequests.js +65 -16
- package/builder/assets/index.ab059cf2.js +0 -1352
- package/scripts/proxy/generateProxyConfig.js +0 -70
|
@@ -74,6 +74,7 @@ var OracleModule;
|
|
|
74
74
|
class OracleIntegration extends sql_1.default {
|
|
75
75
|
constructor(config) {
|
|
76
76
|
super(utils_1.SqlClients.ORACLE);
|
|
77
|
+
this.index = 1;
|
|
77
78
|
this.tables = {};
|
|
78
79
|
this.schemaErrors = {};
|
|
79
80
|
this.COLUMNS_SQL = `
|
|
@@ -116,6 +117,9 @@ var OracleModule;
|
|
|
116
117
|
});
|
|
117
118
|
this.config = config;
|
|
118
119
|
}
|
|
120
|
+
getBindingIdentifier() {
|
|
121
|
+
return `:${this.index++}`;
|
|
122
|
+
}
|
|
119
123
|
/**
|
|
120
124
|
* Map the flat tabular columns and constraints data into a nested object
|
|
121
125
|
*/
|
|
@@ -167,24 +171,18 @@ var OracleModule;
|
|
|
167
171
|
}
|
|
168
172
|
return oracleTables;
|
|
169
173
|
}
|
|
170
|
-
isSupportedColumn(column) {
|
|
171
|
-
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
return true;
|
|
174
|
+
static isSupportedColumn(column) {
|
|
175
|
+
return !UNSUPPORTED_TYPES.includes(column.type);
|
|
175
176
|
}
|
|
176
|
-
isAutoColumn(column) {
|
|
177
|
-
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
return false;
|
|
177
|
+
static isAutoColumn(column) {
|
|
178
|
+
return !!(column.default && column.default.toLowerCase().includes("nextval"));
|
|
181
179
|
}
|
|
182
180
|
/**
|
|
183
181
|
* No native boolean in oracle. Best we can do is to check if a manual 1 or 0 number constraint has been set up
|
|
184
182
|
* This matches the default behaviour for generating DDL used in knex.
|
|
185
183
|
*/
|
|
186
184
|
isBooleanType(column) {
|
|
187
|
-
|
|
185
|
+
return (column.type.toLowerCase() === "number" &&
|
|
188
186
|
Object.values(column.constraints).filter(c => {
|
|
189
187
|
if (c.type === OracleContraintTypes.NOT_NULL_OR_CHECK &&
|
|
190
188
|
c.searchCondition) {
|
|
@@ -197,10 +195,7 @@ var OracleModule;
|
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
197
|
return false;
|
|
200
|
-
}).length > 0)
|
|
201
|
-
return true;
|
|
202
|
-
}
|
|
203
|
-
return false;
|
|
198
|
+
}).length > 0);
|
|
204
199
|
}
|
|
205
200
|
internalConvertType(column) {
|
|
206
201
|
if (this.isBooleanType(column)) {
|
|
@@ -235,7 +230,7 @@ var OracleModule;
|
|
|
235
230
|
// iterate each column on the table
|
|
236
231
|
Object.values(oracleTable.columns)
|
|
237
232
|
// remove columns that we can't read / save
|
|
238
|
-
.filter(oracleColumn =>
|
|
233
|
+
.filter(oracleColumn => OracleIntegration.isSupportedColumn(oracleColumn))
|
|
239
234
|
// match the order of the columns in the db
|
|
240
235
|
.sort((c1, c2) => c1.id - c2.id)
|
|
241
236
|
.forEach(oracleColumn => {
|
|
@@ -243,7 +238,7 @@ var OracleModule;
|
|
|
243
238
|
let fieldSchema = table.schema[columnName];
|
|
244
239
|
if (!fieldSchema) {
|
|
245
240
|
fieldSchema = {
|
|
246
|
-
autocolumn:
|
|
241
|
+
autocolumn: OracleIntegration.isAutoColumn(oracleColumn),
|
|
247
242
|
name: columnName,
|
|
248
243
|
type: this.internalConvertType(oracleColumn),
|
|
249
244
|
};
|
|
@@ -266,11 +261,11 @@ var OracleModule;
|
|
|
266
261
|
return __awaiter(this, void 0, void 0, function* () {
|
|
267
262
|
let connection;
|
|
268
263
|
try {
|
|
264
|
+
this.index = 1;
|
|
269
265
|
connection = yield this.getConnection();
|
|
270
266
|
const options = { autoCommit: true };
|
|
271
267
|
const bindings = query.bindings || [];
|
|
272
|
-
|
|
273
|
-
return result;
|
|
268
|
+
return yield connection.execute(query.sql, bindings, options);
|
|
274
269
|
}
|
|
275
270
|
finally {
|
|
276
271
|
if (connection) {
|
|
@@ -84,31 +84,10 @@ var PostgresModule;
|
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
86
|
};
|
|
87
|
-
function internalQuery(client, query) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
// need to handle a specific issue with json data types in postgres,
|
|
90
|
-
// new lines inside the JSON data will break it
|
|
91
|
-
if (query && query.sql) {
|
|
92
|
-
const matches = query.sql.match(JSON_REGEX);
|
|
93
|
-
if (matches && matches.length > 0) {
|
|
94
|
-
for (let match of matches) {
|
|
95
|
-
const escaped = escapeDangerousCharacters(match);
|
|
96
|
-
query.sql = query.sql.replace(match, escaped);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
return yield client.query(query.sql, query.bindings || []);
|
|
102
|
-
}
|
|
103
|
-
catch (err) {
|
|
104
|
-
// @ts-ignore
|
|
105
|
-
throw new Error(err);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
87
|
class PostgresIntegration extends Sql {
|
|
110
88
|
constructor(config) {
|
|
111
89
|
super(utils_1.SqlClients.POSTGRES);
|
|
90
|
+
this.index = 1;
|
|
112
91
|
this.tables = {};
|
|
113
92
|
this.schemaErrors = {};
|
|
114
93
|
this.PRIMARY_KEYS_SQL = `
|
|
@@ -133,6 +112,33 @@ var PostgresModule;
|
|
|
133
112
|
this.client = this.pool;
|
|
134
113
|
this.setSchema();
|
|
135
114
|
}
|
|
115
|
+
getBindingIdentifier() {
|
|
116
|
+
return `$${this.index++}`;
|
|
117
|
+
}
|
|
118
|
+
internalQuery(query) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const client = this.client;
|
|
121
|
+
this.index = 1;
|
|
122
|
+
// need to handle a specific issue with json data types in postgres,
|
|
123
|
+
// new lines inside the JSON data will break it
|
|
124
|
+
if (query && query.sql) {
|
|
125
|
+
const matches = query.sql.match(JSON_REGEX);
|
|
126
|
+
if (matches && matches.length > 0) {
|
|
127
|
+
for (let match of matches) {
|
|
128
|
+
const escaped = escapeDangerousCharacters(match);
|
|
129
|
+
query.sql = query.sql.replace(match, escaped);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
return yield client.query(query.sql, query.bindings || []);
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
// @ts-ignore
|
|
138
|
+
throw new Error(err);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
136
142
|
setSchema() {
|
|
137
143
|
if (!this.config.schema) {
|
|
138
144
|
this.config.schema = "public";
|
|
@@ -202,25 +208,25 @@ var PostgresModule;
|
|
|
202
208
|
}
|
|
203
209
|
create(query) {
|
|
204
210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
-
const response = yield internalQuery(
|
|
211
|
+
const response = yield this.internalQuery(utils_1.getSqlQuery(query));
|
|
206
212
|
return response.rows.length ? response.rows : [{ created: true }];
|
|
207
213
|
});
|
|
208
214
|
}
|
|
209
215
|
read(query) {
|
|
210
216
|
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
-
const response = yield internalQuery(
|
|
217
|
+
const response = yield this.internalQuery(utils_1.getSqlQuery(query));
|
|
212
218
|
return response.rows;
|
|
213
219
|
});
|
|
214
220
|
}
|
|
215
221
|
update(query) {
|
|
216
222
|
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
-
const response = yield internalQuery(
|
|
223
|
+
const response = yield this.internalQuery(utils_1.getSqlQuery(query));
|
|
218
224
|
return response.rows.length ? response.rows : [{ updated: true }];
|
|
219
225
|
});
|
|
220
226
|
}
|
|
221
227
|
delete(query) {
|
|
222
228
|
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
-
const response = yield internalQuery(
|
|
229
|
+
const response = yield this.internalQuery(utils_1.getSqlQuery(query));
|
|
224
230
|
return response.rows.length ? response.rows : [{ deleted: true }];
|
|
225
231
|
});
|
|
226
232
|
}
|
|
@@ -231,12 +237,12 @@ var PostgresModule;
|
|
|
231
237
|
if (Array.isArray(input)) {
|
|
232
238
|
const responses = [];
|
|
233
239
|
for (let query of input) {
|
|
234
|
-
responses.push(yield internalQuery(
|
|
240
|
+
responses.push(yield this.internalQuery(query));
|
|
235
241
|
}
|
|
236
242
|
return responses;
|
|
237
243
|
}
|
|
238
244
|
else {
|
|
239
|
-
const response = yield internalQuery(
|
|
245
|
+
const response = yield this.internalQuery(input);
|
|
240
246
|
return response.rows.length ? response.rows : [{ [operation]: true }];
|
|
241
247
|
}
|
|
242
248
|
});
|
package/dist/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.79-alpha.9",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -21,10 +21,8 @@
|
|
|
21
21
|
"dev:stack:down": "node scripts/dev/manage.js down",
|
|
22
22
|
"dev:stack:nuke": "node scripts/dev/manage.js nuke",
|
|
23
23
|
"dev:builder": "yarn run dev:stack:up && nodemon",
|
|
24
|
-
"generate:proxy:compose": "node scripts/proxy/generateProxyConfig compose",
|
|
25
|
-
"generate:proxy:preprod": "node scripts/proxy/generateProxyConfig preprod",
|
|
26
|
-
"generate:proxy:prod": "node scripts/proxy/generateProxyConfig prod",
|
|
27
24
|
"format": "prettier --config ../../.prettierrc.json 'src/**/*.ts' --write",
|
|
25
|
+
"specs": "node specs/generate.js && openapi-typescript specs/openapi.yaml --output src/definitions/openapi.ts",
|
|
28
26
|
"lint": "eslint --fix src/",
|
|
29
27
|
"lint:fix": "yarn run format && yarn run lint",
|
|
30
28
|
"initialise": "node scripts/initialise.js",
|
|
@@ -73,9 +71,9 @@
|
|
|
73
71
|
"license": "GPL-3.0",
|
|
74
72
|
"dependencies": {
|
|
75
73
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
76
|
-
"@budibase/backend-core": "^1.0.
|
|
77
|
-
"@budibase/client": "^1.0.
|
|
78
|
-
"@budibase/string-templates": "^1.0.
|
|
74
|
+
"@budibase/backend-core": "^1.0.79-alpha.9",
|
|
75
|
+
"@budibase/client": "^1.0.79-alpha.9",
|
|
76
|
+
"@budibase/string-templates": "^1.0.79-alpha.9",
|
|
79
77
|
"@bull-board/api": "^3.7.0",
|
|
80
78
|
"@bull-board/koa": "^3.7.0",
|
|
81
79
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -157,12 +155,15 @@
|
|
|
157
155
|
"docker-compose": "^0.23.6",
|
|
158
156
|
"eslint": "^6.8.0",
|
|
159
157
|
"jest": "^27.0.5",
|
|
158
|
+
"jest-openapi": "^0.14.2",
|
|
160
159
|
"nodemon": "^2.0.4",
|
|
161
160
|
"openapi-types": "^9.3.1",
|
|
161
|
+
"openapi-typescript": "^5.2.0",
|
|
162
162
|
"path-to-regexp": "^6.2.0",
|
|
163
163
|
"prettier": "^2.3.1",
|
|
164
164
|
"rimraf": "^3.0.2",
|
|
165
165
|
"supertest": "^4.0.2",
|
|
166
|
+
"swagger-jsdoc": "^6.1.0",
|
|
166
167
|
"ts-jest": "^27.0.3",
|
|
167
168
|
"ts-node": "^10.0.0",
|
|
168
169
|
"typescript": "^4.3.5",
|
|
@@ -24,6 +24,8 @@ const { createASession } = require("@budibase/backend-core/sessions");
|
|
|
24
24
|
const { user: userCache } = require("@budibase/backend-core/cache");
|
|
25
25
|
const newid = require("../../db/newid");
|
|
26
26
|
const context = require("@budibase/backend-core/context");
|
|
27
|
+
const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db");
|
|
28
|
+
const { encrypt } = require("@budibase/backend-core/encryption");
|
|
27
29
|
const GLOBAL_USER_ID = "us_uuid1";
|
|
28
30
|
const EMAIL = "babs@babs.com";
|
|
29
31
|
const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306";
|
|
@@ -42,6 +44,9 @@ class TestConfiguration {
|
|
|
42
44
|
getRequest() {
|
|
43
45
|
return this.request;
|
|
44
46
|
}
|
|
47
|
+
getApp() {
|
|
48
|
+
return this.app;
|
|
49
|
+
}
|
|
45
50
|
getAppId() {
|
|
46
51
|
return this.appId;
|
|
47
52
|
}
|
|
@@ -80,6 +85,22 @@ class TestConfiguration {
|
|
|
80
85
|
}
|
|
81
86
|
});
|
|
82
87
|
}
|
|
88
|
+
generateApiKey(userId = GLOBAL_USER_ID) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const db = getGlobalDB(TENANT_ID);
|
|
91
|
+
const id = generateDevInfoID(userId);
|
|
92
|
+
let devInfo;
|
|
93
|
+
try {
|
|
94
|
+
devInfo = yield db.get(id);
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
devInfo = { _id: id, userId };
|
|
98
|
+
}
|
|
99
|
+
devInfo.apiKey = encrypt(`${TENANT_ID}${SEPARATOR}${newid()}`);
|
|
100
|
+
yield db.put(devInfo);
|
|
101
|
+
return devInfo.apiKey;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
83
104
|
globalUser({ id = GLOBAL_USER_ID, builder = true, email = EMAIL, roles, } = {}) {
|
|
84
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
106
|
const db = getGlobalDB(TENANT_ID);
|
|
@@ -122,7 +143,7 @@ class TestConfiguration {
|
|
|
122
143
|
}
|
|
123
144
|
cleanup(this.allApps.map(app => app.appId));
|
|
124
145
|
}
|
|
125
|
-
defaultHeaders() {
|
|
146
|
+
defaultHeaders(extras = {}) {
|
|
126
147
|
const auth = {
|
|
127
148
|
userId: GLOBAL_USER_ID,
|
|
128
149
|
sessionId: "sessionid",
|
|
@@ -134,14 +155,10 @@ class TestConfiguration {
|
|
|
134
155
|
};
|
|
135
156
|
const authToken = jwt.sign(auth, env.JWT_SECRET);
|
|
136
157
|
const appToken = jwt.sign(app, env.JWT_SECRET);
|
|
137
|
-
const headers = {
|
|
138
|
-
Accept: "application/json",
|
|
139
|
-
Cookie: [
|
|
158
|
+
const headers = Object.assign({ Accept: "application/json", Cookie: [
|
|
140
159
|
`${Cookies.Auth}=${authToken}`,
|
|
141
160
|
`${Cookies.CurrentApp}=${appToken}`,
|
|
142
|
-
],
|
|
143
|
-
[Headers.CSRF_TOKEN]: CSRF_TOKEN,
|
|
144
|
-
};
|
|
161
|
+
], [Headers.CSRF_TOKEN]: CSRF_TOKEN }, extras);
|
|
145
162
|
if (this.appId) {
|
|
146
163
|
headers[Headers.APP_ID] = this.appId;
|
|
147
164
|
}
|
|
@@ -204,7 +221,7 @@ class TestConfiguration {
|
|
|
204
221
|
getTable(tableId = null) {
|
|
205
222
|
return __awaiter(this, void 0, void 0, function* () {
|
|
206
223
|
tableId = tableId || this.table._id;
|
|
207
|
-
return this._req(null, {
|
|
224
|
+
return this._req(null, { tableId }, controllers.table.find);
|
|
208
225
|
});
|
|
209
226
|
}
|
|
210
227
|
createLinkedTable(relationshipType = null, links = ["link"]) {
|
package/dist/threads/query.js
CHANGED
|
@@ -12,8 +12,9 @@ const threadUtils = require("./utils");
|
|
|
12
12
|
threadUtils.threadSetup();
|
|
13
13
|
const ScriptRunner = require("../utilities/scriptRunner");
|
|
14
14
|
const { integrations } = require("../integrations");
|
|
15
|
-
const { processStringSync } = require("@budibase/string-templates");
|
|
15
|
+
const { processStringSync, findHBSBlocks, } = require("@budibase/string-templates");
|
|
16
16
|
const { doInAppContext, getAppDB } = require("@budibase/backend-core/context");
|
|
17
|
+
const { isSQL } = require("../integrations/utils");
|
|
17
18
|
class QueryRunner {
|
|
18
19
|
constructor(input, flags = { noRecursiveQuery: false }) {
|
|
19
20
|
this.datasource = input.datasource;
|
|
@@ -31,21 +32,45 @@ class QueryRunner {
|
|
|
31
32
|
this.queryResponse = {};
|
|
32
33
|
this.hasRerun = false;
|
|
33
34
|
}
|
|
35
|
+
interpolateSQL(fields, parameters, integration) {
|
|
36
|
+
let sql = fields.sql;
|
|
37
|
+
if (!sql) {
|
|
38
|
+
return fields;
|
|
39
|
+
}
|
|
40
|
+
const bindings = findHBSBlocks(sql);
|
|
41
|
+
let variables = [];
|
|
42
|
+
for (let binding of bindings) {
|
|
43
|
+
let variable = integration.getBindingIdentifier();
|
|
44
|
+
variables.push(binding);
|
|
45
|
+
sql = sql.replace(binding, variable);
|
|
46
|
+
}
|
|
47
|
+
// replicate the knex structure
|
|
48
|
+
fields.sql = sql;
|
|
49
|
+
fields.bindings = this.enrichQueryFields(variables, parameters);
|
|
50
|
+
return fields;
|
|
51
|
+
}
|
|
34
52
|
execute() {
|
|
35
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
54
|
let { datasource, fields, queryVerb, transformer } = this;
|
|
55
|
+
const Integration = integrations[datasource.source];
|
|
56
|
+
if (!Integration) {
|
|
57
|
+
throw "Integration type does not exist.";
|
|
58
|
+
}
|
|
59
|
+
const integration = new Integration(datasource.config);
|
|
37
60
|
// pre-query, make sure datasource variables are added to parameters
|
|
38
61
|
const parameters = yield this.addDatasourceVariables();
|
|
39
|
-
let query
|
|
62
|
+
let query;
|
|
63
|
+
// handle SQL injections by interpolating the variables
|
|
64
|
+
if (isSQL(datasource)) {
|
|
65
|
+
query = this.interpolateSQL(fields, parameters, integration);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
query = this.enrichQueryFields(fields, parameters);
|
|
69
|
+
}
|
|
40
70
|
// Add pagination values for REST queries
|
|
41
71
|
if (this.pagination) {
|
|
42
72
|
query.paginationValues = this.pagination;
|
|
43
73
|
}
|
|
44
|
-
const Integration = integrations[datasource.source];
|
|
45
|
-
if (!Integration) {
|
|
46
|
-
throw "Integration type does not exist.";
|
|
47
|
-
}
|
|
48
|
-
const integration = new Integration(datasource.config);
|
|
49
74
|
let output = threadUtils.formatResponse(yield integration[queryVerb](query));
|
|
50
75
|
let rows = output, info = undefined, extra = undefined, pagination = undefined;
|
|
51
76
|
if (threadUtils.hasExtraData(output)) {
|
|
@@ -168,7 +193,7 @@ class QueryRunner {
|
|
|
168
193
|
});
|
|
169
194
|
}
|
|
170
195
|
enrichQueryFields(fields, parameters = {}) {
|
|
171
|
-
const enrichedQuery = {};
|
|
196
|
+
const enrichedQuery = Array.isArray(fields) ? [] : {};
|
|
172
197
|
// enrich the fields with dynamic parameters
|
|
173
198
|
for (let key of Object.keys(fields)) {
|
|
174
199
|
if (fields[key] == null) {
|