@openfn/language-mongodb 2.1.18 → 2.1.20
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/ast.json +1 -1
- package/configuration-schema.json +33 -2
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/package.json +2 -2
package/ast.json
CHANGED
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
"operation"
|
|
183
183
|
],
|
|
184
184
|
"docs": {
|
|
185
|
-
"description": "
|
|
185
|
+
"description": "Execute a function only when the condition returns true",
|
|
186
186
|
"tags": [
|
|
187
187
|
{
|
|
188
188
|
"title": "public",
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
"clusterHostname": {
|
|
5
5
|
"title": "Cluster Hostname",
|
|
6
6
|
"type": "string",
|
|
7
|
-
"description": "Your MongoDB cluster hostname",
|
|
7
|
+
"description": "Your MongoDB cluster hostname(s).",
|
|
8
8
|
"format": "string",
|
|
9
9
|
"minLength": 1,
|
|
10
10
|
"examples": [
|
|
11
|
-
"yourCluster-xxxyzzz.mongodb.net"
|
|
11
|
+
"yourCluster-xxxyzzz.mongodb.net",
|
|
12
|
+
"localhost:27017,localhost:27018,localhost:27019"
|
|
12
13
|
]
|
|
13
14
|
},
|
|
14
15
|
"username": {
|
|
@@ -29,6 +30,36 @@
|
|
|
29
30
|
"examples": [
|
|
30
31
|
"@secret(!)Pass"
|
|
31
32
|
]
|
|
33
|
+
},
|
|
34
|
+
"protocol": {
|
|
35
|
+
"title": "Protocol",
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "The protocol to use for the MongoDB connection. Default is 'mongodb+srv'.",
|
|
38
|
+
"enum": [
|
|
39
|
+
"mongodb",
|
|
40
|
+
"mongodb+srv"
|
|
41
|
+
],
|
|
42
|
+
"default": "mongodb+srv",
|
|
43
|
+
"examples": [
|
|
44
|
+
"mongodb+srv"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"options": {
|
|
48
|
+
"title": "Options",
|
|
49
|
+
"type": "object",
|
|
50
|
+
"description": "Additional options for the MongoDB connection.",
|
|
51
|
+
"additionalProperties": true,
|
|
52
|
+
"default": {
|
|
53
|
+
"retryWrites": true,
|
|
54
|
+
"w": "majority"
|
|
55
|
+
},
|
|
56
|
+
"examples": [
|
|
57
|
+
{
|
|
58
|
+
"retryWrites": true,
|
|
59
|
+
"w": "majority",
|
|
60
|
+
"rs": "replicaSet"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
32
63
|
}
|
|
33
64
|
},
|
|
34
65
|
"type": "object",
|
package/dist/index.cjs
CHANGED
|
@@ -82,12 +82,12 @@ function execute(...operations) {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
function connect(state) {
|
|
85
|
-
const { clusterHostname, username, password } = state.configuration;
|
|
86
|
-
const uri =
|
|
85
|
+
const { clusterHostname, username, password, protocol = "mongodb+srv", options = { "retryWrites": true, "w": "majority" } } = state.configuration;
|
|
86
|
+
const uri = `${protocol}://${encodeURIComponent(
|
|
87
87
|
username
|
|
88
88
|
)}:${encodeURIComponent(
|
|
89
89
|
password
|
|
90
|
-
)}@${clusterHostname}/test?
|
|
90
|
+
)}@${clusterHostname}/test${Object.keys(options).length ? "?" : ""}${encodeURIComponent(new URLSearchParams(options).toString())}`;
|
|
91
91
|
const client = new MongoClient(uri, { useNewUrlParser: true });
|
|
92
92
|
return new Promise((resolve, reject) => {
|
|
93
93
|
client.connect((err) => {
|
package/dist/index.js
CHANGED
|
@@ -57,12 +57,12 @@ function execute(...operations) {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
function connect(state) {
|
|
60
|
-
const { clusterHostname, username, password } = state.configuration;
|
|
61
|
-
const uri =
|
|
60
|
+
const { clusterHostname, username, password, protocol = "mongodb+srv", options = { "retryWrites": true, "w": "majority" } } = state.configuration;
|
|
61
|
+
const uri = `${protocol}://${encodeURIComponent(
|
|
62
62
|
username
|
|
63
63
|
)}:${encodeURIComponent(
|
|
64
64
|
password
|
|
65
|
-
)}@${clusterHostname}/test?
|
|
65
|
+
)}@${clusterHostname}/test${Object.keys(options).length ? "?" : ""}${encodeURIComponent(new URLSearchParams(options).toString())}`;
|
|
66
66
|
const client = new MongoClient(uri, { useNewUrlParser: true });
|
|
67
67
|
return new Promise((resolve, reject) => {
|
|
68
68
|
client.connect((err) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/language-mongodb",
|
|
3
3
|
"label": "MongoDB",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.20",
|
|
5
5
|
"description": "A language package for working with MongoDb",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"author": "Open Function Group",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"mongodb": "^3.7.3",
|
|
17
|
-
"@openfn/language-common": "3.0.
|
|
17
|
+
"@openfn/language-common": "3.0.3"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"assertion-error": "^1.1.0",
|