@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
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import postgres from "./postgres"
|
|
2
|
+
import dynamodb from "./dynamodb"
|
|
3
|
+
import mongodb from "./mongodb"
|
|
4
|
+
import elasticsearch from "./elasticsearch"
|
|
5
|
+
import couchdb from "./couchdb"
|
|
6
|
+
import sqlServer from "./microsoftSqlServer"
|
|
7
|
+
import s3 from "./s3"
|
|
8
|
+
import airtable from "./airtable"
|
|
9
|
+
import mysql from "./mysql"
|
|
10
|
+
import arangodb from "./arangodb"
|
|
11
|
+
import rest from "./rest"
|
|
12
|
+
import googlesheets from "./googlesheets"
|
|
13
|
+
import firebase from "./firebase"
|
|
14
|
+
import redis from "./redis"
|
|
15
|
+
import snowflake from "./snowflake"
|
|
16
|
+
import { getPlugins } from "../api/controllers/plugin"
|
|
17
|
+
import { SourceName, Integration, PluginType } from "@budibase/types"
|
|
18
|
+
import { getDatasourcePlugin } from "../utilities/fileSystem"
|
|
17
19
|
const environment = require("../environment")
|
|
20
|
+
const { cloneDeep } = require("lodash")
|
|
18
21
|
|
|
19
|
-
const DEFINITIONS = {
|
|
22
|
+
const DEFINITIONS: { [key: string]: Integration } = {
|
|
20
23
|
[SourceName.POSTGRES]: postgres.schema,
|
|
21
24
|
[SourceName.DYNAMODB]: dynamodb.schema,
|
|
22
25
|
[SourceName.MONGODB]: mongodb.schema,
|
|
@@ -33,7 +36,7 @@ const DEFINITIONS = {
|
|
|
33
36
|
[SourceName.SNOWFLAKE]: snowflake.schema,
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
const INTEGRATIONS = {
|
|
39
|
+
const INTEGRATIONS: { [key: string]: any } = {
|
|
37
40
|
[SourceName.POSTGRES]: postgres.integration,
|
|
38
41
|
[SourceName.DYNAMODB]: dynamodb.integration,
|
|
39
42
|
[SourceName.MONGODB]: mongodb.integration,
|
|
@@ -48,7 +51,7 @@ const INTEGRATIONS = {
|
|
|
48
51
|
[SourceName.FIRESTORE]: firebase.integration,
|
|
49
52
|
[SourceName.GOOGLE_SHEETS]: googlesheets.integration,
|
|
50
53
|
[SourceName.REDIS]: redis.integration,
|
|
51
|
-
[SourceName.
|
|
54
|
+
[SourceName.FIRESTORE]: firebase.integration,
|
|
52
55
|
[SourceName.SNOWFLAKE]: snowflake.integration,
|
|
53
56
|
}
|
|
54
57
|
|
|
@@ -64,6 +67,46 @@ if (environment.SELF_HOSTED) {
|
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
module.exports = {
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
getDefinitions: async () => {
|
|
71
|
+
const pluginSchemas: { [key: string]: Integration } = {}
|
|
72
|
+
if (environment.SELF_HOSTED) {
|
|
73
|
+
const plugins = await getPlugins(PluginType.DATASOURCE)
|
|
74
|
+
// extract the actual schema from each custom
|
|
75
|
+
for (let plugin of plugins) {
|
|
76
|
+
const sourceId = plugin.name
|
|
77
|
+
pluginSchemas[sourceId] = {
|
|
78
|
+
...plugin.schema["schema"],
|
|
79
|
+
custom: true,
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
...cloneDeep(DEFINITIONS),
|
|
85
|
+
...pluginSchemas,
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
getIntegration: async (integration: string) => {
|
|
89
|
+
if (INTEGRATIONS[integration]) {
|
|
90
|
+
return INTEGRATIONS[integration]
|
|
91
|
+
}
|
|
92
|
+
if (environment.SELF_HOSTED) {
|
|
93
|
+
const plugins = await getPlugins(PluginType.DATASOURCE)
|
|
94
|
+
for (let plugin of plugins) {
|
|
95
|
+
if (plugin.name === integration) {
|
|
96
|
+
// need to use commonJS require due to its dynamic runtime nature
|
|
97
|
+
const retrieved: any = await getDatasourcePlugin(
|
|
98
|
+
plugin.name,
|
|
99
|
+
plugin.jsUrl,
|
|
100
|
+
plugin.schema?.hash
|
|
101
|
+
)
|
|
102
|
+
if (retrieved.integration) {
|
|
103
|
+
return retrieved.integration
|
|
104
|
+
} else {
|
|
105
|
+
return retrieved
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
throw new Error("No datasource implementation found.")
|
|
111
|
+
},
|
|
69
112
|
}
|
|
@@ -18,292 +18,290 @@ import {
|
|
|
18
18
|
} from "./utils"
|
|
19
19
|
import Sql from "./base/sql"
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const DEFAULT_SCHEMA = "dbo"
|
|
21
|
+
const sqlServer = require("mssql")
|
|
22
|
+
const DEFAULT_SCHEMA = "dbo"
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
interface MSSQLConfig {
|
|
25
|
+
user: string
|
|
26
|
+
password: string
|
|
27
|
+
server: string
|
|
28
|
+
port: number
|
|
29
|
+
database: string
|
|
30
|
+
schema: string
|
|
31
|
+
encrypt?: boolean
|
|
32
|
+
}
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
interface TablesResponse {
|
|
35
|
+
TABLE_CATALOG: string
|
|
36
|
+
TABLE_SCHEMA: string
|
|
37
|
+
TABLE_NAME: string
|
|
38
|
+
TABLE_TYPE: string
|
|
39
|
+
}
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
password: {
|
|
56
|
-
type: DatasourceFieldType.PASSWORD,
|
|
57
|
-
required: true,
|
|
58
|
-
},
|
|
59
|
-
server: {
|
|
60
|
-
type: DatasourceFieldType.STRING,
|
|
61
|
-
default: "localhost",
|
|
62
|
-
},
|
|
63
|
-
port: {
|
|
64
|
-
type: DatasourceFieldType.NUMBER,
|
|
65
|
-
required: false,
|
|
66
|
-
default: 1433,
|
|
67
|
-
},
|
|
68
|
-
database: {
|
|
69
|
-
type: DatasourceFieldType.STRING,
|
|
70
|
-
default: "root",
|
|
71
|
-
},
|
|
72
|
-
schema: {
|
|
73
|
-
type: DatasourceFieldType.STRING,
|
|
74
|
-
default: DEFAULT_SCHEMA,
|
|
75
|
-
},
|
|
76
|
-
encrypt: {
|
|
77
|
-
type: DatasourceFieldType.BOOLEAN,
|
|
78
|
-
default: true,
|
|
79
|
-
},
|
|
41
|
+
const SCHEMA: Integration = {
|
|
42
|
+
docs: "https://github.com/tediousjs/node-mssql",
|
|
43
|
+
plus: true,
|
|
44
|
+
description:
|
|
45
|
+
"Microsoft SQL Server is a relational database management system developed by Microsoft. ",
|
|
46
|
+
friendlyName: "MS SQL Server",
|
|
47
|
+
type: "Relational",
|
|
48
|
+
datasource: {
|
|
49
|
+
user: {
|
|
50
|
+
type: DatasourceFieldType.STRING,
|
|
51
|
+
required: true,
|
|
52
|
+
default: "localhost",
|
|
80
53
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
},
|
|
85
|
-
read: {
|
|
86
|
-
type: QueryType.SQL,
|
|
87
|
-
},
|
|
88
|
-
update: {
|
|
89
|
-
type: QueryType.SQL,
|
|
90
|
-
},
|
|
91
|
-
delete: {
|
|
92
|
-
type: QueryType.SQL,
|
|
93
|
-
},
|
|
54
|
+
password: {
|
|
55
|
+
type: DatasourceFieldType.PASSWORD,
|
|
56
|
+
required: true,
|
|
94
57
|
},
|
|
95
|
-
|
|
58
|
+
server: {
|
|
59
|
+
type: DatasourceFieldType.STRING,
|
|
60
|
+
default: "localhost",
|
|
61
|
+
},
|
|
62
|
+
port: {
|
|
63
|
+
type: DatasourceFieldType.NUMBER,
|
|
64
|
+
required: false,
|
|
65
|
+
default: 1433,
|
|
66
|
+
},
|
|
67
|
+
database: {
|
|
68
|
+
type: DatasourceFieldType.STRING,
|
|
69
|
+
default: "root",
|
|
70
|
+
},
|
|
71
|
+
schema: {
|
|
72
|
+
type: DatasourceFieldType.STRING,
|
|
73
|
+
default: DEFAULT_SCHEMA,
|
|
74
|
+
},
|
|
75
|
+
encrypt: {
|
|
76
|
+
type: DatasourceFieldType.BOOLEAN,
|
|
77
|
+
default: true,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
query: {
|
|
81
|
+
create: {
|
|
82
|
+
type: QueryType.SQL,
|
|
83
|
+
},
|
|
84
|
+
read: {
|
|
85
|
+
type: QueryType.SQL,
|
|
86
|
+
},
|
|
87
|
+
update: {
|
|
88
|
+
type: QueryType.SQL,
|
|
89
|
+
},
|
|
90
|
+
delete: {
|
|
91
|
+
type: QueryType.SQL,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
}
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
class SqlServerIntegration extends Sql implements DatasourcePlus {
|
|
97
|
+
private readonly config: MSSQLConfig
|
|
98
|
+
private index: number = 0
|
|
99
|
+
private readonly pool: any
|
|
100
|
+
private client: any
|
|
101
|
+
public tables: Record<string, Table> = {}
|
|
102
|
+
public schemaErrors: Record<string, string> = {}
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
MASTER_TABLES = [
|
|
105
|
+
"spt_fallback_db",
|
|
106
|
+
"spt_fallback_dev",
|
|
107
|
+
"spt_fallback_usg",
|
|
108
|
+
"spt_monitor",
|
|
109
|
+
"MSreplication_options",
|
|
110
|
+
]
|
|
111
|
+
TABLES_SQL =
|
|
112
|
+
"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'"
|
|
114
113
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
delete clientCfg.encrypt
|
|
126
|
-
if (!this.pool) {
|
|
127
|
-
this.pool = new sqlServer.ConnectionPool(clientCfg)
|
|
128
|
-
}
|
|
114
|
+
constructor(config: MSSQLConfig) {
|
|
115
|
+
super(SqlClient.MS_SQL)
|
|
116
|
+
this.config = config
|
|
117
|
+
const clientCfg = {
|
|
118
|
+
...this.config,
|
|
119
|
+
options: {
|
|
120
|
+
encrypt: this.config.encrypt,
|
|
121
|
+
enableArithAbort: true,
|
|
122
|
+
},
|
|
129
123
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
delete clientCfg.encrypt
|
|
125
|
+
if (!this.pool) {
|
|
126
|
+
this.pool = new sqlServer.ConnectionPool(clientCfg)
|
|
133
127
|
}
|
|
128
|
+
}
|
|
134
129
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
130
|
+
getBindingIdentifier(): string {
|
|
131
|
+
return `@p${this.index++}`
|
|
132
|
+
}
|
|
138
133
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
134
|
+
getStringConcat(parts: string[]): string {
|
|
135
|
+
return `concat(${parts.join(", ")})`
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async connect() {
|
|
139
|
+
try {
|
|
140
|
+
this.client = await this.pool.connect()
|
|
141
|
+
} catch (err) {
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
throw new Error(err)
|
|
146
144
|
}
|
|
145
|
+
}
|
|
147
146
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
147
|
+
async internalQuery(
|
|
148
|
+
query: SqlQuery,
|
|
149
|
+
operation: string | undefined = undefined
|
|
150
|
+
) {
|
|
151
|
+
const client = this.client
|
|
152
|
+
const request = client.request()
|
|
153
|
+
this.index = 0
|
|
154
|
+
try {
|
|
155
|
+
if (Array.isArray(query.bindings)) {
|
|
156
|
+
let count = 0
|
|
157
|
+
for (let binding of query.bindings) {
|
|
158
|
+
request.input(`p${count++}`, binding)
|
|
161
159
|
}
|
|
162
|
-
// this is a hack to get the inserted ID back,
|
|
163
|
-
// no way to do this with Knex nicely
|
|
164
|
-
const sql =
|
|
165
|
-
operation === Operation.CREATE
|
|
166
|
-
? `${query.sql}; SELECT SCOPE_IDENTITY() AS id;`
|
|
167
|
-
: query.sql
|
|
168
|
-
return await request.query(sql)
|
|
169
|
-
} catch (err) {
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
throw new Error(err)
|
|
172
160
|
}
|
|
161
|
+
// this is a hack to get the inserted ID back,
|
|
162
|
+
// no way to do this with Knex nicely
|
|
163
|
+
const sql =
|
|
164
|
+
operation === Operation.CREATE
|
|
165
|
+
? `${query.sql}; SELECT SCOPE_IDENTITY() AS id;`
|
|
166
|
+
: query.sql
|
|
167
|
+
return await request.query(sql)
|
|
168
|
+
} catch (err) {
|
|
169
|
+
// @ts-ignore
|
|
170
|
+
throw new Error(err)
|
|
173
171
|
}
|
|
172
|
+
}
|
|
174
173
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
174
|
+
getDefinitionSQL(tableName: string) {
|
|
175
|
+
return `select *
|
|
176
|
+
from INFORMATION_SCHEMA.COLUMNS
|
|
177
|
+
where TABLE_NAME='${tableName}'`
|
|
178
|
+
}
|
|
180
179
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
180
|
+
getConstraintsSQL(tableName: string) {
|
|
181
|
+
return `SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC
|
|
182
|
+
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KU
|
|
183
|
+
ON TC.CONSTRAINT_TYPE = 'PRIMARY KEY'
|
|
184
|
+
AND TC.CONSTRAINT_NAME = KU.CONSTRAINT_NAME
|
|
185
|
+
AND KU.table_name='${tableName}'
|
|
186
|
+
ORDER BY
|
|
187
|
+
KU.TABLE_NAME,
|
|
188
|
+
KU.ORDINAL_POSITION;`
|
|
189
|
+
}
|
|
191
190
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
191
|
+
getAutoColumnsSQL(tableName: string) {
|
|
192
|
+
return `SELECT
|
|
193
|
+
COLUMNPROPERTY(OBJECT_ID(TABLE_SCHEMA+'.'+TABLE_NAME),COLUMN_NAME,'IsComputed')
|
|
194
|
+
AS IS_COMPUTED,
|
|
195
|
+
COLUMNPROPERTY(object_id(TABLE_SCHEMA+'.'+TABLE_NAME), COLUMN_NAME, 'IsIdentity')
|
|
196
|
+
AS IS_IDENTITY,
|
|
197
|
+
*
|
|
198
|
+
FROM INFORMATION_SCHEMA.COLUMNS
|
|
199
|
+
WHERE TABLE_NAME='${tableName}'`
|
|
200
|
+
}
|
|
202
201
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
202
|
+
async runSQL(sql: string) {
|
|
203
|
+
return (await this.internalQuery(getSqlQuery(sql))).recordset
|
|
204
|
+
}
|
|
206
205
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Fetches the tables from the sql server database and assigns them to the datasource.
|
|
208
|
+
* @param {*} datasourceId - datasourceId to fetch
|
|
209
|
+
* @param entities - the tables that are to be built
|
|
210
|
+
*/
|
|
211
|
+
async buildSchema(datasourceId: string, entities: Record<string, Table>) {
|
|
212
|
+
await this.connect()
|
|
213
|
+
let tableInfo: TablesResponse[] = await this.runSQL(this.TABLES_SQL)
|
|
214
|
+
if (tableInfo == null || !Array.isArray(tableInfo)) {
|
|
215
|
+
throw "Unable to get list of tables in database"
|
|
216
|
+
}
|
|
218
217
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
218
|
+
const schema = this.config.schema || DEFAULT_SCHEMA
|
|
219
|
+
const tableNames = tableInfo
|
|
220
|
+
.filter((record: any) => record.TABLE_SCHEMA === schema)
|
|
221
|
+
.map((record: any) => record.TABLE_NAME)
|
|
222
|
+
.filter((name: string) => this.MASTER_TABLES.indexOf(name) === -1)
|
|
224
223
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
224
|
+
const tables: Record<string, Table> = {}
|
|
225
|
+
for (let tableName of tableNames) {
|
|
226
|
+
// get the column definition (type)
|
|
227
|
+
const definition = await this.runSQL(this.getDefinitionSQL(tableName))
|
|
228
|
+
// find primary key constraints
|
|
229
|
+
const constraints = await this.runSQL(this.getConstraintsSQL(tableName))
|
|
230
|
+
// find the computed and identity columns (auto columns)
|
|
231
|
+
const columns = await this.runSQL(this.getAutoColumnsSQL(tableName))
|
|
232
|
+
const primaryKeys = constraints
|
|
233
|
+
.filter(
|
|
234
|
+
(constraint: any) => constraint.CONSTRAINT_TYPE === "PRIMARY KEY"
|
|
235
|
+
)
|
|
236
|
+
.map((constraint: any) => constraint.COLUMN_NAME)
|
|
237
|
+
const autoColumns = columns
|
|
238
|
+
.filter((col: any) => col.IS_COMPUTED || col.IS_IDENTITY)
|
|
239
|
+
.map((col: any) => col.COLUMN_NAME)
|
|
241
240
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
schema[name] = {
|
|
249
|
-
autocolumn: !!autoColumns.find((col: string) => col === name),
|
|
250
|
-
name: name,
|
|
251
|
-
...convertSqlType(def.DATA_TYPE),
|
|
252
|
-
externalType: def.DATA_TYPE,
|
|
253
|
-
}
|
|
241
|
+
let schema: TableSchema = {}
|
|
242
|
+
for (let def of definition) {
|
|
243
|
+
const name = def.COLUMN_NAME
|
|
244
|
+
if (typeof name !== "string") {
|
|
245
|
+
continue
|
|
254
246
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
247
|
+
schema[name] = {
|
|
248
|
+
autocolumn: !!autoColumns.find((col: string) => col === name),
|
|
249
|
+
name: name,
|
|
250
|
+
...convertSqlType(def.DATA_TYPE),
|
|
251
|
+
externalType: def.DATA_TYPE,
|
|
260
252
|
}
|
|
261
253
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
254
|
+
tables[tableName] = {
|
|
255
|
+
_id: buildExternalTableId(datasourceId, tableName),
|
|
256
|
+
primary: primaryKeys,
|
|
257
|
+
name: tableName,
|
|
258
|
+
schema,
|
|
259
|
+
}
|
|
265
260
|
}
|
|
261
|
+
const final = finaliseExternalTables(tables, entities)
|
|
262
|
+
this.tables = final.tables
|
|
263
|
+
this.schemaErrors = final.errors
|
|
264
|
+
}
|
|
266
265
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
266
|
+
async read(query: SqlQuery | string) {
|
|
267
|
+
await this.connect()
|
|
268
|
+
const response = await this.internalQuery(getSqlQuery(query))
|
|
269
|
+
return response.recordset
|
|
270
|
+
}
|
|
272
271
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
272
|
+
async create(query: SqlQuery | string) {
|
|
273
|
+
await this.connect()
|
|
274
|
+
const response = await this.internalQuery(getSqlQuery(query))
|
|
275
|
+
return response.recordset || [{ created: true }]
|
|
276
|
+
}
|
|
278
277
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
278
|
+
async update(query: SqlQuery | string) {
|
|
279
|
+
await this.connect()
|
|
280
|
+
const response = await this.internalQuery(getSqlQuery(query))
|
|
281
|
+
return response.recordset || [{ updated: true }]
|
|
282
|
+
}
|
|
284
283
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
284
|
+
async delete(query: SqlQuery | string) {
|
|
285
|
+
await this.connect()
|
|
286
|
+
const response = await this.internalQuery(getSqlQuery(query))
|
|
287
|
+
return response.recordset || [{ deleted: true }]
|
|
288
|
+
}
|
|
290
289
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
const operation = this._operation(json)
|
|
298
|
-
const queryFn = (query: any, op: string) => this.internalQuery(query, op)
|
|
299
|
-
const processFn = (result: any) =>
|
|
300
|
-
result.recordset ? result.recordset : [{ [operation]: true }]
|
|
301
|
-
return this.queryWithReturning(json, queryFn, processFn)
|
|
290
|
+
async query(json: QueryJson) {
|
|
291
|
+
const schema = this.config.schema
|
|
292
|
+
await this.connect()
|
|
293
|
+
if (schema && schema !== DEFAULT_SCHEMA && json?.endpoint) {
|
|
294
|
+
json.endpoint.schema = schema
|
|
302
295
|
}
|
|
296
|
+
const operation = this._operation(json)
|
|
297
|
+
const queryFn = (query: any, op: string) => this.internalQuery(query, op)
|
|
298
|
+
const processFn = (result: any) =>
|
|
299
|
+
result.recordset ? result.recordset : [{ [operation]: true }]
|
|
300
|
+
return this.queryWithReturning(json, queryFn, processFn)
|
|
303
301
|
}
|
|
302
|
+
}
|
|
304
303
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
304
|
+
export default {
|
|
305
|
+
schema: SCHEMA,
|
|
306
|
+
integration: SqlServerIntegration,
|
|
309
307
|
}
|