@budibase/server 1.2.37 → 1.2.39-alpha.1
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__/mongodb.ts +4 -0
- package/__mocks__/node-fetch.ts +8 -1
- package/builder/assets/index.a1c0a62f.js +977 -0
- package/builder/assets/{index.08dd0c5e.css → index.f1c7e247.css} +1 -1
- package/builder/index.html +2 -2
- package/coverage/clover.xml +385 -380
- package/coverage/coverage-final.json +21 -21
- 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 +3 -3
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
- package/coverage/lcov-report/api/controllers/cloud.js.html +4 -4
- package/coverage/lcov-report/api/controllers/component.js.html +3 -3
- package/coverage/lcov-report/api/controllers/datasource.js.html +3 -3
- package/coverage/lcov-report/api/controllers/dev.js.html +4 -4
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +3 -3
- 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 +25 -25
- package/coverage/lcov-report/api/controllers/row/internal.js.html +3 -3
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +209 -191
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +27 -18
- 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 +2 -2
- 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 +19 -19
- 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 +3 -3
- package/coverage/lcov-report/api/controllers/view/utils.js.html +5 -5
- 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 +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- 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 +30 -30
- 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 +3 -3
- package/coverage/lcov-report/db/newid.js.html +3 -3
- package/coverage/lcov-report/db/utils.js.html +99 -99
- 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 +19 -19
- 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 +3 -3
- 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/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 +16 -16
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +23 -23
- 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 +3 -3
- 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 +9 -9
- 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 +7 -7
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +598 -593
- package/dist/api/controllers/analytics.js +1 -1
- package/dist/api/controllers/application.js +8 -8
- package/dist/api/controllers/automation.js +2 -2
- package/dist/api/controllers/backup.js +2 -2
- package/dist/api/controllers/cloud.js +3 -3
- package/dist/api/controllers/component.js +2 -2
- package/dist/api/controllers/datasource.js +2 -2
- package/dist/api/controllers/deploy/index.js +6 -6
- package/dist/api/controllers/dev.js +3 -3
- package/dist/api/controllers/integration.js +2 -2
- package/dist/api/controllers/public/utils.js +1 -1
- package/dist/api/controllers/row/ExternalRequest.js +3 -3
- package/dist/api/controllers/row/internal.js +2 -2
- package/dist/api/controllers/row/internalSearch.js +5 -0
- package/dist/api/controllers/row/utils.js +3 -1
- package/dist/api/controllers/static/index.js +2 -2
- package/dist/api/controllers/table/external.js +1 -1
- package/dist/api/controllers/view/index.js +2 -2
- package/dist/api/controllers/view/utils.js +3 -3
- package/dist/automations/logging/index.js +3 -0
- package/dist/db/linkedRows/linkUtils.js +2 -2
- package/dist/db/utils.js +37 -37
- package/dist/db/views/staticViews.js +4 -4
- package/dist/definitions/automations.js +6 -6
- package/dist/definitions/datasource.js +6 -70
- package/dist/integrations/airtable.js +13 -13
- package/dist/integrations/arangodb.js +8 -8
- package/dist/integrations/base/query.js +27 -0
- package/dist/integrations/base/sql.js +33 -32
- package/dist/integrations/base/sqlTable.js +4 -4
- package/dist/integrations/base/utils.js +13 -27
- package/dist/integrations/couchdb.js +8 -8
- package/dist/integrations/dynamodb.js +21 -21
- package/dist/integrations/elasticsearch.js +12 -12
- package/dist/integrations/firebase.js +12 -12
- package/dist/integrations/googlesheets.js +14 -14
- package/dist/integrations/index.js +34 -34
- package/dist/integrations/microsoftSqlServer.js +19 -16
- package/dist/integrations/mongodb.js +44 -17
- package/dist/integrations/mysql.js +15 -15
- package/dist/integrations/oracle.js +13 -13
- package/dist/integrations/postgres.js +20 -17
- package/dist/integrations/redis.js +10 -10
- package/dist/integrations/rest.js +15 -14
- package/dist/integrations/s3.js +2 -2
- package/dist/integrations/snowflake.js +5 -5
- package/dist/integrations/utils.js +14 -14
- package/dist/middleware/builder.js +2 -2
- package/dist/migrations/functions/appUrls.js +2 -2
- package/dist/migrations/functions/backfill/app/queries.js +3 -1
- package/dist/migrations/functions/backfill/app.js +1 -1
- package/dist/migrations/functions/backfill/global/users.js +1 -1
- package/dist/package.json +7 -7
- package/dist/tests/utilities/TestConfiguration.js +2 -2
- package/dist/threads/automation.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/routing/index.js +2 -2
- package/dist/utilities/security.js +8 -8
- package/package.json +8 -8
- package/src/api/controllers/analytics.ts +2 -2
- package/src/api/controllers/application.ts +9 -9
- package/src/api/controllers/automation.js +2 -2
- package/src/api/controllers/backup.js +2 -2
- package/src/api/controllers/cloud.js +3 -3
- package/src/api/controllers/component.js +2 -2
- package/src/api/controllers/datasource.js +2 -2
- package/src/api/controllers/deploy/index.ts +7 -7
- package/src/api/controllers/dev.js +3 -3
- package/src/api/controllers/integration.js +2 -2
- package/src/api/controllers/public/utils.ts +2 -2
- package/src/api/controllers/query/import/sources/openapi2.ts +1 -1
- package/src/api/controllers/query/import/sources/openapi3.ts +1 -1
- package/src/api/controllers/row/ExternalRequest.ts +5 -7
- package/src/api/controllers/row/internal.js +2 -2
- package/src/api/controllers/row/internalSearch.js +6 -0
- package/src/api/controllers/row/utils.js +4 -1
- package/src/api/controllers/static/index.ts +2 -2
- package/src/api/controllers/table/external.js +1 -1
- package/src/api/controllers/view/index.js +2 -2
- package/src/api/controllers/view/utils.js +4 -4
- package/src/api/routes/tests/internalSearch.spec.js +157 -0
- package/src/automations/logging/index.ts +3 -0
- package/src/db/linkedRows/linkUtils.js +2 -2
- package/src/db/utils.js +38 -38
- package/src/db/views/staticViews.js +4 -9
- package/src/definitions/automations.ts +2 -2
- package/src/definitions/common.ts +14 -65
- package/src/definitions/datasource.ts +5 -250
- package/src/integrations/airtable.ts +16 -16
- package/src/integrations/arangodb.ts +11 -11
- package/src/integrations/base/query.ts +16 -0
- package/src/integrations/base/sql.ts +21 -20
- package/src/integrations/base/sqlTable.ts +1 -6
- package/src/integrations/base/utils.ts +9 -19
- package/src/integrations/couchdb.ts +11 -11
- package/src/integrations/dynamodb.ts +24 -24
- package/src/integrations/elasticsearch.ts +15 -15
- package/src/integrations/firebase.ts +15 -15
- package/src/integrations/googlesheets.ts +19 -18
- package/src/integrations/index.ts +34 -34
- package/src/integrations/microsoftSqlServer.ts +22 -20
- package/src/integrations/mongodb.ts +47 -20
- package/src/integrations/mysql.ts +20 -19
- package/src/integrations/oracle.ts +16 -16
- package/src/integrations/postgres.ts +22 -21
- package/src/integrations/queries/sql.ts +1 -2
- package/src/integrations/redis.ts +10 -14
- package/src/integrations/rest.ts +22 -20
- package/src/integrations/s3.ts +2 -3
- package/src/integrations/snowflake.ts +5 -5
- package/src/integrations/tests/mongo.spec.js +218 -0
- package/src/integrations/tests/sql.spec.js +8 -8
- package/src/integrations/utils.ts +8 -9
- package/src/middleware/builder.js +2 -2
- package/src/migrations/functions/appUrls.ts +2 -2
- package/src/migrations/functions/backfill/app/queries.ts +3 -2
- package/src/migrations/functions/backfill/app.ts +1 -1
- package/src/migrations/functions/backfill/global/users.ts +1 -1
- package/src/migrations/functions/tests/appUrls.spec.js +3 -3
- package/src/migrations/tests/index.spec.ts +2 -2
- package/src/tests/utilities/TestConfiguration.js +2 -2
- package/src/threads/automation.ts +3 -3
- package/src/utilities/routing/index.js +2 -2
- package/src/utilities/security.js +8 -8
- package/builder/assets/index.3ce7fa08.js +0 -975
- package/dist/integrations/base/IntegrationBase.js +0 -2
- package/dist/integrations/base/datasourcePlus.js +0 -2
- package/src/integrations/base/IntegrationBase.ts +0 -6
- package/src/integrations/base/datasourcePlus.ts +0 -13
|
@@ -13,10 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const knex_1 = require("knex");
|
|
16
|
-
const
|
|
16
|
+
const types_1 = require("@budibase/types");
|
|
17
17
|
const utils_1 = require("../utils");
|
|
18
18
|
const sqlTable_1 = __importDefault(require("./sqlTable"));
|
|
19
19
|
const environment_1 = __importDefault(require("../../environment"));
|
|
20
|
+
const utils_2 = require("./utils");
|
|
20
21
|
const envLimit = environment_1.default.SQL_MAX_ROWS
|
|
21
22
|
? parseInt(environment_1.default.SQL_MAX_ROWS)
|
|
22
23
|
: null;
|
|
@@ -30,14 +31,14 @@ function likeKey(client, key) {
|
|
|
30
31
|
}
|
|
31
32
|
let start, end;
|
|
32
33
|
switch (client) {
|
|
33
|
-
case utils_1.
|
|
34
|
+
case utils_1.SqlClient.MY_SQL:
|
|
34
35
|
start = end = "`";
|
|
35
36
|
break;
|
|
36
|
-
case utils_1.
|
|
37
|
-
case utils_1.
|
|
37
|
+
case utils_1.SqlClient.ORACLE:
|
|
38
|
+
case utils_1.SqlClient.POSTGRES:
|
|
38
39
|
start = end = '"';
|
|
39
40
|
break;
|
|
40
|
-
case utils_1.
|
|
41
|
+
case utils_1.SqlClient.MS_SQL:
|
|
41
42
|
start = "[";
|
|
42
43
|
end = "]";
|
|
43
44
|
break;
|
|
@@ -99,7 +100,7 @@ function generateSelectStatement(json, knex) {
|
|
|
99
100
|
const columnName = fieldNames[1];
|
|
100
101
|
if (columnName &&
|
|
101
102
|
(schema === null || schema === void 0 ? void 0 : schema[columnName]) &&
|
|
102
|
-
knex.client.config.client === utils_1.
|
|
103
|
+
knex.client.config.client === utils_1.SqlClient.POSTGRES) {
|
|
103
104
|
const externalType = schema[columnName].externalType;
|
|
104
105
|
if (externalType === null || externalType === void 0 ? void 0 : externalType.includes("money")) {
|
|
105
106
|
return knex.raw(`"${tableName}"."${columnName}"::money::numeric as "${field}"`);
|
|
@@ -116,19 +117,20 @@ class InternalBuilder {
|
|
|
116
117
|
addFilters(query, filters, opts) {
|
|
117
118
|
function iterate(structure, fn) {
|
|
118
119
|
for (let [key, value] of Object.entries(structure)) {
|
|
119
|
-
const
|
|
120
|
+
const updatedKey = (0, utils_2.removeKeyNumbering)(key);
|
|
121
|
+
const isRelationshipField = updatedKey.includes(".");
|
|
120
122
|
if (!opts.relationship && !isRelationshipField) {
|
|
121
|
-
fn(`${opts.tableName}.${
|
|
123
|
+
fn(`${opts.tableName}.${updatedKey}`, value);
|
|
122
124
|
}
|
|
123
125
|
if (opts.relationship && isRelationshipField) {
|
|
124
|
-
fn(
|
|
126
|
+
fn(updatedKey, value);
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
const like = (key, value) => {
|
|
129
131
|
const fnc = allOr ? "orWhere" : "where";
|
|
130
132
|
// postgres supports ilike, nothing else does
|
|
131
|
-
if (this.client === utils_1.
|
|
133
|
+
if (this.client === utils_1.SqlClient.POSTGRES) {
|
|
132
134
|
query = query[fnc](key, "ilike", `%${value}%`);
|
|
133
135
|
}
|
|
134
136
|
else {
|
|
@@ -155,7 +157,7 @@ class InternalBuilder {
|
|
|
155
157
|
iterate(filters.string, (key, value) => {
|
|
156
158
|
const fnc = allOr ? "orWhere" : "where";
|
|
157
159
|
// postgres supports ilike, nothing else does
|
|
158
|
-
if (this.client === utils_1.
|
|
160
|
+
if (this.client === utils_1.SqlClient.POSTGRES) {
|
|
159
161
|
query = query[fnc](key, "ilike", `${value}%`);
|
|
160
162
|
}
|
|
161
163
|
else {
|
|
@@ -214,7 +216,7 @@ class InternalBuilder {
|
|
|
214
216
|
if (filters.contains) {
|
|
215
217
|
const fnc = allOr ? "orWhere" : "where";
|
|
216
218
|
const rawFnc = `${fnc}Raw`;
|
|
217
|
-
if (this.client === utils_1.
|
|
219
|
+
if (this.client === utils_1.SqlClient.POSTGRES) {
|
|
218
220
|
iterate(filters.contains, (key, value) => {
|
|
219
221
|
const fieldNames = key.split(/\./g);
|
|
220
222
|
const tableName = fieldNames[0];
|
|
@@ -226,7 +228,7 @@ class InternalBuilder {
|
|
|
226
228
|
query = query[rawFnc](`"${tableName}"."${columnName}"::jsonb @> '[${value}]'`);
|
|
227
229
|
});
|
|
228
230
|
}
|
|
229
|
-
else if (this.client === utils_1.
|
|
231
|
+
else if (this.client === utils_1.SqlClient.MY_SQL) {
|
|
230
232
|
iterate(filters.contains, (key, value) => {
|
|
231
233
|
if (typeof value === "string") {
|
|
232
234
|
value = `"${value}"`;
|
|
@@ -247,11 +249,11 @@ class InternalBuilder {
|
|
|
247
249
|
const table = (_a = json.meta) === null || _a === void 0 ? void 0 : _a.table;
|
|
248
250
|
if (sort) {
|
|
249
251
|
for (let [key, value] of Object.entries(sort)) {
|
|
250
|
-
const direction = value ===
|
|
252
|
+
const direction = value === types_1.SortDirection.ASCENDING ? "asc" : "desc";
|
|
251
253
|
query = query.orderBy(`${table === null || table === void 0 ? void 0 : table.name}.${key}`, direction);
|
|
252
254
|
}
|
|
253
255
|
}
|
|
254
|
-
else if (this.client === utils_1.
|
|
256
|
+
else if (this.client === utils_1.SqlClient.MS_SQL && (paginate === null || paginate === void 0 ? void 0 : paginate.limit)) {
|
|
255
257
|
// @ts-ignore
|
|
256
258
|
query = query.orderBy(`${table === null || table === void 0 ? void 0 : table.name}.${table === null || table === void 0 ? void 0 : table.primary[0]}`);
|
|
257
259
|
}
|
|
@@ -391,7 +393,7 @@ class InternalBuilder {
|
|
|
391
393
|
[tableName]: query,
|
|
392
394
|
}).select(selectStatement);
|
|
393
395
|
// have to add after as well (this breaks MS-SQL)
|
|
394
|
-
if (this.client !== utils_1.
|
|
396
|
+
if (this.client !== utils_1.SqlClient.MS_SQL) {
|
|
395
397
|
preQuery = this.addSorting(preQuery, json);
|
|
396
398
|
}
|
|
397
399
|
// handle joins
|
|
@@ -448,24 +450,24 @@ class SqlQueryBuilder extends sqlTable_1.default {
|
|
|
448
450
|
let query;
|
|
449
451
|
const builder = new InternalBuilder(sqlClient);
|
|
450
452
|
switch (this._operation(json)) {
|
|
451
|
-
case
|
|
453
|
+
case types_1.Operation.CREATE:
|
|
452
454
|
query = builder.create(client, json, opts);
|
|
453
455
|
break;
|
|
454
|
-
case
|
|
456
|
+
case types_1.Operation.READ:
|
|
455
457
|
query = builder.read(client, json, this.limit);
|
|
456
458
|
break;
|
|
457
|
-
case
|
|
459
|
+
case types_1.Operation.UPDATE:
|
|
458
460
|
query = builder.update(client, json, opts);
|
|
459
461
|
break;
|
|
460
|
-
case
|
|
462
|
+
case types_1.Operation.DELETE:
|
|
461
463
|
query = builder.delete(client, json, opts);
|
|
462
464
|
break;
|
|
463
|
-
case
|
|
465
|
+
case types_1.Operation.BULK_CREATE:
|
|
464
466
|
query = builder.bulkCreate(client, json);
|
|
465
467
|
break;
|
|
466
|
-
case
|
|
467
|
-
case
|
|
468
|
-
case
|
|
468
|
+
case types_1.Operation.CREATE_TABLE:
|
|
469
|
+
case types_1.Operation.UPDATE_TABLE:
|
|
470
|
+
case types_1.Operation.DELETE_TABLE:
|
|
469
471
|
return this._tableQuery(json);
|
|
470
472
|
default:
|
|
471
473
|
throw `Operation type is not supported by SQL query builder`;
|
|
@@ -479,7 +481,7 @@ class SqlQueryBuilder extends sqlTable_1.default {
|
|
|
479
481
|
return {};
|
|
480
482
|
}
|
|
481
483
|
const input = this._query({
|
|
482
|
-
endpoint: Object.assign(Object.assign({}, json.endpoint), { operation:
|
|
484
|
+
endpoint: Object.assign(Object.assign({}, json.endpoint), { operation: types_1.Operation.READ }),
|
|
483
485
|
resource: {
|
|
484
486
|
fields: [],
|
|
485
487
|
},
|
|
@@ -489,7 +491,7 @@ class SqlQueryBuilder extends sqlTable_1.default {
|
|
|
489
491
|
},
|
|
490
492
|
meta: json.meta,
|
|
491
493
|
});
|
|
492
|
-
return queryFn(input,
|
|
494
|
+
return queryFn(input, types_1.Operation.READ);
|
|
493
495
|
});
|
|
494
496
|
}
|
|
495
497
|
// when creating if an ID has been inserted need to make sure
|
|
@@ -524,23 +526,23 @@ class SqlQueryBuilder extends sqlTable_1.default {
|
|
|
524
526
|
}
|
|
525
527
|
let row;
|
|
526
528
|
// need to manage returning, a feature mySQL can't do
|
|
527
|
-
if (operation ===
|
|
529
|
+
if (operation === types_1.Operation.DELETE) {
|
|
528
530
|
row = processFn(yield this.getReturningRow(queryFn, json));
|
|
529
531
|
}
|
|
530
532
|
const response = yield queryFn(input, operation);
|
|
531
533
|
const results = processFn(response);
|
|
532
534
|
// same as delete, manage returning
|
|
533
|
-
if (operation ===
|
|
535
|
+
if (operation === types_1.Operation.CREATE || operation === types_1.Operation.UPDATE) {
|
|
534
536
|
let id;
|
|
535
|
-
if (sqlClient === utils_1.
|
|
537
|
+
if (sqlClient === utils_1.SqlClient.MS_SQL) {
|
|
536
538
|
id = results === null || results === void 0 ? void 0 : results[0].id;
|
|
537
539
|
}
|
|
538
|
-
else if (sqlClient === utils_1.
|
|
540
|
+
else if (sqlClient === utils_1.SqlClient.MY_SQL) {
|
|
539
541
|
id = results === null || results === void 0 ? void 0 : results.insertId;
|
|
540
542
|
}
|
|
541
543
|
row = processFn(yield this.getReturningRow(queryFn, this.checkLookupKeys(id, json)));
|
|
542
544
|
}
|
|
543
|
-
if (operation !==
|
|
545
|
+
if (operation !== types_1.Operation.READ) {
|
|
544
546
|
return row;
|
|
545
547
|
}
|
|
546
548
|
return results.length ? results : [{ [operation.toLowerCase()]: true }];
|
|
@@ -548,4 +550,3 @@ class SqlQueryBuilder extends sqlTable_1.default {
|
|
|
548
550
|
}
|
|
549
551
|
}
|
|
550
552
|
exports.default = SqlQueryBuilder;
|
|
551
|
-
module.exports = SqlQueryBuilder;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const knex_1 = require("knex");
|
|
4
|
-
const
|
|
4
|
+
const types_1 = require("@budibase/types");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const { FieldTypes, RelationshipTypes } = require("../../constants");
|
|
7
7
|
function generateSchema(schema, table, tables, oldTable = null, renamed) {
|
|
@@ -135,16 +135,16 @@ class SqlTableQueryBuilder {
|
|
|
135
135
|
throw "Cannot execute without table being specified";
|
|
136
136
|
}
|
|
137
137
|
switch (this._operation(json)) {
|
|
138
|
-
case
|
|
138
|
+
case types_1.Operation.CREATE_TABLE:
|
|
139
139
|
query = buildCreateTable(client, json.table, json.meta.tables);
|
|
140
140
|
break;
|
|
141
|
-
case
|
|
141
|
+
case types_1.Operation.UPDATE_TABLE:
|
|
142
142
|
if (!json.meta || !json.meta.table) {
|
|
143
143
|
throw "Must specify old table for update";
|
|
144
144
|
}
|
|
145
145
|
query = buildUpdateTable(client, json.table, json.meta.tables, json.meta.table, json.meta.renamed);
|
|
146
146
|
break;
|
|
147
|
-
case
|
|
147
|
+
case types_1.Operation.DELETE_TABLE:
|
|
148
148
|
query = buildDeleteTable(client, json.table);
|
|
149
149
|
break;
|
|
150
150
|
default:
|
|
@@ -1,30 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const integration = new Integration(datasource.config);
|
|
21
|
-
return integration.query(json);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
throw "Datasource does not support query.";
|
|
25
|
-
}
|
|
26
|
-
});
|
|
3
|
+
exports.removeKeyNumbering = void 0;
|
|
4
|
+
const QUERY_START_REGEX = /\d[0-9]*:/g;
|
|
5
|
+
function removeKeyNumbering(key) {
|
|
6
|
+
if (typeof key === "string" && key.match(QUERY_START_REGEX) != null) {
|
|
7
|
+
const parts = key.split(":");
|
|
8
|
+
// remove the number
|
|
9
|
+
parts.shift();
|
|
10
|
+
return parts.join(":");
|
|
27
11
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
12
|
+
else {
|
|
13
|
+
return key;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.removeKeyNumbering = removeKeyNumbering;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const types_1 = require("@budibase/types");
|
|
13
13
|
var CouchDBModule;
|
|
14
14
|
(function (CouchDBModule) {
|
|
15
15
|
const PouchDB = require("pouchdb");
|
|
@@ -20,30 +20,30 @@ var CouchDBModule;
|
|
|
20
20
|
description: "Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang.",
|
|
21
21
|
datasource: {
|
|
22
22
|
url: {
|
|
23
|
-
type:
|
|
23
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
24
24
|
required: true,
|
|
25
25
|
default: "http://localhost:5984",
|
|
26
26
|
},
|
|
27
27
|
database: {
|
|
28
|
-
type:
|
|
28
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
29
29
|
required: true,
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
query: {
|
|
33
33
|
create: {
|
|
34
|
-
type:
|
|
34
|
+
type: types_1.QueryType.JSON,
|
|
35
35
|
},
|
|
36
36
|
read: {
|
|
37
|
-
type:
|
|
37
|
+
type: types_1.QueryType.JSON,
|
|
38
38
|
},
|
|
39
39
|
update: {
|
|
40
|
-
type:
|
|
40
|
+
type: types_1.QueryType.JSON,
|
|
41
41
|
},
|
|
42
42
|
delete: {
|
|
43
|
-
type:
|
|
43
|
+
type: types_1.QueryType.FIELDS,
|
|
44
44
|
fields: {
|
|
45
45
|
id: {
|
|
46
|
-
type:
|
|
46
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
47
47
|
required: true,
|
|
48
48
|
},
|
|
49
49
|
},
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const types_1 = require("@budibase/types");
|
|
13
13
|
var DynamoModule;
|
|
14
14
|
(function (DynamoModule) {
|
|
15
15
|
const AWS = require("aws-sdk");
|
|
@@ -21,101 +21,101 @@ var DynamoModule;
|
|
|
21
21
|
type: "Non-relational",
|
|
22
22
|
datasource: {
|
|
23
23
|
region: {
|
|
24
|
-
type:
|
|
24
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
25
25
|
required: true,
|
|
26
26
|
default: "us-east-1",
|
|
27
27
|
},
|
|
28
28
|
accessKeyId: {
|
|
29
|
-
type:
|
|
29
|
+
type: types_1.DatasourceFieldType.PASSWORD,
|
|
30
30
|
required: true,
|
|
31
31
|
},
|
|
32
32
|
secretAccessKey: {
|
|
33
|
-
type:
|
|
33
|
+
type: types_1.DatasourceFieldType.PASSWORD,
|
|
34
34
|
required: true,
|
|
35
35
|
},
|
|
36
36
|
endpoint: {
|
|
37
|
-
type:
|
|
37
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
38
38
|
required: false,
|
|
39
39
|
default: "https://dynamodb.us-east-1.amazonaws.com",
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
42
|
query: {
|
|
43
43
|
create: {
|
|
44
|
-
type:
|
|
44
|
+
type: types_1.QueryType.FIELDS,
|
|
45
45
|
customisable: true,
|
|
46
46
|
fields: {
|
|
47
47
|
table: {
|
|
48
|
-
type:
|
|
48
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
49
49
|
required: true,
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
53
|
read: {
|
|
54
|
-
type:
|
|
54
|
+
type: types_1.QueryType.FIELDS,
|
|
55
55
|
customisable: true,
|
|
56
56
|
readable: true,
|
|
57
57
|
fields: {
|
|
58
58
|
table: {
|
|
59
|
-
type:
|
|
59
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
60
60
|
required: true,
|
|
61
61
|
},
|
|
62
62
|
index: {
|
|
63
|
-
type:
|
|
63
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
67
|
scan: {
|
|
68
|
-
type:
|
|
68
|
+
type: types_1.QueryType.FIELDS,
|
|
69
69
|
customisable: true,
|
|
70
70
|
readable: true,
|
|
71
71
|
fields: {
|
|
72
72
|
table: {
|
|
73
|
-
type:
|
|
73
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
74
74
|
required: true,
|
|
75
75
|
},
|
|
76
76
|
index: {
|
|
77
|
-
type:
|
|
77
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
78
78
|
},
|
|
79
79
|
},
|
|
80
80
|
},
|
|
81
81
|
describe: {
|
|
82
|
-
type:
|
|
82
|
+
type: types_1.QueryType.FIELDS,
|
|
83
83
|
customisable: true,
|
|
84
84
|
readable: true,
|
|
85
85
|
fields: {
|
|
86
86
|
table: {
|
|
87
|
-
type:
|
|
87
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
88
88
|
required: true,
|
|
89
89
|
},
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
92
|
get: {
|
|
93
|
-
type:
|
|
93
|
+
type: types_1.QueryType.FIELDS,
|
|
94
94
|
customisable: true,
|
|
95
95
|
readable: true,
|
|
96
96
|
fields: {
|
|
97
97
|
table: {
|
|
98
|
-
type:
|
|
98
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
99
99
|
required: true,
|
|
100
100
|
},
|
|
101
101
|
},
|
|
102
102
|
},
|
|
103
103
|
update: {
|
|
104
|
-
type:
|
|
104
|
+
type: types_1.QueryType.FIELDS,
|
|
105
105
|
customisable: true,
|
|
106
106
|
fields: {
|
|
107
107
|
table: {
|
|
108
|
-
type:
|
|
108
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
109
109
|
required: true,
|
|
110
110
|
},
|
|
111
111
|
},
|
|
112
112
|
},
|
|
113
113
|
delete: {
|
|
114
|
-
type:
|
|
114
|
+
type: types_1.QueryType.FIELDS,
|
|
115
115
|
customisable: true,
|
|
116
116
|
fields: {
|
|
117
117
|
table: {
|
|
118
|
-
type:
|
|
118
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
119
119
|
required: true,
|
|
120
120
|
},
|
|
121
121
|
},
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const types_1 = require("@budibase/types");
|
|
13
13
|
var ElasticsearchModule;
|
|
14
14
|
(function (ElasticsearchModule) {
|
|
15
15
|
const { Client } = require("@elastic/elasticsearch");
|
|
@@ -20,55 +20,55 @@ var ElasticsearchModule;
|
|
|
20
20
|
type: "Non-relational",
|
|
21
21
|
datasource: {
|
|
22
22
|
url: {
|
|
23
|
-
type:
|
|
23
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
24
24
|
required: true,
|
|
25
25
|
default: "http://localhost:9200",
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
28
|
query: {
|
|
29
29
|
create: {
|
|
30
|
-
type:
|
|
30
|
+
type: types_1.QueryType.FIELDS,
|
|
31
31
|
customisable: true,
|
|
32
32
|
fields: {
|
|
33
33
|
index: {
|
|
34
|
-
type:
|
|
34
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
35
35
|
required: true,
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
39
|
read: {
|
|
40
|
-
type:
|
|
40
|
+
type: types_1.QueryType.FIELDS,
|
|
41
41
|
customisable: true,
|
|
42
42
|
fields: {
|
|
43
43
|
index: {
|
|
44
|
-
type:
|
|
44
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
45
45
|
required: true,
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
49
|
update: {
|
|
50
|
-
type:
|
|
50
|
+
type: types_1.QueryType.FIELDS,
|
|
51
51
|
customisable: true,
|
|
52
52
|
fields: {
|
|
53
53
|
id: {
|
|
54
|
-
type:
|
|
54
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
55
55
|
required: true,
|
|
56
56
|
},
|
|
57
57
|
index: {
|
|
58
|
-
type:
|
|
58
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
59
59
|
required: true,
|
|
60
60
|
},
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
delete: {
|
|
64
|
-
type:
|
|
64
|
+
type: types_1.QueryType.FIELDS,
|
|
65
65
|
fields: {
|
|
66
66
|
index: {
|
|
67
|
-
type:
|
|
67
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
68
68
|
required: true,
|
|
69
69
|
},
|
|
70
70
|
id: {
|
|
71
|
-
type:
|
|
71
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
72
72
|
required: true,
|
|
73
73
|
},
|
|
74
74
|
},
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const types_1 = require("@budibase/types");
|
|
13
13
|
const firestore_1 = require("@google-cloud/firestore");
|
|
14
14
|
var Firebase;
|
|
15
15
|
(function (Firebase) {
|
|
@@ -20,46 +20,46 @@ var Firebase;
|
|
|
20
20
|
description: "Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud.",
|
|
21
21
|
datasource: {
|
|
22
22
|
email: {
|
|
23
|
-
type:
|
|
23
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
24
24
|
required: true,
|
|
25
25
|
},
|
|
26
26
|
privateKey: {
|
|
27
|
-
type:
|
|
27
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
28
28
|
required: true,
|
|
29
29
|
},
|
|
30
30
|
projectId: {
|
|
31
|
-
type:
|
|
31
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
32
32
|
required: true,
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
query: {
|
|
36
36
|
create: {
|
|
37
|
-
type:
|
|
37
|
+
type: types_1.QueryType.JSON,
|
|
38
38
|
},
|
|
39
39
|
read: {
|
|
40
|
-
type:
|
|
40
|
+
type: types_1.QueryType.JSON,
|
|
41
41
|
},
|
|
42
42
|
update: {
|
|
43
|
-
type:
|
|
43
|
+
type: types_1.QueryType.JSON,
|
|
44
44
|
},
|
|
45
45
|
delete: {
|
|
46
|
-
type:
|
|
46
|
+
type: types_1.QueryType.JSON,
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
49
|
extra: {
|
|
50
50
|
collection: {
|
|
51
51
|
displayName: "Collection",
|
|
52
|
-
type:
|
|
52
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
53
53
|
required: true,
|
|
54
54
|
},
|
|
55
55
|
filterField: {
|
|
56
56
|
displayName: "Filter field",
|
|
57
|
-
type:
|
|
57
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
58
58
|
required: false,
|
|
59
59
|
},
|
|
60
60
|
filter: {
|
|
61
61
|
displayName: "Filter comparison",
|
|
62
|
-
type:
|
|
62
|
+
type: types_1.DatasourceFieldType.LIST,
|
|
63
63
|
required: false,
|
|
64
64
|
data: {
|
|
65
65
|
read: [
|
|
@@ -78,7 +78,7 @@ var Firebase;
|
|
|
78
78
|
},
|
|
79
79
|
filterValue: {
|
|
80
80
|
displayName: "Filter value",
|
|
81
|
-
type:
|
|
81
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
82
82
|
required: false,
|
|
83
83
|
},
|
|
84
84
|
},
|