@budibase/server 1.0.219 → 1.0.220-alpha.2

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 (284) hide show
  1. package/.yarnrc +1 -0
  2. package/__mocks__/node-fetch.ts +9 -0
  3. package/builder/assets/index.7786f497.css +6 -0
  4. package/builder/assets/index.e1885c5f.js +974 -0
  5. package/builder/assets/{vendor.9bf2fcb4.js → vendor.001dcf8c.js} +163 -163
  6. package/builder/index.html +3 -3
  7. package/coverage/clover.xml +1018 -950
  8. package/coverage/coverage-final.json +31 -31
  9. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/automation.js.html +111 -12
  12. package/coverage/lcov-report/api/controllers/backup.js.html +9 -6
  13. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
  16. package/coverage/lcov-report/api/controllers/dev.js.html +13 -166
  17. package/coverage/lcov-report/api/controllers/index.html +32 -32
  18. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  24. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/external.js.html +47 -17
  28. package/coverage/lcov-report/api/controllers/row/index.html +33 -33
  29. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +159 -21
  31. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  32. package/coverage/lcov-report/api/controllers/row/utils.js.html +17 -8
  33. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  38. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  42. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  44. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  45. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  46. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  47. package/coverage/lcov-report/api/index.html +15 -15
  48. package/coverage/lcov-report/api/index.js.html +22 -13
  49. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/automation.js.html +32 -2
  53. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/dev.js.html +2 -5
  59. package/coverage/lcov-report/api/routes/index.html +1 -1
  60. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  74. package/coverage/lcov-report/api/routes/utils/validators.js.html +5 -2
  75. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  76. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  77. package/coverage/lcov-report/automations/actions.js.html +1 -1
  78. package/coverage/lcov-report/automations/automationUtils.js.html +57 -12
  79. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  80. package/coverage/lcov-report/automations/index.html +17 -17
  81. package/coverage/lcov-report/automations/index.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/executeQuery.js.html +2 -2
  86. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/filter.js.html +58 -34
  88. package/coverage/lcov-report/automations/steps/index.html +11 -11
  89. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  97. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  98. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  106. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  107. package/coverage/lcov-report/automations/triggers.js.html +4 -4
  108. package/coverage/lcov-report/constants/index.html +1 -1
  109. package/coverage/lcov-report/constants/index.js.html +1 -1
  110. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  111. package/coverage/lcov-report/constants/screens.js.html +1 -1
  112. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  113. package/coverage/lcov-report/db/index.html +14 -14
  114. package/coverage/lcov-report/db/index.js.html +1 -1
  115. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  116. package/coverage/lcov-report/db/linkedRows/index.html +13 -13
  117. package/coverage/lcov-report/db/linkedRows/index.js.html +10 -7
  118. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  119. package/coverage/lcov-report/db/newid.js.html +2 -2
  120. package/coverage/lcov-report/db/utils.js.html +27 -51
  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 +83 -83
  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/builder.js.html +12 -12
  130. package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
  131. package/coverage/lcov-report/middleware/index.html +1 -1
  132. package/coverage/lcov-report/middleware/joi-validator.js.html +10 -10
  133. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  134. package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
  135. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  136. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  137. package/coverage/lcov-report/threads/automation.js.html +18 -9
  138. package/coverage/lcov-report/threads/index.html +25 -25
  139. package/coverage/lcov-report/threads/query.js.html +301 -79
  140. package/coverage/lcov-report/threads/utils.js.html +4 -4
  141. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  142. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  143. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  144. package/coverage/lcov-report/utilities/global.js.html +14 -14
  145. package/coverage/lcov-report/utilities/index.html +26 -26
  146. package/coverage/lcov-report/utilities/index.js.html +17 -32
  147. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
  148. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  149. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  150. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  151. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  152. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  153. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  154. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  155. package/coverage/lcov-report/utilities/security.js.html +2 -2
  156. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  157. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  158. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  159. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  160. package/coverage/lcov-report/utilities/users.js.html +1 -1
  161. package/coverage/lcov-report/utilities/workerRequests.js.html +57 -9
  162. package/coverage/lcov.info +1789 -1665
  163. package/dist/api/controllers/application.js +19 -16
  164. package/dist/api/controllers/automation.js +28 -2
  165. package/dist/api/controllers/backup.js +3 -2
  166. package/dist/api/controllers/dev.js +2 -40
  167. package/dist/api/controllers/public/applications.js +1 -1
  168. package/dist/api/controllers/public/utils.js +8 -1
  169. package/dist/api/controllers/query/index.js +31 -3
  170. package/dist/api/controllers/row/external.js +19 -7
  171. package/dist/api/controllers/row/internalSearch.js +47 -10
  172. package/dist/api/controllers/row/utils.js +3 -0
  173. package/dist/api/controllers/static/index.js +1 -5
  174. package/dist/api/index.js +4 -1
  175. package/dist/api/routes/automation.js +2 -0
  176. package/dist/api/routes/dev.js +1 -2
  177. package/dist/api/routes/public/rows.js +7 -2
  178. package/dist/api/routes/utils/validators.js +1 -0
  179. package/dist/app.js +20 -0
  180. package/dist/automations/automationUtils.js +16 -4
  181. package/dist/automations/logging/index.js +70 -0
  182. package/dist/automations/steps/executeQuery.js +1 -1
  183. package/dist/automations/steps/filter.js +38 -29
  184. package/dist/automations/triggers.js +1 -1
  185. package/dist/db/linkedRows/index.js +1 -0
  186. package/dist/db/utils.js +4 -31
  187. package/dist/definitions/datasource.js +1 -0
  188. package/dist/environment.js +3 -0
  189. package/dist/integrations/airtable.js +1 -0
  190. package/dist/integrations/arangodb.js +1 -0
  191. package/dist/integrations/base/sql.js +22 -3
  192. package/dist/integrations/couchdb.js +1 -0
  193. package/dist/integrations/dynamodb.js +1 -0
  194. package/dist/integrations/elasticsearch.js +1 -0
  195. package/dist/integrations/firebase.js +1 -0
  196. package/dist/integrations/googlesheets.js +1 -0
  197. package/dist/integrations/index.js +4 -0
  198. package/dist/integrations/microsoftSqlServer.js +2 -1
  199. package/dist/integrations/mongodb.js +1 -0
  200. package/dist/integrations/mysql.js +2 -1
  201. package/dist/integrations/oracle.js +1 -0
  202. package/dist/integrations/postgres.js +2 -1
  203. package/dist/integrations/queries/sql.js +3 -0
  204. package/dist/integrations/redis.js +1 -0
  205. package/dist/integrations/rest.js +2 -1
  206. package/dist/integrations/s3.js +1 -0
  207. package/dist/integrations/snowflake.js +102 -0
  208. package/dist/package.json +7 -6
  209. package/dist/tests/utilities/TestConfiguration.js +19 -6
  210. package/dist/threads/automation.js +6 -3
  211. package/dist/threads/index.js +15 -1
  212. package/dist/threads/query.js +65 -12
  213. package/dist/tsconfig.build.tsbuildinfo +1 -1
  214. package/dist/utilities/fileSystem/index.js +16 -6
  215. package/dist/utilities/index.js +1 -5
  216. package/dist/utilities/workerRequests.js +8 -0
  217. package/package.json +8 -7
  218. package/scripts/dev/manage.js +2 -0
  219. package/scripts/integrations/oracle/instantclient/linux/arm64/basiclite-19.10.zip +0 -0
  220. package/scripts/integrations/oracle/instantclient/linux/arm64/install.sh +23 -0
  221. package/scripts/integrations/oracle/instantclient/linux/install.sh +10 -0
  222. package/specs/openapi.json +9 -5
  223. package/specs/openapi.yaml +10 -4
  224. package/src/api/controllers/application.ts +19 -19
  225. package/src/api/controllers/automation.js +35 -2
  226. package/src/api/controllers/backup.js +3 -2
  227. package/src/api/controllers/dev.js +2 -53
  228. package/src/api/controllers/public/applications.ts +2 -2
  229. package/src/api/controllers/public/utils.ts +8 -1
  230. package/src/api/controllers/query/index.ts +40 -4
  231. package/src/api/controllers/row/external.js +19 -9
  232. package/src/api/controllers/row/internalSearch.js +55 -9
  233. package/src/api/controllers/row/utils.js +3 -0
  234. package/src/api/controllers/static/index.js +1 -6
  235. package/src/api/index.js +4 -1
  236. package/src/api/routes/automation.js +10 -0
  237. package/src/api/routes/dev.js +0 -1
  238. package/src/api/routes/public/rows.ts +7 -2
  239. package/src/api/routes/tests/query.spec.js +166 -1
  240. package/src/api/routes/utils/validators.js +1 -0
  241. package/src/app.ts +30 -1
  242. package/src/automations/automationUtils.js +19 -4
  243. package/src/automations/logging/index.ts +35 -0
  244. package/src/automations/steps/executeQuery.js +1 -1
  245. package/src/automations/steps/filter.js +36 -28
  246. package/src/automations/tests/filter.spec.js +2 -1
  247. package/src/automations/triggers.js +1 -1
  248. package/src/db/linkedRows/index.js +1 -0
  249. package/src/db/utils.js +5 -13
  250. package/src/definitions/common.ts +1 -0
  251. package/src/definitions/datasource.ts +2 -0
  252. package/src/definitions/openapi.ts +471 -469
  253. package/src/environment.js +3 -0
  254. package/src/integrations/airtable.ts +1 -0
  255. package/src/integrations/arangodb.ts +1 -0
  256. package/src/integrations/base/sql.ts +29 -11
  257. package/src/integrations/couchdb.ts +1 -0
  258. package/src/integrations/dynamodb.ts +1 -0
  259. package/src/integrations/elasticsearch.ts +1 -0
  260. package/src/integrations/firebase.ts +1 -0
  261. package/src/integrations/googlesheets.ts +1 -0
  262. package/src/integrations/index.ts +4 -0
  263. package/src/integrations/microsoftSqlServer.ts +2 -0
  264. package/src/integrations/mongodb.ts +1 -0
  265. package/src/integrations/mysql.ts +2 -0
  266. package/src/integrations/oracle.ts +1 -0
  267. package/src/integrations/postgres.ts +2 -0
  268. package/src/integrations/queries/sql.ts +3 -1
  269. package/src/integrations/redis.ts +1 -0
  270. package/src/integrations/rest.ts +2 -1
  271. package/src/integrations/s3.ts +1 -0
  272. package/src/integrations/snowflake.ts +99 -0
  273. package/src/integrations/tests/rest.spec.js +16 -1
  274. package/src/migrations/tests/index.spec.ts +18 -2
  275. package/src/module.d.ts +2 -0
  276. package/src/tests/utilities/TestConfiguration.js +22 -3
  277. package/src/threads/automation.js +6 -3
  278. package/src/threads/index.ts +5 -1
  279. package/src/threads/query.js +88 -14
  280. package/src/utilities/fileSystem/index.js +22 -8
  281. package/src/utilities/index.js +1 -6
  282. package/src/utilities/workerRequests.js +16 -0
  283. package/builder/assets/index.1c640a53.js +0 -1316
  284. 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).
@@ -57,12 +57,8 @@ exports.objectStoreUrl = () => {
57
57
  * @return {string} The URL to be inserted into appPackage response or server rendered
58
58
  * app index file.
59
59
  */
60
- exports.clientLibraryPath = (appId, version, ctx) => {
60
+ exports.clientLibraryPath = (appId, version) => {
61
61
  if (env.isProd()) {
62
- // TODO: remove - for beta testing UI
63
- if (ctx && ctx.cookies.get("beta:design_ui")) {
64
- return "https://cdn.budi.live/beta:design_ui/budibase-client.js";
65
- }
66
62
  let url = `${exports.objectStoreUrl()}/${sanitizeKey(appId)}/budibase-client.js`;
67
63
  // append app version to bust the cache
68
64
  if (version) {
@@ -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.2",
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.2",
81
+ "@budibase/client": "^1.0.220-alpha.2",
82
+ "@budibase/pro": "1.0.220-alpha.1",
83
+ "@budibase/string-templates": "^1.0.220-alpha.2",
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.2",
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": "80b7a2da2fba39ff25622873c95598fa931ea6ed"
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) => {
@@ -227,11 +229,7 @@ export const fetchAppPackage = async (ctx: any) => {
227
229
  application,
228
230
  screens,
229
231
  layouts,
230
- clientLibPath: clientLibraryPath(
231
- ctx.params.appId,
232
- application.version,
233
- ctx
234
- ),
232
+ clientLibPath: clientLibraryPath(ctx.params.appId, application.version),
235
233
  }
236
234
  }
237
235
 
@@ -548,22 +546,24 @@ export const sync = async (ctx: any, next: any) => {
548
546
  }
549
547
 
550
548
  const updateAppPackage = async (appPackage: any, appId: any) => {
551
- const db = getAppDB()
552
- const application = await db.get(DocumentTypes.APP_METADATA)
549
+ return doInAppContext(appId, async () => {
550
+ const db = getAppDB()
551
+ const application = await db.get(DocumentTypes.APP_METADATA)
553
552
 
554
- const newAppPackage = { ...application, ...appPackage }
555
- if (appPackage._rev !== application._rev) {
556
- newAppPackage._rev = application._rev
557
- }
553
+ const newAppPackage = { ...application, ...appPackage }
554
+ if (appPackage._rev !== application._rev) {
555
+ newAppPackage._rev = application._rev
556
+ }
558
557
 
559
- // the locked by property is attached by server but generated from
560
- // Redis, shouldn't ever store it
561
- delete newAppPackage.lockedBy
558
+ // the locked by property is attached by server but generated from
559
+ // Redis, shouldn't ever store it
560
+ delete newAppPackage.lockedBy
562
561
 
563
- await db.put(newAppPackage)
564
- // remove any cached metadata, so that it will be updated
565
- await appCache.invalidateAppMetadata(appId)
566
- return newAppPackage
562
+ await db.put(newAppPackage)
563
+ // remove any cached metadata, so that it will be updated
564
+ await appCache.invalidateAppMetadata(appId)
565
+ return newAppPackage
566
+ })
567
567
  }
568
568
 
569
569
  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()
@@ -3,12 +3,8 @@ const env = require("../../environment")
3
3
  const { checkSlashesInUrl } = require("../../utilities")
4
4
  const { request } = require("../../utilities/workerRequests")
5
5
  const { clearLock } = require("../../utilities/redis")
6
- const {
7
- Replication,
8
- getProdAppID,
9
- dangerousGetDB,
10
- } = require("@budibase/backend-core/db")
11
- const { DocumentTypes, getRowParams } = require("../../db/utils")
6
+ const { Replication, getProdAppID } = require("@budibase/backend-core/db")
7
+ const { DocumentTypes } = require("../../db/utils")
12
8
  const { app: appCache } = require("@budibase/backend-core/cache")
13
9
  const { getProdAppDB, getAppDB } = require("@budibase/backend-core/context")
14
10
  const { events } = require("@budibase/backend-core")
@@ -137,50 +133,3 @@ exports.getBudibaseVersion = async ctx => {
137
133
  }
138
134
  await events.installation.versionChecked(version)
139
135
  }
140
-
141
- // TODO: remove as part of beta program
142
- exports.checkBetaAccess = async ctx => {
143
- // go to the cloud platform if running self hosted
144
- if (env.SELF_HOSTED || !env.MULTI_TENANCY) {
145
- let baseUrl = ""
146
- if (env.ACCOUNT_PORTAL_URL) {
147
- baseUrl = env.ACCOUNT_PORTAL_URL.replace("account.", "")
148
- } else {
149
- baseUrl = "https://budibase.app"
150
- }
151
-
152
- const response = await fetch(
153
- `${baseUrl}/api/beta/access?email=${ctx.query.email}`
154
- )
155
- const json = await response.json()
156
- ctx.body = json
157
- return
158
- }
159
-
160
- const userToCheck = ctx.query.email
161
- const BETA_USERS_DB = "app_bb_f9b77d06b9db4e3ca185476ab87a2364"
162
- const BETA_USERS_TABLE = "ta_8c2c6df1c03f49cfb6340e85e066dd15"
163
-
164
- try {
165
- const db = dangerousGetDB(BETA_USERS_DB)
166
- const betaUsers = (
167
- await db.allDocs(
168
- getRowParams(BETA_USERS_TABLE, null, {
169
- include_docs: true,
170
- })
171
- )
172
- ).rows.map(row => row.doc)
173
-
174
- let access = false
175
- for (let betaUser of betaUsers) {
176
- if (betaUser["Email address"].trim() === userToCheck) {
177
- access = true
178
- break
179
- }
180
- }
181
- ctx.body = { access }
182
- } catch (err) {
183
- console.error(err)
184
- ctx.body = { access: false }
185
- }
186
- }
@@ -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 => {