@budibase/server 1.0.113 → 1.0.114

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 (186) hide show
  1. package/builder/assets/{index.e3e5909b.js → index.4cdeec28.js} +4 -4
  2. package/builder/index.html +1 -1
  3. package/coverage/clover.xml +105 -150
  4. package/coverage/coverage-final.json +2 -2
  5. package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
  6. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  7. package/coverage/lcov-report/api/controllers/application.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/index.html +1 -1
  16. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/index.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/row/staticFormula.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/bulkFormula.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  38. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/table/internal.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/table/utils.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  42. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  44. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  45. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  46. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  47. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  48. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  49. package/coverage/lcov-report/api/index.html +1 -1
  50. package/coverage/lcov-report/api/index.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/application.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/index.html +1 -1
  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/migrations.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/row.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  75. package/coverage/lcov-report/api/routes/static.js.html +1 -1
  76. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  77. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  78. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  79. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  80. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  81. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  82. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  83. package/coverage/lcov-report/automations/actions.js.html +1 -1
  84. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  85. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  86. package/coverage/lcov-report/automations/index.html +1 -1
  87. package/coverage/lcov-report/automations/index.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/index.html +1 -1
  97. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  98. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  99. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  100. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  101. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  102. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  103. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  104. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  105. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  106. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  107. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  108. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  109. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  110. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  111. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  112. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  113. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  114. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  115. package/coverage/lcov-report/automations/utils.js.html +1 -1
  116. package/coverage/lcov-report/constants/index.html +1 -1
  117. package/coverage/lcov-report/constants/index.js.html +1 -1
  118. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  119. package/coverage/lcov-report/constants/screens.js.html +1 -1
  120. package/coverage/lcov-report/db/client.js.html +1 -1
  121. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  122. package/coverage/lcov-report/db/index.html +1 -1
  123. package/coverage/lcov-report/db/index.js.html +1 -1
  124. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  125. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  126. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  127. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  128. package/coverage/lcov-report/db/newid.js.html +1 -1
  129. package/coverage/lcov-report/db/utils.js.html +1 -1
  130. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  131. package/coverage/lcov-report/events/index.html +1 -1
  132. package/coverage/lcov-report/events/index.js.html +1 -1
  133. package/coverage/lcov-report/events/utils.js.html +1 -1
  134. package/coverage/lcov-report/index.html +20 -20
  135. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  136. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  137. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  138. package/coverage/lcov-report/middleware/authorized.js.html +1 -1
  139. package/coverage/lcov-report/middleware/builder.js.html +1 -1
  140. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  141. package/coverage/lcov-report/middleware/index.html +1 -1
  142. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  143. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  144. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  145. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  146. package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
  147. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  148. package/coverage/lcov-report/threads/automation.js.html +1 -1
  149. package/coverage/lcov-report/threads/index.html +29 -29
  150. package/coverage/lcov-report/threads/index.js.html +27 -9
  151. package/coverage/lcov-report/threads/query.js.html +20 -356
  152. package/coverage/lcov-report/threads/utils.js.html +1 -1
  153. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  154. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  155. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  156. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  157. package/coverage/lcov-report/utilities/global.js.html +1 -1
  158. package/coverage/lcov-report/utilities/index.html +1 -1
  159. package/coverage/lcov-report/utilities/index.js.html +1 -1
  160. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  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 +1 -1
  164. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  165. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  166. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  167. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  168. package/coverage/lcov-report/utilities/security.js.html +1 -1
  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 +1 -1
  172. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  173. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  174. package/coverage/lcov-report/utilities/users.js.html +1 -1
  175. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  176. package/coverage/lcov.info +185 -263
  177. package/dist/integrations/queries/sql.js +108 -0
  178. package/dist/package.json +4 -4
  179. package/dist/threads/index.js +6 -1
  180. package/dist/threads/query.js +4 -103
  181. package/dist/tsconfig.tsbuildinfo +1 -1
  182. package/package.json +5 -5
  183. package/scripts/integrations/mysql/init.sql +1 -0
  184. package/src/integrations/queries/sql.ts +125 -0
  185. package/src/threads/index.js +7 -1
  186. package/src/threads/query.js +7 -119
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.interpolateSQL = exports.enrichQueryFields = void 0;
4
+ const string_templates_1 = require("@budibase/string-templates");
5
+ const CONST_CHAR_REGEX = new RegExp("'[^']*'", "g");
6
+ function enrichQueryFields(fields, parameters = {}) {
7
+ const enrichedQuery = Array.isArray(fields) ? [] : {};
8
+ // enrich the fields with dynamic parameters
9
+ for (let key of Object.keys(fields)) {
10
+ if (fields[key] == null) {
11
+ continue;
12
+ }
13
+ if (typeof fields[key] === "object") {
14
+ // enrich nested fields object
15
+ enrichedQuery[key] = enrichQueryFields(fields[key], parameters);
16
+ }
17
+ else if (typeof fields[key] === "string") {
18
+ // enrich string value as normal
19
+ enrichedQuery[key] = string_templates_1.processStringSync(fields[key], parameters, {
20
+ noEscaping: true,
21
+ noHelpers: true,
22
+ escapeNewlines: true,
23
+ });
24
+ }
25
+ else {
26
+ enrichedQuery[key] = fields[key];
27
+ }
28
+ }
29
+ if (enrichedQuery.json ||
30
+ enrichedQuery.customData ||
31
+ enrichedQuery.requestBody) {
32
+ try {
33
+ enrichedQuery.json = JSON.parse(enrichedQuery.json ||
34
+ enrichedQuery.customData ||
35
+ enrichedQuery.requestBody);
36
+ }
37
+ catch (err) {
38
+ // no json found, ignore
39
+ }
40
+ delete enrichedQuery.customData;
41
+ }
42
+ return enrichedQuery;
43
+ }
44
+ exports.enrichQueryFields = enrichQueryFields;
45
+ function interpolateSQL(fields, parameters, integration) {
46
+ let sql = fields.sql;
47
+ if (!sql || typeof sql !== "string") {
48
+ return fields;
49
+ }
50
+ const bindings = string_templates_1.findHBSBlocks(sql);
51
+ let variables = [], arrays = [];
52
+ for (let binding of bindings) {
53
+ // look for array/list operations in the SQL statement, which will need handled later
54
+ const listRegexMatch = sql.match(new RegExp(`(in|IN|In|iN)( )+[(]?${binding}[)]?`));
55
+ // check if the variable was used as part of a string concat e.g. 'Hello {{binding}}'
56
+ // start by finding all the instances of const character strings
57
+ const charConstMatch = sql.match(CONST_CHAR_REGEX) || [];
58
+ // now look within them to see if a binding is used
59
+ const charConstBindingMatch = charConstMatch.find((string) => string.match(new RegExp(`'[^']*${binding}[^']*'`)));
60
+ if (charConstBindingMatch) {
61
+ let [part1, part2] = charConstBindingMatch.split(binding);
62
+ part1 = `'${part1.substring(1)}'`;
63
+ part2 = `'${part2.substring(0, part2.length - 1)}'`;
64
+ sql = sql.replace(charConstBindingMatch, integration.getStringConcat([
65
+ part1,
66
+ integration.getBindingIdentifier(),
67
+ part2,
68
+ ]));
69
+ }
70
+ // generate SQL parameterised array
71
+ else if (listRegexMatch) {
72
+ arrays.push(binding);
73
+ // determine the length of the array
74
+ const value = enrichQueryFields([binding], parameters)[0]
75
+ .split(",")
76
+ .map((val) => val.trim());
77
+ // build a string like ($1, $2, $3)
78
+ let replacement = `${Array.apply(null, Array(value.length))
79
+ .map(() => integration.getBindingIdentifier())
80
+ .join(",")}`;
81
+ // check if parentheses are needed
82
+ if (!listRegexMatch[0].includes(`(${binding})`)) {
83
+ replacement = `(${replacement})`;
84
+ }
85
+ sql = sql.replace(binding, replacement);
86
+ }
87
+ else {
88
+ sql = sql.replace(binding, integration.getBindingIdentifier());
89
+ }
90
+ variables.push(binding);
91
+ }
92
+ // replicate the knex structure
93
+ fields.sql = sql;
94
+ fields.bindings = enrichQueryFields(variables, parameters);
95
+ // check for arrays in the data
96
+ let updated = [];
97
+ for (let i = 0; i < variables.length; i++) {
98
+ if (arrays.includes(variables[i])) {
99
+ updated = updated.concat(fields.bindings[i].split(",").map((val) => val.trim()));
100
+ }
101
+ else {
102
+ updated.push(fields.bindings[i]);
103
+ }
104
+ }
105
+ fields.bindings = updated;
106
+ return fields;
107
+ }
108
+ exports.interpolateSQL = interpolateSQL;
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.112",
4
+ "version": "1.0.113",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -68,9 +68,9 @@
68
68
  "license": "GPL-3.0",
69
69
  "dependencies": {
70
70
  "@apidevtools/swagger-parser": "^10.0.3",
71
- "@budibase/backend-core": "^1.0.112",
72
- "@budibase/client": "^1.0.112",
73
- "@budibase/string-templates": "^1.0.112",
71
+ "@budibase/backend-core": "^1.0.113",
72
+ "@budibase/client": "^1.0.113",
73
+ "@budibase/string-templates": "^1.0.113",
74
74
  "@bull-board/api": "^3.7.0",
75
75
  "@bull-board/koa": "^3.7.0",
76
76
  "@elastic/elasticsearch": "7.10.0",
@@ -34,12 +34,14 @@ class Thread {
34
34
  maxConcurrentWorkers: this.count,
35
35
  };
36
36
  if (opts.timeoutMs) {
37
+ this.timeoutMs = opts.timeoutMs;
37
38
  workerOpts.maxCallTime = opts.timeoutMs;
38
39
  }
39
40
  this.workers = workerFarm(workerOpts, typeToFile(type));
40
41
  }
41
42
  }
42
43
  run(data) {
44
+ const timeoutMs = this.timeoutMs;
43
45
  return new Promise((resolve, reject) => {
44
46
  let fncToCall;
45
47
  // if in test then don't use threading
@@ -50,7 +52,10 @@ class Thread {
50
52
  fncToCall = this.workers;
51
53
  }
52
54
  fncToCall(data, (err, response) => {
53
- if (err) {
55
+ if (err && err.type === "TimeoutError") {
56
+ reject(new Error(`Query response time exceeded ${timeoutMs}ms timeout.`));
57
+ }
58
+ else if (err) {
54
59
  reject(err);
55
60
  }
56
61
  else {
@@ -12,10 +12,10 @@ 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
17
  const { isSQL } = require("../integrations/utils");
18
- const CONST_CHAR_REGEX = new RegExp("'[^']*'", "g");
18
+ const { enrichQueryFields, interpolateSQL, } = require("../integrations/queries/sql");
19
19
  class QueryRunner {
20
20
  constructor(input, flags = { noRecursiveQuery: false }) {
21
21
  this.datasource = input.datasource;
@@ -33,67 +33,6 @@ class QueryRunner {
33
33
  this.queryResponse = {};
34
34
  this.hasRerun = false;
35
35
  }
36
- interpolateSQL(fields, parameters, integration) {
37
- let sql = fields.sql;
38
- if (!sql) {
39
- return fields;
40
- }
41
- const bindings = findHBSBlocks(sql);
42
- let variables = [], arrays = [];
43
- for (let binding of bindings) {
44
- // look for array/list operations in the SQL statement, which will need handled later
45
- const listRegexMatch = sql.match(new RegExp(`(in|IN|In|iN)( )+[(]?${binding}[)]?`));
46
- // check if the variable was used as part of a string concat e.g. 'Hello {{binding}}'
47
- // start by finding all the instances of const character strings
48
- const charConstMatch = sql.match(CONST_CHAR_REGEX) || [];
49
- // now look within them to see if a binding is used
50
- const charConstBindingMatch = charConstMatch.find(string => string.match(new RegExp(`'[^']*${binding}[^']*'`)));
51
- if (charConstBindingMatch) {
52
- let [part1, part2] = charConstBindingMatch.split(binding);
53
- part1 = `'${part1.substring(1)}'`;
54
- part2 = `'${part2.substring(0, part2.length - 1)}'`;
55
- sql = sql.replace(charConstBindingMatch, integration.getStringConcat([
56
- part1,
57
- integration.getBindingIdentifier(),
58
- part2,
59
- ]));
60
- }
61
- // generate SQL parameterised array
62
- else if (listRegexMatch) {
63
- arrays.push(binding);
64
- // determine the length of the array
65
- const value = this.enrichQueryFields([binding], parameters)[0].split(",");
66
- // build a string like ($1, $2, $3)
67
- let replacement = `${Array.apply(null, Array(value.length))
68
- .map(() => integration.getBindingIdentifier())
69
- .join(",")}`;
70
- // check if parentheses are needed
71
- if (!listRegexMatch[0].includes(`(${binding})`)) {
72
- replacement = `(${replacement})`;
73
- }
74
- sql = sql.replace(binding, replacement);
75
- }
76
- else {
77
- sql = sql.replace(binding, integration.getBindingIdentifier());
78
- }
79
- variables.push(binding);
80
- }
81
- // replicate the knex structure
82
- fields.sql = sql;
83
- fields.bindings = this.enrichQueryFields(variables, parameters);
84
- // check for arrays in the data
85
- let updated = [];
86
- for (let i = 0; i < variables.length; i++) {
87
- if (arrays.includes(variables[i])) {
88
- updated = updated.concat(fields.bindings[i].split(","));
89
- }
90
- else {
91
- updated.push(fields.bindings[i]);
92
- }
93
- }
94
- fields.bindings = updated;
95
- return fields;
96
- }
97
36
  execute() {
98
37
  return __awaiter(this, void 0, void 0, function* () {
99
38
  let { datasource, fields, queryVerb, transformer } = this;
@@ -107,10 +46,10 @@ class QueryRunner {
107
46
  let query;
108
47
  // handle SQL injections by interpolating the variables
109
48
  if (isSQL(datasource)) {
110
- query = this.interpolateSQL(fields, parameters, integration);
49
+ query = interpolateSQL(fields, parameters, integration);
111
50
  }
112
51
  else {
113
- query = this.enrichQueryFields(fields, parameters);
52
+ query = enrichQueryFields(fields, parameters);
114
53
  }
115
54
  // Add pagination values for REST queries
116
55
  if (this.pagination) {
@@ -237,44 +176,6 @@ class QueryRunner {
237
176
  return parameters;
238
177
  });
239
178
  }
240
- enrichQueryFields(fields, parameters = {}) {
241
- const enrichedQuery = Array.isArray(fields) ? [] : {};
242
- // enrich the fields with dynamic parameters
243
- for (let key of Object.keys(fields)) {
244
- if (fields[key] == null) {
245
- continue;
246
- }
247
- if (typeof fields[key] === "object") {
248
- // enrich nested fields object
249
- enrichedQuery[key] = this.enrichQueryFields(fields[key], parameters);
250
- }
251
- else if (typeof fields[key] === "string") {
252
- // enrich string value as normal
253
- enrichedQuery[key] = processStringSync(fields[key], parameters, {
254
- noEscaping: true,
255
- noHelpers: true,
256
- escapeNewlines: true,
257
- });
258
- }
259
- else {
260
- enrichedQuery[key] = fields[key];
261
- }
262
- }
263
- if (enrichedQuery.json ||
264
- enrichedQuery.customData ||
265
- enrichedQuery.requestBody) {
266
- try {
267
- enrichedQuery.json = JSON.parse(enrichedQuery.json ||
268
- enrichedQuery.customData ||
269
- enrichedQuery.requestBody);
270
- }
271
- catch (err) {
272
- // no json found, ignore
273
- }
274
- delete enrichedQuery.customData;
275
- }
276
- return enrichedQuery;
277
- }
278
179
  }
279
180
  module.exports = (input, callback) => {
280
181
  doInAppContext(input.appId, () => {