@budibase/server 1.0.219-alpha.7 → 1.0.219

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 (257) hide show
  1. package/__mocks__/node-fetch.ts +0 -9
  2. package/builder/assets/index.1c640a53.js +1316 -0
  3. package/builder/assets/index.24307ca0.css +6 -0
  4. package/builder/assets/{vendor.001dcf8c.js → vendor.9bf2fcb4.js} +163 -163
  5. package/builder/index.html +3 -3
  6. package/coverage/clover.xml +794 -868
  7. package/coverage/coverage-final.json +26 -26
  8. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/automation.js.html +12 -111
  11. package/coverage/lcov-report/api/controllers/backup.js.html +6 -9
  12. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
  15. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  16. package/coverage/lcov-report/api/controllers/index.html +21 -21
  17. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/index.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 +17 -47
  27. package/coverage/lcov-report/api/controllers/row/index.html +34 -34
  28. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +11 -95
  30. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/row/utils.js.html +8 -17
  32. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/table/bulkFormula.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/templates.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  42. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  44. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  45. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  46. package/coverage/lcov-report/api/index.html +15 -15
  47. package/coverage/lcov-report/api/index.js.html +13 -22
  48. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/automation.js.html +2 -32
  52. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/index.html +1 -1
  59. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  73. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  75. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  76. package/coverage/lcov-report/automations/actions.js.html +1 -1
  77. package/coverage/lcov-report/automations/automationUtils.js.html +12 -57
  78. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  79. package/coverage/lcov-report/automations/index.html +17 -17
  80. package/coverage/lcov-report/automations/index.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/filter.js.html +34 -58
  87. package/coverage/lcov-report/automations/steps/index.html +11 -11
  88. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  97. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  106. package/coverage/lcov-report/automations/triggers.js.html +4 -4
  107. package/coverage/lcov-report/constants/index.html +1 -1
  108. package/coverage/lcov-report/constants/index.js.html +1 -1
  109. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  110. package/coverage/lcov-report/constants/screens.js.html +1 -1
  111. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  112. package/coverage/lcov-report/db/index.html +14 -14
  113. package/coverage/lcov-report/db/index.js.html +1 -1
  114. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  115. package/coverage/lcov-report/db/linkedRows/index.html +13 -13
  116. package/coverage/lcov-report/db/linkedRows/index.js.html +7 -10
  117. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  118. package/coverage/lcov-report/db/newid.js.html +2 -2
  119. package/coverage/lcov-report/db/utils.js.html +51 -27
  120. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  121. package/coverage/lcov-report/events/index.html +1 -1
  122. package/coverage/lcov-report/events/index.js.html +1 -1
  123. package/coverage/lcov-report/events/utils.js.html +1 -1
  124. package/coverage/lcov-report/index.html +74 -74
  125. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  126. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  127. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  128. package/coverage/lcov-report/middleware/builder.js.html +12 -12
  129. package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
  130. package/coverage/lcov-report/middleware/index.html +1 -1
  131. package/coverage/lcov-report/middleware/joi-validator.js.html +10 -10
  132. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  133. package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
  134. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  135. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  136. package/coverage/lcov-report/threads/automation.js.html +9 -18
  137. package/coverage/lcov-report/threads/index.html +25 -25
  138. package/coverage/lcov-report/threads/query.js.html +76 -283
  139. package/coverage/lcov-report/threads/utils.js.html +4 -4
  140. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  141. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  142. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  143. package/coverage/lcov-report/utilities/global.js.html +14 -14
  144. package/coverage/lcov-report/utilities/index.html +1 -1
  145. package/coverage/lcov-report/utilities/index.js.html +9 -9
  146. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
  147. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  148. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  149. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  150. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  151. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  152. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  153. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  154. package/coverage/lcov-report/utilities/security.js.html +2 -2
  155. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  156. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  157. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  158. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  159. package/coverage/lcov-report/utilities/users.js.html +1 -1
  160. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  161. package/coverage/lcov.info +1425 -1553
  162. package/dist/api/controllers/application.js +15 -18
  163. package/dist/api/controllers/automation.js +2 -28
  164. package/dist/api/controllers/backup.js +2 -3
  165. package/dist/api/controllers/query/index.js +0 -25
  166. package/dist/api/controllers/row/external.js +7 -19
  167. package/dist/api/controllers/row/internalSearch.js +1 -22
  168. package/dist/api/controllers/row/utils.js +0 -3
  169. package/dist/api/index.js +1 -4
  170. package/dist/api/routes/automation.js +0 -2
  171. package/dist/automations/automationUtils.js +4 -16
  172. package/dist/automations/steps/filter.js +29 -38
  173. package/dist/automations/triggers.js +1 -1
  174. package/dist/db/linkedRows/index.js +0 -1
  175. package/dist/db/utils.js +31 -4
  176. package/dist/definitions/datasource.js +0 -1
  177. package/dist/environment.js +0 -1
  178. package/dist/integrations/airtable.js +0 -1
  179. package/dist/integrations/arangodb.js +0 -1
  180. package/dist/integrations/base/sql.js +3 -20
  181. package/dist/integrations/couchdb.js +0 -1
  182. package/dist/integrations/dynamodb.js +0 -1
  183. package/dist/integrations/elasticsearch.js +0 -1
  184. package/dist/integrations/firebase.js +0 -1
  185. package/dist/integrations/googlesheets.js +0 -1
  186. package/dist/integrations/index.js +0 -4
  187. package/dist/integrations/microsoftSqlServer.js +1 -2
  188. package/dist/integrations/mongodb.js +0 -1
  189. package/dist/integrations/mysql.js +1 -2
  190. package/dist/integrations/oracle.js +0 -1
  191. package/dist/integrations/postgres.js +1 -2
  192. package/dist/integrations/queries/sql.js +0 -3
  193. package/dist/integrations/redis.js +0 -1
  194. package/dist/integrations/rest.js +1 -2
  195. package/dist/integrations/s3.js +0 -1
  196. package/dist/package.json +6 -7
  197. package/dist/tests/utilities/TestConfiguration.js +6 -19
  198. package/dist/threads/automation.js +3 -6
  199. package/dist/threads/index.js +1 -15
  200. package/dist/threads/query.js +8 -54
  201. package/dist/tsconfig.build.tsbuildinfo +1 -1
  202. package/dist/utilities/fileSystem/index.js +6 -16
  203. package/package.json +7 -8
  204. package/src/api/controllers/application.ts +14 -18
  205. package/src/api/controllers/automation.js +2 -35
  206. package/src/api/controllers/backup.js +2 -3
  207. package/src/api/controllers/query/index.ts +1 -29
  208. package/src/api/controllers/row/external.js +9 -19
  209. package/src/api/controllers/row/internalSearch.js +0 -28
  210. package/src/api/controllers/row/utils.js +0 -3
  211. package/src/api/index.js +1 -4
  212. package/src/api/routes/automation.js +0 -10
  213. package/src/api/routes/tests/query.spec.js +0 -166
  214. package/src/automations/automationUtils.js +4 -19
  215. package/src/automations/steps/filter.js +28 -36
  216. package/src/automations/tests/filter.spec.js +1 -2
  217. package/src/automations/triggers.js +1 -1
  218. package/src/db/linkedRows/index.js +0 -1
  219. package/src/db/utils.js +13 -5
  220. package/src/definitions/common.ts +0 -1
  221. package/src/definitions/datasource.ts +0 -2
  222. package/src/environment.js +0 -1
  223. package/src/integrations/airtable.ts +0 -1
  224. package/src/integrations/arangodb.ts +0 -1
  225. package/src/integrations/base/sql.ts +11 -25
  226. package/src/integrations/couchdb.ts +0 -1
  227. package/src/integrations/dynamodb.ts +0 -1
  228. package/src/integrations/elasticsearch.ts +0 -1
  229. package/src/integrations/firebase.ts +0 -1
  230. package/src/integrations/googlesheets.ts +0 -1
  231. package/src/integrations/index.ts +0 -4
  232. package/src/integrations/microsoftSqlServer.ts +0 -2
  233. package/src/integrations/mongodb.ts +0 -1
  234. package/src/integrations/mysql.ts +0 -2
  235. package/src/integrations/oracle.ts +0 -1
  236. package/src/integrations/postgres.ts +0 -2
  237. package/src/integrations/queries/sql.ts +1 -3
  238. package/src/integrations/redis.ts +0 -1
  239. package/src/integrations/rest.ts +1 -2
  240. package/src/integrations/s3.ts +0 -1
  241. package/src/integrations/tests/rest.spec.js +1 -16
  242. package/src/migrations/tests/index.spec.ts +2 -18
  243. package/src/module.d.ts +0 -2
  244. package/src/tests/utilities/TestConfiguration.js +3 -22
  245. package/src/threads/automation.js +3 -6
  246. package/src/threads/index.ts +1 -5
  247. package/src/threads/query.js +10 -79
  248. package/src/utilities/fileSystem/index.js +8 -22
  249. package/builder/assets/index.5a233c3d.js +0 -977
  250. package/builder/assets/index.7786f497.css +0 -6
  251. package/dist/automations/logging/index.js +0 -70
  252. package/dist/integrations/snowflake.js +0 -102
  253. package/scripts/integrations/oracle/instantclient/linux/arm64/basiclite-19.10.zip +0 -0
  254. package/scripts/integrations/oracle/instantclient/linux/arm64/install.sh +0 -23
  255. package/scripts/integrations/oracle/instantclient/linux/install.sh +0 -10
  256. package/src/automations/logging/index.ts +0 -35
  257. package/src/integrations/snowflake.ts +0 -99
@@ -77,7 +77,7 @@ export class Thread {
77
77
  })
78
78
  }
79
79
 
80
- static stopThreads() {
80
+ static shutdown() {
81
81
  return new Promise<void>(resolve => {
82
82
  if (Thread.workerRefs.length === 0) {
83
83
  resolve()
@@ -95,8 +95,4 @@ export class Thread {
95
95
  Thread.workerRefs = []
96
96
  })
97
97
  }
98
-
99
- static async shutdown() {
100
- await Thread.stopThreads()
101
- }
102
98
  }
@@ -4,13 +4,6 @@ const ScriptRunner = require("../utilities/scriptRunner")
4
4
  const { integrations } = require("../integrations")
5
5
  const { processStringSync } = require("@budibase/string-templates")
6
6
  const { doInAppContext, getAppDB } = require("@budibase/backend-core/context")
7
- const {
8
- refreshOAuthToken,
9
- updateUserOAuth,
10
- } = require("@budibase/backend-core/auth")
11
- const { user: userCache } = require("@budibase/backend-core/cache")
12
- const { getGlobalIDFromUserMetadataID } = require("../db/utils")
13
-
14
7
  const { isSQL } = require("../integrations/utils")
15
8
  const {
16
9
  enrichQueryFields,
@@ -28,56 +21,29 @@ class QueryRunner {
28
21
  this.queryId = input.queryId
29
22
  this.noRecursiveQuery = flags.noRecursiveQuery
30
23
  this.cachedVariables = []
31
- // Additional context items for enrichment
32
- this.ctx = input.ctx
33
24
  // allows the response from a query to be stored throughout this
34
25
  // execution so that if it needs to be re-used for another variable
35
26
  // it can be
36
27
  this.queryResponse = {}
37
28
  this.hasRerun = false
38
- this.hasRefreshedOAuth = false
39
29
  }
40
30
 
41
31
  async execute() {
42
32
  let { datasource, fields, queryVerb, transformer } = this
43
-
44
33
  const Integration = integrations[datasource.source]
45
34
  if (!Integration) {
46
35
  throw "Integration type does not exist."
47
36
  }
48
-
49
- if (datasource.config.authConfigs) {
50
- datasource.config.authConfigs = datasource.config.authConfigs.map(
51
- config => {
52
- return enrichQueryFields(config, this.ctx)
53
- }
54
- )
55
- }
56
-
57
37
  const integration = new Integration(datasource.config)
58
38
 
59
39
  // pre-query, make sure datasource variables are added to parameters
60
40
  const parameters = await this.addDatasourceVariables()
61
-
62
- // Enrich the parameters with the addition context items.
63
- // 'user' is now a reserved variable key in mapping parameters
64
- const enrichedParameters = enrichQueryFields(parameters, this.ctx)
65
- const enrichedContext = { ...enrichedParameters, ...this.ctx }
66
-
67
- // Parse global headers
68
- if (datasource.config.defaultHeaders) {
69
- datasource.config.defaultHeaders = enrichQueryFields(
70
- datasource.config.defaultHeaders,
71
- enrichedContext
72
- )
73
- }
74
-
75
41
  let query
76
42
  // handle SQL injections by interpolating the variables
77
43
  if (isSQL(datasource)) {
78
- query = interpolateSQL(fields, enrichedParameters, integration)
44
+ query = interpolateSQL(fields, parameters, integration)
79
45
  } else {
80
- query = enrichQueryFields(fields, enrichedContext)
46
+ query = enrichQueryFields(fields, parameters)
81
47
  }
82
48
 
83
49
  // Add pagination values for REST queries
@@ -101,24 +67,20 @@ class QueryRunner {
101
67
  if (transformer) {
102
68
  const runner = new ScriptRunner(transformer, {
103
69
  data: rows,
104
- params: enrichedParameters,
70
+ params: parameters,
105
71
  })
106
72
  rows = runner.execute()
107
73
  }
108
74
 
109
75
  // if the request fails we retry once, invalidating the cached value
110
- if (info && info.code >= 400 && !this.hasRerun) {
111
- if (
112
- this.ctx.user?.provider &&
113
- info.code === 401 &&
114
- !this.hasRefreshedOAuth
115
- ) {
116
- await this.refreshOAuth2(this.ctx)
117
- // Attempt to refresh the access token from the provider
118
- this.hasRefreshedOAuth = true
119
- }
120
-
76
+ if (
77
+ info &&
78
+ info.code >= 400 &&
79
+ this.cachedVariables.length > 0 &&
80
+ !this.hasRerun
81
+ ) {
121
82
  this.hasRerun = true
83
+ // invalidate the cache value
122
84
  await threadUtils.invalidateDynamicVariables(this.cachedVariables)
123
85
  return this.execute()
124
86
  }
@@ -164,37 +126,6 @@ class QueryRunner {
164
126
  ).execute()
165
127
  }
166
128
 
167
- async refreshOAuth2(ctx) {
168
- const { oauth2, providerType, _id } = ctx.user
169
- const { configId } = ctx.auth
170
-
171
- if (!providerType || !oauth2?.refreshToken) {
172
- throw new Error("No refresh token found for authenticated user")
173
- }
174
-
175
- const resp = await refreshOAuthToken(
176
- oauth2.refreshToken,
177
- providerType,
178
- configId
179
- )
180
-
181
- // Refresh session flow. Should be in same location as refreshOAuthToken
182
- // There are several other properties available in 'resp'
183
- if (!resp.err) {
184
- const globalUserId = getGlobalIDFromUserMetadataID(_id)
185
- await updateUserOAuth(globalUserId, resp)
186
- this.ctx.user = await userCache.getUser(globalUserId)
187
- } else {
188
- // In this event the user may have oAuth issues that
189
- // could require re-authenticating with their provider.
190
- throw new Error(
191
- "OAuth2 access token could not be refreshed: " + resp.err.toString()
192
- )
193
- }
194
-
195
- return resp
196
- }
197
-
198
129
  async getDynamicVariable(variable) {
199
130
  let { parameters } = this
200
131
  const queryId = variable.queryId,
@@ -21,7 +21,6 @@ const env = require("../../environment")
21
21
  const {
22
22
  USER_METDATA_PREFIX,
23
23
  LINK_USER_METADATA_PREFIX,
24
- TABLE_ROW_PREFIX,
25
24
  } = require("../../db/utils")
26
25
  const MemoryStream = require("memorystream")
27
26
  const { getAppId } = require("@budibase/backend-core/context")
@@ -110,23 +109,6 @@ exports.apiFileReturn = contents => {
110
109
  return fs.createReadStream(path)
111
110
  }
112
111
 
113
- exports.defineFilter = excludeRows => {
114
- if (excludeRows) {
115
- return doc =>
116
- !(
117
- doc._id.includes(USER_METDATA_PREFIX) ||
118
- doc._id.includes(LINK_USER_METADATA_PREFIX) ||
119
- doc._id.includes(TABLE_ROW_PREFIX)
120
- )
121
- } else if (!excludeRows) {
122
- return doc =>
123
- !(
124
- doc._id.includes(USER_METDATA_PREFIX) ||
125
- doc._id.includes(LINK_USER_METADATA_PREFIX)
126
- )
127
- }
128
- }
129
-
130
112
  /**
131
113
  * Local utility to back up the database state for an app, excluding global user
132
114
  * data or user relationships.
@@ -134,10 +116,14 @@ exports.defineFilter = excludeRows => {
134
116
  * @param {object} config Config to send to export DB
135
117
  * @returns {*} either a string or a stream of the backup
136
118
  */
137
- const backupAppData = async (appId, config, includeRows) => {
119
+ const backupAppData = async (appId, config) => {
138
120
  return await exports.exportDB(appId, {
139
121
  ...config,
140
- filter: exports.defineFilter(includeRows),
122
+ filter: doc =>
123
+ !(
124
+ doc._id.includes(USER_METDATA_PREFIX) ||
125
+ doc._id.includes(LINK_USER_METADATA_PREFIX)
126
+ ),
141
127
  })
142
128
  }
143
129
 
@@ -156,8 +142,8 @@ exports.performBackup = async (appId, backupName) => {
156
142
  * @param {string} appId The ID of the app which is to be backed up.
157
143
  * @returns {*} a readable stream of the backup which is written in real time
158
144
  */
159
- exports.streamBackup = async (appId, includeRows) => {
160
- return await backupAppData(appId, { stream: true }, includeRows)
145
+ exports.streamBackup = async appId => {
146
+ return await backupAppData(appId, { stream: true })
161
147
  }
162
148
 
163
149
  /**