@budibase/server 0.9.140-alpha.4 → 0.9.140-alpha.5
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/builder/assets/{index.2bcd18f5.js → index.80d850d1.js} +1 -1
- package/builder/index.html +1 -1
- package/coverage/clover.xml +646 -528
- package/coverage/coverage-final.json +17 -15
- 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/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +3 -3
- 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 +19 -19
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +242 -47
- 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/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +2 -2
- package/coverage/lcov-report/api/controllers/table/utils.js.html +31 -19
- 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 +32 -17
- package/coverage/lcov-report/api/controllers/view/index.js.html +84 -186
- package/coverage/lcov-report/api/controllers/view/utils.js.html +407 -0
- 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/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 +10 -19
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +14 -20
- 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 +31 -31
- 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 +18 -27
- 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 +12 -21
- package/coverage/lcov-report/automations/steps/utils.js.html +23 -23
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/thread.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 +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/client.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +224 -0
- package/coverage/lcov-report/db/index.html +34 -19
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +4 -4
- package/coverage/lcov-report/db/linkedRows/index.html +14 -14
- package/coverage/lcov-report/db/linkedRows/index.js.html +18 -9
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +37 -10
- 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 +65 -65
- 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/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 +15 -15
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +58 -13
- package/coverage/lcov-report/utilities/rowProcessor/utils.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/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +1093 -883
- package/dist/api/controllers/datasource.js +2 -2
- package/dist/api/controllers/row/ExternalRequest.js +4 -0
- package/dist/api/controllers/row/internal.js +97 -23
- package/dist/api/controllers/table/index.js +1 -1
- package/dist/api/controllers/table/utils.js +13 -11
- package/dist/api/controllers/view/index.js +74 -96
- package/dist/api/controllers/view/utils.js +102 -0
- package/dist/automations/steps/createRow.js +5 -8
- package/dist/automations/steps/deleteRow.js +7 -10
- package/dist/automations/steps/queryRows.js +11 -14
- package/dist/automations/steps/updateRow.js +4 -7
- package/dist/db/inMemoryView.js +51 -0
- package/dist/db/linkedRows/index.js +5 -2
- package/dist/db/utils.js +7 -0
- package/dist/environment.js +7 -1
- package/dist/integrations/mysql.js +2 -13
- package/dist/integrations/postgres.js +8 -14
- package/dist/integrations/utils.js +19 -1
- package/dist/package.json +5 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/rowProcessor/index.js +10 -5
- package/package.json +6 -6
- package/scripts/integrations/service-vehicles/docker-compose.yml +28 -0
- package/scripts/integrations/service-vehicles/init.sql +52 -0
- package/scripts/integrations/service-vehicles/reset.sh +3 -0
- package/src/api/controllers/datasource.js +2 -2
- package/src/api/controllers/row/ExternalRequest.ts +5 -1
- package/src/api/controllers/row/internal.js +88 -23
- package/src/api/controllers/table/index.js +1 -1
- package/src/api/controllers/table/utils.js +16 -12
- package/src/api/controllers/view/index.js +82 -116
- package/src/api/controllers/view/utils.js +109 -0
- package/src/api/routes/tests/view.spec.js +1 -1
- package/src/automations/steps/createRow.js +5 -8
- package/src/automations/steps/deleteRow.js +8 -10
- package/src/automations/steps/queryRows.js +11 -14
- package/src/automations/steps/updateRow.js +7 -10
- package/src/db/inMemoryView.js +48 -0
- package/src/db/linkedRows/index.js +5 -2
- package/src/db/utils.js +9 -0
- package/src/environment.js +8 -1
- package/src/integrations/mysql.ts +2 -13
- package/src/integrations/postgres.ts +9 -16
- package/src/integrations/utils.ts +18 -0
- package/src/utilities/rowProcessor/index.js +20 -5
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const rowController = require("../../api/controllers/row");
|
|
12
12
|
const automationUtils = require("../automationUtils");
|
|
13
|
+
const { buildCtx } = require("./utils");
|
|
13
14
|
exports.definition = {
|
|
14
15
|
name: "Update Row",
|
|
15
16
|
tagline: "Update a {{inputs.enriched.table.name}} row",
|
|
@@ -79,16 +80,12 @@ exports.run = function ({ inputs, appId, emitter }) {
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
// have to clean up the row, remove the table from it
|
|
82
|
-
const ctx = {
|
|
83
|
+
const ctx = buildCtx(appId, emitter, {
|
|
84
|
+
body: Object.assign(Object.assign({}, inputs.row), { _id: inputs.rowId }),
|
|
83
85
|
params: {
|
|
84
86
|
rowId: inputs.rowId,
|
|
85
87
|
},
|
|
86
|
-
|
|
87
|
-
body: Object.assign(Object.assign({}, inputs.row), { _id: inputs.rowId }),
|
|
88
|
-
},
|
|
89
|
-
appId,
|
|
90
|
-
eventEmitter: emitter,
|
|
91
|
-
};
|
|
88
|
+
});
|
|
92
89
|
try {
|
|
93
90
|
inputs.row = yield automationUtils.cleanUpRowById(appId, inputs.rowId, inputs.row);
|
|
94
91
|
yield rowController.patch(ctx);
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
const PouchDB = require("pouchdb");
|
|
12
|
+
const memory = require("pouchdb-adapter-memory");
|
|
13
|
+
const newid = require("./newid");
|
|
14
|
+
PouchDB.plugin(memory);
|
|
15
|
+
const Pouch = PouchDB.defaults({
|
|
16
|
+
prefix: undefined,
|
|
17
|
+
adapter: "memory",
|
|
18
|
+
});
|
|
19
|
+
exports.runView = (view, calculation, group, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
// use a different ID each time for the DB, make sure they
|
|
21
|
+
// are always unique for each query, don't want overlap
|
|
22
|
+
// which could cause 409s
|
|
23
|
+
const db = new Pouch(newid());
|
|
24
|
+
// write all the docs to the in memory Pouch (remove revs)
|
|
25
|
+
yield db.bulkDocs(data.map(row => (Object.assign(Object.assign({}, row), { _rev: undefined }))));
|
|
26
|
+
let fn = (doc, emit) => emit(doc._id);
|
|
27
|
+
eval("fn = " + view.map.replace("function (doc)", "function (doc, emit)"));
|
|
28
|
+
const queryFns = {
|
|
29
|
+
meta: view.meta,
|
|
30
|
+
map: fn,
|
|
31
|
+
};
|
|
32
|
+
if (view.reduce) {
|
|
33
|
+
queryFns.reduce = view.reduce;
|
|
34
|
+
}
|
|
35
|
+
const response = yield db.query(queryFns, {
|
|
36
|
+
include_docs: !calculation,
|
|
37
|
+
group: !!group,
|
|
38
|
+
});
|
|
39
|
+
// need to fix the revs to be totally accurate
|
|
40
|
+
for (let row of response.rows) {
|
|
41
|
+
if (!row._rev || !row._id) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const found = data.find(possible => possible._id === row._id);
|
|
45
|
+
if (found) {
|
|
46
|
+
row._rev = found._rev;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
yield db.destroy();
|
|
50
|
+
return response;
|
|
51
|
+
});
|
|
@@ -66,7 +66,10 @@ function getFullLinkedDocs(ctx, appId, links) {
|
|
|
66
66
|
// create DBs
|
|
67
67
|
const db = new CouchDB(appId);
|
|
68
68
|
const linkedRowIds = links.map(link => link.id);
|
|
69
|
-
|
|
69
|
+
const uniqueRowIds = [...new Set(linkedRowIds)];
|
|
70
|
+
let dbRows = (yield db.allDocs(getMultiIDParams(uniqueRowIds))).rows.map(row => row.doc);
|
|
71
|
+
// convert the unique db rows back to a full list of linked rows
|
|
72
|
+
const linked = linkedRowIds.map(id => dbRows.find(row => row._id === id));
|
|
70
73
|
// need to handle users as specific cases
|
|
71
74
|
let [users, other] = partition(linked, linkRow => linkRow._id.startsWith(USER_METDATA_PREFIX));
|
|
72
75
|
users = yield getGlobalUsersFromMetadata(appId, users);
|
|
@@ -98,7 +101,7 @@ exports.updateLinks = function (args) {
|
|
|
98
101
|
}
|
|
99
102
|
let linkController = new LinkController(args);
|
|
100
103
|
try {
|
|
101
|
-
if (!(yield linkController.doesTableHaveLinkedFields()) &&
|
|
104
|
+
if (!(yield linkController.doesTableHaveLinkedFields(table)) &&
|
|
102
105
|
(oldTable == null ||
|
|
103
106
|
!(yield linkController.doesTableHaveLinkedFields(oldTable)))) {
|
|
104
107
|
return baseReturnObj;
|
package/dist/db/utils.js
CHANGED
|
@@ -27,6 +27,7 @@ const DocumentTypes = {
|
|
|
27
27
|
QUERY: "query",
|
|
28
28
|
DEPLOYMENTS: "deployments",
|
|
29
29
|
METADATA: "metadata",
|
|
30
|
+
MEM_VIEW: "view",
|
|
30
31
|
};
|
|
31
32
|
const ViewNames = {
|
|
32
33
|
LINK: "by_link",
|
|
@@ -279,6 +280,12 @@ exports.getMetadataParams = (type, entityId = null, otherProps = {}) => {
|
|
|
279
280
|
}
|
|
280
281
|
return getDocParams(DocumentTypes.METADATA, docId, otherProps);
|
|
281
282
|
};
|
|
283
|
+
exports.generateMemoryViewID = viewName => {
|
|
284
|
+
return `${DocumentTypes.MEM_VIEW}${SEPARATOR}${viewName}`;
|
|
285
|
+
};
|
|
286
|
+
exports.getMemoryViewParams = (otherProps = {}) => {
|
|
287
|
+
return getDocParams(DocumentTypes.MEM_VIEW, null, otherProps);
|
|
288
|
+
};
|
|
282
289
|
/**
|
|
283
290
|
* This can be used with the db.allDocs to get a list of IDs
|
|
284
291
|
*/
|
package/dist/environment.js
CHANGED
|
@@ -20,7 +20,7 @@ module.exports = {
|
|
|
20
20
|
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
|
21
21
|
MINIO_URL: process.env.MINIO_URL,
|
|
22
22
|
WORKER_URL: process.env.WORKER_URL,
|
|
23
|
-
SELF_HOSTED:
|
|
23
|
+
SELF_HOSTED: process.env.SELF_HOSTED,
|
|
24
24
|
AWS_REGION: process.env.AWS_REGION,
|
|
25
25
|
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
|
26
26
|
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
|
@@ -60,3 +60,9 @@ module.exports = {
|
|
|
60
60
|
return !isDev();
|
|
61
61
|
},
|
|
62
62
|
};
|
|
63
|
+
// convert any strings to numbers if required, like "0" would be true otherwise
|
|
64
|
+
for (let [key, value] of Object.entries(module.exports)) {
|
|
65
|
+
if (typeof value === "string" && !isNaN(parseInt(value))) {
|
|
66
|
+
module.exports[key] = parseInt(value);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -15,7 +15,7 @@ var MySQLModule;
|
|
|
15
15
|
(function (MySQLModule) {
|
|
16
16
|
const mysql = require("mysql");
|
|
17
17
|
const Sql = require("./base/sql");
|
|
18
|
-
const { buildExternalTableId, convertType } = require("./utils");
|
|
18
|
+
const { buildExternalTableId, convertType, copyExistingPropsOver } = require("./utils");
|
|
19
19
|
const { FieldTypes } = require("../constants");
|
|
20
20
|
const TYPE_MAP = {
|
|
21
21
|
text: FieldTypes.LONGFORM,
|
|
@@ -160,18 +160,7 @@ var MySQLModule;
|
|
|
160
160
|
schema,
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
|
-
|
|
164
|
-
if (entities && entities[tableName]) {
|
|
165
|
-
const existingTableSchema = entities[tableName].schema;
|
|
166
|
-
for (let key in existingTableSchema) {
|
|
167
|
-
if (!existingTableSchema.hasOwnProperty(key)) {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (existingTableSchema[key].type === "link") {
|
|
171
|
-
tables[tableName].schema[key] = existingTableSchema[key];
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
163
|
+
copyExistingPropsOver(tableName, tables, entities);
|
|
175
164
|
}
|
|
176
165
|
this.client.end();
|
|
177
166
|
this.tables = tables;
|
|
@@ -16,7 +16,7 @@ var PostgresModule;
|
|
|
16
16
|
const { Pool } = require("pg");
|
|
17
17
|
const Sql = require("./base/sql");
|
|
18
18
|
const { FieldTypes } = require("../constants");
|
|
19
|
-
const { buildExternalTableId, convertType } = require("./utils");
|
|
19
|
+
const { buildExternalTableId, convertType, copyExistingPropsOver } = require("./utils");
|
|
20
20
|
const SCHEMA = {
|
|
21
21
|
docs: "https://node-postgres.com",
|
|
22
22
|
plus: true,
|
|
@@ -150,28 +150,22 @@ var PostgresModule;
|
|
|
150
150
|
name: tableName,
|
|
151
151
|
schema: {},
|
|
152
152
|
};
|
|
153
|
-
// add the existing relationships from the entities if they exist, to prevent them from being overridden
|
|
154
|
-
if (entities && entities[tableName]) {
|
|
155
|
-
const existingTableSchema = entities[tableName].schema;
|
|
156
|
-
for (let key in existingTableSchema) {
|
|
157
|
-
if (!existingTableSchema.hasOwnProperty(key)) {
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
if (existingTableSchema[key].type === "link") {
|
|
161
|
-
tables[tableName].schema[key] = existingTableSchema[key];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
153
|
}
|
|
166
154
|
const type = convertType(column.data_type, TYPE_MAP);
|
|
167
|
-
const
|
|
155
|
+
const identity = !!(column.identity_generation || column.identity_start || column.identity_increment);
|
|
156
|
+
const hasDefault = typeof column.column_default === "string" &&
|
|
168
157
|
column.column_default.startsWith("nextval");
|
|
158
|
+
const isGenerated = column.is_generated && column.is_generated !== "NEVER";
|
|
159
|
+
const isAuto = hasDefault || identity || isGenerated;
|
|
169
160
|
tables[tableName].schema[columnName] = {
|
|
170
161
|
autocolumn: isAuto,
|
|
171
162
|
name: columnName,
|
|
172
163
|
type,
|
|
173
164
|
};
|
|
174
165
|
}
|
|
166
|
+
for (let tableName of Object.keys(tables)) {
|
|
167
|
+
copyExistingPropsOver(tableName, tables, entities);
|
|
168
|
+
}
|
|
175
169
|
this.tables = tables;
|
|
176
170
|
});
|
|
177
171
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isIsoDateString = exports.isSQL = exports.getSqlQuery = exports.convertType = exports.breakRowIdField = exports.generateRowIdField = exports.breakExternalTableId = exports.buildExternalTableId = exports.isExternalTable = void 0;
|
|
3
|
+
exports.copyExistingPropsOver = exports.isIsoDateString = exports.isSQL = exports.getSqlQuery = exports.convertType = exports.breakRowIdField = exports.generateRowIdField = exports.breakExternalTableId = exports.buildExternalTableId = exports.isExternalTable = void 0;
|
|
4
4
|
const datasource_1 = require("../definitions/datasource");
|
|
5
5
|
const { DocumentTypes, SEPARATOR } = require("../db/utils");
|
|
6
6
|
const { FieldTypes } = require("../constants");
|
|
@@ -84,3 +84,21 @@ function isIsoDateString(str) {
|
|
|
84
84
|
return d.toISOString() === str;
|
|
85
85
|
}
|
|
86
86
|
exports.isIsoDateString = isIsoDateString;
|
|
87
|
+
// add the existing relationships from the entities if they exist, to prevent them from being overridden
|
|
88
|
+
function copyExistingPropsOver(tableName, tables, entities) {
|
|
89
|
+
if (entities && entities[tableName]) {
|
|
90
|
+
if (entities[tableName].primaryDisplay) {
|
|
91
|
+
tables[tableName].primaryDisplay = entities[tableName].primaryDisplay;
|
|
92
|
+
}
|
|
93
|
+
const existingTableSchema = entities[tableName].schema;
|
|
94
|
+
for (let key in existingTableSchema) {
|
|
95
|
+
if (!existingTableSchema.hasOwnProperty(key)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (existingTableSchema[key].type === "link") {
|
|
99
|
+
tables[tableName].schema[key] = existingTableSchema[key];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.copyExistingPropsOver = copyExistingPropsOver;
|
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.140-alpha.
|
|
4
|
+
"version": "0.9.140-alpha.4",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"author": "Budibase",
|
|
63
63
|
"license": "AGPL-3.0-or-later",
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@budibase/auth": "^0.9.140-alpha.
|
|
66
|
-
"@budibase/client": "^0.9.140-alpha.
|
|
67
|
-
"@budibase/string-templates": "^0.9.140-alpha.
|
|
65
|
+
"@budibase/auth": "^0.9.140-alpha.4",
|
|
66
|
+
"@budibase/client": "^0.9.140-alpha.4",
|
|
67
|
+
"@budibase/string-templates": "^0.9.140-alpha.4",
|
|
68
68
|
"@elastic/elasticsearch": "7.10.0",
|
|
69
69
|
"@koa/router": "8.0.0",
|
|
70
70
|
"@sendgrid/mail": "7.1.1",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"pouchdb-all-dbs": "1.0.2",
|
|
106
106
|
"pouchdb-find": "^7.2.2",
|
|
107
107
|
"pouchdb-replication-stream": "1.2.9",
|
|
108
|
+
"pouchdb-adapter-memory": "^7.2.1",
|
|
108
109
|
"server-destroy": "1.0.1",
|
|
109
110
|
"svelte": "^3.38.2",
|
|
110
111
|
"to-json-schema": "0.2.5",
|
|
@@ -131,7 +132,6 @@
|
|
|
131
132
|
"express": "^4.17.1",
|
|
132
133
|
"jest": "^27.0.5",
|
|
133
134
|
"nodemon": "^2.0.4",
|
|
134
|
-
"pouchdb-adapter-memory": "^7.2.1",
|
|
135
135
|
"prettier": "^2.3.1",
|
|
136
136
|
"rimraf": "^3.0.2",
|
|
137
137
|
"supertest": "^4.0.2",
|