@budibase/server 1.0.80-alpha.3 → 1.0.80
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__/node-fetch.ts +0 -1
- package/builder/assets/index.22a39cc9.js +1352 -0
- package/builder/assets/{index.c57242d4.css → index.c8d1e8f0.css} +2 -2
- package/builder/assets/{vendor.a7c6ad0a.js → vendor.20f80cec.js} +216 -190
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2327 -2390
- package/coverage/coverage-final.json +137 -138
- package/coverage/lcov-report/api/controllers/analytics.js.html +6 -6
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/application.js.html +149 -152
- package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
- package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -11
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
- package/coverage/lcov-report/api/controllers/dev.js.html +19 -19
- package/coverage/lcov-report/api/controllers/index.html +16 -16
- package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
- package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
- package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +16 -16
- package/coverage/lcov-report/api/controllers/row/index.html +27 -27
- package/coverage/lcov-report/api/controllers/row/index.js.html +46 -46
- package/coverage/lcov-report/api/controllers/row/internal.js.html +82 -94
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +204 -204
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
- package/coverage/lcov-report/api/controllers/row/utils.js.html +29 -29
- package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +49 -49
- package/coverage/lcov-report/api/controllers/table/external.js.html +12 -12
- package/coverage/lcov-report/api/controllers/table/index.html +11 -11
- package/coverage/lcov-report/api/controllers/table/index.js.html +44 -47
- package/coverage/lcov-report/api/controllers/table/internal.js.html +50 -50
- package/coverage/lcov-report/api/controllers/table/utils.js.html +80 -80
- package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
- package/coverage/lcov-report/api/controllers/user.js.html +19 -19
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/view/utils.js.html +12 -12
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +27 -18
- package/coverage/lcov-report/api/index.html +10 -10
- package/coverage/lcov-report/api/index.js.html +28 -37
- package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/application.js.html +9 -9
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +109 -19
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +156 -18
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +13 -13
- package/coverage/lcov-report/api/routes/index.html +35 -35
- package/coverage/lcov-report/api/routes/index.js.html +32 -38
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
- package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
- package/coverage/lcov-report/api/routes/permission.js.html +58 -16
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +78 -15
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +14 -17
- package/coverage/lcov-report/api/routes/screen.js.html +95 -14
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +13 -13
- package/coverage/lcov-report/api/routes/table.js.html +62 -17
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +8 -8
- package/coverage/lcov-report/api/routes/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +62 -14
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +7 -7
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +9 -12
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +11 -11
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +26 -26
- package/coverage/lcov-report/automations/utils.js.html +35 -35
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +28 -40
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +21 -21
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +30 -30
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +87 -123
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +8 -8
- package/coverage/lcov-report/events/utils.js.html +18 -18
- package/coverage/lcov-report/index.html +74 -89
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +5 -5
- package/coverage/lcov-report/middleware/authorized.js.html +29 -29
- package/coverage/lcov-report/middleware/builder.js.html +16 -16
- package/coverage/lcov-report/middleware/currentapp.js.html +44 -44
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
- package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +17 -17
- package/coverage/lcov-report/middleware/utils.js.html +4 -4
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +19 -19
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +39 -123
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +28 -28
- package/coverage/lcov-report/utilities/index.html +18 -18
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -9
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +60 -60
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +13 -13
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +12 -12
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +8 -8
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +53 -200
- package/coverage/lcov.info +3233 -3332
- package/dist/api/controllers/application.js +0 -1
- package/dist/api/controllers/row/internal.js +1 -4
- package/dist/api/controllers/table/index.js +1 -2
- package/dist/api/controllers/webhook.js +5 -3
- package/dist/api/index.js +1 -3
- package/dist/api/routes/automation.js +31 -3
- package/dist/api/routes/datasource.js +50 -3
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/permission.js +14 -4
- package/dist/api/routes/role.js +19 -3
- package/dist/api/routes/row.js +4 -3
- package/dist/api/routes/screen.js +23 -2
- package/dist/api/routes/table.js +17 -3
- package/dist/api/routes/tests/utilities/index.js +0 -23
- package/dist/api/routes/webhook.js +17 -2
- package/dist/automations/steps/filter.js +2 -2
- package/dist/automations/steps/queryRows.js +1 -1
- package/dist/automations/utils.js +2 -2
- package/dist/constants/index.js +0 -3
- package/dist/db/utils.js +0 -11
- package/dist/environment.js +0 -1
- package/dist/integrations/base/sql.js +1 -16
- package/dist/integrations/base/sqlTable.js +4 -8
- package/dist/integrations/googlesheets.js +0 -3
- package/dist/integrations/microsoftSqlServer.js +43 -60
- package/dist/integrations/mysql.js +0 -3
- package/dist/integrations/oracle.js +19 -14
- package/dist/integrations/postgres.js +28 -34
- package/dist/integrations/utils.js +15 -32
- package/dist/package.json +7 -11
- package/dist/tests/utilities/TestConfiguration.js +8 -25
- package/dist/threads/query.js +8 -33
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +15 -50
- package/package.json +8 -12
- package/scripts/integrations/mssql/data/setup.sql +1 -18
- package/scripts/integrations/oracle/oracle.md +2 -2
- package/scripts/integrations/postgres/init.sql +3 -11
- package/scripts/likeCypress.ts +6 -9
- package/scripts/proxy/generateProxyConfig.js +70 -0
- package/src/api/controllers/application.js +0 -1
- package/src/api/controllers/row/ExternalRequest.ts +1 -1
- package/src/api/controllers/row/internal.js +0 -4
- package/src/api/controllers/table/index.js +1 -2
- package/src/api/controllers/webhook.js +6 -3
- package/src/api/index.js +1 -4
- package/src/api/routes/automation.js +33 -3
- package/src/api/routes/datasource.js +52 -6
- package/src/api/routes/index.js +0 -2
- package/src/api/routes/permission.js +18 -4
- package/src/api/routes/role.js +24 -3
- package/src/api/routes/row.js +2 -3
- package/src/api/routes/screen.js +29 -2
- package/src/api/routes/table.js +19 -4
- package/src/api/routes/tests/utilities/index.js +0 -24
- package/src/api/routes/webhook.js +18 -2
- package/src/automations/steps/filter.js +2 -3
- package/src/automations/steps/queryRows.js +1 -1
- package/src/automations/utils.js +2 -2
- package/src/constants/index.js +0 -4
- package/src/db/utils.js +0 -12
- package/src/definitions/common.ts +0 -4
- package/src/definitions/datasource.ts +0 -1
- package/src/environment.js +0 -1
- package/src/integrations/base/datasourcePlus.ts +0 -3
- package/src/integrations/base/sql.ts +1 -16
- package/src/integrations/base/sqlTable.ts +7 -11
- package/src/integrations/googlesheets.ts +2 -5
- package/src/integrations/microsoftSqlServer.ts +61 -86
- package/src/integrations/mysql.ts +0 -4
- package/src/integrations/oracle.ts +35 -27
- package/src/integrations/postgres.ts +26 -33
- package/src/integrations/utils.ts +15 -43
- package/src/tests/utilities/TestConfiguration.js +2 -23
- package/src/threads/query.js +9 -37
- package/src/utilities/workerRequests.js +16 -65
- package/builder/assets/index.f8c92447.js +0 -1288
- package/coverage/lcov-report/api/routes/utils/index.html +0 -111
- package/coverage/lcov-report/api/routes/utils/validators.js.html +0 -737
- package/dist/api/controllers/public/applications.js +0 -94
- package/dist/api/controllers/public/mapping/applications.js +0 -29
- package/dist/api/controllers/public/mapping/index.js +0 -11
- package/dist/api/controllers/public/mapping/queries.js +0 -36
- package/dist/api/controllers/public/mapping/rows.js +0 -24
- package/dist/api/controllers/public/mapping/tables.js +0 -23
- package/dist/api/controllers/public/mapping/types.js +0 -2
- package/dist/api/controllers/public/mapping/users.js +0 -29
- package/dist/api/controllers/public/queries.js +0 -38
- package/dist/api/controllers/public/rows.js +0 -97
- package/dist/api/controllers/public/tables.js +0 -75
- package/dist/api/controllers/public/users.js +0 -95
- package/dist/api/controllers/public/utils.js +0 -49
- package/dist/api/routes/public/applications.js +0 -141
- package/dist/api/routes/public/index.js +0 -101
- package/dist/api/routes/public/middleware/mapper.js +0 -94
- package/dist/api/routes/public/queries.js +0 -77
- package/dist/api/routes/public/rows.js +0 -229
- package/dist/api/routes/public/tables.js +0 -154
- package/dist/api/routes/public/users.js +0 -137
- package/dist/api/routes/public/utils/Endpoint.js +0 -36
- package/dist/api/routes/utils/validators.js +0 -200
- package/dist/definitions/openapi.js +0 -6
- package/specs/generate.js +0 -94
- package/specs/openapi.json +0 -2232
- package/specs/openapi.yaml +0 -1538
- package/specs/parameters.js +0 -59
- package/specs/resources/application.js +0 -101
- package/specs/resources/index.js +0 -24
- package/specs/resources/misc.js +0 -12
- package/specs/resources/query.js +0 -189
- package/specs/resources/row.js +0 -125
- package/specs/resources/table.js +0 -191
- package/specs/resources/user.js +0 -126
- package/specs/resources/utils/Resource.js +0 -26
- package/specs/resources/utils/index.js +0 -11
- package/specs/security.js +0 -7
- package/src/api/controllers/public/applications.ts +0 -74
- package/src/api/controllers/public/mapping/applications.ts +0 -32
- package/src/api/controllers/public/mapping/index.ts +0 -13
- package/src/api/controllers/public/mapping/queries.ts +0 -39
- package/src/api/controllers/public/mapping/rows.ts +0 -31
- package/src/api/controllers/public/mapping/tables.ts +0 -26
- package/src/api/controllers/public/mapping/types.ts +0 -13
- package/src/api/controllers/public/mapping/users.ts +0 -32
- package/src/api/controllers/public/queries.ts +0 -20
- package/src/api/controllers/public/rows.ts +0 -77
- package/src/api/controllers/public/tables.ts +0 -56
- package/src/api/controllers/public/users.ts +0 -82
- package/src/api/controllers/public/utils.ts +0 -38
- package/src/api/routes/public/applications.ts +0 -156
- package/src/api/routes/public/index.ts +0 -118
- package/src/api/routes/public/middleware/mapper.ts +0 -81
- package/src/api/routes/public/queries.ts +0 -81
- package/src/api/routes/public/rows.ts +0 -242
- package/src/api/routes/public/tables.ts +0 -169
- package/src/api/routes/public/tests/compare.spec.js +0 -184
- package/src/api/routes/public/users.ts +0 -144
- package/src/api/routes/public/utils/Endpoint.ts +0 -51
- package/src/api/routes/utils/validators.js +0 -219
- package/src/definitions/openapi.ts +0 -943
|
@@ -19,7 +19,6 @@ import { Table, TableSchema } from "../definitions/common"
|
|
|
19
19
|
module MSSQLModule {
|
|
20
20
|
const sqlServer = require("mssql")
|
|
21
21
|
const Sql = require("./base/sql")
|
|
22
|
-
const DEFAULT_SCHEMA = "dbo"
|
|
23
22
|
|
|
24
23
|
interface MSSQLConfig {
|
|
25
24
|
user: string
|
|
@@ -27,17 +26,9 @@ module MSSQLModule {
|
|
|
27
26
|
server: string
|
|
28
27
|
port: number
|
|
29
28
|
database: string
|
|
30
|
-
schema: string
|
|
31
29
|
encrypt?: boolean
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
interface TablesResponse {
|
|
35
|
-
TABLE_CATALOG: string
|
|
36
|
-
TABLE_SCHEMA: string
|
|
37
|
-
TABLE_NAME: string
|
|
38
|
-
TABLE_TYPE: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
32
|
const SCHEMA: Integration = {
|
|
42
33
|
docs: "https://github.com/tediousjs/node-mssql",
|
|
43
34
|
plus: true,
|
|
@@ -67,10 +58,6 @@ module MSSQLModule {
|
|
|
67
58
|
type: DatasourceFieldTypes.STRING,
|
|
68
59
|
default: "root",
|
|
69
60
|
},
|
|
70
|
-
schema: {
|
|
71
|
-
type: DatasourceFieldTypes.STRING,
|
|
72
|
-
default: DEFAULT_SCHEMA,
|
|
73
|
-
},
|
|
74
61
|
encrypt: {
|
|
75
62
|
type: DatasourceFieldTypes.BOOLEAN,
|
|
76
63
|
default: true,
|
|
@@ -92,9 +79,34 @@ module MSSQLModule {
|
|
|
92
79
|
},
|
|
93
80
|
}
|
|
94
81
|
|
|
82
|
+
async function internalQuery(
|
|
83
|
+
client: any,
|
|
84
|
+
query: SqlQuery,
|
|
85
|
+
operation: string | undefined = undefined
|
|
86
|
+
) {
|
|
87
|
+
const request = client.request()
|
|
88
|
+
try {
|
|
89
|
+
if (Array.isArray(query.bindings)) {
|
|
90
|
+
let count = 0
|
|
91
|
+
for (let binding of query.bindings) {
|
|
92
|
+
request.input(`p${count++}`, binding)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// this is a hack to get the inserted ID back,
|
|
96
|
+
// no way to do this with Knex nicely
|
|
97
|
+
const sql =
|
|
98
|
+
operation === Operation.CREATE
|
|
99
|
+
? `${query.sql}; SELECT SCOPE_IDENTITY() AS id;`
|
|
100
|
+
: query.sql
|
|
101
|
+
return await request.query(sql)
|
|
102
|
+
} catch (err) {
|
|
103
|
+
// @ts-ignore
|
|
104
|
+
throw new Error(err)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
95
108
|
class SqlServerIntegration extends Sql implements DatasourcePlus {
|
|
96
109
|
private readonly config: MSSQLConfig
|
|
97
|
-
private index: number = 0
|
|
98
110
|
static pool: any
|
|
99
111
|
public tables: Record<string, Table> = {}
|
|
100
112
|
public schemaErrors: Record<string, string> = {}
|
|
@@ -109,62 +121,6 @@ module MSSQLModule {
|
|
|
109
121
|
TABLES_SQL =
|
|
110
122
|
"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'"
|
|
111
123
|
|
|
112
|
-
constructor(config: MSSQLConfig) {
|
|
113
|
-
super(SqlClients.MS_SQL)
|
|
114
|
-
this.config = config
|
|
115
|
-
const clientCfg = {
|
|
116
|
-
...this.config,
|
|
117
|
-
options: {
|
|
118
|
-
encrypt: this.config.encrypt,
|
|
119
|
-
enableArithAbort: true,
|
|
120
|
-
},
|
|
121
|
-
}
|
|
122
|
-
delete clientCfg.encrypt
|
|
123
|
-
if (!this.pool) {
|
|
124
|
-
this.pool = new sqlServer.ConnectionPool(clientCfg)
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
getBindingIdentifier(): string {
|
|
129
|
-
return `(@p${this.index++})`
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
async connect() {
|
|
133
|
-
try {
|
|
134
|
-
this.client = await this.pool.connect()
|
|
135
|
-
} catch (err) {
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
throw new Error(err)
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async internalQuery(
|
|
142
|
-
query: SqlQuery,
|
|
143
|
-
operation: string | undefined = undefined
|
|
144
|
-
) {
|
|
145
|
-
const client = this.client
|
|
146
|
-
const request = client.request()
|
|
147
|
-
this.index = 0
|
|
148
|
-
try {
|
|
149
|
-
if (Array.isArray(query.bindings)) {
|
|
150
|
-
let count = 0
|
|
151
|
-
for (let binding of query.bindings) {
|
|
152
|
-
request.input(`p${count++}`, binding)
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
// this is a hack to get the inserted ID back,
|
|
156
|
-
// no way to do this with Knex nicely
|
|
157
|
-
const sql =
|
|
158
|
-
operation === Operation.CREATE
|
|
159
|
-
? `${query.sql}; SELECT SCOPE_IDENTITY() AS id;`
|
|
160
|
-
: query.sql
|
|
161
|
-
return await request.query(sql)
|
|
162
|
-
} catch (err) {
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
throw new Error(err)
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
124
|
getDefinitionSQL(tableName: string) {
|
|
169
125
|
return `select *
|
|
170
126
|
from INFORMATION_SCHEMA.COLUMNS
|
|
@@ -193,8 +149,33 @@ module MSSQLModule {
|
|
|
193
149
|
WHERE TABLE_NAME='${tableName}'`
|
|
194
150
|
}
|
|
195
151
|
|
|
152
|
+
constructor(config: MSSQLConfig) {
|
|
153
|
+
super(SqlClients.MS_SQL)
|
|
154
|
+
this.config = config
|
|
155
|
+
const clientCfg = {
|
|
156
|
+
...this.config,
|
|
157
|
+
options: {
|
|
158
|
+
encrypt: this.config.encrypt,
|
|
159
|
+
enableArithAbort: true,
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
delete clientCfg.encrypt
|
|
163
|
+
if (!this.pool) {
|
|
164
|
+
this.pool = new sqlServer.ConnectionPool(clientCfg)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async connect() {
|
|
169
|
+
try {
|
|
170
|
+
this.client = await this.pool.connect()
|
|
171
|
+
} catch (err) {
|
|
172
|
+
// @ts-ignore
|
|
173
|
+
throw new Error(err)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
196
177
|
async runSQL(sql: string) {
|
|
197
|
-
return (await this.
|
|
178
|
+
return (await internalQuery(this.client, getSqlQuery(sql))).recordset
|
|
198
179
|
}
|
|
199
180
|
|
|
200
181
|
/**
|
|
@@ -204,14 +185,11 @@ module MSSQLModule {
|
|
|
204
185
|
*/
|
|
205
186
|
async buildSchema(datasourceId: string, entities: Record<string, Table>) {
|
|
206
187
|
await this.connect()
|
|
207
|
-
let
|
|
208
|
-
if (
|
|
188
|
+
let tableNames = await this.runSQL(this.TABLES_SQL)
|
|
189
|
+
if (tableNames == null || !Array.isArray(tableNames)) {
|
|
209
190
|
throw "Unable to get list of tables in database"
|
|
210
191
|
}
|
|
211
|
-
|
|
212
|
-
const schema = this.config.schema || DEFAULT_SCHEMA
|
|
213
|
-
const tableNames = tableInfo
|
|
214
|
-
.filter((record: any) => record.TABLE_SCHEMA === schema)
|
|
192
|
+
tableNames = tableNames
|
|
215
193
|
.map((record: any) => record.TABLE_NAME)
|
|
216
194
|
.filter((name: string) => this.MASTER_TABLES.indexOf(name) === -1)
|
|
217
195
|
|
|
@@ -260,36 +238,33 @@ module MSSQLModule {
|
|
|
260
238
|
|
|
261
239
|
async read(query: SqlQuery | string) {
|
|
262
240
|
await this.connect()
|
|
263
|
-
const response = await this.
|
|
241
|
+
const response = await internalQuery(this.client, getSqlQuery(query))
|
|
264
242
|
return response.recordset
|
|
265
243
|
}
|
|
266
244
|
|
|
267
245
|
async create(query: SqlQuery | string) {
|
|
268
246
|
await this.connect()
|
|
269
|
-
const response = await this.
|
|
247
|
+
const response = await internalQuery(this.client, getSqlQuery(query))
|
|
270
248
|
return response.recordset || [{ created: true }]
|
|
271
249
|
}
|
|
272
250
|
|
|
273
251
|
async update(query: SqlQuery | string) {
|
|
274
252
|
await this.connect()
|
|
275
|
-
const response = await this.
|
|
253
|
+
const response = await internalQuery(this.client, getSqlQuery(query))
|
|
276
254
|
return response.recordset || [{ updated: true }]
|
|
277
255
|
}
|
|
278
256
|
|
|
279
257
|
async delete(query: SqlQuery | string) {
|
|
280
258
|
await this.connect()
|
|
281
|
-
const response = await this.
|
|
259
|
+
const response = await internalQuery(this.client, getSqlQuery(query))
|
|
282
260
|
return response.recordset || [{ deleted: true }]
|
|
283
261
|
}
|
|
284
262
|
|
|
285
263
|
async query(json: QueryJson) {
|
|
286
|
-
const schema = this.config.schema
|
|
287
264
|
await this.connect()
|
|
288
|
-
if (schema && schema !== DEFAULT_SCHEMA && json?.endpoint) {
|
|
289
|
-
json.endpoint.schema = schema
|
|
290
|
-
}
|
|
291
265
|
const operation = this._operation(json)
|
|
292
|
-
const queryFn = (query: any, op: string) =>
|
|
266
|
+
const queryFn = (query: any, op: string) =>
|
|
267
|
+
internalQuery(this.client, query, op)
|
|
293
268
|
const processFn = (result: any) =>
|
|
294
269
|
result.recordset ? result.recordset : [{ [operation]: true }]
|
|
295
270
|
return this.queryWithReturning(json, queryFn, processFn)
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
DatasourceFieldTypes,
|
|
3
2
|
Integration,
|
|
4
|
-
|
|
5
|
-
QueryJson,
|
|
3
|
+
DatasourceFieldTypes,
|
|
6
4
|
QueryTypes,
|
|
7
5
|
SqlQuery,
|
|
6
|
+
QueryJson,
|
|
7
|
+
Operation,
|
|
8
8
|
} from "../definitions/datasource"
|
|
9
9
|
import {
|
|
10
|
-
buildExternalTableId,
|
|
11
|
-
convertSqlType,
|
|
12
10
|
finaliseExternalTables,
|
|
13
11
|
getSqlQuery,
|
|
12
|
+
buildExternalTableId,
|
|
13
|
+
convertSqlType,
|
|
14
14
|
SqlClients,
|
|
15
15
|
} from "./utils"
|
|
16
16
|
import oracledb, {
|
|
17
|
-
BindParameters,
|
|
18
|
-
Connection,
|
|
19
|
-
ConnectionAttributes,
|
|
20
17
|
ExecuteOptions,
|
|
21
18
|
Result,
|
|
19
|
+
Connection,
|
|
20
|
+
ConnectionAttributes,
|
|
21
|
+
BindParameters,
|
|
22
22
|
} from "oracledb"
|
|
23
23
|
import Sql from "./base/sql"
|
|
24
24
|
import { Table } from "../definitions/common"
|
|
@@ -137,7 +137,6 @@ module OracleModule {
|
|
|
137
137
|
|
|
138
138
|
class OracleIntegration extends Sql implements DatasourcePlus {
|
|
139
139
|
private readonly config: OracleConfig
|
|
140
|
-
private index: number = 1
|
|
141
140
|
|
|
142
141
|
public tables: Record<string, Table> = {}
|
|
143
142
|
public schemaErrors: Record<string, string> = {}
|
|
@@ -175,10 +174,6 @@ module OracleModule {
|
|
|
175
174
|
this.config = config
|
|
176
175
|
}
|
|
177
176
|
|
|
178
|
-
getBindingIdentifier(): string {
|
|
179
|
-
return `:${this.index++}`
|
|
180
|
-
}
|
|
181
|
-
|
|
182
177
|
/**
|
|
183
178
|
* Map the flat tabular columns and constraints data into a nested object
|
|
184
179
|
*/
|
|
@@ -238,14 +233,20 @@ module OracleModule {
|
|
|
238
233
|
return oracleTables
|
|
239
234
|
}
|
|
240
235
|
|
|
241
|
-
private
|
|
242
|
-
|
|
236
|
+
private isSupportedColumn(column: OracleColumn) {
|
|
237
|
+
if (UNSUPPORTED_TYPES.includes(column.type)) {
|
|
238
|
+
return false
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return true
|
|
243
242
|
}
|
|
244
243
|
|
|
245
|
-
private
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
private isAutoColumn(column: OracleColumn) {
|
|
245
|
+
if (column.default && column.default.toLowerCase().includes("nextval")) {
|
|
246
|
+
return true
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return false
|
|
249
250
|
}
|
|
250
251
|
|
|
251
252
|
/**
|
|
@@ -253,7 +254,7 @@ module OracleModule {
|
|
|
253
254
|
* This matches the default behaviour for generating DDL used in knex.
|
|
254
255
|
*/
|
|
255
256
|
private isBooleanType(column: OracleColumn): boolean {
|
|
256
|
-
|
|
257
|
+
if (
|
|
257
258
|
column.type.toLowerCase() === "number" &&
|
|
258
259
|
Object.values(column.constraints).filter(c => {
|
|
259
260
|
if (
|
|
@@ -272,7 +273,11 @@ module OracleModule {
|
|
|
272
273
|
}
|
|
273
274
|
return false
|
|
274
275
|
}).length > 0
|
|
275
|
-
)
|
|
276
|
+
) {
|
|
277
|
+
return true
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return false
|
|
276
281
|
}
|
|
277
282
|
|
|
278
283
|
private internalConvertType(column: OracleColumn): string {
|
|
@@ -312,9 +317,7 @@ module OracleModule {
|
|
|
312
317
|
// iterate each column on the table
|
|
313
318
|
Object.values(oracleTable.columns)
|
|
314
319
|
// remove columns that we can't read / save
|
|
315
|
-
.filter(oracleColumn =>
|
|
316
|
-
OracleIntegration.isSupportedColumn(oracleColumn)
|
|
317
|
-
)
|
|
320
|
+
.filter(oracleColumn => this.isSupportedColumn(oracleColumn))
|
|
318
321
|
// match the order of the columns in the db
|
|
319
322
|
.sort((c1, c2) => c1.id - c2.id)
|
|
320
323
|
.forEach(oracleColumn => {
|
|
@@ -322,7 +325,7 @@ module OracleModule {
|
|
|
322
325
|
let fieldSchema = table.schema[columnName]
|
|
323
326
|
if (!fieldSchema) {
|
|
324
327
|
fieldSchema = {
|
|
325
|
-
autocolumn:
|
|
328
|
+
autocolumn: this.isAutoColumn(oracleColumn),
|
|
326
329
|
name: columnName,
|
|
327
330
|
type: this.internalConvertType(oracleColumn),
|
|
328
331
|
}
|
|
@@ -348,13 +351,18 @@ module OracleModule {
|
|
|
348
351
|
private async internalQuery<T>(query: SqlQuery): Promise<Result<T>> {
|
|
349
352
|
let connection
|
|
350
353
|
try {
|
|
351
|
-
this.index = 1
|
|
352
354
|
connection = await this.getConnection()
|
|
353
355
|
|
|
354
356
|
const options: ExecuteOptions = { autoCommit: true }
|
|
355
357
|
const bindings: BindParameters = query.bindings || []
|
|
356
358
|
|
|
357
|
-
|
|
359
|
+
const result: Result<T> = await connection.execute<T>(
|
|
360
|
+
query.sql,
|
|
361
|
+
bindings,
|
|
362
|
+
options
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
return result
|
|
358
366
|
} finally {
|
|
359
367
|
if (connection) {
|
|
360
368
|
try {
|
|
@@ -103,11 +103,30 @@ module PostgresModule {
|
|
|
103
103
|
},
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
async function internalQuery(client: any, query: SqlQuery) {
|
|
107
|
+
// need to handle a specific issue with json data types in postgres,
|
|
108
|
+
// new lines inside the JSON data will break it
|
|
109
|
+
if (query && query.sql) {
|
|
110
|
+
const matches = query.sql.match(JSON_REGEX)
|
|
111
|
+
if (matches && matches.length > 0) {
|
|
112
|
+
for (let match of matches) {
|
|
113
|
+
const escaped = escapeDangerousCharacters(match)
|
|
114
|
+
query.sql = query.sql.replace(match, escaped)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
return await client.query(query.sql, query.bindings || [])
|
|
120
|
+
} catch (err) {
|
|
121
|
+
// @ts-ignore
|
|
122
|
+
throw new Error(err)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
106
126
|
class PostgresIntegration extends Sql implements DatasourcePlus {
|
|
107
127
|
static pool: any
|
|
108
128
|
private readonly client: any
|
|
109
129
|
private readonly config: PostgresConfig
|
|
110
|
-
private index: number = 1
|
|
111
130
|
public tables: Record<string, Table> = {}
|
|
112
131
|
public schemaErrors: Record<string, string> = {}
|
|
113
132
|
|
|
@@ -144,32 +163,6 @@ module PostgresModule {
|
|
|
144
163
|
this.setSchema()
|
|
145
164
|
}
|
|
146
165
|
|
|
147
|
-
getBindingIdentifier(): string {
|
|
148
|
-
return `$${this.index++}`
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
async internalQuery(query: SqlQuery) {
|
|
152
|
-
const client = this.client
|
|
153
|
-
this.index = 1
|
|
154
|
-
// need to handle a specific issue with json data types in postgres,
|
|
155
|
-
// new lines inside the JSON data will break it
|
|
156
|
-
if (query && query.sql) {
|
|
157
|
-
const matches = query.sql.match(JSON_REGEX)
|
|
158
|
-
if (matches && matches.length > 0) {
|
|
159
|
-
for (let match of matches) {
|
|
160
|
-
const escaped = escapeDangerousCharacters(match)
|
|
161
|
-
query.sql = query.sql.replace(match, escaped)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
try {
|
|
166
|
-
return await client.query(query.sql, query.bindings || [])
|
|
167
|
-
} catch (err) {
|
|
168
|
-
// @ts-ignore
|
|
169
|
-
throw new Error(err)
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
166
|
setSchema() {
|
|
174
167
|
if (!this.config.schema) {
|
|
175
168
|
this.config.schema = "public"
|
|
@@ -248,22 +241,22 @@ module PostgresModule {
|
|
|
248
241
|
}
|
|
249
242
|
|
|
250
243
|
async create(query: SqlQuery | string) {
|
|
251
|
-
const response = await this.
|
|
244
|
+
const response = await internalQuery(this.client, getSqlQuery(query))
|
|
252
245
|
return response.rows.length ? response.rows : [{ created: true }]
|
|
253
246
|
}
|
|
254
247
|
|
|
255
248
|
async read(query: SqlQuery | string) {
|
|
256
|
-
const response = await this.
|
|
249
|
+
const response = await internalQuery(this.client, getSqlQuery(query))
|
|
257
250
|
return response.rows
|
|
258
251
|
}
|
|
259
252
|
|
|
260
253
|
async update(query: SqlQuery | string) {
|
|
261
|
-
const response = await this.
|
|
254
|
+
const response = await internalQuery(this.client, getSqlQuery(query))
|
|
262
255
|
return response.rows.length ? response.rows : [{ updated: true }]
|
|
263
256
|
}
|
|
264
257
|
|
|
265
258
|
async delete(query: SqlQuery | string) {
|
|
266
|
-
const response = await this.
|
|
259
|
+
const response = await internalQuery(this.client, getSqlQuery(query))
|
|
267
260
|
return response.rows.length ? response.rows : [{ deleted: true }]
|
|
268
261
|
}
|
|
269
262
|
|
|
@@ -273,11 +266,11 @@ module PostgresModule {
|
|
|
273
266
|
if (Array.isArray(input)) {
|
|
274
267
|
const responses = []
|
|
275
268
|
for (let query of input) {
|
|
276
|
-
responses.push(await this.
|
|
269
|
+
responses.push(await internalQuery(this.client, query))
|
|
277
270
|
}
|
|
278
271
|
return responses
|
|
279
272
|
} else {
|
|
280
|
-
const response = await this.
|
|
273
|
+
const response = await internalQuery(this.client, input)
|
|
281
274
|
return response.rows.length ? response.rows : [{ [operation]: true }]
|
|
282
275
|
}
|
|
283
276
|
}
|
|
@@ -6,63 +6,35 @@ import { FieldTypes, BuildSchemaErrors, InvalidColumns } from "../constants"
|
|
|
6
6
|
const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`
|
|
7
7
|
const ROW_ID_REGEX = /^\[.*]$/g
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const SQL_TYPE_MAP = {
|
|
10
|
+
text: FieldTypes.LONGFORM,
|
|
11
|
+
varchar: FieldTypes.STRING,
|
|
10
12
|
integer: FieldTypes.NUMBER,
|
|
11
|
-
int: FieldTypes.NUMBER,
|
|
12
13
|
bigint: FieldTypes.NUMBER,
|
|
13
14
|
decimal: FieldTypes.NUMBER,
|
|
14
15
|
smallint: FieldTypes.NUMBER,
|
|
15
16
|
real: FieldTypes.NUMBER,
|
|
17
|
+
"double precision": FieldTypes.NUMBER,
|
|
18
|
+
timestamp: FieldTypes.DATETIME,
|
|
19
|
+
time: FieldTypes.DATETIME,
|
|
20
|
+
boolean: FieldTypes.BOOLEAN,
|
|
21
|
+
json: FieldTypes.JSON,
|
|
22
|
+
date: FieldTypes.DATETIME,
|
|
23
|
+
blob: FieldTypes.LONGFORM,
|
|
24
|
+
enum: FieldTypes.STRING,
|
|
16
25
|
float: FieldTypes.NUMBER,
|
|
26
|
+
int: FieldTypes.NUMBER,
|
|
17
27
|
numeric: FieldTypes.NUMBER,
|
|
18
28
|
mediumint: FieldTypes.NUMBER,
|
|
19
29
|
dec: FieldTypes.NUMBER,
|
|
20
30
|
double: FieldTypes.NUMBER,
|
|
21
31
|
fixed: FieldTypes.NUMBER,
|
|
22
|
-
|
|
32
|
+
datetime: FieldTypes.DATETIME,
|
|
33
|
+
tinyint: FieldTypes.BOOLEAN,
|
|
34
|
+
long: FieldTypes.LONGFORM,
|
|
23
35
|
number: FieldTypes.NUMBER,
|
|
24
36
|
binary_float: FieldTypes.NUMBER,
|
|
25
37
|
binary_double: FieldTypes.NUMBER,
|
|
26
|
-
money: FieldTypes.NUMBER,
|
|
27
|
-
smallmoney: FieldTypes.NUMBER,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const SQL_DATE_TYPE_MAP = {
|
|
31
|
-
timestamp: FieldTypes.DATETIME,
|
|
32
|
-
time: FieldTypes.DATETIME,
|
|
33
|
-
datetime: FieldTypes.DATETIME,
|
|
34
|
-
smalldatetime: FieldTypes.DATETIME,
|
|
35
|
-
date: FieldTypes.DATETIME,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const SQL_STRING_TYPE_MAP = {
|
|
39
|
-
varchar: FieldTypes.STRING,
|
|
40
|
-
char: FieldTypes.STRING,
|
|
41
|
-
nchar: FieldTypes.STRING,
|
|
42
|
-
nvarchar: FieldTypes.STRING,
|
|
43
|
-
ntext: FieldTypes.STRING,
|
|
44
|
-
enum: FieldTypes.STRING,
|
|
45
|
-
blob: FieldTypes.LONGFORM,
|
|
46
|
-
long: FieldTypes.LONGFORM,
|
|
47
|
-
text: FieldTypes.LONGFORM,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const SQL_BOOLEAN_TYPE_MAP = {
|
|
51
|
-
boolean: FieldTypes.BOOLEAN,
|
|
52
|
-
bit: FieldTypes.BOOLEAN,
|
|
53
|
-
tinyint: FieldTypes.BOOLEAN,
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const SQL_MISC_TYPE_MAP = {
|
|
57
|
-
json: FieldTypes.JSON,
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const SQL_TYPE_MAP = {
|
|
61
|
-
...SQL_NUMBER_TYPE_MAP,
|
|
62
|
-
...SQL_DATE_TYPE_MAP,
|
|
63
|
-
...SQL_STRING_TYPE_MAP,
|
|
64
|
-
...SQL_BOOLEAN_TYPE_MAP,
|
|
65
|
-
...SQL_MISC_TYPE_MAP,
|
|
66
38
|
}
|
|
67
39
|
|
|
68
40
|
export enum SqlClients {
|
|
@@ -25,8 +25,6 @@ const { createASession } = require("@budibase/backend-core/sessions")
|
|
|
25
25
|
const { user: userCache } = require("@budibase/backend-core/cache")
|
|
26
26
|
const newid = require("../../db/newid")
|
|
27
27
|
const context = require("@budibase/backend-core/context")
|
|
28
|
-
const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db")
|
|
29
|
-
const { encrypt } = require("@budibase/backend-core/encryption")
|
|
30
28
|
|
|
31
29
|
const GLOBAL_USER_ID = "us_uuid1"
|
|
32
30
|
const EMAIL = "babs@babs.com"
|
|
@@ -49,10 +47,6 @@ class TestConfiguration {
|
|
|
49
47
|
return this.request
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
getApp() {
|
|
53
|
-
return this.app
|
|
54
|
-
}
|
|
55
|
-
|
|
56
50
|
getAppId() {
|
|
57
51
|
return this.appId
|
|
58
52
|
}
|
|
@@ -89,20 +83,6 @@ class TestConfiguration {
|
|
|
89
83
|
}
|
|
90
84
|
}
|
|
91
85
|
|
|
92
|
-
async generateApiKey(userId = GLOBAL_USER_ID) {
|
|
93
|
-
const db = getGlobalDB(TENANT_ID)
|
|
94
|
-
const id = generateDevInfoID(userId)
|
|
95
|
-
let devInfo
|
|
96
|
-
try {
|
|
97
|
-
devInfo = await db.get(id)
|
|
98
|
-
} catch (err) {
|
|
99
|
-
devInfo = { _id: id, userId }
|
|
100
|
-
}
|
|
101
|
-
devInfo.apiKey = encrypt(`${TENANT_ID}${SEPARATOR}${newid()}`)
|
|
102
|
-
await db.put(devInfo)
|
|
103
|
-
return devInfo.apiKey
|
|
104
|
-
}
|
|
105
|
-
|
|
106
86
|
async globalUser({
|
|
107
87
|
id = GLOBAL_USER_ID,
|
|
108
88
|
builder = true,
|
|
@@ -155,7 +135,7 @@ class TestConfiguration {
|
|
|
155
135
|
cleanup(this.allApps.map(app => app.appId))
|
|
156
136
|
}
|
|
157
137
|
|
|
158
|
-
defaultHeaders(
|
|
138
|
+
defaultHeaders() {
|
|
159
139
|
const auth = {
|
|
160
140
|
userId: GLOBAL_USER_ID,
|
|
161
141
|
sessionId: "sessionid",
|
|
@@ -174,7 +154,6 @@ class TestConfiguration {
|
|
|
174
154
|
`${Cookies.CurrentApp}=${appToken}`,
|
|
175
155
|
],
|
|
176
156
|
[Headers.CSRF_TOKEN]: CSRF_TOKEN,
|
|
177
|
-
...extras,
|
|
178
157
|
}
|
|
179
158
|
if (this.appId) {
|
|
180
159
|
headers[Headers.APP_ID] = this.appId
|
|
@@ -247,7 +226,7 @@ class TestConfiguration {
|
|
|
247
226
|
|
|
248
227
|
async getTable(tableId = null) {
|
|
249
228
|
tableId = tableId || this.table._id
|
|
250
|
-
return this._req(null, { tableId }, controllers.table.find)
|
|
229
|
+
return this._req(null, { id: tableId }, controllers.table.find)
|
|
251
230
|
}
|
|
252
231
|
|
|
253
232
|
async createLinkedTable(relationshipType = null, links = ["link"]) {
|