@budibase/server 1.0.80-alpha.1 → 1.0.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/__mocks__/node-fetch.ts +0 -1
  2. package/builder/assets/index.22a39cc9.js +1352 -0
  3. package/builder/assets/{index.c57242d4.css → index.c8d1e8f0.css} +2 -2
  4. package/builder/assets/{vendor.a7c6ad0a.js → vendor.20f80cec.js} +216 -190
  5. package/builder/index.html +3 -3
  6. package/coverage/clover.xml +2327 -2390
  7. package/coverage/coverage-final.json +137 -138
  8. package/coverage/lcov-report/api/controllers/analytics.js.html +6 -6
  9. package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
  10. package/coverage/lcov-report/api/controllers/application.js.html +149 -152
  11. package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
  12. package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
  13. package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
  14. package/coverage/lcov-report/api/controllers/cloud.js.html +11 -11
  15. package/coverage/lcov-report/api/controllers/component.js.html +5 -5
  16. package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
  17. package/coverage/lcov-report/api/controllers/dev.js.html +19 -19
  18. package/coverage/lcov-report/api/controllers/index.html +16 -16
  19. package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
  20. package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
  21. package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
  22. package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
  23. package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
  24. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  25. package/coverage/lcov-report/api/controllers/query/index.js.html +26 -26
  26. package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
  27. package/coverage/lcov-report/api/controllers/role.js.html +9 -9
  28. package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
  29. package/coverage/lcov-report/api/controllers/row/external.js.html +16 -16
  30. package/coverage/lcov-report/api/controllers/row/index.html +27 -27
  31. package/coverage/lcov-report/api/controllers/row/index.js.html +46 -46
  32. package/coverage/lcov-report/api/controllers/row/internal.js.html +82 -94
  33. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +204 -204
  34. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
  35. package/coverage/lcov-report/api/controllers/row/utils.js.html +29 -29
  36. package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
  37. package/coverage/lcov-report/api/controllers/script.js.html +4 -4
  38. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +49 -49
  39. package/coverage/lcov-report/api/controllers/table/external.js.html +12 -12
  40. package/coverage/lcov-report/api/controllers/table/index.html +11 -11
  41. package/coverage/lcov-report/api/controllers/table/index.js.html +44 -47
  42. package/coverage/lcov-report/api/controllers/table/internal.js.html +50 -50
  43. package/coverage/lcov-report/api/controllers/table/utils.js.html +80 -80
  44. package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
  45. package/coverage/lcov-report/api/controllers/user.js.html +19 -19
  46. package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
  47. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  48. package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
  49. package/coverage/lcov-report/api/controllers/view/utils.js.html +12 -12
  50. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
  51. package/coverage/lcov-report/api/controllers/webhook.js.html +27 -18
  52. package/coverage/lcov-report/api/index.html +10 -10
  53. package/coverage/lcov-report/api/index.js.html +28 -37
  54. package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
  55. package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
  56. package/coverage/lcov-report/api/routes/application.js.html +9 -9
  57. package/coverage/lcov-report/api/routes/auth.js.html +6 -6
  58. package/coverage/lcov-report/api/routes/automation.js.html +109 -19
  59. package/coverage/lcov-report/api/routes/backup.js.html +8 -8
  60. package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
  61. package/coverage/lcov-report/api/routes/component.js.html +8 -8
  62. package/coverage/lcov-report/api/routes/datasource.js.html +156 -18
  63. package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
  64. package/coverage/lcov-report/api/routes/dev.js.html +13 -13
  65. package/coverage/lcov-report/api/routes/index.html +35 -35
  66. package/coverage/lcov-report/api/routes/index.js.html +32 -38
  67. package/coverage/lcov-report/api/routes/integration.js.html +8 -8
  68. package/coverage/lcov-report/api/routes/layout.js.html +8 -8
  69. package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
  70. package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
  71. package/coverage/lcov-report/api/routes/permission.js.html +58 -16
  72. package/coverage/lcov-report/api/routes/query.js.html +10 -10
  73. package/coverage/lcov-report/api/routes/role.js.html +78 -15
  74. package/coverage/lcov-report/api/routes/routing.js.html +8 -8
  75. package/coverage/lcov-report/api/routes/row.js.html +14 -17
  76. package/coverage/lcov-report/api/routes/screen.js.html +95 -14
  77. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  78. package/coverage/lcov-report/api/routes/static.js.html +13 -13
  79. package/coverage/lcov-report/api/routes/table.js.html +62 -17
  80. package/coverage/lcov-report/api/routes/templates.js.html +8 -8
  81. package/coverage/lcov-report/api/routes/user.js.html +8 -8
  82. package/coverage/lcov-report/api/routes/view.js.html +10 -10
  83. package/coverage/lcov-report/api/routes/webhook.js.html +62 -14
  84. package/coverage/lcov-report/automations/actions.js.html +24 -24
  85. package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
  86. package/coverage/lcov-report/automations/bullboard.js.html +16 -16
  87. package/coverage/lcov-report/automations/index.html +1 -1
  88. package/coverage/lcov-report/automations/index.js.html +7 -7
  89. package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
  90. package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
  91. package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
  92. package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
  93. package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
  94. package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
  95. package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
  96. package/coverage/lcov-report/automations/steps/filter.js.html +9 -12
  97. package/coverage/lcov-report/automations/steps/index.html +1 -1
  98. package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
  99. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
  100. package/coverage/lcov-report/automations/steps/queryRows.js.html +11 -11
  101. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
  102. package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
  103. package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
  104. package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
  105. package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
  106. package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
  107. package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
  108. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
  109. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  110. package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
  111. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
  112. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
  113. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
  114. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
  115. package/coverage/lcov-report/automations/triggers.js.html +26 -26
  116. package/coverage/lcov-report/automations/utils.js.html +35 -35
  117. package/coverage/lcov-report/constants/index.html +5 -5
  118. package/coverage/lcov-report/constants/index.js.html +28 -40
  119. package/coverage/lcov-report/constants/layouts.js.html +5 -5
  120. package/coverage/lcov-report/constants/screens.js.html +4 -4
  121. package/coverage/lcov-report/db/client.js.html +18 -18
  122. package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
  123. package/coverage/lcov-report/db/index.html +15 -15
  124. package/coverage/lcov-report/db/index.js.html +3 -3
  125. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +21 -21
  126. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  127. package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
  128. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +30 -30
  129. package/coverage/lcov-report/db/newid.js.html +4 -4
  130. package/coverage/lcov-report/db/utils.js.html +87 -123
  131. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  132. package/coverage/lcov-report/events/index.html +1 -1
  133. package/coverage/lcov-report/events/index.js.html +8 -8
  134. package/coverage/lcov-report/events/utils.js.html +18 -18
  135. package/coverage/lcov-report/index.html +74 -89
  136. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  137. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  138. package/coverage/lcov-report/middleware/appInfo.js.html +5 -5
  139. package/coverage/lcov-report/middleware/authorized.js.html +29 -29
  140. package/coverage/lcov-report/middleware/builder.js.html +16 -16
  141. package/coverage/lcov-report/middleware/currentapp.js.html +44 -44
  142. package/coverage/lcov-report/middleware/index.html +1 -1
  143. package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
  144. package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
  145. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  146. package/coverage/lcov-report/middleware/usageQuota.js.html +17 -17
  147. package/coverage/lcov-report/middleware/utils.js.html +4 -4
  148. package/coverage/lcov-report/threads/automation.js.html +1 -1
  149. package/coverage/lcov-report/threads/index.html +19 -19
  150. package/coverage/lcov-report/threads/index.js.html +10 -10
  151. package/coverage/lcov-report/threads/query.js.html +39 -123
  152. package/coverage/lcov-report/threads/utils.js.html +14 -14
  153. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  154. package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
  155. package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
  156. package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
  157. package/coverage/lcov-report/utilities/global.js.html +28 -28
  158. package/coverage/lcov-report/utilities/index.html +18 -18
  159. package/coverage/lcov-report/utilities/index.js.html +24 -24
  160. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -9
  161. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  162. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  163. package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
  164. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  165. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +60 -60
  166. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +13 -13
  167. package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
  168. package/coverage/lcov-report/utilities/security.js.html +8 -8
  169. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  170. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  171. package/coverage/lcov-report/utilities/usageQuota/index.js.html +12 -12
  172. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +8 -8
  173. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  174. package/coverage/lcov-report/utilities/users.js.html +5 -5
  175. package/coverage/lcov-report/utilities/workerRequests.js.html +53 -200
  176. package/coverage/lcov.info +3233 -3332
  177. package/dist/api/controllers/application.js +0 -1
  178. package/dist/api/controllers/row/internal.js +1 -4
  179. package/dist/api/controllers/table/index.js +1 -2
  180. package/dist/api/controllers/webhook.js +5 -3
  181. package/dist/api/index.js +1 -3
  182. package/dist/api/routes/automation.js +31 -3
  183. package/dist/api/routes/datasource.js +50 -3
  184. package/dist/api/routes/index.js +0 -2
  185. package/dist/api/routes/permission.js +14 -4
  186. package/dist/api/routes/role.js +19 -3
  187. package/dist/api/routes/row.js +4 -3
  188. package/dist/api/routes/screen.js +23 -2
  189. package/dist/api/routes/table.js +17 -3
  190. package/dist/api/routes/tests/utilities/index.js +0 -23
  191. package/dist/api/routes/webhook.js +17 -2
  192. package/dist/automations/steps/filter.js +2 -2
  193. package/dist/automations/steps/queryRows.js +1 -1
  194. package/dist/automations/utils.js +2 -2
  195. package/dist/constants/index.js +0 -3
  196. package/dist/db/utils.js +0 -11
  197. package/dist/environment.js +0 -1
  198. package/dist/integrations/googlesheets.js +0 -3
  199. package/dist/integrations/microsoftSqlServer.js +29 -35
  200. package/dist/integrations/mysql.js +0 -3
  201. package/dist/integrations/oracle.js +19 -14
  202. package/dist/integrations/postgres.js +28 -34
  203. package/dist/package.json +7 -11
  204. package/dist/tests/utilities/TestConfiguration.js +8 -25
  205. package/dist/threads/query.js +8 -33
  206. package/dist/tsconfig.tsbuildinfo +1 -1
  207. package/dist/utilities/workerRequests.js +15 -50
  208. package/package.json +8 -12
  209. package/scripts/integrations/oracle/oracle.md +2 -2
  210. package/scripts/integrations/postgres/init.sql +3 -5
  211. package/scripts/likeCypress.ts +6 -9
  212. package/scripts/proxy/generateProxyConfig.js +70 -0
  213. package/src/api/controllers/application.js +0 -1
  214. package/src/api/controllers/row/ExternalRequest.ts +1 -1
  215. package/src/api/controllers/row/internal.js +0 -4
  216. package/src/api/controllers/table/index.js +1 -2
  217. package/src/api/controllers/webhook.js +6 -3
  218. package/src/api/index.js +1 -4
  219. package/src/api/routes/automation.js +33 -3
  220. package/src/api/routes/datasource.js +52 -6
  221. package/src/api/routes/index.js +0 -2
  222. package/src/api/routes/permission.js +18 -4
  223. package/src/api/routes/role.js +24 -3
  224. package/src/api/routes/row.js +2 -3
  225. package/src/api/routes/screen.js +29 -2
  226. package/src/api/routes/table.js +19 -4
  227. package/src/api/routes/tests/utilities/index.js +0 -24
  228. package/src/api/routes/webhook.js +18 -2
  229. package/src/automations/steps/filter.js +2 -3
  230. package/src/automations/steps/queryRows.js +1 -1
  231. package/src/automations/utils.js +2 -2
  232. package/src/constants/index.js +0 -4
  233. package/src/db/utils.js +0 -12
  234. package/src/definitions/common.ts +0 -4
  235. package/src/environment.js +0 -1
  236. package/src/integrations/base/datasourcePlus.ts +0 -3
  237. package/src/integrations/googlesheets.ts +2 -5
  238. package/src/integrations/microsoftSqlServer.ts +33 -38
  239. package/src/integrations/mysql.ts +0 -4
  240. package/src/integrations/oracle.ts +35 -27
  241. package/src/integrations/postgres.ts +26 -33
  242. package/src/tests/utilities/TestConfiguration.js +2 -23
  243. package/src/threads/query.js +9 -37
  244. package/src/utilities/workerRequests.js +16 -65
  245. package/builder/assets/index.c0b657be.js +0 -1288
  246. package/coverage/lcov-report/api/routes/utils/index.html +0 -111
  247. package/coverage/lcov-report/api/routes/utils/validators.js.html +0 -737
  248. package/dist/api/controllers/public/applications.js +0 -94
  249. package/dist/api/controllers/public/mapping/applications.js +0 -29
  250. package/dist/api/controllers/public/mapping/index.js +0 -11
  251. package/dist/api/controllers/public/mapping/queries.js +0 -36
  252. package/dist/api/controllers/public/mapping/rows.js +0 -24
  253. package/dist/api/controllers/public/mapping/tables.js +0 -23
  254. package/dist/api/controllers/public/mapping/types.js +0 -2
  255. package/dist/api/controllers/public/mapping/users.js +0 -29
  256. package/dist/api/controllers/public/queries.js +0 -38
  257. package/dist/api/controllers/public/rows.js +0 -97
  258. package/dist/api/controllers/public/tables.js +0 -75
  259. package/dist/api/controllers/public/users.js +0 -95
  260. package/dist/api/controllers/public/utils.js +0 -49
  261. package/dist/api/routes/public/applications.js +0 -141
  262. package/dist/api/routes/public/index.js +0 -101
  263. package/dist/api/routes/public/middleware/mapper.js +0 -94
  264. package/dist/api/routes/public/queries.js +0 -77
  265. package/dist/api/routes/public/rows.js +0 -229
  266. package/dist/api/routes/public/tables.js +0 -154
  267. package/dist/api/routes/public/users.js +0 -137
  268. package/dist/api/routes/public/utils/Endpoint.js +0 -36
  269. package/dist/api/routes/utils/validators.js +0 -200
  270. package/dist/definitions/openapi.js +0 -6
  271. package/specs/generate.js +0 -83
  272. package/specs/openapi.json +0 -2222
  273. package/specs/openapi.yaml +0 -1530
  274. package/specs/parameters.js +0 -59
  275. package/specs/resources/application.js +0 -101
  276. package/specs/resources/index.js +0 -24
  277. package/specs/resources/misc.js +0 -12
  278. package/specs/resources/query.js +0 -189
  279. package/specs/resources/row.js +0 -125
  280. package/specs/resources/table.js +0 -191
  281. package/specs/resources/user.js +0 -126
  282. package/specs/resources/utils/Resource.js +0 -26
  283. package/specs/resources/utils/index.js +0 -11
  284. package/specs/security.js +0 -7
  285. package/src/api/controllers/public/applications.ts +0 -74
  286. package/src/api/controllers/public/mapping/applications.ts +0 -32
  287. package/src/api/controllers/public/mapping/index.ts +0 -13
  288. package/src/api/controllers/public/mapping/queries.ts +0 -39
  289. package/src/api/controllers/public/mapping/rows.ts +0 -31
  290. package/src/api/controllers/public/mapping/tables.ts +0 -26
  291. package/src/api/controllers/public/mapping/types.ts +0 -13
  292. package/src/api/controllers/public/mapping/users.ts +0 -32
  293. package/src/api/controllers/public/queries.ts +0 -20
  294. package/src/api/controllers/public/rows.ts +0 -77
  295. package/src/api/controllers/public/tables.ts +0 -56
  296. package/src/api/controllers/public/users.ts +0 -82
  297. package/src/api/controllers/public/utils.ts +0 -38
  298. package/src/api/routes/public/applications.ts +0 -156
  299. package/src/api/routes/public/index.ts +0 -118
  300. package/src/api/routes/public/middleware/mapper.ts +0 -81
  301. package/src/api/routes/public/queries.ts +0 -81
  302. package/src/api/routes/public/rows.ts +0 -242
  303. package/src/api/routes/public/tables.ts +0 -169
  304. package/src/api/routes/public/tests/compare.spec.js +0 -184
  305. package/src/api/routes/public/users.ts +0 -144
  306. package/src/api/routes/public/utils/Endpoint.ts +0 -51
  307. package/src/api/routes/utils/validators.js +0 -219
  308. package/src/definitions/openapi.ts +0 -943
@@ -63,10 +63,32 @@ var MSSQLModule;
63
63
  },
64
64
  },
65
65
  };
66
+ function internalQuery(client, query, operation = undefined) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ const request = client.request();
69
+ try {
70
+ if (Array.isArray(query.bindings)) {
71
+ let count = 0;
72
+ for (let binding of query.bindings) {
73
+ request.input(`p${count++}`, binding);
74
+ }
75
+ }
76
+ // this is a hack to get the inserted ID back,
77
+ // no way to do this with Knex nicely
78
+ const sql = operation === datasource_1.Operation.CREATE
79
+ ? `${query.sql}; SELECT SCOPE_IDENTITY() AS id;`
80
+ : query.sql;
81
+ return yield request.query(sql);
82
+ }
83
+ catch (err) {
84
+ // @ts-ignore
85
+ throw new Error(err);
86
+ }
87
+ });
88
+ }
66
89
  class SqlServerIntegration extends Sql {
67
90
  constructor(config) {
68
91
  super(utils_1.SqlClients.MS_SQL);
69
- this.index = 0;
70
92
  this.tables = {};
71
93
  this.schemaErrors = {};
72
94
  this.MASTER_TABLES = [
@@ -87,31 +109,6 @@ var MSSQLModule;
87
109
  this.pool = new sqlServer.ConnectionPool(clientCfg);
88
110
  }
89
111
  }
90
- internalQuery(query, operation = undefined) {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- const client = this.client;
93
- const request = client.request();
94
- this.index = 0;
95
- try {
96
- if (Array.isArray(query.bindings)) {
97
- let count = 0;
98
- for (let binding of query.bindings) {
99
- request.input(`p${count++}`, binding);
100
- }
101
- }
102
- // this is a hack to get the inserted ID back,
103
- // no way to do this with Knex nicely
104
- const sql = operation === datasource_1.Operation.CREATE
105
- ? `${query.sql}; SELECT SCOPE_IDENTITY() AS id;`
106
- : query.sql;
107
- return yield request.query(sql);
108
- }
109
- catch (err) {
110
- // @ts-ignore
111
- throw new Error(err);
112
- }
113
- });
114
- }
115
112
  getDefinitionSQL(tableName) {
116
113
  return `select *
117
114
  from INFORMATION_SCHEMA.COLUMNS
@@ -137,9 +134,6 @@ var MSSQLModule;
137
134
  FROM INFORMATION_SCHEMA.COLUMNS
138
135
  WHERE TABLE_NAME='${tableName}'`;
139
136
  }
140
- getBindingIdentifier() {
141
- return `(@p${this.index++})`;
142
- }
143
137
  connect() {
144
138
  return __awaiter(this, void 0, void 0, function* () {
145
139
  try {
@@ -153,7 +147,7 @@ var MSSQLModule;
153
147
  }
154
148
  runSQL(sql) {
155
149
  return __awaiter(this, void 0, void 0, function* () {
156
- return (yield this.internalQuery(utils_1.getSqlQuery(sql))).recordset;
150
+ return (yield internalQuery(this.client, utils_1.getSqlQuery(sql))).recordset;
157
151
  });
158
152
  }
159
153
  /**
@@ -213,28 +207,28 @@ var MSSQLModule;
213
207
  read(query) {
214
208
  return __awaiter(this, void 0, void 0, function* () {
215
209
  yield this.connect();
216
- const response = yield this.internalQuery(utils_1.getSqlQuery(query));
210
+ const response = yield internalQuery(this.client, utils_1.getSqlQuery(query));
217
211
  return response.recordset;
218
212
  });
219
213
  }
220
214
  create(query) {
221
215
  return __awaiter(this, void 0, void 0, function* () {
222
216
  yield this.connect();
223
- const response = yield this.internalQuery(utils_1.getSqlQuery(query));
217
+ const response = yield internalQuery(this.client, utils_1.getSqlQuery(query));
224
218
  return response.recordset || [{ created: true }];
225
219
  });
226
220
  }
227
221
  update(query) {
228
222
  return __awaiter(this, void 0, void 0, function* () {
229
223
  yield this.connect();
230
- const response = yield this.internalQuery(utils_1.getSqlQuery(query));
224
+ const response = yield internalQuery(this.client, utils_1.getSqlQuery(query));
231
225
  return response.recordset || [{ updated: true }];
232
226
  });
233
227
  }
234
228
  delete(query) {
235
229
  return __awaiter(this, void 0, void 0, function* () {
236
230
  yield this.connect();
237
- const response = yield this.internalQuery(utils_1.getSqlQuery(query));
231
+ const response = yield internalQuery(this.client, utils_1.getSqlQuery(query));
238
232
  return response.recordset || [{ deleted: true }];
239
233
  });
240
234
  }
@@ -242,7 +236,7 @@ var MSSQLModule;
242
236
  return __awaiter(this, void 0, void 0, function* () {
243
237
  yield this.connect();
244
238
  const operation = this._operation(json);
245
- const queryFn = (query, op) => this.internalQuery(query, op);
239
+ const queryFn = (query, op) => internalQuery(this.client, query, op);
246
240
  const processFn = (result) => result.recordset ? result.recordset : [{ [operation]: true }];
247
241
  return this.queryWithReturning(json, queryFn, processFn);
248
242
  });
@@ -76,9 +76,6 @@ var MySQLModule;
76
76
  }
77
77
  this.config = config;
78
78
  }
79
- getBindingIdentifier() {
80
- return "?";
81
- }
82
79
  connect() {
83
80
  return __awaiter(this, void 0, void 0, function* () {
84
81
  this.client = yield mysql.createConnection(this.config);
@@ -74,7 +74,6 @@ var OracleModule;
74
74
  class OracleIntegration extends sql_1.default {
75
75
  constructor(config) {
76
76
  super(utils_1.SqlClients.ORACLE);
77
- this.index = 1;
78
77
  this.tables = {};
79
78
  this.schemaErrors = {};
80
79
  this.COLUMNS_SQL = `
@@ -117,9 +116,6 @@ var OracleModule;
117
116
  });
118
117
  this.config = config;
119
118
  }
120
- getBindingIdentifier() {
121
- return `:${this.index++}`;
122
- }
123
119
  /**
124
120
  * Map the flat tabular columns and constraints data into a nested object
125
121
  */
@@ -171,18 +167,24 @@ var OracleModule;
171
167
  }
172
168
  return oracleTables;
173
169
  }
174
- static isSupportedColumn(column) {
175
- return !UNSUPPORTED_TYPES.includes(column.type);
170
+ isSupportedColumn(column) {
171
+ if (UNSUPPORTED_TYPES.includes(column.type)) {
172
+ return false;
173
+ }
174
+ return true;
176
175
  }
177
- static isAutoColumn(column) {
178
- return !!(column.default && column.default.toLowerCase().includes("nextval"));
176
+ isAutoColumn(column) {
177
+ if (column.default && column.default.toLowerCase().includes("nextval")) {
178
+ return true;
179
+ }
180
+ return false;
179
181
  }
180
182
  /**
181
183
  * No native boolean in oracle. Best we can do is to check if a manual 1 or 0 number constraint has been set up
182
184
  * This matches the default behaviour for generating DDL used in knex.
183
185
  */
184
186
  isBooleanType(column) {
185
- return (column.type.toLowerCase() === "number" &&
187
+ if (column.type.toLowerCase() === "number" &&
186
188
  Object.values(column.constraints).filter(c => {
187
189
  if (c.type === OracleContraintTypes.NOT_NULL_OR_CHECK &&
188
190
  c.searchCondition) {
@@ -195,7 +197,10 @@ var OracleModule;
195
197
  }
196
198
  }
197
199
  return false;
198
- }).length > 0);
200
+ }).length > 0) {
201
+ return true;
202
+ }
203
+ return false;
199
204
  }
200
205
  internalConvertType(column) {
201
206
  if (this.isBooleanType(column)) {
@@ -230,7 +235,7 @@ var OracleModule;
230
235
  // iterate each column on the table
231
236
  Object.values(oracleTable.columns)
232
237
  // remove columns that we can't read / save
233
- .filter(oracleColumn => OracleIntegration.isSupportedColumn(oracleColumn))
238
+ .filter(oracleColumn => this.isSupportedColumn(oracleColumn))
234
239
  // match the order of the columns in the db
235
240
  .sort((c1, c2) => c1.id - c2.id)
236
241
  .forEach(oracleColumn => {
@@ -238,7 +243,7 @@ var OracleModule;
238
243
  let fieldSchema = table.schema[columnName];
239
244
  if (!fieldSchema) {
240
245
  fieldSchema = {
241
- autocolumn: OracleIntegration.isAutoColumn(oracleColumn),
246
+ autocolumn: this.isAutoColumn(oracleColumn),
242
247
  name: columnName,
243
248
  type: this.internalConvertType(oracleColumn),
244
249
  };
@@ -261,11 +266,11 @@ var OracleModule;
261
266
  return __awaiter(this, void 0, void 0, function* () {
262
267
  let connection;
263
268
  try {
264
- this.index = 1;
265
269
  connection = yield this.getConnection();
266
270
  const options = { autoCommit: true };
267
271
  const bindings = query.bindings || [];
268
- return yield connection.execute(query.sql, bindings, options);
272
+ const result = yield connection.execute(query.sql, bindings, options);
273
+ return result;
269
274
  }
270
275
  finally {
271
276
  if (connection) {
@@ -84,10 +84,31 @@ var PostgresModule;
84
84
  },
85
85
  },
86
86
  };
87
+ function internalQuery(client, query) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ // need to handle a specific issue with json data types in postgres,
90
+ // new lines inside the JSON data will break it
91
+ if (query && query.sql) {
92
+ const matches = query.sql.match(JSON_REGEX);
93
+ if (matches && matches.length > 0) {
94
+ for (let match of matches) {
95
+ const escaped = escapeDangerousCharacters(match);
96
+ query.sql = query.sql.replace(match, escaped);
97
+ }
98
+ }
99
+ }
100
+ try {
101
+ return yield client.query(query.sql, query.bindings || []);
102
+ }
103
+ catch (err) {
104
+ // @ts-ignore
105
+ throw new Error(err);
106
+ }
107
+ });
108
+ }
87
109
  class PostgresIntegration extends Sql {
88
110
  constructor(config) {
89
111
  super(utils_1.SqlClients.POSTGRES);
90
- this.index = 1;
91
112
  this.tables = {};
92
113
  this.schemaErrors = {};
93
114
  this.PRIMARY_KEYS_SQL = `
@@ -112,33 +133,6 @@ var PostgresModule;
112
133
  this.client = this.pool;
113
134
  this.setSchema();
114
135
  }
115
- getBindingIdentifier() {
116
- return `$${this.index++}`;
117
- }
118
- internalQuery(query) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- const client = this.client;
121
- this.index = 1;
122
- // need to handle a specific issue with json data types in postgres,
123
- // new lines inside the JSON data will break it
124
- if (query && query.sql) {
125
- const matches = query.sql.match(JSON_REGEX);
126
- if (matches && matches.length > 0) {
127
- for (let match of matches) {
128
- const escaped = escapeDangerousCharacters(match);
129
- query.sql = query.sql.replace(match, escaped);
130
- }
131
- }
132
- }
133
- try {
134
- return yield client.query(query.sql, query.bindings || []);
135
- }
136
- catch (err) {
137
- // @ts-ignore
138
- throw new Error(err);
139
- }
140
- });
141
- }
142
136
  setSchema() {
143
137
  if (!this.config.schema) {
144
138
  this.config.schema = "public";
@@ -208,25 +202,25 @@ var PostgresModule;
208
202
  }
209
203
  create(query) {
210
204
  return __awaiter(this, void 0, void 0, function* () {
211
- const response = yield this.internalQuery(utils_1.getSqlQuery(query));
205
+ const response = yield internalQuery(this.client, utils_1.getSqlQuery(query));
212
206
  return response.rows.length ? response.rows : [{ created: true }];
213
207
  });
214
208
  }
215
209
  read(query) {
216
210
  return __awaiter(this, void 0, void 0, function* () {
217
- const response = yield this.internalQuery(utils_1.getSqlQuery(query));
211
+ const response = yield internalQuery(this.client, utils_1.getSqlQuery(query));
218
212
  return response.rows;
219
213
  });
220
214
  }
221
215
  update(query) {
222
216
  return __awaiter(this, void 0, void 0, function* () {
223
- const response = yield this.internalQuery(utils_1.getSqlQuery(query));
217
+ const response = yield internalQuery(this.client, utils_1.getSqlQuery(query));
224
218
  return response.rows.length ? response.rows : [{ updated: true }];
225
219
  });
226
220
  }
227
221
  delete(query) {
228
222
  return __awaiter(this, void 0, void 0, function* () {
229
- const response = yield this.internalQuery(utils_1.getSqlQuery(query));
223
+ const response = yield internalQuery(this.client, utils_1.getSqlQuery(query));
230
224
  return response.rows.length ? response.rows : [{ deleted: true }];
231
225
  });
232
226
  }
@@ -237,12 +231,12 @@ var PostgresModule;
237
231
  if (Array.isArray(input)) {
238
232
  const responses = [];
239
233
  for (let query of input) {
240
- responses.push(yield this.internalQuery(query));
234
+ responses.push(yield internalQuery(this.client, query));
241
235
  }
242
236
  return responses;
243
237
  }
244
238
  else {
245
- const response = yield this.internalQuery(input);
239
+ const response = yield internalQuery(this.client, input);
246
240
  return response.rows.length ? response.rows : [{ [operation]: true }];
247
241
  }
248
242
  });
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "1.0.80-alpha.0",
4
+ "version": "1.0.79",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -21,8 +21,10 @@
21
21
  "dev:stack:down": "node scripts/dev/manage.js down",
22
22
  "dev:stack:nuke": "node scripts/dev/manage.js nuke",
23
23
  "dev:builder": "yarn run dev:stack:up && nodemon",
24
+ "generate:proxy:compose": "node scripts/proxy/generateProxyConfig compose",
25
+ "generate:proxy:preprod": "node scripts/proxy/generateProxyConfig preprod",
26
+ "generate:proxy:prod": "node scripts/proxy/generateProxyConfig prod",
24
27
  "format": "prettier --config ../../.prettierrc.json 'src/**/*.ts' --write",
25
- "specs": "node specs/generate.js && openapi-typescript specs/openapi.yaml --output src/definitions/openapi.ts",
26
28
  "lint": "eslint --fix src/",
27
29
  "lint:fix": "yarn run format && yarn run lint",
28
30
  "initialise": "node scripts/initialise.js",
@@ -71,9 +73,9 @@
71
73
  "license": "GPL-3.0",
72
74
  "dependencies": {
73
75
  "@apidevtools/swagger-parser": "^10.0.3",
74
- "@budibase/backend-core": "^1.0.80-alpha.0",
75
- "@budibase/client": "^1.0.80-alpha.0",
76
- "@budibase/string-templates": "^1.0.80-alpha.0",
76
+ "@budibase/backend-core": "^1.0.79",
77
+ "@budibase/client": "^1.0.79",
78
+ "@budibase/string-templates": "^1.0.79",
77
79
  "@bull-board/api": "^3.7.0",
78
80
  "@bull-board/koa": "^3.7.0",
79
81
  "@elastic/elasticsearch": "7.10.0",
@@ -108,7 +110,6 @@
108
110
  "koa-send": "5.0.0",
109
111
  "koa-session": "5.12.0",
110
112
  "koa-static": "5.0.0",
111
- "koa2-ratelimit": "^1.1.0",
112
113
  "lodash": "4.17.21",
113
114
  "memorystream": "^0.3.1",
114
115
  "mongodb": "3.6.3",
@@ -124,7 +125,6 @@
124
125
  "pouchdb-all-dbs": "1.0.2",
125
126
  "pouchdb-find": "^7.2.2",
126
127
  "pouchdb-replication-stream": "1.2.9",
127
- "redis": "4",
128
128
  "server-destroy": "1.0.1",
129
129
  "svelte": "^3.38.2",
130
130
  "swagger-parser": "^10.0.3",
@@ -150,7 +150,6 @@
150
150
  "@types/koa-router": "^7.4.2",
151
151
  "@types/node": "^15.12.4",
152
152
  "@types/oracledb": "^5.2.1",
153
- "@types/redis": "^4.0.11",
154
153
  "@typescript-eslint/parser": "4.28.0",
155
154
  "apidoc": "^0.50.2",
156
155
  "babel-jest": "^27.0.2",
@@ -158,15 +157,12 @@
158
157
  "docker-compose": "^0.23.6",
159
158
  "eslint": "^6.8.0",
160
159
  "jest": "^27.0.5",
161
- "jest-openapi": "^0.14.2",
162
160
  "nodemon": "^2.0.4",
163
161
  "openapi-types": "^9.3.1",
164
- "openapi-typescript": "^5.2.0",
165
162
  "path-to-regexp": "^6.2.0",
166
163
  "prettier": "^2.3.1",
167
164
  "rimraf": "^3.0.2",
168
165
  "supertest": "^4.0.2",
169
- "swagger-jsdoc": "^6.1.0",
170
166
  "ts-jest": "^27.0.3",
171
167
  "ts-node": "^10.0.0",
172
168
  "typescript": "^4.3.5",
@@ -24,8 +24,6 @@ const { createASession } = require("@budibase/backend-core/sessions");
24
24
  const { user: userCache } = require("@budibase/backend-core/cache");
25
25
  const newid = require("../../db/newid");
26
26
  const context = require("@budibase/backend-core/context");
27
- const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db");
28
- const { encrypt } = require("@budibase/backend-core/encryption");
29
27
  const GLOBAL_USER_ID = "us_uuid1";
30
28
  const EMAIL = "babs@babs.com";
31
29
  const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306";
@@ -44,9 +42,6 @@ class TestConfiguration {
44
42
  getRequest() {
45
43
  return this.request;
46
44
  }
47
- getApp() {
48
- return this.app;
49
- }
50
45
  getAppId() {
51
46
  return this.appId;
52
47
  }
@@ -85,22 +80,6 @@ class TestConfiguration {
85
80
  }
86
81
  });
87
82
  }
88
- generateApiKey(userId = GLOBAL_USER_ID) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- const db = getGlobalDB(TENANT_ID);
91
- const id = generateDevInfoID(userId);
92
- let devInfo;
93
- try {
94
- devInfo = yield db.get(id);
95
- }
96
- catch (err) {
97
- devInfo = { _id: id, userId };
98
- }
99
- devInfo.apiKey = encrypt(`${TENANT_ID}${SEPARATOR}${newid()}`);
100
- yield db.put(devInfo);
101
- return devInfo.apiKey;
102
- });
103
- }
104
83
  globalUser({ id = GLOBAL_USER_ID, builder = true, email = EMAIL, roles, } = {}) {
105
84
  return __awaiter(this, void 0, void 0, function* () {
106
85
  const db = getGlobalDB(TENANT_ID);
@@ -143,7 +122,7 @@ class TestConfiguration {
143
122
  }
144
123
  cleanup(this.allApps.map(app => app.appId));
145
124
  }
146
- defaultHeaders(extras = {}) {
125
+ defaultHeaders() {
147
126
  const auth = {
148
127
  userId: GLOBAL_USER_ID,
149
128
  sessionId: "sessionid",
@@ -155,10 +134,14 @@ class TestConfiguration {
155
134
  };
156
135
  const authToken = jwt.sign(auth, env.JWT_SECRET);
157
136
  const appToken = jwt.sign(app, env.JWT_SECRET);
158
- const headers = Object.assign({ Accept: "application/json", Cookie: [
137
+ const headers = {
138
+ Accept: "application/json",
139
+ Cookie: [
159
140
  `${Cookies.Auth}=${authToken}`,
160
141
  `${Cookies.CurrentApp}=${appToken}`,
161
- ], [Headers.CSRF_TOKEN]: CSRF_TOKEN }, extras);
142
+ ],
143
+ [Headers.CSRF_TOKEN]: CSRF_TOKEN,
144
+ };
162
145
  if (this.appId) {
163
146
  headers[Headers.APP_ID] = this.appId;
164
147
  }
@@ -221,7 +204,7 @@ class TestConfiguration {
221
204
  getTable(tableId = null) {
222
205
  return __awaiter(this, void 0, void 0, function* () {
223
206
  tableId = tableId || this.table._id;
224
- return this._req(null, { tableId }, controllers.table.find);
207
+ return this._req(null, { id: tableId }, controllers.table.find);
225
208
  });
226
209
  }
227
210
  createLinkedTable(relationshipType = null, links = ["link"]) {
@@ -12,9 +12,8 @@ const threadUtils = require("./utils");
12
12
  threadUtils.threadSetup();
13
13
  const ScriptRunner = require("../utilities/scriptRunner");
14
14
  const { integrations } = require("../integrations");
15
- const { processStringSync, findHBSBlocks, } = require("@budibase/string-templates");
15
+ const { processStringSync } = require("@budibase/string-templates");
16
16
  const { doInAppContext, getAppDB } = require("@budibase/backend-core/context");
17
- const { isSQL } = require("../integrations/utils");
18
17
  class QueryRunner {
19
18
  constructor(input, flags = { noRecursiveQuery: false }) {
20
19
  this.datasource = input.datasource;
@@ -32,45 +31,21 @@ class QueryRunner {
32
31
  this.queryResponse = {};
33
32
  this.hasRerun = false;
34
33
  }
35
- interpolateSQL(fields, parameters, integration) {
36
- let sql = fields.sql;
37
- if (!sql) {
38
- return fields;
39
- }
40
- const bindings = findHBSBlocks(sql);
41
- let variables = [];
42
- for (let binding of bindings) {
43
- let variable = integration.getBindingIdentifier();
44
- variables.push(binding);
45
- sql = sql.replace(binding, variable);
46
- }
47
- // replicate the knex structure
48
- fields.sql = sql;
49
- fields.bindings = this.enrichQueryFields(variables, parameters);
50
- return fields;
51
- }
52
34
  execute() {
53
35
  return __awaiter(this, void 0, void 0, function* () {
54
36
  let { datasource, fields, queryVerb, transformer } = this;
55
- const Integration = integrations[datasource.source];
56
- if (!Integration) {
57
- throw "Integration type does not exist.";
58
- }
59
- const integration = new Integration(datasource.config);
60
37
  // pre-query, make sure datasource variables are added to parameters
61
38
  const parameters = yield this.addDatasourceVariables();
62
- let query;
63
- // handle SQL injections by interpolating the variables
64
- if (isSQL(datasource)) {
65
- query = this.interpolateSQL(fields, parameters, integration);
66
- }
67
- else {
68
- query = this.enrichQueryFields(fields, parameters);
69
- }
39
+ let query = this.enrichQueryFields(fields, parameters);
70
40
  // Add pagination values for REST queries
71
41
  if (this.pagination) {
72
42
  query.paginationValues = this.pagination;
73
43
  }
44
+ const Integration = integrations[datasource.source];
45
+ if (!Integration) {
46
+ throw "Integration type does not exist.";
47
+ }
48
+ const integration = new Integration(datasource.config);
74
49
  let output = threadUtils.formatResponse(yield integration[queryVerb](query));
75
50
  let rows = output, info = undefined, extra = undefined, pagination = undefined;
76
51
  if (threadUtils.hasExtraData(output)) {
@@ -193,7 +168,7 @@ class QueryRunner {
193
168
  });
194
169
  }
195
170
  enrichQueryFields(fields, parameters = {}) {
196
- const enrichedQuery = Array.isArray(fields) ? [] : {};
171
+ const enrichedQuery = {};
197
172
  // enrich the fields with dynamic parameters
198
173
  for (let key of Object.keys(fields)) {
199
174
  if (fields[key] == null) {