@budibase/server 0.9.185-alpha.13 → 0.9.185-alpha.17
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/Dockerfile +7 -1
- package/__mocks__/oracledb.ts +31 -0
- package/builder/assets/{index.4a7c5636.css → index.67ac3a72.css} +1 -1
- package/builder/assets/{index.dc495306.js → index.a8407653.js} +176 -175
- package/builder/assets/oracle.66592424.png +0 -0
- package/builder/index.html +2 -2
- package/coverage/clover.xml +239 -230
- package/coverage/coverage-final.json +7 -7
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.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 +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/hosting.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- 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/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query.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/index.js.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/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +29 -8
- package/coverage/lcov-report/api/controllers/table/index.html +13 -13
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/utils.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 +1 -1
- 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/application.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/hosting.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/index.js.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/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/row.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/static.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/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/createRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/deleteRow.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/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/automations/utils.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +22 -22
- 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/client.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- 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 +3 -3
- package/coverage/lcov-report/db/utils.js.html +57 -57
- 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 +23 -23
- 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/authorized.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- 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/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/threads/automation.js.html +14 -8
- package/coverage/lcov-report/threads/index.html +27 -27
- package/coverage/lcov-report/threads/index.js.html +29 -11
- package/coverage/lcov-report/threads/query.js.html +16 -7
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/utilities/statusCodes.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 +328 -309
- package/dist/api/controllers/table/external.js +8 -1
- package/dist/definitions/datasource.js +1 -0
- package/dist/environment.js +13 -0
- package/dist/integrations/base/sql.js +4 -0
- package/dist/integrations/index.js +6 -0
- package/dist/integrations/oracle.js +345 -0
- package/dist/integrations/utils.js +10 -1
- package/dist/package.json +8 -4
- package/dist/threads/automation.js +3 -1
- package/dist/threads/index.js +9 -3
- package/dist/threads/query.js +3 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -5
- package/scripts/dev/manage.js +1 -0
- package/scripts/integrations/oracle/docker-compose.yml +19 -0
- package/scripts/integrations/oracle/instantclient/linux/x86-64/basiclite-21.4.zip +0 -0
- package/scripts/integrations/oracle/instantclient/linux/x86-64/install.sh +23 -0
- package/scripts/integrations/oracle/oracle.md +90 -0
- package/scripts/integrations/postgres/docker-compose.yml +3 -3
- package/src/api/controllers/table/external.js +8 -1
- package/src/definitions/datasource.ts +1 -0
- package/src/environment.js +15 -0
- package/src/integrations/base/IntegrationBase.ts +4 -4
- package/src/integrations/base/sql.ts +3 -0
- package/src/integrations/index.ts +7 -0
- package/src/integrations/oracle.ts +445 -0
- package/src/integrations/tests/oracle.spec.js +94 -0
- package/src/integrations/utils.ts +10 -1
- package/src/threads/automation.js +3 -1
- package/src/threads/index.js +9 -3
- package/src/threads/query.js +3 -0
|
@@ -136,9 +136,13 @@ exports.save = function (ctx) {
|
|
|
136
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
137
|
const appId = ctx.appId;
|
|
138
138
|
const table = ctx.request.body;
|
|
139
|
-
// can't do this
|
|
139
|
+
// can't do this right now
|
|
140
140
|
delete table.dataImport;
|
|
141
141
|
const datasourceId = getDatasourceId(ctx.request.body);
|
|
142
|
+
// table doesn't exist already, note that it is created
|
|
143
|
+
if (!table._id) {
|
|
144
|
+
table.created = true;
|
|
145
|
+
}
|
|
142
146
|
let tableToSave = Object.assign({ type: "table", _id: buildExternalTableId(datasourceId, table.name) }, table);
|
|
143
147
|
let oldTable;
|
|
144
148
|
if (ctx.request.body && ctx.request.body._id) {
|
|
@@ -213,6 +217,9 @@ exports.destroy = function (ctx) {
|
|
|
213
217
|
return __awaiter(this, void 0, void 0, function* () {
|
|
214
218
|
const appId = ctx.appId;
|
|
215
219
|
const tableToDelete = yield getTable(appId, ctx.params.tableId);
|
|
220
|
+
if (!tableToDelete || !tableToDelete.created) {
|
|
221
|
+
ctx.throw(400, "Cannot delete tables which weren't created in Budibase.");
|
|
222
|
+
}
|
|
216
223
|
const datasourceId = getDatasourceId(tableToDelete);
|
|
217
224
|
const db = new CouchDB(appId);
|
|
218
225
|
const datasource = yield db.get(datasourceId);
|
|
@@ -48,6 +48,7 @@ var SourceNames;
|
|
|
48
48
|
SourceNames["MYSQL"] = "MYSQL";
|
|
49
49
|
SourceNames["ARANGODB"] = "ARANGODB";
|
|
50
50
|
SourceNames["REST"] = "REST";
|
|
51
|
+
SourceNames["ORACLE"] = "ORACLE";
|
|
51
52
|
})(SourceNames = exports.SourceNames || (exports.SourceNames = {}));
|
|
52
53
|
var IncludeRelationships;
|
|
53
54
|
(function (IncludeRelationships) {
|
package/dist/environment.js
CHANGED
|
@@ -16,6 +16,7 @@ if (!LOADED && isDev() && !isTest()) {
|
|
|
16
16
|
require("dotenv").config();
|
|
17
17
|
LOADED = true;
|
|
18
18
|
}
|
|
19
|
+
let inThread = false;
|
|
19
20
|
module.exports = {
|
|
20
21
|
// important
|
|
21
22
|
PORT: process.env.PORT,
|
|
@@ -55,6 +56,7 @@ module.exports = {
|
|
|
55
56
|
USERID_API_KEY: process.env.USERID_API_KEY,
|
|
56
57
|
DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
|
|
57
58
|
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
|
|
59
|
+
DISABLE_THREADING: process.env.DISABLE_THREADING,
|
|
58
60
|
_set(key, value) {
|
|
59
61
|
process.env[key] = value;
|
|
60
62
|
module.exports[key] = value;
|
|
@@ -65,7 +67,18 @@ module.exports = {
|
|
|
65
67
|
isProd: () => {
|
|
66
68
|
return !isDev();
|
|
67
69
|
},
|
|
70
|
+
// used to check if already in a thread, don't thread further
|
|
71
|
+
setInThread: () => {
|
|
72
|
+
inThread = true;
|
|
73
|
+
},
|
|
74
|
+
isInThread: () => {
|
|
75
|
+
return inThread;
|
|
76
|
+
},
|
|
68
77
|
};
|
|
78
|
+
// threading can cause memory issues with node-ts in development
|
|
79
|
+
if (isDev() && module.exports.DISABLE_THREADING == null) {
|
|
80
|
+
module.exports._set("DISABLE_THREADING", "1");
|
|
81
|
+
}
|
|
69
82
|
// clean up any environment variable edge cases
|
|
70
83
|
for (let [key, value] of Object.entries(module.exports)) {
|
|
71
84
|
// handle the edge case of "0" to disable an environment variable
|
|
@@ -379,6 +379,9 @@ class SqlQueryBuilder extends sqlTable_1.default {
|
|
|
379
379
|
else if (sqlClient === utils_1.SqlClients.MY_SQL) {
|
|
380
380
|
id = results === null || results === void 0 ? void 0 : results.insertId;
|
|
381
381
|
}
|
|
382
|
+
else if (sqlClient === utils_1.SqlClients.ORACLE) {
|
|
383
|
+
id = response.outBinds[0][0];
|
|
384
|
+
}
|
|
382
385
|
row = processFn(yield this.getReturningRow(queryFn, this.checkLookupKeys(id, json)));
|
|
383
386
|
}
|
|
384
387
|
if (operation !== datasource_1.Operation.READ) {
|
|
@@ -388,4 +391,5 @@ class SqlQueryBuilder extends sqlTable_1.default {
|
|
|
388
391
|
});
|
|
389
392
|
}
|
|
390
393
|
}
|
|
394
|
+
exports.default = SqlQueryBuilder;
|
|
391
395
|
module.exports = SqlQueryBuilder;
|
|
@@ -37,6 +37,12 @@ const INTEGRATIONS = {
|
|
|
37
37
|
[SourceNames.ARANGODB]: arangodb.integration,
|
|
38
38
|
[SourceNames.REST]: rest.integration,
|
|
39
39
|
};
|
|
40
|
+
// optionally add oracle integration if the oracle binary can be installed
|
|
41
|
+
if (!(process.arch === 'arm64' && process.platform === 'darwin')) {
|
|
42
|
+
const oracle = require("./oracle");
|
|
43
|
+
DEFINITIONS[SourceNames.ORACLE] = oracle.schema;
|
|
44
|
+
INTEGRATIONS[SourceNames.ORACLE] = oracle.integration;
|
|
45
|
+
}
|
|
40
46
|
module.exports = {
|
|
41
47
|
definitions: DEFINITIONS,
|
|
42
48
|
integrations: INTEGRATIONS,
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const datasource_1 = require("../definitions/datasource");
|
|
16
|
+
const utils_1 = require("./utils");
|
|
17
|
+
const oracledb_1 = __importDefault(require("oracledb"));
|
|
18
|
+
const sql_1 = __importDefault(require("./base/sql"));
|
|
19
|
+
const constants_1 = require("../constants");
|
|
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
|
+
description: "Oracle Database is an object-relational database management system developed by Oracle Corporation",
|
|
28
|
+
datasource: {
|
|
29
|
+
host: {
|
|
30
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
31
|
+
default: "localhost",
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
port: {
|
|
35
|
+
type: datasource_1.DatasourceFieldTypes.NUMBER,
|
|
36
|
+
required: true,
|
|
37
|
+
default: 1521,
|
|
38
|
+
},
|
|
39
|
+
database: {
|
|
40
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
41
|
+
required: true,
|
|
42
|
+
},
|
|
43
|
+
user: {
|
|
44
|
+
type: datasource_1.DatasourceFieldTypes.STRING,
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
47
|
+
password: {
|
|
48
|
+
type: datasource_1.DatasourceFieldTypes.PASSWORD,
|
|
49
|
+
required: true,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
query: {
|
|
53
|
+
create: {
|
|
54
|
+
type: datasource_1.QueryTypes.SQL,
|
|
55
|
+
},
|
|
56
|
+
read: {
|
|
57
|
+
type: datasource_1.QueryTypes.SQL,
|
|
58
|
+
},
|
|
59
|
+
update: {
|
|
60
|
+
type: datasource_1.QueryTypes.SQL,
|
|
61
|
+
},
|
|
62
|
+
delete: {
|
|
63
|
+
type: datasource_1.QueryTypes.SQL,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
const UNSUPPORTED_TYPES = ["BLOB", "CLOB", "NCLOB"];
|
|
68
|
+
const OracleContraintTypes = {
|
|
69
|
+
PRIMARY: "P",
|
|
70
|
+
NOT_NULL_OR_CHECK: "C",
|
|
71
|
+
FOREIGN_KEY: "R",
|
|
72
|
+
UNIQUE: "U",
|
|
73
|
+
};
|
|
74
|
+
class OracleIntegration extends sql_1.default {
|
|
75
|
+
constructor(config) {
|
|
76
|
+
super(utils_1.SqlClients.ORACLE);
|
|
77
|
+
this.tables = {};
|
|
78
|
+
this.schemaErrors = {};
|
|
79
|
+
this.COLUMNS_SQL = `
|
|
80
|
+
SELECT
|
|
81
|
+
tabs.table_name,
|
|
82
|
+
cols.column_name,
|
|
83
|
+
cols.data_type,
|
|
84
|
+
cols.data_default,
|
|
85
|
+
cols.column_id,
|
|
86
|
+
cons.constraint_name,
|
|
87
|
+
cons.constraint_type,
|
|
88
|
+
cons.r_constraint_name,
|
|
89
|
+
cons.search_condition
|
|
90
|
+
FROM
|
|
91
|
+
user_tables tabs
|
|
92
|
+
JOIN
|
|
93
|
+
user_tab_columns cols
|
|
94
|
+
ON tabs.table_name = cols.table_name
|
|
95
|
+
LEFT JOIN
|
|
96
|
+
user_cons_columns col_cons
|
|
97
|
+
ON cols.column_name = col_cons.column_name
|
|
98
|
+
AND cols.table_name = col_cons.table_name
|
|
99
|
+
LEFT JOIN
|
|
100
|
+
user_constraints cons
|
|
101
|
+
ON col_cons.constraint_name = cons.constraint_name
|
|
102
|
+
AND cons.table_name = cols.table_name
|
|
103
|
+
WHERE
|
|
104
|
+
(cons.status = 'ENABLED'
|
|
105
|
+
OR cons.status IS NULL)
|
|
106
|
+
`;
|
|
107
|
+
this.getConnection = () => __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
//connectString : "(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA =(SID= ORCL)))"
|
|
109
|
+
const connectString = `${this.config.host}:${this.config.port || 1521}/${this.config.database}`;
|
|
110
|
+
const attributes = {
|
|
111
|
+
user: this.config.user,
|
|
112
|
+
password: this.config.user,
|
|
113
|
+
connectString,
|
|
114
|
+
};
|
|
115
|
+
return oracledb_1.default.getConnection(attributes);
|
|
116
|
+
});
|
|
117
|
+
this.config = config;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Map the flat tabular columns and constraints data into a nested object
|
|
121
|
+
*/
|
|
122
|
+
mapColumns(result) {
|
|
123
|
+
const oracleTables = {};
|
|
124
|
+
if (result.rows) {
|
|
125
|
+
result.rows.forEach(row => {
|
|
126
|
+
const tableName = row.TABLE_NAME;
|
|
127
|
+
const columnName = row.COLUMN_NAME;
|
|
128
|
+
const dataType = row.DATA_TYPE;
|
|
129
|
+
const dataDefault = row.DATA_DEFAULT;
|
|
130
|
+
const columnId = row.COLUMN_ID;
|
|
131
|
+
const constraintName = row.CONSTRAINT_NAME;
|
|
132
|
+
const constraintType = row.CONSTRAINT_TYPE;
|
|
133
|
+
const relatedConstraintName = row.R_CONSTRAINT_NAME;
|
|
134
|
+
const searchCondition = row.SEARCH_CONDITION;
|
|
135
|
+
let table = oracleTables[tableName];
|
|
136
|
+
if (!table) {
|
|
137
|
+
table = {
|
|
138
|
+
name: tableName,
|
|
139
|
+
columns: {},
|
|
140
|
+
};
|
|
141
|
+
oracleTables[tableName] = table;
|
|
142
|
+
}
|
|
143
|
+
let column = table.columns[columnName];
|
|
144
|
+
if (!column) {
|
|
145
|
+
column = {
|
|
146
|
+
name: columnName,
|
|
147
|
+
type: dataType,
|
|
148
|
+
default: dataDefault,
|
|
149
|
+
id: columnId,
|
|
150
|
+
constraints: {},
|
|
151
|
+
};
|
|
152
|
+
table.columns[columnName] = column;
|
|
153
|
+
}
|
|
154
|
+
if (constraintName && constraintType) {
|
|
155
|
+
let constraint = column.constraints[constraintName];
|
|
156
|
+
if (!constraint) {
|
|
157
|
+
constraint = {
|
|
158
|
+
name: constraintName,
|
|
159
|
+
type: constraintType,
|
|
160
|
+
relatedConstraintName: relatedConstraintName,
|
|
161
|
+
searchCondition: searchCondition,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
column.constraints[constraintName] = constraint;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return oracleTables;
|
|
169
|
+
}
|
|
170
|
+
isSupportedColumn(column) {
|
|
171
|
+
if (UNSUPPORTED_TYPES.includes(column.type)) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
isAutoColumn(column) {
|
|
177
|
+
if (column.default && column.default.toLowerCase().includes("nextval")) {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* No native boolean in oracle. Best we can do is to check if a manual 1 or 0 number constraint has been set up
|
|
184
|
+
* This matches the default behaviour for generating DDL used in knex.
|
|
185
|
+
*/
|
|
186
|
+
isBooleanType(column) {
|
|
187
|
+
if (column.type.toLowerCase() === "number" &&
|
|
188
|
+
Object.values(column.constraints).filter(c => {
|
|
189
|
+
if (c.type === OracleContraintTypes.NOT_NULL_OR_CHECK &&
|
|
190
|
+
c.searchCondition) {
|
|
191
|
+
const condition = c.searchCondition
|
|
192
|
+
.replace(/\s/g, "") // remove spaces
|
|
193
|
+
.replace(/[']+/g, ""); // remove quotes
|
|
194
|
+
if (condition.includes("in(0,1)") ||
|
|
195
|
+
condition.includes("in(1,0)")) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
}).length > 0) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
internalConvertType(column) {
|
|
206
|
+
if (this.isBooleanType(column)) {
|
|
207
|
+
return constants_1.FieldTypes.BOOLEAN;
|
|
208
|
+
}
|
|
209
|
+
return utils_1.convertSqlType(column.type);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Fetches the tables from the oracle table and assigns them to the datasource.
|
|
213
|
+
* @param {*} datasourceId - datasourceId to fetch
|
|
214
|
+
* @param entities - the tables that are to be built
|
|
215
|
+
*/
|
|
216
|
+
buildSchema(datasourceId, entities) {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
218
|
+
const columnsResponse = yield this.internalQuery({
|
|
219
|
+
sql: this.COLUMNS_SQL,
|
|
220
|
+
});
|
|
221
|
+
const oracleTables = this.mapColumns(columnsResponse);
|
|
222
|
+
const tables = {};
|
|
223
|
+
// iterate each table
|
|
224
|
+
Object.values(oracleTables).forEach(oracleTable => {
|
|
225
|
+
let table = tables[oracleTable.name];
|
|
226
|
+
if (!table) {
|
|
227
|
+
table = {
|
|
228
|
+
_id: utils_1.buildExternalTableId(datasourceId, oracleTable.name),
|
|
229
|
+
primary: [],
|
|
230
|
+
name: oracleTable.name,
|
|
231
|
+
schema: {},
|
|
232
|
+
};
|
|
233
|
+
tables[oracleTable.name] = table;
|
|
234
|
+
}
|
|
235
|
+
// iterate each column on the table
|
|
236
|
+
Object.values(oracleTable.columns)
|
|
237
|
+
// remove columns that we can't read / save
|
|
238
|
+
.filter(oracleColumn => this.isSupportedColumn(oracleColumn))
|
|
239
|
+
// match the order of the columns in the db
|
|
240
|
+
.sort((c1, c2) => c1.id - c2.id)
|
|
241
|
+
.forEach(oracleColumn => {
|
|
242
|
+
const columnName = oracleColumn.name;
|
|
243
|
+
let fieldSchema = table.schema[columnName];
|
|
244
|
+
if (!fieldSchema) {
|
|
245
|
+
fieldSchema = {
|
|
246
|
+
autocolumn: this.isAutoColumn(oracleColumn),
|
|
247
|
+
name: columnName,
|
|
248
|
+
type: this.internalConvertType(oracleColumn),
|
|
249
|
+
};
|
|
250
|
+
table.schema[columnName] = fieldSchema;
|
|
251
|
+
}
|
|
252
|
+
// iterate each constraint on the column
|
|
253
|
+
Object.values(oracleColumn.constraints).forEach(oracleConstraint => {
|
|
254
|
+
if (oracleConstraint.type === OracleContraintTypes.PRIMARY) {
|
|
255
|
+
table.primary.push(columnName);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
const final = utils_1.finaliseExternalTables(tables, entities);
|
|
261
|
+
this.tables = final.tables;
|
|
262
|
+
this.schemaErrors = final.errors;
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Knex default returning behaviour does not work with oracle
|
|
267
|
+
* Manually add the behaviour for the return column
|
|
268
|
+
*/
|
|
269
|
+
addReturning(query, bindings, returnColumn) {
|
|
270
|
+
if (bindings instanceof Array) {
|
|
271
|
+
bindings.push({ dir: oracledb_1.default.BIND_OUT });
|
|
272
|
+
query.sql = query.sql + ` returning \"${returnColumn}\" into :${bindings.length}`;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
internalQuery(query, returnColum, operation) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
+
let connection;
|
|
278
|
+
try {
|
|
279
|
+
connection = yield this.getConnection();
|
|
280
|
+
const options = { autoCommit: true };
|
|
281
|
+
const bindings = query.bindings || [];
|
|
282
|
+
if (returnColum && (operation === datasource_1.Operation.CREATE || operation === datasource_1.Operation.UPDATE)) {
|
|
283
|
+
this.addReturning(query, bindings, returnColum);
|
|
284
|
+
}
|
|
285
|
+
const result = yield connection.execute(query.sql, bindings, options);
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
finally {
|
|
289
|
+
if (connection) {
|
|
290
|
+
try {
|
|
291
|
+
yield connection.close();
|
|
292
|
+
}
|
|
293
|
+
catch (err) {
|
|
294
|
+
console.error(err);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
create(query) {
|
|
301
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
302
|
+
const response = yield this.internalQuery(utils_1.getSqlQuery(query));
|
|
303
|
+
return response.rows && response.rows.length
|
|
304
|
+
? response.rows
|
|
305
|
+
: [{ created: true }];
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
read(query) {
|
|
309
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
310
|
+
const response = yield this.internalQuery(utils_1.getSqlQuery(query));
|
|
311
|
+
return response.rows ? response.rows : [];
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
update(query) {
|
|
315
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
316
|
+
const response = yield this.internalQuery(utils_1.getSqlQuery(query));
|
|
317
|
+
return response.rows && response.rows.length
|
|
318
|
+
? response.rows
|
|
319
|
+
: [{ updated: true }];
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
delete(query) {
|
|
323
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
324
|
+
const response = yield this.internalQuery(utils_1.getSqlQuery(query));
|
|
325
|
+
return response.rows && response.rows.length
|
|
326
|
+
? response.rows
|
|
327
|
+
: [{ deleted: true }];
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
query(json) {
|
|
331
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
332
|
+
const primaryKeys = json.meta.table.primary;
|
|
333
|
+
const primaryKey = primaryKeys ? primaryKeys[0] : undefined;
|
|
334
|
+
const queryFn = (query, operation) => this.internalQuery(query, primaryKey, operation);
|
|
335
|
+
const processFn = (response) => response.rows ? response.rows : [];
|
|
336
|
+
const output = yield this.queryWithReturning(json, queryFn, processFn);
|
|
337
|
+
return output;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
module.exports = {
|
|
342
|
+
schema: SCHEMA,
|
|
343
|
+
integration: OracleIntegration,
|
|
344
|
+
};
|
|
345
|
+
})(OracleModule || (OracleModule = {}));
|
|
@@ -31,12 +31,17 @@ const SQL_TYPE_MAP = {
|
|
|
31
31
|
fixed: FieldTypes.NUMBER,
|
|
32
32
|
datetime: FieldTypes.DATETIME,
|
|
33
33
|
tinyint: FieldTypes.BOOLEAN,
|
|
34
|
+
long: FieldTypes.LONGFORM,
|
|
35
|
+
number: FieldTypes.NUMBER,
|
|
36
|
+
binary_float: FieldTypes.NUMBER,
|
|
37
|
+
binary_double: FieldTypes.NUMBER,
|
|
34
38
|
};
|
|
35
39
|
var SqlClients;
|
|
36
40
|
(function (SqlClients) {
|
|
37
41
|
SqlClients["MS_SQL"] = "mssql";
|
|
38
42
|
SqlClients["POSTGRES"] = "pg";
|
|
39
43
|
SqlClients["MY_SQL"] = "mysql";
|
|
44
|
+
SqlClients["ORACLE"] = "oracledb";
|
|
40
45
|
})(SqlClients = exports.SqlClients || (exports.SqlClients = {}));
|
|
41
46
|
function isExternalTable(tableId) {
|
|
42
47
|
return tableId.includes(DocumentTypes.DATASOURCE);
|
|
@@ -152,7 +157,7 @@ function copyExistingPropsOver(tableName, table, entities) {
|
|
|
152
157
|
}
|
|
153
158
|
function finaliseExternalTables(tables, entities) {
|
|
154
159
|
const invalidColumns = Object.values(InvalidColumns);
|
|
155
|
-
|
|
160
|
+
let finalTables = {};
|
|
156
161
|
const errors = {};
|
|
157
162
|
for (let [name, table] of Object.entries(tables)) {
|
|
158
163
|
const schemaFields = Object.keys(table.schema);
|
|
@@ -168,6 +173,10 @@ function finaliseExternalTables(tables, entities) {
|
|
|
168
173
|
// make sure all previous props have been added back
|
|
169
174
|
finalTables[name] = copyExistingPropsOver(name, table, entities);
|
|
170
175
|
}
|
|
176
|
+
// sort the tables by name
|
|
177
|
+
finalTables = Object.entries(finalTables)
|
|
178
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
179
|
+
.reduce((r, [k, v]) => (Object.assign(Object.assign({}, r), { [k]: v })), {});
|
|
171
180
|
return { tables: finalTables, errors };
|
|
172
181
|
}
|
|
173
182
|
exports.finaliseExternalTables = finaliseExternalTables;
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "0.9.185-alpha.
|
|
4
|
+
"version": "0.9.185-alpha.16",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"author": "Budibase",
|
|
69
69
|
"license": "AGPL-3.0-or-later",
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@budibase/auth": "^0.9.185-alpha.
|
|
72
|
-
"@budibase/client": "^0.9.185-alpha.
|
|
73
|
-
"@budibase/string-templates": "^0.9.185-alpha.
|
|
71
|
+
"@budibase/auth": "^0.9.185-alpha.16",
|
|
72
|
+
"@budibase/client": "^0.9.185-alpha.16",
|
|
73
|
+
"@budibase/string-templates": "^0.9.185-alpha.16",
|
|
74
74
|
"@bull-board/api": "^3.7.0",
|
|
75
75
|
"@bull-board/koa": "^3.7.0",
|
|
76
76
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -135,6 +135,7 @@
|
|
|
135
135
|
"@types/koa": "^2.13.3",
|
|
136
136
|
"@types/koa-router": "^7.4.2",
|
|
137
137
|
"@types/node": "^15.12.4",
|
|
138
|
+
"@types/oracledb": "^5.2.1",
|
|
138
139
|
"@typescript-eslint/parser": "4.28.0",
|
|
139
140
|
"babel-jest": "^27.0.2",
|
|
140
141
|
"copyfiles": "^2.4.1",
|
|
@@ -150,5 +151,8 @@
|
|
|
150
151
|
"typescript": "^4.3.5",
|
|
151
152
|
"update-dotenv": "^1.1.1"
|
|
152
153
|
},
|
|
154
|
+
"optionalDependencies": {
|
|
155
|
+
"oracledb": "^5.3.0"
|
|
156
|
+
},
|
|
153
157
|
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc"
|
|
154
158
|
}
|
|
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
// when thread starts, make sure it is recorded
|
|
12
|
+
const env = require("../environment");
|
|
13
|
+
env.setInThread();
|
|
11
14
|
const actions = require("../automations/actions");
|
|
12
15
|
const automationUtils = require("../automations/automationUtils");
|
|
13
16
|
const AutomationEmitter = require("../events/AutomationEmitter");
|
|
@@ -16,7 +19,6 @@ const { DEFAULT_TENANT_ID } = require("@budibase/auth").constants;
|
|
|
16
19
|
const CouchDB = require("../db");
|
|
17
20
|
const { DocumentTypes, isDevAppID } = require("../db/utils");
|
|
18
21
|
const { doInTenant } = require("@budibase/auth/tenancy");
|
|
19
|
-
const env = require("../environment");
|
|
20
22
|
const usage = require("../utilities/usageQuota");
|
|
21
23
|
const { definitions: triggerDefs } = require("../automations/triggerInfo");
|
|
22
24
|
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId;
|
package/dist/threads/index.js
CHANGED
|
@@ -22,10 +22,16 @@ function typeToFile(type) {
|
|
|
22
22
|
class Thread {
|
|
23
23
|
constructor(type, opts = { timeoutMs: null, count: 1 }) {
|
|
24
24
|
this.type = type;
|
|
25
|
-
|
|
25
|
+
this.count = opts.count ? opts.count : 1;
|
|
26
|
+
this.disableThreading =
|
|
27
|
+
env.isTest() ||
|
|
28
|
+
env.DISABLE_THREADING ||
|
|
29
|
+
this.count === 0 ||
|
|
30
|
+
env.isInThread();
|
|
31
|
+
if (!this.disableThreading) {
|
|
26
32
|
const workerOpts = {
|
|
27
33
|
autoStart: true,
|
|
28
|
-
maxConcurrentWorkers:
|
|
34
|
+
maxConcurrentWorkers: this.count,
|
|
29
35
|
};
|
|
30
36
|
if (opts.timeoutMs) {
|
|
31
37
|
workerOpts.maxCallTime = opts.timeoutMs;
|
|
@@ -37,7 +43,7 @@ class Thread {
|
|
|
37
43
|
return new Promise((resolve, reject) => {
|
|
38
44
|
let fncToCall;
|
|
39
45
|
// if in test then don't use threading
|
|
40
|
-
if (
|
|
46
|
+
if (this.disableThreading) {
|
|
41
47
|
fncToCall = require(typeToFile(this.type));
|
|
42
48
|
}
|
|
43
49
|
else {
|
package/dist/threads/query.js
CHANGED
|
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
// when thread starts, make sure it is recorded
|
|
12
|
+
const env = require("../environment");
|
|
13
|
+
env.setInThread();
|
|
11
14
|
const ScriptRunner = require("../utilities/scriptRunner");
|
|
12
15
|
const { integrations } = require("../integrations");
|
|
13
16
|
function formatResponse(resp) {
|