@budibase/server 1.0.78 → 1.0.79-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/__mocks__/node-fetch.ts +1 -0
  2. package/builder/assets/index.1a081633.js +1288 -0
  3. package/builder/assets/{index.c8d1e8f0.css → index.c57242d4.css} +2 -2
  4. package/builder/assets/{vendor.20f80cec.js → vendor.a7c6ad0a.js} +190 -216
  5. package/builder/index.html +3 -3
  6. package/coverage/clover.xml +2399 -2336
  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 +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 +94 -82
  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 +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 +17 -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 +89 -74
  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 +3323 -3224
  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/internal.js +4 -1
  194. package/dist/api/controllers/table/index.js +2 -1
  195. package/dist/api/controllers/webhook.js +3 -5
  196. package/dist/api/index.js +3 -1
  197. package/dist/api/routes/automation.js +3 -31
  198. package/dist/api/routes/datasource.js +3 -50
  199. package/dist/api/routes/index.js +2 -0
  200. package/dist/api/routes/permission.js +4 -14
  201. package/dist/api/routes/public/applications.js +141 -0
  202. package/dist/api/routes/public/index.js +68 -0
  203. package/dist/api/routes/public/middleware/mapper.js +94 -0
  204. package/dist/api/routes/public/queries.js +77 -0
  205. package/dist/api/routes/public/rows.js +229 -0
  206. package/dist/api/routes/public/tables.js +154 -0
  207. package/dist/api/routes/public/users.js +137 -0
  208. package/dist/api/routes/public/utils/Endpoint.js +36 -0
  209. package/dist/api/routes/role.js +3 -19
  210. package/dist/api/routes/row.js +3 -4
  211. package/dist/api/routes/screen.js +2 -23
  212. package/dist/api/routes/table.js +3 -17
  213. package/dist/api/routes/tests/utilities/index.js +23 -0
  214. package/dist/api/routes/utils/validators.js +200 -0
  215. package/dist/api/routes/webhook.js +2 -17
  216. package/dist/automations/steps/filter.js +2 -2
  217. package/dist/automations/steps/queryRows.js +1 -1
  218. package/dist/automations/utils.js +2 -2
  219. package/dist/constants/index.js +3 -0
  220. package/dist/db/utils.js +11 -0
  221. package/dist/definitions/openapi.js +6 -0
  222. package/dist/integrations/googlesheets.js +3 -0
  223. package/dist/integrations/microsoftSqlServer.js +35 -29
  224. package/dist/integrations/mysql.js +30 -26
  225. package/dist/integrations/oracle.js +14 -19
  226. package/dist/integrations/postgres.js +34 -28
  227. package/dist/package.json +8 -7
  228. package/dist/tests/utilities/TestConfiguration.js +25 -8
  229. package/dist/threads/query.js +33 -8
  230. package/dist/tsconfig.tsbuildinfo +1 -1
  231. package/dist/utilities/workerRequests.js +50 -15
  232. package/package.json +9 -8
  233. package/scripts/integrations/oracle/oracle.md +2 -2
  234. package/scripts/integrations/postgres/init.sql +5 -3
  235. package/scripts/likeCypress.ts +9 -6
  236. package/specs/generate.js +83 -0
  237. package/specs/openapi.json +2222 -0
  238. package/specs/openapi.yaml +1530 -0
  239. package/specs/parameters.js +59 -0
  240. package/specs/resources/application.js +101 -0
  241. package/specs/resources/index.js +24 -0
  242. package/specs/resources/misc.js +12 -0
  243. package/specs/resources/query.js +189 -0
  244. package/specs/resources/row.js +125 -0
  245. package/specs/resources/table.js +191 -0
  246. package/specs/resources/user.js +126 -0
  247. package/specs/resources/utils/Resource.js +26 -0
  248. package/specs/resources/utils/index.js +11 -0
  249. package/specs/security.js +7 -0
  250. package/src/api/controllers/application.js +1 -0
  251. package/src/api/controllers/public/applications.ts +74 -0
  252. package/src/api/controllers/public/mapping/applications.ts +32 -0
  253. package/src/api/controllers/public/mapping/index.ts +13 -0
  254. package/src/api/controllers/public/mapping/queries.ts +39 -0
  255. package/src/api/controllers/public/mapping/rows.ts +31 -0
  256. package/src/api/controllers/public/mapping/tables.ts +26 -0
  257. package/src/api/controllers/public/mapping/types.ts +13 -0
  258. package/src/api/controllers/public/mapping/users.ts +32 -0
  259. package/src/api/controllers/public/queries.ts +20 -0
  260. package/src/api/controllers/public/rows.ts +77 -0
  261. package/src/api/controllers/public/tables.ts +56 -0
  262. package/src/api/controllers/public/users.ts +82 -0
  263. package/src/api/controllers/public/utils.ts +38 -0
  264. package/src/api/controllers/row/internal.js +4 -0
  265. package/src/api/controllers/table/index.js +2 -1
  266. package/src/api/controllers/webhook.js +3 -6
  267. package/src/api/index.js +4 -1
  268. package/src/api/routes/automation.js +3 -33
  269. package/src/api/routes/datasource.js +6 -52
  270. package/src/api/routes/index.js +2 -0
  271. package/src/api/routes/permission.js +4 -18
  272. package/src/api/routes/public/applications.ts +156 -0
  273. package/src/api/routes/public/index.ts +82 -0
  274. package/src/api/routes/public/middleware/mapper.ts +81 -0
  275. package/src/api/routes/public/queries.ts +81 -0
  276. package/src/api/routes/public/rows.ts +242 -0
  277. package/src/api/routes/public/tables.ts +169 -0
  278. package/src/api/routes/public/tests/compare.spec.js +184 -0
  279. package/src/api/routes/public/users.ts +144 -0
  280. package/src/api/routes/public/utils/Endpoint.ts +51 -0
  281. package/src/api/routes/role.js +3 -24
  282. package/src/api/routes/row.js +3 -2
  283. package/src/api/routes/screen.js +2 -29
  284. package/src/api/routes/table.js +4 -19
  285. package/src/api/routes/tests/utilities/index.js +24 -0
  286. package/src/api/routes/utils/validators.js +219 -0
  287. package/src/api/routes/webhook.js +2 -18
  288. package/src/automations/steps/filter.js +3 -2
  289. package/src/automations/steps/queryRows.js +1 -1
  290. package/src/automations/utils.js +2 -2
  291. package/src/constants/index.js +4 -0
  292. package/src/db/utils.js +12 -0
  293. package/src/definitions/common.ts +4 -0
  294. package/src/definitions/openapi.ts +943 -0
  295. package/src/integrations/base/datasourcePlus.ts +3 -0
  296. package/src/integrations/googlesheets.ts +5 -2
  297. package/src/integrations/microsoftSqlServer.ts +38 -33
  298. package/src/integrations/mysql.ts +38 -36
  299. package/src/integrations/oracle.ts +27 -35
  300. package/src/integrations/postgres.ts +33 -26
  301. package/src/tests/utilities/TestConfiguration.js +23 -2
  302. package/src/threads/query.js +37 -9
  303. package/src/utilities/workerRequests.js +65 -16
  304. package/builder/assets/index.ab059cf2.js +0 -1352
  305. package/scripts/proxy/generateProxyConfig.js +0 -70
@@ -0,0 +1,81 @@
1
+ import controller from "../../controllers/public/queries"
2
+ import Endpoint from "./utils/Endpoint"
3
+ import { nameValidator } from "../utils/validators"
4
+
5
+ const read = [],
6
+ write = []
7
+
8
+ /**
9
+ * @openapi
10
+ * /queries/{queryId}:
11
+ * post:
12
+ * summary: Execute a query
13
+ * description: Queries which have been created within a Budibase app can be executed using this,
14
+ * tags:
15
+ * - queries
16
+ * parameters:
17
+ * - $ref: '#/components/parameters/queryId'
18
+ * - $ref: '#/components/parameters/appId'
19
+ * requestBody:
20
+ * required: true
21
+ * content:
22
+ * application/json:
23
+ * schema:
24
+ * $ref: '#/components/schemas/executeQuery'
25
+ * responses:
26
+ * 200:
27
+ * description: Returns the result of the query execution.
28
+ * content:
29
+ * application/json:
30
+ * schema:
31
+ * $ref: '#/components/schemas/executeQueryOutput'
32
+ * examples:
33
+ * REST:
34
+ * $ref: '#/components/examples/restResponse'
35
+ * SQL:
36
+ * $ref: '#/components/examples/sqlResponse'
37
+ *
38
+ */
39
+ write.push(new Endpoint("post", "/queries/:queryId", controller.execute))
40
+
41
+ /**
42
+ * @openapi
43
+ * /queries/search:
44
+ * post:
45
+ * summary: Search for queries
46
+ * description: Based on query properties (currently only name) search for queries.
47
+ * tags:
48
+ * - queries
49
+ * parameters:
50
+ * - $ref: '#/components/parameters/appId'
51
+ * requestBody:
52
+ * required: true
53
+ * content:
54
+ * application/json:
55
+ * schema:
56
+ * $ref: '#/components/schemas/nameSearch'
57
+ * responses:
58
+ * 200:
59
+ * description: Returns the queries found based on the search parameters.
60
+ * content:
61
+ * application/json:
62
+ * schema:
63
+ * type: object
64
+ * required:
65
+ * - data
66
+ * properties:
67
+ * data:
68
+ * type: array
69
+ * items:
70
+ * $ref: '#/components/schemas/query'
71
+ * examples:
72
+ * queries:
73
+ * $ref: '#/components/examples/queries'
74
+ */
75
+ read.push(
76
+ new Endpoint("post", "/queries/search", controller.search).addMiddleware(
77
+ nameValidator()
78
+ )
79
+ )
80
+
81
+ export default { read, write }
@@ -0,0 +1,242 @@
1
+ import controller from "../../controllers/public/rows"
2
+ import Endpoint from "./utils/Endpoint"
3
+ import { externalSearchValidator } from "../utils/validators"
4
+
5
+ const read = [],
6
+ write = []
7
+
8
+ /**
9
+ * @openapi
10
+ * /tables/{tableId}/rows:
11
+ * post:
12
+ * summary: Create a row
13
+ * description: Creates a row within the specified table.
14
+ * tags:
15
+ * - rows
16
+ * parameters:
17
+ * - $ref: '#/components/parameters/tableId'
18
+ * - $ref: '#/components/parameters/appId'
19
+ * requestBody:
20
+ * required: true
21
+ * content:
22
+ * application/json:
23
+ * schema:
24
+ * $ref: '#/components/schemas/row'
25
+ * examples:
26
+ * row:
27
+ * $ref: '#/components/examples/inputRow'
28
+ * responses:
29
+ * 200:
30
+ * description: Returns the created row, including the ID which has been generated for it.
31
+ * This can be found in the Budibase portal, viewed under the developer information.
32
+ * content:
33
+ * application/json:
34
+ * schema:
35
+ * $ref: '#/components/schemas/rowOutput'
36
+ * examples:
37
+ * row:
38
+ * $ref: '#/components/examples/row'
39
+ */
40
+ write.push(new Endpoint("post", "/tables/:tableId/rows", controller.create))
41
+
42
+ /**
43
+ * @openapi
44
+ * /tables/{tableId}/rows/{rowId}:
45
+ * put:
46
+ * summary: Update a row
47
+ * description: Updates a row within the specified table.
48
+ * tags:
49
+ * - rows
50
+ * parameters:
51
+ * - $ref: '#/components/parameters/tableId'
52
+ * - $ref: '#/components/parameters/rowId'
53
+ * - $ref: '#/components/parameters/appId'
54
+ * requestBody:
55
+ * required: true
56
+ * content:
57
+ * application/json:
58
+ * schema:
59
+ * $ref: '#/components/schemas/row'
60
+ * examples:
61
+ * row:
62
+ * $ref: '#/components/examples/inputRow'
63
+ * responses:
64
+ * 200:
65
+ * description: Returns the created row, including the ID which has been generated for it.
66
+ * content:
67
+ * application/json:
68
+ * schema:
69
+ * $ref: '#/components/schemas/rowOutput'
70
+ * examples:
71
+ * row:
72
+ * $ref: '#/components/examples/row'
73
+ */
74
+ write.push(
75
+ new Endpoint("put", "/tables/:tableId/rows/:rowId", controller.update)
76
+ )
77
+
78
+ /**
79
+ * @openapi
80
+ * /tables/{tableId}/rows/{rowId}:
81
+ * delete:
82
+ * summary: Delete a row
83
+ * description: Deletes a row within the specified table.
84
+ * tags:
85
+ * - rows
86
+ * parameters:
87
+ * - $ref: '#/components/parameters/tableId'
88
+ * - $ref: '#/components/parameters/rowId'
89
+ * - $ref: '#/components/parameters/appId'
90
+ * responses:
91
+ * 200:
92
+ * description: Returns the deleted row, including the ID which has been generated for it.
93
+ * content:
94
+ * application/json:
95
+ * schema:
96
+ * $ref: '#/components/schemas/rowOutput'
97
+ * examples:
98
+ * row:
99
+ * $ref: '#/components/examples/row'
100
+ */
101
+ write.push(
102
+ new Endpoint("delete", "/tables/:tableId/rows/:rowId", controller.destroy)
103
+ )
104
+
105
+ /**
106
+ * @openapi
107
+ * /tables/{tableId}/rows/{rowId}:
108
+ * get:
109
+ * summary: Retrieve a row
110
+ * description: This gets a single row, it will be enriched with the full related rows, rather than
111
+ * the squashed "primaryDisplay" format returned by the search endpoint.
112
+ * tags:
113
+ * - rows
114
+ * parameters:
115
+ * - $ref: '#/components/parameters/tableId'
116
+ * - $ref: '#/components/parameters/rowId'
117
+ * - $ref: '#/components/parameters/appId'
118
+ * responses:
119
+ * 200:
120
+ * description: Returns the retrieved row.
121
+ * content:
122
+ * application/json:
123
+ * schema:
124
+ * $ref: '#/components/schemas/rowOutput'
125
+ * examples:
126
+ * enrichedRow:
127
+ * $ref: '#/components/examples/enrichedRow'
128
+ */
129
+ read.push(new Endpoint("get", "/tables/:tableId/rows/:rowId", controller.read))
130
+
131
+ /**
132
+ * @openapi
133
+ * /tables/{tableId}/rows/search:
134
+ * post:
135
+ * summary: Search for rows
136
+ * tags:
137
+ * - rows
138
+ * parameters:
139
+ * - $ref: '#/components/parameters/tableId'
140
+ * - $ref: '#/components/parameters/appId'
141
+ * requestBody:
142
+ * required: true
143
+ * content:
144
+ * application/json:
145
+ * schema:
146
+ * type: object
147
+ * required:
148
+ * - query
149
+ * properties:
150
+ * query:
151
+ * type: object
152
+ * properties:
153
+ * string:
154
+ * type: object
155
+ * example:
156
+ * columnName1: value
157
+ * columnName2: value
158
+ * description: A map of field name to the string to search for,
159
+ * this will look for rows that have a value starting with the
160
+ * string value.
161
+ * additionalProperties:
162
+ * type: string
163
+ * description: The value to search for in the column.
164
+ * fuzzy:
165
+ * type: object
166
+ * description: A fuzzy search, only supported by internal tables.
167
+ * range:
168
+ * type: object
169
+ * description: Searches within a range, the format of this must be
170
+ * columnName -> [low, high].
171
+ * example:
172
+ * columnName1: [10, 20]
173
+ * equal:
174
+ * type: object
175
+ * description: Searches for rows that have a column value that is
176
+ * exactly the value set.
177
+ * notEqual:
178
+ * type: object
179
+ * description: Searches for any row which does not contain the specified
180
+ * column value.
181
+ * empty:
182
+ * type: object
183
+ * description: Searches for rows which do not contain the specified column.
184
+ * The object should simply contain keys of the column names, these
185
+ * can map to any value.
186
+ * example:
187
+ * columnName1: ""
188
+ * notEmpty:
189
+ * type: object
190
+ * description: Searches for rows which have the specified column.
191
+ * oneOf:
192
+ * type: object
193
+ * description: Searches for rows which have a column value that is any
194
+ * of the specified values. The format of this must be columnName -> [value1, value2].
195
+ * paginate:
196
+ * type: boolean
197
+ * description: Enables pagination, by default this is disabled.
198
+ * bookmark:
199
+ * oneOf:
200
+ * - type: string
201
+ * - type: integer
202
+ * description: If retrieving another page, the bookmark from the previous request must be supplied.
203
+ * limit:
204
+ * type: integer
205
+ * description: The maximum number of rows to return, useful when paginating, for internal tables this
206
+ * will be limited to 1000, for SQL tables it will be 5000.
207
+ * sort:
208
+ * type: object
209
+ * description: A set of parameters describing the sort behaviour of the search.
210
+ * properties:
211
+ * order:
212
+ * type: string
213
+ * enum: [ascending, descending]
214
+ * description: The order of the sort, by default this is ascending.
215
+ * column:
216
+ * type: string
217
+ * description: The name of the column by which the rows will be sorted.
218
+ * type:
219
+ * type: string
220
+ * enum: [string, number]
221
+ * description: Defines whether the column should be treated as a string
222
+ * or as numbers when sorting.
223
+ * responses:
224
+ * 200:
225
+ * description: The response will contain an array of rows that match the search parameters.
226
+ * content:
227
+ * application/json:
228
+ * schema:
229
+ * $ref: '#/components/schemas/searchOutput'
230
+ * examples:
231
+ * search:
232
+ * $ref: '#/components/examples/rows'
233
+ */
234
+ read.push(
235
+ new Endpoint(
236
+ "post",
237
+ "/tables/:tableId/rows/search",
238
+ controller.search
239
+ ).addMiddleware(externalSearchValidator())
240
+ )
241
+
242
+ export default { read, write }
@@ -0,0 +1,169 @@
1
+ import controller from "../../controllers/public/tables"
2
+ import Endpoint from "./utils/Endpoint"
3
+ import { tableValidator, nameValidator } from "../utils/validators"
4
+
5
+ const read = [],
6
+ write = []
7
+
8
+ /**
9
+ * @openapi
10
+ * /tables:
11
+ * post:
12
+ * summary: Create a table
13
+ * description: Create a table, this could be internal or external.
14
+ * tags:
15
+ * - tables
16
+ * parameters:
17
+ * - $ref: '#/components/parameters/appId'
18
+ * requestBody:
19
+ * content:
20
+ * application/json:
21
+ * schema:
22
+ * $ref: '#/components/schemas/table'
23
+ * examples:
24
+ * table:
25
+ * $ref: '#/components/examples/table'
26
+ * responses:
27
+ * 200:
28
+ * description: Returns the created table, including the ID which has been generated for it. This can be
29
+ * internal or external data sources.
30
+ * content:
31
+ * application/json:
32
+ * schema:
33
+ * $ref: '#/components/schemas/tableOutput'
34
+ * examples:
35
+ * table:
36
+ * $ref: '#/components/examples/table'
37
+ */
38
+ write.push(
39
+ new Endpoint("post", "/tables", controller.create).addMiddleware(
40
+ tableValidator()
41
+ )
42
+ )
43
+
44
+ /**
45
+ * @openapi
46
+ * /tables/{tableId}:
47
+ * put:
48
+ * summary: Update a table
49
+ * description: Update a table, this could be internal or external.
50
+ * tags:
51
+ * - tables
52
+ * parameters:
53
+ * - $ref: '#/components/parameters/tableId'
54
+ * - $ref: '#/components/parameters/appId'
55
+ * requestBody:
56
+ * content:
57
+ * application/json:
58
+ * schema:
59
+ * $ref: '#/components/schemas/table'
60
+ * examples:
61
+ * table:
62
+ * $ref: '#/components/examples/table'
63
+ * responses:
64
+ * 200:
65
+ * description: Returns the updated table.
66
+ * content:
67
+ * application/json:
68
+ * schema:
69
+ * $ref: '#/components/schemas/tableOutput'
70
+ * examples:
71
+ * table:
72
+ * $ref: '#/components/examples/table'
73
+ */
74
+ write.push(
75
+ new Endpoint("put", "/tables/:tableId", controller.update).addMiddleware(
76
+ tableValidator()
77
+ )
78
+ )
79
+
80
+ /**
81
+ * @openapi
82
+ * /tables/{tableId}:
83
+ * delete:
84
+ * summary: Delete a table
85
+ * description: Delete a table, this could be internal or external.
86
+ * tags:
87
+ * - tables
88
+ * parameters:
89
+ * - $ref: '#/components/parameters/tableId'
90
+ * - $ref: '#/components/parameters/appId'
91
+ * responses:
92
+ * 200:
93
+ * description: Returns the deleted table.
94
+ * content:
95
+ * application/json:
96
+ * schema:
97
+ * $ref: '#/components/schemas/tableOutput'
98
+ * examples:
99
+ * table:
100
+ * $ref: '#/components/examples/table'
101
+ */
102
+ write.push(new Endpoint("delete", "/tables/:tableId", controller.destroy))
103
+
104
+ /**
105
+ * @openapi
106
+ * /tables/{tableId}:
107
+ * get:
108
+ * summary: Retrieve a table
109
+ * description: Lookup a table, this could be internal or external.
110
+ * tags:
111
+ * - tables
112
+ * parameters:
113
+ * - $ref: '#/components/parameters/tableId'
114
+ * - $ref: '#/components/parameters/appId'
115
+ * responses:
116
+ * 200:
117
+ * description: Returns the retrieved table.
118
+ * content:
119
+ * application/json:
120
+ * schema:
121
+ * $ref: '#/components/schemas/tableOutput'
122
+ * examples:
123
+ * table:
124
+ * $ref: '#/components/examples/table'
125
+ */
126
+ read.push(new Endpoint("get", "/tables/:tableId", controller.read))
127
+
128
+ /**
129
+ * @openapi
130
+ * /tables/search:
131
+ * post:
132
+ * summary: Search for tables
133
+ * description: Based on table properties (currently only name) search for tables. This could be
134
+ * an internal or an external table.
135
+ * tags:
136
+ * - tables
137
+ * parameters:
138
+ * - $ref: '#/components/parameters/appId'
139
+ * requestBody:
140
+ * required: true
141
+ * content:
142
+ * application/json:
143
+ * schema:
144
+ * $ref: '#/components/schemas/nameSearch'
145
+ * responses:
146
+ * 200:
147
+ * description: Returns the found tables, based on the search parameters.
148
+ * content:
149
+ * application/json:
150
+ * schema:
151
+ * type: object
152
+ * required:
153
+ * - data
154
+ * properties:
155
+ * data:
156
+ * type: array
157
+ * items:
158
+ * $ref: '#/components/schemas/table'
159
+ * examples:
160
+ * tables:
161
+ * $ref: '#/components/examples/tables'
162
+ */
163
+ read.push(
164
+ new Endpoint("post", "/tables/search", controller.search).addMiddleware(
165
+ nameValidator()
166
+ )
167
+ )
168
+
169
+ export default { read, write }
@@ -0,0 +1,184 @@
1
+ const jestOpenAPI = require("jest-openapi").default
2
+ const generateSchema = require("../../../../../specs/generate")
3
+ const setup = require("../../tests/utilities")
4
+ const { checkSlashesInUrl } = require("../../../../utilities")
5
+
6
+ const yamlPath = generateSchema()
7
+ jestOpenAPI(yamlPath)
8
+
9
+ let request = setup.getRequest()
10
+ let config = setup.getConfig()
11
+ let apiKey, table, app
12
+
13
+ beforeAll(async () => {
14
+ app = await config.init()
15
+ table = await config.updateTable()
16
+ apiKey = await config.generateApiKey()
17
+ })
18
+
19
+ afterAll(setup.afterAll)
20
+
21
+ async function makeRequest(method, endpoint, body, appId = config.getAppId()) {
22
+ const extraHeaders = {
23
+ "x-budibase-api-key": apiKey,
24
+ }
25
+ if (appId) {
26
+ extraHeaders["x-budibase-app-id"] = appId
27
+ }
28
+ const req = request
29
+ [method](checkSlashesInUrl(`/api/public/v1/${endpoint}`))
30
+ .set(config.defaultHeaders(extraHeaders))
31
+ if (body) {
32
+ req.send(body)
33
+ }
34
+ const res = await req.expect("Content-Type", /json/).expect(200)
35
+ expect(res.body).toBeDefined()
36
+ return res
37
+ }
38
+
39
+ describe("check the applications endpoints", () => {
40
+ it("should allow retrieving applications through search", async () => {
41
+ const res = await makeRequest("post", "/applications/search")
42
+ expect(res).toSatisfyApiSpec()
43
+ })
44
+
45
+ it("should allow creating an application", async () => {
46
+ const res = await makeRequest("post", "/applications", {
47
+ name: "new App"
48
+ }, null)
49
+ expect(res).toSatisfyApiSpec()
50
+ })
51
+
52
+ it("should allow updating an application", async () => {
53
+ const app = config.getApp()
54
+ const appId = config.getAppId()
55
+ const res = await makeRequest("put", `/applications/${appId}`, {
56
+ ...app,
57
+ name: "updated app name",
58
+ }, appId)
59
+ expect(res).toSatisfyApiSpec()
60
+ })
61
+
62
+ it("should allow retrieving an application", async () => {
63
+ const res = await makeRequest("get", `/applications/${config.getAppId()}`)
64
+ expect(res).toSatisfyApiSpec()
65
+ })
66
+
67
+ it("should allow deleting an application", async () => {
68
+ const res = await makeRequest("delete", `/applications/${config.getAppId()}`)
69
+ expect(res).toSatisfyApiSpec()
70
+ })
71
+ })
72
+
73
+ describe("check the tables endpoints", () => {
74
+ it("should allow retrieving tables through search", async () => {
75
+ await config.createApp("new app 1")
76
+ table = await config.updateTable()
77
+ const res = await makeRequest("post", "/tables/search")
78
+ expect(res).toSatisfyApiSpec()
79
+ })
80
+
81
+ it("should allow creating a table", async () => {
82
+ const res = await makeRequest("post", "/tables", {
83
+ name: "table name",
84
+ primaryDisplay: "column1",
85
+ schema: {
86
+ column1: {
87
+ type: "string",
88
+ constraints: {},
89
+ }
90
+ }
91
+ })
92
+ expect(res).toSatisfyApiSpec()
93
+ })
94
+
95
+ it("should allow updating a table", async () => {
96
+ const updated = { ...table, _rev: undefined, name: "new name" }
97
+ const res = await makeRequest("put", `/tables/${table._id}`, updated)
98
+ expect(res).toSatisfyApiSpec()
99
+ })
100
+
101
+ it("should allow retrieving a table", async () => {
102
+ const res = await makeRequest("get", `/tables/${table._id}`)
103
+ expect(res).toSatisfyApiSpec()
104
+ })
105
+
106
+ it("should allow deleting a table", async () => {
107
+ const res = await makeRequest("delete", `/tables/${table._id}`)
108
+ expect(res).toSatisfyApiSpec()
109
+ })
110
+ })
111
+
112
+ describe("check the rows endpoints", () => {
113
+ let row
114
+ it("should allow retrieving rows through search", async () => {
115
+ table = await config.updateTable()
116
+ const res = await makeRequest("post", `/tables/${table._id}/rows/search`, {
117
+ query: {
118
+ },
119
+ })
120
+ expect(res).toSatisfyApiSpec()
121
+ })
122
+
123
+ it("should allow creating a row", async () => {
124
+ const res = await makeRequest("post", `/tables/${table._id}/rows`, {
125
+ name: "test row",
126
+ })
127
+ expect(res).toSatisfyApiSpec()
128
+ row = res.body.data
129
+ })
130
+
131
+ it("should allow updating a row", async () => {
132
+ const res = await makeRequest("put", `/tables/${table._id}/rows/${row._id}`, {
133
+ name: "test row updated",
134
+ })
135
+ expect(res).toSatisfyApiSpec()
136
+ })
137
+
138
+ it("should allow retrieving a row", async () => {
139
+ const res = await makeRequest("get", `/tables/${table._id}/rows/${row._id}`)
140
+ expect(res).toSatisfyApiSpec()
141
+ })
142
+
143
+ it("should allow deleting a row", async () => {
144
+ const res = await makeRequest("delete", `/tables/${table._id}/rows/${row._id}`)
145
+ expect(res).toSatisfyApiSpec()
146
+ })
147
+ })
148
+
149
+ describe("check the users endpoints", () => {
150
+ let user
151
+ it("should allow retrieving users through search", async () => {
152
+ user = await config.createUser()
153
+ const res = await makeRequest("post", "/users/search")
154
+ expect(res).toSatisfyApiSpec()
155
+ })
156
+
157
+ it("should allow creating a user", async () => {
158
+ const res = await makeRequest("post", "/users")
159
+ expect(res).toSatisfyApiSpec()
160
+ })
161
+
162
+ it("should allow updating a user", async () => {
163
+ const res = await makeRequest("put", `/users/${user._id}`)
164
+ expect(res).toSatisfyApiSpec()
165
+ })
166
+
167
+ it("should allow retrieving a user", async () => {
168
+ const res = await makeRequest("get", `/users/${user._id}`)
169
+ expect(res).toSatisfyApiSpec()
170
+ })
171
+
172
+ it("should allow deleting a user", async () => {
173
+ const res = await makeRequest("delete", `/users/${user._id}`)
174
+ expect(res).toSatisfyApiSpec()
175
+ })
176
+ })
177
+
178
+ describe("check the queries endpoints", () => {
179
+ it("should allow retrieving queries through search", async () => {
180
+ const res = await makeRequest("post", "/queries/search")
181
+ expect(res).toSatisfyApiSpec()
182
+ })
183
+ })
184
+