@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.
Files changed (200) hide show
  1. package/builder/assets/{index.2bcd18f5.js → index.80d850d1.js} +1 -1
  2. package/builder/index.html +1 -1
  3. package/coverage/clover.xml +646 -528
  4. package/coverage/coverage-final.json +17 -15
  5. package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
  6. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  7. package/coverage/lcov-report/api/controllers/application.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/datasource.js.html +3 -3
  13. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/hosting.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/index.html +1 -1
  16. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/query.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/row/index.html +19 -19
  25. package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/internal.js.html +242 -47
  27. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  32. package/coverage/lcov-report/api/controllers/table/index.js.html +2 -2
  33. package/coverage/lcov-report/api/controllers/table/utils.js.html +31 -19
  34. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/view/index.html +32 -17
  38. package/coverage/lcov-report/api/controllers/view/index.js.html +84 -186
  39. package/coverage/lcov-report/api/controllers/view/utils.js.html +407 -0
  40. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  42. package/coverage/lcov-report/api/index.html +1 -1
  43. package/coverage/lcov-report/api/index.js.html +1 -1
  44. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  45. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  46. package/coverage/lcov-report/api/routes/application.js.html +1 -1
  47. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/hosting.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/index.html +1 -1
  56. package/coverage/lcov-report/api/routes/index.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/row.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/static.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  73. package/coverage/lcov-report/automations/actions.js.html +1 -1
  74. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  75. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  76. package/coverage/lcov-report/automations/index.html +1 -1
  77. package/coverage/lcov-report/automations/index.js.html +1 -1
  78. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  79. package/coverage/lcov-report/automations/steps/createRow.js.html +10 -19
  80. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/deleteRow.js.html +14 -20
  82. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/index.html +31 -31
  87. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/queryRows.js.html +18 -27
  90. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/updateRow.js.html +12 -21
  94. package/coverage/lcov-report/automations/steps/utils.js.html +23 -23
  95. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  96. package/coverage/lcov-report/automations/thread.js.html +1 -1
  97. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  106. package/coverage/lcov-report/automations/utils.js.html +1 -1
  107. package/coverage/lcov-report/constants/index.html +1 -1
  108. package/coverage/lcov-report/constants/index.js.html +1 -1
  109. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  110. package/coverage/lcov-report/constants/screens.js.html +1 -1
  111. package/coverage/lcov-report/db/client.js.html +1 -1
  112. package/coverage/lcov-report/db/inMemoryView.js.html +224 -0
  113. package/coverage/lcov-report/db/index.html +34 -19
  114. package/coverage/lcov-report/db/index.js.html +1 -1
  115. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +4 -4
  116. package/coverage/lcov-report/db/linkedRows/index.html +14 -14
  117. package/coverage/lcov-report/db/linkedRows/index.js.html +18 -9
  118. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  119. package/coverage/lcov-report/db/newid.js.html +1 -1
  120. package/coverage/lcov-report/db/utils.js.html +37 -10
  121. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  122. package/coverage/lcov-report/events/index.html +1 -1
  123. package/coverage/lcov-report/events/index.js.html +1 -1
  124. package/coverage/lcov-report/events/utils.js.html +1 -1
  125. package/coverage/lcov-report/index.html +65 -65
  126. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  127. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  128. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  129. package/coverage/lcov-report/middleware/authorized.js.html +1 -1
  130. package/coverage/lcov-report/middleware/builder.js.html +1 -1
  131. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  132. package/coverage/lcov-report/middleware/index.html +1 -1
  133. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  134. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  135. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  136. package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
  137. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  138. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  139. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  140. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  141. package/coverage/lcov-report/utilities/global.js.html +1 -1
  142. package/coverage/lcov-report/utilities/index.html +1 -1
  143. package/coverage/lcov-report/utilities/index.js.html +1 -1
  144. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  145. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  146. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  147. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  148. package/coverage/lcov-report/utilities/rowProcessor/index.html +15 -15
  149. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +58 -13
  150. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  151. package/coverage/lcov-report/utilities/security.js.html +2 -2
  152. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  153. package/coverage/lcov-report/utilities/users.js.html +1 -1
  154. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  155. package/coverage/lcov.info +1093 -883
  156. package/dist/api/controllers/datasource.js +2 -2
  157. package/dist/api/controllers/row/ExternalRequest.js +4 -0
  158. package/dist/api/controllers/row/internal.js +97 -23
  159. package/dist/api/controllers/table/index.js +1 -1
  160. package/dist/api/controllers/table/utils.js +13 -11
  161. package/dist/api/controllers/view/index.js +74 -96
  162. package/dist/api/controllers/view/utils.js +102 -0
  163. package/dist/automations/steps/createRow.js +5 -8
  164. package/dist/automations/steps/deleteRow.js +7 -10
  165. package/dist/automations/steps/queryRows.js +11 -14
  166. package/dist/automations/steps/updateRow.js +4 -7
  167. package/dist/db/inMemoryView.js +51 -0
  168. package/dist/db/linkedRows/index.js +5 -2
  169. package/dist/db/utils.js +7 -0
  170. package/dist/environment.js +7 -1
  171. package/dist/integrations/mysql.js +2 -13
  172. package/dist/integrations/postgres.js +8 -14
  173. package/dist/integrations/utils.js +19 -1
  174. package/dist/package.json +5 -5
  175. package/dist/tsconfig.tsbuildinfo +1 -1
  176. package/dist/utilities/rowProcessor/index.js +10 -5
  177. package/package.json +6 -6
  178. package/scripts/integrations/service-vehicles/docker-compose.yml +28 -0
  179. package/scripts/integrations/service-vehicles/init.sql +52 -0
  180. package/scripts/integrations/service-vehicles/reset.sh +3 -0
  181. package/src/api/controllers/datasource.js +2 -2
  182. package/src/api/controllers/row/ExternalRequest.ts +5 -1
  183. package/src/api/controllers/row/internal.js +88 -23
  184. package/src/api/controllers/table/index.js +1 -1
  185. package/src/api/controllers/table/utils.js +16 -12
  186. package/src/api/controllers/view/index.js +82 -116
  187. package/src/api/controllers/view/utils.js +109 -0
  188. package/src/api/routes/tests/view.spec.js +1 -1
  189. package/src/automations/steps/createRow.js +5 -8
  190. package/src/automations/steps/deleteRow.js +8 -10
  191. package/src/automations/steps/queryRows.js +11 -14
  192. package/src/automations/steps/updateRow.js +7 -10
  193. package/src/db/inMemoryView.js +48 -0
  194. package/src/db/linkedRows/index.js +5 -2
  195. package/src/db/utils.js +9 -0
  196. package/src/environment.js +8 -1
  197. package/src/integrations/mysql.ts +2 -13
  198. package/src/integrations/postgres.ts +9 -16
  199. package/src/integrations/utils.ts +18 -0
  200. 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
- request: {
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
- let linked = (yield db.allDocs(getMultiIDParams(linkedRowIds))).rows.map(row => row.doc);
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
  */
@@ -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: !!parseInt(process.env.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
- // add the existing relationships from the entities if they exist, to prevent them from being overridden
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 isAuto = typeof column.column_default === "string" &&
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.3",
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.3",
66
- "@budibase/client": "^0.9.140-alpha.3",
67
- "@budibase/string-templates": "^0.9.140-alpha.3",
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",