@budibase/server 1.0.80 → 1.0.81-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/__mocks__/node-fetch.ts +1 -0
  2. package/builder/assets/{index.c8d1e8f0.css → index.8b1dc06c.css} +2 -2
  3. package/builder/assets/index.e4d4c510.js +1291 -0
  4. package/builder/assets/{vendor.20f80cec.js → vendor.a7c6ad0a.js} +190 -216
  5. package/builder/index.html +3 -3
  6. package/coverage/clover.xml +2531 -2440
  7. package/coverage/coverage-final.json +138 -137
  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 +152 -149
  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 +86 -23
  30. package/coverage/lcov-report/api/controllers/row/index.html +46 -46
  31. package/coverage/lcov-report/api/controllers/row/index.js.html +76 -49
  32. package/coverage/lcov-report/api/controllers/row/internal.js.html +144 -84
  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 +62 -20
  40. package/coverage/lcov-report/api/controllers/table/index.html +20 -20
  41. package/coverage/lcov-report/api/controllers/table/index.js.html +47 -44
  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 +18 -27
  52. package/coverage/lcov-report/api/index.html +10 -10
  53. package/coverage/lcov-report/api/index.js.html +37 -28
  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 +19 -109
  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 +18 -156
  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 +38 -32
  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 +16 -58
  72. package/coverage/lcov-report/api/routes/query.js.html +10 -10
  73. package/coverage/lcov-report/api/routes/role.js.html +15 -78
  74. package/coverage/lcov-report/api/routes/routing.js.html +8 -8
  75. package/coverage/lcov-report/api/routes/row.js.html +80 -14
  76. package/coverage/lcov-report/api/routes/screen.js.html +14 -95
  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 +17 -62
  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/utils/index.html +111 -0
  83. package/coverage/lcov-report/api/routes/utils/validators.js.html +737 -0
  84. package/coverage/lcov-report/api/routes/view.js.html +10 -10
  85. package/coverage/lcov-report/api/routes/webhook.js.html +14 -62
  86. package/coverage/lcov-report/automations/actions.js.html +24 -24
  87. package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
  88. package/coverage/lcov-report/automations/bullboard.js.html +16 -16
  89. package/coverage/lcov-report/automations/index.html +1 -1
  90. package/coverage/lcov-report/automations/index.js.html +7 -7
  91. package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
  92. package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
  93. package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
  94. package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
  95. package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
  96. package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
  97. package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
  98. package/coverage/lcov-report/automations/steps/filter.js.html +12 -9
  99. package/coverage/lcov-report/automations/steps/index.html +1 -1
  100. package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
  101. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
  102. package/coverage/lcov-report/automations/steps/queryRows.js.html +11 -11
  103. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
  104. package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
  105. package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
  106. package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
  107. package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
  108. package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
  109. package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
  110. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
  111. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  112. package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
  113. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
  114. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
  115. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
  116. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
  117. package/coverage/lcov-report/automations/triggers.js.html +26 -26
  118. package/coverage/lcov-report/automations/utils.js.html +35 -35
  119. package/coverage/lcov-report/constants/index.html +5 -5
  120. package/coverage/lcov-report/constants/index.js.html +40 -28
  121. package/coverage/lcov-report/constants/layouts.js.html +5 -5
  122. package/coverage/lcov-report/constants/screens.js.html +4 -4
  123. package/coverage/lcov-report/db/client.js.html +18 -18
  124. package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
  125. package/coverage/lcov-report/db/index.html +15 -15
  126. package/coverage/lcov-report/db/index.js.html +3 -3
  127. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +21 -21
  128. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  129. package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
  130. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +30 -30
  131. package/coverage/lcov-report/db/newid.js.html +4 -4
  132. package/coverage/lcov-report/db/utils.js.html +123 -87
  133. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  134. package/coverage/lcov-report/events/index.html +1 -1
  135. package/coverage/lcov-report/events/index.js.html +8 -8
  136. package/coverage/lcov-report/events/utils.js.html +18 -18
  137. package/coverage/lcov-report/index.html +91 -76
  138. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  139. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  140. package/coverage/lcov-report/middleware/appInfo.js.html +5 -5
  141. package/coverage/lcov-report/middleware/authorized.js.html +29 -29
  142. package/coverage/lcov-report/middleware/builder.js.html +16 -16
  143. package/coverage/lcov-report/middleware/currentapp.js.html +44 -44
  144. package/coverage/lcov-report/middleware/index.html +1 -1
  145. package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
  146. package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
  147. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  148. package/coverage/lcov-report/middleware/usageQuota.js.html +17 -17
  149. package/coverage/lcov-report/middleware/utils.js.html +4 -4
  150. package/coverage/lcov-report/threads/automation.js.html +1 -1
  151. package/coverage/lcov-report/threads/index.html +19 -19
  152. package/coverage/lcov-report/threads/index.js.html +10 -10
  153. package/coverage/lcov-report/threads/query.js.html +123 -39
  154. package/coverage/lcov-report/threads/utils.js.html +14 -14
  155. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  156. package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
  157. package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
  158. package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
  159. package/coverage/lcov-report/utilities/global.js.html +28 -28
  160. package/coverage/lcov-report/utilities/index.html +18 -18
  161. package/coverage/lcov-report/utilities/index.js.html +24 -24
  162. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -9
  163. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  164. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  165. package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
  166. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  167. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +60 -60
  168. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +13 -13
  169. package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
  170. package/coverage/lcov-report/utilities/security.js.html +8 -8
  171. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  172. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  173. package/coverage/lcov-report/utilities/usageQuota/index.js.html +12 -12
  174. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +8 -8
  175. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  176. package/coverage/lcov-report/utilities/users.js.html +5 -5
  177. package/coverage/lcov-report/utilities/workerRequests.js.html +200 -53
  178. package/coverage/lcov.info +3555 -3411
  179. package/dist/api/controllers/application.js +1 -0
  180. package/dist/api/controllers/public/applications.js +94 -0
  181. package/dist/api/controllers/public/mapping/applications.js +29 -0
  182. package/dist/api/controllers/public/mapping/index.js +11 -0
  183. package/dist/api/controllers/public/mapping/queries.js +36 -0
  184. package/dist/api/controllers/public/mapping/rows.js +24 -0
  185. package/dist/api/controllers/public/mapping/tables.js +23 -0
  186. package/dist/api/controllers/public/mapping/types.js +2 -0
  187. package/dist/api/controllers/public/mapping/users.js +29 -0
  188. package/dist/api/controllers/public/queries.js +38 -0
  189. package/dist/api/controllers/public/rows.js +97 -0
  190. package/dist/api/controllers/public/tables.js +75 -0
  191. package/dist/api/controllers/public/users.js +95 -0
  192. package/dist/api/controllers/public/utils.js +49 -0
  193. package/dist/api/controllers/row/external.js +18 -0
  194. package/dist/api/controllers/row/index.js +11 -0
  195. package/dist/api/controllers/row/internal.js +15 -1
  196. package/dist/api/controllers/table/external.js +8 -2
  197. package/dist/api/controllers/table/index.js +2 -1
  198. package/dist/api/controllers/webhook.js +3 -5
  199. package/dist/api/index.js +3 -1
  200. package/dist/api/routes/automation.js +3 -31
  201. package/dist/api/routes/datasource.js +3 -50
  202. package/dist/api/routes/index.js +2 -0
  203. package/dist/api/routes/permission.js +4 -14
  204. package/dist/api/routes/public/applications.js +141 -0
  205. package/dist/api/routes/public/index.js +101 -0
  206. package/dist/api/routes/public/middleware/mapper.js +94 -0
  207. package/dist/api/routes/public/queries.js +77 -0
  208. package/dist/api/routes/public/rows.js +229 -0
  209. package/dist/api/routes/public/tables.js +154 -0
  210. package/dist/api/routes/public/users.js +137 -0
  211. package/dist/api/routes/public/utils/Endpoint.js +36 -0
  212. package/dist/api/routes/role.js +3 -19
  213. package/dist/api/routes/row.js +18 -5
  214. package/dist/api/routes/screen.js +2 -23
  215. package/dist/api/routes/table.js +3 -17
  216. package/dist/api/routes/tests/utilities/index.js +23 -0
  217. package/dist/api/routes/utils/validators.js +200 -0
  218. package/dist/api/routes/webhook.js +2 -17
  219. package/dist/automations/steps/filter.js +2 -2
  220. package/dist/automations/steps/queryRows.js +1 -1
  221. package/dist/automations/utils.js +2 -2
  222. package/dist/constants/index.js +3 -0
  223. package/dist/db/utils.js +11 -0
  224. package/dist/definitions/openapi.js +6 -0
  225. package/dist/environment.js +1 -0
  226. package/dist/integrations/base/sql.js +16 -1
  227. package/dist/integrations/base/sqlTable.js +21 -9
  228. package/dist/integrations/googlesheets.js +3 -0
  229. package/dist/integrations/microsoftSqlServer.js +60 -43
  230. package/dist/integrations/mysql.js +3 -0
  231. package/dist/integrations/oracle.js +14 -19
  232. package/dist/integrations/postgres.js +34 -28
  233. package/dist/integrations/utils.js +32 -15
  234. package/dist/package.json +11 -7
  235. package/dist/tests/utilities/TestConfiguration.js +25 -8
  236. package/dist/threads/query.js +33 -8
  237. package/dist/tsconfig.tsbuildinfo +1 -1
  238. package/dist/utilities/workerRequests.js +50 -15
  239. package/package.json +12 -8
  240. package/scripts/integrations/mssql/data/setup.sql +18 -1
  241. package/scripts/integrations/oracle/oracle.md +2 -2
  242. package/scripts/integrations/postgres/init.sql +11 -3
  243. package/scripts/likeCypress.ts +9 -6
  244. package/specs/generate.js +94 -0
  245. package/specs/openapi.json +2232 -0
  246. package/specs/openapi.yaml +1538 -0
  247. package/specs/parameters.js +59 -0
  248. package/specs/resources/application.js +101 -0
  249. package/specs/resources/index.js +24 -0
  250. package/specs/resources/misc.js +12 -0
  251. package/specs/resources/query.js +189 -0
  252. package/specs/resources/row.js +125 -0
  253. package/specs/resources/table.js +191 -0
  254. package/specs/resources/user.js +126 -0
  255. package/specs/resources/utils/Resource.js +26 -0
  256. package/specs/resources/utils/index.js +11 -0
  257. package/specs/security.js +7 -0
  258. package/src/api/controllers/application.js +1 -0
  259. package/src/api/controllers/public/applications.ts +74 -0
  260. package/src/api/controllers/public/mapping/applications.ts +32 -0
  261. package/src/api/controllers/public/mapping/index.ts +13 -0
  262. package/src/api/controllers/public/mapping/queries.ts +39 -0
  263. package/src/api/controllers/public/mapping/rows.ts +31 -0
  264. package/src/api/controllers/public/mapping/tables.ts +26 -0
  265. package/src/api/controllers/public/mapping/types.ts +13 -0
  266. package/src/api/controllers/public/mapping/users.ts +32 -0
  267. package/src/api/controllers/public/queries.ts +20 -0
  268. package/src/api/controllers/public/rows.ts +77 -0
  269. package/src/api/controllers/public/tables.ts +56 -0
  270. package/src/api/controllers/public/users.ts +82 -0
  271. package/src/api/controllers/public/utils.ts +38 -0
  272. package/src/api/controllers/row/ExternalRequest.ts +1 -1
  273. package/src/api/controllers/row/external.js +21 -0
  274. package/src/api/controllers/row/index.js +9 -0
  275. package/src/api/controllers/row/internal.js +20 -0
  276. package/src/api/controllers/table/external.js +16 -2
  277. package/src/api/controllers/table/index.js +2 -1
  278. package/src/api/controllers/webhook.js +3 -6
  279. package/src/api/index.js +4 -1
  280. package/src/api/routes/automation.js +3 -33
  281. package/src/api/routes/datasource.js +6 -52
  282. package/src/api/routes/index.js +2 -0
  283. package/src/api/routes/permission.js +4 -18
  284. package/src/api/routes/public/applications.ts +156 -0
  285. package/src/api/routes/public/index.ts +118 -0
  286. package/src/api/routes/public/middleware/mapper.ts +81 -0
  287. package/src/api/routes/public/queries.ts +81 -0
  288. package/src/api/routes/public/rows.ts +242 -0
  289. package/src/api/routes/public/tables.ts +169 -0
  290. package/src/api/routes/public/tests/compare.spec.js +184 -0
  291. package/src/api/routes/public/users.ts +144 -0
  292. package/src/api/routes/public/utils/Endpoint.ts +51 -0
  293. package/src/api/routes/role.js +3 -24
  294. package/src/api/routes/row.js +24 -2
  295. package/src/api/routes/screen.js +2 -29
  296. package/src/api/routes/table.js +4 -19
  297. package/src/api/routes/tests/utilities/index.js +24 -0
  298. package/src/api/routes/utils/validators.js +219 -0
  299. package/src/api/routes/webhook.js +2 -18
  300. package/src/automations/steps/filter.js +3 -2
  301. package/src/automations/steps/queryRows.js +1 -1
  302. package/src/automations/utils.js +2 -2
  303. package/src/constants/index.js +4 -0
  304. package/src/db/utils.js +12 -0
  305. package/src/definitions/common.ts +4 -0
  306. package/src/definitions/datasource.ts +7 -0
  307. package/src/definitions/openapi.ts +943 -0
  308. package/src/environment.js +1 -0
  309. package/src/integrations/base/datasourcePlus.ts +3 -0
  310. package/src/integrations/base/sql.ts +16 -1
  311. package/src/integrations/base/sqlTable.ts +35 -13
  312. package/src/integrations/googlesheets.ts +5 -2
  313. package/src/integrations/microsoftSqlServer.ts +86 -61
  314. package/src/integrations/mysql.ts +4 -0
  315. package/src/integrations/oracle.ts +27 -35
  316. package/src/integrations/postgres.ts +33 -26
  317. package/src/integrations/utils.ts +43 -15
  318. package/src/tests/utilities/TestConfiguration.js +23 -2
  319. package/src/threads/query.js +37 -9
  320. package/src/utilities/workerRequests.js +65 -16
  321. package/builder/assets/index.22a39cc9.js +0 -1352
  322. package/scripts/proxy/generateProxyConfig.js +0 -70
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const queries_1 = __importDefault(require("../../controllers/public/queries"));
7
+ const Endpoint_1 = __importDefault(require("./utils/Endpoint"));
8
+ const validators_1 = require("../utils/validators");
9
+ const read = [], write = [];
10
+ /**
11
+ * @openapi
12
+ * /queries/{queryId}:
13
+ * post:
14
+ * summary: Execute a query
15
+ * description: Queries which have been created within a Budibase app can be executed using this,
16
+ * tags:
17
+ * - queries
18
+ * parameters:
19
+ * - $ref: '#/components/parameters/queryId'
20
+ * - $ref: '#/components/parameters/appId'
21
+ * requestBody:
22
+ * required: true
23
+ * content:
24
+ * application/json:
25
+ * schema:
26
+ * $ref: '#/components/schemas/executeQuery'
27
+ * responses:
28
+ * 200:
29
+ * description: Returns the result of the query execution.
30
+ * content:
31
+ * application/json:
32
+ * schema:
33
+ * $ref: '#/components/schemas/executeQueryOutput'
34
+ * examples:
35
+ * REST:
36
+ * $ref: '#/components/examples/restResponse'
37
+ * SQL:
38
+ * $ref: '#/components/examples/sqlResponse'
39
+ *
40
+ */
41
+ write.push(new Endpoint_1.default("post", "/queries/:queryId", queries_1.default.execute));
42
+ /**
43
+ * @openapi
44
+ * /queries/search:
45
+ * post:
46
+ * summary: Search for queries
47
+ * description: Based on query properties (currently only name) search for queries.
48
+ * tags:
49
+ * - queries
50
+ * parameters:
51
+ * - $ref: '#/components/parameters/appId'
52
+ * requestBody:
53
+ * required: true
54
+ * content:
55
+ * application/json:
56
+ * schema:
57
+ * $ref: '#/components/schemas/nameSearch'
58
+ * responses:
59
+ * 200:
60
+ * description: Returns the queries found based on the search parameters.
61
+ * content:
62
+ * application/json:
63
+ * schema:
64
+ * type: object
65
+ * required:
66
+ * - data
67
+ * properties:
68
+ * data:
69
+ * type: array
70
+ * items:
71
+ * $ref: '#/components/schemas/query'
72
+ * examples:
73
+ * queries:
74
+ * $ref: '#/components/examples/queries'
75
+ */
76
+ read.push(new Endpoint_1.default("post", "/queries/search", queries_1.default.search).addMiddleware(validators_1.nameValidator()));
77
+ exports.default = { read, write };
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const rows_1 = __importDefault(require("../../controllers/public/rows"));
7
+ const Endpoint_1 = __importDefault(require("./utils/Endpoint"));
8
+ const validators_1 = require("../utils/validators");
9
+ const read = [], write = [];
10
+ /**
11
+ * @openapi
12
+ * /tables/{tableId}/rows:
13
+ * post:
14
+ * summary: Create a row
15
+ * description: Creates a row within the specified table.
16
+ * tags:
17
+ * - rows
18
+ * parameters:
19
+ * - $ref: '#/components/parameters/tableId'
20
+ * - $ref: '#/components/parameters/appId'
21
+ * requestBody:
22
+ * required: true
23
+ * content:
24
+ * application/json:
25
+ * schema:
26
+ * $ref: '#/components/schemas/row'
27
+ * examples:
28
+ * row:
29
+ * $ref: '#/components/examples/inputRow'
30
+ * responses:
31
+ * 200:
32
+ * description: Returns the created row, including the ID which has been generated for it.
33
+ * This can be found in the Budibase portal, viewed under the developer information.
34
+ * content:
35
+ * application/json:
36
+ * schema:
37
+ * $ref: '#/components/schemas/rowOutput'
38
+ * examples:
39
+ * row:
40
+ * $ref: '#/components/examples/row'
41
+ */
42
+ write.push(new Endpoint_1.default("post", "/tables/:tableId/rows", rows_1.default.create));
43
+ /**
44
+ * @openapi
45
+ * /tables/{tableId}/rows/{rowId}:
46
+ * put:
47
+ * summary: Update a row
48
+ * description: Updates a row within the specified table.
49
+ * tags:
50
+ * - rows
51
+ * parameters:
52
+ * - $ref: '#/components/parameters/tableId'
53
+ * - $ref: '#/components/parameters/rowId'
54
+ * - $ref: '#/components/parameters/appId'
55
+ * requestBody:
56
+ * required: true
57
+ * content:
58
+ * application/json:
59
+ * schema:
60
+ * $ref: '#/components/schemas/row'
61
+ * examples:
62
+ * row:
63
+ * $ref: '#/components/examples/inputRow'
64
+ * responses:
65
+ * 200:
66
+ * description: Returns the created row, including the ID which has been generated for it.
67
+ * content:
68
+ * application/json:
69
+ * schema:
70
+ * $ref: '#/components/schemas/rowOutput'
71
+ * examples:
72
+ * row:
73
+ * $ref: '#/components/examples/row'
74
+ */
75
+ write.push(new Endpoint_1.default("put", "/tables/:tableId/rows/:rowId", rows_1.default.update));
76
+ /**
77
+ * @openapi
78
+ * /tables/{tableId}/rows/{rowId}:
79
+ * delete:
80
+ * summary: Delete a row
81
+ * description: Deletes a row within the specified table.
82
+ * tags:
83
+ * - rows
84
+ * parameters:
85
+ * - $ref: '#/components/parameters/tableId'
86
+ * - $ref: '#/components/parameters/rowId'
87
+ * - $ref: '#/components/parameters/appId'
88
+ * responses:
89
+ * 200:
90
+ * description: Returns the deleted row, including the ID which has been generated for it.
91
+ * content:
92
+ * application/json:
93
+ * schema:
94
+ * $ref: '#/components/schemas/rowOutput'
95
+ * examples:
96
+ * row:
97
+ * $ref: '#/components/examples/row'
98
+ */
99
+ write.push(new Endpoint_1.default("delete", "/tables/:tableId/rows/:rowId", rows_1.default.destroy));
100
+ /**
101
+ * @openapi
102
+ * /tables/{tableId}/rows/{rowId}:
103
+ * get:
104
+ * summary: Retrieve a row
105
+ * description: This gets a single row, it will be enriched with the full related rows, rather than
106
+ * the squashed "primaryDisplay" format returned by the search endpoint.
107
+ * tags:
108
+ * - rows
109
+ * parameters:
110
+ * - $ref: '#/components/parameters/tableId'
111
+ * - $ref: '#/components/parameters/rowId'
112
+ * - $ref: '#/components/parameters/appId'
113
+ * responses:
114
+ * 200:
115
+ * description: Returns the retrieved row.
116
+ * content:
117
+ * application/json:
118
+ * schema:
119
+ * $ref: '#/components/schemas/rowOutput'
120
+ * examples:
121
+ * enrichedRow:
122
+ * $ref: '#/components/examples/enrichedRow'
123
+ */
124
+ read.push(new Endpoint_1.default("get", "/tables/:tableId/rows/:rowId", rows_1.default.read));
125
+ /**
126
+ * @openapi
127
+ * /tables/{tableId}/rows/search:
128
+ * post:
129
+ * summary: Search for rows
130
+ * tags:
131
+ * - rows
132
+ * parameters:
133
+ * - $ref: '#/components/parameters/tableId'
134
+ * - $ref: '#/components/parameters/appId'
135
+ * requestBody:
136
+ * required: true
137
+ * content:
138
+ * application/json:
139
+ * schema:
140
+ * type: object
141
+ * required:
142
+ * - query
143
+ * properties:
144
+ * query:
145
+ * type: object
146
+ * properties:
147
+ * string:
148
+ * type: object
149
+ * example:
150
+ * columnName1: value
151
+ * columnName2: value
152
+ * description: A map of field name to the string to search for,
153
+ * this will look for rows that have a value starting with the
154
+ * string value.
155
+ * additionalProperties:
156
+ * type: string
157
+ * description: The value to search for in the column.
158
+ * fuzzy:
159
+ * type: object
160
+ * description: A fuzzy search, only supported by internal tables.
161
+ * range:
162
+ * type: object
163
+ * description: Searches within a range, the format of this must be
164
+ * columnName -> [low, high].
165
+ * example:
166
+ * columnName1: [10, 20]
167
+ * equal:
168
+ * type: object
169
+ * description: Searches for rows that have a column value that is
170
+ * exactly the value set.
171
+ * notEqual:
172
+ * type: object
173
+ * description: Searches for any row which does not contain the specified
174
+ * column value.
175
+ * empty:
176
+ * type: object
177
+ * description: Searches for rows which do not contain the specified column.
178
+ * The object should simply contain keys of the column names, these
179
+ * can map to any value.
180
+ * example:
181
+ * columnName1: ""
182
+ * notEmpty:
183
+ * type: object
184
+ * description: Searches for rows which have the specified column.
185
+ * oneOf:
186
+ * type: object
187
+ * description: Searches for rows which have a column value that is any
188
+ * of the specified values. The format of this must be columnName -> [value1, value2].
189
+ * paginate:
190
+ * type: boolean
191
+ * description: Enables pagination, by default this is disabled.
192
+ * bookmark:
193
+ * oneOf:
194
+ * - type: string
195
+ * - type: integer
196
+ * description: If retrieving another page, the bookmark from the previous request must be supplied.
197
+ * limit:
198
+ * type: integer
199
+ * description: The maximum number of rows to return, useful when paginating, for internal tables this
200
+ * will be limited to 1000, for SQL tables it will be 5000.
201
+ * sort:
202
+ * type: object
203
+ * description: A set of parameters describing the sort behaviour of the search.
204
+ * properties:
205
+ * order:
206
+ * type: string
207
+ * enum: [ascending, descending]
208
+ * description: The order of the sort, by default this is ascending.
209
+ * column:
210
+ * type: string
211
+ * description: The name of the column by which the rows will be sorted.
212
+ * type:
213
+ * type: string
214
+ * enum: [string, number]
215
+ * description: Defines whether the column should be treated as a string
216
+ * or as numbers when sorting.
217
+ * responses:
218
+ * 200:
219
+ * description: The response will contain an array of rows that match the search parameters.
220
+ * content:
221
+ * application/json:
222
+ * schema:
223
+ * $ref: '#/components/schemas/searchOutput'
224
+ * examples:
225
+ * search:
226
+ * $ref: '#/components/examples/rows'
227
+ */
228
+ read.push(new Endpoint_1.default("post", "/tables/:tableId/rows/search", rows_1.default.search).addMiddleware(validators_1.externalSearchValidator()));
229
+ exports.default = { read, write };
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const tables_1 = __importDefault(require("../../controllers/public/tables"));
7
+ const Endpoint_1 = __importDefault(require("./utils/Endpoint"));
8
+ const validators_1 = require("../utils/validators");
9
+ const read = [], write = [];
10
+ /**
11
+ * @openapi
12
+ * /tables:
13
+ * post:
14
+ * summary: Create a table
15
+ * description: Create a table, this could be internal or external.
16
+ * tags:
17
+ * - tables
18
+ * parameters:
19
+ * - $ref: '#/components/parameters/appId'
20
+ * requestBody:
21
+ * content:
22
+ * application/json:
23
+ * schema:
24
+ * $ref: '#/components/schemas/table'
25
+ * examples:
26
+ * table:
27
+ * $ref: '#/components/examples/table'
28
+ * responses:
29
+ * 200:
30
+ * description: Returns the created table, including the ID which has been generated for it. This can be
31
+ * internal or external data sources.
32
+ * content:
33
+ * application/json:
34
+ * schema:
35
+ * $ref: '#/components/schemas/tableOutput'
36
+ * examples:
37
+ * table:
38
+ * $ref: '#/components/examples/table'
39
+ */
40
+ write.push(new Endpoint_1.default("post", "/tables", tables_1.default.create).addMiddleware(validators_1.tableValidator()));
41
+ /**
42
+ * @openapi
43
+ * /tables/{tableId}:
44
+ * put:
45
+ * summary: Update a table
46
+ * description: Update a table, this could be internal or external.
47
+ * tags:
48
+ * - tables
49
+ * parameters:
50
+ * - $ref: '#/components/parameters/tableId'
51
+ * - $ref: '#/components/parameters/appId'
52
+ * requestBody:
53
+ * content:
54
+ * application/json:
55
+ * schema:
56
+ * $ref: '#/components/schemas/table'
57
+ * examples:
58
+ * table:
59
+ * $ref: '#/components/examples/table'
60
+ * responses:
61
+ * 200:
62
+ * description: Returns the updated table.
63
+ * content:
64
+ * application/json:
65
+ * schema:
66
+ * $ref: '#/components/schemas/tableOutput'
67
+ * examples:
68
+ * table:
69
+ * $ref: '#/components/examples/table'
70
+ */
71
+ write.push(new Endpoint_1.default("put", "/tables/:tableId", tables_1.default.update).addMiddleware(validators_1.tableValidator()));
72
+ /**
73
+ * @openapi
74
+ * /tables/{tableId}:
75
+ * delete:
76
+ * summary: Delete a table
77
+ * description: Delete a table, this could be internal or external.
78
+ * tags:
79
+ * - tables
80
+ * parameters:
81
+ * - $ref: '#/components/parameters/tableId'
82
+ * - $ref: '#/components/parameters/appId'
83
+ * responses:
84
+ * 200:
85
+ * description: Returns the deleted table.
86
+ * content:
87
+ * application/json:
88
+ * schema:
89
+ * $ref: '#/components/schemas/tableOutput'
90
+ * examples:
91
+ * table:
92
+ * $ref: '#/components/examples/table'
93
+ */
94
+ write.push(new Endpoint_1.default("delete", "/tables/:tableId", tables_1.default.destroy));
95
+ /**
96
+ * @openapi
97
+ * /tables/{tableId}:
98
+ * get:
99
+ * summary: Retrieve a table
100
+ * description: Lookup a table, this could be internal or external.
101
+ * tags:
102
+ * - tables
103
+ * parameters:
104
+ * - $ref: '#/components/parameters/tableId'
105
+ * - $ref: '#/components/parameters/appId'
106
+ * responses:
107
+ * 200:
108
+ * description: Returns the retrieved table.
109
+ * content:
110
+ * application/json:
111
+ * schema:
112
+ * $ref: '#/components/schemas/tableOutput'
113
+ * examples:
114
+ * table:
115
+ * $ref: '#/components/examples/table'
116
+ */
117
+ read.push(new Endpoint_1.default("get", "/tables/:tableId", tables_1.default.read));
118
+ /**
119
+ * @openapi
120
+ * /tables/search:
121
+ * post:
122
+ * summary: Search for tables
123
+ * description: Based on table properties (currently only name) search for tables. This could be
124
+ * an internal or an external table.
125
+ * tags:
126
+ * - tables
127
+ * parameters:
128
+ * - $ref: '#/components/parameters/appId'
129
+ * requestBody:
130
+ * required: true
131
+ * content:
132
+ * application/json:
133
+ * schema:
134
+ * $ref: '#/components/schemas/nameSearch'
135
+ * responses:
136
+ * 200:
137
+ * description: Returns the found tables, based on the search parameters.
138
+ * content:
139
+ * application/json:
140
+ * schema:
141
+ * type: object
142
+ * required:
143
+ * - data
144
+ * properties:
145
+ * data:
146
+ * type: array
147
+ * items:
148
+ * $ref: '#/components/schemas/table'
149
+ * examples:
150
+ * tables:
151
+ * $ref: '#/components/examples/tables'
152
+ */
153
+ read.push(new Endpoint_1.default("post", "/tables/search", tables_1.default.search).addMiddleware(validators_1.nameValidator()));
154
+ exports.default = { read, write };
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const users_1 = __importDefault(require("../../controllers/public/users"));
7
+ const Endpoint_1 = __importDefault(require("./utils/Endpoint"));
8
+ const validators_1 = require("../utils/validators");
9
+ const read = [], write = [];
10
+ /**
11
+ * @openapi
12
+ * /users:
13
+ * post:
14
+ * summary: Create a user
15
+ * tags:
16
+ * - users
17
+ * requestBody:
18
+ * required: true
19
+ * content:
20
+ * application/json:
21
+ * schema:
22
+ * $ref: '#/components/schemas/user'
23
+ * responses:
24
+ * 200:
25
+ * description: Returns the created user.
26
+ * content:
27
+ * application/json:
28
+ * schema:
29
+ * $ref: '#/components/schemas/userOutput'
30
+ * examples:
31
+ * user:
32
+ * $ref: '#/components/examples/user'
33
+ */
34
+ write.push(new Endpoint_1.default("post", "/users", users_1.default.create));
35
+ /**
36
+ * @openapi
37
+ * /users/{userId}:
38
+ * put:
39
+ * summary: Update a user
40
+ * tags:
41
+ * - users
42
+ * parameters:
43
+ * - $ref: '#/components/parameters/userId'
44
+ * requestBody:
45
+ * required: true
46
+ * content:
47
+ * application/json:
48
+ * schema:
49
+ * $ref: '#/components/schemas/user'
50
+ * responses:
51
+ * 200:
52
+ * description: Returns the updated user.
53
+ * content:
54
+ * application/json:
55
+ * schema:
56
+ * $ref: '#/components/schemas/userOutput'
57
+ * examples:
58
+ * user:
59
+ * $ref: '#/components/examples/user'
60
+ */
61
+ write.push(new Endpoint_1.default("put", "/users/:userId", users_1.default.update));
62
+ /**
63
+ * @openapi
64
+ * /users/{userId}:
65
+ * delete:
66
+ * summary: Delete a user
67
+ * tags:
68
+ * - users
69
+ * parameters:
70
+ * - $ref: '#/components/parameters/userId'
71
+ * responses:
72
+ * 200:
73
+ * description: Returns the deleted user.
74
+ * content:
75
+ * application/json:
76
+ * schema:
77
+ * $ref: '#/components/schemas/userOutput'
78
+ * examples:
79
+ * user:
80
+ * $ref: '#/components/examples/user'
81
+ */
82
+ write.push(new Endpoint_1.default("delete", "/users/:userId", users_1.default.destroy));
83
+ /**
84
+ * @openapi
85
+ * /users/{userId}:
86
+ * get:
87
+ * summary: Retrieve a user
88
+ * tags:
89
+ * - users
90
+ * parameters:
91
+ * - $ref: '#/components/parameters/userId'
92
+ * responses:
93
+ * 200:
94
+ * description: Returns the retrieved user.
95
+ * content:
96
+ * application/json:
97
+ * schema:
98
+ * $ref: '#/components/schemas/userOutput'
99
+ * examples:
100
+ * user:
101
+ * $ref: '#/components/examples/user'
102
+ */
103
+ read.push(new Endpoint_1.default("get", "/users/:userId", users_1.default.read));
104
+ /**
105
+ * @openapi
106
+ * /users/search:
107
+ * post:
108
+ * summary: Search for users
109
+ * description: Based on user properties (currently only name) search for users.
110
+ * tags:
111
+ * - users
112
+ * requestBody:
113
+ * required: true
114
+ * content:
115
+ * application/json:
116
+ * schema:
117
+ * $ref: '#/components/schemas/nameSearch'
118
+ * responses:
119
+ * 200:
120
+ * description: Returns the found users based on search parameters.
121
+ * content:
122
+ * application/json:
123
+ * schema:
124
+ * type: object
125
+ * required:
126
+ * - data
127
+ * properties:
128
+ * data:
129
+ * type: array
130
+ * items:
131
+ * $ref: '#/components/schemas/user'
132
+ * examples:
133
+ * users:
134
+ * $ref: '#/components/examples/users'
135
+ */
136
+ read.push(new Endpoint_1.default("post", "/users/search", users_1.default.search).addMiddleware(validators_1.nameValidator()));
137
+ exports.default = { read, write };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Endpoint {
4
+ constructor(method, url, controller) {
5
+ this.method = method;
6
+ this.url = url;
7
+ this.controller = controller;
8
+ this.middlewares = [];
9
+ this.outputMiddlewares = [];
10
+ }
11
+ addMiddleware(middleware) {
12
+ this.middlewares.push(middleware);
13
+ return this;
14
+ }
15
+ addOutputMiddleware(middleware) {
16
+ this.outputMiddlewares.push(middleware);
17
+ return this;
18
+ }
19
+ apply(router) {
20
+ const method = this.method, url = this.url;
21
+ const middlewares = this.middlewares, controller = this.controller, outputMiddlewares = this.outputMiddlewares;
22
+ // need a function to do nothing to stop the execution at the end
23
+ // middlewares are circular so if they always keep calling next, it'll just keep looping
24
+ const complete = () => { };
25
+ const params = [
26
+ url,
27
+ ...middlewares,
28
+ controller,
29
+ ...outputMiddlewares,
30
+ complete,
31
+ ];
32
+ // @ts-ignore
33
+ router[method](...params);
34
+ }
35
+ }
36
+ exports.default = Endpoint;
@@ -2,27 +2,11 @@
2
2
  const Router = require("@koa/router");
3
3
  const controller = require("../controllers/role");
4
4
  const authorized = require("../../middleware/authorized");
5
- const Joi = require("joi");
6
- const joiValidator = require("../../middleware/joi-validator");
7
- const { BUILTIN_PERMISSION_IDS, BUILDER, PermissionLevels, } = require("@budibase/backend-core/permissions");
5
+ const { BUILDER } = require("@budibase/backend-core/permissions");
6
+ const { roleValidator } = require("./utils/validators");
8
7
  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
- }
24
8
  router
25
- .post("/api/roles", authorized(BUILDER), generateValidator(), controller.save)
9
+ .post("/api/roles", authorized(BUILDER), roleValidator(), controller.save)
26
10
  .get("/api/roles", authorized(BUILDER), controller.fetch)
27
11
  .get("/api/roles/:roleId", authorized(BUILDER), controller.find)
28
12
  .delete("/api/roles/:roleId/:rev", authorized(BUILDER), controller.destroy);