@budibase/server 1.3.19-alpha.2 → 1.3.19
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.9ce4f8c5.css +6 -0
- package/builder/assets/index.a1f7532b.js +876 -0
- package/builder/assets/vendor.5e1fe644.css +1 -0
- package/builder/assets/vendor.67dbd8fa.js +248 -0
- package/builder/index.html +4 -2
- package/coverage/clover.xml +388 -446
- package/coverage/coverage-final.json +20 -20
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +8 -41
- 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/component.js.html +11 -68
- package/coverage/lcov-report/api/controllers/datasource.js.html +34 -73
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +46 -46
- 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/screen.js.html +12 -207
- 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 +12 -75
- 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 +18 -18
- 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 +20 -56
- 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 +39 -39
- 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 +40 -46
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov.info +669 -790
- package/dist/api/controllers/application.js +5 -5
- package/dist/api/controllers/auth.js +0 -9
- package/dist/api/controllers/component.js +1 -14
- package/dist/api/controllers/datasource.js +8 -21
- package/dist/api/controllers/deploy/index.js +8 -1
- package/dist/api/controllers/integration.js +4 -4
- package/dist/api/controllers/row/external.js +1 -1
- package/dist/api/controllers/screen.js +2 -52
- package/dist/api/controllers/static/index.js +0 -1
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +0 -10
- package/dist/api/controllers/static/templates/preview.hbs +1 -5
- package/dist/api/index.js +1 -1
- package/dist/api/routes/application.js +2 -3
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/public/tables.js +1 -1
- package/dist/api/routes/table.js +1 -1
- package/dist/api/routes/utils/validators.js +2 -20
- package/dist/app.js +0 -11
- package/dist/db/utils.js +1 -10
- package/dist/environment.js +0 -1
- package/dist/integrations/airtable.js +129 -126
- package/dist/integrations/arangodb.js +89 -86
- package/dist/integrations/base/query.js +2 -2
- package/dist/integrations/base/sqlTable.js +1 -3
- package/dist/integrations/couchdb.js +83 -80
- package/dist/integrations/dynamodb.js +164 -161
- package/dist/integrations/elasticsearch.js +138 -135
- package/dist/integrations/firebase.js +157 -154
- package/dist/integrations/googlesheets.js +327 -323
- package/dist/integrations/index.js +51 -99
- package/dist/integrations/microsoftSqlServer.js +243 -240
- package/dist/integrations/mongodb.js +242 -239
- package/dist/integrations/mysql.js +219 -215
- package/dist/integrations/oracle.js +322 -318
- package/dist/integrations/postgres.js +265 -262
- package/dist/integrations/redis.js +139 -134
- package/dist/integrations/rest.js +292 -289
- package/dist/integrations/s3.js +64 -61
- package/dist/integrations/snowflake.js +86 -83
- package/dist/middleware/currentapp.js +0 -2
- package/dist/migrations/functions/backfill/global.js +3 -0
- package/dist/migrations/functions/developerQuota.js +49 -0
- package/dist/{api/routes/plugin.js → migrations/functions/publishedAppsQuota.js} +21 -13
- package/dist/{api/controllers/plugin/url.js → migrations/functions/usageQuotas/syncDevelopers.js} +13 -13
- package/dist/{api/controllers/plugin/file.js → migrations/functions/usageQuotas/syncPublishedApps.js} +15 -13
- package/dist/migrations/index.js +10 -0
- package/dist/package.json +6 -9
- 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 +1 -110
- package/package.json +7 -10
- package/scripts/dev/manage.js +0 -1
- package/scripts/localdomain.js +1 -3
- package/specs/openapi.json +3 -3
- package/specs/openapi.yaml +3 -3
- package/specs/resources/query.js +1 -1
- package/src/api/controllers/application.ts +2 -1
- package/src/api/controllers/auth.js +0 -11
- package/src/api/controllers/component.js +2 -21
- package/src/api/controllers/datasource.js +8 -21
- package/src/api/controllers/deploy/index.ts +6 -1
- package/src/api/controllers/integration.js +4 -4
- package/src/api/controllers/row/external.js +1 -1
- package/src/api/controllers/screen.js +1 -66
- package/src/api/controllers/static/index.ts +1 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +0 -10
- package/src/api/controllers/static/templates/preview.hbs +1 -5
- package/src/api/index.js +1 -1
- package/src/api/routes/application.ts +2 -13
- package/src/api/routes/index.ts +0 -2
- 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 +25 -8
- package/src/api/routes/tests/user.spec.js +2 -0
- package/src/api/routes/utils/validators.js +5 -26
- package/src/app.ts +0 -14
- package/src/db/utils.js +0 -12
- package/src/definitions/openapi.ts +3 -3
- package/src/environment.js +0 -1
- package/src/integrations/airtable.ts +118 -116
- package/src/integrations/arangodb.ts +89 -87
- package/src/integrations/base/query.ts +2 -2
- package/src/integrations/base/sqlTable.ts +1 -3
- package/src/integrations/couchdb.ts +89 -83
- package/src/integrations/dynamodb.ts +175 -173
- package/src/integrations/elasticsearch.ts +122 -120
- package/src/integrations/firebase.ts +159 -157
- package/src/integrations/googlesheets.ts +338 -328
- package/src/integrations/index.ts +21 -64
- package/src/integrations/microsoftSqlServer.ts +251 -249
- package/src/integrations/mongodb.ts +258 -261
- package/src/integrations/mysql.ts +234 -229
- package/src/integrations/oracle.ts +380 -373
- package/src/integrations/postgres.ts +268 -264
- package/src/integrations/redis.ts +132 -128
- package/src/integrations/rest.ts +329 -324
- package/src/integrations/s3.ts +71 -68
- package/src/integrations/snowflake.ts +82 -80
- package/src/integrations/tests/{airtable.spec.ts → airtable.spec.js} +18 -21
- package/src/integrations/tests/{arangodb.spec.ts → arangodb.spec.js} +9 -12
- package/src/integrations/tests/{couchdb.spec.ts → couchdb.spec.js} +27 -33
- package/src/integrations/tests/{dynamodb.spec.ts → dynamodb.spec.js} +41 -45
- package/src/integrations/tests/{elasticsearch.spec.ts → elasticsearch.spec.js} +21 -22
- package/src/integrations/tests/{firebase.spec.ts → firebase.spec.js} +28 -33
- package/src/integrations/tests/{microsoftSqlServer.spec.ts → microsoftSqlServer.spec.js} +11 -12
- package/src/integrations/tests/{mongo.spec.ts → mongo.spec.js} +35 -46
- package/src/integrations/tests/{mysql.spec.ts → mysql.spec.js} +15 -17
- package/src/integrations/tests/{oracle.spec.ts → oracle.spec.js} +17 -19
- package/src/integrations/tests/{postgres.spec.ts → postgres.spec.js} +17 -19
- package/src/integrations/tests/{redis.spec.ts → redis.spec.js} +18 -27
- package/src/integrations/tests/{rest.spec.ts → rest.spec.js} +14 -22
- package/src/integrations/tests/{s3.spec.ts → s3.spec.js} +8 -10
- package/src/integrations/tests/{sql.spec.ts → sql.spec.js} +177 -228
- package/src/middleware/currentapp.js +0 -2
- package/src/migrations/functions/backfill/global.ts +3 -0
- package/src/migrations/functions/developerQuota.ts +15 -0
- package/src/migrations/functions/publishedAppsQuota.ts +13 -0
- package/src/migrations/functions/usageQuotas/syncDevelopers.ts +19 -0
- package/src/migrations/functions/usageQuotas/syncPublishedApps.ts +21 -0
- package/src/migrations/index.ts +16 -0
- package/src/module.d.ts +0 -2
- package/src/tests/utilities/TestConfiguration.js +1 -1
- package/src/threads/query.ts +2 -2
- package/src/utilities/fileSystem/index.js +0 -129
- package/builder/assets/index.8f621053.css +0 -6
- package/builder/assets/index.bd4753ac.js +0 -1005
- package/dist/api/controllers/plugin/github.js +0 -69
- package/dist/api/controllers/plugin/index.js +0 -200
- package/dist/api/controllers/plugin/npm.js +0 -58
- package/dist/api/controllers/plugin/uploaders.js +0 -11
- package/dist/api/controllers/plugin/utils.js +0 -26
- package/dist/watch.js +0 -77
- package/dist/websocket.js +0 -22
- package/src/api/controllers/plugin/file.ts +0 -15
- package/src/api/controllers/plugin/github.ts +0 -75
- package/src/api/controllers/plugin/index.ts +0 -215
- package/src/api/controllers/plugin/npm.ts +0 -56
- package/src/api/controllers/plugin/uploaders.ts +0 -4
- package/src/api/controllers/plugin/url.ts +0 -12
- package/src/api/controllers/plugin/utils.ts +0 -19
- package/src/api/routes/plugin.ts +0 -14
- package/src/watch.ts +0 -38
- package/src/websocket.ts +0 -26
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import { SourceName, Integration, PluginType } from "@budibase/types"
|
|
18
|
-
import { getDatasourcePlugin } from "../utilities/fileSystem"
|
|
1
|
+
const postgres = require("./postgres")
|
|
2
|
+
const dynamodb = require("./dynamodb")
|
|
3
|
+
const mongodb = require("./mongodb")
|
|
4
|
+
const elasticsearch = require("./elasticsearch")
|
|
5
|
+
const couchdb = require("./couchdb")
|
|
6
|
+
const sqlServer = require("./microsoftSqlServer")
|
|
7
|
+
const s3 = require("./s3")
|
|
8
|
+
const airtable = require("./airtable")
|
|
9
|
+
const mysql = require("./mysql")
|
|
10
|
+
const arangodb = require("./arangodb")
|
|
11
|
+
const rest = require("./rest")
|
|
12
|
+
const googlesheets = require("./googlesheets")
|
|
13
|
+
const firebase = require("./firebase")
|
|
14
|
+
const redis = require("./redis")
|
|
15
|
+
const snowflake = require("./snowflake")
|
|
16
|
+
const { SourceName } = require("@budibase/types")
|
|
19
17
|
const environment = require("../environment")
|
|
20
|
-
const { cloneDeep } = require("lodash")
|
|
21
18
|
|
|
22
|
-
const DEFINITIONS
|
|
19
|
+
const DEFINITIONS = {
|
|
23
20
|
[SourceName.POSTGRES]: postgres.schema,
|
|
24
21
|
[SourceName.DYNAMODB]: dynamodb.schema,
|
|
25
22
|
[SourceName.MONGODB]: mongodb.schema,
|
|
@@ -36,7 +33,7 @@ const DEFINITIONS: { [key: string]: Integration } = {
|
|
|
36
33
|
[SourceName.SNOWFLAKE]: snowflake.schema,
|
|
37
34
|
}
|
|
38
35
|
|
|
39
|
-
const INTEGRATIONS
|
|
36
|
+
const INTEGRATIONS = {
|
|
40
37
|
[SourceName.POSTGRES]: postgres.integration,
|
|
41
38
|
[SourceName.DYNAMODB]: dynamodb.integration,
|
|
42
39
|
[SourceName.MONGODB]: mongodb.integration,
|
|
@@ -51,7 +48,7 @@ const INTEGRATIONS: { [key: string]: any } = {
|
|
|
51
48
|
[SourceName.FIRESTORE]: firebase.integration,
|
|
52
49
|
[SourceName.GOOGLE_SHEETS]: googlesheets.integration,
|
|
53
50
|
[SourceName.REDIS]: redis.integration,
|
|
54
|
-
[SourceName.
|
|
51
|
+
[SourceName.FIREBASE]: firebase.integration,
|
|
55
52
|
[SourceName.SNOWFLAKE]: snowflake.integration,
|
|
56
53
|
}
|
|
57
54
|
|
|
@@ -67,46 +64,6 @@ if (environment.SELF_HOSTED) {
|
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
module.exports = {
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
},
|
|
67
|
+
definitions: DEFINITIONS,
|
|
68
|
+
integrations: INTEGRATIONS,
|
|
112
69
|
}
|
|
@@ -18,290 +18,292 @@ import {
|
|
|
18
18
|
} from "./utils"
|
|
19
19
|
import Sql from "./base/sql"
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
const
|
|
21
|
+
module MSSQLModule {
|
|
22
|
+
const sqlServer = require("mssql")
|
|
23
|
+
const DEFAULT_SCHEMA = "dbo"
|
|
23
24
|
|
|
24
|
-
interface MSSQLConfig {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
25
|
+
interface MSSQLConfig {
|
|
26
|
+
user: string
|
|
27
|
+
password: string
|
|
28
|
+
server: string
|
|
29
|
+
port: number
|
|
30
|
+
database: string
|
|
31
|
+
schema: string
|
|
32
|
+
encrypt?: boolean
|
|
33
|
+
}
|
|
33
34
|
|
|
34
|
-
interface TablesResponse {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
35
|
+
interface TablesResponse {
|
|
36
|
+
TABLE_CATALOG: string
|
|
37
|
+
TABLE_SCHEMA: string
|
|
38
|
+
TABLE_NAME: string
|
|
39
|
+
TABLE_TYPE: string
|
|
40
|
+
}
|
|
40
41
|
|
|
41
|
-
const SCHEMA: Integration = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
query: {
|
|
81
|
-
create: {
|
|
82
|
-
type: QueryType.SQL,
|
|
83
|
-
},
|
|
84
|
-
read: {
|
|
85
|
-
type: QueryType.SQL,
|
|
86
|
-
},
|
|
87
|
-
update: {
|
|
88
|
-
type: QueryType.SQL,
|
|
42
|
+
const SCHEMA: Integration = {
|
|
43
|
+
docs: "https://github.com/tediousjs/node-mssql",
|
|
44
|
+
plus: true,
|
|
45
|
+
description:
|
|
46
|
+
"Microsoft SQL Server is a relational database management system developed by Microsoft. ",
|
|
47
|
+
friendlyName: "MS SQL Server",
|
|
48
|
+
type: "Relational",
|
|
49
|
+
datasource: {
|
|
50
|
+
user: {
|
|
51
|
+
type: DatasourceFieldType.STRING,
|
|
52
|
+
required: true,
|
|
53
|
+
default: "localhost",
|
|
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
|
+
},
|
|
89
80
|
},
|
|
90
|
-
|
|
91
|
-
|
|
81
|
+
query: {
|
|
82
|
+
create: {
|
|
83
|
+
type: QueryType.SQL,
|
|
84
|
+
},
|
|
85
|
+
read: {
|
|
86
|
+
type: QueryType.SQL,
|
|
87
|
+
},
|
|
88
|
+
update: {
|
|
89
|
+
type: QueryType.SQL,
|
|
90
|
+
},
|
|
91
|
+
delete: {
|
|
92
|
+
type: QueryType.SQL,
|
|
93
|
+
},
|
|
92
94
|
},
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
+
}
|
|
95
96
|
|
|
96
|
-
class SqlServerIntegration extends Sql implements DatasourcePlus {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
class SqlServerIntegration extends Sql implements DatasourcePlus {
|
|
98
|
+
private readonly config: MSSQLConfig
|
|
99
|
+
private index: number = 0
|
|
100
|
+
private readonly pool: any
|
|
101
|
+
private client: any
|
|
102
|
+
public tables: Record<string, Table> = {}
|
|
103
|
+
public schemaErrors: Record<string, string> = {}
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
105
|
+
MASTER_TABLES = [
|
|
106
|
+
"spt_fallback_db",
|
|
107
|
+
"spt_fallback_dev",
|
|
108
|
+
"spt_fallback_usg",
|
|
109
|
+
"spt_monitor",
|
|
110
|
+
"MSreplication_options",
|
|
111
|
+
]
|
|
112
|
+
TABLES_SQL =
|
|
113
|
+
"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'"
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
constructor(config: MSSQLConfig) {
|
|
116
|
+
super(SqlClient.MS_SQL)
|
|
117
|
+
this.config = config
|
|
118
|
+
const clientCfg = {
|
|
119
|
+
...this.config,
|
|
120
|
+
options: {
|
|
121
|
+
encrypt: this.config.encrypt,
|
|
122
|
+
enableArithAbort: true,
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
delete clientCfg.encrypt
|
|
126
|
+
if (!this.pool) {
|
|
127
|
+
this.pool = new sqlServer.ConnectionPool(clientCfg)
|
|
128
|
+
}
|
|
127
129
|
}
|
|
128
|
-
}
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
getBindingIdentifier(): string {
|
|
132
|
+
return `@p${this.index++}`
|
|
133
|
+
}
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
getStringConcat(parts: string[]): string {
|
|
136
|
+
return `concat(${parts.join(", ")})`
|
|
137
|
+
}
|
|
137
138
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
async connect() {
|
|
140
|
+
try {
|
|
141
|
+
this.client = await this.pool.connect()
|
|
142
|
+
} catch (err) {
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
throw new Error(err)
|
|
145
|
+
}
|
|
144
146
|
}
|
|
145
|
-
}
|
|
146
147
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
async internalQuery(
|
|
149
|
+
query: SqlQuery,
|
|
150
|
+
operation: string | undefined = undefined
|
|
151
|
+
) {
|
|
152
|
+
const client = this.client
|
|
153
|
+
const request = client.request()
|
|
154
|
+
this.index = 0
|
|
155
|
+
try {
|
|
156
|
+
if (Array.isArray(query.bindings)) {
|
|
157
|
+
let count = 0
|
|
158
|
+
for (let binding of query.bindings) {
|
|
159
|
+
request.input(`p${count++}`, binding)
|
|
160
|
+
}
|
|
159
161
|
}
|
|
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)
|
|
160
172
|
}
|
|
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)
|
|
171
173
|
}
|
|
172
|
-
}
|
|
173
174
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
}
|
|
175
|
+
getDefinitionSQL(tableName: string) {
|
|
176
|
+
return `select *
|
|
177
|
+
from INFORMATION_SCHEMA.COLUMNS
|
|
178
|
+
where TABLE_NAME='${tableName}'`
|
|
179
|
+
}
|
|
190
180
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
181
|
+
getConstraintsSQL(tableName: string) {
|
|
182
|
+
return `SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC
|
|
183
|
+
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KU
|
|
184
|
+
ON TC.CONSTRAINT_TYPE = 'PRIMARY KEY'
|
|
185
|
+
AND TC.CONSTRAINT_NAME = KU.CONSTRAINT_NAME
|
|
186
|
+
AND KU.table_name='${tableName}'
|
|
187
|
+
ORDER BY
|
|
188
|
+
KU.TABLE_NAME,
|
|
189
|
+
KU.ORDINAL_POSITION;`
|
|
190
|
+
}
|
|
201
191
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
192
|
+
getAutoColumnsSQL(tableName: string) {
|
|
193
|
+
return `SELECT
|
|
194
|
+
COLUMNPROPERTY(OBJECT_ID(TABLE_SCHEMA+'.'+TABLE_NAME),COLUMN_NAME,'IsComputed')
|
|
195
|
+
AS IS_COMPUTED,
|
|
196
|
+
COLUMNPROPERTY(object_id(TABLE_SCHEMA+'.'+TABLE_NAME), COLUMN_NAME, 'IsIdentity')
|
|
197
|
+
AS IS_IDENTITY,
|
|
198
|
+
*
|
|
199
|
+
FROM INFORMATION_SCHEMA.COLUMNS
|
|
200
|
+
WHERE TABLE_NAME='${tableName}'`
|
|
201
|
+
}
|
|
205
202
|
|
|
206
|
-
|
|
207
|
-
|
|
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"
|
|
203
|
+
async runSQL(sql: string) {
|
|
204
|
+
return (await this.internalQuery(getSqlQuery(sql))).recordset
|
|
216
205
|
}
|
|
217
206
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Fetches the tables from the sql server database and assigns them to the datasource.
|
|
209
|
+
* @param {*} datasourceId - datasourceId to fetch
|
|
210
|
+
* @param entities - the tables that are to be built
|
|
211
|
+
*/
|
|
212
|
+
async buildSchema(datasourceId: string, entities: Record<string, Table>) {
|
|
213
|
+
await this.connect()
|
|
214
|
+
let tableInfo: TablesResponse[] = await this.runSQL(this.TABLES_SQL)
|
|
215
|
+
if (tableInfo == null || !Array.isArray(tableInfo)) {
|
|
216
|
+
throw "Unable to get list of tables in database"
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const schema = this.config.schema || DEFAULT_SCHEMA
|
|
220
|
+
const tableNames = tableInfo
|
|
221
|
+
.filter((record: any) => record.TABLE_SCHEMA === schema)
|
|
222
|
+
.map((record: any) => record.TABLE_NAME)
|
|
223
|
+
.filter((name: string) => this.MASTER_TABLES.indexOf(name) === -1)
|
|
223
224
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
225
|
+
const tables: Record<string, Table> = {}
|
|
226
|
+
for (let tableName of tableNames) {
|
|
227
|
+
// get the column definition (type)
|
|
228
|
+
const definition = await this.runSQL(this.getDefinitionSQL(tableName))
|
|
229
|
+
// find primary key constraints
|
|
230
|
+
const constraints = await this.runSQL(this.getConstraintsSQL(tableName))
|
|
231
|
+
// find the computed and identity columns (auto columns)
|
|
232
|
+
const columns = await this.runSQL(this.getAutoColumnsSQL(tableName))
|
|
233
|
+
const primaryKeys = constraints
|
|
234
|
+
.filter(
|
|
235
|
+
(constraint: any) => constraint.CONSTRAINT_TYPE === "PRIMARY KEY"
|
|
236
|
+
)
|
|
237
|
+
.map((constraint: any) => constraint.COLUMN_NAME)
|
|
238
|
+
const autoColumns = columns
|
|
239
|
+
.filter((col: any) => col.IS_COMPUTED || col.IS_IDENTITY)
|
|
240
|
+
.map((col: any) => col.COLUMN_NAME)
|
|
240
241
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
242
|
+
let schema: TableSchema = {}
|
|
243
|
+
for (let def of definition) {
|
|
244
|
+
const name = def.COLUMN_NAME
|
|
245
|
+
if (typeof name !== "string") {
|
|
246
|
+
continue
|
|
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
|
+
}
|
|
246
254
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
255
|
+
tables[tableName] = {
|
|
256
|
+
_id: buildExternalTableId(datasourceId, tableName),
|
|
257
|
+
primary: primaryKeys,
|
|
258
|
+
name: tableName,
|
|
259
|
+
schema,
|
|
252
260
|
}
|
|
253
261
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
name: tableName,
|
|
258
|
-
schema,
|
|
259
|
-
}
|
|
262
|
+
const final = finaliseExternalTables(tables, entities)
|
|
263
|
+
this.tables = final.tables
|
|
264
|
+
this.schemaErrors = final.errors
|
|
260
265
|
}
|
|
261
|
-
const final = finaliseExternalTables(tables, entities)
|
|
262
|
-
this.tables = final.tables
|
|
263
|
-
this.schemaErrors = final.errors
|
|
264
|
-
}
|
|
265
266
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
267
|
+
async read(query: SqlQuery | string) {
|
|
268
|
+
await this.connect()
|
|
269
|
+
const response = await this.internalQuery(getSqlQuery(query))
|
|
270
|
+
return response.recordset
|
|
271
|
+
}
|
|
271
272
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
273
|
+
async create(query: SqlQuery | string) {
|
|
274
|
+
await this.connect()
|
|
275
|
+
const response = await this.internalQuery(getSqlQuery(query))
|
|
276
|
+
return response.recordset || [{ created: true }]
|
|
277
|
+
}
|
|
277
278
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
async update(query: SqlQuery | string) {
|
|
280
|
+
await this.connect()
|
|
281
|
+
const response = await this.internalQuery(getSqlQuery(query))
|
|
282
|
+
return response.recordset || [{ updated: true }]
|
|
283
|
+
}
|
|
283
284
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
285
|
+
async delete(query: SqlQuery | string) {
|
|
286
|
+
await this.connect()
|
|
287
|
+
const response = await this.internalQuery(getSqlQuery(query))
|
|
288
|
+
return response.recordset || [{ deleted: true }]
|
|
289
|
+
}
|
|
289
290
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
291
|
+
async query(json: QueryJson) {
|
|
292
|
+
const schema = this.config.schema
|
|
293
|
+
await this.connect()
|
|
294
|
+
if (schema && schema !== DEFAULT_SCHEMA && json?.endpoint) {
|
|
295
|
+
json.endpoint.schema = schema
|
|
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)
|
|
295
302
|
}
|
|
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)
|
|
301
303
|
}
|
|
302
|
-
}
|
|
303
304
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
module.exports = {
|
|
306
|
+
schema: SCHEMA,
|
|
307
|
+
integration: SqlServerIntegration,
|
|
308
|
+
}
|
|
307
309
|
}
|