@budibase/server 2.0.30-alpha.7 → 2.0.31

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 (215) hide show
  1. package/__mocks__/mongodb.ts +1 -1
  2. package/builder/assets/{index.b1aa5e8a.js → index.c4b43e7e.js} +283 -287
  3. package/builder/assets/{index.a6a040bb.css → index.dfa4073c.css} +2 -2
  4. package/builder/index.html +2 -2
  5. package/coverage/clover.xml +491 -495
  6. package/coverage/coverage-final.json +26 -26
  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 +2 -2
  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 +12 -12
  26. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +15 -15
  28. package/coverage/lcov-report/api/controllers/row/utils.js.html +13 -13
  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 +5 -5
  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 +5 -5
  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 +3 -3
  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 +22 -22
  102. package/coverage/lcov-report/constants/index.html +1 -1
  103. package/coverage/lcov-report/constants/index.js.html +2 -8
  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 +11 -11
  110. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  111. package/coverage/lcov-report/db/linkedRows/index.js.html +11 -11
  112. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +3 -3
  113. package/coverage/lcov-report/db/newid.js.html +2 -2
  114. package/coverage/lcov-report/db/utils.js.html +16 -10
  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 +2 -2
  118. package/coverage/lcov-report/events/utils.js.html +9 -9
  119. package/coverage/lcov-report/index.html +24 -24
  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 +11 -11
  124. package/coverage/lcov-report/middleware/currentapp.js.html +34 -34
  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 +7 -7
  129. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  130. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  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 +8 -11
  134. package/coverage/lcov-report/utilities/global.js.html +16 -16
  135. package/coverage/lcov-report/utilities/index.html +15 -15
  136. package/coverage/lcov-report/utilities/index.js.html +7 -7
  137. package/coverage/lcov-report/utilities/plugins.js.html +1 -1
  138. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +13 -13
  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 +39 -54
  144. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
  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 +14 -14
  149. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +11 -23
  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 +892 -900
  154. package/dist/api/controllers/application.js +2 -2
  155. package/dist/api/controllers/dev.js +1 -1
  156. package/dist/api/controllers/query/index.js +2 -7
  157. package/dist/api/controllers/row/index.js +10 -30
  158. package/dist/api/controllers/static/templates/preview.hbs +0 -10
  159. package/dist/api/controllers/table/internal.js +2 -8
  160. package/dist/api/controllers/table/utils.js +1 -3
  161. package/dist/automations/steps/updateRow.js +2 -2
  162. package/dist/automations/utils.js +3 -5
  163. package/dist/constants/index.js +0 -2
  164. package/dist/db/utils.js +1 -1
  165. package/dist/index.js +0 -1
  166. package/dist/integrations/base/sqlTable.js +0 -1
  167. package/dist/integrations/mongodb.js +11 -300
  168. package/dist/integrations/rest.js +5 -38
  169. package/dist/migrations/functions/{usageQuotas/syncPlugins.js → pluginCount.js} +3 -1
  170. package/dist/migrations/functions/{syncQuotas.js → quotas1.js} +7 -3
  171. package/dist/migrations/functions/usageQuotas/syncApps.js +1 -0
  172. package/dist/migrations/functions/usageQuotas/syncRows.js +5 -9
  173. package/dist/migrations/index.js +38 -9
  174. package/dist/package.json +9 -8
  175. package/dist/tsconfig.build.tsbuildinfo +1 -1
  176. package/dist/utilities/csvParser.js +0 -1
  177. package/dist/utilities/rowProcessor/index.js +0 -5
  178. package/dist/utilities/usageQuota/rows.js +4 -6
  179. package/package.json +10 -9
  180. package/specs/openapi.json +0 -3
  181. package/specs/openapi.yaml +0 -3
  182. package/src/api/controllers/application.ts +2 -2
  183. package/src/api/controllers/deploy/index.ts +1 -0
  184. package/src/api/controllers/dev.js +1 -1
  185. package/src/api/controllers/query/index.ts +2 -8
  186. package/src/api/controllers/row/index.ts +13 -36
  187. package/src/api/controllers/static/templates/preview.hbs +0 -10
  188. package/src/api/controllers/table/internal.ts +2 -5
  189. package/src/api/controllers/table/utils.ts +1 -3
  190. package/src/api/routes/tests/row.spec.js +27 -22
  191. package/src/automations/steps/updateRow.js +2 -2
  192. package/src/automations/tests/automation.spec.js +6 -1
  193. package/src/automations/utils.ts +4 -6
  194. package/src/constants/index.js +0 -2
  195. package/src/db/utils.js +2 -0
  196. package/src/definitions/datasource.ts +0 -1
  197. package/src/index.ts +0 -1
  198. package/src/integrations/base/sqlTable.ts +0 -1
  199. package/src/integrations/mongodb.ts +27 -290
  200. package/src/integrations/rest.ts +5 -17
  201. package/src/integrations/tests/mongo.spec.ts +19 -19
  202. package/src/integrations/tests/rest.spec.ts +22 -38
  203. package/src/migrations/functions/backfill/global.ts +1 -1
  204. package/src/migrations/functions/pluginCount.ts +12 -0
  205. package/src/migrations/functions/{syncQuotas.ts → quotas1.ts} +8 -3
  206. package/src/migrations/functions/tests/{syncQuotas.spec.js → quotas1.spec.js} +2 -5
  207. package/src/migrations/functions/usageQuotas/syncApps.ts +1 -0
  208. package/src/migrations/functions/usageQuotas/syncRows.ts +6 -15
  209. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +1 -9
  210. package/src/migrations/index.ts +45 -20
  211. package/src/migrations/tests/index.spec.ts +1 -0
  212. package/src/utilities/csvParser.js +0 -1
  213. package/src/utilities/rowProcessor/index.js +0 -5
  214. package/src/utilities/usageQuota/rows.js +3 -7
  215. package/src/migrations/functions/usageQuotas/syncPlugins.ts +0 -10
@@ -6,12 +6,13 @@ import {
6
6
  } from "@budibase/types"
7
7
  import {
8
8
  MongoClient,
9
- ObjectId,
10
- Filter,
11
- UpdateFilter,
12
- FindOneAndUpdateOptions,
13
- UpdateOptions,
14
- OperationOptions,
9
+ ObjectID,
10
+ FilterQuery,
11
+ UpdateQuery,
12
+ FindOneAndUpdateOption,
13
+ UpdateOneOptions,
14
+ UpdateManyOptions,
15
+ CommonOptions,
15
16
  } from "mongodb"
16
17
 
17
18
  interface MongoDBConfig {
@@ -56,232 +57,6 @@ const SCHEMA: Integration = {
56
57
  delete: {
57
58
  type: QueryType.JSON,
58
59
  },
59
- aggregate: {
60
- type: QueryType.JSON,
61
- steps: [
62
- {
63
- key: "$addFields",
64
- template: "{\n\t\n}",
65
- },
66
- {
67
- key: "$bucket",
68
- template: `{
69
- "groupBy": "",
70
- "boundaries": [],
71
- "default": "",
72
- "output": {}
73
- }`,
74
- },
75
- {
76
- key: "$bucketAuto",
77
- template: `{
78
- "groupBy": "",
79
- "buckets": 1,
80
- "output": {},
81
- "granularity": "R5"
82
- }`,
83
- },
84
- {
85
- key: "$changeStream",
86
- template: `{
87
- "allChangesForCluster": true,
88
- "fullDocument": "",
89
- "fullDocumentBeforeChange": "",
90
- "resumeAfter": 1,
91
- "showExpandedEvents": true,
92
- "startAfter": {},
93
- "startAtOperationTime": ""
94
- }`,
95
- },
96
- {
97
- key: "$collStats",
98
- template: `{
99
- "latencyStats": { "histograms": true } },
100
- "storageStats": { "scale": 1 } },
101
- "count": {},
102
- "queryExecStats": {}
103
- }`,
104
- },
105
- {
106
- key: "$count",
107
- template: ``,
108
- },
109
- {
110
- key: "$densify",
111
- template: `{
112
- "field": "",
113
- "partitionByFields": [],
114
- "range": {
115
- "step": 1,
116
- "unit": 1,
117
- "bounds": "full"
118
- }
119
- }`,
120
- },
121
- {
122
- key: "$documents",
123
- template: `[]`,
124
- },
125
- {
126
- key: "$facet",
127
- template: `{\n\t\n}`,
128
- },
129
- {
130
- key: "$fill",
131
- template: `{
132
- "partitionBy": "",
133
- "partitionByFields": [],
134
- "sortBy": {},
135
- "output": {}
136
- }`,
137
- },
138
- {
139
- key: "$geoNear",
140
- template: `{
141
- "near": {
142
- "type": "Point",
143
- "coordinates": [
144
- -73.98142, 40.71782
145
- ]
146
- },
147
- "key": "location",
148
- "distanceField": "dist.calculated",
149
- "query": { "category": "Parks" }
150
- }`,
151
- },
152
- {
153
- key: "$graphLookup",
154
- template: `{
155
- "from": "",
156
- "startWith": "",
157
- "connectFromField": "",
158
- "connectToField": "",
159
- "as": "",
160
- "maxDepth": 1,
161
- "depthField": "",
162
- "restrictSearchWithMatch": {}
163
- }`,
164
- },
165
- {
166
- key: "$group",
167
- template: `{
168
- "_id": ""
169
- }`,
170
- },
171
- {
172
- key: "$indexStats",
173
- template: "{\n\t\n}",
174
- },
175
- {
176
- key: "$limit",
177
- template: `1`,
178
- },
179
- {
180
- key: "$listLocalSessions",
181
- template: `{\n\t\n}`,
182
- },
183
- {
184
- key: "$listSessions",
185
- template: `{\n\t\n}`,
186
- },
187
- {
188
- key: "$lookup",
189
- template: `{
190
- "from": "",
191
- "localField": "",
192
- "foreignField": "",
193
- "as": ""
194
- }`,
195
- },
196
- {
197
- key: "$match",
198
- template: "{\n\t\n}",
199
- },
200
- {
201
- key: "$merge",
202
- template: `{
203
- "into": {},
204
- "on": "_id",
205
- "whenMatched": "replace",
206
- "whenNotMatched": "insert"
207
- }`,
208
- },
209
- {
210
- key: "$out",
211
- template: `{
212
- "db": "",
213
- "coll": ""
214
- }`,
215
- },
216
- {
217
- key: "$planCacheStats",
218
- template: "{\n\t\n}",
219
- },
220
- {
221
- key: "$project",
222
- template: "{\n\t\n}",
223
- },
224
- {
225
- key: "$redact",
226
- template: "",
227
- },
228
- {
229
- key: "$replaceRoot",
230
- template: `{ "newRoot": "" }`,
231
- },
232
- {
233
- key: "$replaceWith",
234
- template: ``,
235
- },
236
- {
237
- key: "$sample",
238
- template: `{ "size": 3 }`,
239
- },
240
- {
241
- key: "$set",
242
- template: "{\n\t\n}",
243
- },
244
- {
245
- key: "$setWindowFields",
246
- template: `{
247
- "partitionBy": "",
248
- "sortBy": {},
249
- "output": {}
250
- }`,
251
- },
252
- {
253
- key: "$skip",
254
- template: `1`,
255
- },
256
- {
257
- key: "$sort",
258
- template: "{\n\t\n}",
259
- },
260
- {
261
- key: "$sortByCount",
262
- template: "",
263
- },
264
- {
265
- key: "$unionWith",
266
- template: `{
267
- "coll": "",
268
- "pipeline": []
269
- }`,
270
- },
271
- {
272
- key: "$unset",
273
- template: "",
274
- },
275
- {
276
- key: "$unwind",
277
- template: `{
278
- "path": "",
279
- "includeArrayIndex": "",
280
- "preserveNullAndEmptyArrays": true
281
- }`,
282
- },
283
- ],
284
- },
285
60
  },
286
61
  extra: {
287
62
  collection: {
@@ -289,8 +64,8 @@ const SCHEMA: Integration = {
289
64
  type: DatasourceFieldType.STRING,
290
65
  required: true,
291
66
  },
292
- actionType: {
293
- displayName: "Query Type",
67
+ actionTypes: {
68
+ displayName: "Action Types",
294
69
  type: DatasourceFieldType.LIST,
295
70
  required: true,
296
71
  data: {
@@ -298,7 +73,6 @@ const SCHEMA: Integration = {
298
73
  create: ["insertOne", "insertMany"],
299
74
  update: ["updateOne", "updateMany"],
300
75
  delete: ["deleteOne", "deleteMany"],
301
- aggregate: ["json", "pipeline"],
302
76
  },
303
77
  },
304
78
  },
@@ -330,7 +104,7 @@ class MongoIntegration implements IntegrationBase {
330
104
  ) {
331
105
  const id = json[field].match(/(?<=objectid\(['"]).*(?=['"]\))/gi)?.[0]
332
106
  if (id) {
333
- json[field] = ObjectId.createFromHexString(id)
107
+ json[field] = ObjectID.createFromHexString(id)
334
108
  }
335
109
  }
336
110
  }
@@ -394,7 +168,7 @@ class MongoIntegration implements IntegrationBase {
394
168
 
395
169
  // For mongodb we add an extra actionType to specify
396
170
  // which method we want to call on the collection
397
- switch (query.extra.actionType) {
171
+ switch (query.extra.actionTypes) {
398
172
  case "insertOne": {
399
173
  return await collection.insertOne(json)
400
174
  }
@@ -403,7 +177,7 @@ class MongoIntegration implements IntegrationBase {
403
177
  }
404
178
  default: {
405
179
  throw new Error(
406
- `actionType ${query.extra.actionType} does not exist on DB for create`
180
+ `actionType ${query.extra.actionTypes} does not exist on DB for create`
407
181
  )
408
182
  }
409
183
  }
@@ -422,7 +196,7 @@ class MongoIntegration implements IntegrationBase {
422
196
  const collection = db.collection(query.extra.collection)
423
197
  let json = this.createObjectIds(query.json)
424
198
 
425
- switch (query.extra.actionType) {
199
+ switch (query.extra.actionTypes) {
426
200
  case "find": {
427
201
  return await collection.find(json).toArray()
428
202
  }
@@ -434,9 +208,9 @@ class MongoIntegration implements IntegrationBase {
434
208
  json = this.parseQueryParams(query.json, "update")
435
209
  }
436
210
  let findAndUpdateJson = this.createObjectIds(json) as {
437
- filter: Filter<any>
438
- update: UpdateFilter<any>
439
- options: FindOneAndUpdateOptions
211
+ filter: FilterQuery<any>
212
+ update: UpdateQuery<any>
213
+ options: FindOneAndUpdateOption<any>
440
214
  }
441
215
  return await collection.findOneAndUpdate(
442
216
  findAndUpdateJson.filter,
@@ -452,7 +226,7 @@ class MongoIntegration implements IntegrationBase {
452
226
  }
453
227
  default: {
454
228
  throw new Error(
455
- `actionType ${query.extra.actionType} does not exist on DB for read`
229
+ `actionType ${query.extra.actionTypes} does not exist on DB for read`
456
230
  )
457
231
  }
458
232
  }
@@ -474,29 +248,29 @@ class MongoIntegration implements IntegrationBase {
474
248
  queryJson = this.parseQueryParams(queryJson, "update")
475
249
  }
476
250
  let json = this.createObjectIds(queryJson) as {
477
- filter: Filter<any>
478
- update: UpdateFilter<any>
251
+ filter: FilterQuery<any>
252
+ update: UpdateQuery<any>
479
253
  options: object
480
254
  }
481
255
 
482
- switch (query.extra.actionType) {
256
+ switch (query.extra.actionTypes) {
483
257
  case "updateOne": {
484
258
  return await collection.updateOne(
485
259
  json.filter,
486
260
  json.update,
487
- json.options as UpdateOptions
261
+ json.options as UpdateOneOptions
488
262
  )
489
263
  }
490
264
  case "updateMany": {
491
265
  return await collection.updateMany(
492
266
  json.filter,
493
267
  json.update,
494
- json.options as UpdateOptions
268
+ json.options as UpdateManyOptions
495
269
  )
496
270
  }
497
271
  default: {
498
272
  throw new Error(
499
- `actionType ${query.extra.actionType} does not exist on DB for update`
273
+ `actionType ${query.extra.actionTypes} does not exist on DB for update`
500
274
  )
501
275
  }
502
276
  }
@@ -518,8 +292,8 @@ class MongoIntegration implements IntegrationBase {
518
292
  queryJson = this.parseQueryParams(queryJson, "delete")
519
293
  }
520
294
  let json = this.createObjectIds(queryJson) as {
521
- filter: Filter<any>
522
- options: OperationOptions
295
+ filter: FilterQuery<any>
296
+ options: CommonOptions
523
297
  }
524
298
  if (!json.options) {
525
299
  json = {
@@ -528,7 +302,7 @@ class MongoIntegration implements IntegrationBase {
528
302
  }
529
303
  }
530
304
 
531
- switch (query.extra.actionType) {
305
+ switch (query.extra.actionTypes) {
532
306
  case "deleteOne": {
533
307
  return await collection.deleteOne(json.filter, json.options)
534
308
  }
@@ -537,7 +311,7 @@ class MongoIntegration implements IntegrationBase {
537
311
  }
538
312
  default: {
539
313
  throw new Error(
540
- `actionType ${query.extra.actionType} does not exist on DB for delete`
314
+ `actionType ${query.extra.actionTypes} does not exist on DB for delete`
541
315
  )
542
316
  }
543
317
  }
@@ -548,43 +322,6 @@ class MongoIntegration implements IntegrationBase {
548
322
  await this.client.close()
549
323
  }
550
324
  }
551
-
552
- async aggregate(query: {
553
- json: object
554
- steps: any[]
555
- extra: { [key: string]: string }
556
- }) {
557
- try {
558
- await this.connect()
559
- const db = this.client.db(this.config.db)
560
- const collection = db.collection(query.extra.collection)
561
- let response = []
562
- if (query.extra?.actionType === "pipeline") {
563
- for await (const doc of collection.aggregate(
564
- query.steps.map(({ key, value }) => {
565
- let temp: any = {}
566
- temp[key] = JSON.parse(value.value)
567
- return this.createObjectIds(temp)
568
- })
569
- )) {
570
- response.push(doc)
571
- }
572
- } else {
573
- const stages: Array<any> = query.json as Array<any>
574
- for await (const doc of collection.aggregate(
575
- stages ? this.createObjectIds(stages) : []
576
- )) {
577
- response.push(doc)
578
- }
579
- }
580
- return response
581
- } catch (err) {
582
- console.error("Error writing to mongodb", err)
583
- throw err
584
- } finally {
585
- await this.client.close()
586
- }
587
- }
588
325
  }
589
326
 
590
327
  export default {
@@ -14,7 +14,6 @@ import {
14
14
  BearerAuthConfig,
15
15
  } from "../definitions/datasource"
16
16
  import { get } from "lodash"
17
- import * as https from "https"
18
17
  import qs from "querystring"
19
18
  const fetch = require("node-fetch")
20
19
  const { formatBytes } = require("../utilities")
@@ -77,11 +76,11 @@ const SCHEMA: Integration = {
77
76
  required: false,
78
77
  default: {},
79
78
  },
80
- rejectUnauthorized: {
81
- display: "Reject Unauthorized",
79
+ legacyHttpParser: {
80
+ display: "Legacy HTTP Support",
82
81
  type: DatasourceFieldType.BOOLEAN,
83
- default: true,
84
82
  required: false,
83
+ default: false,
85
84
  },
86
85
  },
87
86
  query: {
@@ -219,12 +218,8 @@ class RestIntegration implements IntegrationBase {
219
218
  }
220
219
  }
221
220
 
222
- if (queryString) {
223
- // make sure the query string is fully encoded
224
- queryString = "?" + qs.encode(qs.decode(queryString))
225
- }
226
- const main = `${path}${queryString}`
227
-
221
+ // make sure the query string is fully encoded
222
+ const main = `${path}?${qs.encode(qs.decode(queryString))}`
228
223
  let complete = main
229
224
  if (this.config.url && !main.startsWith("http")) {
230
225
  complete = !this.config.url ? main : `${this.config.url}/${main}`
@@ -386,13 +381,6 @@ class RestIntegration implements IntegrationBase {
386
381
  paginationValues
387
382
  )
388
383
 
389
- if (this.config.rejectUnauthorized == false) {
390
- input.agent = new https.Agent({
391
- rejectUnauthorized: false,
392
- })
393
- }
394
-
395
- // Deprecated by rejectUnauthorized
396
384
  if (this.config.legacyHttpParser) {
397
385
  // https://github.com/nodejs/node/issues/43798
398
386
  input.extraHttpOptions = { insecureHTTPParser: true }
@@ -34,7 +34,7 @@ describe("MongoDB Integration", () => {
34
34
  await config.integration.create({
35
35
  index: indexName,
36
36
  json: body,
37
- extra: { collection: "testCollection", actionType: "insertOne" },
37
+ extra: { collection: "testCollection", actionTypes: "insertOne" },
38
38
  })
39
39
  expect(config.integration.client.insertOne).toHaveBeenCalledWith(body)
40
40
  })
@@ -44,7 +44,7 @@ describe("MongoDB Integration", () => {
44
44
  json: {
45
45
  address: "test",
46
46
  },
47
- extra: { collection: "testCollection", actionType: "find" },
47
+ extra: { collection: "testCollection", actionTypes: "find" },
48
48
  }
49
49
  const response = await config.integration.read(query)
50
50
  expect(config.integration.client.find).toHaveBeenCalledWith(query.json)
@@ -61,7 +61,7 @@ describe("MongoDB Integration", () => {
61
61
  opt: "option",
62
62
  },
63
63
  },
64
- extra: { collection: "testCollection", actionType: "deleteOne" },
64
+ extra: { collection: "testCollection", actionTypes: "deleteOne" },
65
65
  }
66
66
  await config.integration.delete(query)
67
67
  expect(config.integration.client.deleteOne).toHaveBeenCalledWith(
@@ -83,7 +83,7 @@ describe("MongoDB Integration", () => {
83
83
  upsert: false,
84
84
  },
85
85
  },
86
- extra: { collection: "testCollection", actionType: "updateOne" },
86
+ extra: { collection: "testCollection", actionTypes: "updateOne" },
87
87
  }
88
88
  await config.integration.update(query)
89
89
  expect(config.integration.client.updateOne).toHaveBeenCalledWith(
@@ -97,7 +97,7 @@ describe("MongoDB Integration", () => {
97
97
  const restore = disableConsole()
98
98
 
99
99
  const query = {
100
- extra: { collection: "testCollection", actionType: "deleteOne" },
100
+ extra: { collection: "testCollection", actionTypes: "deleteOne" },
101
101
  }
102
102
 
103
103
  let error = null
@@ -125,19 +125,19 @@ describe("MongoDB Integration", () => {
125
125
  upsert: false,
126
126
  },
127
127
  },
128
- extra: { collection: "testCollection", actionType: "updateOne" },
128
+ extra: { collection: "testCollection", actionTypes: "updateOne" },
129
129
  }
130
130
  await config.integration.update(query)
131
131
  expect(config.integration.client.updateOne).toHaveBeenCalled()
132
132
 
133
133
  const args = config.integration.client.updateOne.mock.calls[0]
134
134
  expect(args[0]).toEqual({
135
- _id: mongo.ObjectId.createFromHexString("ACBD12345678ABCD12345678"),
136
- name: mongo.ObjectId.createFromHexString("BBBB12345678ABCD12345678"),
135
+ _id: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
136
+ name: mongo.ObjectID.createFromHexString("BBBB12345678ABCD12345678"),
137
137
  })
138
138
  expect(args[1]).toEqual({
139
- _id: mongo.ObjectId.createFromHexString("FFFF12345678ABCD12345678"),
140
- name: mongo.ObjectId.createFromHexString("CCCC12345678ABCD12345678"),
139
+ _id: mongo.ObjectID.createFromHexString("FFFF12345678ABCD12345678"),
140
+ name: mongo.ObjectID.createFromHexString("CCCC12345678ABCD12345678"),
141
141
  })
142
142
  expect(args[2]).toEqual({
143
143
  upsert: false,
@@ -161,7 +161,7 @@ describe("MongoDB Integration", () => {
161
161
  upsert: true,
162
162
  },
163
163
  },
164
- extra: { collection: "testCollection", actionType: "updateOne" },
164
+ extra: { collection: "testCollection", actionTypes: "updateOne" },
165
165
  }
166
166
  await config.integration.update(query)
167
167
  expect(config.integration.client.updateOne).toHaveBeenCalled()
@@ -169,12 +169,12 @@ describe("MongoDB Integration", () => {
169
169
  const args = config.integration.client.updateOne.mock.calls[0]
170
170
  expect(args[0]).toEqual({
171
171
  _id: {
172
- $eq: mongo.ObjectId.createFromHexString("ACBD12345678ABCD12345678"),
172
+ $eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
173
173
  },
174
174
  })
175
175
  expect(args[1]).toEqual({
176
176
  $set: {
177
- _id: mongo.ObjectId.createFromHexString("FFFF12345678ABCD12345678"),
177
+ _id: mongo.ObjectID.createFromHexString("FFFF12345678ABCD12345678"),
178
178
  },
179
179
  })
180
180
  expect(args[2]).toEqual({
@@ -200,7 +200,7 @@ describe("MongoDB Integration", () => {
200
200
  upsert: false,
201
201
  },
202
202
  },
203
- extra: { collection: "testCollection", actionType: "findOneAndUpdate" },
203
+ extra: { collection: "testCollection", actionTypes: "findOneAndUpdate" },
204
204
  }
205
205
  await config.integration.read(query)
206
206
  expect(config.integration.client.findOneAndUpdate).toHaveBeenCalled()
@@ -208,7 +208,7 @@ describe("MongoDB Integration", () => {
208
208
  const args = config.integration.client.findOneAndUpdate.mock.calls[0]
209
209
  expect(args[0]).toEqual({
210
210
  _id: {
211
- $eq: mongo.ObjectId.createFromHexString("ACBD12345678ABCD12345678"),
211
+ $eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
212
212
  },
213
213
  })
214
214
  expect(args[1]).toEqual({
@@ -245,7 +245,7 @@ describe("MongoDB Integration", () => {
245
245
  {
246
246
  "upsert": true
247
247
  }`,
248
- extra: { collection: "testCollection", actionType: "updateOne" },
248
+ extra: { collection: "testCollection", actionTypes: "updateOne" },
249
249
  }
250
250
  await config.integration.update(query)
251
251
  expect(config.integration.client.updateOne).toHaveBeenCalled()
@@ -253,7 +253,7 @@ describe("MongoDB Integration", () => {
253
253
  const args = config.integration.client.updateOne.mock.calls[0]
254
254
  expect(args[0]).toEqual({
255
255
  _id: {
256
- $eq: mongo.ObjectId.createFromHexString("ACBD12345678ABCD12345678"),
256
+ $eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
257
257
  },
258
258
  })
259
259
  expect(args[1]).toEqual({
@@ -300,7 +300,7 @@ describe("MongoDB Integration", () => {
300
300
  "upsert": true,
301
301
  "extra": "ad\\"{\\"d"
302
302
  }`,
303
- extra: { collection: "testCollection", actionType: "updateOne" },
303
+ extra: { collection: "testCollection", actionTypes: "updateOne" },
304
304
  }
305
305
  await config.integration.update(query)
306
306
  expect(config.integration.client.updateOne).toHaveBeenCalled()
@@ -308,7 +308,7 @@ describe("MongoDB Integration", () => {
308
308
  const args = config.integration.client.updateOne.mock.calls[0]
309
309
  expect(args[0]).toEqual({
310
310
  _id: {
311
- $eq: mongo.ObjectId.createFromHexString("ACBD12345678ABCD12345678"),
311
+ $eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
312
312
  },
313
313
  })
314
314
  expect(args[1]).toEqual({