@budibase/server 1.0.23-alpha.2 → 1.0.26

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 (234) hide show
  1. package/__mocks__/node-fetch.ts +0 -3
  2. package/builder/assets/{index.4a13c4cb.css → index.4fb3f887.css} +1 -1
  3. package/builder/assets/{index.26923a83.js → index.8adef83f.js} +204 -208
  4. package/builder/assets/{vendor.f9faf6ab.js → vendor.470042a4.js} +88 -88
  5. package/builder/index.html +3 -3
  6. package/coverage/clover.xml +512 -589
  7. package/coverage/coverage-final.json +19 -20
  8. package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/application.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/automation.js.html +10 -22
  13. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  16. package/coverage/lcov-report/api/controllers/datasource.js.html +14 -14
  17. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/hosting.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/index.html +43 -28
  20. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/{query/index.js.html → query.js.html} +27 -159
  25. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  29. package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  32. package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  37. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/table/internal.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/table/utils.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/user.js.html +9 -108
  42. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  44. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  45. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  46. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  47. package/coverage/lcov-report/api/controllers/webhook.js.html +6 -18
  48. package/coverage/lcov-report/api/index.html +1 -1
  49. package/coverage/lcov-report/api/index.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/application.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/hosting.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/index.html +9 -9
  63. package/coverage/lcov-report/api/routes/index.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/query.js.html +98 -11
  69. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/row.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/static.js.html +1 -1
  75. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  76. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  77. package/coverage/lcov-report/api/routes/user.js.html +2 -32
  78. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  79. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  80. package/coverage/lcov-report/automations/actions.js.html +1 -1
  81. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  82. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  83. package/coverage/lcov-report/automations/index.html +20 -20
  84. package/coverage/lcov-report/automations/index.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/index.html +1 -1
  94. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -5
  96. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  97. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  98. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  99. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  100. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  101. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  102. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  106. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  107. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  108. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  109. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  110. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  111. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  112. package/coverage/lcov-report/automations/utils.js.html +11 -44
  113. package/coverage/lcov-report/constants/index.html +1 -1
  114. package/coverage/lcov-report/constants/index.js.html +22 -22
  115. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  116. package/coverage/lcov-report/constants/screens.js.html +1 -1
  117. package/coverage/lcov-report/db/client.js.html +18 -18
  118. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  119. package/coverage/lcov-report/db/index.html +15 -15
  120. package/coverage/lcov-report/db/index.js.html +3 -3
  121. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  122. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  123. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  124. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  125. package/coverage/lcov-report/db/newid.js.html +4 -4
  126. package/coverage/lcov-report/db/utils.js.html +64 -91
  127. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  128. package/coverage/lcov-report/events/index.html +1 -1
  129. package/coverage/lcov-report/events/index.js.html +1 -1
  130. package/coverage/lcov-report/events/utils.js.html +1 -1
  131. package/coverage/lcov-report/index.html +60 -75
  132. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  133. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  134. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  135. package/coverage/lcov-report/middleware/authorized.js.html +2 -2
  136. package/coverage/lcov-report/middleware/builder.js.html +1 -1
  137. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  138. package/coverage/lcov-report/middleware/index.html +1 -1
  139. package/coverage/lcov-report/middleware/joi-validator.js.html +3 -3
  140. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  141. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  142. package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
  143. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  144. package/coverage/lcov-report/threads/automation.js.html +1 -1
  145. package/coverage/lcov-report/threads/index.html +19 -19
  146. package/coverage/lcov-report/threads/index.js.html +1 -1
  147. package/coverage/lcov-report/threads/query.js.html +12 -63
  148. package/coverage/lcov-report/threads/utils.js.html +1 -1
  149. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  150. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  151. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  152. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  153. package/coverage/lcov-report/utilities/global.js.html +1 -1
  154. package/coverage/lcov-report/utilities/index.html +19 -19
  155. package/coverage/lcov-report/utilities/index.js.html +33 -66
  156. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  157. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  158. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  159. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  160. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  161. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  162. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  163. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  164. package/coverage/lcov-report/utilities/security.js.html +2 -2
  165. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  166. package/coverage/lcov-report/utilities/users.js.html +1 -1
  167. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  168. package/coverage/lcov.info +851 -969
  169. package/dist/api/controllers/automation.js +5 -7
  170. package/dist/api/controllers/{query/index.js → query.js} +6 -42
  171. package/dist/api/controllers/user.js +1 -37
  172. package/dist/api/controllers/webhook.js +0 -4
  173. package/dist/api/routes/query.js +32 -2
  174. package/dist/api/routes/user.js +1 -3
  175. package/dist/automations/steps/outgoingWebhook.js +3 -2
  176. package/dist/automations/utils.js +0 -10
  177. package/dist/db/utils.js +0 -8
  178. package/dist/definitions/datasource.js +1 -6
  179. package/dist/integrations/rest.js +117 -207
  180. package/dist/package.json +4 -10
  181. package/dist/threads/query.js +2 -14
  182. package/dist/tsconfig.tsbuildinfo +1 -1
  183. package/dist/utilities/index.js +0 -10
  184. package/package.json +5 -11
  185. package/src/api/controllers/automation.js +4 -8
  186. package/src/api/controllers/{query/index.js → query.js} +6 -50
  187. package/src/api/controllers/user.js +0 -33
  188. package/src/api/controllers/webhook.js +0 -4
  189. package/src/api/routes/query.js +34 -5
  190. package/src/api/routes/user.js +0 -10
  191. package/src/automations/steps/outgoingWebhook.js +3 -2
  192. package/src/automations/utils.js +0 -11
  193. package/src/db/utils.js +0 -9
  194. package/src/definitions/common.ts +16 -2
  195. package/src/definitions/datasource.ts +1 -73
  196. package/src/integrations/base/IntegrationBase.ts +4 -4
  197. package/src/integrations/oracle.ts +1 -1
  198. package/src/integrations/rest.ts +137 -227
  199. package/src/integrations/tests/rest.spec.js +19 -167
  200. package/src/threads/query.js +2 -19
  201. package/src/utilities/index.js +0 -11
  202. package/builder/assets/bb-spaceship.8f6e81e1.svg +0 -227
  203. package/coverage/lcov-report/api/controllers/query/index.html +0 -126
  204. package/coverage/lcov-report/api/controllers/query/validation.js.html +0 -203
  205. package/dist/api/controllers/query/import/index.js +0 -79
  206. package/dist/api/controllers/query/import/sources/base/index.js +0 -63
  207. package/dist/api/controllers/query/import/sources/base/openapi.js +0 -42
  208. package/dist/api/controllers/query/import/sources/curl.js +0 -90
  209. package/dist/api/controllers/query/import/sources/openapi2.js +0 -139
  210. package/dist/api/controllers/query/import/sources/tests/openapi2/data/crud/crud.json +0 -253
  211. package/dist/api/controllers/query/import/sources/tests/openapi2/data/petstore/petstore.json +0 -1054
  212. package/dist/api/controllers/query/validation.js +0 -37
  213. package/src/api/controllers/query/import/index.ts +0 -85
  214. package/src/api/controllers/query/import/sources/base/index.ts +0 -85
  215. package/src/api/controllers/query/import/sources/base/openapi.ts +0 -24
  216. package/src/api/controllers/query/import/sources/curl.ts +0 -94
  217. package/src/api/controllers/query/import/sources/openapi2.ts +0 -159
  218. package/src/api/controllers/query/import/sources/tests/curl/curl.spec.js +0 -104
  219. package/src/api/controllers/query/import/sources/tests/curl/data/delete.txt +0 -1
  220. package/src/api/controllers/query/import/sources/tests/curl/data/empty-body.txt +0 -2
  221. package/src/api/controllers/query/import/sources/tests/curl/data/get.txt +0 -1
  222. package/src/api/controllers/query/import/sources/tests/curl/data/headers.txt +0 -3
  223. package/src/api/controllers/query/import/sources/tests/curl/data/patch.txt +0 -2
  224. package/src/api/controllers/query/import/sources/tests/curl/data/path.txt +0 -1
  225. package/src/api/controllers/query/import/sources/tests/curl/data/post.txt +0 -2
  226. package/src/api/controllers/query/import/sources/tests/curl/data/put.txt +0 -2
  227. package/src/api/controllers/query/import/sources/tests/curl/data/query.txt +0 -1
  228. package/src/api/controllers/query/import/sources/tests/openapi2/data/crud/crud.json +0 -253
  229. package/src/api/controllers/query/import/sources/tests/openapi2/data/crud/crud.yaml +0 -160
  230. package/src/api/controllers/query/import/sources/tests/openapi2/data/petstore/petstore.json +0 -1054
  231. package/src/api/controllers/query/import/sources/tests/openapi2/data/petstore/petstore.yaml +0 -711
  232. package/src/api/controllers/query/import/sources/tests/openapi2/openapi2.spec.js +0 -239
  233. package/src/api/controllers/query/import/tests/index.spec.js +0 -115
  234. package/src/api/controllers/query/validation.js +0 -41
@@ -142,13 +142,3 @@ exports.doesDatabaseExist = (dbName) => __awaiter(void 0, void 0, void 0, functi
142
142
  return false;
143
143
  }
144
144
  });
145
- exports.formatBytes = bytes => {
146
- const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
147
- const byteIncrements = 1024;
148
- let unit = 0;
149
- let size = parseInt(bytes, 10) || 0;
150
- while (size >= byteIncrements && ++unit) {
151
- size /= byteIncrements;
152
- }
153
- return `${size.toFixed(size < 10 && unit > 0 ? 1 : 0)}${units[unit]}`;
154
- };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "1.0.23-alpha.2",
4
+ "version": "1.0.26",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -69,10 +69,9 @@
69
69
  "author": "Budibase",
70
70
  "license": "GPL-3.0",
71
71
  "dependencies": {
72
- "@apidevtools/swagger-parser": "^10.0.3",
73
- "@budibase/auth": "^1.0.23-alpha.2",
74
- "@budibase/client": "^1.0.23-alpha.2",
75
- "@budibase/string-templates": "^1.0.23-alpha.2",
72
+ "@budibase/auth": "^1.0.26",
73
+ "@budibase/client": "^1.0.26",
74
+ "@budibase/string-templates": "^1.0.26",
76
75
  "@bull-board/api": "^3.7.0",
77
76
  "@bull-board/koa": "^3.7.0",
78
77
  "@elastic/elasticsearch": "7.10.0",
@@ -86,15 +85,12 @@
86
85
  "bull": "^3.22.4",
87
86
  "chmodr": "1.2.0",
88
87
  "csvtojson": "2.0.10",
89
- "curlconverter": "^3.21.0",
90
88
  "dotenv": "8.2.0",
91
89
  "download": "8.0.0",
92
90
  "fix-path": "3.0.0",
93
- "form-data": "^4.0.0",
94
91
  "fs-extra": "8.1.0",
95
92
  "jimp": "0.16.1",
96
93
  "joi": "17.2.1",
97
- "js-yaml": "^4.1.0",
98
94
  "jsonschema": "1.4.0",
99
95
  "knex": "^0.95.6",
100
96
  "koa": "2.7.0",
@@ -127,7 +123,6 @@
127
123
  "validate.js": "0.13.1",
128
124
  "vm2": "^3.9.3",
129
125
  "worker-farm": "^1.7.0",
130
- "xml2js": "^0.4.23",
131
126
  "yargs": "13.2.4",
132
127
  "zlib": "1.0.5"
133
128
  },
@@ -151,7 +146,6 @@
151
146
  "eslint": "^6.8.0",
152
147
  "jest": "^27.0.5",
153
148
  "nodemon": "^2.0.4",
154
- "openapi-types": "^9.3.1",
155
149
  "path-to-regexp": "^6.2.0",
156
150
  "prettier": "^2.3.1",
157
151
  "rimraf": "^3.0.2",
@@ -164,5 +158,5 @@
164
158
  "optionalDependencies": {
165
159
  "oracledb": "^5.3.0"
166
160
  },
167
- "gitHead": "b053be7d765d7641eafe09ea5110a8c6afb95734"
161
+ "gitHead": "6ebc345b6523efdd0ac77ea4c7e392918aff0757"
168
162
  }
@@ -5,15 +5,11 @@ const { getAutomationParams, generateAutomationID } = require("../../db/utils")
5
5
  const {
6
6
  checkForWebhooks,
7
7
  updateTestHistory,
8
- removeDeprecated,
9
8
  } = require("../../automations/utils")
10
9
  const { deleteEntityMetadata } = require("../../utilities")
11
10
  const { MetadataTypes } = require("../../constants")
12
11
  const { setTestFlag, clearTestFlag } = require("../../utilities/redis")
13
12
 
14
- const ACTION_DEFS = removeDeprecated(actions.ACTION_DEFINITIONS)
15
- const TRIGGER_DEFS = removeDeprecated(triggers.TRIGGER_DEFINITIONS)
16
-
17
13
  /*************************
18
14
  * *
19
15
  * BUILDER FUNCTIONS *
@@ -159,17 +155,17 @@ exports.destroy = async function (ctx) {
159
155
  }
160
156
 
161
157
  exports.getActionList = async function (ctx) {
162
- ctx.body = ACTION_DEFS
158
+ ctx.body = actions.ACTION_DEFINITIONS
163
159
  }
164
160
 
165
161
  exports.getTriggerList = async function (ctx) {
166
- ctx.body = TRIGGER_DEFS
162
+ ctx.body = triggers.TRIGGER_DEFINITIONS
167
163
  }
168
164
 
169
165
  module.exports.getDefinitionList = async function (ctx) {
170
166
  ctx.body = {
171
- trigger: TRIGGER_DEFS,
172
- action: ACTION_DEFS,
167
+ trigger: triggers.TRIGGER_DEFINITIONS,
168
+ action: actions.ACTION_DEFINITIONS,
173
169
  }
174
170
  }
175
171
 
@@ -1,14 +1,12 @@
1
1
  const { processString } = require("@budibase/string-templates")
2
- const CouchDB = require("../../../db")
2
+ const CouchDB = require("../../db")
3
3
  const {
4
4
  generateQueryID,
5
5
  getQueryParams,
6
6
  isProdAppID,
7
- } = require("../../../db/utils")
8
- const { BaseQueryVerbs } = require("../../../constants")
9
- const { Thread, ThreadType } = require("../../../threads")
10
- const { save: saveDatasource } = require("../datasource")
11
- const { RestImporter } = require("./import")
7
+ } = require("../../db/utils")
8
+ const { BaseQueryVerbs } = require("../../constants")
9
+ const { Thread, ThreadType } = require("../../threads")
12
10
 
13
11
  const Runner = new Thread(ThreadType.QUERY, { timeoutMs: 10000 })
14
12
 
@@ -32,49 +30,9 @@ exports.fetch = async function (ctx) {
32
30
  include_docs: true,
33
31
  })
34
32
  )
35
-
36
33
  ctx.body = enrichQueries(body.rows.map(row => row.doc))
37
34
  }
38
35
 
39
- exports.import = async ctx => {
40
- const body = ctx.request.body
41
- const data = body.data
42
-
43
- const importer = new RestImporter(data)
44
- await importer.init()
45
-
46
- let datasourceId
47
- if (!body.datasourceId) {
48
- // construct new datasource
49
- const info = await importer.getInfo()
50
- let datasource = {
51
- type: "datasource",
52
- source: "REST",
53
- config: {
54
- url: info.url,
55
- defaultHeaders: [],
56
- },
57
- name: info.name,
58
- }
59
- // save the datasource
60
- const datasourceCtx = { ...ctx }
61
- datasourceCtx.request.body.datasource = datasource
62
- await saveDatasource(datasourceCtx)
63
- datasourceId = datasourceCtx.body.datasource._id
64
- } else {
65
- // use existing datasource
66
- datasourceId = body.datasourceId
67
- }
68
-
69
- const importResult = await importer.importQueries(ctx.appId, datasourceId)
70
-
71
- ctx.body = {
72
- ...importResult,
73
- datasourceId,
74
- }
75
- ctx.status = 200
76
- }
77
-
78
36
  exports.save = async function (ctx) {
79
37
  const db = new CouchDB(ctx.appId)
80
38
  const query = ctx.request.body
@@ -123,7 +81,7 @@ async function enrichQueryFields(fields, parameters = {}) {
123
81
  enrichedQuery.requestBody
124
82
  )
125
83
  } catch (err) {
126
- // no json found, ignore
84
+ throw { message: `JSON Invalid - error: ${err}` }
127
85
  }
128
86
  delete enrichedQuery.customData
129
87
  }
@@ -151,7 +109,7 @@ exports.preview = async function (ctx) {
151
109
  const enrichedQuery = await enrichQueryFields(fields, parameters)
152
110
 
153
111
  try {
154
- const { rows, keys, info, extra } = await Runner.run({
112
+ const { rows, keys } = await Runner.run({
155
113
  datasource,
156
114
  queryVerb,
157
115
  query: enrichedQuery,
@@ -161,8 +119,6 @@ exports.preview = async function (ctx) {
161
119
  ctx.body = {
162
120
  rows,
163
121
  schemaFields: [...new Set(keys)],
164
- info,
165
- extra,
166
122
  }
167
123
  } catch (err) {
168
124
  ctx.throw(400, err)
@@ -2,7 +2,6 @@ const CouchDB = require("../../db")
2
2
  const {
3
3
  generateUserMetadataID,
4
4
  getUserMetadataParams,
5
- generateUserFlagID,
6
5
  } = require("../../db/utils")
7
6
  const { InternalTables } = require("../../db/utils")
8
7
  const { getGlobalUsers, getRawGlobalUser } = require("../../utilities/global")
@@ -196,35 +195,3 @@ exports.destroyMetadata = async function (ctx) {
196
195
  exports.findMetadata = async function (ctx) {
197
196
  ctx.body = await getFullUser(ctx, ctx.params.id)
198
197
  }
199
-
200
- exports.setFlag = async function (ctx) {
201
- const userId = ctx.user._id
202
- const { flag, value } = ctx.request.body
203
- if (!flag) {
204
- ctx.throw(400, "Must supply a 'flag' field in request body.")
205
- }
206
- const flagDocId = generateUserFlagID(userId)
207
- const db = new CouchDB(ctx.appId)
208
- let doc
209
- try {
210
- doc = await db.get(flagDocId)
211
- } catch (err) {
212
- doc = { _id: flagDocId }
213
- }
214
- doc[flag] = value || true
215
- await db.put(doc)
216
- ctx.body = { message: "Flag set successfully" }
217
- }
218
-
219
- exports.getFlags = async function (ctx) {
220
- const userId = ctx.user._id
221
- const docId = generateUserFlagID(userId)
222
- const db = new CouchDB(ctx.appId)
223
- let doc
224
- try {
225
- doc = await db.get(docId)
226
- } catch (err) {
227
- doc = { _id: docId }
228
- }
229
- ctx.body = doc
230
- }
@@ -65,10 +65,6 @@ exports.buildSchema = async ctx => {
65
65
  let automation = await db.get(webhook.action.target)
66
66
  const autoOutputs = automation.definition.trigger.schema.outputs
67
67
  let properties = webhook.bodySchema.properties
68
- // reset webhook outputs
69
- autoOutputs.properties = {
70
- body: autoOutputs.properties.body,
71
- }
72
68
  for (let prop of Object.keys(properties)) {
73
69
  autoOutputs.properties[prop] = {
74
70
  type: properties[prop].type,
@@ -1,23 +1,53 @@
1
1
  const Router = require("@koa/router")
2
2
  const queryController = require("../controllers/query")
3
3
  const authorized = require("../../middleware/authorized")
4
+ const Joi = require("joi")
4
5
  const {
5
6
  PermissionLevels,
6
7
  PermissionTypes,
7
8
  BUILDER,
8
9
  } = require("@budibase/auth/permissions")
10
+ const joiValidator = require("../../middleware/joi-validator")
9
11
  const {
10
12
  bodyResource,
11
13
  bodySubResource,
12
14
  paramResource,
13
15
  } = require("../../middleware/resourceId")
14
- const {
15
- generateQueryPreviewValidation,
16
- generateQueryValidation,
17
- } = require("../controllers/query/validation")
18
16
 
19
17
  const router = Router()
20
18
 
19
+ function generateQueryValidation() {
20
+ // prettier-ignore
21
+ return joiValidator.body(Joi.object({
22
+ _id: Joi.string(),
23
+ _rev: Joi.string(),
24
+ name: Joi.string().required(),
25
+ fields: Joi.object().required(),
26
+ datasourceId: Joi.string().required(),
27
+ readable: Joi.boolean(),
28
+ parameters: Joi.array().items(Joi.object({
29
+ name: Joi.string(),
30
+ default: Joi.string().allow(""),
31
+ })),
32
+ queryVerb: Joi.string().allow().required(),
33
+ extra: Joi.object().optional(),
34
+ schema: Joi.object({}).required().unknown(true),
35
+ transformer: Joi.string().optional(),
36
+ }))
37
+ }
38
+
39
+ function generateQueryPreviewValidation() {
40
+ // prettier-ignore
41
+ return joiValidator.body(Joi.object({
42
+ fields: Joi.object().required(),
43
+ queryVerb: Joi.string().allow().required(),
44
+ extra: Joi.object().optional(),
45
+ datasourceId: Joi.string().required(),
46
+ transformer: Joi.string().optional(),
47
+ parameters: Joi.object({}).required().unknown(true)
48
+ }))
49
+ }
50
+
21
51
  router
22
52
  .get("/api/queries", authorized(BUILDER), queryController.fetch)
23
53
  .post(
@@ -27,7 +57,6 @@ router
27
57
  generateQueryValidation(),
28
58
  queryController.save
29
59
  )
30
- .post("/api/queries/import", authorized(BUILDER), queryController.import)
31
60
  .post(
32
61
  "/api/queries/preview",
33
62
  bodyResource("datasourceId"),
@@ -39,15 +39,5 @@ router
39
39
  authorized(PermissionTypes.USER, PermissionLevels.WRITE),
40
40
  controller.syncUser
41
41
  )
42
- .post(
43
- "/api/users/flags",
44
- authorized(PermissionTypes.USER, PermissionLevels.WRITE),
45
- controller.setFlag
46
- )
47
- .get(
48
- "/api/users/flags",
49
- authorized(PermissionTypes.USER, PermissionLevels.READ),
50
- controller.getFlags
51
- )
52
42
 
53
43
  module.exports = router
@@ -13,11 +13,12 @@ const RequestType = {
13
13
  const BODY_REQUESTS = [RequestType.POST, RequestType.PUT, RequestType.PATCH]
14
14
 
15
15
  /**
16
- * NOTE: this functionality is deprecated - it no longer should be used.
16
+ * Note, there is some functionality in this that is not currently exposed as it
17
+ * is complex and maybe better to be opinionated here.
18
+ * GET/DELETE requests cannot handle body elements so they will not be sent if configured.
17
19
  */
18
20
 
19
21
  exports.definition = {
20
- deprecated: true,
21
22
  name: "Outgoing webhook",
22
23
  tagline: "Send a {{inputs.requestMethod}} request",
23
24
  icon: "Send",
@@ -7,7 +7,6 @@ const newid = require("../db/newid")
7
7
  const { updateEntityMetadata } = require("../utilities")
8
8
  const { MetadataTypes } = require("../constants")
9
9
  const { getDeployedAppID } = require("@budibase/auth/db")
10
- const { cloneDeep } = require("lodash/fp")
11
10
 
12
11
  const WH_STEP_ID = definitions.WEBHOOK.stepId
13
12
  const CRON_STEP_ID = definitions.CRON.stepId
@@ -43,16 +42,6 @@ exports.updateTestHistory = async (appId, automation, history) => {
43
42
  )
44
43
  }
45
44
 
46
- exports.removeDeprecated = definitions => {
47
- const base = cloneDeep(definitions)
48
- for (let key of Object.keys(base)) {
49
- if (base[key].deprecated) {
50
- delete base[key]
51
- }
52
- }
53
- return base
54
- }
55
-
56
45
  // end the repetition and the job itself
57
46
  exports.disableAllCrons = async appId => {
58
47
  const promises = []
package/src/db/utils.js CHANGED
@@ -40,7 +40,6 @@ const DocumentTypes = {
40
40
  DEPLOYMENTS: "deployments",
41
41
  METADATA: "metadata",
42
42
  MEM_VIEW: "view",
43
- USER_FLAG: "flag",
44
43
  }
45
44
 
46
45
  const ViewNames = {
@@ -340,14 +339,6 @@ exports.getQueryParams = (datasourceId = null, otherProps = {}) => {
340
339
  )
341
340
  }
342
341
 
343
- /**
344
- * Generates a new flag document ID.
345
- * @returns {string} The ID of the flag document that was generated.
346
- */
347
- exports.generateUserFlagID = userId => {
348
- return `${DocumentTypes.USER_FLAG}${SEPARATOR}${userId}`
349
- }
350
-
351
342
  exports.generateMetadataID = (type, entityId) => {
352
343
  return `${DocumentTypes.METADATA}${SEPARATOR}${type}${SEPARATOR}${entityId}`
353
344
  }
@@ -1,6 +1,6 @@
1
- export { Query, Datasource } from "./datasource"
1
+ import { SourceNames } from "./datasource"
2
2
 
3
- export interface Base {
3
+ interface Base {
4
4
  _id?: string
5
5
  _rev?: string
6
6
  }
@@ -93,3 +93,17 @@ export interface Automation extends Base {
93
93
  trigger?: AutomationStep
94
94
  }
95
95
  }
96
+
97
+ export interface Datasource extends Base {
98
+ type: string
99
+ name: string
100
+ source: SourceNames
101
+ // the config is defined by the schema
102
+ config: {
103
+ [key: string]: string | number | boolean
104
+ }
105
+ plus: boolean
106
+ entities?: {
107
+ [key: string]: Table
108
+ }
109
+ }
@@ -1,4 +1,4 @@
1
- import { Row, Table, Base } from "./common"
1
+ import { Row, Table } from "./common"
2
2
 
3
3
  export enum Operation {
4
4
  CREATE = "CREATE",
@@ -181,75 +181,3 @@ export interface SqlQuery {
181
181
  export interface QueryOptions {
182
182
  disableReturning?: boolean
183
183
  }
184
-
185
- export interface Datasource extends Base {
186
- type: string
187
- name: string
188
- source: SourceNames
189
- // the config is defined by the schema
190
- config: {
191
- [key: string]: string | number | boolean
192
- }
193
- plus: boolean
194
- entities?: {
195
- [key: string]: Table
196
- }
197
- }
198
-
199
- export enum AuthType {
200
- BASIC = "basic",
201
- BEARER = "bearer",
202
- }
203
-
204
- interface AuthConfig {
205
- _id: string
206
- name: string
207
- type: AuthType
208
- config: BasicAuthConfig | BearerAuthConfig
209
- }
210
-
211
- export interface BasicAuthConfig {
212
- username: string
213
- password: string
214
- }
215
-
216
- export interface BearerAuthConfig {
217
- token: string
218
- }
219
-
220
- export interface QueryParameter {
221
- name: string
222
- default: string
223
- }
224
-
225
- export interface RestQueryFields {
226
- path: string
227
- queryString?: string
228
- headers: { [key: string]: any }
229
- disabledHeaders: { [key: string]: any }
230
- requestBody: any
231
- bodyType: string
232
- json: object
233
- method: string
234
- authConfigId: string
235
- }
236
-
237
- export interface RestConfig {
238
- url: string
239
- defaultHeaders: {
240
- [key: string]: any
241
- }
242
- authConfigs: AuthConfig[]
243
- }
244
-
245
- export interface Query {
246
- _id?: string
247
- datasourceId: string
248
- name: string
249
- parameters: QueryParameter[]
250
- fields: RestQueryFields | any
251
- transformer: string | null
252
- schema: any
253
- readable: boolean
254
- queryVerb: string
255
- }
@@ -1,6 +1,6 @@
1
1
  export interface IntegrationBase {
2
- create?(query: any): Promise<any[] | any>
3
- read?(query: any): Promise<any[] | any>
4
- update?(query: any): Promise<any[] | any>
5
- delete?(query: any): Promise<any[] | any>
2
+ create?(query: any): Promise<any[]>
3
+ read?(query: any): Promise<any[]>
4
+ update?(query: any): Promise<any[]>
5
+ delete?(query: any): Promise<any[]>
6
6
  }
@@ -450,7 +450,7 @@ module OracleModule {
450
450
  })
451
451
  return lastRow.rows
452
452
  } else {
453
- return [{ [operation.toLowerCase()]: true }]
453
+ return [{ [ operation.toLowerCase() ]: true }]
454
454
  }
455
455
  }
456
456
  }