@budibase/server 1.0.79-alpha.7 → 1.0.79
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__/mysql2/promise.ts +17 -0
- package/__mocks__/node-fetch.ts +0 -1
- package/builder/assets/{index.c57242d4.css → index.c8d1e8f0.css} +2 -2
- package/builder/assets/index.f28c5d54.js +1352 -0
- package/builder/assets/{vendor.6b00a24f.js → vendor.20f80cec.js} +216 -190
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2229 -2277
- package/coverage/coverage-final.json +136 -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 +149 -152
- 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 +82 -94
- 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 +44 -47
- 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 +27 -18
- package/coverage/lcov-report/api/index.html +10 -10
- package/coverage/lcov-report/api/index.js.html +28 -37
- 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 +109 -19
- 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 +156 -18
- 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 +32 -38
- 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 +58 -16
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +78 -15
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +14 -17
- package/coverage/lcov-report/api/routes/screen.js.html +95 -14
- 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 +62 -17
- 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/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +62 -14
- 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 +9 -12
- 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 +28 -40
- 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 +87 -123
- 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 +64 -79
- 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 +1 -1
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +1 -1
- 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 +53 -200
- package/coverage/lcov.info +3039 -3115
- package/dist/api/controllers/application.js +0 -1
- package/dist/api/controllers/row/internal.js +1 -4
- package/dist/api/controllers/table/index.js +1 -2
- package/dist/api/controllers/webhook.js +5 -3
- package/dist/api/index.js +1 -3
- package/dist/api/routes/automation.js +31 -3
- package/dist/api/routes/datasource.js +50 -3
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/permission.js +14 -4
- package/dist/api/routes/role.js +19 -3
- package/dist/api/routes/row.js +4 -3
- package/dist/api/routes/screen.js +23 -2
- package/dist/api/routes/table.js +17 -3
- package/dist/api/routes/tests/utilities/index.js +0 -23
- package/dist/api/routes/webhook.js +17 -2
- 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 +0 -3
- package/dist/db/utils.js +0 -11
- package/dist/integrations/mysql.js +81 -65
- package/dist/integrations/utils.js +1 -1
- package/dist/package.json +4 -8
- package/dist/tests/utilities/TestConfiguration.js +8 -25
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +15 -50
- package/package.json +5 -9
- package/scripts/integrations/postgres/init.sql +3 -5
- package/scripts/likeCypress.ts +6 -9
- package/src/api/controllers/application.js +0 -1
- package/src/api/controllers/row/internal.js +0 -4
- package/src/api/controllers/table/index.js +1 -2
- package/src/api/controllers/webhook.js +6 -3
- package/src/api/index.js +1 -4
- package/src/api/routes/automation.js +33 -3
- package/src/api/routes/datasource.js +52 -6
- package/src/api/routes/index.js +0 -2
- package/src/api/routes/permission.js +18 -4
- package/src/api/routes/role.js +24 -3
- package/src/api/routes/row.js +2 -3
- package/src/api/routes/screen.js +29 -2
- package/src/api/routes/table.js +19 -4
- package/src/api/routes/tests/utilities/index.js +0 -24
- package/src/api/routes/webhook.js +18 -2
- package/src/automations/steps/filter.js +2 -3
- package/src/automations/steps/queryRows.js +1 -1
- package/src/automations/utils.js +2 -2
- package/src/constants/index.js +0 -4
- package/src/db/utils.js +0 -12
- package/src/definitions/common.ts +0 -4
- package/src/integrations/mysql.ts +92 -85
- package/src/integrations/tests/mysql.spec.js +4 -4
- package/src/integrations/utils.ts +1 -1
- package/src/tests/utilities/TestConfiguration.js +2 -23
- package/src/utilities/workerRequests.js +16 -65
- package/builder/assets/index.ef62c13b.js +0 -1288
- package/coverage/lcov-report/api/routes/utils/index.html +0 -111
- package/coverage/lcov-report/api/routes/utils/validators.js.html +0 -737
- package/dist/api/controllers/public/applications.js +0 -94
- package/dist/api/controllers/public/mapping/applications.js +0 -29
- package/dist/api/controllers/public/mapping/index.js +0 -11
- package/dist/api/controllers/public/mapping/queries.js +0 -36
- package/dist/api/controllers/public/mapping/rows.js +0 -24
- package/dist/api/controllers/public/mapping/tables.js +0 -23
- package/dist/api/controllers/public/mapping/types.js +0 -2
- package/dist/api/controllers/public/mapping/users.js +0 -29
- package/dist/api/controllers/public/queries.js +0 -38
- package/dist/api/controllers/public/rows.js +0 -97
- package/dist/api/controllers/public/tables.js +0 -75
- package/dist/api/controllers/public/users.js +0 -95
- package/dist/api/controllers/public/utils.js +0 -49
- package/dist/api/routes/public/applications.js +0 -141
- package/dist/api/routes/public/index.js +0 -68
- package/dist/api/routes/public/middleware/mapper.js +0 -94
- package/dist/api/routes/public/queries.js +0 -77
- package/dist/api/routes/public/rows.js +0 -229
- package/dist/api/routes/public/tables.js +0 -154
- package/dist/api/routes/public/users.js +0 -137
- package/dist/api/routes/public/utils/Endpoint.js +0 -36
- package/dist/api/routes/utils/validators.js +0 -200
- package/dist/definitions/openapi.js +0 -6
- package/specs/generate.js +0 -83
- package/specs/openapi.json +0 -2222
- package/specs/openapi.yaml +0 -1530
- package/specs/parameters.js +0 -59
- package/specs/resources/application.js +0 -101
- package/specs/resources/index.js +0 -24
- package/specs/resources/misc.js +0 -12
- package/specs/resources/query.js +0 -189
- package/specs/resources/row.js +0 -125
- package/specs/resources/table.js +0 -191
- package/specs/resources/user.js +0 -126
- package/specs/resources/utils/Resource.js +0 -26
- package/specs/resources/utils/index.js +0 -11
- package/specs/security.js +0 -7
- package/src/api/controllers/public/applications.ts +0 -74
- package/src/api/controllers/public/mapping/applications.ts +0 -32
- package/src/api/controllers/public/mapping/index.ts +0 -13
- package/src/api/controllers/public/mapping/queries.ts +0 -39
- package/src/api/controllers/public/mapping/rows.ts +0 -31
- package/src/api/controllers/public/mapping/tables.ts +0 -26
- package/src/api/controllers/public/mapping/types.ts +0 -13
- package/src/api/controllers/public/mapping/users.ts +0 -32
- package/src/api/controllers/public/queries.ts +0 -20
- package/src/api/controllers/public/rows.ts +0 -77
- package/src/api/controllers/public/tables.ts +0 -56
- package/src/api/controllers/public/users.ts +0 -82
- package/src/api/controllers/public/utils.ts +0 -38
- package/src/api/routes/public/applications.ts +0 -156
- package/src/api/routes/public/index.ts +0 -82
- package/src/api/routes/public/middleware/mapper.ts +0 -81
- package/src/api/routes/public/queries.ts +0 -81
- package/src/api/routes/public/rows.ts +0 -242
- package/src/api/routes/public/tables.ts +0 -169
- package/src/api/routes/public/tests/compare.spec.js +0 -184
- package/src/api/routes/public/users.ts +0 -144
- package/src/api/routes/public/utils/Endpoint.ts +0 -51
- package/src/api/routes/utils/validators.js +0 -219
- package/src/definitions/openapi.ts +0 -943
|
@@ -13,10 +13,10 @@ const datasource_1 = require("../definitions/datasource");
|
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
14
|
var MySQLModule;
|
|
15
15
|
(function (MySQLModule) {
|
|
16
|
-
const mysql = require("mysql2");
|
|
16
|
+
const mysql = require("mysql2/promise");
|
|
17
17
|
const Sql = require("./base/sql");
|
|
18
18
|
const SCHEMA = {
|
|
19
|
-
docs: "https://github.com/
|
|
19
|
+
docs: "https://github.com/sidorares/node-mysql2",
|
|
20
20
|
plus: true,
|
|
21
21
|
friendlyName: "MySQL",
|
|
22
22
|
description: "MySQL Database Service is a fully managed database service to deploy cloud-native applications. ",
|
|
@@ -65,25 +65,6 @@ var MySQLModule;
|
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
67
|
};
|
|
68
|
-
function internalQuery(client, query, connect = true) {
|
|
69
|
-
// Node MySQL is callback based, so we must wrap our call in a promise
|
|
70
|
-
return new Promise((resolve, reject) => {
|
|
71
|
-
if (connect) {
|
|
72
|
-
client.connect();
|
|
73
|
-
}
|
|
74
|
-
return client.query(query.sql, query.bindings || {}, (error, results) => {
|
|
75
|
-
if (error) {
|
|
76
|
-
reject(error);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
resolve(results);
|
|
80
|
-
}
|
|
81
|
-
if (connect) {
|
|
82
|
-
client.end();
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
68
|
class MySQLIntegration extends Sql {
|
|
88
69
|
constructor(config) {
|
|
89
70
|
super(utils_1.SqlClients.MY_SQL);
|
|
@@ -93,49 +74,81 @@ var MySQLModule;
|
|
|
93
74
|
if (config.ssl && Object.keys(config.ssl).length === 0) {
|
|
94
75
|
delete config.ssl;
|
|
95
76
|
}
|
|
96
|
-
this.
|
|
77
|
+
this.config = config;
|
|
78
|
+
}
|
|
79
|
+
connect() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
this.client = yield mysql.createConnection(this.config);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
disconnect() {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
yield this.client.end();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
internalQuery(query, connect = true) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
try {
|
|
92
|
+
if (connect) {
|
|
93
|
+
yield this.connect();
|
|
94
|
+
}
|
|
95
|
+
// Node MySQL is callback based, so we must wrap our call in a promise
|
|
96
|
+
const response = yield this.client.query(query.sql, query.bindings || []);
|
|
97
|
+
return response[0];
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
if (connect) {
|
|
101
|
+
yield this.disconnect();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
97
105
|
}
|
|
98
106
|
buildSchema(datasourceId, entities) {
|
|
99
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
108
|
const tables = {};
|
|
101
109
|
const database = this.config.database;
|
|
102
|
-
this.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
obj[`Tables_in_${database
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
yield this.connect();
|
|
111
|
+
try {
|
|
112
|
+
// get the tables first
|
|
113
|
+
const tablesResp = yield this.internalQuery({ sql: "SHOW TABLES;" }, false);
|
|
114
|
+
const tableNames = tablesResp.map((obj) => obj[`Tables_in_${database}`] ||
|
|
115
|
+
obj[`Tables_in_${database.toLowerCase()}`]);
|
|
116
|
+
for (let tableName of tableNames) {
|
|
117
|
+
const primaryKeys = [];
|
|
118
|
+
const schema = {};
|
|
119
|
+
const descResp = yield this.internalQuery({ sql: `DESCRIBE \`${tableName}\`;` }, false);
|
|
120
|
+
for (let column of descResp) {
|
|
121
|
+
const columnName = column.Field;
|
|
122
|
+
if (column.Key === "PRI" &&
|
|
123
|
+
primaryKeys.indexOf(column.Key) === -1) {
|
|
124
|
+
primaryKeys.push(columnName);
|
|
125
|
+
}
|
|
126
|
+
const constraints = {
|
|
127
|
+
presence: column.Null !== "YES",
|
|
128
|
+
};
|
|
129
|
+
const isAuto = typeof column.Extra === "string" &&
|
|
130
|
+
(column.Extra === "auto_increment" ||
|
|
131
|
+
column.Extra.toLowerCase().includes("generated"));
|
|
132
|
+
schema[columnName] = {
|
|
133
|
+
name: columnName,
|
|
134
|
+
autocolumn: isAuto,
|
|
135
|
+
type: utils_1.convertSqlType(column.Type),
|
|
136
|
+
constraints,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
if (!tables[tableName]) {
|
|
140
|
+
tables[tableName] = {
|
|
141
|
+
_id: utils_1.buildExternalTableId(datasourceId, tableName),
|
|
142
|
+
primary: primaryKeys,
|
|
143
|
+
name: tableName,
|
|
144
|
+
schema,
|
|
145
|
+
};
|
|
115
146
|
}
|
|
116
|
-
const constraints = {
|
|
117
|
-
presence: column.Null !== "YES",
|
|
118
|
-
};
|
|
119
|
-
const isAuto = typeof column.Extra === "string" &&
|
|
120
|
-
(column.Extra === "auto_increment" ||
|
|
121
|
-
column.Extra.toLowerCase().includes("generated"));
|
|
122
|
-
schema[columnName] = {
|
|
123
|
-
name: columnName,
|
|
124
|
-
autocolumn: isAuto,
|
|
125
|
-
type: utils_1.convertSqlType(column.Type),
|
|
126
|
-
constraints,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
if (!tables[tableName]) {
|
|
130
|
-
tables[tableName] = {
|
|
131
|
-
_id: utils_1.buildExternalTableId(datasourceId, tableName),
|
|
132
|
-
primary: primaryKeys,
|
|
133
|
-
name: tableName,
|
|
134
|
-
schema,
|
|
135
|
-
};
|
|
136
147
|
}
|
|
137
148
|
}
|
|
138
|
-
|
|
149
|
+
finally {
|
|
150
|
+
yield this.disconnect();
|
|
151
|
+
}
|
|
139
152
|
const final = utils_1.finaliseExternalTables(tables, entities);
|
|
140
153
|
this.tables = final.tables;
|
|
141
154
|
this.schemaErrors = final.errors;
|
|
@@ -143,34 +156,37 @@ var MySQLModule;
|
|
|
143
156
|
}
|
|
144
157
|
create(query) {
|
|
145
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
const results = yield internalQuery(
|
|
159
|
+
const results = yield this.internalQuery(utils_1.getSqlQuery(query));
|
|
147
160
|
return results.length ? results : [{ created: true }];
|
|
148
161
|
});
|
|
149
162
|
}
|
|
150
163
|
read(query) {
|
|
151
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
return internalQuery(
|
|
165
|
+
return this.internalQuery(utils_1.getSqlQuery(query));
|
|
153
166
|
});
|
|
154
167
|
}
|
|
155
168
|
update(query) {
|
|
156
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
const results = yield internalQuery(
|
|
170
|
+
const results = yield this.internalQuery(utils_1.getSqlQuery(query));
|
|
158
171
|
return results.length ? results : [{ updated: true }];
|
|
159
172
|
});
|
|
160
173
|
}
|
|
161
174
|
delete(query) {
|
|
162
175
|
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
const results = yield internalQuery(
|
|
176
|
+
const results = yield this.internalQuery(utils_1.getSqlQuery(query));
|
|
164
177
|
return results.length ? results : [{ deleted: true }];
|
|
165
178
|
});
|
|
166
179
|
}
|
|
167
180
|
query(json) {
|
|
168
181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
-
this.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
182
|
+
yield this.connect();
|
|
183
|
+
try {
|
|
184
|
+
const queryFn = (query) => this.internalQuery(query, false);
|
|
185
|
+
return yield this.queryWithReturning(json, queryFn);
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
yield this.disconnect();
|
|
189
|
+
}
|
|
174
190
|
});
|
|
175
191
|
}
|
|
176
192
|
}
|
|
@@ -40,7 +40,7 @@ var SqlClients;
|
|
|
40
40
|
(function (SqlClients) {
|
|
41
41
|
SqlClients["MS_SQL"] = "mssql";
|
|
42
42
|
SqlClients["POSTGRES"] = "pg";
|
|
43
|
-
SqlClients["MY_SQL"] = "
|
|
43
|
+
SqlClients["MY_SQL"] = "mysql2";
|
|
44
44
|
SqlClients["ORACLE"] = "oracledb";
|
|
45
45
|
})(SqlClients = exports.SqlClients || (exports.SqlClients = {}));
|
|
46
46
|
function isExternalTable(tableId) {
|
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.78",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"generate:proxy:preprod": "node scripts/proxy/generateProxyConfig preprod",
|
|
26
26
|
"generate:proxy:prod": "node scripts/proxy/generateProxyConfig prod",
|
|
27
27
|
"format": "prettier --config ../../.prettierrc.json 'src/**/*.ts' --write",
|
|
28
|
-
"specs": "node specs/generate.js && openapi-typescript specs/openapi.yaml --output src/definitions/openapi.ts",
|
|
29
28
|
"lint": "eslint --fix src/",
|
|
30
29
|
"lint:fix": "yarn run format && yarn run lint",
|
|
31
30
|
"initialise": "node scripts/initialise.js",
|
|
@@ -74,9 +73,9 @@
|
|
|
74
73
|
"license": "GPL-3.0",
|
|
75
74
|
"dependencies": {
|
|
76
75
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
77
|
-
"@budibase/backend-core": "^1.0.
|
|
78
|
-
"@budibase/client": "^1.0.
|
|
79
|
-
"@budibase/string-templates": "^1.0.
|
|
76
|
+
"@budibase/backend-core": "^1.0.78",
|
|
77
|
+
"@budibase/client": "^1.0.78",
|
|
78
|
+
"@budibase/string-templates": "^1.0.78",
|
|
80
79
|
"@bull-board/api": "^3.7.0",
|
|
81
80
|
"@bull-board/koa": "^3.7.0",
|
|
82
81
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -158,15 +157,12 @@
|
|
|
158
157
|
"docker-compose": "^0.23.6",
|
|
159
158
|
"eslint": "^6.8.0",
|
|
160
159
|
"jest": "^27.0.5",
|
|
161
|
-
"jest-openapi": "^0.14.2",
|
|
162
160
|
"nodemon": "^2.0.4",
|
|
163
161
|
"openapi-types": "^9.3.1",
|
|
164
|
-
"openapi-typescript": "^5.2.0",
|
|
165
162
|
"path-to-regexp": "^6.2.0",
|
|
166
163
|
"prettier": "^2.3.1",
|
|
167
164
|
"rimraf": "^3.0.2",
|
|
168
165
|
"supertest": "^4.0.2",
|
|
169
|
-
"swagger-jsdoc": "^6.1.0",
|
|
170
166
|
"ts-jest": "^27.0.3",
|
|
171
167
|
"ts-node": "^10.0.0",
|
|
172
168
|
"typescript": "^4.3.5",
|
|
@@ -24,8 +24,6 @@ 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");
|
|
29
27
|
const GLOBAL_USER_ID = "us_uuid1";
|
|
30
28
|
const EMAIL = "babs@babs.com";
|
|
31
29
|
const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306";
|
|
@@ -44,9 +42,6 @@ class TestConfiguration {
|
|
|
44
42
|
getRequest() {
|
|
45
43
|
return this.request;
|
|
46
44
|
}
|
|
47
|
-
getApp() {
|
|
48
|
-
return this.app;
|
|
49
|
-
}
|
|
50
45
|
getAppId() {
|
|
51
46
|
return this.appId;
|
|
52
47
|
}
|
|
@@ -85,22 +80,6 @@ class TestConfiguration {
|
|
|
85
80
|
}
|
|
86
81
|
});
|
|
87
82
|
}
|
|
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
|
-
}
|
|
104
83
|
globalUser({ id = GLOBAL_USER_ID, builder = true, email = EMAIL, roles, } = {}) {
|
|
105
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
85
|
const db = getGlobalDB(TENANT_ID);
|
|
@@ -143,7 +122,7 @@ class TestConfiguration {
|
|
|
143
122
|
}
|
|
144
123
|
cleanup(this.allApps.map(app => app.appId));
|
|
145
124
|
}
|
|
146
|
-
defaultHeaders(
|
|
125
|
+
defaultHeaders() {
|
|
147
126
|
const auth = {
|
|
148
127
|
userId: GLOBAL_USER_ID,
|
|
149
128
|
sessionId: "sessionid",
|
|
@@ -155,10 +134,14 @@ class TestConfiguration {
|
|
|
155
134
|
};
|
|
156
135
|
const authToken = jwt.sign(auth, env.JWT_SECRET);
|
|
157
136
|
const appToken = jwt.sign(app, env.JWT_SECRET);
|
|
158
|
-
const headers =
|
|
137
|
+
const headers = {
|
|
138
|
+
Accept: "application/json",
|
|
139
|
+
Cookie: [
|
|
159
140
|
`${Cookies.Auth}=${authToken}`,
|
|
160
141
|
`${Cookies.CurrentApp}=${appToken}`,
|
|
161
|
-
],
|
|
142
|
+
],
|
|
143
|
+
[Headers.CSRF_TOKEN]: CSRF_TOKEN,
|
|
144
|
+
};
|
|
162
145
|
if (this.appId) {
|
|
163
146
|
headers[Headers.APP_ID] = this.appId;
|
|
164
147
|
}
|
|
@@ -221,7 +204,7 @@ class TestConfiguration {
|
|
|
221
204
|
getTable(tableId = null) {
|
|
222
205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
223
206
|
tableId = tableId || this.table._id;
|
|
224
|
-
return this._req(null, { tableId }, controllers.table.find);
|
|
207
|
+
return this._req(null, { id: tableId }, controllers.table.find);
|
|
225
208
|
});
|
|
226
209
|
}
|
|
227
210
|
createLinkedTable(relationshipType = null, links = ["link"]) {
|