@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.
- package/__mocks__/mongodb.ts +1 -1
- package/builder/assets/{index.b1aa5e8a.js → index.c4b43e7e.js} +283 -287
- package/builder/assets/{index.a6a040bb.css → index.dfa4073c.css} +2 -2
- package/builder/index.html +2 -2
- package/coverage/clover.xml +491 -495
- package/coverage/coverage-final.json +26 -26
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +2 -2
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +12 -12
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +15 -15
- package/coverage/lcov-report/api/controllers/row/utils.js.html +13 -13
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +5 -5
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +5 -5
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +3 -3
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +22 -22
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +2 -8
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +11 -11
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +11 -11
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +3 -3
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +16 -10
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +2 -2
- package/coverage/lcov-report/events/utils.js.html +9 -9
- package/coverage/lcov-report/index.html +24 -24
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +11 -11
- package/coverage/lcov-report/middleware/currentapp.js.html +34 -34
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +8 -11
- package/coverage/lcov-report/utilities/global.js.html +16 -16
- package/coverage/lcov-report/utilities/index.html +15 -15
- package/coverage/lcov-report/utilities/index.js.html +7 -7
- package/coverage/lcov-report/utilities/plugins.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +13 -13
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +39 -54
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +14 -14
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +11 -23
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +892 -900
- package/dist/api/controllers/application.js +2 -2
- package/dist/api/controllers/dev.js +1 -1
- package/dist/api/controllers/query/index.js +2 -7
- package/dist/api/controllers/row/index.js +10 -30
- package/dist/api/controllers/static/templates/preview.hbs +0 -10
- package/dist/api/controllers/table/internal.js +2 -8
- package/dist/api/controllers/table/utils.js +1 -3
- package/dist/automations/steps/updateRow.js +2 -2
- package/dist/automations/utils.js +3 -5
- package/dist/constants/index.js +0 -2
- package/dist/db/utils.js +1 -1
- package/dist/index.js +0 -1
- package/dist/integrations/base/sqlTable.js +0 -1
- package/dist/integrations/mongodb.js +11 -300
- package/dist/integrations/rest.js +5 -38
- package/dist/migrations/functions/{usageQuotas/syncPlugins.js → pluginCount.js} +3 -1
- package/dist/migrations/functions/{syncQuotas.js → quotas1.js} +7 -3
- package/dist/migrations/functions/usageQuotas/syncApps.js +1 -0
- package/dist/migrations/functions/usageQuotas/syncRows.js +5 -9
- package/dist/migrations/index.js +38 -9
- package/dist/package.json +9 -8
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/csvParser.js +0 -1
- package/dist/utilities/rowProcessor/index.js +0 -5
- package/dist/utilities/usageQuota/rows.js +4 -6
- package/package.json +10 -9
- package/specs/openapi.json +0 -3
- package/specs/openapi.yaml +0 -3
- package/src/api/controllers/application.ts +2 -2
- package/src/api/controllers/deploy/index.ts +1 -0
- package/src/api/controllers/dev.js +1 -1
- package/src/api/controllers/query/index.ts +2 -8
- package/src/api/controllers/row/index.ts +13 -36
- package/src/api/controllers/static/templates/preview.hbs +0 -10
- package/src/api/controllers/table/internal.ts +2 -5
- package/src/api/controllers/table/utils.ts +1 -3
- package/src/api/routes/tests/row.spec.js +27 -22
- package/src/automations/steps/updateRow.js +2 -2
- package/src/automations/tests/automation.spec.js +6 -1
- package/src/automations/utils.ts +4 -6
- package/src/constants/index.js +0 -2
- package/src/db/utils.js +2 -0
- package/src/definitions/datasource.ts +0 -1
- package/src/index.ts +0 -1
- package/src/integrations/base/sqlTable.ts +0 -1
- package/src/integrations/mongodb.ts +27 -290
- package/src/integrations/rest.ts +5 -17
- package/src/integrations/tests/mongo.spec.ts +19 -19
- package/src/integrations/tests/rest.spec.ts +22 -38
- package/src/migrations/functions/backfill/global.ts +1 -1
- package/src/migrations/functions/pluginCount.ts +12 -0
- package/src/migrations/functions/{syncQuotas.ts → quotas1.ts} +8 -3
- package/src/migrations/functions/tests/{syncQuotas.spec.js → quotas1.spec.js} +2 -5
- package/src/migrations/functions/usageQuotas/syncApps.ts +1 -0
- package/src/migrations/functions/usageQuotas/syncRows.ts +6 -15
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +1 -9
- package/src/migrations/index.ts +45 -20
- package/src/migrations/tests/index.spec.ts +1 -0
- package/src/utilities/csvParser.js +0 -1
- package/src/utilities/rowProcessor/index.js +0 -5
- package/src/utilities/usageQuota/rows.js +3 -7
- 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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
293
|
-
displayName: "
|
|
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] =
|
|
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.
|
|
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.
|
|
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.
|
|
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:
|
|
438
|
-
update:
|
|
439
|
-
options:
|
|
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.
|
|
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:
|
|
478
|
-
update:
|
|
251
|
+
filter: FilterQuery<any>
|
|
252
|
+
update: UpdateQuery<any>
|
|
479
253
|
options: object
|
|
480
254
|
}
|
|
481
255
|
|
|
482
|
-
switch (query.extra.
|
|
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
|
|
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
|
|
268
|
+
json.options as UpdateManyOptions
|
|
495
269
|
)
|
|
496
270
|
}
|
|
497
271
|
default: {
|
|
498
272
|
throw new Error(
|
|
499
|
-
`actionType ${query.extra.
|
|
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:
|
|
522
|
-
options:
|
|
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.
|
|
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.
|
|
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 {
|
package/src/integrations/rest.ts
CHANGED
|
@@ -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
|
-
|
|
81
|
-
display: "
|
|
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
|
-
|
|
223
|
-
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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.
|
|
136
|
-
name: mongo.
|
|
135
|
+
_id: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
|
|
136
|
+
name: mongo.ObjectID.createFromHexString("BBBB12345678ABCD12345678"),
|
|
137
137
|
})
|
|
138
138
|
expect(args[1]).toEqual({
|
|
139
|
-
_id: mongo.
|
|
140
|
-
name: mongo.
|
|
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",
|
|
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.
|
|
172
|
+
$eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
|
|
173
173
|
},
|
|
174
174
|
})
|
|
175
175
|
expect(args[1]).toEqual({
|
|
176
176
|
$set: {
|
|
177
|
-
_id: mongo.
|
|
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",
|
|
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.
|
|
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",
|
|
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.
|
|
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",
|
|
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.
|
|
311
|
+
$eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
|
|
312
312
|
},
|
|
313
313
|
})
|
|
314
314
|
expect(args[1]).toEqual({
|