@budibase/server 1.0.123-alpha.0 → 1.0.123

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 (330) hide show
  1. package/builder/assets/index.68a7f4e3.css +6 -0
  2. package/builder/assets/index.8d4a5b33.js +1291 -0
  3. package/builder/assets/{vendor.5240f480.js → vendor.8e34a169.js} +1 -1
  4. package/builder/index.html +3 -3
  5. package/coverage/clover.xml +1763 -758
  6. package/coverage/coverage-final.json +43 -28
  7. package/coverage/lcov-report/api/controllers/analytics.js.html +3 -8
  8. package/coverage/lcov-report/api/controllers/apikeys.js.html +4 -9
  9. package/coverage/lcov-report/api/controllers/application.js.html +1436 -0
  10. package/coverage/lcov-report/api/controllers/auth.js.html +3 -8
  11. package/coverage/lcov-report/api/controllers/automation.js.html +3 -8
  12. package/coverage/lcov-report/api/controllers/backup.js.html +3 -8
  13. package/coverage/lcov-report/api/controllers/cloud.js.html +3 -8
  14. package/coverage/lcov-report/api/controllers/component.js.html +3 -8
  15. package/coverage/lcov-report/api/controllers/datasource.js.html +6 -11
  16. package/coverage/lcov-report/api/controllers/dev.js.html +3 -8
  17. package/coverage/lcov-report/api/controllers/index.html +26 -16
  18. package/coverage/lcov-report/api/controllers/integration.js.html +3 -8
  19. package/coverage/lcov-report/api/controllers/layout.js.html +3 -8
  20. package/coverage/lcov-report/api/controllers/metadata.js.html +3 -8
  21. package/coverage/lcov-report/api/controllers/migrations.js.html +3 -8
  22. package/coverage/lcov-report/api/controllers/permission.js.html +3 -8
  23. package/coverage/lcov-report/api/controllers/query/index.html +26 -16
  24. package/coverage/lcov-report/api/controllers/query/index.js.html +713 -0
  25. package/coverage/lcov-report/api/controllers/query/validation.js.html +3 -8
  26. package/coverage/lcov-report/api/controllers/role.js.html +5 -10
  27. package/coverage/lcov-report/api/controllers/routing.js.html +4 -9
  28. package/coverage/lcov-report/api/controllers/row/external.js.html +3 -8
  29. package/coverage/lcov-report/api/controllers/row/index.html +35 -25
  30. package/coverage/lcov-report/api/controllers/row/index.js.html +524 -0
  31. package/coverage/lcov-report/api/controllers/row/internal.js.html +24 -32
  32. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +16 -21
  33. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +19 -24
  34. package/coverage/lcov-report/api/controllers/row/utils.js.html +19 -33
  35. package/coverage/lcov-report/api/controllers/screen.js.html +4 -9
  36. package/coverage/lcov-report/api/controllers/script.js.html +3 -8
  37. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +50 -55
  38. package/coverage/lcov-report/api/controllers/table/external.js.html +3 -8
  39. package/coverage/lcov-report/api/controllers/table/index.html +44 -19
  40. package/coverage/lcov-report/api/controllers/table/index.js.html +15 -20
  41. package/coverage/lcov-report/api/controllers/table/internal.js.html +620 -0
  42. package/coverage/lcov-report/api/controllers/table/utils.js.html +1331 -0
  43. package/coverage/lcov-report/api/controllers/templates.js.html +3 -8
  44. package/coverage/lcov-report/api/controllers/user.js.html +3 -8
  45. package/coverage/lcov-report/api/controllers/view/exporters.js.html +3 -8
  46. package/coverage/lcov-report/api/controllers/view/index.html +3 -8
  47. package/coverage/lcov-report/api/controllers/view/index.js.html +5 -10
  48. package/coverage/lcov-report/api/controllers/view/utils.js.html +3 -8
  49. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +3 -8
  50. package/coverage/lcov-report/api/controllers/webhook.js.html +5 -10
  51. package/coverage/lcov-report/api/index.html +13 -18
  52. package/coverage/lcov-report/api/index.js.html +8 -28
  53. package/coverage/lcov-report/api/routes/analytics.js.html +3 -8
  54. package/coverage/lcov-report/api/routes/apikeys.js.html +3 -8
  55. package/coverage/lcov-report/api/routes/application.js.html +179 -0
  56. package/coverage/lcov-report/api/routes/auth.js.html +3 -8
  57. package/coverage/lcov-report/api/routes/automation.js.html +3 -8
  58. package/coverage/lcov-report/api/routes/backup.js.html +3 -8
  59. package/coverage/lcov-report/api/routes/cloud.js.html +3 -8
  60. package/coverage/lcov-report/api/routes/component.js.html +3 -8
  61. package/coverage/lcov-report/api/routes/datasource.js.html +3 -8
  62. package/coverage/lcov-report/api/routes/deploy.js.html +3 -8
  63. package/coverage/lcov-report/api/routes/dev.js.html +4 -9
  64. package/coverage/lcov-report/api/routes/index.html +68 -13
  65. package/coverage/lcov-report/api/routes/index.js.html +266 -0
  66. package/coverage/lcov-report/api/routes/integration.js.html +3 -8
  67. package/coverage/lcov-report/api/routes/layout.js.html +3 -8
  68. package/coverage/lcov-report/api/routes/metadata.js.html +3 -8
  69. package/coverage/lcov-report/api/routes/migrations.js.html +3 -8
  70. package/coverage/lcov-report/api/routes/permission.js.html +3 -8
  71. package/coverage/lcov-report/api/routes/query.js.html +3 -8
  72. package/coverage/lcov-report/api/routes/role.js.html +3 -8
  73. package/coverage/lcov-report/api/routes/routing.js.html +3 -8
  74. package/coverage/lcov-report/api/routes/row.js.html +908 -0
  75. package/coverage/lcov-report/api/routes/screen.js.html +3 -8
  76. package/coverage/lcov-report/api/routes/script.js.html +3 -8
  77. package/coverage/lcov-report/{automations/steps/loop.js.html → api/routes/static.js.html} +80 -70
  78. package/coverage/lcov-report/api/routes/table.js.html +3 -8
  79. package/coverage/lcov-report/api/routes/templates.js.html +3 -8
  80. package/coverage/lcov-report/api/routes/user.js.html +3 -8
  81. package/coverage/lcov-report/api/routes/utils/index.html +3 -8
  82. package/coverage/lcov-report/api/routes/utils/validators.js.html +3 -8
  83. package/coverage/lcov-report/api/routes/view.js.html +3 -8
  84. package/coverage/lcov-report/api/routes/webhook.js.html +3 -8
  85. package/coverage/lcov-report/automations/actions.js.html +7 -21
  86. package/coverage/lcov-report/automations/automationUtils.js.html +23 -64
  87. package/coverage/lcov-report/automations/bullboard.js.html +3 -8
  88. package/coverage/lcov-report/automations/index.html +37 -27
  89. package/coverage/lcov-report/automations/index.js.html +3 -8
  90. package/coverage/lcov-report/automations/steps/bash.js.html +3 -8
  91. package/coverage/lcov-report/automations/steps/createRow.js.html +380 -0
  92. package/coverage/lcov-report/automations/steps/delay.js.html +3 -8
  93. package/coverage/lcov-report/automations/steps/deleteRow.js.html +347 -0
  94. package/coverage/lcov-report/automations/steps/discord.js.html +3 -8
  95. package/coverage/lcov-report/automations/steps/executeQuery.js.html +3 -8
  96. package/coverage/lcov-report/automations/steps/executeScript.js.html +3 -8
  97. package/coverage/lcov-report/automations/steps/filter.js.html +3 -8
  98. package/coverage/lcov-report/automations/steps/index.html +41 -31
  99. package/coverage/lcov-report/automations/steps/integromat.js.html +3 -8
  100. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +4 -9
  101. package/coverage/lcov-report/automations/steps/queryRows.js.html +4 -9
  102. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +3 -8
  103. package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -8
  104. package/coverage/lcov-report/automations/steps/slack.js.html +3 -8
  105. package/coverage/lcov-report/automations/steps/updateRow.js.html +3 -8
  106. package/coverage/lcov-report/automations/steps/utils.js.html +9 -14
  107. package/coverage/lcov-report/automations/steps/zapier.js.html +3 -8
  108. package/coverage/lcov-report/automations/triggerInfo/app.js.html +3 -8
  109. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +3 -8
  110. package/coverage/lcov-report/automations/triggerInfo/index.html +3 -8
  111. package/coverage/lcov-report/automations/triggerInfo/index.js.html +3 -8
  112. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +3 -8
  113. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +3 -8
  114. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +3 -8
  115. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +3 -8
  116. package/coverage/lcov-report/automations/triggers.js.html +11 -16
  117. package/coverage/lcov-report/automations/utils.js.html +665 -0
  118. package/coverage/lcov-report/block-navigation.js +0 -8
  119. package/coverage/lcov-report/constants/index.html +3 -8
  120. package/coverage/lcov-report/constants/index.js.html +42 -41
  121. package/coverage/lcov-report/constants/layouts.js.html +3 -8
  122. package/coverage/lcov-report/constants/screens.js.html +3 -8
  123. package/coverage/lcov-report/db/inMemoryView.js.html +3 -8
  124. package/coverage/lcov-report/db/index.html +3 -8
  125. package/coverage/lcov-report/db/index.js.html +4 -9
  126. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +23 -25
  127. package/coverage/lcov-report/db/linkedRows/index.html +12 -17
  128. package/coverage/lcov-report/db/linkedRows/index.js.html +17 -22
  129. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +7 -12
  130. package/coverage/lcov-report/db/newid.js.html +6 -11
  131. package/coverage/lcov-report/db/utils.js.html +79 -84
  132. package/coverage/lcov-report/events/AutomationEmitter.js.html +9 -14
  133. package/coverage/lcov-report/events/index.html +3 -8
  134. package/coverage/lcov-report/events/index.js.html +4 -9
  135. package/coverage/lcov-report/events/utils.js.html +13 -18
  136. package/coverage/lcov-report/index.html +132 -137
  137. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +3 -8
  138. package/coverage/lcov-report/integrations/tests/index.html +3 -8
  139. package/coverage/lcov-report/middleware/appInfo.js.html +3 -8
  140. package/coverage/lcov-report/middleware/authorized.js.html +458 -0
  141. package/coverage/lcov-report/middleware/builder.js.html +3 -8
  142. package/coverage/lcov-report/middleware/currentapp.js.html +15 -65
  143. package/coverage/lcov-report/middleware/index.html +50 -25
  144. package/coverage/lcov-report/middleware/joi-validator.js.html +4 -9
  145. package/coverage/lcov-report/middleware/publicApi.js.html +3 -8
  146. package/coverage/lcov-report/middleware/resourceId.js.html +3 -8
  147. package/coverage/lcov-report/middleware/selfhost.js.html +4 -9
  148. package/coverage/lcov-report/middleware/usageQuota.js.html +572 -0
  149. package/coverage/lcov-report/middleware/utils.js.html +3 -8
  150. package/coverage/lcov-report/sorter.js +0 -26
  151. package/coverage/lcov-report/threads/automation.js.html +90 -581
  152. package/coverage/lcov-report/threads/index.html +40 -30
  153. package/coverage/lcov-report/threads/index.js.html +296 -0
  154. package/coverage/lcov-report/threads/query.js.html +4 -9
  155. package/coverage/lcov-report/threads/utils.js.html +9 -17
  156. package/coverage/lcov-report/utilities/bcrypt.js.html +3 -8
  157. package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -8
  158. package/coverage/lcov-report/utilities/centralPath.js.html +3 -8
  159. package/coverage/lcov-report/utilities/csvParser.js.html +5 -10
  160. package/coverage/lcov-report/utilities/global.js.html +4 -9
  161. package/coverage/lcov-report/utilities/index.html +3 -8
  162. package/coverage/lcov-report/utilities/index.js.html +6 -11
  163. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -32
  164. package/coverage/lcov-report/utilities/queue/index.html +7 -12
  165. package/coverage/lcov-report/utilities/routing/index.html +3 -8
  166. package/coverage/lcov-report/utilities/routing/index.js.html +3 -8
  167. package/coverage/lcov-report/utilities/rowProcessor/index.html +27 -32
  168. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +71 -67
  169. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +106 -27
  170. package/coverage/lcov-report/utilities/scriptRunner.js.html +3 -8
  171. package/coverage/lcov-report/utilities/security.js.html +4 -9
  172. package/coverage/lcov-report/utilities/statusCodes.js.html +3 -8
  173. package/coverage/lcov-report/utilities/usageQuota/index.html +34 -24
  174. package/coverage/lcov-report/utilities/usageQuota/index.js.html +359 -0
  175. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +39 -44
  176. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +3 -8
  177. package/coverage/lcov-report/utilities/users.js.html +3 -8
  178. package/coverage/lcov-report/utilities/workerRequests.js.html +4 -9
  179. package/coverage/lcov.info +3061 -1290
  180. package/dist/api/controllers/application.js +73 -145
  181. package/dist/api/controllers/deploy/index.js +36 -68
  182. package/dist/api/controllers/public/applications.js +9 -29
  183. package/dist/api/controllers/public/queries.js +7 -27
  184. package/dist/api/controllers/public/rows.js +12 -32
  185. package/dist/api/controllers/public/tables.js +2 -2
  186. package/dist/api/controllers/public/users.js +8 -8
  187. package/dist/api/controllers/public/utils.js +1 -1
  188. package/dist/api/controllers/query/import/index.js +3 -3
  189. package/dist/api/controllers/query/index.js +44 -57
  190. package/dist/api/controllers/row/ExternalRequest.js +27 -27
  191. package/dist/api/controllers/row/index.js +60 -83
  192. package/dist/api/controllers/row/internal.js +1 -2
  193. package/dist/api/controllers/row/utils.js +1 -2
  194. package/dist/api/controllers/static/templates/BudibaseApp.svelte +0 -3
  195. package/dist/api/controllers/table/bulkFormula.js +1 -2
  196. package/dist/api/controllers/table/internal.js +55 -40
  197. package/dist/api/controllers/table/utils.js +229 -271
  198. package/dist/api/index.js +0 -5
  199. package/dist/api/routes/application.js +13 -39
  200. package/dist/api/routes/index.js +56 -61
  201. package/dist/api/routes/public/index.js +9 -6
  202. package/dist/api/routes/public/queries.js +1 -1
  203. package/dist/api/routes/public/rows.js +1 -1
  204. package/dist/api/routes/public/tables.js +3 -3
  205. package/dist/api/routes/public/users.js +1 -1
  206. package/dist/api/routes/row.js +17 -43
  207. package/dist/api/routes/static.js +13 -40
  208. package/dist/api/routes/tests/utilities/TestFunctions.js +33 -75
  209. package/dist/app.js +4 -8
  210. package/dist/automations/actions.js +0 -3
  211. package/dist/automations/automationUtils.js +0 -10
  212. package/dist/automations/steps/createRow.js +12 -12
  213. package/dist/automations/steps/deleteRow.js +16 -13
  214. package/dist/automations/tests/utilities/index.js +11 -13
  215. package/dist/automations/utils.js +133 -187
  216. package/dist/constants/index.js +7 -5
  217. package/dist/db/linkedRows/LinkController.js +1 -0
  218. package/dist/definitions/datasource.js +0 -1
  219. package/dist/environment.js +3 -2
  220. package/dist/index.js +0 -4
  221. package/dist/integrations/base/sql.js +2 -2
  222. package/dist/integrations/base/sqlTable.js +2 -2
  223. package/dist/integrations/googlesheets.js +1 -1
  224. package/dist/integrations/index.js +0 -4
  225. package/dist/integrations/microsoftSqlServer.js +8 -8
  226. package/dist/integrations/mysql.js +9 -9
  227. package/dist/integrations/oracle.js +7 -7
  228. package/dist/integrations/postgres.js +7 -7
  229. package/dist/integrations/queries/sql.js +2 -2
  230. package/dist/integrations/rest.js +1 -1
  231. package/dist/middleware/authorized.js +51 -51
  232. package/dist/middleware/currentapp.js +1 -15
  233. package/dist/middleware/usageQuota.js +154 -0
  234. package/dist/migrations/functions/appUrls.js +1 -1
  235. package/dist/migrations/functions/quotas1.js +2 -6
  236. package/dist/migrations/functions/usageQuotas/index.js +4 -0
  237. package/dist/migrations/functions/usageQuotas/syncApps.js +7 -4
  238. package/dist/migrations/functions/usageQuotas/syncRows.js +8 -5
  239. package/dist/migrations/index.js +1 -17
  240. package/dist/package.json +4 -10
  241. package/dist/threads/automation.js +27 -149
  242. package/dist/threads/index.js +10 -36
  243. package/dist/threads/utils.js +0 -1
  244. package/dist/tsconfig.tsbuildinfo +1 -0
  245. package/dist/utilities/queue/inMemoryQueue.js +1 -6
  246. package/dist/utilities/rowProcessor/index.js +11 -6
  247. package/dist/utilities/rowProcessor/utils.js +27 -1
  248. package/dist/utilities/usageQuota/index.js +86 -0
  249. package/nodemon.json +1 -1
  250. package/package.json +9 -15
  251. package/scripts/dev/manage.js +0 -2
  252. package/src/api/controllers/{application.ts → application.js} +51 -118
  253. package/src/api/controllers/deploy/{index.ts → index.js} +29 -53
  254. package/src/api/controllers/public/applications.ts +2 -2
  255. package/src/api/controllers/public/queries.ts +1 -1
  256. package/src/api/controllers/public/rows.ts +1 -1
  257. package/src/api/controllers/query/{index.ts → index.js} +48 -51
  258. package/src/api/controllers/row/ExternalRequest.ts +1 -1
  259. package/src/api/controllers/row/{index.ts → index.js} +17 -24
  260. package/src/api/controllers/row/internal.js +1 -2
  261. package/src/api/controllers/row/utils.js +1 -4
  262. package/src/api/controllers/static/templates/BudibaseApp.svelte +0 -3
  263. package/src/api/controllers/table/bulkFormula.js +1 -1
  264. package/src/api/controllers/table/{internal.ts → internal.js} +48 -27
  265. package/src/api/controllers/table/{utils.ts → utils.js} +69 -86
  266. package/src/api/index.js +0 -5
  267. package/src/api/routes/{application.ts → application.js} +14 -8
  268. package/src/api/routes/index.js +62 -0
  269. package/src/api/routes/public/index.ts +4 -1
  270. package/src/api/routes/{row.ts → row.js} +15 -7
  271. package/src/api/routes/{static.ts → static.js} +11 -11
  272. package/src/api/routes/tests/misc.spec.js +37 -39
  273. package/src/api/routes/tests/routing.spec.js +0 -1
  274. package/src/api/routes/tests/utilities/{TestFunctions.ts → TestFunctions.js} +33 -57
  275. package/src/app.ts +2 -1
  276. package/src/automations/actions.js +0 -3
  277. package/src/automations/automationUtils.js +0 -12
  278. package/src/automations/steps/{createRow.ts → createRow.js} +15 -9
  279. package/src/automations/steps/{deleteRow.ts → deleteRow.js} +16 -10
  280. package/src/automations/tests/automation.spec.js +1 -0
  281. package/src/automations/tests/{createRow.spec.ts → createRow.spec.js} +15 -4
  282. package/src/automations/tests/{deleteRow.spec.ts → deleteRow.spec.js} +5 -3
  283. package/src/automations/tests/utilities/index.js +10 -12
  284. package/src/automations/{utils.ts → utils.js} +28 -39
  285. package/src/constants/index.js +8 -6
  286. package/src/db/linkedRows/LinkController.js +1 -0
  287. package/src/definitions/datasource.ts +0 -1
  288. package/src/environment.js +3 -2
  289. package/src/index.ts +0 -3
  290. package/src/integrations/index.ts +0 -4
  291. package/src/middleware/{authorized.ts → authorized.js} +14 -20
  292. package/src/middleware/currentapp.js +1 -16
  293. package/src/middleware/tests/usageQuota.spec.js +120 -0
  294. package/src/middleware/usageQuota.js +164 -0
  295. package/src/migrations/functions/tests/quotas1.spec.js +2 -0
  296. package/src/migrations/functions/usageQuotas/index.ts +5 -0
  297. package/src/migrations/functions/usageQuotas/syncApps.ts +6 -3
  298. package/src/migrations/functions/usageQuotas/syncRows.ts +6 -3
  299. package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +41 -0
  300. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +45 -0
  301. package/src/migrations/index.ts +1 -13
  302. package/src/threads/automation.js +34 -196
  303. package/src/threads/{index.ts → index.js} +14 -18
  304. package/src/threads/utils.js +0 -1
  305. package/src/utilities/queue/inMemoryQueue.js +1 -7
  306. package/src/utilities/rowProcessor/index.js +12 -9
  307. package/src/utilities/rowProcessor/utils.js +29 -1
  308. package/src/utilities/tests/usageQuota/usageQuota.spec.js +72 -0
  309. package/src/utilities/usageQuota/index.js +93 -0
  310. package/tsconfig.json +2 -2
  311. package/builder/assets/index.89795487.css +0 -6
  312. package/builder/assets/index.be9a1b80.js +0 -1299
  313. package/dist/automations/steps/loop.js +0 -51
  314. package/dist/integrations/redis.js +0 -158
  315. package/dist/migrations/functions/developerQuota.js +0 -49
  316. package/dist/migrations/functions/publishedAppsQuota.js +0 -47
  317. package/dist/migrations/functions/usageQuotas/syncDevelopers.js +0 -24
  318. package/dist/migrations/functions/usageQuotas/syncPublishedApps.js +0 -26
  319. package/dist/tsconfig.build.tsbuildinfo +0 -1
  320. package/src/api/routes/index.ts +0 -60
  321. package/src/automations/steps/loop.js +0 -50
  322. package/src/integrations/redis.ts +0 -152
  323. package/src/integrations/tests/redis.spec.js +0 -60
  324. package/src/migrations/functions/developerQuota.ts +0 -15
  325. package/src/migrations/functions/publishedAppsQuota.ts +0 -13
  326. package/src/migrations/functions/usageQuotas/syncDevelopers.ts +0 -19
  327. package/src/migrations/functions/usageQuotas/syncPublishedApps.ts +0 -21
  328. package/src/migrations/functions/usageQuotas/tests/syncApps.spec.ts +0 -34
  329. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +0 -40
  330. package/tsconfig.build.json +0 -10
@@ -1,19 +1,40 @@
1
- import { updateLinks, EventType } from "../../../db/linkedRows"
2
- import { getRowParams, generateTableID } from "../../../db/utils"
3
- import { FieldTypes } from "../../../constants"
4
- import {
1
+ const linkRows = require("../../../db/linkedRows")
2
+ const { getRowParams, generateTableID } = require("../../../db/utils")
3
+ const { FieldTypes } = require("../../../constants")
4
+ const {
5
5
  TableSaveFunctions,
6
6
  hasTypeChanged,
7
7
  getTable,
8
8
  handleDataImport,
9
- } from "./utils"
9
+ } = require("./utils")
10
+ const usageQuota = require("../../../utilities/usageQuota")
10
11
  const { getAppDB } = require("@budibase/backend-core/context")
11
- import { isTest } from "../../../environment"
12
- import { cleanupAttachments } from "../../../utilities/rowProcessor"
13
- import { runStaticFormulaChecks } from "./bulkFormula"
14
- import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro"
12
+ const env = require("../../../environment")
13
+ const {
14
+ cleanupAttachments,
15
+ fixAutoColumnSubType,
16
+ } = require("../../../utilities/rowProcessor")
17
+ const { runStaticFormulaChecks } = require("./bulkFormula")
18
+
19
+ function checkAutoColumns(table, oldTable) {
20
+ if (!table.schema) {
21
+ return table
22
+ }
23
+ for (let [key, schema] of Object.entries(table.schema)) {
24
+ if (!schema.autocolumn || schema.subtype) {
25
+ continue
26
+ }
27
+ const oldSchema = oldTable && oldTable.schema[key]
28
+ if (oldSchema && oldSchema.subtype) {
29
+ table.schema[key].subtype = oldSchema.subtype
30
+ } else {
31
+ table.schema[key] = fixAutoColumnSubType(schema)
32
+ }
33
+ }
34
+ return table
35
+ }
15
36
 
16
- export async function save(ctx: any) {
37
+ exports.save = async function (ctx) {
17
38
  const db = getAppDB()
18
39
  const { dataImport, ...rest } = ctx.request.body
19
40
  let tableToSave = {
@@ -29,9 +50,12 @@ export async function save(ctx: any) {
29
50
  oldTable = await db.get(ctx.request.body._id)
30
51
  }
31
52
 
53
+ // check all types are correct
32
54
  if (hasTypeChanged(tableToSave, oldTable)) {
33
55
  ctx.throw(400, "A column type has changed.")
34
56
  }
57
+ // check that subtypes have been maintained
58
+ tableToSave = checkAutoColumns(tableToSave, oldTable)
35
59
 
36
60
  // saving a table is a complex operation, involving many different steps, this
37
61
  // has been broken out into a utility to make it more obvious/easier to manipulate
@@ -80,8 +104,10 @@ export async function save(ctx: any) {
80
104
 
81
105
  // update linked rows
82
106
  try {
83
- const linkResp: any = await updateLinks({
84
- eventType: oldTable ? EventType.TABLE_UPDATED : EventType.TABLE_SAVE,
107
+ const linkResp = await linkRows.updateLinks({
108
+ eventType: oldTable
109
+ ? linkRows.EventType.TABLE_UPDATED
110
+ : linkRows.EventType.TABLE_SAVE,
85
111
  table: tableToSave,
86
112
  oldTable: oldTable,
87
113
  })
@@ -103,11 +129,11 @@ export async function save(ctx: any) {
103
129
 
104
130
  tableToSave = await tableSaveFunctions.after(tableToSave)
105
131
  // has to run after, make sure it has _id
106
- await runStaticFormulaChecks(tableToSave, { oldTable, deletion: null })
132
+ await runStaticFormulaChecks(tableToSave, { oldTable })
107
133
  return tableToSave
108
134
  }
109
135
 
110
- export async function destroy(ctx: any) {
136
+ exports.destroy = async function (ctx) {
111
137
  const db = getAppDB()
112
138
  const tableToDelete = await db.get(ctx.params.tableId)
113
139
 
@@ -117,14 +143,12 @@ export async function destroy(ctx: any) {
117
143
  include_docs: true,
118
144
  })
119
145
  )
120
- await db.bulkDocs(
121
- rows.rows.map((row: any) => ({ ...row.doc, _deleted: true }))
122
- )
123
- await quotas.removeRows(rows.rows.length)
146
+ await db.bulkDocs(rows.rows.map(row => ({ ...row.doc, _deleted: true })))
147
+ await usageQuota.update(usageQuota.Properties.ROW, -rows.rows.length)
124
148
 
125
149
  // update linked rows
126
- await updateLinks({
127
- eventType: EventType.TABLE_DELETE,
150
+ await linkRows.updateLinks({
151
+ eventType: linkRows.EventType.TABLE_DELETE,
128
152
  table: tableToDelete,
129
153
  })
130
154
 
@@ -132,10 +156,10 @@ export async function destroy(ctx: any) {
132
156
  await db.remove(tableToDelete)
133
157
 
134
158
  // remove table search index
135
- if (!isTest()) {
159
+ if (!env.isTest()) {
136
160
  const currentIndexes = await db.getIndexes()
137
161
  const existingIndex = currentIndexes.indexes.find(
138
- (existing: any) => existing.name === `search:${ctx.params.tableId}`
162
+ existing => existing.name === `search:${ctx.params.tableId}`
139
163
  )
140
164
  if (existingIndex) {
141
165
  await db.deleteIndex(existingIndex)
@@ -143,15 +167,12 @@ export async function destroy(ctx: any) {
143
167
  }
144
168
 
145
169
  // has to run after, make sure it has _id
146
- await runStaticFormulaChecks(tableToDelete, {
147
- oldTable: null,
148
- deletion: true,
149
- })
170
+ await runStaticFormulaChecks(tableToDelete, { deletion: true })
150
171
  await cleanupAttachments(tableToDelete, { rows })
151
172
  return tableToDelete
152
173
  }
153
174
 
154
- export async function bulkImport(ctx: any) {
175
+ exports.bulkImport = async function (ctx) {
155
176
  const table = await getTable(ctx.params.tableId)
156
177
  const { dataImport } = ctx.request.body
157
178
  await handleDataImport(ctx.user, table, dataImport)
@@ -1,34 +1,34 @@
1
- import { transform } from "../../../utilities/csvParser"
2
- import {
1
+ const csvParser = require("../../../utilities/csvParser")
2
+ const {
3
3
  getRowParams,
4
4
  generateRowID,
5
5
  InternalTables,
6
6
  getTableParams,
7
7
  BudibaseInternalDB,
8
- } from "../../../db/utils"
9
- import { isEqual } from "lodash"
10
- import { AutoFieldSubTypes, FieldTypes } from "../../../constants"
11
- import {
8
+ } = require("../../../db/utils")
9
+ const { isEqual } = require("lodash")
10
+ const { AutoFieldSubTypes, FieldTypes } = require("../../../constants")
11
+ const {
12
12
  inputProcessing,
13
13
  cleanupAttachments,
14
- } from "../../../utilities/rowProcessor"
15
- import {
14
+ } = require("../../../utilities/rowProcessor")
15
+ const {
16
16
  USERS_TABLE_SCHEMA,
17
17
  SwitchableTypes,
18
18
  CanSwitchTypes,
19
- } from "../../../constants"
20
- import {
19
+ } = require("../../../constants")
20
+ const {
21
21
  isExternalTable,
22
22
  breakExternalTableId,
23
23
  isSQL,
24
- } from "../../../integrations/utils"
25
- import { getViews, saveView } from "../view/utils"
26
- import viewTemplate from "../view/viewBuilder"
24
+ } = require("../../../integrations/utils")
25
+ const { getViews, saveView } = require("../view/utils")
26
+ const viewTemplate = require("../view/viewBuilder")
27
+ const usageQuota = require("../../../utilities/usageQuota")
27
28
  const { getAppDB } = require("@budibase/backend-core/context")
28
- import { cloneDeep } from "lodash/fp"
29
- import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro"
29
+ const { cloneDeep } = require("lodash/fp")
30
30
 
31
- export async function clearColumns(table: any, columnNames: any) {
31
+ exports.clearColumns = async (table, columnNames) => {
32
32
  const db = getAppDB()
33
33
  const rows = await db.allDocs(
34
34
  getRowParams(table._id, null, {
@@ -36,18 +36,18 @@ export async function clearColumns(table: any, columnNames: any) {
36
36
  })
37
37
  )
38
38
  return db.bulkDocs(
39
- rows.rows.map(({ doc }: any) => {
40
- columnNames.forEach((colName: any) => delete doc[colName])
39
+ rows.rows.map(({ doc }) => {
40
+ columnNames.forEach(colName => delete doc[colName])
41
41
  return doc
42
42
  })
43
43
  )
44
44
  }
45
45
 
46
- export async function checkForColumnUpdates(oldTable: any, updatedTable: any) {
46
+ exports.checkForColumnUpdates = async (oldTable, updatedTable) => {
47
47
  const db = getAppDB()
48
48
  let updatedRows = []
49
49
  const rename = updatedTable._rename
50
- let deletedColumns: any = []
50
+ let deletedColumns = []
51
51
  if (oldTable && oldTable.schema && updatedTable.schema) {
52
52
  deletedColumns = Object.keys(oldTable.schema).filter(
53
53
  colName => updatedTable.schema[colName] == null
@@ -61,14 +61,14 @@ export async function checkForColumnUpdates(oldTable: any, updatedTable: any) {
61
61
  include_docs: true,
62
62
  })
63
63
  )
64
- const rawRows = rows.rows.map(({ doc }: any) => doc)
65
- updatedRows = rawRows.map((row: any) => {
64
+ const rawRows = rows.rows.map(({ doc }) => doc)
65
+ updatedRows = rawRows.map(row => {
66
66
  row = cloneDeep(row)
67
67
  if (rename) {
68
68
  row[rename.updated] = row[rename.old]
69
69
  delete row[rename.old]
70
70
  } else if (deletedColumns.length !== 0) {
71
- deletedColumns.forEach((colName: any) => delete row[colName])
71
+ deletedColumns.forEach(colName => delete row[colName])
72
72
  }
73
73
  return row
74
74
  })
@@ -76,14 +76,14 @@ export async function checkForColumnUpdates(oldTable: any, updatedTable: any) {
76
76
  // cleanup any attachments from object storage for deleted attachment columns
77
77
  await cleanupAttachments(updatedTable, { oldTable, rows: rawRows })
78
78
  // Update views
79
- await checkForViewUpdates(updatedTable, rename, deletedColumns)
79
+ await exports.checkForViewUpdates(updatedTable, rename, deletedColumns)
80
80
  delete updatedTable._rename
81
81
  }
82
82
  return { rows: updatedRows, table: updatedTable }
83
83
  }
84
84
 
85
85
  // makes sure the passed in table isn't going to reset the auto ID
86
- export function makeSureTableUpToDate(table: any, tableToSave: any) {
86
+ exports.makeSureTableUpToDate = (table, tableToSave) => {
87
87
  if (!table) {
88
88
  return tableToSave
89
89
  }
@@ -91,9 +91,7 @@ export function makeSureTableUpToDate(table: any, tableToSave: any) {
91
91
  tableToSave._rev = table._rev
92
92
  // make sure auto IDs are always updated - these are internal
93
93
  // so the client may not know they have changed
94
- let field: any
95
- let column: any
96
- for ([field, column] of Object.entries(table.schema)) {
94
+ for (let [field, column] of Object.entries(table.schema)) {
97
95
  if (
98
96
  column.autocolumn &&
99
97
  column.subtype === AutoFieldSubTypes.AUTO_ID &&
@@ -105,32 +103,30 @@ export function makeSureTableUpToDate(table: any, tableToSave: any) {
105
103
  return tableToSave
106
104
  }
107
105
 
108
- export async function handleDataImport(user: any, table: any, dataImport: any) {
106
+ exports.handleDataImport = async (user, table, dataImport) => {
109
107
  if (!dataImport || !dataImport.csvString) {
110
108
  return table
111
109
  }
112
110
 
113
111
  const db = getAppDB()
114
112
  // Populate the table with rows imported from CSV in a bulk update
115
- const data = await transform({
113
+ const data = await csvParser.transform({
116
114
  ...dataImport,
117
115
  existingTable: table,
118
116
  })
119
117
 
120
- let finalData: any = []
118
+ let finalData = []
121
119
  for (let i = 0; i < data.length; i++) {
122
120
  let row = data[i]
123
121
  row._id = generateRowID(table._id)
124
122
  row.tableId = table._id
125
- const processed: any = inputProcessing(user, table, row, {
123
+ const processed = inputProcessing(user, table, row, {
126
124
  noAutoRelationships: true,
127
125
  })
128
126
  table = processed.table
129
127
  row = processed.row
130
128
 
131
- let fieldName: any
132
- let schema: any
133
- for ([fieldName, schema] of Object.entries(table.schema)) {
129
+ for (let [fieldName, schema] of Object.entries(table.schema)) {
134
130
  // check whether the options need to be updated for inclusion as part of the data import
135
131
  if (
136
132
  schema.type === FieldTypes.OPTIONS &&
@@ -147,13 +143,17 @@ export async function handleDataImport(user: any, table: any, dataImport: any) {
147
143
  finalData.push(row)
148
144
  }
149
145
 
150
- await quotas.addRows(finalData.length, () => db.bulkDocs(finalData))
146
+ await usageQuota.update(usageQuota.Properties.ROW, finalData.length, {
147
+ dryRun: true,
148
+ })
149
+ await db.bulkDocs(finalData)
150
+ await usageQuota.update(usageQuota.Properties.ROW, finalData.length)
151
151
  let response = await db.put(table)
152
152
  table._rev = response._rev
153
153
  return table
154
154
  }
155
155
 
156
- export async function handleSearchIndexes(table: any) {
156
+ exports.handleSearchIndexes = async table => {
157
157
  const db = getAppDB()
158
158
  // create relevant search indexes
159
159
  if (table.indexes && table.indexes.length > 0) {
@@ -161,12 +161,12 @@ export async function handleSearchIndexes(table: any) {
161
161
  const indexName = `search:${table._id}`
162
162
 
163
163
  const existingIndex = currentIndexes.indexes.find(
164
- (existing: any) => existing.name === indexName
164
+ existing => existing.name === indexName
165
165
  )
166
166
 
167
167
  if (existingIndex) {
168
168
  const currentFields = existingIndex.def.fields.map(
169
- (field: any) => Object.keys(field)[0]
169
+ field => Object.keys(field)[0]
170
170
  )
171
171
 
172
172
  // if index fields have changed, delete the original index
@@ -197,7 +197,7 @@ export async function handleSearchIndexes(table: any) {
197
197
  return table
198
198
  }
199
199
 
200
- export function checkStaticTables(table: any) {
200
+ exports.checkStaticTables = table => {
201
201
  // check user schema has all required elements
202
202
  if (table._id === InternalTables.USER_METADATA) {
203
203
  for (let [key, schema] of Object.entries(USERS_TABLE_SCHEMA.schema)) {
@@ -211,13 +211,7 @@ export function checkStaticTables(table: any) {
211
211
  }
212
212
 
213
213
  class TableSaveFunctions {
214
- db: any
215
- user: any
216
- oldTable: any
217
- dataImport: any
218
- rows: any
219
-
220
- constructor({ user, oldTable, dataImport }: any) {
214
+ constructor({ user, oldTable, dataImport }) {
221
215
  this.db = getAppDB()
222
216
  this.user = user
223
217
  this.oldTable = oldTable
@@ -227,25 +221,25 @@ class TableSaveFunctions {
227
221
  }
228
222
 
229
223
  // before anything is done
230
- async before(table: any) {
224
+ async before(table) {
231
225
  if (this.oldTable) {
232
- table = makeSureTableUpToDate(this.oldTable, table)
226
+ table = exports.makeSureTableUpToDate(this.oldTable, table)
233
227
  }
234
- table = checkStaticTables(table)
228
+ table = exports.checkStaticTables(table)
235
229
  return table
236
230
  }
237
231
 
238
232
  // when confirmed valid
239
- async mid(table: any) {
240
- let response = await checkForColumnUpdates(this.oldTable, table)
233
+ async mid(table) {
234
+ let response = await exports.checkForColumnUpdates(this.oldTable, table)
241
235
  this.rows = this.rows.concat(response.rows)
242
236
  return table
243
237
  }
244
238
 
245
239
  // after saving
246
- async after(table: any) {
247
- table = await handleSearchIndexes(table)
248
- table = await handleDataImport(this.user, table, this.dataImport)
240
+ async after(table) {
241
+ table = await exports.handleSearchIndexes(table)
242
+ table = await exports.handleDataImport(this.user, table, this.dataImport)
249
243
  return table
250
244
  }
251
245
 
@@ -254,21 +248,21 @@ class TableSaveFunctions {
254
248
  }
255
249
  }
256
250
 
257
- export async function getAllInternalTables() {
251
+ exports.getAllInternalTables = async () => {
258
252
  const db = getAppDB()
259
253
  const internalTables = await db.allDocs(
260
254
  getTableParams(null, {
261
255
  include_docs: true,
262
256
  })
263
257
  )
264
- return internalTables.rows.map((tableDoc: any) => ({
258
+ return internalTables.rows.map(tableDoc => ({
265
259
  ...tableDoc.doc,
266
260
  type: "internal",
267
261
  sourceId: BudibaseInternalDB._id,
268
262
  }))
269
263
  }
270
264
 
271
- export async function getAllExternalTables(datasourceId: any) {
265
+ exports.getAllExternalTables = async datasourceId => {
272
266
  const db = getAppDB()
273
267
  const datasource = await db.get(datasourceId)
274
268
  if (!datasource || !datasource.entities) {
@@ -277,28 +271,24 @@ export async function getAllExternalTables(datasourceId: any) {
277
271
  return datasource.entities
278
272
  }
279
273
 
280
- export async function getExternalTable(datasourceId: any, tableName: any) {
281
- const entities = await getAllExternalTables(datasourceId)
274
+ exports.getExternalTable = async (datasourceId, tableName) => {
275
+ const entities = await exports.getAllExternalTables(datasourceId)
282
276
  return entities[tableName]
283
277
  }
284
278
 
285
- export async function getTable(tableId: any) {
279
+ exports.getTable = async tableId => {
286
280
  const db = getAppDB()
287
281
  if (isExternalTable(tableId)) {
288
282
  let { datasourceId, tableName } = breakExternalTableId(tableId)
289
283
  const datasource = await db.get(datasourceId)
290
- const table = await getExternalTable(datasourceId, tableName)
284
+ const table = await exports.getExternalTable(datasourceId, tableName)
291
285
  return { ...table, sql: isSQL(datasource) }
292
286
  } else {
293
287
  return db.get(tableId)
294
288
  }
295
289
  }
296
290
 
297
- export async function checkForViewUpdates(
298
- table: any,
299
- rename: any,
300
- deletedColumns: any
301
- ) {
291
+ exports.checkForViewUpdates = async (table, rename, deletedColumns) => {
302
292
  const views = await getViews()
303
293
  const tableViews = views.filter(view => view.meta.tableId === table._id)
304
294
 
@@ -322,7 +312,7 @@ export async function checkForViewUpdates(
322
312
 
323
313
  // Update filters if required
324
314
  if (view.meta.filters) {
325
- view.meta.filters.forEach((filter: any) => {
315
+ view.meta.filters.forEach(filter => {
326
316
  if (filter.key === rename.old) {
327
317
  filter.key = rename.updated
328
318
  needsUpdated = true
@@ -330,7 +320,7 @@ export async function checkForViewUpdates(
330
320
  })
331
321
  }
332
322
  } else if (deletedColumns) {
333
- deletedColumns.forEach((column: any) => {
323
+ deletedColumns.forEach(column => {
334
324
  // Remove calculation statement if required
335
325
  if (view.meta.field === column) {
336
326
  delete view.meta.field
@@ -348,7 +338,7 @@ export async function checkForViewUpdates(
348
338
  // Remove filters referencing deleted field if required
349
339
  if (view.meta.filters && view.meta.filters.length) {
350
340
  const initialLength = view.meta.filters.length
351
- view.meta.filters = view.meta.filters.filter((filter: any) => {
341
+ view.meta.filters = view.meta.filters.filter(filter => {
352
342
  return filter.key !== column
353
343
  })
354
344
  if (initialLength !== view.meta.filters.length) {
@@ -370,20 +360,16 @@ export async function checkForViewUpdates(
370
360
  }
371
361
  }
372
362
 
373
- export function generateForeignKey(column: any, relatedTable: any) {
363
+ exports.generateForeignKey = (column, relatedTable) => {
374
364
  return `fk_${relatedTable.name}_${column.fieldName}`
375
365
  }
376
366
 
377
- export function generateJunctionTableName(
378
- column: any,
379
- table: any,
380
- relatedTable: any
381
- ) {
367
+ exports.generateJunctionTableName = (column, table, relatedTable) => {
382
368
  return `jt_${table.name}_${relatedTable.name}_${column.name}_${column.fieldName}`
383
369
  }
384
370
 
385
- export function foreignKeyStructure(keyName: any, meta = null) {
386
- const structure: any = {
371
+ exports.foreignKeyStructure = (keyName, meta = null) => {
372
+ const structure = {
387
373
  type: FieldTypes.NUMBER,
388
374
  constraints: {},
389
375
  name: keyName,
@@ -394,7 +380,7 @@ export function foreignKeyStructure(keyName: any, meta = null) {
394
380
  return structure
395
381
  }
396
382
 
397
- export function areSwitchableTypes(type1: any, type2: any) {
383
+ exports.areSwitchableTypes = (type1, type2) => {
398
384
  if (
399
385
  SwitchableTypes.indexOf(type1) === -1 &&
400
386
  SwitchableTypes.indexOf(type2) === -1
@@ -411,24 +397,21 @@ export function areSwitchableTypes(type1: any, type2: any) {
411
397
  return false
412
398
  }
413
399
 
414
- export function hasTypeChanged(table: any, oldTable: any) {
400
+ exports.hasTypeChanged = (table, oldTable) => {
415
401
  if (!oldTable) {
416
402
  return false
417
403
  }
418
- let key: any
419
- let field: any
420
- for ([key, field] of Object.entries(oldTable.schema)) {
404
+ for (let [key, field] of Object.entries(oldTable.schema)) {
421
405
  const oldType = field.type
422
406
  if (!table.schema[key]) {
423
407
  continue
424
408
  }
425
409
  const newType = table.schema[key].type
426
- if (oldType !== newType && !areSwitchableTypes(oldType, newType)) {
410
+ if (oldType !== newType && !exports.areSwitchableTypes(oldType, newType)) {
427
411
  return true
428
412
  }
429
413
  }
430
414
  return false
431
415
  }
432
416
 
433
- const _TableSaveFunctions = TableSaveFunctions
434
- export { _TableSaveFunctions as TableSaveFunctions }
417
+ exports.TableSaveFunctions = TableSaveFunctions
package/src/api/index.js CHANGED
@@ -4,14 +4,12 @@ const {
4
4
  auditLog,
5
5
  buildTenancyMiddleware,
6
6
  } = require("@budibase/backend-core/auth")
7
- const { errors } = require("@budibase/backend-core")
8
7
  const currentApp = require("../middleware/currentapp")
9
8
  const compress = require("koa-compress")
10
9
  const zlib = require("zlib")
11
10
  const { mainRoutes, staticRoutes, publicRoutes } = require("./routes")
12
11
  const pkg = require("../../package.json")
13
12
  const env = require("../environment")
14
- const { middleware: pro } = require("@budibase/pro")
15
13
 
16
14
  const router = new Router()
17
15
 
@@ -54,7 +52,6 @@ router
54
52
  })
55
53
  )
56
54
  .use(currentApp)
57
- .use(pro.licensing())
58
55
  .use(auditLog)
59
56
 
60
57
  // error handling middleware
@@ -63,12 +60,10 @@ router.use(async (ctx, next) => {
63
60
  await next()
64
61
  } catch (err) {
65
62
  ctx.status = err.status || err.statusCode || 500
66
- const error = errors.getPublicError(err)
67
63
  ctx.body = {
68
64
  message: err.message,
69
65
  status: ctx.status,
70
66
  validationErrors: err.validation,
71
- error,
72
67
  }
73
68
  if (env.NODE_ENV !== "jest") {
74
69
  ctx.log.error(err)
@@ -1,13 +1,14 @@
1
- import Router from "@koa/router"
2
- import * as controller from "../controllers/application"
3
- import authorized from "../../middleware/authorized"
4
- import { BUILDER } from "@budibase/backend-core/permissions"
1
+ const Router = require("@koa/router")
2
+ const controller = require("../controllers/application")
3
+ const authorized = require("../../middleware/authorized")
4
+ const { BUILDER } = require("@budibase/backend-core/permissions")
5
+ const usage = require("../../middleware/usageQuota")
5
6
 
6
- const router = new Router()
7
+ const router = Router()
7
8
 
8
9
  router
9
10
  .post("/api/applications/:appId/sync", authorized(BUILDER), controller.sync)
10
- .post("/api/applications", authorized(BUILDER), controller.create)
11
+ .post("/api/applications", authorized(BUILDER), usage, controller.create)
11
12
  .get("/api/applications/:appId/definition", controller.fetchAppDefinition)
12
13
  .get("/api/applications", controller.fetch)
13
14
  .get("/api/applications/:appId/appPackage", controller.fetchAppPackage)
@@ -22,6 +23,11 @@ router
22
23
  authorized(BUILDER),
23
24
  controller.revertClient
24
25
  )
25
- .delete("/api/applications/:appId", authorized(BUILDER), controller.destroy)
26
+ .delete(
27
+ "/api/applications/:appId",
28
+ authorized(BUILDER),
29
+ usage,
30
+ controller.delete
31
+ )
26
32
 
27
- export default router
33
+ module.exports = router
@@ -0,0 +1,62 @@
1
+ const authRoutes = require("./auth")
2
+ const layoutRoutes = require("./layout")
3
+ const screenRoutes = require("./screen")
4
+ const userRoutes = require("./user")
5
+ const applicationRoutes = require("./application")
6
+ const tableRoutes = require("./table")
7
+ const rowRoutes = require("./row")
8
+ const viewRoutes = require("./view")
9
+ const staticRoutes = require("./static")
10
+ const componentRoutes = require("./component")
11
+ const automationRoutes = require("./automation")
12
+ const webhookRoutes = require("./webhook")
13
+ const roleRoutes = require("./role")
14
+ const deployRoutes = require("./deploy")
15
+ const apiKeysRoutes = require("./apikeys")
16
+ const templatesRoutes = require("./templates")
17
+ const analyticsRoutes = require("./analytics")
18
+ const routingRoutes = require("./routing")
19
+ const integrationRoutes = require("./integration")
20
+ const permissionRoutes = require("./permission")
21
+ const datasourceRoutes = require("./datasource")
22
+ const queryRoutes = require("./query")
23
+ const backupRoutes = require("./backup")
24
+ const metadataRoutes = require("./metadata")
25
+ const devRoutes = require("./dev")
26
+ const cloudRoutes = require("./cloud")
27
+ const migrationRoutes = require("./migrations")
28
+ const publicRoutes = require("./public")
29
+
30
+ exports.mainRoutes = [
31
+ authRoutes,
32
+ deployRoutes,
33
+ layoutRoutes,
34
+ screenRoutes,
35
+ userRoutes,
36
+ applicationRoutes,
37
+ automationRoutes,
38
+ viewRoutes,
39
+ componentRoutes,
40
+ roleRoutes,
41
+ apiKeysRoutes,
42
+ templatesRoutes,
43
+ analyticsRoutes,
44
+ webhookRoutes,
45
+ routingRoutes,
46
+ integrationRoutes,
47
+ permissionRoutes,
48
+ datasourceRoutes,
49
+ queryRoutes,
50
+ backupRoutes,
51
+ metadataRoutes,
52
+ devRoutes,
53
+ cloudRoutes,
54
+ // these need to be handled last as they still use /api/:tableId
55
+ // this could be breaking as koa may recognise other routes as this
56
+ tableRoutes,
57
+ rowRoutes,
58
+ migrationRoutes,
59
+ ]
60
+
61
+ exports.publicRoutes = publicRoutes
62
+ exports.staticRoutes = staticRoutes