@budibase/server 1.0.219 → 1.0.220-alpha.0

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 (275) hide show
  1. package/__mocks__/node-fetch.ts +9 -0
  2. package/builder/assets/index.530f60fc.js +978 -0
  3. package/builder/assets/index.7786f497.css +6 -0
  4. package/builder/assets/{vendor.9bf2fcb4.js → vendor.001dcf8c.js} +163 -163
  5. package/builder/index.html +3 -3
  6. package/coverage/clover.xml +927 -832
  7. package/coverage/coverage-final.json +29 -29
  8. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/automation.js.html +111 -12
  11. package/coverage/lcov-report/api/controllers/backup.js.html +9 -6
  12. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
  15. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  16. package/coverage/lcov-report/api/controllers/index.html +21 -21
  17. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  23. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/external.js.html +47 -17
  27. package/coverage/lcov-report/api/controllers/row/index.html +33 -33
  28. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +159 -21
  30. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/row/utils.js.html +17 -8
  32. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  37. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  42. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  44. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  45. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  46. package/coverage/lcov-report/api/index.html +15 -15
  47. package/coverage/lcov-report/api/index.js.html +22 -13
  48. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/automation.js.html +32 -2
  52. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/index.html +1 -1
  59. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  73. package/coverage/lcov-report/api/routes/utils/validators.js.html +5 -2
  74. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  75. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  76. package/coverage/lcov-report/automations/actions.js.html +1 -1
  77. package/coverage/lcov-report/automations/automationUtils.js.html +57 -12
  78. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  79. package/coverage/lcov-report/automations/index.html +17 -17
  80. package/coverage/lcov-report/automations/index.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/executeQuery.js.html +2 -2
  85. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/filter.js.html +58 -34
  87. package/coverage/lcov-report/automations/steps/index.html +11 -11
  88. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  97. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  106. package/coverage/lcov-report/automations/triggers.js.html +4 -4
  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/inMemoryView.js.html +1 -1
  112. package/coverage/lcov-report/db/index.html +14 -14
  113. package/coverage/lcov-report/db/index.js.html +1 -1
  114. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  115. package/coverage/lcov-report/db/linkedRows/index.html +13 -13
  116. package/coverage/lcov-report/db/linkedRows/index.js.html +10 -7
  117. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  118. package/coverage/lcov-report/db/newid.js.html +2 -2
  119. package/coverage/lcov-report/db/utils.js.html +27 -51
  120. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  121. package/coverage/lcov-report/events/index.html +1 -1
  122. package/coverage/lcov-report/events/index.js.html +1 -1
  123. package/coverage/lcov-report/events/utils.js.html +1 -1
  124. package/coverage/lcov-report/index.html +81 -81
  125. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  126. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  127. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  128. package/coverage/lcov-report/middleware/builder.js.html +12 -12
  129. package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
  130. package/coverage/lcov-report/middleware/index.html +1 -1
  131. package/coverage/lcov-report/middleware/joi-validator.js.html +10 -10
  132. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  133. package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
  134. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  135. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  136. package/coverage/lcov-report/threads/automation.js.html +18 -9
  137. package/coverage/lcov-report/threads/index.html +25 -25
  138. package/coverage/lcov-report/threads/query.js.html +301 -79
  139. package/coverage/lcov-report/threads/utils.js.html +4 -4
  140. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  141. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  142. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  143. package/coverage/lcov-report/utilities/global.js.html +14 -14
  144. package/coverage/lcov-report/utilities/index.html +16 -16
  145. package/coverage/lcov-report/utilities/index.js.html +9 -9
  146. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
  147. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  148. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  149. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  150. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  151. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  152. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  153. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  154. package/coverage/lcov-report/utilities/security.js.html +2 -2
  155. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  156. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  157. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  158. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  159. package/coverage/lcov-report/utilities/users.js.html +1 -1
  160. package/coverage/lcov-report/utilities/workerRequests.js.html +57 -9
  161. package/coverage/lcov.info +1656 -1489
  162. package/dist/api/controllers/application.js +18 -15
  163. package/dist/api/controllers/automation.js +28 -2
  164. package/dist/api/controllers/backup.js +3 -2
  165. package/dist/api/controllers/public/applications.js +1 -1
  166. package/dist/api/controllers/public/utils.js +8 -1
  167. package/dist/api/controllers/query/index.js +31 -3
  168. package/dist/api/controllers/row/external.js +19 -7
  169. package/dist/api/controllers/row/internalSearch.js +47 -10
  170. package/dist/api/controllers/row/utils.js +3 -0
  171. package/dist/api/index.js +4 -1
  172. package/dist/api/routes/automation.js +2 -0
  173. package/dist/api/routes/public/rows.js +7 -2
  174. package/dist/api/routes/utils/validators.js +1 -0
  175. package/dist/app.js +20 -0
  176. package/dist/automations/automationUtils.js +16 -4
  177. package/dist/automations/logging/index.js +70 -0
  178. package/dist/automations/steps/executeQuery.js +1 -1
  179. package/dist/automations/steps/filter.js +38 -29
  180. package/dist/automations/triggers.js +1 -1
  181. package/dist/db/linkedRows/index.js +1 -0
  182. package/dist/db/utils.js +4 -31
  183. package/dist/definitions/datasource.js +1 -0
  184. package/dist/environment.js +3 -0
  185. package/dist/integrations/airtable.js +1 -0
  186. package/dist/integrations/arangodb.js +1 -0
  187. package/dist/integrations/base/sql.js +22 -3
  188. package/dist/integrations/couchdb.js +1 -0
  189. package/dist/integrations/dynamodb.js +1 -0
  190. package/dist/integrations/elasticsearch.js +1 -0
  191. package/dist/integrations/firebase.js +1 -0
  192. package/dist/integrations/googlesheets.js +1 -0
  193. package/dist/integrations/index.js +4 -0
  194. package/dist/integrations/microsoftSqlServer.js +2 -1
  195. package/dist/integrations/mongodb.js +1 -0
  196. package/dist/integrations/mysql.js +2 -1
  197. package/dist/integrations/oracle.js +1 -0
  198. package/dist/integrations/postgres.js +2 -1
  199. package/dist/integrations/queries/sql.js +3 -0
  200. package/dist/integrations/redis.js +1 -0
  201. package/dist/integrations/rest.js +2 -1
  202. package/dist/integrations/s3.js +1 -0
  203. package/dist/integrations/snowflake.js +102 -0
  204. package/dist/package.json +7 -6
  205. package/dist/tests/utilities/TestConfiguration.js +19 -6
  206. package/dist/threads/automation.js +6 -3
  207. package/dist/threads/index.js +15 -1
  208. package/dist/threads/query.js +65 -12
  209. package/dist/tsconfig.build.tsbuildinfo +1 -1
  210. package/dist/utilities/fileSystem/index.js +16 -6
  211. package/dist/utilities/workerRequests.js +8 -0
  212. package/package.json +8 -7
  213. package/scripts/dev/manage.js +2 -0
  214. package/scripts/integrations/oracle/instantclient/linux/arm64/basiclite-19.10.zip +0 -0
  215. package/scripts/integrations/oracle/instantclient/linux/arm64/install.sh +23 -0
  216. package/scripts/integrations/oracle/instantclient/linux/install.sh +10 -0
  217. package/specs/openapi.json +9 -5
  218. package/specs/openapi.yaml +10 -4
  219. package/src/api/controllers/application.ts +18 -14
  220. package/src/api/controllers/automation.js +35 -2
  221. package/src/api/controllers/backup.js +3 -2
  222. package/src/api/controllers/public/applications.ts +2 -2
  223. package/src/api/controllers/public/utils.ts +8 -1
  224. package/src/api/controllers/query/index.ts +40 -4
  225. package/src/api/controllers/row/external.js +19 -9
  226. package/src/api/controllers/row/internalSearch.js +55 -9
  227. package/src/api/controllers/row/utils.js +3 -0
  228. package/src/api/index.js +4 -1
  229. package/src/api/routes/automation.js +10 -0
  230. package/src/api/routes/public/rows.ts +7 -2
  231. package/src/api/routes/tests/query.spec.js +166 -1
  232. package/src/api/routes/utils/validators.js +1 -0
  233. package/src/app.ts +30 -1
  234. package/src/automations/automationUtils.js +19 -4
  235. package/src/automations/logging/index.ts +35 -0
  236. package/src/automations/steps/executeQuery.js +1 -1
  237. package/src/automations/steps/filter.js +36 -28
  238. package/src/automations/tests/filter.spec.js +2 -1
  239. package/src/automations/triggers.js +1 -1
  240. package/src/db/linkedRows/index.js +1 -0
  241. package/src/db/utils.js +5 -13
  242. package/src/definitions/common.ts +1 -0
  243. package/src/definitions/datasource.ts +2 -0
  244. package/src/definitions/openapi.ts +471 -469
  245. package/src/environment.js +3 -0
  246. package/src/integrations/airtable.ts +1 -0
  247. package/src/integrations/arangodb.ts +1 -0
  248. package/src/integrations/base/sql.ts +29 -11
  249. package/src/integrations/couchdb.ts +1 -0
  250. package/src/integrations/dynamodb.ts +1 -0
  251. package/src/integrations/elasticsearch.ts +1 -0
  252. package/src/integrations/firebase.ts +1 -0
  253. package/src/integrations/googlesheets.ts +1 -0
  254. package/src/integrations/index.ts +4 -0
  255. package/src/integrations/microsoftSqlServer.ts +2 -0
  256. package/src/integrations/mongodb.ts +1 -0
  257. package/src/integrations/mysql.ts +2 -0
  258. package/src/integrations/oracle.ts +1 -0
  259. package/src/integrations/postgres.ts +2 -0
  260. package/src/integrations/queries/sql.ts +3 -1
  261. package/src/integrations/redis.ts +1 -0
  262. package/src/integrations/rest.ts +2 -1
  263. package/src/integrations/s3.ts +1 -0
  264. package/src/integrations/snowflake.ts +99 -0
  265. package/src/integrations/tests/rest.spec.js +16 -1
  266. package/src/migrations/tests/index.spec.ts +18 -2
  267. package/src/module.d.ts +2 -0
  268. package/src/tests/utilities/TestConfiguration.js +22 -3
  269. package/src/threads/automation.js +6 -3
  270. package/src/threads/index.ts +5 -1
  271. package/src/threads/query.js +88 -14
  272. package/src/utilities/fileSystem/index.js +22 -8
  273. package/src/utilities/workerRequests.js +16 -0
  274. package/builder/assets/index.1c640a53.js +0 -1316
  275. package/builder/assets/index.24307ca0.css +0 -6
@@ -17,7 +17,7 @@ const { ObjectStoreBuckets } = require("../../constants");
17
17
  const { upload, retrieve, retrieveToTmp, streamUpload, deleteFolder, downloadTarball, } = require("./utilities");
18
18
  const { updateClientLibrary } = require("./clientLibrary");
19
19
  const env = require("../../environment");
20
- const { USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX, } = require("../../db/utils");
20
+ const { USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX, TABLE_ROW_PREFIX, } = require("../../db/utils");
21
21
  const MemoryStream = require("memorystream");
22
22
  const { getAppId } = require("@budibase/backend-core/context");
23
23
  const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..");
@@ -98,6 +98,17 @@ exports.apiFileReturn = contents => {
98
98
  fs.writeFileSync(path, contents);
99
99
  return fs.createReadStream(path);
100
100
  };
101
+ exports.defineFilter = excludeRows => {
102
+ if (excludeRows) {
103
+ return doc => !(doc._id.includes(USER_METDATA_PREFIX) ||
104
+ doc._id.includes(LINK_USER_METADATA_PREFIX) ||
105
+ doc._id.includes(TABLE_ROW_PREFIX));
106
+ }
107
+ else if (!excludeRows) {
108
+ return doc => !(doc._id.includes(USER_METDATA_PREFIX) ||
109
+ doc._id.includes(LINK_USER_METADATA_PREFIX));
110
+ }
111
+ };
101
112
  /**
102
113
  * Local utility to back up the database state for an app, excluding global user
103
114
  * data or user relationships.
@@ -105,9 +116,8 @@ exports.apiFileReturn = contents => {
105
116
  * @param {object} config Config to send to export DB
106
117
  * @returns {*} either a string or a stream of the backup
107
118
  */
108
- const backupAppData = (appId, config) => __awaiter(void 0, void 0, void 0, function* () {
109
- return yield exports.exportDB(appId, Object.assign(Object.assign({}, config), { filter: doc => !(doc._id.includes(USER_METDATA_PREFIX) ||
110
- doc._id.includes(LINK_USER_METADATA_PREFIX)) }));
119
+ const backupAppData = (appId, config, includeRows) => __awaiter(void 0, void 0, void 0, function* () {
120
+ return yield exports.exportDB(appId, Object.assign(Object.assign({}, config), { filter: exports.defineFilter(includeRows) }));
111
121
  });
112
122
  /**
113
123
  * Takes a copy of the database state for an app to the object store.
@@ -123,8 +133,8 @@ exports.performBackup = (appId, backupName) => __awaiter(void 0, void 0, void 0,
123
133
  * @param {string} appId The ID of the app which is to be backed up.
124
134
  * @returns {*} a readable stream of the backup which is written in real time
125
135
  */
126
- exports.streamBackup = (appId) => __awaiter(void 0, void 0, void 0, function* () {
127
- return yield backupAppData(appId, { stream: true });
136
+ exports.streamBackup = (appId, includeRows) => __awaiter(void 0, void 0, void 0, function* () {
137
+ return yield backupAppData(appId, { stream: true }, includeRows);
128
138
  });
129
139
  /**
130
140
  * Exports a DB to either file or a variable (memory).
@@ -120,3 +120,11 @@ exports.readGlobalUser = (ctx) => __awaiter(void 0, void 0, void 0, function* ()
120
120
  request(ctx, { method: "GET" }));
121
121
  return checkResponse(response, "get user", { ctx });
122
122
  });
123
+ exports.createAdminUser = (email, password, tenantId) => __awaiter(void 0, void 0, void 0, function* () {
124
+ const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + "/api/global/users/init"), request(null, { method: "POST", body: { email, password, tenantId } }));
125
+ return checkResponse(response, "create admin user");
126
+ });
127
+ exports.getChecklist = () => __awaiter(void 0, void 0, void 0, function* () {
128
+ const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + "/api/global/configs/checklist"), request(null, { method: "GET" }));
129
+ return checkResponse(response, "get checklist");
130
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "1.0.219",
4
+ "version": "1.0.220-alpha.0",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -77,10 +77,10 @@
77
77
  "license": "GPL-3.0",
78
78
  "dependencies": {
79
79
  "@apidevtools/swagger-parser": "10.0.3",
80
- "@budibase/backend-core": "^1.0.219",
81
- "@budibase/client": "^1.0.219",
82
- "@budibase/pro": "1.0.218",
83
- "@budibase/string-templates": "^1.0.219",
80
+ "@budibase/backend-core": "^1.0.220-alpha.0",
81
+ "@budibase/client": "^1.0.220-alpha.0",
82
+ "@budibase/pro": "1.0.219",
83
+ "@budibase/string-templates": "^1.0.220-alpha.0",
84
84
  "@bull-board/api": "3.7.0",
85
85
  "@bull-board/koa": "3.9.4",
86
86
  "@elastic/elasticsearch": "7.10.0",
@@ -135,6 +135,7 @@
135
135
  "pouchdb-replication-stream": "1.2.9",
136
136
  "redis": "4",
137
137
  "server-destroy": "1.0.1",
138
+ "snowflake-promise": "^4.5.0",
138
139
  "svelte": "3.44.1",
139
140
  "swagger-parser": "10.0.3",
140
141
  "to-json-schema": "0.2.5",
@@ -150,7 +151,7 @@
150
151
  "@babel/core": "7.17.4",
151
152
  "@babel/preset-env": "7.16.11",
152
153
  "@budibase/standard-components": "^0.9.139",
153
- "@budibase/types": "^1.0.219",
154
+ "@budibase/types": "^1.0.220-alpha.0",
154
155
  "@jest/test-sequencer": "24.9.0",
155
156
  "@types/apidoc": "0.50.0",
156
157
  "@types/bson": "4.2.0",
@@ -194,5 +195,5 @@
194
195
  "optionalDependencies": {
195
196
  "oracledb": "5.3.0"
196
197
  },
197
- "gitHead": "231b038a3c99f730dd27a595f870663dd84b7837"
198
+ "gitHead": "00cefe45cc19f1151ad2a4590d6a5aed0afa0ea7"
198
199
  }
@@ -56,6 +56,8 @@ async function init() {
56
56
  DISABLE_THREADING: 1,
57
57
  SERVICE: "app-service",
58
58
  DEPLOYMENT_ENVIRONMENT: "development",
59
+ BB_ADMIN_USER_EMAIL: "",
60
+ BB_ADMIN_USER_PASSWORD: "",
59
61
  }
60
62
  let envFile = ""
61
63
  Object.keys(envFileJson).forEach(key => {
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+
3
+ # Must be root to continue
4
+ if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
5
+
6
+ # Allow for re-runs
7
+ rm -rf /opt/oracle
8
+
9
+ echo "Installing oracle instant client"
10
+
11
+ # copy and unzip package
12
+ mkdir -p /opt/oracle
13
+ cp scripts/integrations/oracle/instantclient/linux/arm64/basiclite-19.10.zip /opt/oracle
14
+ cd /opt/oracle
15
+ unzip -qq basiclite-19.10.zip -d .
16
+ rm *.zip
17
+ mv instantclient* instantclient
18
+
19
+ # update runtime link path
20
+ sh -c "echo /opt/oracle/instantclient > /etc/ld.so.conf.d/oracle-instantclient.conf"
21
+ ldconfig /etc/ld.so.conf.d
22
+
23
+ echo "Installation complete"
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"
3
+ if [[ $TARGETARCH == arm* ]] ;
4
+ then
5
+ echo "Installing ARM Oracle instant client..."
6
+ $SCRIPT_DIR/arm64/install.sh
7
+ else
8
+ echo "Installing x86-64 Oracle instant client..."
9
+ $SCRIPT_DIR/x86-64/install.sh
10
+ fi
@@ -2137,6 +2137,10 @@
2137
2137
  "query": {
2138
2138
  "type": "object",
2139
2139
  "properties": {
2140
+ "allOr": {
2141
+ "type": "boolean",
2142
+ "description": "Specifies that a row should be returned if it satisfies any of the specified options, rather than requiring it to fulfill all the search parameters. This defaults to false, meaning AND logic will be used."
2143
+ },
2140
2144
  "string": {
2141
2145
  "type": "object",
2142
2146
  "example": {
@@ -2155,12 +2159,12 @@
2155
2159
  },
2156
2160
  "range": {
2157
2161
  "type": "object",
2158
- "description": "Searches within a range, the format of this must be columnName -> [low, high].",
2162
+ "description": "Searches within a range, the format of this must be in the format of an object with a \"low\" and \"high\" property.",
2159
2163
  "example": {
2160
- "columnName1": [
2161
- 10,
2162
- 20
2163
- ]
2164
+ "columnName1": {
2165
+ "low": 10,
2166
+ "high": 20
2167
+ }
2164
2168
  }
2165
2169
  },
2166
2170
  "equal": {
@@ -1551,6 +1551,12 @@ paths:
1551
1551
  query:
1552
1552
  type: object
1553
1553
  properties:
1554
+ allOr:
1555
+ type: boolean
1556
+ description: Specifies that a row should be returned if it satisfies any of the
1557
+ specified options, rather than requiring it to fulfill
1558
+ all the search parameters. This defaults to false,
1559
+ meaning AND logic will be used.
1554
1560
  string:
1555
1561
  type: object
1556
1562
  example:
@@ -1566,12 +1572,12 @@ paths:
1566
1572
  description: A fuzzy search, only supported by internal tables.
1567
1573
  range:
1568
1574
  type: object
1569
- description: Searches within a range, the format of this must be columnName ->
1570
- [low, high].
1575
+ description: Searches within a range, the format of this must be in the format
1576
+ of an object with a "low" and "high" property.
1571
1577
  example:
1572
1578
  columnName1:
1573
- - 10
1574
- - 20
1579
+ low: 10
1580
+ high: 20
1575
1581
  equal:
1576
1582
  type: object
1577
1583
  description: Searches for rows that have a column value that is exactly the
@@ -45,10 +45,12 @@ const { getTenantId, isMultiTenant } = require("@budibase/backend-core/tenancy")
45
45
  import { syncGlobalUsers } from "./user"
46
46
  const { app: appCache } = require("@budibase/backend-core/cache")
47
47
  import { cleanupAutomations } from "../../automations/utils"
48
+ import { checkAppMetadata } from "../../automations/logging"
48
49
  const {
49
50
  getAppDB,
50
51
  getProdAppDB,
51
52
  updateAppId,
53
+ doInAppContext,
52
54
  } = require("@budibase/backend-core/context")
53
55
  import { getUniqueRows } from "../../utilities/usageQuota/rows"
54
56
  import { quotas } from "@budibase/pro"
@@ -192,7 +194,7 @@ export const fetch = async (ctx: any) => {
192
194
  }
193
195
  }
194
196
 
195
- ctx.body = apps
197
+ ctx.body = await checkAppMetadata(apps)
196
198
  }
197
199
 
198
200
  export const fetchAppDefinition = async (ctx: any) => {
@@ -548,22 +550,24 @@ export const sync = async (ctx: any, next: any) => {
548
550
  }
549
551
 
550
552
  const updateAppPackage = async (appPackage: any, appId: any) => {
551
- const db = getAppDB()
552
- const application = await db.get(DocumentTypes.APP_METADATA)
553
+ return doInAppContext(appId, async () => {
554
+ const db = getAppDB()
555
+ const application = await db.get(DocumentTypes.APP_METADATA)
553
556
 
554
- const newAppPackage = { ...application, ...appPackage }
555
- if (appPackage._rev !== application._rev) {
556
- newAppPackage._rev = application._rev
557
- }
557
+ const newAppPackage = { ...application, ...appPackage }
558
+ if (appPackage._rev !== application._rev) {
559
+ newAppPackage._rev = application._rev
560
+ }
558
561
 
559
- // the locked by property is attached by server but generated from
560
- // Redis, shouldn't ever store it
561
- delete newAppPackage.lockedBy
562
+ // the locked by property is attached by server but generated from
563
+ // Redis, shouldn't ever store it
564
+ delete newAppPackage.lockedBy
562
565
 
563
- await db.put(newAppPackage)
564
- // remove any cached metadata, so that it will be updated
565
- await appCache.invalidateAppMetadata(appId)
566
- return newAppPackage
566
+ await db.put(newAppPackage)
567
+ // remove any cached metadata, so that it will be updated
568
+ await appCache.invalidateAppMetadata(appId)
569
+ return newAppPackage
570
+ })
567
571
  }
568
572
 
569
573
  const createEmptyAppPackage = async (ctx: any, app: any) => {
@@ -1,6 +1,10 @@
1
1
  const actions = require("../../automations/actions")
2
2
  const triggers = require("../../automations/triggers")
3
- const { getAutomationParams, generateAutomationID } = require("../../db/utils")
3
+ const {
4
+ getAutomationParams,
5
+ generateAutomationID,
6
+ DocumentTypes,
7
+ } = require("../../db/utils")
4
8
  const {
5
9
  checkForWebhooks,
6
10
  updateTestHistory,
@@ -9,8 +13,14 @@ const {
9
13
  const { deleteEntityMetadata } = require("../../utilities")
10
14
  const { MetadataTypes } = require("../../constants")
11
15
  const { setTestFlag, clearTestFlag } = require("../../utilities/redis")
12
- const { getAppDB } = require("@budibase/backend-core/context")
16
+ const {
17
+ getAppDB,
18
+ getProdAppDB,
19
+ doInAppContext,
20
+ } = require("@budibase/backend-core/context")
13
21
  const { events } = require("@budibase/backend-core")
22
+ const { app } = require("@budibase/backend-core/cache")
23
+ const { automations } = require("@budibase/pro")
14
24
 
15
25
  const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS)
16
26
  const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS)
@@ -183,6 +193,29 @@ exports.destroy = async function (ctx) {
183
193
  await events.automation.deleted(oldAutomation)
184
194
  }
185
195
 
196
+ exports.logSearch = async function (ctx) {
197
+ ctx.body = await automations.logs.logSearch(ctx.request.body)
198
+ }
199
+
200
+ exports.clearLogError = async function (ctx) {
201
+ const { automationId, appId } = ctx.request.body
202
+ await doInAppContext(appId, async () => {
203
+ const db = getProdAppDB()
204
+ const metadata = await db.get(DocumentTypes.APP_METADATA)
205
+ if (!automationId) {
206
+ delete metadata.automationErrors
207
+ } else if (
208
+ metadata.automationErrors &&
209
+ metadata.automationErrors[automationId]
210
+ ) {
211
+ delete metadata.automationErrors[automationId]
212
+ }
213
+ await db.put(metadata)
214
+ await app.invalidateAppMetadata(metadata.appId, metadata)
215
+ ctx.body = { message: `Error logs cleared.` }
216
+ })
217
+ }
218
+
186
219
  exports.getActionList = async function (ctx) {
187
220
  ctx.body = ACTION_DEFS
188
221
  }
@@ -3,11 +3,12 @@ const { events, context } = require("@budibase/backend-core")
3
3
  const { DocumentTypes } = require("../../db/utils")
4
4
 
5
5
  exports.exportAppDump = async function (ctx) {
6
- const { appId } = ctx.query
6
+ let { appId, excludeRows } = ctx.query
7
7
  const appName = decodeURI(ctx.query.appname)
8
+ excludeRows = excludeRows === "true"
8
9
  const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt`
9
10
  ctx.attachment(backupIdentifier)
10
- ctx.body = await streamBackup(appId)
11
+ ctx.body = await streamBackup(appId, excludeRows)
11
12
 
12
13
  await context.doInAppContext(appId, async () => {
13
14
  const appDb = context.getAppDB()
@@ -1,6 +1,6 @@
1
1
  const { getAllApps } = require("@budibase/backend-core/db")
2
2
  const { updateAppId } = require("@budibase/backend-core/context")
3
- import { search as stringSearch } from "./utils"
3
+ import { search as stringSearch, addRev } from "./utils"
4
4
  import * as controller from "../application"
5
5
  import { Application } from "../../../definitions/common"
6
6
 
@@ -47,7 +47,7 @@ export async function read(ctx: any, next: any) {
47
47
  }
48
48
 
49
49
  export async function update(ctx: any, next: any) {
50
- ctx.request.body = fixAppID(ctx.request.body, ctx.params)
50
+ ctx.request.body = await addRev(fixAppID(ctx.request.body, ctx.params))
51
51
  updateAppId(ctx.params.appId)
52
52
  await controller.update(ctx)
53
53
  await setResponseApp(ctx)
@@ -1,5 +1,6 @@
1
1
  const { getAppDB } = require("@budibase/backend-core/context")
2
2
  import { isExternalTable } from "../../../integrations/utils"
3
+ import { APP_PREFIX, DocumentTypes } from "../../../db/utils"
3
4
 
4
5
  export async function addRev(
5
6
  body: { _id?: string; _rev?: string },
@@ -8,9 +9,15 @@ export async function addRev(
8
9
  if (!body._id || (tableId && isExternalTable(tableId))) {
9
10
  return body
10
11
  }
12
+ let id = body._id
13
+ if (body._id.startsWith(APP_PREFIX)) {
14
+ id = DocumentTypes.APP_METADATA
15
+ }
11
16
  const db = getAppDB()
12
- const dbDoc = await db.get(body._id)
17
+ const dbDoc = await db.get(id)
13
18
  body._rev = dbDoc._rev
19
+ // update ID in case it is an app ID
20
+ body._id = id
14
21
  return body
15
22
  }
16
23
 
@@ -8,6 +8,8 @@ import { QUERY_THREAD_TIMEOUT } from "../../../environment"
8
8
  import { getAppDB } from "@budibase/backend-core/context"
9
9
  import { quotas } from "@budibase/pro"
10
10
  import { events } from "@budibase/backend-core"
11
+ import { getCookie } from "@budibase/backend-core/utils"
12
+ import { Cookies, Configs } from "@budibase/backend-core/constants"
11
13
 
12
14
  const Runner = new Thread(ThreadType.QUERY, {
13
15
  timeoutMs: QUERY_THREAD_TIMEOUT || 10000,
@@ -110,6 +112,21 @@ export async function find(ctx: any) {
110
112
  ctx.body = query
111
113
  }
112
114
 
115
+ //Required to discern between OIDC OAuth config entries
116
+ function getOAuthConfigCookieId(ctx: any) {
117
+ if (ctx.user.providerType === Configs.OIDC) {
118
+ return getCookie(ctx, Cookies.OIDC_CONFIG)
119
+ }
120
+ }
121
+
122
+ function getAuthConfig(ctx: any) {
123
+ const authCookie = getCookie(ctx, Cookies.Auth)
124
+ let authConfigCtx: any = {}
125
+ authConfigCtx["configId"] = getOAuthConfigCookieId(ctx)
126
+ authConfigCtx["sessionId"] = authCookie ? authCookie.sessionId : null
127
+ return authConfigCtx
128
+ }
129
+
113
130
  export async function preview(ctx: any) {
114
131
  const db = getAppDB()
115
132
 
@@ -119,6 +136,8 @@ export async function preview(ctx: any) {
119
136
  // this stops dynamic variables from calling the same query
120
137
  const { fields, parameters, queryVerb, transformer, queryId } = query
121
138
 
139
+ const authConfigCtx: any = getAuthConfig(ctx)
140
+
122
141
  try {
123
142
  const runFn = () =>
124
143
  Runner.run({
@@ -129,8 +148,11 @@ export async function preview(ctx: any) {
129
148
  parameters,
130
149
  transformer,
131
150
  queryId,
151
+ ctx: {
152
+ user: ctx.user,
153
+ auth: { ...authConfigCtx },
154
+ },
132
155
  })
133
-
134
156
  const { rows, keys, info, extra } = await quotas.addQuery(runFn)
135
157
  await events.query.previewed(datasource, query)
136
158
  ctx.body = {
@@ -144,12 +166,19 @@ export async function preview(ctx: any) {
144
166
  }
145
167
  }
146
168
 
147
- async function execute(ctx: any, opts = { rowsOnly: false }) {
169
+ async function execute(
170
+ ctx: any,
171
+ opts: any = { rowsOnly: false, isAutomation: false }
172
+ ) {
148
173
  const db = getAppDB()
149
174
 
150
175
  const query = await db.get(ctx.params.queryId)
151
176
  const datasource = await db.get(query.datasourceId)
152
177
 
178
+ let authConfigCtx: any = {}
179
+ if (!opts.isAutomation) {
180
+ authConfigCtx = getAuthConfig(ctx)
181
+ }
153
182
  const enrichedParameters = ctx.request.body.parameters || {}
154
183
  // make sure parameters are fully enriched with defaults
155
184
  if (query && query.parameters) {
@@ -172,6 +201,10 @@ async function execute(ctx: any, opts = { rowsOnly: false }) {
172
201
  parameters: enrichedParameters,
173
202
  transformer: query.transformer,
174
203
  queryId: ctx.params.queryId,
204
+ ctx: {
205
+ user: ctx.user,
206
+ auth: { ...authConfigCtx },
207
+ },
175
208
  })
176
209
 
177
210
  const { rows, pagination, extra } = await quotas.addQuery(runFn)
@@ -189,8 +222,11 @@ export async function executeV1(ctx: any) {
189
222
  return execute(ctx, { rowsOnly: true })
190
223
  }
191
224
 
192
- export async function executeV2(ctx: any) {
193
- return execute(ctx, { rowsOnly: false })
225
+ export async function executeV2(
226
+ ctx: any,
227
+ { isAutomation }: { isAutomation?: boolean } = {}
228
+ ) {
229
+ return execute(ctx, { rowsOnly: false, isAutomation })
194
230
  }
195
231
 
196
232
  const removeDynamicVariables = async (queryId: any) => {
@@ -155,34 +155,44 @@ exports.validate = async () => {
155
155
  }
156
156
 
157
157
  exports.exportRows = async ctx => {
158
- const { datasourceId, tableName } = breakExternalTableId(ctx.params.tableId)
158
+ const { datasourceId } = breakExternalTableId(ctx.params.tableId)
159
159
  const db = getAppDB()
160
- let format = ctx.query.format
160
+ const format = ctx.query.format
161
+ const { columns } = ctx.request.body
161
162
  const datasource = await db.get(datasourceId)
162
163
  if (!datasource || !datasource.entities) {
163
164
  ctx.throw(400, "Datasource has not been configured for plus API.")
164
165
  }
165
- const tables = datasource.entities
166
- const table = tables[tableName]
167
166
  ctx.request.body = {
168
167
  query: {
169
168
  oneOf: {
170
- [table.primaryDisplay]: ctx.request.body.rows.map(
171
- id => breakRowIdField(id)[0]
172
- ),
169
+ _id: ctx.request.body.rows.map(row => JSON.parse(decodeURI(row))[0]),
173
170
  },
174
171
  },
175
172
  }
176
173
 
177
174
  let result = await exports.search(ctx)
175
+ let rows = []
176
+
177
+ // Filter data to only specified columns if required
178
+ if (columns && columns.length) {
179
+ for (let i = 0; i < result.rows.length; i++) {
180
+ rows[i] = {}
181
+ for (let column of columns) {
182
+ rows[i][column] = result.rows[i][column]
183
+ }
184
+ }
185
+ } else {
186
+ rows = result.rows
187
+ }
178
188
 
179
- let headers = Object.keys(result.rows[0])
189
+ let headers = Object.keys(rows[0])
180
190
  const exporter = exporters[format]
181
191
  const filename = `export.${format}`
182
192
 
183
193
  // send down the file
184
194
  ctx.attachment(filename)
185
- return apiFileReturn(exporter(headers, result.rows))
195
+ return apiFileReturn(exporter(headers, rows))
186
196
  }
187
197
 
188
198
  exports.fetchEnrichedRow = async ctx => {
@@ -10,6 +10,7 @@ const { getAppId } = require("@budibase/backend-core/context")
10
10
  class QueryBuilder {
11
11
  constructor(base) {
12
12
  this.query = {
13
+ allOr: false,
13
14
  string: {},
14
15
  fuzzy: {},
15
16
  range: {},
@@ -17,6 +18,7 @@ class QueryBuilder {
17
18
  notEqual: {},
18
19
  empty: {},
19
20
  notEmpty: {},
21
+ oneOf: {},
20
22
  ...base,
21
23
  }
22
24
  this.limit = 50
@@ -112,6 +114,11 @@ class QueryBuilder {
112
114
  return this
113
115
  }
114
116
 
117
+ addOneOf(key, value) {
118
+ this.query.oneOf[key] = value
119
+ return this
120
+ }
121
+
115
122
  /**
116
123
  * Preprocesses a value before going into a lucene search.
117
124
  * Transforms strings to lowercase and wraps strings and bools in quotes.
@@ -140,8 +147,22 @@ class QueryBuilder {
140
147
 
141
148
  buildSearchQuery() {
142
149
  const builder = this
143
- let query = "*:*"
150
+ let allOr = this.query && this.query.allOr
151
+ let query = allOr ? "" : "*:*"
144
152
  const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true }
153
+ let tableId
154
+ if (this.query.equal.tableId) {
155
+ tableId = this.query.equal.tableId
156
+ delete this.query.equal.tableId
157
+ }
158
+
159
+ const equal = (key, value) => {
160
+ // 0 evaluates to false, which means we would return all rows if we don't check it
161
+ if (!value && value !== 0) {
162
+ return null
163
+ }
164
+ return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`
165
+ }
145
166
 
146
167
  function build(structure, queryFn) {
147
168
  for (let [key, value] of Object.entries(structure)) {
@@ -152,7 +173,10 @@ class QueryBuilder {
152
173
  if (expression == null) {
153
174
  continue
154
175
  }
155
- query += ` AND ${expression}`
176
+ if (query.length > 0) {
177
+ query += ` ${allOr ? "OR" : "AND"} `
178
+ }
179
+ query += expression
156
180
  }
157
181
  }
158
182
 
@@ -198,13 +222,7 @@ class QueryBuilder {
198
222
  })
199
223
  }
200
224
  if (this.query.equal) {
201
- build(this.query.equal, (key, value) => {
202
- // 0 evaluates to false, which means we would return all rows if we don't check it
203
- if (!value && value !== 0) {
204
- return null
205
- }
206
- return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`
207
- })
225
+ build(this.query.equal, equal)
208
226
  }
209
227
  if (this.query.notEqual) {
210
228
  build(this.query.notEqual, (key, value) => {
@@ -220,6 +238,34 @@ class QueryBuilder {
220
238
  if (this.query.notEmpty) {
221
239
  build(this.query.notEmpty, key => `${key}:["" TO *]`)
222
240
  }
241
+ if (this.query.oneOf) {
242
+ build(this.query.oneOf, (key, value) => {
243
+ if (!Array.isArray(value)) {
244
+ if (typeof value === "string") {
245
+ value = value.split(",")
246
+ } else {
247
+ return ""
248
+ }
249
+ }
250
+ let orStatement = `${builder.preprocess(
251
+ value[0],
252
+ allPreProcessingOpts
253
+ )}`
254
+ for (let i = 1; i < value.length; i++) {
255
+ orStatement += ` OR ${builder.preprocess(
256
+ value[i],
257
+ allPreProcessingOpts
258
+ )}`
259
+ }
260
+ return `${key}:(${orStatement})`
261
+ })
262
+ }
263
+ // make sure table ID is always added as an AND
264
+ if (tableId) {
265
+ query = `(${query})`
266
+ allOr = false
267
+ build({ tableId }, equal)
268
+ }
223
269
  return query
224
270
  }
225
271
 
@@ -64,6 +64,9 @@ exports.validate = async ({ tableId, row, table }) => {
64
64
  // Validate.js doesn't seem to handle array
65
65
  if (type === FieldTypes.ARRAY && row[fieldName]) {
66
66
  if (row[fieldName].length) {
67
+ if (!Array.isArray(row[fieldName])) {
68
+ row[fieldName] = row[fieldName].split(",")
69
+ }
67
70
  row[fieldName].map(val => {
68
71
  if (
69
72
  !constraints.inclusion.includes(val) &&