@budibase/server 1.0.115 → 1.0.118

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 (235) hide show
  1. package/builder/assets/{index.dae9f8cf.js → index.b1f26359.js} +2 -2
  2. package/builder/index.html +1 -1
  3. package/coverage/clover.xml +1113 -1125
  4. package/coverage/coverage-final.json +85 -86
  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 +126 -120
  8. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
  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 +16 -16
  14. package/coverage/lcov-report/api/controllers/dev.js.html +23 -14
  15. package/coverage/lcov-report/api/controllers/index.html +17 -17
  16. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
  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 +15 -15
  21. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/index.js.html +19 -19
  23. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/role.js.html +9 -9
  25. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/external.js.html +19 -19
  27. package/coverage/lcov-report/api/controllers/row/index.html +10 -10
  28. package/coverage/lcov-report/api/controllers/row/index.js.html +14 -14
  29. package/coverage/lcov-report/api/controllers/row/internal.js.html +37 -34
  30. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +9 -9
  31. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +10 -10
  32. package/coverage/lcov-report/api/controllers/row/utils.js.html +12 -12
  33. package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
  34. package/coverage/lcov-report/api/controllers/script.js.html +4 -4
  35. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +9 -9
  36. package/coverage/lcov-report/api/controllers/table/external.js.html +12 -12
  37. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  38. package/coverage/lcov-report/api/controllers/table/index.js.html +14 -14
  39. package/coverage/lcov-report/api/controllers/table/internal.js.html +13 -13
  40. package/coverage/lcov-report/api/controllers/table/utils.js.html +30 -30
  41. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  42. package/coverage/lcov-report/api/controllers/user.js.html +19 -19
  43. package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
  44. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  45. package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
  46. package/coverage/lcov-report/api/controllers/view/utils.js.html +12 -12
  47. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
  48. package/coverage/lcov-report/api/controllers/webhook.js.html +17 -17
  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 +24 -24
  84. package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
  85. package/coverage/lcov-report/automations/bullboard.js.html +16 -16
  86. package/coverage/lcov-report/automations/index.html +5 -5
  87. package/coverage/lcov-report/automations/index.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/bash.js.html +7 -7
  89. package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
  90. package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
  91. package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
  92. package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
  93. package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
  94. package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
  95. package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
  96. package/coverage/lcov-report/automations/steps/index.html +1 -1
  97. package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
  98. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
  99. package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
  100. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
  101. package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
  102. package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
  103. package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
  104. package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
  105. package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
  106. package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
  107. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
  108. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  109. package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
  110. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
  111. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
  112. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
  113. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
  114. package/coverage/lcov-report/automations/triggers.js.html +18 -18
  115. package/coverage/lcov-report/automations/utils.js.html +43 -40
  116. package/coverage/lcov-report/constants/index.html +1 -1
  117. package/coverage/lcov-report/constants/index.js.html +27 -27
  118. package/coverage/lcov-report/constants/layouts.js.html +5 -5
  119. package/coverage/lcov-report/constants/screens.js.html +4 -4
  120. package/coverage/lcov-report/db/inMemoryView.js.html +52 -49
  121. package/coverage/lcov-report/db/index.html +21 -36
  122. package/coverage/lcov-report/db/index.js.html +49 -10
  123. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +7 -7
  124. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  125. package/coverage/lcov-report/db/linkedRows/index.js.html +18 -18
  126. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +13 -13
  127. package/coverage/lcov-report/db/newid.js.html +2 -2
  128. package/coverage/lcov-report/db/utils.js.html +13 -13
  129. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  130. package/coverage/lcov-report/events/index.html +1 -1
  131. package/coverage/lcov-report/events/index.js.html +5 -5
  132. package/coverage/lcov-report/events/utils.js.html +3 -3
  133. package/coverage/lcov-report/index.html +46 -46
  134. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  135. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  136. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  137. package/coverage/lcov-report/middleware/authorized.js.html +1 -1
  138. package/coverage/lcov-report/middleware/builder.js.html +15 -12
  139. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  140. package/coverage/lcov-report/middleware/index.html +4 -4
  141. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  142. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  143. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  144. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  145. package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
  146. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  147. package/coverage/lcov-report/threads/automation.js.html +1 -1
  148. package/coverage/lcov-report/threads/index.html +10 -10
  149. package/coverage/lcov-report/threads/index.js.html +10 -10
  150. package/coverage/lcov-report/threads/query.js.html +1 -1
  151. package/coverage/lcov-report/threads/utils.js.html +19 -22
  152. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  153. package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
  154. package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
  155. package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
  156. package/coverage/lcov-report/utilities/global.js.html +15 -15
  157. package/coverage/lcov-report/utilities/index.html +1 -1
  158. package/coverage/lcov-report/utilities/index.js.html +26 -26
  159. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +8 -8
  160. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  161. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  162. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  163. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  164. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +18 -18
  165. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +4 -4
  166. package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
  167. package/coverage/lcov-report/utilities/security.js.html +8 -8
  168. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  169. package/coverage/lcov-report/utilities/usageQuota/index.html +13 -13
  170. package/coverage/lcov-report/utilities/usageQuota/index.js.html +8 -8
  171. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +38 -26
  172. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  173. package/coverage/lcov-report/utilities/users.js.html +5 -5
  174. package/coverage/lcov-report/utilities/workerRequests.js.html +28 -28
  175. package/coverage/lcov.info +1392 -1404
  176. package/dist/api/controllers/application.js +4 -1
  177. package/dist/api/controllers/deploy/index.js +5 -1
  178. package/dist/api/controllers/dev.js +9 -5
  179. package/dist/api/controllers/row/ExternalRequest.js +18 -7
  180. package/dist/api/controllers/row/internal.js +2 -1
  181. package/dist/api/controllers/webhook.js +2 -2
  182. package/dist/api/routes/tests/utilities/TestFunctions.js +1 -4
  183. package/dist/app.js +5 -2
  184. package/dist/automations/utils.js +6 -5
  185. package/dist/db/inMemoryView.js +33 -31
  186. package/dist/db/index.js +13 -2
  187. package/dist/integrations/couchdb.js +19 -25
  188. package/dist/integrations/mysql.js +13 -0
  189. package/dist/middleware/builder.js +10 -9
  190. package/dist/migrations/index.js +1 -5
  191. package/dist/package.json +5 -5
  192. package/dist/tests/utilities/TestConfiguration.js +66 -59
  193. package/dist/threads/utils.js +2 -3
  194. package/dist/tsconfig.tsbuildinfo +1 -1
  195. package/dist/utilities/fileSystem/index.js +27 -26
  196. package/dist/utilities/usageQuota/rows.js +16 -16
  197. package/package.json +6 -6
  198. package/scripts/exportAppTemplate.js +10 -8
  199. package/src/api/controllers/application.js +3 -1
  200. package/src/api/controllers/deploy/index.js +4 -4
  201. package/src/api/controllers/dev.js +9 -6
  202. package/src/api/controllers/query/import/tests/index.spec.js +7 -11
  203. package/src/api/controllers/row/ExternalRequest.ts +25 -7
  204. package/src/api/controllers/row/internal.js +2 -1
  205. package/src/api/controllers/webhook.js +2 -2
  206. package/src/api/routes/tests/row.spec.js +15 -11
  207. package/src/api/routes/tests/table.spec.js +3 -2
  208. package/src/api/routes/tests/utilities/TestFunctions.js +1 -5
  209. package/src/app.ts +2 -2
  210. package/src/automations/tests/deleteRow.spec.js +1 -1
  211. package/src/automations/utils.js +6 -5
  212. package/src/db/inMemoryView.js +37 -36
  213. package/src/db/index.js +15 -2
  214. package/src/db/tests/linkTests.spec.js +8 -7
  215. package/src/integrations/couchdb.ts +28 -24
  216. package/src/integrations/mysql.ts +17 -1
  217. package/src/integrations/tests/airtable.spec.js +3 -1
  218. package/src/integrations/tests/couchdb.spec.js +4 -1
  219. package/src/middleware/builder.js +10 -9
  220. package/src/middleware/tests/authorized.spec.js +0 -1
  221. package/src/middleware/tests/usageQuota.spec.js +6 -20
  222. package/src/migrations/functions/tests/appUrls.spec.js +8 -11
  223. package/src/migrations/functions/tests/userEmailViewCasing.spec.js +13 -10
  224. package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +25 -21
  225. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +26 -24
  226. package/src/migrations/index.ts +1 -2
  227. package/src/module.d.ts +8 -0
  228. package/src/tests/utilities/TestConfiguration.js +62 -55
  229. package/src/threads/utils.js +2 -3
  230. package/src/utilities/fileSystem/index.js +30 -30
  231. package/src/utilities/usageQuota/rows.js +22 -18
  232. package/coverage/lcov-report/db/client.js.html +0 -173
  233. package/dist/db/client.js +0 -25
  234. package/scripts/replicateApp.js +0 -50
  235. package/src/db/client.js +0 -31
@@ -8,9 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- const core = require("@budibase/backend-core");
12
- const CouchDB = require("../../db");
13
- core.init(CouchDB);
11
+ require("../../db").init();
14
12
  const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles");
15
13
  const env = require("../../environment");
16
14
  const { basicTable, basicRow, basicRole, basicAutomation, basicDatasource, basicQuery, basicScreen, basicLayout, basicWebhook, TENANT_ID, } = require("./structures");
@@ -19,7 +17,7 @@ const supertest = require("supertest");
19
17
  const { cleanup } = require("../../utilities/fileSystem");
20
18
  const { Cookies, Headers } = require("@budibase/backend-core/constants");
21
19
  const { jwt } = require("@budibase/backend-core/auth");
22
- const { getGlobalDB } = require("@budibase/backend-core/tenancy");
20
+ const { doInTenant, doWithGlobalDB } = require("@budibase/backend-core/tenancy");
23
21
  const { createASession } = require("@budibase/backend-core/sessions");
24
22
  const { user: userCache } = require("@budibase/backend-core/cache");
25
23
  const newid = require("../../db/newid");
@@ -50,8 +48,23 @@ class TestConfiguration {
50
48
  getAppId() {
51
49
  return this.appId;
52
50
  }
53
- getCouch() {
54
- return CouchDB;
51
+ doInContext(appId, task) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ if (!appId) {
54
+ appId = this.appId;
55
+ }
56
+ return doInTenant(TENANT_ID, () => {
57
+ // check if already in a context
58
+ if (context.getAppId() == null && appId !== null) {
59
+ return context.doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
60
+ return task();
61
+ }));
62
+ }
63
+ else {
64
+ return task();
65
+ }
66
+ });
67
+ });
55
68
  }
56
69
  _req(config, params, controlFunc) {
57
70
  return __awaiter(this, void 0, void 0, function* () {
@@ -65,66 +78,57 @@ class TestConfiguration {
65
78
  request.request = {
66
79
  body: config,
67
80
  };
68
- function run() {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- if (params) {
71
- request.params = params;
72
- }
73
- yield controlFunc(request);
74
- return request.body;
75
- });
76
- }
77
- // check if already in a context
78
- if (context.getAppId() == null && this.appId !== null) {
79
- return context.doInAppContext(this.appId, () => __awaiter(this, void 0, void 0, function* () {
80
- return run();
81
- }));
82
- }
83
- else {
84
- return run();
85
- }
81
+ return this.doInContext(this.appId, () => __awaiter(this, void 0, void 0, function* () {
82
+ if (params) {
83
+ request.params = params;
84
+ }
85
+ yield controlFunc(request);
86
+ return request.body;
87
+ }));
86
88
  });
87
89
  }
88
90
  generateApiKey(userId = GLOBAL_USER_ID) {
89
91
  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;
92
+ return doWithGlobalDB(TENANT_ID, (db) => __awaiter(this, void 0, void 0, function* () {
93
+ const id = generateDevInfoID(userId);
94
+ let devInfo;
95
+ try {
96
+ devInfo = yield db.get(id);
97
+ }
98
+ catch (err) {
99
+ devInfo = { _id: id, userId };
100
+ }
101
+ devInfo.apiKey = encrypt(`${TENANT_ID}${SEPARATOR}${newid()}`);
102
+ yield db.put(devInfo);
103
+ return devInfo.apiKey;
104
+ }));
102
105
  });
103
106
  }
104
107
  globalUser({ id = GLOBAL_USER_ID, builder = true, email = EMAIL, roles, } = {}) {
105
108
  return __awaiter(this, void 0, void 0, function* () {
106
- const db = getGlobalDB(TENANT_ID);
107
- let existing;
108
- try {
109
- existing = yield db.get(id);
110
- }
111
- catch (err) {
112
- existing = { email };
113
- }
114
- const user = Object.assign(Object.assign({ _id: id }, existing), { roles: roles || {}, tenantId: TENANT_ID });
115
- yield createASession(id, {
116
- sessionId: "sessionid",
117
- tenantId: TENANT_ID,
118
- csrfToken: CSRF_TOKEN,
119
- });
120
- if (builder) {
121
- user.builder = { global: true };
122
- }
123
- else {
124
- user.builder = { global: false };
125
- }
126
- const resp = yield db.put(user);
127
- return Object.assign({ _rev: resp._rev }, user);
109
+ return doWithGlobalDB(TENANT_ID, (db) => __awaiter(this, void 0, void 0, function* () {
110
+ let existing;
111
+ try {
112
+ existing = yield db.get(id);
113
+ }
114
+ catch (err) {
115
+ existing = { email };
116
+ }
117
+ const user = Object.assign(Object.assign({ _id: id }, existing), { roles: roles || {}, tenantId: TENANT_ID });
118
+ yield createASession(id, {
119
+ sessionId: "sessionid",
120
+ tenantId: TENANT_ID,
121
+ csrfToken: CSRF_TOKEN,
122
+ });
123
+ if (builder) {
124
+ user.builder = { global: true };
125
+ }
126
+ else {
127
+ user.builder = { global: false };
128
+ }
129
+ const resp = yield db.put(user);
130
+ return Object.assign({ _rev: resp._rev }, user);
131
+ }));
128
132
  });
129
133
  }
130
134
  // use a new id as the name to avoid name collisions
@@ -182,9 +186,12 @@ class TestConfiguration {
182
186
  createApp(appName) {
183
187
  return __awaiter(this, void 0, void 0, function* () {
184
188
  // create dev app
189
+ // clear any old app
190
+ this.appId = null;
191
+ yield context.updateAppId(null);
185
192
  this.app = yield this._req({ name: appName }, null, controllers.app.create);
186
193
  this.appId = this.app.appId;
187
- context.updateAppId(this.appId);
194
+ yield context.updateAppId(this.appId);
188
195
  // create production app
189
196
  this.prodApp = yield this.deploy();
190
197
  this.prodAppId = this.prodApp.appId;
@@ -9,8 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  const env = require("../environment");
12
- const CouchDB = require("../db");
13
- const { init } = require("@budibase/backend-core");
12
+ const db = require("../db");
14
13
  const redis = require("@budibase/backend-core/redis");
15
14
  const { SEPARATOR } = require("@budibase/backend-core/db");
16
15
  const VARIABLE_TTL_SECONDS = 3600;
@@ -34,7 +33,7 @@ exports.threadSetup = () => {
34
33
  }
35
34
  // when thread starts, make sure it is recorded
36
35
  env.setInThread();
37
- init(CouchDB);
36
+ db.init();
38
37
  };
39
38
  function makeVariableKey(queryId, variable) {
40
39
  return `${queryId}${SEPARATOR}${variable}`;