@budibase/server 1.3.15-alpha.0 → 1.3.15
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.3953692d.js +876 -0
- package/builder/assets/{index.f5c54dd2.css → index.a70e216a.css} +2 -2
- 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 +254 -296
- package/coverage/coverage-final.json +17 -17
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- 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 +13 -82
- package/coverage/lcov-report/api/controllers/datasource.js.html +20 -20
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +30 -30
- 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 +1 -1
- 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 -204
- 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 +12 -12
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- 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 +1 -1
- 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 +28 -28
- 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 +33 -33
- package/coverage/lcov-report/middleware/index.html +1 -1
- 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 +445 -533
- package/dist/api/controllers/application.js +4 -5
- package/dist/api/controllers/component.js +1 -18
- package/dist/api/controllers/datasource.js +4 -4
- package/dist/api/controllers/integration.js +4 -4
- package/dist/api/controllers/screen.js +2 -51
- 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 -3
- package/dist/api/routes/index.js +0 -2
- package/dist/app.js +0 -9
- package/dist/db/utils.js +1 -10
- package/dist/environment.js +2 -3
- 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/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 -93
- 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/package.json +0 -2
- package/dist/threads/query.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +10 -66
- package/package.json +6 -8
- package/scripts/dev/manage.js +0 -1
- package/src/api/controllers/application.ts +1 -1
- package/src/api/controllers/component.js +2 -25
- package/src/api/controllers/datasource.js +4 -4
- package/src/api/controllers/integration.js +4 -4
- package/src/api/controllers/screen.js +1 -65
- package/src/api/controllers/static/index.ts +0 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +0 -10
- package/src/api/controllers/static/templates/preview.hbs +1 -3
- package/src/api/routes/index.ts +0 -2
- package/src/api/routes/tests/query.spec.js +25 -8
- package/src/app.ts +0 -12
- package/src/db/utils.js +0 -12
- package/src/environment.js +2 -3
- 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/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 -59
- 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/module.d.ts +0 -1
- package/src/threads/query.ts +2 -2
- package/src/utilities/fileSystem/index.js +9 -70
- package/builder/assets/index.b266d29f.js +0 -995
- package/dist/api/controllers/plugin.js +0 -119
- package/dist/api/routes/plugin.js +0 -38
- package/dist/watch.js +0 -77
- package/src/api/controllers/plugin.ts +0 -110
- package/src/api/routes/plugin.ts +0 -13
- package/src/watch.ts +0 -38
|
@@ -17,342 +17,346 @@ const utils_1 = require("./utils");
|
|
|
17
17
|
const oracledb_1 = __importDefault(require("oracledb"));
|
|
18
18
|
const sql_1 = __importDefault(require("./base/sql"));
|
|
19
19
|
const constants_1 = require("../constants");
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
var OracleModule;
|
|
21
|
+
(function (OracleModule) {
|
|
22
|
+
oracledb_1.default.outFormat = oracledb_1.default.OUT_FORMAT_OBJECT;
|
|
23
|
+
const SCHEMA = {
|
|
24
|
+
docs: "https://github.com/oracle/node-oracledb",
|
|
25
|
+
plus: true,
|
|
26
|
+
friendlyName: "Oracle",
|
|
27
|
+
type: "Relational",
|
|
28
|
+
description: "Oracle Database is an object-relational database management system developed by Oracle Corporation",
|
|
29
|
+
datasource: {
|
|
30
|
+
host: {
|
|
31
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
32
|
+
default: "localhost",
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
port: {
|
|
36
|
+
type: types_1.DatasourceFieldType.NUMBER,
|
|
37
|
+
required: true,
|
|
38
|
+
default: 1521,
|
|
39
|
+
},
|
|
40
|
+
database: {
|
|
41
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
42
|
+
required: true,
|
|
43
|
+
},
|
|
44
|
+
user: {
|
|
45
|
+
type: types_1.DatasourceFieldType.STRING,
|
|
46
|
+
required: true,
|
|
47
|
+
},
|
|
48
|
+
password: {
|
|
49
|
+
type: types_1.DatasourceFieldType.PASSWORD,
|
|
50
|
+
required: true,
|
|
51
|
+
},
|
|
32
52
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
query: {
|
|
54
|
+
create: {
|
|
55
|
+
type: types_1.QueryType.SQL,
|
|
56
|
+
},
|
|
57
|
+
read: {
|
|
58
|
+
type: types_1.QueryType.SQL,
|
|
59
|
+
},
|
|
60
|
+
update: {
|
|
61
|
+
type: types_1.QueryType.SQL,
|
|
62
|
+
},
|
|
63
|
+
delete: {
|
|
64
|
+
type: types_1.QueryType.SQL,
|
|
65
|
+
},
|
|
37
66
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
getBindingIdentifier() {
|
|
120
|
-
return `:${this.index++}`;
|
|
121
|
-
}
|
|
122
|
-
getStringConcat(parts) {
|
|
123
|
-
return parts.join(" || ");
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Map the flat tabular columns and constraints data into a nested object
|
|
127
|
-
*/
|
|
128
|
-
mapColumns(result) {
|
|
129
|
-
const oracleTables = {};
|
|
130
|
-
if (result.rows) {
|
|
131
|
-
result.rows.forEach(row => {
|
|
132
|
-
const tableName = row.TABLE_NAME;
|
|
133
|
-
const columnName = row.COLUMN_NAME;
|
|
134
|
-
const dataType = row.DATA_TYPE;
|
|
135
|
-
const dataDefault = row.DATA_DEFAULT;
|
|
136
|
-
const columnId = row.COLUMN_ID;
|
|
137
|
-
const constraintName = row.CONSTRAINT_NAME;
|
|
138
|
-
const constraintType = row.CONSTRAINT_TYPE;
|
|
139
|
-
const relatedConstraintName = row.R_CONSTRAINT_NAME;
|
|
140
|
-
const searchCondition = row.SEARCH_CONDITION;
|
|
141
|
-
let table = oracleTables[tableName];
|
|
142
|
-
if (!table) {
|
|
143
|
-
table = {
|
|
144
|
-
name: tableName,
|
|
145
|
-
columns: {},
|
|
146
|
-
};
|
|
147
|
-
oracleTables[tableName] = table;
|
|
148
|
-
}
|
|
149
|
-
let column = table.columns[columnName];
|
|
150
|
-
if (!column) {
|
|
151
|
-
column = {
|
|
152
|
-
name: columnName,
|
|
153
|
-
type: dataType,
|
|
154
|
-
default: dataDefault,
|
|
155
|
-
id: columnId,
|
|
156
|
-
constraints: {},
|
|
157
|
-
};
|
|
158
|
-
table.columns[columnName] = column;
|
|
159
|
-
}
|
|
160
|
-
if (constraintName && constraintType) {
|
|
161
|
-
let constraint = column.constraints[constraintName];
|
|
162
|
-
if (!constraint) {
|
|
163
|
-
constraint = {
|
|
164
|
-
name: constraintName,
|
|
165
|
-
type: constraintType,
|
|
166
|
-
relatedConstraintName: relatedConstraintName,
|
|
167
|
-
searchCondition: searchCondition,
|
|
67
|
+
};
|
|
68
|
+
const UNSUPPORTED_TYPES = ["BLOB", "CLOB", "NCLOB"];
|
|
69
|
+
const OracleContraintTypes = {
|
|
70
|
+
PRIMARY: "P",
|
|
71
|
+
NOT_NULL_OR_CHECK: "C",
|
|
72
|
+
FOREIGN_KEY: "R",
|
|
73
|
+
UNIQUE: "U",
|
|
74
|
+
};
|
|
75
|
+
class OracleIntegration extends sql_1.default {
|
|
76
|
+
constructor(config) {
|
|
77
|
+
super(utils_1.SqlClient.ORACLE);
|
|
78
|
+
this.index = 1;
|
|
79
|
+
this.tables = {};
|
|
80
|
+
this.schemaErrors = {};
|
|
81
|
+
this.COLUMNS_SQL = `
|
|
82
|
+
SELECT
|
|
83
|
+
tabs.table_name,
|
|
84
|
+
cols.column_name,
|
|
85
|
+
cols.data_type,
|
|
86
|
+
cols.data_default,
|
|
87
|
+
cols.column_id,
|
|
88
|
+
cons.constraint_name,
|
|
89
|
+
cons.constraint_type,
|
|
90
|
+
cons.r_constraint_name,
|
|
91
|
+
cons.search_condition
|
|
92
|
+
FROM
|
|
93
|
+
user_tables tabs
|
|
94
|
+
JOIN
|
|
95
|
+
user_tab_columns cols
|
|
96
|
+
ON tabs.table_name = cols.table_name
|
|
97
|
+
LEFT JOIN
|
|
98
|
+
user_cons_columns col_cons
|
|
99
|
+
ON cols.column_name = col_cons.column_name
|
|
100
|
+
AND cols.table_name = col_cons.table_name
|
|
101
|
+
LEFT JOIN
|
|
102
|
+
user_constraints cons
|
|
103
|
+
ON col_cons.constraint_name = cons.constraint_name
|
|
104
|
+
AND cons.table_name = cols.table_name
|
|
105
|
+
WHERE
|
|
106
|
+
(cons.status = 'ENABLED'
|
|
107
|
+
OR cons.status IS NULL)
|
|
108
|
+
`;
|
|
109
|
+
this.getConnection = () => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
//connectString : "(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA =(SID= ORCL)))"
|
|
111
|
+
const connectString = `${this.config.host}:${this.config.port || 1521}/${this.config.database}`;
|
|
112
|
+
const attributes = {
|
|
113
|
+
user: this.config.user,
|
|
114
|
+
password: this.config.password,
|
|
115
|
+
connectString,
|
|
116
|
+
};
|
|
117
|
+
return oracledb_1.default.getConnection(attributes);
|
|
118
|
+
});
|
|
119
|
+
this.config = config;
|
|
120
|
+
}
|
|
121
|
+
getBindingIdentifier() {
|
|
122
|
+
return `:${this.index++}`;
|
|
123
|
+
}
|
|
124
|
+
getStringConcat(parts) {
|
|
125
|
+
return parts.join(" || ");
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Map the flat tabular columns and constraints data into a nested object
|
|
129
|
+
*/
|
|
130
|
+
mapColumns(result) {
|
|
131
|
+
const oracleTables = {};
|
|
132
|
+
if (result.rows) {
|
|
133
|
+
result.rows.forEach(row => {
|
|
134
|
+
const tableName = row.TABLE_NAME;
|
|
135
|
+
const columnName = row.COLUMN_NAME;
|
|
136
|
+
const dataType = row.DATA_TYPE;
|
|
137
|
+
const dataDefault = row.DATA_DEFAULT;
|
|
138
|
+
const columnId = row.COLUMN_ID;
|
|
139
|
+
const constraintName = row.CONSTRAINT_NAME;
|
|
140
|
+
const constraintType = row.CONSTRAINT_TYPE;
|
|
141
|
+
const relatedConstraintName = row.R_CONSTRAINT_NAME;
|
|
142
|
+
const searchCondition = row.SEARCH_CONDITION;
|
|
143
|
+
let table = oracleTables[tableName];
|
|
144
|
+
if (!table) {
|
|
145
|
+
table = {
|
|
146
|
+
name: tableName,
|
|
147
|
+
columns: {},
|
|
168
148
|
};
|
|
149
|
+
oracleTables[tableName] = table;
|
|
169
150
|
}
|
|
170
|
-
column.
|
|
171
|
-
|
|
172
|
-
|
|
151
|
+
let column = table.columns[columnName];
|
|
152
|
+
if (!column) {
|
|
153
|
+
column = {
|
|
154
|
+
name: columnName,
|
|
155
|
+
type: dataType,
|
|
156
|
+
default: dataDefault,
|
|
157
|
+
id: columnId,
|
|
158
|
+
constraints: {},
|
|
159
|
+
};
|
|
160
|
+
table.columns[columnName] = column;
|
|
161
|
+
}
|
|
162
|
+
if (constraintName && constraintType) {
|
|
163
|
+
let constraint = column.constraints[constraintName];
|
|
164
|
+
if (!constraint) {
|
|
165
|
+
constraint = {
|
|
166
|
+
name: constraintName,
|
|
167
|
+
type: constraintType,
|
|
168
|
+
relatedConstraintName: relatedConstraintName,
|
|
169
|
+
searchCondition: searchCondition,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
column.constraints[constraintName] = constraint;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return oracleTables;
|
|
173
177
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
178
|
+
static isSupportedColumn(column) {
|
|
179
|
+
return !UNSUPPORTED_TYPES.includes(column.type);
|
|
180
|
+
}
|
|
181
|
+
static isAutoColumn(column) {
|
|
182
|
+
return !!(column.default && column.default.toLowerCase().includes("nextval"));
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* No native boolean in oracle. Best we can do is to check if a manual 1 or 0 number constraint has been set up
|
|
186
|
+
* This matches the default behaviour for generating DDL used in knex.
|
|
187
|
+
*/
|
|
188
|
+
isBooleanType(column) {
|
|
189
|
+
return (column.type.toLowerCase() === "number" &&
|
|
190
|
+
Object.values(column.constraints).filter(c => {
|
|
191
|
+
if (c.type === OracleContraintTypes.NOT_NULL_OR_CHECK &&
|
|
192
|
+
c.searchCondition) {
|
|
193
|
+
const condition = c.searchCondition
|
|
194
|
+
.replace(/\s/g, "") // remove spaces
|
|
195
|
+
.replace(/[']+/g, ""); // remove quotes
|
|
196
|
+
if (condition.includes("in(0,1)") ||
|
|
197
|
+
condition.includes("in(1,0)")) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
196
200
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}).length > 0);
|
|
200
|
-
}
|
|
201
|
-
internalConvertType(column) {
|
|
202
|
-
if (this.isBooleanType(column)) {
|
|
203
|
-
return { type: constants_1.FieldTypes.BOOLEAN };
|
|
201
|
+
return false;
|
|
202
|
+
}).length > 0);
|
|
204
203
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
.filter(oracleColumn => OracleIntegration.isSupportedColumn(oracleColumn))
|
|
235
|
-
// match the order of the columns in the db
|
|
236
|
-
.sort((c1, c2) => c1.id - c2.id)
|
|
237
|
-
.forEach(oracleColumn => {
|
|
238
|
-
const columnName = oracleColumn.name;
|
|
239
|
-
let fieldSchema = table.schema[columnName];
|
|
240
|
-
if (!fieldSchema) {
|
|
241
|
-
fieldSchema = Object.assign({ autocolumn: OracleIntegration.isAutoColumn(oracleColumn), name: columnName }, this.internalConvertType(oracleColumn));
|
|
242
|
-
table.schema[columnName] = fieldSchema;
|
|
204
|
+
internalConvertType(column) {
|
|
205
|
+
if (this.isBooleanType(column)) {
|
|
206
|
+
return { type: constants_1.FieldTypes.BOOLEAN };
|
|
207
|
+
}
|
|
208
|
+
return (0, utils_1.convertSqlType)(column.type);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Fetches the tables from the oracle table and assigns them to the datasource.
|
|
212
|
+
* @param {*} datasourceId - datasourceId to fetch
|
|
213
|
+
* @param entities - the tables that are to be built
|
|
214
|
+
*/
|
|
215
|
+
buildSchema(datasourceId, entities) {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
const columnsResponse = yield this.internalQuery({
|
|
218
|
+
sql: this.COLUMNS_SQL,
|
|
219
|
+
});
|
|
220
|
+
const oracleTables = this.mapColumns(columnsResponse);
|
|
221
|
+
const tables = {};
|
|
222
|
+
// iterate each table
|
|
223
|
+
Object.values(oracleTables).forEach(oracleTable => {
|
|
224
|
+
let table = tables[oracleTable.name];
|
|
225
|
+
if (!table) {
|
|
226
|
+
table = {
|
|
227
|
+
_id: (0, utils_1.buildExternalTableId)(datasourceId, oracleTable.name),
|
|
228
|
+
primary: [],
|
|
229
|
+
name: oracleTable.name,
|
|
230
|
+
schema: {},
|
|
231
|
+
};
|
|
232
|
+
tables[oracleTable.name] = table;
|
|
243
233
|
}
|
|
244
|
-
// iterate each
|
|
245
|
-
Object.values(
|
|
246
|
-
|
|
247
|
-
|
|
234
|
+
// iterate each column on the table
|
|
235
|
+
Object.values(oracleTable.columns)
|
|
236
|
+
// remove columns that we can't read / save
|
|
237
|
+
.filter(oracleColumn => OracleIntegration.isSupportedColumn(oracleColumn))
|
|
238
|
+
// match the order of the columns in the db
|
|
239
|
+
.sort((c1, c2) => c1.id - c2.id)
|
|
240
|
+
.forEach(oracleColumn => {
|
|
241
|
+
const columnName = oracleColumn.name;
|
|
242
|
+
let fieldSchema = table.schema[columnName];
|
|
243
|
+
if (!fieldSchema) {
|
|
244
|
+
fieldSchema = Object.assign({ autocolumn: OracleIntegration.isAutoColumn(oracleColumn), name: columnName }, this.internalConvertType(oracleColumn));
|
|
245
|
+
table.schema[columnName] = fieldSchema;
|
|
248
246
|
}
|
|
247
|
+
// iterate each constraint on the column
|
|
248
|
+
Object.values(oracleColumn.constraints).forEach(oracleConstraint => {
|
|
249
|
+
if (oracleConstraint.type === OracleContraintTypes.PRIMARY) {
|
|
250
|
+
table.primary.push(columnName);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
249
253
|
});
|
|
250
254
|
});
|
|
255
|
+
const final = (0, utils_1.finaliseExternalTables)(tables, entities);
|
|
256
|
+
this.tables = final.tables;
|
|
257
|
+
this.schemaErrors = final.errors;
|
|
251
258
|
});
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
this
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
connection = yield this.getConnection();
|
|
263
|
-
const options = { autoCommit: true };
|
|
264
|
-
const bindings = query.bindings || [];
|
|
265
|
-
return yield connection.execute(query.sql, bindings, options);
|
|
266
|
-
}
|
|
267
|
-
finally {
|
|
268
|
-
if (connection) {
|
|
269
|
-
try {
|
|
270
|
-
yield connection.close();
|
|
271
|
-
}
|
|
272
|
-
catch (err) {
|
|
273
|
-
console.error(err);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
create(query) {
|
|
280
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
281
|
-
const response = yield this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
282
|
-
return response.rows && response.rows.length
|
|
283
|
-
? response.rows
|
|
284
|
-
: [{ created: true }];
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
read(query) {
|
|
288
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
289
|
-
const response = yield this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
290
|
-
return response.rows ? response.rows : [];
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
update(query) {
|
|
294
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
295
|
-
const response = yield this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
296
|
-
return response.rows && response.rows.length
|
|
297
|
-
? response.rows
|
|
298
|
-
: [{ updated: true }];
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
delete(query) {
|
|
302
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
-
const response = yield this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
304
|
-
return response.rows && response.rows.length
|
|
305
|
-
? response.rows
|
|
306
|
-
: [{ deleted: true }];
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
query(json) {
|
|
310
|
-
var _a, _b, _c;
|
|
311
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
312
|
-
const operation = this._operation(json);
|
|
313
|
-
const input = this._query(json, { disableReturning: true });
|
|
314
|
-
if (Array.isArray(input)) {
|
|
315
|
-
const responses = [];
|
|
316
|
-
for (let query of input) {
|
|
317
|
-
responses.push(yield this.internalQuery(query));
|
|
318
|
-
}
|
|
319
|
-
return responses;
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
// read the row to be deleted up front for the return
|
|
323
|
-
let deletedRows;
|
|
324
|
-
if (operation === types_1.Operation.DELETE) {
|
|
325
|
-
const queryFn = (query) => this.internalQuery(query);
|
|
326
|
-
deletedRows = yield this.getReturningRow(queryFn, json);
|
|
259
|
+
}
|
|
260
|
+
internalQuery(query) {
|
|
261
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
262
|
+
let connection;
|
|
263
|
+
try {
|
|
264
|
+
this.index = 1;
|
|
265
|
+
connection = yield this.getConnection();
|
|
266
|
+
const options = { autoCommit: true };
|
|
267
|
+
const bindings = query.bindings || [];
|
|
268
|
+
return yield connection.execute(query.sql, bindings, options);
|
|
327
269
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
270
|
+
finally {
|
|
271
|
+
if (connection) {
|
|
272
|
+
try {
|
|
273
|
+
yield connection.close();
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
console.error(err);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
333
279
|
}
|
|
334
|
-
|
|
335
|
-
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
create(query) {
|
|
283
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
284
|
+
const response = yield this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
285
|
+
return response.rows && response.rows.length
|
|
286
|
+
? response.rows
|
|
287
|
+
: [{ created: true }];
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
read(query) {
|
|
291
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
+
const response = yield this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
293
|
+
return response.rows ? response.rows : [];
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
update(query) {
|
|
297
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
298
|
+
const response = yield this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
299
|
+
return response.rows && response.rows.length
|
|
300
|
+
? response.rows
|
|
301
|
+
: [{ updated: true }];
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
delete(query) {
|
|
305
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
306
|
+
const response = yield this.internalQuery((0, utils_1.getSqlQuery)(query));
|
|
307
|
+
return response.rows && response.rows.length
|
|
308
|
+
? response.rows
|
|
309
|
+
: [{ deleted: true }];
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
query(json) {
|
|
313
|
+
var _a, _b, _c;
|
|
314
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
315
|
+
const operation = this._operation(json);
|
|
316
|
+
const input = this._query(json, { disableReturning: true });
|
|
317
|
+
if (Array.isArray(input)) {
|
|
318
|
+
const responses = [];
|
|
319
|
+
for (let query of input) {
|
|
320
|
+
responses.push(yield this.internalQuery(query));
|
|
321
|
+
}
|
|
322
|
+
return responses;
|
|
336
323
|
}
|
|
337
324
|
else {
|
|
338
|
-
//
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
325
|
+
// read the row to be deleted up front for the return
|
|
326
|
+
let deletedRows;
|
|
327
|
+
if (operation === types_1.Operation.DELETE) {
|
|
328
|
+
const queryFn = (query) => this.internalQuery(query);
|
|
329
|
+
deletedRows = yield this.getReturningRow(queryFn, json);
|
|
330
|
+
}
|
|
331
|
+
// run the query
|
|
332
|
+
const response = yield this.internalQuery(input);
|
|
333
|
+
// get the results or return the created / updated / deleted row
|
|
334
|
+
if ((_a = deletedRows === null || deletedRows === void 0 ? void 0 : deletedRows.rows) === null || _a === void 0 ? void 0 : _a.length) {
|
|
335
|
+
return deletedRows.rows;
|
|
336
|
+
}
|
|
337
|
+
else if ((_b = response.rows) === null || _b === void 0 ? void 0 : _b.length) {
|
|
338
|
+
return response.rows;
|
|
346
339
|
}
|
|
347
340
|
else {
|
|
348
|
-
|
|
341
|
+
// get the last row that was updated
|
|
342
|
+
if (response.lastRowid &&
|
|
343
|
+
((_c = json.endpoint) === null || _c === void 0 ? void 0 : _c.entityId) &&
|
|
344
|
+
operation !== types_1.Operation.DELETE) {
|
|
345
|
+
const lastRow = yield this.internalQuery({
|
|
346
|
+
sql: `SELECT * FROM \"${json.endpoint.entityId}\" WHERE ROWID = '${response.lastRowid}'`,
|
|
347
|
+
});
|
|
348
|
+
return lastRow.rows;
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
return [{ [operation.toLowerCase()]: true }];
|
|
352
|
+
}
|
|
349
353
|
}
|
|
350
354
|
}
|
|
351
|
-
}
|
|
352
|
-
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
353
357
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
};
|
|
358
|
+
module.exports = {
|
|
359
|
+
schema: SCHEMA,
|
|
360
|
+
integration: OracleIntegration,
|
|
361
|
+
};
|
|
362
|
+
})(OracleModule || (OracleModule = {}));
|