@budibase/server 1.3.21 → 1.3.22-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 +1 -1
- package/builder/assets/index.96c69636.js +1008 -0
- package/builder/assets/index.c167b5c3.css +6 -0
- package/builder/index.html +2 -4
- package/coverage/clover.xml +308 -338
- package/coverage/coverage-final.json +19 -21
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +41 -8
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +73 -34
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +27 -57
- package/coverage/lcov-report/api/controllers/integration.js.html +6 -6
- 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 +2 -2
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +13 -13
- 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 +2 -2
- 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 +9 -9
- package/coverage/lcov-report/api/routes/utils/validators.js.html +75 -12
- 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 +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +14 -14
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +30 -18
- package/coverage/lcov-report/events/AutomationEmitter.js.html +3 -3
- 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 +44 -44
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +12 -12
- package/coverage/lcov-report/middleware/currentapp.js.html +46 -40
- package/coverage/lcov-report/middleware/index.html +15 -15
- 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 +7 -7
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -3
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- 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 +15 -15
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +32 -8
- package/coverage/lcov.info +521 -558
- package/dist/api/controllers/application.js +5 -5
- package/dist/api/controllers/auth.js +9 -0
- package/dist/api/controllers/component.js +19 -6
- package/dist/api/controllers/datasource.js +21 -8
- package/dist/api/controllers/deploy/index.js +1 -8
- package/dist/api/controllers/integration.js +4 -4
- package/dist/{migrations/functions/usageQuotas/syncDevelopers.js → api/controllers/plugin/file.js} +13 -13
- package/dist/api/controllers/plugin/github.js +69 -0
- package/dist/api/controllers/plugin/index.js +144 -0
- package/dist/api/controllers/plugin/npm.js +58 -0
- package/dist/api/controllers/plugin/uploaders.js +11 -0
- package/dist/{migrations/functions/usageQuotas/syncPublishedApps.js → api/controllers/plugin/url.js} +13 -15
- package/dist/api/controllers/plugin/utils.js +26 -0
- package/dist/api/controllers/row/external.js +1 -1
- package/dist/api/controllers/screen.js +62 -14
- package/dist/api/controllers/static/index.js +1 -0
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +10 -0
- package/dist/api/controllers/static/templates/preview.hbs +5 -1
- package/dist/api/index.js +1 -1
- package/dist/api/routes/application.js +3 -2
- package/dist/api/routes/index.js +2 -0
- package/dist/{migrations/functions/publishedAppsQuota.js → api/routes/plugin.js} +13 -21
- package/dist/api/routes/public/rows.js +1 -82
- package/dist/api/routes/public/tables.js +1 -1
- package/dist/api/routes/table.js +1 -1
- package/dist/api/routes/utils/validators.js +20 -2
- package/dist/app.js +16 -1
- package/dist/db/utils.js +3 -0
- package/dist/environment.js +1 -0
- package/dist/integrations/airtable.js +126 -129
- package/dist/integrations/arangodb.js +86 -89
- package/dist/integrations/base/query.js +2 -2
- package/dist/integrations/base/sqlTable.js +3 -1
- package/dist/integrations/couchdb.js +80 -83
- package/dist/integrations/dynamodb.js +161 -164
- package/dist/integrations/elasticsearch.js +135 -138
- package/dist/integrations/firebase.js +154 -157
- package/dist/integrations/googlesheets.js +323 -327
- package/dist/integrations/index.js +99 -51
- package/dist/integrations/microsoftSqlServer.js +240 -243
- package/dist/integrations/mongodb.js +239 -242
- package/dist/integrations/mysql.js +215 -219
- package/dist/integrations/oracle.js +318 -322
- package/dist/integrations/postgres.js +262 -265
- package/dist/integrations/redis.js +134 -139
- package/dist/integrations/rest.js +289 -292
- package/dist/integrations/s3.js +61 -64
- package/dist/integrations/snowflake.js +83 -86
- package/dist/middleware/currentapp.js +2 -0
- package/dist/migrations/functions/backfill/global.js +0 -3
- package/dist/migrations/index.js +0 -10
- package/dist/package.json +9 -6
- package/dist/tests/utilities/TestConfiguration.js +1 -1
- package/dist/threads/query.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +105 -1
- package/dist/utilities/workerRequests.js +4 -0
- package/dist/watch.js +77 -0
- package/dist/websocket.js +22 -0
- package/package.json +10 -7
- package/scripts/dev/manage.js +4 -0
- package/scripts/localdomain.js +3 -1
- package/specs/openapi.json +115 -112
- package/specs/openapi.yaml +96 -94
- package/specs/resources/misc.js +116 -0
- package/specs/resources/query.js +1 -1
- package/src/api/controllers/application.ts +1 -2
- package/src/api/controllers/auth.js +11 -0
- package/src/api/controllers/component.ts +57 -0
- package/src/api/controllers/datasource.js +21 -8
- package/src/api/controllers/deploy/index.ts +1 -6
- package/src/api/controllers/integration.js +4 -4
- package/src/api/controllers/plugin/file.ts +15 -0
- package/src/api/controllers/plugin/github.ts +75 -0
- package/src/api/controllers/plugin/index.ts +134 -0
- package/src/api/controllers/plugin/npm.ts +56 -0
- package/src/api/controllers/plugin/uploaders.ts +4 -0
- package/src/api/controllers/plugin/url.ts +12 -0
- package/src/api/controllers/plugin/utils.ts +19 -0
- package/src/api/controllers/public/mapping/types.ts +8 -0
- package/src/api/controllers/row/external.js +1 -1
- package/src/api/controllers/screen.ts +122 -0
- package/src/api/controllers/static/index.ts +1 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +10 -0
- package/src/api/controllers/static/templates/preview.hbs +5 -1
- package/src/api/index.js +1 -1
- package/src/api/routes/application.ts +13 -2
- package/src/api/routes/index.ts +2 -0
- package/src/api/routes/plugin.ts +14 -0
- package/src/api/routes/public/rows.ts +1 -82
- package/src/api/routes/public/tables.ts +1 -1
- package/src/api/routes/table.js +1 -1
- package/src/api/routes/tests/query.spec.js +8 -25
- package/src/api/routes/tests/user.spec.js +0 -2
- package/src/api/routes/utils/validators.js +26 -5
- package/src/app.ts +25 -2
- package/src/db/utils.js +4 -0
- package/src/definitions/openapi.ts +56 -55
- package/src/environment.js +1 -0
- package/src/integrations/airtable.ts +116 -118
- package/src/integrations/arangodb.ts +87 -89
- package/src/integrations/base/query.ts +2 -2
- package/src/integrations/base/sqlTable.ts +3 -1
- package/src/integrations/couchdb.ts +83 -89
- package/src/integrations/dynamodb.ts +173 -175
- package/src/integrations/elasticsearch.ts +120 -122
- package/src/integrations/firebase.ts +157 -159
- package/src/integrations/googlesheets.ts +328 -338
- package/src/integrations/index.ts +64 -21
- package/src/integrations/microsoftSqlServer.ts +249 -251
- package/src/integrations/mongodb.ts +261 -258
- package/src/integrations/mysql.ts +229 -234
- package/src/integrations/oracle.ts +373 -380
- package/src/integrations/postgres.ts +264 -268
- package/src/integrations/redis.ts +128 -132
- package/src/integrations/rest.ts +324 -329
- package/src/integrations/s3.ts +68 -71
- package/src/integrations/snowflake.ts +80 -82
- package/src/integrations/tests/{airtable.spec.js → airtable.spec.ts} +21 -18
- package/src/integrations/tests/{arangodb.spec.js → arangodb.spec.ts} +12 -9
- package/src/integrations/tests/{couchdb.spec.js → couchdb.spec.ts} +33 -27
- package/src/integrations/tests/{dynamodb.spec.js → dynamodb.spec.ts} +45 -41
- package/src/integrations/tests/{elasticsearch.spec.js → elasticsearch.spec.ts} +22 -21
- package/src/integrations/tests/{firebase.spec.js → firebase.spec.ts} +33 -28
- package/src/integrations/tests/{microsoftSqlServer.spec.js → microsoftSqlServer.spec.ts} +12 -11
- package/src/integrations/tests/{mongo.spec.js → mongo.spec.ts} +46 -35
- package/src/integrations/tests/{mysql.spec.js → mysql.spec.ts} +17 -15
- package/src/integrations/tests/{oracle.spec.js → oracle.spec.ts} +19 -17
- package/src/integrations/tests/{postgres.spec.js → postgres.spec.ts} +19 -17
- package/src/integrations/tests/{redis.spec.js → redis.spec.ts} +27 -18
- package/src/integrations/tests/{rest.spec.js → rest.spec.ts} +22 -14
- package/src/integrations/tests/{s3.spec.js → s3.spec.ts} +10 -8
- package/src/integrations/tests/{sql.spec.js → sql.spec.ts} +228 -177
- package/src/middleware/currentapp.js +2 -0
- package/src/migrations/functions/backfill/global.ts +0 -3
- package/src/migrations/index.ts +0 -16
- package/src/module.d.ts +2 -0
- package/src/tests/utilities/TestConfiguration.js +1 -1
- package/src/threads/query.ts +2 -2
- package/src/utilities/fileSystem/index.js +123 -0
- package/src/utilities/workerRequests.js +8 -0
- package/src/watch.ts +38 -0
- package/src/websocket.ts +26 -0
- package/builder/assets/index.8d12d461.css +0 -6
- package/builder/assets/index.d354271c.js +0 -879
- package/builder/assets/vendor.5e1fe644.css +0 -1
- package/builder/assets/vendor.67dbd8fa.js +0 -248
- package/coverage/lcov-report/api/controllers/component.js.html +0 -199
- package/coverage/lcov-report/api/controllers/screen.js.html +0 -259
- package/dist/migrations/functions/developerQuota.js +0 -49
- package/src/api/controllers/component.js +0 -38
- package/src/api/controllers/screen.js +0 -58
- package/src/migrations/functions/developerQuota.ts +0 -15
- package/src/migrations/functions/publishedAppsQuota.ts +0 -13
- package/src/migrations/functions/usageQuotas/syncDevelopers.ts +0 -19
- package/src/migrations/functions/usageQuotas/syncPublishedApps.ts +0 -21
|
@@ -17,235 +17,231 @@ const utils_1 = require("./utils");
|
|
|
17
17
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
18
18
|
const { NUMBER_REGEX } = require("../utilities");
|
|
19
19
|
const sql_1 = __importDefault(require("./base/sql"));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
default: "localhost",
|
|
33
|
-
required: true,
|
|
34
|
-
},
|
|
35
|
-
port: {
|
|
36
|
-
type: types_1.DatasourceFieldType.NUMBER,
|
|
37
|
-
default: 3306,
|
|
38
|
-
required: false,
|
|
39
|
-
},
|
|
40
|
-
user: {
|
|
41
|
-
type: types_1.DatasourceFieldType.STRING,
|
|
42
|
-
default: "root",
|
|
43
|
-
required: true,
|
|
44
|
-
},
|
|
45
|
-
password: {
|
|
46
|
-
type: types_1.DatasourceFieldType.PASSWORD,
|
|
47
|
-
default: "root",
|
|
48
|
-
required: true,
|
|
49
|
-
},
|
|
50
|
-
database: {
|
|
51
|
-
type: types_1.DatasourceFieldType.STRING,
|
|
52
|
-
required: true,
|
|
53
|
-
},
|
|
54
|
-
ssl: {
|
|
55
|
-
type: types_1.DatasourceFieldType.OBJECT,
|
|
56
|
-
required: false,
|
|
57
|
-
},
|
|
58
|
-
rejectUnauthorized: {
|
|
59
|
-
type: types_1.DatasourceFieldType.BOOLEAN,
|
|
60
|
-
default: true,
|
|
61
|
-
required: false,
|
|
62
|
-
},
|
|
20
|
+
const mysql = require("mysql2/promise");
|
|
21
|
+
const SCHEMA = {
|
|
22
|
+
docs: "https://github.com/sidorares/node-mysql2",
|
|
23
|
+
plus: true,
|
|
24
|
+
friendlyName: "MySQL",
|
|
25
|
+
type: "Relational",
|
|
26
|
+
description: "MySQL Database Service is a fully managed database service to deploy cloud-native applications. ",
|
|
27
|
+
datasource: {
|
|
28
|
+
host: {
|
|
29
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
30
|
+
default: "localhost",
|
|
31
|
+
required: true,
|
|
63
32
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
read: {
|
|
69
|
-
type: types_1.QueryType.SQL,
|
|
70
|
-
},
|
|
71
|
-
update: {
|
|
72
|
-
type: types_1.QueryType.SQL,
|
|
73
|
-
},
|
|
74
|
-
delete: {
|
|
75
|
-
type: types_1.QueryType.SQL,
|
|
76
|
-
},
|
|
33
|
+
port: {
|
|
34
|
+
type: types_1.DatasourceFieldType.NUMBER,
|
|
35
|
+
default: 3306,
|
|
36
|
+
required: false,
|
|
77
37
|
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
} });
|
|
38
|
+
user: {
|
|
39
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
40
|
+
default: "root",
|
|
41
|
+
required: true,
|
|
42
|
+
},
|
|
43
|
+
password: {
|
|
44
|
+
type: types_1.DatasourceFieldType.PASSWORD,
|
|
45
|
+
default: "root",
|
|
46
|
+
required: true,
|
|
47
|
+
},
|
|
48
|
+
database: {
|
|
49
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
50
|
+
required: true,
|
|
51
|
+
},
|
|
52
|
+
ssl: {
|
|
53
|
+
type: types_1.DatasourceFieldType.OBJECT,
|
|
54
|
+
required: false,
|
|
55
|
+
},
|
|
56
|
+
rejectUnauthorized: {
|
|
57
|
+
type: types_1.DatasourceFieldType.BOOLEAN,
|
|
58
|
+
default: true,
|
|
59
|
+
required: false,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
query: {
|
|
63
|
+
create: {
|
|
64
|
+
type: types_1.QueryType.SQL,
|
|
65
|
+
},
|
|
66
|
+
read: {
|
|
67
|
+
type: types_1.QueryType.SQL,
|
|
68
|
+
},
|
|
69
|
+
update: {
|
|
70
|
+
type: types_1.QueryType.SQL,
|
|
71
|
+
},
|
|
72
|
+
delete: {
|
|
73
|
+
type: types_1.QueryType.SQL,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const TimezoneAwareDateTypes = ["timestamp"];
|
|
78
|
+
function bindingTypeCoerce(bindings) {
|
|
79
|
+
for (let i = 0; i < bindings.length; i++) {
|
|
80
|
+
const binding = bindings[i];
|
|
81
|
+
if (typeof binding !== "string") {
|
|
82
|
+
continue;
|
|
124
83
|
}
|
|
125
|
-
|
|
126
|
-
|
|
84
|
+
const matches = binding.match(NUMBER_REGEX);
|
|
85
|
+
// check if number first
|
|
86
|
+
if (matches && matches[0] !== "" && !isNaN(Number(matches[0]))) {
|
|
87
|
+
bindings[i] = parseFloat(binding);
|
|
127
88
|
}
|
|
128
|
-
|
|
129
|
-
|
|
89
|
+
// if not a number, see if it is a date - important to do in this order as any
|
|
90
|
+
// integer will be considered a valid date
|
|
91
|
+
else if (/^\d/.test(binding) && (0, dayjs_1.default)(binding).isValid()) {
|
|
92
|
+
bindings[i] = (0, dayjs_1.default)(binding).toDate();
|
|
130
93
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
94
|
+
}
|
|
95
|
+
return bindings;
|
|
96
|
+
}
|
|
97
|
+
class MySQLIntegration extends sql_1.default {
|
|
98
|
+
constructor(config) {
|
|
99
|
+
super(utils_1.SqlClient.MY_SQL);
|
|
100
|
+
this.tables = {};
|
|
101
|
+
this.schemaErrors = {};
|
|
102
|
+
this.config = config;
|
|
103
|
+
if (config.ssl && Object.keys(config.ssl).length === 0) {
|
|
104
|
+
delete config.ssl;
|
|
135
105
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
106
|
+
// make sure this defaults to true
|
|
107
|
+
if (config.rejectUnauthorized != null &&
|
|
108
|
+
!config.rejectUnauthorized &&
|
|
109
|
+
config.ssl) {
|
|
110
|
+
config.ssl.rejectUnauthorized = config.rejectUnauthorized;
|
|
140
111
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
yield this.connect();
|
|
149
|
-
}
|
|
150
|
-
const baseBindings = query.bindings || [];
|
|
151
|
-
const bindings = (opts === null || opts === void 0 ? void 0 : opts.disableCoercion)
|
|
152
|
-
? baseBindings
|
|
153
|
-
: bindingTypeCoerce(baseBindings);
|
|
154
|
-
// Node MySQL is callback based, so we must wrap our call in a promise
|
|
155
|
-
const response = yield this.client.query(query.sql, bindings);
|
|
156
|
-
return response[0];
|
|
157
|
-
}
|
|
158
|
-
finally {
|
|
159
|
-
if (opts === null || opts === void 0 ? void 0 : opts.connect) {
|
|
160
|
-
yield this.disconnect();
|
|
161
|
-
}
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
delete config.rejectUnauthorized;
|
|
114
|
+
this.config = Object.assign(Object.assign({}, config), { typeCast: function (field, next) {
|
|
115
|
+
if (field.type == "DATETIME" ||
|
|
116
|
+
field.type === "DATE" ||
|
|
117
|
+
field.type === "TIMESTAMP") {
|
|
118
|
+
return field.string();
|
|
162
119
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
column.Extra.toLowerCase().includes("generated"));
|
|
191
|
-
schema[columnName] = Object.assign(Object.assign({ name: columnName, autocolumn: isAuto, constraints }, (0, utils_1.convertSqlType)(column.Type)), { externalType: column.Type });
|
|
192
|
-
}
|
|
193
|
-
if (!tables[tableName]) {
|
|
194
|
-
tables[tableName] = {
|
|
195
|
-
_id: (0, utils_1.buildExternalTableId)(datasourceId, tableName),
|
|
196
|
-
primary: primaryKeys,
|
|
197
|
-
name: tableName,
|
|
198
|
-
schema,
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
}
|
|
120
|
+
return next();
|
|
121
|
+
} });
|
|
122
|
+
}
|
|
123
|
+
getBindingIdentifier() {
|
|
124
|
+
return "?";
|
|
125
|
+
}
|
|
126
|
+
getStringConcat(parts) {
|
|
127
|
+
return `concat(${parts.join(", ")})`;
|
|
128
|
+
}
|
|
129
|
+
connect() {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
this.client = yield mysql.createConnection(this.config);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
disconnect() {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
yield this.client.end();
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
internalQuery(query, opts = {
|
|
140
|
+
connect: true,
|
|
141
|
+
disableCoercion: false,
|
|
142
|
+
}) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
try {
|
|
145
|
+
if (opts === null || opts === void 0 ? void 0 : opts.connect) {
|
|
146
|
+
yield this.connect();
|
|
202
147
|
}
|
|
203
|
-
|
|
148
|
+
const baseBindings = query.bindings || [];
|
|
149
|
+
const bindings = (opts === null || opts === void 0 ? void 0 : opts.disableCoercion)
|
|
150
|
+
? baseBindings
|
|
151
|
+
: bindingTypeCoerce(baseBindings);
|
|
152
|
+
// Node MySQL is callback based, so we must wrap our call in a promise
|
|
153
|
+
const response = yield this.client.query(query.sql, bindings);
|
|
154
|
+
return response[0];
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
if (opts === null || opts === void 0 ? void 0 : opts.connect) {
|
|
204
158
|
yield this.disconnect();
|
|
205
159
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
buildSchema(datasourceId, entities) {
|
|
164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
const tables = {};
|
|
166
|
+
const database = this.config.database;
|
|
167
|
+
yield this.connect();
|
|
168
|
+
try {
|
|
169
|
+
// get the tables first
|
|
170
|
+
const tablesResp = yield this.internalQuery({ sql: "SHOW TABLES;" }, { connect: false });
|
|
171
|
+
const tableNames = tablesResp.map((obj) => obj[`Tables_in_${database}`] ||
|
|
172
|
+
obj[`Tables_in_${database.toLowerCase()}`]);
|
|
173
|
+
for (let tableName of tableNames) {
|
|
174
|
+
const primaryKeys = [];
|
|
175
|
+
const schema = {};
|
|
176
|
+
const descResp = yield this.internalQuery({ sql: `DESCRIBE \`${tableName}\`;` }, { connect: false });
|
|
177
|
+
for (let column of descResp) {
|
|
178
|
+
const columnName = column.Field;
|
|
179
|
+
if (column.Key === "PRI" && primaryKeys.indexOf(column.Key) === -1) {
|
|
180
|
+
primaryKeys.push(columnName);
|
|
181
|
+
}
|
|
182
|
+
const constraints = {
|
|
183
|
+
presence: column.Null !== "YES",
|
|
184
|
+
};
|
|
185
|
+
const isAuto = typeof column.Extra === "string" &&
|
|
186
|
+
(column.Extra === "auto_increment" ||
|
|
187
|
+
column.Extra.toLowerCase().includes("generated"));
|
|
188
|
+
schema[columnName] = Object.assign(Object.assign({ name: columnName, autocolumn: isAuto, constraints }, (0, utils_1.convertSqlType)(column.Type)), { externalType: column.Type });
|
|
189
|
+
}
|
|
190
|
+
if (!tables[tableName]) {
|
|
191
|
+
tables[tableName] = {
|
|
192
|
+
_id: (0, utils_1.buildExternalTableId)(datasourceId, tableName),
|
|
193
|
+
primary: primaryKeys,
|
|
194
|
+
name: tableName,
|
|
195
|
+
schema,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
243
198
|
}
|
|
244
|
-
}
|
|
245
|
-
|
|
199
|
+
}
|
|
200
|
+
finally {
|
|
201
|
+
yield this.disconnect();
|
|
202
|
+
}
|
|
203
|
+
const final = (0, utils_1.finaliseExternalTables)(tables, entities);
|
|
204
|
+
this.tables = final.tables;
|
|
205
|
+
this.schemaErrors = final.errors;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
create(query) {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
const results = yield this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
211
|
+
return results.length ? results : [{ created: true }];
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
read(query) {
|
|
215
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
return this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
217
|
+
});
|
|
246
218
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
})
|
|
219
|
+
update(query) {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
const results = yield this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
222
|
+
return results.length ? results : [{ updated: true }];
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
delete(query) {
|
|
226
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
227
|
+
const results = yield this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
228
|
+
return results.length ? results : [{ deleted: true }];
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
query(json) {
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
yield this.connect();
|
|
234
|
+
try {
|
|
235
|
+
const queryFn = (query) => this.internalQuery(query, { connect: false, disableCoercion: true });
|
|
236
|
+
return yield this.queryWithReturning(json, queryFn);
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
yield this.disconnect();
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.default = {
|
|
245
|
+
schema: SCHEMA,
|
|
246
|
+
integration: MySQLIntegration,
|
|
247
|
+
};
|