@budibase/server 0.9.188 → 0.9.190-alpha.10

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 (314) hide show
  1. package/Dockerfile +7 -1
  2. package/__mocks__/mssql.ts +1 -1
  3. package/__mocks__/oracledb.ts +31 -0
  4. package/__mocks__/pg.ts +3 -0
  5. package/builder/assets/bb-space-man.5be51a45.svg +290 -0
  6. package/builder/assets/index.2bd3b345.js +1316 -0
  7. package/builder/assets/index.4fb3f887.css +1 -0
  8. package/builder/assets/oracle.66592424.png +0 -0
  9. package/builder/assets/vendor.470042a4.js +152 -0
  10. package/builder/assets/vendor.5e1fe644.css +1 -0
  11. package/builder/index.html +4 -4
  12. package/coverage/clover.xml +1608 -1191
  13. package/coverage/coverage-final.json +97 -93
  14. package/coverage/lcov-report/api/controllers/analytics.js.html +2 -2
  15. package/coverage/lcov-report/api/controllers/apikeys.js.html +2 -2
  16. package/coverage/lcov-report/api/controllers/application.js.html +113 -80
  17. package/coverage/lcov-report/api/controllers/auth.js.html +19 -10
  18. package/coverage/lcov-report/api/controllers/automation.js.html +3 -3
  19. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/component.js.html +4 -4
  22. package/coverage/lcov-report/api/controllers/datasource.js.html +245 -41
  23. package/coverage/lcov-report/api/controllers/dev.js.html +16 -7
  24. package/coverage/lcov-report/api/controllers/hosting.js.html +10 -10
  25. package/coverage/lcov-report/api/controllers/index.html +98 -98
  26. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/layout.js.html +9 -9
  28. package/coverage/lcov-report/api/controllers/metadata.js.html +3 -3
  29. package/coverage/lcov-report/api/controllers/permission.js.html +3 -3
  30. package/coverage/lcov-report/api/controllers/query.js.html +79 -229
  31. package/coverage/lcov-report/api/controllers/role.js.html +9 -9
  32. package/coverage/lcov-report/api/controllers/routing.js.html +29 -29
  33. package/coverage/lcov-report/api/controllers/row/external.js.html +17 -8
  34. package/coverage/lcov-report/api/controllers/row/index.html +26 -26
  35. package/coverage/lcov-report/api/controllers/row/index.js.html +2 -2
  36. package/coverage/lcov-report/api/controllers/row/internal.js.html +9 -9
  37. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +2 -2
  38. package/coverage/lcov-report/api/controllers/row/utils.js.html +21 -30
  39. package/coverage/lcov-report/api/controllers/screen.js.html +3 -3
  40. package/coverage/lcov-report/api/controllers/script.js.html +3 -3
  41. package/coverage/lcov-report/api/controllers/table/external.js.html +1001 -0
  42. package/coverage/lcov-report/api/controllers/table/index.html +56 -26
  43. package/coverage/lcov-report/api/controllers/table/index.js.html +80 -350
  44. package/coverage/lcov-report/api/controllers/table/internal.js.html +533 -0
  45. package/coverage/lcov-report/api/controllers/table/utils.js.html +175 -52
  46. package/coverage/lcov-report/api/controllers/templates.js.html +4 -4
  47. package/coverage/lcov-report/api/controllers/user.js.html +390 -33
  48. package/coverage/lcov-report/api/controllers/view/exporters.js.html +19 -4
  49. package/coverage/lcov-report/api/controllers/view/index.html +22 -22
  50. package/coverage/lcov-report/api/controllers/view/index.js.html +52 -13
  51. package/coverage/lcov-report/api/controllers/view/utils.js.html +11 -11
  52. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +3 -3
  53. package/coverage/lcov-report/api/controllers/webhook.js.html +4 -4
  54. package/coverage/lcov-report/api/index.html +1 -1
  55. package/coverage/lcov-report/api/index.js.html +5 -5
  56. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/application.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/dev.js.html +2 -2
  67. package/coverage/lcov-report/api/routes/hosting.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/index.html +4 -4
  69. package/coverage/lcov-report/api/routes/index.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/query.js.html +5 -2
  75. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  76. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  77. package/coverage/lcov-report/api/routes/row.js.html +536 -2
  78. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  79. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  80. package/coverage/lcov-report/api/routes/static.js.html +2 -2
  81. package/coverage/lcov-report/api/routes/table.js.html +464 -2
  82. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  83. package/coverage/lcov-report/api/routes/user.js.html +17 -2
  84. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  85. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  86. package/coverage/lcov-report/automations/actions.js.html +2 -2
  87. package/coverage/lcov-report/automations/automationUtils.js.html +4 -4
  88. package/coverage/lcov-report/automations/bullboard.js.html +71 -20
  89. package/coverage/lcov-report/automations/index.html +35 -50
  90. package/coverage/lcov-report/automations/index.js.html +2 -2
  91. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/discord.js.html +3 -3
  96. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  97. package/coverage/lcov-report/automations/steps/executeScript.js.html +3 -3
  98. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  99. package/coverage/lcov-report/automations/steps/index.html +14 -14
  100. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  101. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +3 -3
  102. package/coverage/lcov-report/automations/steps/queryRows.js.html +3 -3
  103. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  104. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  105. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  106. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  107. package/coverage/lcov-report/automations/steps/utils.js.html +7 -7
  108. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  109. package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
  110. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
  111. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  112. package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
  113. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
  114. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
  115. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
  116. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
  117. package/coverage/lcov-report/automations/triggers.js.html +22 -10
  118. package/coverage/lcov-report/automations/utils.js.html +46 -16
  119. package/coverage/lcov-report/constants/index.html +5 -5
  120. package/coverage/lcov-report/constants/index.js.html +87 -21
  121. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  122. package/coverage/lcov-report/constants/screens.js.html +2 -2
  123. package/coverage/lcov-report/db/client.js.html +2 -2
  124. package/coverage/lcov-report/db/inMemoryView.js.html +2 -2
  125. package/coverage/lcov-report/db/index.html +2 -2
  126. package/coverage/lcov-report/db/index.js.html +1 -1
  127. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +6 -6
  128. package/coverage/lcov-report/db/linkedRows/index.html +10 -10
  129. package/coverage/lcov-report/db/linkedRows/index.js.html +5 -5
  130. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +6 -6
  131. package/coverage/lcov-report/db/newid.js.html +4 -4
  132. package/coverage/lcov-report/db/utils.js.html +75 -75
  133. package/coverage/lcov-report/events/AutomationEmitter.js.html +6 -6
  134. package/coverage/lcov-report/events/index.html +6 -6
  135. package/coverage/lcov-report/events/index.js.html +1 -1
  136. package/coverage/lcov-report/events/utils.js.html +5 -5
  137. package/coverage/lcov-report/index.html +106 -91
  138. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  139. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  140. package/coverage/lcov-report/middleware/appInfo.js.html +2 -2
  141. package/coverage/lcov-report/middleware/authorized.js.html +19 -16
  142. package/coverage/lcov-report/middleware/builder.js.html +22 -13
  143. package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
  144. package/coverage/lcov-report/middleware/index.html +23 -23
  145. package/coverage/lcov-report/middleware/joi-validator.js.html +2 -2
  146. package/coverage/lcov-report/middleware/resourceId.js.html +18 -18
  147. package/coverage/lcov-report/middleware/selfhost.js.html +2 -2
  148. package/coverage/lcov-report/middleware/usageQuota.js.html +4 -4
  149. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  150. package/coverage/lcov-report/{automations/thread.js.html → threads/automation.js.html} +90 -33
  151. package/coverage/lcov-report/threads/index.html +141 -0
  152. package/coverage/lcov-report/threads/index.js.html +278 -0
  153. package/coverage/lcov-report/threads/query.js.html +278 -0
  154. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  155. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  156. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  157. package/coverage/lcov-report/utilities/csvParser.js.html +144 -15
  158. package/coverage/lcov-report/utilities/global.js.html +38 -23
  159. package/coverage/lcov-report/utilities/index.html +48 -48
  160. package/coverage/lcov-report/utilities/index.js.html +49 -16
  161. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +31 -10
  162. package/coverage/lcov-report/utilities/queue/index.html +14 -14
  163. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  164. package/coverage/lcov-report/utilities/routing/index.js.html +2 -2
  165. package/coverage/lcov-report/utilities/rowProcessor/index.html +4 -4
  166. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +2 -2
  167. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +3 -3
  168. package/coverage/lcov-report/utilities/scriptRunner.js.html +16 -7
  169. package/coverage/lcov-report/utilities/security.js.html +3 -3
  170. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  171. package/coverage/lcov-report/utilities/users.js.html +1 -1
  172. package/coverage/lcov-report/utilities/workerRequests.js.html +5 -5
  173. package/coverage/lcov.info +2687 -1942
  174. package/dist/api/controllers/application.js +16 -6
  175. package/dist/api/controllers/auth.js +3 -3
  176. package/dist/api/controllers/datasource.js +67 -16
  177. package/dist/api/controllers/deploy/index.js +2 -0
  178. package/dist/api/controllers/dev.js +4 -1
  179. package/dist/api/controllers/query.js +32 -62
  180. package/dist/api/controllers/row/ExternalRequest.js +83 -36
  181. package/dist/api/controllers/row/external.js +3 -1
  182. package/dist/api/controllers/row/utils.js +6 -12
  183. package/dist/api/controllers/table/external.js +249 -0
  184. package/dist/api/controllers/table/index.js +49 -123
  185. package/dist/api/controllers/table/internal.js +146 -0
  186. package/dist/api/controllers/table/utils.js +62 -28
  187. package/dist/api/controllers/user.js +123 -11
  188. package/dist/api/controllers/view/exporters.js +4 -0
  189. package/dist/api/controllers/view/index.js +14 -2
  190. package/dist/api/routes/query.js +1 -1
  191. package/dist/api/routes/row.js +178 -0
  192. package/dist/api/routes/table.js +150 -1
  193. package/dist/api/routes/user.js +2 -1
  194. package/dist/app.js +2 -11
  195. package/dist/automations/bullboard.js +37 -10
  196. package/dist/automations/triggers.js +7 -3
  197. package/dist/automations/utils.js +11 -2
  198. package/dist/constants/index.js +19 -0
  199. package/dist/definitions/datasource.js +17 -1
  200. package/dist/environment.js +13 -0
  201. package/dist/integrations/base/IntegrationBase.js +2 -0
  202. package/dist/integrations/base/datasourcePlus.js +2 -0
  203. package/dist/integrations/base/sql.js +350 -177
  204. package/dist/integrations/base/sqlTable.js +143 -0
  205. package/dist/integrations/base/utils.js +30 -0
  206. package/dist/integrations/index.js +6 -0
  207. package/dist/integrations/microsoftSqlServer.js +117 -9
  208. package/dist/integrations/mysql.js +16 -85
  209. package/dist/integrations/oracle.js +367 -0
  210. package/dist/integrations/postgres.js +35 -28
  211. package/dist/integrations/utils.js +71 -9
  212. package/dist/middleware/authorized.js +2 -1
  213. package/dist/middleware/builder.js +4 -1
  214. package/dist/package.json +18 -9
  215. package/dist/tests/utilities/TestConfiguration.js +2 -1
  216. package/dist/{automations/thread.js → threads/automation.js} +26 -8
  217. package/dist/threads/index.js +64 -0
  218. package/dist/threads/query.js +64 -0
  219. package/dist/tsconfig.tsbuildinfo +1 -1
  220. package/dist/utilities/csvParser.js +46 -5
  221. package/dist/utilities/global.js +6 -2
  222. package/dist/utilities/index.js +11 -0
  223. package/dist/utilities/queue/inMemoryQueue.js +8 -0
  224. package/dist/utilities/scriptRunner.js +4 -1
  225. package/package.json +19 -10
  226. package/scripts/dev/manage.js +1 -0
  227. package/scripts/docs/README.md +31 -0
  228. package/scripts/docs/generate.js +74 -0
  229. package/scripts/docs/toSwagger.js +320 -0
  230. package/scripts/integrations/mssql/data/Dockerfile +9 -0
  231. package/scripts/integrations/mssql/data/entrypoint.sh +24 -0
  232. package/scripts/integrations/mssql/data/setup.sql +54 -0
  233. package/scripts/integrations/mssql/docker-compose.yaml +12 -0
  234. package/scripts/integrations/mssql/reset.sh +3 -0
  235. package/scripts/integrations/oracle/docker-compose.yml +19 -0
  236. package/scripts/integrations/oracle/instantclient/linux/x86-64/basiclite-21.4.zip +0 -0
  237. package/scripts/integrations/oracle/instantclient/linux/x86-64/install.sh +23 -0
  238. package/scripts/integrations/oracle/oracle.md +90 -0
  239. package/scripts/integrations/postgres/docker-compose.yml +3 -3
  240. package/scripts/likeCypress.ts +33 -0
  241. package/src/api/controllers/application.js +18 -7
  242. package/src/api/controllers/auth.js +3 -0
  243. package/src/api/controllers/datasource.js +84 -16
  244. package/src/api/controllers/deploy/index.js +2 -0
  245. package/src/api/controllers/dev.js +4 -1
  246. package/src/api/controllers/query.js +35 -85
  247. package/src/api/controllers/row/ExternalRequest.ts +99 -38
  248. package/src/api/controllers/row/external.js +4 -1
  249. package/src/api/controllers/row/utils.js +8 -11
  250. package/src/api/controllers/table/external.js +307 -0
  251. package/src/api/controllers/table/index.js +47 -137
  252. package/src/api/controllers/table/internal.js +151 -0
  253. package/src/api/controllers/table/utils.js +74 -33
  254. package/src/api/controllers/user.js +132 -13
  255. package/src/api/controllers/view/exporters.js +5 -0
  256. package/src/api/controllers/view/index.js +15 -2
  257. package/src/api/routes/query.js +1 -0
  258. package/src/api/routes/row.js +178 -0
  259. package/src/api/routes/table.js +154 -0
  260. package/src/api/routes/tests/application.spec.js +0 -2
  261. package/src/api/routes/tests/datasource.spec.js +2 -2
  262. package/src/api/routes/tests/misc.spec.js +5 -1
  263. package/src/api/routes/tests/query.spec.js +38 -9
  264. package/src/api/routes/tests/screen.spec.js +1 -1
  265. package/src/api/routes/user.js +5 -0
  266. package/src/app.ts +2 -10
  267. package/src/automations/bullboard.js +28 -11
  268. package/src/automations/tests/automation.spec.js +3 -4
  269. package/src/automations/triggers.js +7 -3
  270. package/src/automations/utils.js +12 -2
  271. package/src/constants/index.js +22 -0
  272. package/src/definitions/common.ts +7 -1
  273. package/src/definitions/datasource.ts +21 -3
  274. package/src/environment.js +15 -0
  275. package/src/integrations/airtable.ts +2 -1
  276. package/src/integrations/arangodb.ts +2 -1
  277. package/src/integrations/base/IntegrationBase.ts +6 -0
  278. package/src/integrations/base/datasourcePlus.ts +9 -0
  279. package/src/integrations/base/sql.ts +375 -218
  280. package/src/integrations/base/sqlTable.ts +180 -0
  281. package/src/integrations/base/utils.ts +22 -0
  282. package/src/integrations/couchdb.ts +2 -1
  283. package/src/integrations/dynamodb.ts +2 -1
  284. package/src/integrations/elasticsearch.ts +2 -1
  285. package/src/integrations/index.ts +7 -0
  286. package/src/integrations/microsoftSqlServer.ts +145 -13
  287. package/src/integrations/mongodb.ts +2 -1
  288. package/src/integrations/mysql.ts +23 -95
  289. package/src/integrations/oracle.ts +464 -0
  290. package/src/integrations/postgres.ts +45 -35
  291. package/src/integrations/rest.ts +2 -1
  292. package/src/integrations/s3.ts +2 -1
  293. package/src/integrations/tests/microsoftSqlServer.spec.js +22 -15
  294. package/src/integrations/tests/oracle.spec.js +94 -0
  295. package/src/integrations/tests/postgres.spec.js +4 -0
  296. package/src/integrations/utils.ts +78 -8
  297. package/src/middleware/authorized.js +2 -1
  298. package/src/middleware/builder.js +4 -1
  299. package/src/tests/utilities/TestConfiguration.js +2 -1
  300. package/src/{automations/thread.js → threads/automation.js} +27 -8
  301. package/src/threads/index.js +66 -0
  302. package/src/threads/query.js +66 -0
  303. package/src/utilities/csvParser.js +48 -5
  304. package/src/utilities/global.js +7 -2
  305. package/src/utilities/index.js +11 -0
  306. package/src/utilities/queue/inMemoryQueue.js +7 -0
  307. package/src/utilities/scriptRunner.js +4 -1
  308. package/src/utilities/tests/__snapshots__/csvParser.spec.js.snap +0 -6
  309. package/src/utilities/tests/csvParser.spec.js +3 -0
  310. package/tsconfig.json +1 -1
  311. package/builder/assets/index.550fdba7.js +0 -201
  312. package/builder/assets/index.7469e1e4.css +0 -29
  313. package/builder/assets/vendor.278a305c.js +0 -9
  314. package/builder/assets/vendor.d75d5eb7.css +0 -1
@@ -7,15 +7,193 @@ const { paramResource, paramSubResource, } = require("../../middleware/resourceI
7
7
  const { PermissionLevels, PermissionTypes, } = require("@budibase/auth/permissions");
8
8
  const router = Router();
9
9
  router
10
+ /**
11
+ * @api {get} /api/:tableId/:rowId/enrich Get an enriched row
12
+ * @apiName Get an enriched row
13
+ * @apiGroup rows
14
+ * @apiPermission table read access
15
+ * @apiDescription This API is only useful when dealing with rows that have relationships.
16
+ * Normally when a row is a returned from the API relationships will only have the structure
17
+ * `{ primaryDisplay: "name", _id: ... }` but this call will return the full related rows
18
+ * for each relationship instead.
19
+ *
20
+ * @apiParam {string} rowId The ID of the row which is to be retrieved and enriched.
21
+ *
22
+ * @apiSuccess {object} row The response body will be the enriched row.
23
+ */
10
24
  .get("/api/:tableId/:rowId/enrich", paramSubResource("tableId", "rowId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.fetchEnrichedRow)
25
+ /**
26
+ * @api {get} /api/:tableId/rows Get all rows in a table
27
+ * @apiName Get all rows in a table
28
+ * @apiGroup rows
29
+ * @apiPermission table read access
30
+ * @apiDescription This is a deprecated endpoint that should not be used anymore, instead use the search endpoint.
31
+ * This endpoint gets all of the rows within the specified table - it is not heavily used
32
+ * due to its lack of support for pagination. With SQL tables this will retrieve up to a limit and then
33
+ * will simply stop.
34
+ *
35
+ * @apiParam {string} tableId The ID of the table to retrieve all rows within.
36
+ *
37
+ * @apiSuccess {object[]} rows The response body will be an array of all rows found.
38
+ */
11
39
  .get("/api/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.fetch)
40
+ /**
41
+ * @api {get} /api/:tableId/rows/:rowId Retrieve a single row
42
+ * @apiName Retrieve a single row
43
+ * @apiGroup rows
44
+ * @apiPermission table read access
45
+ * @apiDescription This endpoint retrieves only the specified row. If you wish to retrieve
46
+ * a row by anything other than its _id field, use the search endpoint.
47
+ *
48
+ * @apiParam {string} tableId The ID of the table to retrieve a row from.
49
+ * @apiParam {string} rowId The ID of the row to retrieve.
50
+ *
51
+ * @apiSuccess {object} body The response body will be the row that was found.
52
+ */
12
53
  .get("/api/:tableId/rows/:rowId", paramSubResource("tableId", "rowId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.find)
54
+ /**
55
+ * @api {post} /api/:tableId/search Search for rows in a table
56
+ * @apiName Search for rows in a table
57
+ * @apiGroup rows
58
+ * @apiPermission table read access
59
+ * @apiDescription This is the primary method of accessing rows in Budibase, the data provider
60
+ * and data UI in the builder are built atop this. All filtering, sorting and pagination is
61
+ * handled through this, for internal and external (datasource plus, e.g. SQL) tables.
62
+ *
63
+ * @apiParam {string} tableId The ID of the table to retrieve rows from.
64
+ *
65
+ * @apiParam (Body) {boolean} [paginate] If pagination is required then this should be set to true,
66
+ * defaults to false.
67
+ * @apiParam (Body) {object} [query] This contains a set of filters which should be applied, if none
68
+ * specified then the request will be unfiltered. An example with all of the possible query
69
+ * options has been supplied below.
70
+ * @apiParam (Body) {number} [limit] This sets a limit for the number of rows that will be returned,
71
+ * this will be implemented at the database level if supported for performance reasons. This
72
+ * is useful when paginating to set exactly how many rows per page.
73
+ * @apiParam (Body) {string} [bookmark] If pagination is enabled then a bookmark will be returned
74
+ * with each successful search request, this should be supplied back to get the next page.
75
+ * @apiParam (Body) {object} [sort] If sort is desired this should contain the name of the column to
76
+ * sort on.
77
+ * @apiParam (Body) {string} [sortOrder] If sort is enabled then this can be either "descending" or
78
+ * "ascending" as required.
79
+ * @apiParam (Body) {string} [sortType] If sort is enabled then you must specify the type of search
80
+ * being used, either "string" or "number". This is only used for internal tables.
81
+ *
82
+ * @apiParamExample {json} Example:
83
+ * {
84
+ * "tableId": "ta_70260ff0b85c467ca74364aefc46f26d",
85
+ * "query": {
86
+ * "string": {},
87
+ * "fuzzy": {},
88
+ * "range": {
89
+ * "columnName": {
90
+ * "high": 20,
91
+ * "low": 10,
92
+ * }
93
+ * },
94
+ * "equal": {
95
+ * "columnName": "someValue"
96
+ * },
97
+ * "notEqual": {},
98
+ * "empty": {},
99
+ * "notEmpty": {},
100
+ * "contains": {},
101
+ * "notContains": {}
102
+ * "oneOf": {
103
+ * "columnName": ["value"]
104
+ * }
105
+ * },
106
+ * "limit": 10,
107
+ * "sort": "name",
108
+ * "sortOrder": "descending",
109
+ * "sortType": "string",
110
+ * "paginate": true
111
+ * }
112
+ *
113
+ * @apiSuccess {object[]} rows An array of rows that was found based on the supplied parameters.
114
+ * @apiSuccess {boolean} hasNextPage If pagination was enabled then this specifies whether or
115
+ * not there is another page after this request.
116
+ * @apiSuccess {string} bookmark The bookmark to be sent with the next request to get the next
117
+ * page.
118
+ */
13
119
  .post("/api/:tableId/search", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.search)
14
120
  // DEPRECATED - this is an old API, but for backwards compat it needs to be
15
121
  // supported still
16
122
  .post("/api/search/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.search)
123
+ /**
124
+ * @api {post} /api/:tableId/rows Creates a new row
125
+ * @apiName Creates a new row
126
+ * @apiGroup rows
127
+ * @apiPermission table write access
128
+ * @apiDescription This API will create a new row based on the supplied body. If the
129
+ * body includes an "_id" field then it will update an existing row if the field
130
+ * links to one. Please note that "_id", "_rev" and "tableId" are fields that are
131
+ * already used by Budibase tables and cannot be used for columns.
132
+ *
133
+ * @apiParam {string} tableId The ID of the table to save a row to.
134
+ *
135
+ * @apiParam (Body) {string} [_id] If the row exists already then an ID for the row must be provided.
136
+ * @apiParam (Body) {string} [_rev] If working with an existing row for an internal table its revision
137
+ * must also be provided.
138
+ * @apiParam (Body) {string} tableId The ID of the table should also be specified in the row body itself.
139
+ * @apiParam (Body) {any} [any] Any field supplied in the body will be assessed to see if it matches
140
+ * a column in the specified table. All other fields will be dropped and not stored.
141
+ *
142
+ * @apiSuccess {string} _id The ID of the row that was just saved, if it was just created this
143
+ * is the rows new ID.
144
+ * @apiSuccess {string} [_rev] If saving to an internal table a revision will also be returned.
145
+ * @apiSuccess {object} body The contents of the row that was saved will be returned as well.
146
+ */
17
147
  .post("/api/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), usage, rowController.save)
148
+ /**
149
+ * @api {patch} /api/:tableId/rows Updates a row
150
+ * @apiName Update a row
151
+ * @apiGroup rows
152
+ * @apiPermission table write access
153
+ * @apiDescription This endpoint is identical to the row creation endpoint but instead it will
154
+ * error if an _id isn't provided, it will only function for existing rows.
155
+ */
18
156
  .patch("/api/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), rowController.patch)
157
+ /**
158
+ * @api {post} /api/:tableId/rows/validate Validate inputs for a row
159
+ * @apiName Validate inputs for a row
160
+ * @apiGroup rows
161
+ * @apiPermission table write access
162
+ * @apiDescription When attempting to save a row you may want to check if the row is valid
163
+ * given the table schema, this will iterate through all the constraints on the table and
164
+ * check if the request body is valid.
165
+ *
166
+ * @apiParam {string} tableId The ID of the table the row is to be validated for.
167
+ *
168
+ * @apiParam (Body) {any} [any] Any fields provided in the request body will be tested
169
+ * against the table schema and constraints.
170
+ *
171
+ * @apiSuccess {boolean} valid If inputs provided are acceptable within the table schema this
172
+ * will be true, if it is not then then errors property will be populated.
173
+ * @apiSuccess {object} [errors] A key value map of information about fields on the input
174
+ * which do not match the table schema. The key name will be the column names that have breached
175
+ * the schema.
176
+ */
19
177
  .post("/api/:tableId/rows/validate", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), rowController.validate)
178
+ /**
179
+ * @api {delete} /api/:tableId/rows Delete rows
180
+ * @apiName Delete rows
181
+ * @apiGroup rows
182
+ * @apiPermission table write access
183
+ * @apiDescription This endpoint can delete a single row, or delete them in a bulk
184
+ * fashion.
185
+ *
186
+ * @apiParam {string} tableId The ID of the table the row is to be deleted from.
187
+ *
188
+ * @apiParam (Body) {object[]} [rows] If bulk deletion is desired then provide the rows in this
189
+ * key of the request body that are to be deleted.
190
+ * @apiParam (Body) {string} [_id] If deleting a single row then provide its ID in this field.
191
+ * @apiParam (Body) {string} [_rev] If deleting a single row from an internal table then provide its
192
+ * revision here.
193
+ *
194
+ * @apiSuccess {object[]|object} body If deleting bulk then the response body will be an array
195
+ * of the deleted rows, if deleting a single row then the body will contain a "row" property which
196
+ * is the deleted row.
197
+ */
20
198
  .delete("/api/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), usage, rowController.destroy);
21
199
  module.exports = router;
@@ -21,11 +21,160 @@ function generateSaveValidator() {
21
21
  }).unknown(true));
22
22
  }
23
23
  router
24
+ /**
25
+ * @api {get} /api/tables Fetch all tables
26
+ * @apiName Fetch all tables
27
+ * @apiGroup tables
28
+ * @apiPermission table read access
29
+ * @apiDescription This endpoint retrieves all of the tables which have been created in
30
+ * an app. This includes all of the external and internal tables; to tell the difference
31
+ * between these look for the "type" property on each table, either being "internal" or "external".
32
+ *
33
+ * @apiSuccess {object[]} body The response body will be the list of tables that was found - as
34
+ * this does not take any parameters the only error scenario is no access.
35
+ */
24
36
  .get("/api/tables", authorized(BUILDER), tableController.fetch)
37
+ /**
38
+ * @api {get} /api/tables/:id Fetch a single table
39
+ * @apiName Fetch a single table
40
+ * @apiGroup tables
41
+ * @apiPermission table read access
42
+ * @apiDescription Retrieves a single table this could be be internal or external based on
43
+ * the provided table ID.
44
+ *
45
+ * @apiParam {string} id The ID of the table which is to be retrieved.
46
+ *
47
+ * @apiSuccess {object[]} body The response body will be the table that was found.
48
+ */
25
49
  .get("/api/tables/:id", paramResource("id"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), tableController.find)
50
+ /**
51
+ * @api {post} /api/tables Save a table
52
+ * @apiName Save a table
53
+ * @apiGroup tables
54
+ * @apiPermission builder
55
+ * @apiDescription Create or update a table with this endpoint, this will function for both internal
56
+ * external tables.
57
+ *
58
+ * @apiParam (Body) {string} [_id] If updating an existing table then the ID of the table must be specified.
59
+ * @apiParam (Body) {string} [_rev] If updating an existing internal table then the revision must also be specified.
60
+ * @apiParam (Body) {string} type] This should either be "internal" or "external" depending on the table type -
61
+ * this will default to internal.
62
+ * @apiParam (Body) {string} [sourceId] If creating an external table then this should be set to the data source ID. If
63
+ * building an internal table this does not need to be set, although it will be returned as "bb_internal".
64
+ * @apiParam (Body) {string} name The name of the table, this will be used in the UI. To rename the table simply
65
+ * supply the table structure to this endpoint with the name changed.
66
+ * @apiParam (Body) {object} schema A key value object which has all of the columns in the table as the keys in this
67
+ * object. For each column a "type" and "constraints" must be specified, with some types requiring further information.
68
+ * More information about the schema structure can be found in the Typescript definitions.
69
+ * @apiParam (Body) {string} [primaryDisplay] The name of the column which should be used when displaying rows
70
+ * from this table as relationships.
71
+ * @apiParam (Body) {object[]} [indexes] Specifies the search indexes - this is deprecated behaviour with the introduction
72
+ * of lucene indexes. This functionality is only available for internal tables.
73
+ * @apiParam (Body) {object} [_rename] If a column is to be renamed then the "old" column name should be set in this
74
+ * structure, and the "updated", new column name should also be supplied. The schema should also be updated, this field
75
+ * lets the server know that a field hasn't just been deleted, that the data has moved to a new name, this will fix
76
+ * the rows in the table. This functionality is only available for internal tables.
77
+ * @apiParam (Body) {object} [dataImport] When creating an internal table it can be built from a CSV, by using the
78
+ * CSV validation endpoint. Send the CSV data to the validation endpoint, then put the results of that call
79
+ * into this property, along with the CSV and a table/rows will be built from it. This is not supported when updating
80
+ * or for external tables.
81
+ *
82
+ * @apiParamExample {json} Example:
83
+ * {
84
+ * "_id": "ta_05541307fa0f4044abee071ca2a82119",
85
+ * "_rev": "10-0fbe4e78f69b255d79f1017e2eeef807",
86
+ * "type": "internal",
87
+ * "views": {},
88
+ * "name": "tableName",
89
+ * "schema": {
90
+ * "column": {
91
+ * "type": "string",
92
+ * "constraints": {
93
+ * "type": "string",
94
+ * "length": {
95
+ * "maximum": null
96
+ * },
97
+ * "presence": false
98
+ * },
99
+ * "name": "column"
100
+ * },
101
+ * },
102
+ * "primaryDisplay": "column",
103
+ * "indexes": [],
104
+ * "sourceId": "bb_internal",
105
+ * "_rename": {
106
+ * "old": "columnName",
107
+ * "updated": "newColumnName",
108
+ * },
109
+ * "dataImport": {
110
+ * "csvString": "column\nvalue",
111
+ * "primaryDisplay": "column",
112
+ * "schema": {
113
+ * "column": {
114
+ * "type": "string"
115
+ * }
116
+ * }
117
+ * }
118
+ * }
119
+ *
120
+ * @apiSuccess {object} table The response body will contain the table structure after being cleaned up and
121
+ * saved to the database.
122
+ */
26
123
  .post("/api/tables",
27
124
  // allows control over updating a table
28
125
  bodyResource("_id"), authorized(BUILDER), generateSaveValidator(), tableController.save)
126
+ /**
127
+ * @api {post} /api/tables/csv/validate Validate a CSV for a table
128
+ * @apiName Validate a CSV for a table
129
+ * @apiGroup tables
130
+ * @apiPermission builder
131
+ * @apiDescription When creating a new table, or importing a CSV to an existing table the CSV must be validated and
132
+ * converted into a Budibase schema; this endpoint does this.
133
+ *
134
+ * @apiParam (Body) {string} csvString The CSV which is to be validated as a string.
135
+ * @apiParam (Body) {object} [schema] When a CSV has been validated it is possible to re-validate after changing the
136
+ * type of a field, by default everything will be strings as there is no way to infer types. The returned schema can
137
+ * be updated and then returned to the endpoint to re-validate and check if the type will work for the CSV, e.g.
138
+ * using a number instead of strings.
139
+ * @apiParam (Body) {string} [tableId] If importing data to an existing table this will pull the current table and
140
+ * remove any fields from the CSV schema which do not exist on the table/don't match the type of the table. When
141
+ * importing a CSV to an existing table only fields that are present on the table can be imported.
142
+ *
143
+ * @apiSuccess {object} schema The response body will contain a "schema" object that represents the schema found for
144
+ * the CSV - this will be in the same format used for table schema.s
145
+ */
29
146
  .post("/api/tables/csv/validate", authorized(BUILDER), tableController.validateCSVSchema)
30
- .delete("/api/tables/:tableId/:revId", paramResource("tableId"), authorized(BUILDER), tableController.destroy);
147
+ /**
148
+ * @api {post} /api/tables/:tableId/:revId Delete a table
149
+ * @apiName Delete a table
150
+ * @apiGroup tables
151
+ * @apiPermission builder
152
+ * @apiDescription This endpoint will delete a table and all of its associated data, for this reason it is
153
+ * quite dangerous - it will work for internal and external tables.
154
+ *
155
+ * @apiParam {string} tableId The ID of the table which is to be deleted.
156
+ * @apiParam {string} [revId] If deleting an internal table then the revision must also be supplied (_rev), for
157
+ * external tables this can simply be set to anything, e.g. "external".
158
+ *
159
+ * @apiSuccess {string} message A message stating that the table was deleted successfully.
160
+ */
161
+ .delete("/api/tables/:tableId/:revId", paramResource("tableId"), authorized(BUILDER), tableController.destroy)
162
+ /**
163
+ * @api {post} /api/tables/:tableId/:revId Import CSV to existing table
164
+ * @apiName Import CSV to existing table
165
+ * @apiGroup tables
166
+ * @apiPermission builder
167
+ * @apiDescription This endpoint will import data to existing tables, internal or external. It is used in combination
168
+ * with the CSV validation endpoint. Take the output of the CSV validation endpoint and pass it to this endpoint to
169
+ * import the data; please note this will only import fields that already exist on the table/match the type.
170
+ *
171
+ * @apiParam {string} tableId The ID of the table which the data should be imported to.
172
+ *
173
+ * @apiParam (Body) {object} dataImport This is the same as the structure used when creating an internal table with
174
+ * a CSV, it will have the "schema" returned from the CSV validation endpoint and the "csvString" which is to be
175
+ * turned into rows.
176
+ *
177
+ * @apiSuccess {string} message A message stating that the data was imported successfully.
178
+ */
179
+ .post("/api/tables/:tableId/import", paramResource("tableId"), authorized(BUILDER), tableController.bulkImport);
31
180
  module.exports = router;
@@ -9,5 +9,6 @@ router
9
9
  .get("/api/users/metadata/:id", authorized(PermissionTypes.USER, PermissionLevels.READ), controller.findMetadata)
10
10
  .put("/api/users/metadata", authorized(PermissionTypes.USER, PermissionLevels.WRITE), controller.updateMetadata)
11
11
  .post("/api/users/metadata/self", authorized(PermissionTypes.USER, PermissionLevels.WRITE), controller.updateSelfMetadata)
12
- .delete("/api/users/metadata/:id", authorized(PermissionTypes.USER, PermissionLevels.WRITE), controller.destroyMetadata);
12
+ .delete("/api/users/metadata/:id", authorized(PermissionTypes.USER, PermissionLevels.WRITE), controller.destroyMetadata)
13
+ .post("/api/users/metadata/sync/:id", authorized(PermissionTypes.USER, PermissionLevels.WRITE), controller.syncUser);
13
14
  module.exports = router;
package/dist/app.js CHANGED
@@ -41,17 +41,8 @@ app.use(pino({
41
41
  level: env.LOG_LEVEL || "error",
42
42
  }));
43
43
  if (!env.isTest()) {
44
- const bullApp = bullboard.init();
45
- app.use((ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
46
- if (ctx.path.startsWith(bullboard.pathPrefix)) {
47
- ctx.status = 200;
48
- ctx.respond = false;
49
- bullApp(ctx.req, ctx.res);
50
- }
51
- else {
52
- yield next();
53
- }
54
- }));
44
+ const plugin = bullboard.init();
45
+ app.use(plugin);
55
46
  }
56
47
  app.context.eventEmitter = eventEmitter;
57
48
  app.context.auth = {};
@@ -1,7 +1,16 @@
1
1
  "use strict";
2
- const { createBullBoard } = require("bull-board");
3
- const { BullAdapter } = require("bull-board/bullAdapter");
4
- const express = require("express");
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 { createBullBoard } = require("@bull-board/api");
12
+ const { BullAdapter } = require("@bull-board/api/bullAdapter");
13
+ const { KoaAdapter } = require("@bull-board/koa");
5
14
  const env = require("../environment");
6
15
  const Queue = env.isTest()
7
16
  ? require("../utilities/queue/inMemoryQueue")
@@ -9,19 +18,37 @@ const Queue = env.isTest()
9
18
  const { JobQueues } = require("../constants");
10
19
  const { utils } = require("@budibase/auth/redis");
11
20
  const { opts, redisProtocolUrl } = utils.getRedisOptions();
12
- const redisConfig = redisProtocolUrl || { redis: opts };
13
- let automationQueue = new Queue(JobQueues.AUTOMATIONS, redisConfig);
14
- exports.pathPrefix = "/bulladmin";
21
+ const CLEANUP_PERIOD_MS = 60 * 1000;
22
+ const queueConfig = redisProtocolUrl || { redis: opts };
23
+ let cleanupInternal = null;
24
+ let automationQueue = new Queue(JobQueues.AUTOMATIONS, queueConfig);
25
+ function cleanup() {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ yield automationQueue.clean(CLEANUP_PERIOD_MS, "completed");
28
+ });
29
+ }
30
+ const PATH_PREFIX = "/bulladmin";
15
31
  exports.init = () => {
16
- const expressApp = express();
32
+ // cleanup the events every 5 minutes
33
+ if (!cleanupInternal) {
34
+ cleanupInternal = setInterval(cleanup, CLEANUP_PERIOD_MS);
35
+ // fire off an initial cleanup
36
+ cleanup().catch(err => {
37
+ console.error(`Unable to cleanup automation queue initially - ${err}`);
38
+ });
39
+ }
17
40
  // Set up queues for bull board admin
18
41
  const queues = [automationQueue];
19
42
  const adapters = [];
43
+ const serverAdapter = new KoaAdapter();
20
44
  for (let queue of queues) {
21
45
  adapters.push(new BullAdapter(queue));
22
46
  }
23
- const { router } = createBullBoard(adapters);
24
- expressApp.use(exports.pathPrefix, router);
25
- return expressApp;
47
+ createBullBoard({
48
+ queues: adapters,
49
+ serverAdapter,
50
+ });
51
+ serverAdapter.setBasePath(PATH_PREFIX);
52
+ return serverAdapter.registerPlugin();
26
53
  };
27
54
  exports.queue = automationQueue;
@@ -20,6 +20,10 @@ const { checkTestFlag } = require("../utilities/redis");
20
20
  const utils = require("./utils");
21
21
  const env = require("../environment");
22
22
  const TRIGGER_DEFINITIONS = definitions;
23
+ const JOB_OPTS = {
24
+ removeOnComplete: true,
25
+ removeOnFail: true,
26
+ };
23
27
  function queueRelevantRowAutomations(event, eventType) {
24
28
  return __awaiter(this, void 0, void 0, function* () {
25
29
  if (event.appId == null) {
@@ -47,7 +51,7 @@ function queueRelevantRowAutomations(event, eventType) {
47
51
  }
48
52
  if (automationTrigger.inputs &&
49
53
  automationTrigger.inputs.tableId === event.row.tableId) {
50
- yield queue.add({ automation, event });
54
+ yield queue.add({ automation, event }, JOB_OPTS);
51
55
  }
52
56
  }
53
57
  });
@@ -85,7 +89,7 @@ exports.externalTrigger = function (automation, params, { getResponses } = {}) {
85
89
  automation.definition.trigger != null &&
86
90
  automation.definition.trigger.stepId === definitions.APP.stepId &&
87
91
  automation.definition.trigger.stepId === "APP" &&
88
- !checkTestFlag(automation._id)) {
92
+ !(yield checkTestFlag(automation._id))) {
89
93
  // values are likely to be submitted as strings, so we shall convert to correct type
90
94
  const coercedFields = {};
91
95
  const fields = automation.definition.trigger.inputs.fields;
@@ -99,7 +103,7 @@ exports.externalTrigger = function (automation, params, { getResponses } = {}) {
99
103
  return utils.processEvent({ data });
100
104
  }
101
105
  else {
102
- return queue.add(data);
106
+ return queue.add(data, JOB_OPTS);
103
107
  }
104
108
  });
105
109
  };
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- const runner = require("./thread");
11
+ const { Thread, ThreadType } = require("../threads");
12
12
  const { definitions } = require("./triggerInfo");
13
13
  const webhooks = require("../api/controllers/webhook");
14
14
  const CouchDB = require("../db");
@@ -19,10 +19,11 @@ const { MetadataTypes } = require("../constants");
19
19
  const { getDeployedAppID } = require("@budibase/auth/db");
20
20
  const WH_STEP_ID = definitions.WEBHOOK.stepId;
21
21
  const CRON_STEP_ID = definitions.CRON.stepId;
22
+ const Runner = new Thread(ThreadType.AUTOMATION);
22
23
  exports.processEvent = (job) => __awaiter(void 0, void 0, void 0, function* () {
23
24
  try {
24
25
  // need to actually await these so that an error can be captured properly
25
- return yield runner(job);
26
+ return yield Runner.run(job);
26
27
  }
27
28
  catch (err) {
28
29
  console.error(`${job.data.automation.appId} automation ${job.data.automation._id} was unable to run - ${err}`);
@@ -146,3 +147,11 @@ exports.checkForWebhooks = ({ appId, oldAuto, newAuto }) => __awaiter(void 0, vo
146
147
  }
147
148
  return newAuto;
148
149
  });
150
+ /**
151
+ * When removing an app/unpublishing it need to make sure automations are cleaned up (cron).
152
+ * @param appId {string} the app that is being removed.
153
+ * @return {Promise<void>} clean is complete if this succeeds.
154
+ */
155
+ exports.cleanupAutomations = (appId) => __awaiter(void 0, void 0, void 0, function* () {
156
+ yield exports.disableAllCrons(appId);
157
+ });
@@ -41,6 +41,12 @@ exports.FieldTypes = {
41
41
  JSON: "json",
42
42
  INTERNAL: "internal",
43
43
  };
44
+ exports.SwitchableTypes = [
45
+ exports.FieldTypes.STRING,
46
+ exports.FieldTypes.OPTIONS,
47
+ exports.FieldTypes.NUMBER,
48
+ exports.FieldTypes.BOOLEAN,
49
+ ];
44
50
  exports.RelationshipTypes = {
45
51
  ONE_TO_MANY: "one-to-many",
46
52
  MANY_TO_ONE: "many-to-one",
@@ -56,6 +62,10 @@ exports.DataSourceOperation = {
56
62
  READ: "READ",
57
63
  UPDATE: "UPDATE",
58
64
  DELETE: "DELETE",
65
+ BULK_CREATE: "BULK_CREATE",
66
+ CREATE_TABLE: "CREATE_TABLE",
67
+ UPDATE_TABLE: "UPDATE_TABLE",
68
+ DELETE_TABLE: "DELETE_TABLE",
59
69
  };
60
70
  exports.SortDirection = {
61
71
  ASCENDING: "ASCENDING",
@@ -140,5 +150,14 @@ exports.MetadataTypes = {
140
150
  AUTOMATION_TEST_INPUT: "automationTestInput",
141
151
  AUTOMATION_TEST_HISTORY: "automationTestHistory",
142
152
  };
153
+ exports.InvalidColumns = {
154
+ ID: "_id",
155
+ REV: "_rev",
156
+ TABLE_ID: "tableId",
157
+ };
158
+ exports.BuildSchemaErrors = {
159
+ NO_KEY: "no_key",
160
+ INVALID_COLUMN: "invalid_column",
161
+ };
143
162
  // pass through the list from the auth/core lib
144
163
  exports.ObjectStoreBuckets = ObjectStoreBuckets;
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IncludeRelationships = exports.SourceNames = exports.DatasourceFieldTypes = exports.QueryTypes = exports.SortDirection = exports.Operation = void 0;
3
+ exports.FilterTypes = exports.IncludeRelationships = exports.SourceNames = exports.DatasourceFieldTypes = exports.QueryTypes = exports.SortDirection = exports.Operation = void 0;
4
4
  var Operation;
5
5
  (function (Operation) {
6
6
  Operation["CREATE"] = "CREATE";
7
7
  Operation["READ"] = "READ";
8
8
  Operation["UPDATE"] = "UPDATE";
9
9
  Operation["DELETE"] = "DELETE";
10
+ Operation["BULK_CREATE"] = "BULK_CREATE";
11
+ Operation["CREATE_TABLE"] = "CREATE_TABLE";
12
+ Operation["UPDATE_TABLE"] = "UPDATE_TABLE";
13
+ Operation["DELETE_TABLE"] = "DELETE_TABLE";
10
14
  })(Operation = exports.Operation || (exports.Operation = {}));
11
15
  var SortDirection;
12
16
  (function (SortDirection) {
@@ -44,9 +48,21 @@ var SourceNames;
44
48
  SourceNames["MYSQL"] = "MYSQL";
45
49
  SourceNames["ARANGODB"] = "ARANGODB";
46
50
  SourceNames["REST"] = "REST";
51
+ SourceNames["ORACLE"] = "ORACLE";
47
52
  })(SourceNames = exports.SourceNames || (exports.SourceNames = {}));
48
53
  var IncludeRelationships;
49
54
  (function (IncludeRelationships) {
50
55
  IncludeRelationships[IncludeRelationships["INCLUDE"] = 1] = "INCLUDE";
51
56
  IncludeRelationships[IncludeRelationships["EXCLUDE"] = 0] = "EXCLUDE";
52
57
  })(IncludeRelationships = exports.IncludeRelationships || (exports.IncludeRelationships = {}));
58
+ var FilterTypes;
59
+ (function (FilterTypes) {
60
+ FilterTypes["STRING"] = "string";
61
+ FilterTypes["FUZZY"] = "fuzzy";
62
+ FilterTypes["RANGE"] = "range";
63
+ FilterTypes["EQUAL"] = "equal";
64
+ FilterTypes["NOT_EQUAL"] = "notEqual";
65
+ FilterTypes["EMPTY"] = "empty";
66
+ FilterTypes["NOT_EMPTY"] = "notEmpty";
67
+ FilterTypes["ONE_OF"] = "oneOf";
68
+ })(FilterTypes = exports.FilterTypes || (exports.FilterTypes = {}));
@@ -16,6 +16,7 @@ if (!LOADED && isDev() && !isTest()) {
16
16
  require("dotenv").config();
17
17
  LOADED = true;
18
18
  }
19
+ let inThread = false;
19
20
  module.exports = {
20
21
  // important
21
22
  PORT: process.env.PORT,
@@ -55,6 +56,7 @@ module.exports = {
55
56
  USERID_API_KEY: process.env.USERID_API_KEY,
56
57
  DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
57
58
  ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
59
+ DISABLE_THREADING: process.env.DISABLE_THREADING,
58
60
  _set(key, value) {
59
61
  process.env[key] = value;
60
62
  module.exports[key] = value;
@@ -65,7 +67,18 @@ module.exports = {
65
67
  isProd: () => {
66
68
  return !isDev();
67
69
  },
70
+ // used to check if already in a thread, don't thread further
71
+ setInThread: () => {
72
+ inThread = true;
73
+ },
74
+ isInThread: () => {
75
+ return inThread;
76
+ },
68
77
  };
78
+ // threading can cause memory issues with node-ts in development
79
+ if (isDev() && module.exports.DISABLE_THREADING == null) {
80
+ module.exports._set("DISABLE_THREADING", "1");
81
+ }
69
82
  // clean up any environment variable edge cases
70
83
  for (let [key, value] of Object.entries(module.exports)) {
71
84
  // handle the edge case of "0" to disable an environment variable
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });