@budibase/server 2.0.30-alpha.3 → 2.0.30-alpha.4

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 (169) hide show
  1. package/__mocks__/mongodb.ts +1 -1
  2. package/builder/assets/{index.bd6c0866.js → index.0f137fa3.js} +244 -240
  3. package/builder/assets/{index.e56da48a.css → index.a6a040bb.css} +1 -1
  4. package/builder/index.html +2 -2
  5. package/coverage/clover.xml +185 -184
  6. package/coverage/coverage-final.json +3 -3
  7. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/index.html +1 -1
  14. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  16. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  20. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  25. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  32. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  33. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  38. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  42. package/coverage/lcov-report/api/index.html +1 -1
  43. package/coverage/lcov-report/api/index.js.html +1 -1
  44. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  45. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  46. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  47. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/index.html +1 -1
  54. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  68. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  71. package/coverage/lcov-report/automations/actions.js.html +1 -1
  72. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  73. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  74. package/coverage/lcov-report/automations/index.html +1 -1
  75. package/coverage/lcov-report/automations/index.js.html +1 -1
  76. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  77. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  78. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  79. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  80. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/index.html +1 -1
  83. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  93. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  94. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  95. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  96. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  97. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  101. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  102. package/coverage/lcov-report/constants/index.html +1 -1
  103. package/coverage/lcov-report/constants/index.js.html +8 -2
  104. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  105. package/coverage/lcov-report/constants/screens.js.html +1 -1
  106. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  107. package/coverage/lcov-report/db/index.html +1 -1
  108. package/coverage/lcov-report/db/index.js.html +1 -1
  109. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  110. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  111. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  112. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  113. package/coverage/lcov-report/db/newid.js.html +1 -1
  114. package/coverage/lcov-report/db/utils.js.html +1 -1
  115. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  116. package/coverage/lcov-report/events/index.html +1 -1
  117. package/coverage/lcov-report/events/index.js.html +1 -1
  118. package/coverage/lcov-report/events/utils.js.html +1 -1
  119. package/coverage/lcov-report/index.html +14 -14
  120. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  121. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  122. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  123. package/coverage/lcov-report/middleware/builder.js.html +1 -1
  124. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  125. package/coverage/lcov-report/middleware/index.html +1 -1
  126. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  127. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  128. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  129. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  130. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  131. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  132. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  133. package/coverage/lcov-report/utilities/csvParser.js.html +11 -8
  134. package/coverage/lcov-report/utilities/global.js.html +1 -1
  135. package/coverage/lcov-report/utilities/index.html +15 -15
  136. package/coverage/lcov-report/utilities/index.js.html +1 -1
  137. package/coverage/lcov-report/utilities/plugins.js.html +1 -1
  138. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  139. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  140. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  141. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  142. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  143. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +17 -2
  144. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  145. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  146. package/coverage/lcov-report/utilities/security.js.html +1 -1
  147. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  148. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  149. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  150. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  151. package/coverage/lcov-report/utilities/users.js.html +1 -1
  152. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  153. package/coverage/lcov.info +324 -321
  154. package/dist/constants/index.js +2 -0
  155. package/dist/integrations/base/sqlTable.js +1 -0
  156. package/dist/integrations/mongodb.js +300 -11
  157. package/dist/package.json +7 -8
  158. package/dist/tsconfig.build.tsbuildinfo +1 -1
  159. package/dist/utilities/csvParser.js +1 -0
  160. package/dist/utilities/rowProcessor/index.js +5 -0
  161. package/package.json +8 -9
  162. package/specs/openapi.json +3 -0
  163. package/specs/openapi.yaml +3 -0
  164. package/src/constants/index.js +2 -0
  165. package/src/integrations/base/sqlTable.ts +1 -0
  166. package/src/integrations/mongodb.ts +290 -27
  167. package/src/integrations/tests/mongo.spec.ts +19 -19
  168. package/src/utilities/csvParser.js +1 -0
  169. package/src/utilities/rowProcessor/index.js +5 -0
@@ -28,6 +28,7 @@ exports.NoEmptyFilterStrings = [
28
28
  ];
29
29
  exports.FieldTypes = {
30
30
  STRING: "string",
31
+ BARCODEQR: "barcodeqr",
31
32
  LONGFORM: "longform",
32
33
  OPTIONS: "options",
33
34
  NUMBER: "number",
@@ -47,6 +48,7 @@ exports.CanSwitchTypes = [
47
48
  exports.FieldTypes.STRING,
48
49
  exports.FieldTypes.OPTIONS,
49
50
  exports.FieldTypes.LONGFORM,
51
+ exports.FieldTypes.BARCODEQR,
50
52
  ],
51
53
  [exports.FieldTypes.BOOLEAN, exports.FieldTypes.NUMBER],
52
54
  ];
@@ -31,6 +31,7 @@ function generateSchema(schema, table, tables, oldTable = null, renamed) {
31
31
  case FieldTypes.STRING:
32
32
  case FieldTypes.OPTIONS:
33
33
  case FieldTypes.LONGFORM:
34
+ case FieldTypes.BARCODEQR:
34
35
  schema.text(key);
35
36
  break;
36
37
  case FieldTypes.NUMBER:
@@ -8,6 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
12
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
+ var m = o[Symbol.asyncIterator], i;
14
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
+ };
11
18
  Object.defineProperty(exports, "__esModule", { value: true });
12
19
  const types_1 = require("@budibase/types");
13
20
  const mongodb_1 = require("mongodb");
@@ -40,6 +47,232 @@ const SCHEMA = {
40
47
  delete: {
41
48
  type: types_1.QueryType.JSON,
42
49
  },
50
+ aggregate: {
51
+ type: types_1.QueryType.JSON,
52
+ steps: [
53
+ {
54
+ key: "$addFields",
55
+ template: "{\n\t\n}",
56
+ },
57
+ {
58
+ key: "$bucket",
59
+ template: `{
60
+ "groupBy": "",
61
+ "boundaries": [],
62
+ "default": "",
63
+ "output": {}
64
+ }`,
65
+ },
66
+ {
67
+ key: "$bucketAuto",
68
+ template: `{
69
+ "groupBy": "",
70
+ "buckets": 1,
71
+ "output": {},
72
+ "granularity": "R5"
73
+ }`,
74
+ },
75
+ {
76
+ key: "$changeStream",
77
+ template: `{
78
+ "allChangesForCluster": true,
79
+ "fullDocument": "",
80
+ "fullDocumentBeforeChange": "",
81
+ "resumeAfter": 1,
82
+ "showExpandedEvents": true,
83
+ "startAfter": {},
84
+ "startAtOperationTime": ""
85
+ }`,
86
+ },
87
+ {
88
+ key: "$collStats",
89
+ template: `{
90
+ "latencyStats": { "histograms": true } },
91
+ "storageStats": { "scale": 1 } },
92
+ "count": {},
93
+ "queryExecStats": {}
94
+ }`,
95
+ },
96
+ {
97
+ key: "$count",
98
+ template: ``,
99
+ },
100
+ {
101
+ key: "$densify",
102
+ template: `{
103
+ "field": "",
104
+ "partitionByFields": [],
105
+ "range": {
106
+ "step": 1,
107
+ "unit": 1,
108
+ "bounds": "full"
109
+ }
110
+ }`,
111
+ },
112
+ {
113
+ key: "$documents",
114
+ template: `[]`,
115
+ },
116
+ {
117
+ key: "$facet",
118
+ template: `{\n\t\n}`,
119
+ },
120
+ {
121
+ key: "$fill",
122
+ template: `{
123
+ "partitionBy": "",
124
+ "partitionByFields": [],
125
+ "sortBy": {},
126
+ "output": {}
127
+ }`,
128
+ },
129
+ {
130
+ key: "$geoNear",
131
+ template: `{
132
+ "near": {
133
+ "type": "Point",
134
+ "coordinates": [
135
+ -73.98142, 40.71782
136
+ ]
137
+ },
138
+ "key": "location",
139
+ "distanceField": "dist.calculated",
140
+ "query": { "category": "Parks" }
141
+ }`,
142
+ },
143
+ {
144
+ key: "$graphLookup",
145
+ template: `{
146
+ "from": "",
147
+ "startWith": "",
148
+ "connectFromField": "",
149
+ "connectToField": "",
150
+ "as": "",
151
+ "maxDepth": 1,
152
+ "depthField": "",
153
+ "restrictSearchWithMatch": {}
154
+ }`,
155
+ },
156
+ {
157
+ key: "$group",
158
+ template: `{
159
+ "_id": ""
160
+ }`,
161
+ },
162
+ {
163
+ key: "$indexStats",
164
+ template: "{\n\t\n}",
165
+ },
166
+ {
167
+ key: "$limit",
168
+ template: `1`,
169
+ },
170
+ {
171
+ key: "$listLocalSessions",
172
+ template: `{\n\t\n}`,
173
+ },
174
+ {
175
+ key: "$listSessions",
176
+ template: `{\n\t\n}`,
177
+ },
178
+ {
179
+ key: "$lookup",
180
+ template: `{
181
+ "from": "",
182
+ "localField": "",
183
+ "foreignField": "",
184
+ "as": ""
185
+ }`,
186
+ },
187
+ {
188
+ key: "$match",
189
+ template: "{\n\t\n}",
190
+ },
191
+ {
192
+ key: "$merge",
193
+ template: `{
194
+ "into": {},
195
+ "on": "_id",
196
+ "whenMatched": "replace",
197
+ "whenNotMatched": "insert"
198
+ }`,
199
+ },
200
+ {
201
+ key: "$out",
202
+ template: `{
203
+ "db": "",
204
+ "coll": ""
205
+ }`,
206
+ },
207
+ {
208
+ key: "$planCacheStats",
209
+ template: "{\n\t\n}",
210
+ },
211
+ {
212
+ key: "$project",
213
+ template: "{\n\t\n}",
214
+ },
215
+ {
216
+ key: "$redact",
217
+ template: "",
218
+ },
219
+ {
220
+ key: "$replaceRoot",
221
+ template: `{ "newRoot": "" }`,
222
+ },
223
+ {
224
+ key: "$replaceWith",
225
+ template: ``,
226
+ },
227
+ {
228
+ key: "$sample",
229
+ template: `{ "size": 3 }`,
230
+ },
231
+ {
232
+ key: "$set",
233
+ template: "{\n\t\n}",
234
+ },
235
+ {
236
+ key: "$setWindowFields",
237
+ template: `{
238
+ "partitionBy": "",
239
+ "sortBy": {},
240
+ "output": {}
241
+ }`,
242
+ },
243
+ {
244
+ key: "$skip",
245
+ template: `1`,
246
+ },
247
+ {
248
+ key: "$sort",
249
+ template: "{\n\t\n}",
250
+ },
251
+ {
252
+ key: "$sortByCount",
253
+ template: "",
254
+ },
255
+ {
256
+ key: "$unionWith",
257
+ template: `{
258
+ "coll": "",
259
+ "pipeline": []
260
+ }`,
261
+ },
262
+ {
263
+ key: "$unset",
264
+ template: "",
265
+ },
266
+ {
267
+ key: "$unwind",
268
+ template: `{
269
+ "path": "",
270
+ "includeArrayIndex": "",
271
+ "preserveNullAndEmptyArrays": true
272
+ }`,
273
+ },
274
+ ],
275
+ },
43
276
  },
44
277
  extra: {
45
278
  collection: {
@@ -47,8 +280,8 @@ const SCHEMA = {
47
280
  type: types_1.DatasourceFieldType.STRING,
48
281
  required: true,
49
282
  },
50
- actionTypes: {
51
- displayName: "Action Types",
283
+ actionType: {
284
+ displayName: "Query Type",
52
285
  type: types_1.DatasourceFieldType.LIST,
53
286
  required: true,
54
287
  data: {
@@ -56,6 +289,7 @@ const SCHEMA = {
56
289
  create: ["insertOne", "insertMany"],
57
290
  update: ["updateOne", "updateMany"],
58
291
  delete: ["deleteOne", "deleteMany"],
292
+ aggregate: ["json", "pipeline"],
59
293
  },
60
294
  },
61
295
  },
@@ -82,7 +316,7 @@ class MongoIntegration {
82
316
  json[field].toLowerCase().startsWith("objectid")) {
83
317
  const id = (_a = json[field].match(/(?<=objectid\(['"]).*(?=['"]\))/gi)) === null || _a === void 0 ? void 0 : _a[0];
84
318
  if (id) {
85
- json[field] = mongodb_1.ObjectID.createFromHexString(id);
319
+ json[field] = mongodb_1.ObjectId.createFromHexString(id);
86
320
  }
87
321
  }
88
322
  }
@@ -145,7 +379,7 @@ class MongoIntegration {
145
379
  let json = this.createObjectIds(query.json);
146
380
  // For mongodb we add an extra actionType to specify
147
381
  // which method we want to call on the collection
148
- switch (query.extra.actionTypes) {
382
+ switch (query.extra.actionType) {
149
383
  case "insertOne": {
150
384
  return yield collection.insertOne(json);
151
385
  }
@@ -153,7 +387,7 @@ class MongoIntegration {
153
387
  return yield collection.insertMany(json);
154
388
  }
155
389
  default: {
156
- throw new Error(`actionType ${query.extra.actionTypes} does not exist on DB for create`);
390
+ throw new Error(`actionType ${query.extra.actionType} does not exist on DB for create`);
157
391
  }
158
392
  }
159
393
  }
@@ -173,7 +407,7 @@ class MongoIntegration {
173
407
  const db = this.client.db(this.config.db);
174
408
  const collection = db.collection(query.extra.collection);
175
409
  let json = this.createObjectIds(query.json);
176
- switch (query.extra.actionTypes) {
410
+ switch (query.extra.actionType) {
177
411
  case "find": {
178
412
  return yield collection.find(json).toArray();
179
413
  }
@@ -194,7 +428,7 @@ class MongoIntegration {
194
428
  return yield collection.distinct(json);
195
429
  }
196
430
  default: {
197
- throw new Error(`actionType ${query.extra.actionTypes} does not exist on DB for read`);
431
+ throw new Error(`actionType ${query.extra.actionType} does not exist on DB for read`);
198
432
  }
199
433
  }
200
434
  }
@@ -218,7 +452,7 @@ class MongoIntegration {
218
452
  queryJson = this.parseQueryParams(queryJson, "update");
219
453
  }
220
454
  let json = this.createObjectIds(queryJson);
221
- switch (query.extra.actionTypes) {
455
+ switch (query.extra.actionType) {
222
456
  case "updateOne": {
223
457
  return yield collection.updateOne(json.filter, json.update, json.options);
224
458
  }
@@ -226,7 +460,7 @@ class MongoIntegration {
226
460
  return yield collection.updateMany(json.filter, json.update, json.options);
227
461
  }
228
462
  default: {
229
- throw new Error(`actionType ${query.extra.actionTypes} does not exist on DB for update`);
463
+ throw new Error(`actionType ${query.extra.actionType} does not exist on DB for update`);
230
464
  }
231
465
  }
232
466
  }
@@ -256,7 +490,7 @@ class MongoIntegration {
256
490
  options: {},
257
491
  };
258
492
  }
259
- switch (query.extra.actionTypes) {
493
+ switch (query.extra.actionType) {
260
494
  case "deleteOne": {
261
495
  return yield collection.deleteOne(json.filter, json.options);
262
496
  }
@@ -264,9 +498,64 @@ class MongoIntegration {
264
498
  return yield collection.deleteMany(json.filter, json.options);
265
499
  }
266
500
  default: {
267
- throw new Error(`actionType ${query.extra.actionTypes} does not exist on DB for delete`);
501
+ throw new Error(`actionType ${query.extra.actionType} does not exist on DB for delete`);
502
+ }
503
+ }
504
+ }
505
+ catch (err) {
506
+ console.error("Error writing to mongodb", err);
507
+ throw err;
508
+ }
509
+ finally {
510
+ yield this.client.close();
511
+ }
512
+ });
513
+ }
514
+ aggregate(query) {
515
+ var e_1, _a, e_2, _b;
516
+ var _c;
517
+ return __awaiter(this, void 0, void 0, function* () {
518
+ try {
519
+ yield this.connect();
520
+ const db = this.client.db(this.config.db);
521
+ const collection = db.collection(query.extra.collection);
522
+ let response = [];
523
+ if (((_c = query.extra) === null || _c === void 0 ? void 0 : _c.actionType) === "pipeline") {
524
+ try {
525
+ for (var _d = __asyncValues(collection.aggregate(query.steps.map(({ key, value }) => {
526
+ let temp = {};
527
+ temp[key] = JSON.parse(value.value);
528
+ return this.createObjectIds(temp);
529
+ }))), _e; _e = yield _d.next(), !_e.done;) {
530
+ const doc = _e.value;
531
+ response.push(doc);
532
+ }
533
+ }
534
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
535
+ finally {
536
+ try {
537
+ if (_e && !_e.done && (_a = _d.return)) yield _a.call(_d);
538
+ }
539
+ finally { if (e_1) throw e_1.error; }
540
+ }
541
+ }
542
+ else {
543
+ const stages = query.json;
544
+ try {
545
+ for (var _f = __asyncValues(collection.aggregate(stages ? this.createObjectIds(stages) : [])), _g; _g = yield _f.next(), !_g.done;) {
546
+ const doc = _g.value;
547
+ response.push(doc);
548
+ }
549
+ }
550
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
551
+ finally {
552
+ try {
553
+ if (_g && !_g.done && (_b = _f.return)) yield _b.call(_f);
554
+ }
555
+ finally { if (e_2) throw e_2.error; }
268
556
  }
269
557
  }
558
+ return response;
270
559
  }
271
560
  catch (err) {
272
561
  console.error("Error writing to mongodb", err);
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.0.30-alpha.2",
4
+ "version": "2.0.30-alpha.3",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -77,11 +77,11 @@
77
77
  "license": "GPL-3.0",
78
78
  "dependencies": {
79
79
  "@apidevtools/swagger-parser": "10.0.3",
80
- "@budibase/backend-core": "2.0.30-alpha.2",
81
- "@budibase/client": "2.0.30-alpha.2",
82
- "@budibase/pro": "2.0.30-alpha.2",
83
- "@budibase/string-templates": "2.0.30-alpha.2",
84
- "@budibase/types": "2.0.30-alpha.2",
80
+ "@budibase/backend-core": "2.0.30-alpha.3",
81
+ "@budibase/client": "2.0.30-alpha.3",
82
+ "@budibase/pro": "2.0.30-alpha.3",
83
+ "@budibase/string-templates": "2.0.30-alpha.3",
84
+ "@budibase/types": "2.0.30-alpha.3",
85
85
  "@bull-board/api": "3.7.0",
86
86
  "@bull-board/koa": "3.9.4",
87
87
  "@elastic/elasticsearch": "7.10.0",
@@ -123,7 +123,7 @@
123
123
  "koa2-ratelimit": "1.1.1",
124
124
  "lodash": "4.17.21",
125
125
  "memorystream": "0.3.1",
126
- "mongodb": "3.6.3",
126
+ "mongodb": "4.9",
127
127
  "mssql": "6.2.3",
128
128
  "mysql2": "2.3.3",
129
129
  "node-fetch": "2.6.7",
@@ -166,7 +166,6 @@
166
166
  "@types/koa": "2.13.4",
167
167
  "@types/koa__router": "8.0.0",
168
168
  "@types/lodash": "4.14.180",
169
- "@types/mongodb": "3.6.3",
170
169
  "@types/node": "14.18.20",
171
170
  "@types/node-fetch": "2.6.1",
172
171
  "@types/oracledb": "5.2.2",