@budibase/server 1.0.80-alpha.3 → 1.0.80

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 (316) hide show
  1. package/__mocks__/node-fetch.ts +0 -1
  2. package/builder/assets/index.22a39cc9.js +1352 -0
  3. package/builder/assets/{index.c57242d4.css → index.c8d1e8f0.css} +2 -2
  4. package/builder/assets/{vendor.a7c6ad0a.js → vendor.20f80cec.js} +216 -190
  5. package/builder/index.html +3 -3
  6. package/coverage/clover.xml +2327 -2390
  7. package/coverage/coverage-final.json +137 -138
  8. package/coverage/lcov-report/api/controllers/analytics.js.html +6 -6
  9. package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
  10. package/coverage/lcov-report/api/controllers/application.js.html +149 -152
  11. package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
  12. package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
  13. package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
  14. package/coverage/lcov-report/api/controllers/cloud.js.html +11 -11
  15. package/coverage/lcov-report/api/controllers/component.js.html +5 -5
  16. package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
  17. package/coverage/lcov-report/api/controllers/dev.js.html +19 -19
  18. package/coverage/lcov-report/api/controllers/index.html +16 -16
  19. package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
  20. package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
  21. package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
  22. package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
  23. package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
  24. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  25. package/coverage/lcov-report/api/controllers/query/index.js.html +26 -26
  26. package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
  27. package/coverage/lcov-report/api/controllers/role.js.html +9 -9
  28. package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
  29. package/coverage/lcov-report/api/controllers/row/external.js.html +16 -16
  30. package/coverage/lcov-report/api/controllers/row/index.html +27 -27
  31. package/coverage/lcov-report/api/controllers/row/index.js.html +46 -46
  32. package/coverage/lcov-report/api/controllers/row/internal.js.html +82 -94
  33. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +204 -204
  34. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
  35. package/coverage/lcov-report/api/controllers/row/utils.js.html +29 -29
  36. package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
  37. package/coverage/lcov-report/api/controllers/script.js.html +4 -4
  38. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +49 -49
  39. package/coverage/lcov-report/api/controllers/table/external.js.html +12 -12
  40. package/coverage/lcov-report/api/controllers/table/index.html +11 -11
  41. package/coverage/lcov-report/api/controllers/table/index.js.html +44 -47
  42. package/coverage/lcov-report/api/controllers/table/internal.js.html +50 -50
  43. package/coverage/lcov-report/api/controllers/table/utils.js.html +80 -80
  44. package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
  45. package/coverage/lcov-report/api/controllers/user.js.html +19 -19
  46. package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
  47. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  48. package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
  49. package/coverage/lcov-report/api/controllers/view/utils.js.html +12 -12
  50. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
  51. package/coverage/lcov-report/api/controllers/webhook.js.html +27 -18
  52. package/coverage/lcov-report/api/index.html +10 -10
  53. package/coverage/lcov-report/api/index.js.html +28 -37
  54. package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
  55. package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
  56. package/coverage/lcov-report/api/routes/application.js.html +9 -9
  57. package/coverage/lcov-report/api/routes/auth.js.html +6 -6
  58. package/coverage/lcov-report/api/routes/automation.js.html +109 -19
  59. package/coverage/lcov-report/api/routes/backup.js.html +8 -8
  60. package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
  61. package/coverage/lcov-report/api/routes/component.js.html +8 -8
  62. package/coverage/lcov-report/api/routes/datasource.js.html +156 -18
  63. package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
  64. package/coverage/lcov-report/api/routes/dev.js.html +13 -13
  65. package/coverage/lcov-report/api/routes/index.html +35 -35
  66. package/coverage/lcov-report/api/routes/index.js.html +32 -38
  67. package/coverage/lcov-report/api/routes/integration.js.html +8 -8
  68. package/coverage/lcov-report/api/routes/layout.js.html +8 -8
  69. package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
  70. package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
  71. package/coverage/lcov-report/api/routes/permission.js.html +58 -16
  72. package/coverage/lcov-report/api/routes/query.js.html +10 -10
  73. package/coverage/lcov-report/api/routes/role.js.html +78 -15
  74. package/coverage/lcov-report/api/routes/routing.js.html +8 -8
  75. package/coverage/lcov-report/api/routes/row.js.html +14 -17
  76. package/coverage/lcov-report/api/routes/screen.js.html +95 -14
  77. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  78. package/coverage/lcov-report/api/routes/static.js.html +13 -13
  79. package/coverage/lcov-report/api/routes/table.js.html +62 -17
  80. package/coverage/lcov-report/api/routes/templates.js.html +8 -8
  81. package/coverage/lcov-report/api/routes/user.js.html +8 -8
  82. package/coverage/lcov-report/api/routes/view.js.html +10 -10
  83. package/coverage/lcov-report/api/routes/webhook.js.html +62 -14
  84. package/coverage/lcov-report/automations/actions.js.html +24 -24
  85. package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
  86. package/coverage/lcov-report/automations/bullboard.js.html +16 -16
  87. package/coverage/lcov-report/automations/index.html +1 -1
  88. package/coverage/lcov-report/automations/index.js.html +7 -7
  89. package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
  90. package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
  91. package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
  92. package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
  93. package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
  94. package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
  95. package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
  96. package/coverage/lcov-report/automations/steps/filter.js.html +9 -12
  97. package/coverage/lcov-report/automations/steps/index.html +1 -1
  98. package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
  99. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
  100. package/coverage/lcov-report/automations/steps/queryRows.js.html +11 -11
  101. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
  102. package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
  103. package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
  104. package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
  105. package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
  106. package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
  107. package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
  108. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
  109. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  110. package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
  111. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
  112. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
  113. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
  114. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
  115. package/coverage/lcov-report/automations/triggers.js.html +26 -26
  116. package/coverage/lcov-report/automations/utils.js.html +35 -35
  117. package/coverage/lcov-report/constants/index.html +5 -5
  118. package/coverage/lcov-report/constants/index.js.html +28 -40
  119. package/coverage/lcov-report/constants/layouts.js.html +5 -5
  120. package/coverage/lcov-report/constants/screens.js.html +4 -4
  121. package/coverage/lcov-report/db/client.js.html +18 -18
  122. package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
  123. package/coverage/lcov-report/db/index.html +15 -15
  124. package/coverage/lcov-report/db/index.js.html +3 -3
  125. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +21 -21
  126. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  127. package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
  128. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +30 -30
  129. package/coverage/lcov-report/db/newid.js.html +4 -4
  130. package/coverage/lcov-report/db/utils.js.html +87 -123
  131. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  132. package/coverage/lcov-report/events/index.html +1 -1
  133. package/coverage/lcov-report/events/index.js.html +8 -8
  134. package/coverage/lcov-report/events/utils.js.html +18 -18
  135. package/coverage/lcov-report/index.html +74 -89
  136. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  137. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  138. package/coverage/lcov-report/middleware/appInfo.js.html +5 -5
  139. package/coverage/lcov-report/middleware/authorized.js.html +29 -29
  140. package/coverage/lcov-report/middleware/builder.js.html +16 -16
  141. package/coverage/lcov-report/middleware/currentapp.js.html +44 -44
  142. package/coverage/lcov-report/middleware/index.html +1 -1
  143. package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
  144. package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
  145. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  146. package/coverage/lcov-report/middleware/usageQuota.js.html +17 -17
  147. package/coverage/lcov-report/middleware/utils.js.html +4 -4
  148. package/coverage/lcov-report/threads/automation.js.html +1 -1
  149. package/coverage/lcov-report/threads/index.html +19 -19
  150. package/coverage/lcov-report/threads/index.js.html +10 -10
  151. package/coverage/lcov-report/threads/query.js.html +39 -123
  152. package/coverage/lcov-report/threads/utils.js.html +14 -14
  153. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  154. package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
  155. package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
  156. package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
  157. package/coverage/lcov-report/utilities/global.js.html +28 -28
  158. package/coverage/lcov-report/utilities/index.html +18 -18
  159. package/coverage/lcov-report/utilities/index.js.html +24 -24
  160. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -9
  161. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  162. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  163. package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
  164. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  165. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +60 -60
  166. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +13 -13
  167. package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
  168. package/coverage/lcov-report/utilities/security.js.html +8 -8
  169. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  170. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  171. package/coverage/lcov-report/utilities/usageQuota/index.js.html +12 -12
  172. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +8 -8
  173. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  174. package/coverage/lcov-report/utilities/users.js.html +5 -5
  175. package/coverage/lcov-report/utilities/workerRequests.js.html +53 -200
  176. package/coverage/lcov.info +3233 -3332
  177. package/dist/api/controllers/application.js +0 -1
  178. package/dist/api/controllers/row/internal.js +1 -4
  179. package/dist/api/controllers/table/index.js +1 -2
  180. package/dist/api/controllers/webhook.js +5 -3
  181. package/dist/api/index.js +1 -3
  182. package/dist/api/routes/automation.js +31 -3
  183. package/dist/api/routes/datasource.js +50 -3
  184. package/dist/api/routes/index.js +0 -2
  185. package/dist/api/routes/permission.js +14 -4
  186. package/dist/api/routes/role.js +19 -3
  187. package/dist/api/routes/row.js +4 -3
  188. package/dist/api/routes/screen.js +23 -2
  189. package/dist/api/routes/table.js +17 -3
  190. package/dist/api/routes/tests/utilities/index.js +0 -23
  191. package/dist/api/routes/webhook.js +17 -2
  192. package/dist/automations/steps/filter.js +2 -2
  193. package/dist/automations/steps/queryRows.js +1 -1
  194. package/dist/automations/utils.js +2 -2
  195. package/dist/constants/index.js +0 -3
  196. package/dist/db/utils.js +0 -11
  197. package/dist/environment.js +0 -1
  198. package/dist/integrations/base/sql.js +1 -16
  199. package/dist/integrations/base/sqlTable.js +4 -8
  200. package/dist/integrations/googlesheets.js +0 -3
  201. package/dist/integrations/microsoftSqlServer.js +43 -60
  202. package/dist/integrations/mysql.js +0 -3
  203. package/dist/integrations/oracle.js +19 -14
  204. package/dist/integrations/postgres.js +28 -34
  205. package/dist/integrations/utils.js +15 -32
  206. package/dist/package.json +7 -11
  207. package/dist/tests/utilities/TestConfiguration.js +8 -25
  208. package/dist/threads/query.js +8 -33
  209. package/dist/tsconfig.tsbuildinfo +1 -1
  210. package/dist/utilities/workerRequests.js +15 -50
  211. package/package.json +8 -12
  212. package/scripts/integrations/mssql/data/setup.sql +1 -18
  213. package/scripts/integrations/oracle/oracle.md +2 -2
  214. package/scripts/integrations/postgres/init.sql +3 -11
  215. package/scripts/likeCypress.ts +6 -9
  216. package/scripts/proxy/generateProxyConfig.js +70 -0
  217. package/src/api/controllers/application.js +0 -1
  218. package/src/api/controllers/row/ExternalRequest.ts +1 -1
  219. package/src/api/controllers/row/internal.js +0 -4
  220. package/src/api/controllers/table/index.js +1 -2
  221. package/src/api/controllers/webhook.js +6 -3
  222. package/src/api/index.js +1 -4
  223. package/src/api/routes/automation.js +33 -3
  224. package/src/api/routes/datasource.js +52 -6
  225. package/src/api/routes/index.js +0 -2
  226. package/src/api/routes/permission.js +18 -4
  227. package/src/api/routes/role.js +24 -3
  228. package/src/api/routes/row.js +2 -3
  229. package/src/api/routes/screen.js +29 -2
  230. package/src/api/routes/table.js +19 -4
  231. package/src/api/routes/tests/utilities/index.js +0 -24
  232. package/src/api/routes/webhook.js +18 -2
  233. package/src/automations/steps/filter.js +2 -3
  234. package/src/automations/steps/queryRows.js +1 -1
  235. package/src/automations/utils.js +2 -2
  236. package/src/constants/index.js +0 -4
  237. package/src/db/utils.js +0 -12
  238. package/src/definitions/common.ts +0 -4
  239. package/src/definitions/datasource.ts +0 -1
  240. package/src/environment.js +0 -1
  241. package/src/integrations/base/datasourcePlus.ts +0 -3
  242. package/src/integrations/base/sql.ts +1 -16
  243. package/src/integrations/base/sqlTable.ts +7 -11
  244. package/src/integrations/googlesheets.ts +2 -5
  245. package/src/integrations/microsoftSqlServer.ts +61 -86
  246. package/src/integrations/mysql.ts +0 -4
  247. package/src/integrations/oracle.ts +35 -27
  248. package/src/integrations/postgres.ts +26 -33
  249. package/src/integrations/utils.ts +15 -43
  250. package/src/tests/utilities/TestConfiguration.js +2 -23
  251. package/src/threads/query.js +9 -37
  252. package/src/utilities/workerRequests.js +16 -65
  253. package/builder/assets/index.f8c92447.js +0 -1288
  254. package/coverage/lcov-report/api/routes/utils/index.html +0 -111
  255. package/coverage/lcov-report/api/routes/utils/validators.js.html +0 -737
  256. package/dist/api/controllers/public/applications.js +0 -94
  257. package/dist/api/controllers/public/mapping/applications.js +0 -29
  258. package/dist/api/controllers/public/mapping/index.js +0 -11
  259. package/dist/api/controllers/public/mapping/queries.js +0 -36
  260. package/dist/api/controllers/public/mapping/rows.js +0 -24
  261. package/dist/api/controllers/public/mapping/tables.js +0 -23
  262. package/dist/api/controllers/public/mapping/types.js +0 -2
  263. package/dist/api/controllers/public/mapping/users.js +0 -29
  264. package/dist/api/controllers/public/queries.js +0 -38
  265. package/dist/api/controllers/public/rows.js +0 -97
  266. package/dist/api/controllers/public/tables.js +0 -75
  267. package/dist/api/controllers/public/users.js +0 -95
  268. package/dist/api/controllers/public/utils.js +0 -49
  269. package/dist/api/routes/public/applications.js +0 -141
  270. package/dist/api/routes/public/index.js +0 -101
  271. package/dist/api/routes/public/middleware/mapper.js +0 -94
  272. package/dist/api/routes/public/queries.js +0 -77
  273. package/dist/api/routes/public/rows.js +0 -229
  274. package/dist/api/routes/public/tables.js +0 -154
  275. package/dist/api/routes/public/users.js +0 -137
  276. package/dist/api/routes/public/utils/Endpoint.js +0 -36
  277. package/dist/api/routes/utils/validators.js +0 -200
  278. package/dist/definitions/openapi.js +0 -6
  279. package/specs/generate.js +0 -94
  280. package/specs/openapi.json +0 -2232
  281. package/specs/openapi.yaml +0 -1538
  282. package/specs/parameters.js +0 -59
  283. package/specs/resources/application.js +0 -101
  284. package/specs/resources/index.js +0 -24
  285. package/specs/resources/misc.js +0 -12
  286. package/specs/resources/query.js +0 -189
  287. package/specs/resources/row.js +0 -125
  288. package/specs/resources/table.js +0 -191
  289. package/specs/resources/user.js +0 -126
  290. package/specs/resources/utils/Resource.js +0 -26
  291. package/specs/resources/utils/index.js +0 -11
  292. package/specs/security.js +0 -7
  293. package/src/api/controllers/public/applications.ts +0 -74
  294. package/src/api/controllers/public/mapping/applications.ts +0 -32
  295. package/src/api/controllers/public/mapping/index.ts +0 -13
  296. package/src/api/controllers/public/mapping/queries.ts +0 -39
  297. package/src/api/controllers/public/mapping/rows.ts +0 -31
  298. package/src/api/controllers/public/mapping/tables.ts +0 -26
  299. package/src/api/controllers/public/mapping/types.ts +0 -13
  300. package/src/api/controllers/public/mapping/users.ts +0 -32
  301. package/src/api/controllers/public/queries.ts +0 -20
  302. package/src/api/controllers/public/rows.ts +0 -77
  303. package/src/api/controllers/public/tables.ts +0 -56
  304. package/src/api/controllers/public/users.ts +0 -82
  305. package/src/api/controllers/public/utils.ts +0 -38
  306. package/src/api/routes/public/applications.ts +0 -156
  307. package/src/api/routes/public/index.ts +0 -118
  308. package/src/api/routes/public/middleware/mapper.ts +0 -81
  309. package/src/api/routes/public/queries.ts +0 -81
  310. package/src/api/routes/public/rows.ts +0 -242
  311. package/src/api/routes/public/tables.ts +0 -169
  312. package/src/api/routes/public/tests/compare.spec.js +0 -184
  313. package/src/api/routes/public/users.ts +0 -144
  314. package/src/api/routes/public/utils/Endpoint.ts +0 -51
  315. package/src/api/routes/utils/validators.js +0 -219
  316. package/src/definitions/openapi.ts +0 -943
@@ -220,7 +220,6 @@ exports.create = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
220
220
  tenantId: getTenantId(),
221
221
  updatedAt: new Date().toISOString(),
222
222
  createdAt: new Date().toISOString(),
223
- status: AppStatus.DEV,
224
223
  };
225
224
  const response = yield db.put(newApplication, { force: true });
226
225
  newApplication._rev = response.rev;
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  return t;
21
21
  };
22
22
  const linkRows = require("../../../db/linkedRows");
23
- const { generateRowID, getRowParams, getTableIDFromRowID, DocumentTypes, InternalTables, } = require("../../../db/utils");
23
+ const { generateRowID, getRowParams, DocumentTypes, InternalTables, } = require("../../../db/utils");
24
24
  const userController = require("../user");
25
25
  const { inputProcessing, outputProcessing, cleanupAttachments, } = require("../../../utilities/rowProcessor");
26
26
  const { FieldTypes } = require("../../../constants");
@@ -358,9 +358,6 @@ exports.fetchEnrichedRow = (ctx) => __awaiter(void 0, void 0, void 0, function*
358
358
  // group responses by table
359
359
  let groups = {}, tables = {};
360
360
  for (let row of response) {
361
- if (!row.tableId) {
362
- row.tableId = getTableIDFromRowID(row._id);
363
- }
364
361
  const linkedTableId = row.tableId;
365
362
  if (groups[linkedTableId] == null) {
366
363
  groups[linkedTableId] = [row];
@@ -49,7 +49,7 @@ exports.fetch = function (ctx) {
49
49
  };
50
50
  exports.find = function (ctx) {
51
51
  return __awaiter(this, void 0, void 0, function* () {
52
- const tableId = ctx.params.tableId;
52
+ const tableId = ctx.params.id;
53
53
  ctx.body = yield getTable(tableId);
54
54
  });
55
55
  };
@@ -73,7 +73,6 @@ exports.destroy = function (ctx) {
73
73
  ctx.eventEmitter &&
74
74
  ctx.eventEmitter.emitTable(`table:delete`, appId, deletedTable);
75
75
  ctx.status = 200;
76
- ctx.table = deletedTable;
77
76
  ctx.body = { message: `Table ${tableId} deleted.` };
78
77
  });
79
78
  };
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  const { generateWebhookID, getWebhookParams } = require("../../db/utils");
12
12
  const toJsonSchema = require("to-json-schema");
13
13
  const validate = require("jsonschema").validate;
14
- const { WebhookType } = require("../../constants");
15
14
  const triggers = require("../../automations/triggers");
16
15
  const { getProdAppID } = require("@budibase/backend-core/db");
17
16
  const { getAppDB, updateAppId } = require("@budibase/backend-core/context");
@@ -25,6 +24,9 @@ function Webhook(name, type, target) {
25
24
  };
26
25
  }
27
26
  exports.Webhook = Webhook;
27
+ exports.WebhookType = {
28
+ AUTOMATION: "automation",
29
+ };
28
30
  exports.fetch = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
29
31
  const db = getAppDB();
30
32
  const response = yield db.allDocs(getWebhookParams(null, {
@@ -60,7 +62,7 @@ exports.buildSchema = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
60
62
  const webhook = yield db.get(ctx.params.id);
61
63
  webhook.bodySchema = toJsonSchema(ctx.request.body);
62
64
  // update the automation outputs
63
- if (webhook.action.type === WebhookType.AUTOMATION) {
65
+ if (webhook.action.type === exports.WebhookType.AUTOMATION) {
64
66
  let automation = yield db.get(webhook.action.target);
65
67
  const autoOutputs = automation.definition.trigger.schema.outputs;
66
68
  let properties = webhook.bodySchema.properties;
@@ -89,7 +91,7 @@ exports.trigger = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
89
91
  validate(ctx.request.body, webhook.bodySchema);
90
92
  }
91
93
  const target = yield db.get(webhook.action.target);
92
- if (webhook.action.type === WebhookType.AUTOMATION) {
94
+ if (webhook.action.type === exports.WebhookType.AUTOMATION) {
93
95
  // trigger with both the pure request and then expand it
94
96
  // incase the user has produced a schema to bind to
95
97
  yield triggers.externalTrigger(target, Object.assign(Object.assign({ body: ctx.request.body }, ctx.request.body), { appId: prodAppId }));
package/dist/api/index.js CHANGED
@@ -13,7 +13,7 @@ const { buildAuthMiddleware, auditLog, buildTenancyMiddleware, buildAppTenancyMi
13
13
  const currentApp = require("../middleware/currentapp");
14
14
  const compress = require("koa-compress");
15
15
  const zlib = require("zlib");
16
- const { mainRoutes, staticRoutes, publicRoutes } = require("./routes");
16
+ const { mainRoutes, staticRoutes } = require("./routes");
17
17
  const pkg = require("../../package.json");
18
18
  const env = require("../environment");
19
19
  const router = new Router();
@@ -76,8 +76,6 @@ for (let route of mainRoutes) {
76
76
  router.use(route.routes());
77
77
  router.use(route.allowedMethods());
78
78
  }
79
- router.use(publicRoutes.routes());
80
- router.use(publicRoutes.allowedMethods());
81
79
  // WARNING - static routes will catch everything else after them this must be last
82
80
  router.use(staticRoutes.routes());
83
81
  router.use(staticRoutes.allowedMethods());
@@ -2,19 +2,47 @@
2
2
  const Router = require("@koa/router");
3
3
  const controller = require("../controllers/automation");
4
4
  const authorized = require("../../middleware/authorized");
5
+ const joiValidator = require("../../middleware/joi-validator");
5
6
  const { BUILDER, PermissionLevels, PermissionTypes, } = require("@budibase/backend-core/permissions");
7
+ const Joi = require("joi");
6
8
  const { bodyResource, paramResource } = require("../../middleware/resourceId");
7
9
  const { middleware: appInfoMiddleware, AppType, } = require("../../middleware/appInfo");
8
- const { automationValidator } = require("./utils/validators");
9
10
  const router = Router();
11
+ // prettier-ignore
12
+ function generateStepSchema(allowStepTypes) {
13
+ return Joi.object({
14
+ stepId: Joi.string().required(),
15
+ id: Joi.string().required(),
16
+ description: Joi.string().required(),
17
+ name: Joi.string().required(),
18
+ tagline: Joi.string().required(),
19
+ icon: Joi.string().required(),
20
+ params: Joi.object(),
21
+ args: Joi.object(),
22
+ type: Joi.string().required().valid(...allowStepTypes),
23
+ }).unknown(true);
24
+ }
25
+ function generateValidator(existing = false) {
26
+ // prettier-ignore
27
+ return joiValidator.body(Joi.object({
28
+ _id: existing ? Joi.string().required() : Joi.string(),
29
+ _rev: existing ? Joi.string().required() : Joi.string(),
30
+ name: Joi.string().required(),
31
+ type: Joi.string().valid("automation").required(),
32
+ definition: Joi.object({
33
+ steps: Joi.array().required().items(generateStepSchema(["ACTION", "LOGIC"])),
34
+ trigger: generateStepSchema(["TRIGGER"]).allow(null),
35
+ }).required().unknown(true),
36
+ }).unknown(true));
37
+ }
10
38
  router
11
39
  .get("/api/automations/trigger/list", authorized(BUILDER), controller.getTriggerList)
12
40
  .get("/api/automations/action/list", authorized(BUILDER), controller.getActionList)
13
41
  .get("/api/automations/definitions/list", authorized(BUILDER), controller.getDefinitionList)
14
42
  .get("/api/automations", authorized(BUILDER), controller.fetch)
15
43
  .get("/api/automations/:id", paramResource("id"), authorized(BUILDER), controller.find)
16
- .put("/api/automations", bodyResource("_id"), authorized(BUILDER), automationValidator(true), controller.update)
17
- .post("/api/automations", authorized(BUILDER), automationValidator(false), controller.create)
44
+ .put("/api/automations", bodyResource("_id"), authorized(BUILDER), generateValidator(true), controller.update)
45
+ .post("/api/automations", authorized(BUILDER), generateValidator(false), controller.create)
18
46
  .delete("/api/automations/:id/:rev", paramResource("id"), authorized(BUILDER), controller.destroy)
19
47
  .post("/api/automations/:id/trigger", appInfoMiddleware({ appType: AppType.PROD }), paramResource("id"), authorized(PermissionTypes.AUTOMATION, PermissionLevels.EXECUTE), controller.trigger)
20
48
  .post("/api/automations/:id/test", appInfoMiddleware({ appType: AppType.DEV }), paramResource("id"), authorized(PermissionTypes.AUTOMATION, PermissionLevels.EXECUTE), controller.test);
@@ -2,15 +2,62 @@
2
2
  const Router = require("@koa/router");
3
3
  const datasourceController = require("../controllers/datasource");
4
4
  const authorized = require("../../middleware/authorized");
5
+ const joiValidator = require("../../middleware/joi-validator");
5
6
  const { BUILDER, PermissionLevels, PermissionTypes, } = require("@budibase/backend-core/permissions");
6
- const { datasourceValidator, datasourceQueryValidator, } = require("./utils/validators");
7
+ const Joi = require("joi");
8
+ const { DataSourceOperation } = require("../../constants");
7
9
  const router = Router();
10
+ function generateDatasourceSchema() {
11
+ // prettier-ignore
12
+ return joiValidator.body(Joi.object({
13
+ _id: Joi.string(),
14
+ _rev: Joi.string(),
15
+ // source: Joi.string().valid("POSTGRES_PLUS"),
16
+ type: Joi.string().allow("datasource_plus"),
17
+ relationships: Joi.array().items(Joi.object({
18
+ from: Joi.string().required(),
19
+ to: Joi.string().required(),
20
+ cardinality: Joi.valid("1:N", "1:1", "N:N").required()
21
+ })),
22
+ // entities: Joi.array().items(Joi.object({
23
+ // type: Joi.string().valid(...Object.values(FieldTypes)).required(),
24
+ // name: Joi.string().required(),
25
+ // })),
26
+ }).unknown(true));
27
+ }
28
+ function generateQueryDatasourceSchema() {
29
+ // prettier-ignore
30
+ return joiValidator.body(Joi.object({
31
+ endpoint: Joi.object({
32
+ datasourceId: Joi.string().required(),
33
+ operation: Joi.string().required().valid(...Object.values(DataSourceOperation)),
34
+ entityId: Joi.string().required(),
35
+ }).required(),
36
+ resource: Joi.object({
37
+ fields: Joi.array().items(Joi.string()).optional(),
38
+ }).optional(),
39
+ body: Joi.object().optional(),
40
+ sort: Joi.object().optional(),
41
+ filters: Joi.object({
42
+ string: Joi.object().optional(),
43
+ range: Joi.object().optional(),
44
+ equal: Joi.object().optional(),
45
+ notEqual: Joi.object().optional(),
46
+ empty: Joi.object().optional(),
47
+ notEmpty: Joi.object().optional(),
48
+ }).optional(),
49
+ paginate: Joi.object({
50
+ page: Joi.string().alphanum().optional(),
51
+ limit: Joi.number().optional(),
52
+ }).optional(),
53
+ }));
54
+ }
8
55
  router
9
56
  .get("/api/datasources", authorized(BUILDER), datasourceController.fetch)
10
57
  .get("/api/datasources/:datasourceId", authorized(PermissionTypes.TABLE, PermissionLevels.READ), datasourceController.find)
11
58
  .put("/api/datasources/:datasourceId", authorized(PermissionTypes.TABLE, PermissionLevels.READ), datasourceController.update)
12
- .post("/api/datasources/query", authorized(PermissionTypes.TABLE, PermissionLevels.READ), datasourceQueryValidator(), datasourceController.query)
59
+ .post("/api/datasources/query", authorized(PermissionTypes.TABLE, PermissionLevels.READ), generateQueryDatasourceSchema(), datasourceController.query)
13
60
  .post("/api/datasources/:datasourceId/schema", authorized(BUILDER), datasourceController.buildSchemaFromDb)
14
- .post("/api/datasources", authorized(BUILDER), datasourceValidator(), datasourceController.save)
61
+ .post("/api/datasources", authorized(BUILDER), generateDatasourceSchema(), datasourceController.save)
15
62
  .delete("/api/datasources/:datasourceId/:revId", authorized(BUILDER), datasourceController.destroy);
16
63
  module.exports = router;
@@ -26,7 +26,6 @@ const metadataRoutes = require("./metadata");
26
26
  const devRoutes = require("./dev");
27
27
  const cloudRoutes = require("./cloud");
28
28
  const migrationRoutes = require("./migrations");
29
- const publicRoutes = require("./public");
30
29
  exports.mainRoutes = [
31
30
  authRoutes,
32
31
  deployRoutes,
@@ -57,5 +56,4 @@ exports.mainRoutes = [
57
56
  rowRoutes,
58
57
  migrationRoutes,
59
58
  ];
60
- exports.publicRoutes = publicRoutes;
61
59
  exports.staticRoutes = staticRoutes;
@@ -2,16 +2,26 @@
2
2
  const Router = require("@koa/router");
3
3
  const controller = require("../controllers/permission");
4
4
  const authorized = require("../../middleware/authorized");
5
- const { BUILDER } = require("@budibase/backend-core/permissions");
6
- const { permissionValidator } = require("./utils/validators");
5
+ const { BUILDER, PermissionLevels, } = require("@budibase/backend-core/permissions");
6
+ const Joi = require("joi");
7
+ const joiValidator = require("../../middleware/joi-validator");
7
8
  const router = Router();
9
+ function generateValidator() {
10
+ const permLevelArray = Object.values(PermissionLevels);
11
+ // prettier-ignore
12
+ return joiValidator.params(Joi.object({
13
+ level: Joi.string().valid(...permLevelArray).required(),
14
+ resourceId: Joi.string(),
15
+ roleId: Joi.string(),
16
+ }).unknown(true));
17
+ }
8
18
  router
9
19
  .get("/api/permission/builtin", authorized(BUILDER), controller.fetchBuiltin)
10
20
  .get("/api/permission/levels", authorized(BUILDER), controller.fetchLevels)
11
21
  .get("/api/permission", authorized(BUILDER), controller.fetch)
12
22
  .get("/api/permission/:resourceId", authorized(BUILDER), controller.getResourcePerms)
13
23
  // adding a specific role/level for the resource overrides the underlying access control
14
- .post("/api/permission/:roleId/:resourceId/:level", authorized(BUILDER), permissionValidator(), controller.addPermission)
24
+ .post("/api/permission/:roleId/:resourceId/:level", authorized(BUILDER), generateValidator(), controller.addPermission)
15
25
  // deleting the level defaults it back the underlying access control for the resource
16
- .delete("/api/permission/:roleId/:resourceId/:level", authorized(BUILDER), permissionValidator(), controller.removePermission);
26
+ .delete("/api/permission/:roleId/:resourceId/:level", authorized(BUILDER), generateValidator(), controller.removePermission);
17
27
  module.exports = router;
@@ -2,11 +2,27 @@
2
2
  const Router = require("@koa/router");
3
3
  const controller = require("../controllers/role");
4
4
  const authorized = require("../../middleware/authorized");
5
- const { BUILDER } = require("@budibase/backend-core/permissions");
6
- const { roleValidator } = require("./utils/validators");
5
+ const Joi = require("joi");
6
+ const joiValidator = require("../../middleware/joi-validator");
7
+ const { BUILTIN_PERMISSION_IDS, BUILDER, PermissionLevels, } = require("@budibase/backend-core/permissions");
7
8
  const router = Router();
9
+ function generateValidator() {
10
+ const permLevelArray = Object.values(PermissionLevels);
11
+ // prettier-ignore
12
+ return joiValidator.body(Joi.object({
13
+ _id: Joi.string().optional(),
14
+ _rev: Joi.string().optional(),
15
+ name: Joi.string().required(),
16
+ // this is the base permission ID (for now a built in)
17
+ permissionId: Joi.string().valid(...Object.values(BUILTIN_PERMISSION_IDS)).required(),
18
+ permissions: Joi.object()
19
+ .pattern(/.*/, [Joi.string().valid(...permLevelArray)])
20
+ .optional(),
21
+ inherits: Joi.string().optional(),
22
+ }).unknown(true));
23
+ }
8
24
  router
9
- .post("/api/roles", authorized(BUILDER), roleValidator(), controller.save)
25
+ .post("/api/roles", authorized(BUILDER), generateValidator(), controller.save)
10
26
  .get("/api/roles", authorized(BUILDER), controller.fetch)
11
27
  .get("/api/roles/:roleId", authorized(BUILDER), controller.find)
12
28
  .delete("/api/roles/:roleId/:rev", authorized(BUILDER), controller.destroy);
@@ -5,7 +5,6 @@ const authorized = require("../../middleware/authorized");
5
5
  const usage = require("../../middleware/usageQuota");
6
6
  const { paramResource, paramSubResource, } = require("../../middleware/resourceId");
7
7
  const { PermissionLevels, PermissionTypes, } = require("@budibase/backend-core/permissions");
8
- const { internalSearchValidator } = require("./utils/validators");
9
8
  const router = Router();
10
9
  router
11
10
  /**
@@ -98,6 +97,8 @@ router
98
97
  * "notEqual": {},
99
98
  * "empty": {},
100
99
  * "notEmpty": {},
100
+ * "contains": {},
101
+ * "notContains": {}
101
102
  * "oneOf": {
102
103
  * "columnName": ["value"]
103
104
  * }
@@ -115,7 +116,7 @@ router
115
116
  * @apiSuccess {string} bookmark The bookmark to be sent with the next request to get the next
116
117
  * page.
117
118
  */
118
- .post("/api/:tableId/search", internalSearchValidator(), paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.search)
119
+ .post("/api/:tableId/search", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.search)
119
120
  // DEPRECATED - this is an old API, but for backwards compat it needs to be
120
121
  // supported still
121
122
  .post("/api/search/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), rowController.search)
@@ -152,7 +153,7 @@ router
152
153
  * @apiDescription This endpoint is identical to the row creation endpoint but instead it will
153
154
  * error if an _id isn't provided, it will only function for existing rows.
154
155
  */
155
- .patch("/api/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), usage, rowController.patch)
156
+ .patch("/api/:tableId/rows", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.WRITE), rowController.patch)
156
157
  /**
157
158
  * @api {post} /api/:tableId/rows/validate Validate inputs for a row
158
159
  * @apiName Validate inputs for a row
@@ -3,10 +3,31 @@ const Router = require("@koa/router");
3
3
  const controller = require("../controllers/screen");
4
4
  const authorized = require("../../middleware/authorized");
5
5
  const { BUILDER } = require("@budibase/backend-core/permissions");
6
- const { screenValidator } = require("./utils/validators");
6
+ const joiValidator = require("../../middleware/joi-validator");
7
+ const Joi = require("joi");
7
8
  const router = Router();
9
+ function generateSaveValidation() {
10
+ // prettier-ignore
11
+ return joiValidator.body(Joi.object({
12
+ name: Joi.string().required(),
13
+ routing: Joi.object({
14
+ route: Joi.string().required(),
15
+ roleId: Joi.string().required().allow(""),
16
+ }).required().unknown(true),
17
+ props: Joi.object({
18
+ _id: Joi.string().required(),
19
+ _component: Joi.string().required(),
20
+ _children: Joi.array().required(),
21
+ _instanceName: Joi.string().required(),
22
+ _styles: Joi.object().required(),
23
+ type: Joi.string().optional(),
24
+ table: Joi.string().optional(),
25
+ layoutId: Joi.string().optional(),
26
+ }).required().unknown(true),
27
+ }).unknown(true));
28
+ }
8
29
  router
9
30
  .get("/api/screens", authorized(BUILDER), controller.fetch)
10
- .post("/api/screens", authorized(BUILDER), screenValidator(), controller.save)
31
+ .post("/api/screens", authorized(BUILDER), generateSaveValidation(), controller.save)
11
32
  .delete("/api/screens/:screenId/:screenRev", authorized(BUILDER), controller.destroy);
12
33
  module.exports = router;
@@ -4,8 +4,22 @@ const tableController = require("../controllers/table");
4
4
  const authorized = require("../../middleware/authorized");
5
5
  const { paramResource, bodyResource } = require("../../middleware/resourceId");
6
6
  const { BUILDER, PermissionLevels, PermissionTypes, } = require("@budibase/backend-core/permissions");
7
- const { tableValidator } = require("./utils/validators");
7
+ const joiValidator = require("../../middleware/joi-validator");
8
+ const Joi = require("joi");
8
9
  const router = Router();
10
+ function generateSaveValidator() {
11
+ // prettier-ignore
12
+ return joiValidator.body(Joi.object({
13
+ _id: Joi.string(),
14
+ _rev: Joi.string(),
15
+ type: Joi.string().valid("table", "internal", "external"),
16
+ primaryDisplay: Joi.string(),
17
+ schema: Joi.object().required(),
18
+ name: Joi.string().required(),
19
+ views: Joi.object(),
20
+ dataImport: Joi.object(),
21
+ }).unknown(true));
22
+ }
9
23
  router
10
24
  /**
11
25
  * @api {get} /api/tables Fetch all tables
@@ -32,7 +46,7 @@ router
32
46
  *
33
47
  * @apiSuccess {object[]} body The response body will be the table that was found.
34
48
  */
35
- .get("/api/tables/:tableId", paramResource("tableId"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), tableController.find)
49
+ .get("/api/tables/:id", paramResource("id"), authorized(PermissionTypes.TABLE, PermissionLevels.READ), tableController.find)
36
50
  /**
37
51
  * @api {post} /api/tables Save a table
38
52
  * @apiName Save a table
@@ -108,7 +122,7 @@ router
108
122
  */
109
123
  .post("/api/tables",
110
124
  // allows control over updating a table
111
- bodyResource("_id"), authorized(BUILDER), tableValidator(), tableController.save)
125
+ bodyResource("_id"), authorized(BUILDER), generateSaveValidator(), tableController.save)
112
126
  /**
113
127
  * @api {post} /api/tables/csv/validate Validate a CSV for a table
114
128
  * @apiName Validate a CSV for a table
@@ -11,17 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  const TestConfig = require("../../../../tests/utilities/TestConfiguration");
12
12
  const structures = require("../../../../tests/utilities/structures");
13
13
  const env = require("../../../../environment");
14
- function user() {
15
- return {
16
- _id: "user",
17
- _rev: "rev",
18
- createdAt: Date.now(),
19
- email: "test@test.com",
20
- roles: {},
21
- tenantId: "default",
22
- status: "active",
23
- };
24
- }
25
14
  jest.mock("../../../../utilities/workerRequests", () => ({
26
15
  getGlobalUsers: jest.fn(() => {
27
16
  return {
@@ -33,18 +22,6 @@ jest.mock("../../../../utilities/workerRequests", () => ({
33
22
  _id: "us_uuid1",
34
23
  };
35
24
  }),
36
- allGlobalUsers: jest.fn(() => {
37
- return [user()];
38
- }),
39
- readGlobalUser: jest.fn(() => {
40
- return user();
41
- }),
42
- saveGlobalUser: jest.fn(() => {
43
- return { _id: "user", _rev: "rev" };
44
- }),
45
- deleteGlobalUser: jest.fn(() => {
46
- return { message: "deleted user" };
47
- }),
48
25
  removeAppFromUserRoles: jest.fn(),
49
26
  }));
50
27
  exports.delay = ms => new Promise(resolve => setTimeout(resolve, ms));
@@ -2,12 +2,27 @@
2
2
  const Router = require("@koa/router");
3
3
  const controller = require("../controllers/webhook");
4
4
  const authorized = require("../../middleware/authorized");
5
+ const joiValidator = require("../../middleware/joi-validator");
5
6
  const { BUILDER } = require("@budibase/backend-core/permissions");
6
- const { webhookValidator } = require("./utils/validators");
7
+ const Joi = require("joi");
7
8
  const router = Router();
9
+ function generateSaveValidator() {
10
+ // prettier-ignore
11
+ return joiValidator.body(Joi.object({
12
+ live: Joi.bool(),
13
+ _id: Joi.string().optional(),
14
+ _rev: Joi.string().optional(),
15
+ name: Joi.string().required(),
16
+ bodySchema: Joi.object().optional(),
17
+ action: Joi.object({
18
+ type: Joi.string().required().valid(controller.WebhookType.AUTOMATION),
19
+ target: Joi.string().required(),
20
+ }).required(),
21
+ }).unknown(true));
22
+ }
8
23
  router
9
24
  .get("/api/webhooks", authorized(BUILDER), controller.fetch)
10
- .put("/api/webhooks", authorized(BUILDER), webhookValidator(), controller.save)
25
+ .put("/api/webhooks", authorized(BUILDER), generateSaveValidator(), controller.save)
11
26
  .delete("/api/webhooks/:id/:rev", authorized(BUILDER), controller.destroy)
12
27
  .post("/api/webhooks/schema/:instance/:id", authorized(BUILDER), controller.buildSchema)
13
28
  // this shouldn't have authorisation, right now its always public
@@ -23,10 +23,10 @@ const PrettyFilterConditions = {
23
23
  exports.FilterConditions = FilterConditions;
24
24
  exports.PrettyFilterConditions = PrettyFilterConditions;
25
25
  exports.definition = {
26
- name: "Condition",
26
+ name: "Filter",
27
27
  tagline: "{{inputs.field}} {{inputs.condition}} {{inputs.value}}",
28
28
  icon: "Branch2",
29
- description: "Conditionally halt automations which do not meet certain conditions",
29
+ description: "Filter any automations which do not meet certain conditions",
30
30
  type: "LOGIC",
31
31
  internal: true,
32
32
  stepId: "FILTER",
@@ -81,7 +81,7 @@ function getTable(appId, tableId) {
81
81
  return __awaiter(this, void 0, void 0, function* () {
82
82
  const ctx = buildCtx(appId, null, {
83
83
  params: {
84
- tableId,
84
+ id: tableId,
85
85
  },
86
86
  });
87
87
  yield tableController.find(ctx);
@@ -15,7 +15,7 @@ const CouchDB = require("../db");
15
15
  const { queue } = require("./bullboard");
16
16
  const newid = require("../db/newid");
17
17
  const { updateEntityMetadata } = require("../utilities");
18
- const { MetadataTypes, WebhookType } = require("../constants");
18
+ const { MetadataTypes } = require("../constants");
19
19
  const { getProdAppID } = require("@budibase/backend-core/db");
20
20
  const { cloneDeep } = require("lodash/fp");
21
21
  const { getAppDB, getAppId } = require("@budibase/backend-core/context");
@@ -145,7 +145,7 @@ exports.checkForWebhooks = ({ oldAuto, newAuto }) => __awaiter(void 0, void 0, v
145
145
  const ctx = {
146
146
  appId,
147
147
  request: {
148
- body: new webhooks.Webhook("Automation webhook", WebhookType.AUTOMATION, newAuto._id),
148
+ body: new webhooks.Webhook("Automation webhook", webhooks.WebhookType.AUTOMATION, newAuto._id),
149
149
  },
150
150
  };
151
151
  yield webhooks.save(ctx);
@@ -166,8 +166,5 @@ exports.BuildSchemaErrors = {
166
166
  NO_KEY: "no_key",
167
167
  INVALID_COLUMN: "invalid_column",
168
168
  };
169
- exports.WebhookType = {
170
- AUTOMATION: "automation",
171
- };
172
169
  // pass through the list from the auth/core lib
173
170
  exports.ObjectStoreBuckets = ObjectStoreBuckets;
package/dist/db/utils.js CHANGED
@@ -114,17 +114,6 @@ exports.getRowParams = (tableId = null, rowId = null, otherProps = {}) => {
114
114
  const endOfKey = rowId == null ? `${tableId}${SEPARATOR}` : rowId;
115
115
  return getDocParams(DocumentTypes.ROW, endOfKey, otherProps);
116
116
  };
117
- /**
118
- * Given a row ID this will find the table ID within it (only works for internal tables).
119
- * @param {string} rowId The ID of the row.
120
- * @returns {string} The table ID.
121
- */
122
- exports.getTableIDFromRowID = rowId => {
123
- const components = rowId
124
- .split(DocumentTypes.TABLE + SEPARATOR)[1]
125
- .split(SEPARATOR);
126
- return `${DocumentTypes.TABLE}${SEPARATOR}${components[0]}`;
127
- };
128
117
  /**
129
118
  * Gets a new row ID for the specified table.
130
119
  * @param {string} tableId The table which the row is being created for.
@@ -37,7 +37,6 @@ module.exports = {
37
37
  INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
38
38
  MULTI_TENANCY: process.env.MULTI_TENANCY,
39
39
  HTTP_MIGRATIONS: process.env.HTTP_MIGRATIONS,
40
- API_REQ_LIMIT_PER_SEC: process.env.API_REQ_LIMIT_PER_SEC,
41
40
  // environment
42
41
  NODE_ENV: process.env.NODE_ENV,
43
42
  JEST_WORKER_ID: process.env.JEST_WORKER_ID,
@@ -232,9 +232,6 @@ class InternalBuilder {
232
232
  create(knex, json, opts) {
233
233
  const { endpoint, body } = json;
234
234
  let query = knex(endpoint.entityId);
235
- if (endpoint.schema) {
236
- query = query.withSchema(endpoint.schema);
237
- }
238
235
  const parsedBody = parseBody(body);
239
236
  // make sure no null values in body for creation
240
237
  for (let [key, value] of Object.entries(parsedBody)) {
@@ -253,9 +250,6 @@ class InternalBuilder {
253
250
  bulkCreate(knex, json) {
254
251
  const { endpoint, body } = json;
255
252
  let query = knex(endpoint.entityId);
256
- if (endpoint.schema) {
257
- query = query.withSchema(endpoint.schema);
258
- }
259
253
  if (!Array.isArray(body)) {
260
254
  return query;
261
255
  }
@@ -263,7 +257,7 @@ class InternalBuilder {
263
257
  return query.insert(parsedBody);
264
258
  }
265
259
  read(knex, json, limit) {
266
- let { endpoint, resource, filters, paginate, relationships } = json;
260
+ let { endpoint, resource, filters, sort, paginate, relationships } = json;
267
261
  const tableName = endpoint.entityId;
268
262
  // select all if not specified
269
263
  if (!resource) {
@@ -291,9 +285,6 @@ class InternalBuilder {
291
285
  }
292
286
  // start building the query
293
287
  let query = knex(tableName).limit(foundLimit);
294
- if (endpoint.schema) {
295
- query = query.withSchema(endpoint.schema);
296
- }
297
288
  if (foundOffset) {
298
289
  query = query.offset(foundOffset);
299
290
  }
@@ -316,9 +307,6 @@ class InternalBuilder {
316
307
  update(knex, json, opts) {
317
308
  const { endpoint, body, filters } = json;
318
309
  let query = knex(endpoint.entityId);
319
- if (endpoint.schema) {
320
- query = query.withSchema(endpoint.schema);
321
- }
322
310
  const parsedBody = parseBody(body);
323
311
  query = this.addFilters(query, filters, { tableName: endpoint.entityId });
324
312
  // mysql can't use returning
@@ -332,9 +320,6 @@ class InternalBuilder {
332
320
  delete(knex, json, opts) {
333
321
  const { endpoint, filters } = json;
334
322
  let query = knex(endpoint.entityId);
335
- if (endpoint.schema) {
336
- query = query.withSchema(endpoint.schema);
337
- }
338
323
  query = this.addFilters(query, filters, { tableName: endpoint.entityId });
339
324
  // mysql can't use returning
340
325
  if (opts.disableReturning) {