@budibase/server 2.0.30-alpha.2 → 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.
- package/__mocks__/mongodb.ts +1 -1
- package/builder/assets/{index.57d5334d.js → index.0f137fa3.js} +243 -239
- package/builder/assets/{index.e56da48a.css → index.a6a040bb.css} +1 -1
- package/builder/index.html +2 -2
- package/coverage/clover.xml +185 -184
- package/coverage/coverage-final.json +3 -3
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +8 -2
- 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 +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +14 -14
- 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 +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- 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 +11 -8
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +15 -15
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/plugins.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- 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 +17 -2
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- 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 +324 -321
- package/dist/constants/index.js +2 -0
- package/dist/integrations/base/sqlTable.js +1 -0
- package/dist/integrations/mongodb.js +300 -11
- package/dist/package.json +7 -8
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/csvParser.js +1 -0
- package/dist/utilities/rowProcessor/index.js +5 -0
- package/package.json +8 -9
- package/specs/openapi.json +3 -0
- package/specs/openapi.yaml +3 -0
- package/src/constants/index.js +2 -0
- package/src/integrations/base/sqlTable.ts +1 -0
- package/src/integrations/mongodb.ts +290 -27
- package/src/integrations/tests/mongo.spec.ts +19 -19
- package/src/utilities/csvParser.js +1 -0
- package/src/utilities/rowProcessor/index.js +5 -0
|
@@ -13,6 +13,7 @@ const { FieldTypes } = require("../constants");
|
|
|
13
13
|
const VALIDATORS = {
|
|
14
14
|
[FieldTypes.STRING]: () => true,
|
|
15
15
|
[FieldTypes.OPTIONS]: () => true,
|
|
16
|
+
[FieldTypes.BARCODEQR]: () => true,
|
|
16
17
|
[FieldTypes.NUMBER]: attribute => {
|
|
17
18
|
// allow not to be present
|
|
18
19
|
if (!attribute) {
|
package/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.
|
|
4
|
+
"version": "2.0.30-alpha.4",
|
|
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.
|
|
81
|
-
"@budibase/client": "2.0.30-alpha.
|
|
82
|
-
"@budibase/pro": "2.0.30-alpha.
|
|
83
|
-
"@budibase/string-templates": "2.0.30-alpha.
|
|
84
|
-
"@budibase/types": "2.0.30-alpha.
|
|
80
|
+
"@budibase/backend-core": "2.0.30-alpha.4",
|
|
81
|
+
"@budibase/client": "2.0.30-alpha.4",
|
|
82
|
+
"@budibase/pro": "2.0.30-alpha.3",
|
|
83
|
+
"@budibase/string-templates": "2.0.30-alpha.4",
|
|
84
|
+
"@budibase/types": "2.0.30-alpha.4",
|
|
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": "
|
|
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",
|
|
@@ -199,5 +198,5 @@
|
|
|
199
198
|
"optionalDependencies": {
|
|
200
199
|
"oracledb": "5.3.0"
|
|
201
200
|
},
|
|
202
|
-
"gitHead": "
|
|
201
|
+
"gitHead": "3cd510757350340571fe0bf9895302e233cda95a"
|
|
203
202
|
}
|
package/specs/openapi.json
CHANGED
|
@@ -783,6 +783,7 @@
|
|
|
783
783
|
"type": "string",
|
|
784
784
|
"enum": [
|
|
785
785
|
"string",
|
|
786
|
+
"barcodeqr",
|
|
786
787
|
"longform",
|
|
787
788
|
"options",
|
|
788
789
|
"number",
|
|
@@ -986,6 +987,7 @@
|
|
|
986
987
|
"type": "string",
|
|
987
988
|
"enum": [
|
|
988
989
|
"string",
|
|
990
|
+
"barcodeqr",
|
|
989
991
|
"longform",
|
|
990
992
|
"options",
|
|
991
993
|
"number",
|
|
@@ -1200,6 +1202,7 @@
|
|
|
1200
1202
|
"type": "string",
|
|
1201
1203
|
"enum": [
|
|
1202
1204
|
"string",
|
|
1205
|
+
"barcodeqr",
|
|
1203
1206
|
"longform",
|
|
1204
1207
|
"options",
|
|
1205
1208
|
"number",
|
package/specs/openapi.yaml
CHANGED
|
@@ -579,6 +579,7 @@ components:
|
|
|
579
579
|
type: string
|
|
580
580
|
enum:
|
|
581
581
|
- string
|
|
582
|
+
- barcodeqr
|
|
582
583
|
- longform
|
|
583
584
|
- options
|
|
584
585
|
- number
|
|
@@ -741,6 +742,7 @@ components:
|
|
|
741
742
|
type: string
|
|
742
743
|
enum:
|
|
743
744
|
- string
|
|
745
|
+
- barcodeqr
|
|
744
746
|
- longform
|
|
745
747
|
- options
|
|
746
748
|
- number
|
|
@@ -910,6 +912,7 @@ components:
|
|
|
910
912
|
type: string
|
|
911
913
|
enum:
|
|
912
914
|
- string
|
|
915
|
+
- barcodeqr
|
|
913
916
|
- longform
|
|
914
917
|
- options
|
|
915
918
|
- number
|
package/src/constants/index.js
CHANGED
|
@@ -31,6 +31,7 @@ exports.NoEmptyFilterStrings = [
|
|
|
31
31
|
|
|
32
32
|
exports.FieldTypes = {
|
|
33
33
|
STRING: "string",
|
|
34
|
+
BARCODEQR: "barcodeqr",
|
|
34
35
|
LONGFORM: "longform",
|
|
35
36
|
OPTIONS: "options",
|
|
36
37
|
NUMBER: "number",
|
|
@@ -51,6 +52,7 @@ exports.CanSwitchTypes = [
|
|
|
51
52
|
exports.FieldTypes.STRING,
|
|
52
53
|
exports.FieldTypes.OPTIONS,
|
|
53
54
|
exports.FieldTypes.LONGFORM,
|
|
55
|
+
exports.FieldTypes.BARCODEQR,
|
|
54
56
|
],
|
|
55
57
|
[exports.FieldTypes.BOOLEAN, exports.FieldTypes.NUMBER],
|
|
56
58
|
]
|
|
@@ -6,13 +6,12 @@ import {
|
|
|
6
6
|
} from "@budibase/types"
|
|
7
7
|
import {
|
|
8
8
|
MongoClient,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
CommonOptions,
|
|
9
|
+
ObjectId,
|
|
10
|
+
Filter,
|
|
11
|
+
UpdateFilter,
|
|
12
|
+
FindOneAndUpdateOptions,
|
|
13
|
+
UpdateOptions,
|
|
14
|
+
OperationOptions,
|
|
16
15
|
} from "mongodb"
|
|
17
16
|
|
|
18
17
|
interface MongoDBConfig {
|
|
@@ -57,6 +56,232 @@ const SCHEMA: Integration = {
|
|
|
57
56
|
delete: {
|
|
58
57
|
type: QueryType.JSON,
|
|
59
58
|
},
|
|
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
|
+
},
|
|
60
285
|
},
|
|
61
286
|
extra: {
|
|
62
287
|
collection: {
|
|
@@ -64,8 +289,8 @@ const SCHEMA: Integration = {
|
|
|
64
289
|
type: DatasourceFieldType.STRING,
|
|
65
290
|
required: true,
|
|
66
291
|
},
|
|
67
|
-
|
|
68
|
-
displayName: "
|
|
292
|
+
actionType: {
|
|
293
|
+
displayName: "Query Type",
|
|
69
294
|
type: DatasourceFieldType.LIST,
|
|
70
295
|
required: true,
|
|
71
296
|
data: {
|
|
@@ -73,6 +298,7 @@ const SCHEMA: Integration = {
|
|
|
73
298
|
create: ["insertOne", "insertMany"],
|
|
74
299
|
update: ["updateOne", "updateMany"],
|
|
75
300
|
delete: ["deleteOne", "deleteMany"],
|
|
301
|
+
aggregate: ["json", "pipeline"],
|
|
76
302
|
},
|
|
77
303
|
},
|
|
78
304
|
},
|
|
@@ -104,7 +330,7 @@ class MongoIntegration implements IntegrationBase {
|
|
|
104
330
|
) {
|
|
105
331
|
const id = json[field].match(/(?<=objectid\(['"]).*(?=['"]\))/gi)?.[0]
|
|
106
332
|
if (id) {
|
|
107
|
-
json[field] =
|
|
333
|
+
json[field] = ObjectId.createFromHexString(id)
|
|
108
334
|
}
|
|
109
335
|
}
|
|
110
336
|
}
|
|
@@ -168,7 +394,7 @@ class MongoIntegration implements IntegrationBase {
|
|
|
168
394
|
|
|
169
395
|
// For mongodb we add an extra actionType to specify
|
|
170
396
|
// which method we want to call on the collection
|
|
171
|
-
switch (query.extra.
|
|
397
|
+
switch (query.extra.actionType) {
|
|
172
398
|
case "insertOne": {
|
|
173
399
|
return await collection.insertOne(json)
|
|
174
400
|
}
|
|
@@ -177,7 +403,7 @@ class MongoIntegration implements IntegrationBase {
|
|
|
177
403
|
}
|
|
178
404
|
default: {
|
|
179
405
|
throw new Error(
|
|
180
|
-
`actionType ${query.extra.
|
|
406
|
+
`actionType ${query.extra.actionType} does not exist on DB for create`
|
|
181
407
|
)
|
|
182
408
|
}
|
|
183
409
|
}
|
|
@@ -196,7 +422,7 @@ class MongoIntegration implements IntegrationBase {
|
|
|
196
422
|
const collection = db.collection(query.extra.collection)
|
|
197
423
|
let json = this.createObjectIds(query.json)
|
|
198
424
|
|
|
199
|
-
switch (query.extra.
|
|
425
|
+
switch (query.extra.actionType) {
|
|
200
426
|
case "find": {
|
|
201
427
|
return await collection.find(json).toArray()
|
|
202
428
|
}
|
|
@@ -208,9 +434,9 @@ class MongoIntegration implements IntegrationBase {
|
|
|
208
434
|
json = this.parseQueryParams(query.json, "update")
|
|
209
435
|
}
|
|
210
436
|
let findAndUpdateJson = this.createObjectIds(json) as {
|
|
211
|
-
filter:
|
|
212
|
-
update:
|
|
213
|
-
options:
|
|
437
|
+
filter: Filter<any>
|
|
438
|
+
update: UpdateFilter<any>
|
|
439
|
+
options: FindOneAndUpdateOptions
|
|
214
440
|
}
|
|
215
441
|
return await collection.findOneAndUpdate(
|
|
216
442
|
findAndUpdateJson.filter,
|
|
@@ -226,7 +452,7 @@ class MongoIntegration implements IntegrationBase {
|
|
|
226
452
|
}
|
|
227
453
|
default: {
|
|
228
454
|
throw new Error(
|
|
229
|
-
`actionType ${query.extra.
|
|
455
|
+
`actionType ${query.extra.actionType} does not exist on DB for read`
|
|
230
456
|
)
|
|
231
457
|
}
|
|
232
458
|
}
|
|
@@ -248,29 +474,29 @@ class MongoIntegration implements IntegrationBase {
|
|
|
248
474
|
queryJson = this.parseQueryParams(queryJson, "update")
|
|
249
475
|
}
|
|
250
476
|
let json = this.createObjectIds(queryJson) as {
|
|
251
|
-
filter:
|
|
252
|
-
update:
|
|
477
|
+
filter: Filter<any>
|
|
478
|
+
update: UpdateFilter<any>
|
|
253
479
|
options: object
|
|
254
480
|
}
|
|
255
481
|
|
|
256
|
-
switch (query.extra.
|
|
482
|
+
switch (query.extra.actionType) {
|
|
257
483
|
case "updateOne": {
|
|
258
484
|
return await collection.updateOne(
|
|
259
485
|
json.filter,
|
|
260
486
|
json.update,
|
|
261
|
-
json.options as
|
|
487
|
+
json.options as UpdateOptions
|
|
262
488
|
)
|
|
263
489
|
}
|
|
264
490
|
case "updateMany": {
|
|
265
491
|
return await collection.updateMany(
|
|
266
492
|
json.filter,
|
|
267
493
|
json.update,
|
|
268
|
-
json.options as
|
|
494
|
+
json.options as UpdateOptions
|
|
269
495
|
)
|
|
270
496
|
}
|
|
271
497
|
default: {
|
|
272
498
|
throw new Error(
|
|
273
|
-
`actionType ${query.extra.
|
|
499
|
+
`actionType ${query.extra.actionType} does not exist on DB for update`
|
|
274
500
|
)
|
|
275
501
|
}
|
|
276
502
|
}
|
|
@@ -292,8 +518,8 @@ class MongoIntegration implements IntegrationBase {
|
|
|
292
518
|
queryJson = this.parseQueryParams(queryJson, "delete")
|
|
293
519
|
}
|
|
294
520
|
let json = this.createObjectIds(queryJson) as {
|
|
295
|
-
filter:
|
|
296
|
-
options:
|
|
521
|
+
filter: Filter<any>
|
|
522
|
+
options: OperationOptions
|
|
297
523
|
}
|
|
298
524
|
if (!json.options) {
|
|
299
525
|
json = {
|
|
@@ -302,7 +528,7 @@ class MongoIntegration implements IntegrationBase {
|
|
|
302
528
|
}
|
|
303
529
|
}
|
|
304
530
|
|
|
305
|
-
switch (query.extra.
|
|
531
|
+
switch (query.extra.actionType) {
|
|
306
532
|
case "deleteOne": {
|
|
307
533
|
return await collection.deleteOne(json.filter, json.options)
|
|
308
534
|
}
|
|
@@ -311,7 +537,7 @@ class MongoIntegration implements IntegrationBase {
|
|
|
311
537
|
}
|
|
312
538
|
default: {
|
|
313
539
|
throw new Error(
|
|
314
|
-
`actionType ${query.extra.
|
|
540
|
+
`actionType ${query.extra.actionType} does not exist on DB for delete`
|
|
315
541
|
)
|
|
316
542
|
}
|
|
317
543
|
}
|
|
@@ -322,6 +548,43 @@ class MongoIntegration implements IntegrationBase {
|
|
|
322
548
|
await this.client.close()
|
|
323
549
|
}
|
|
324
550
|
}
|
|
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
|
+
}
|
|
325
588
|
}
|
|
326
589
|
|
|
327
590
|
export default {
|