@pi-r/atlas 0.3.0 → 0.5.0
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/client/index.js +2 -18
- package/package.json +7 -7
package/client/index.js
CHANGED
|
@@ -6,32 +6,16 @@ const types_1 = require("@e-mc/types");
|
|
|
6
6
|
const util_1 = require("@e-mc/cloud/util");
|
|
7
7
|
const mongodb_1 = require("@pi-r/mongodb");
|
|
8
8
|
const Module = require("@e-mc/module");
|
|
9
|
-
const MONGODB_V3 = Module.checkSemVer('mongodb', 1, 4);
|
|
10
9
|
function sanitizeCredentials(item, credential) {
|
|
11
10
|
const { username, password } = credential;
|
|
12
11
|
if (username) {
|
|
13
12
|
const auth = password ? { username, password } : { username };
|
|
14
|
-
|
|
15
|
-
credential.auth = password || !credential.auth?.password ? auth : credential.auth;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
credential.auth || (credential.auth = auth);
|
|
19
|
-
}
|
|
13
|
+
credential.auth || (credential.auth = auth);
|
|
20
14
|
delete credential.username;
|
|
21
15
|
}
|
|
22
16
|
if (password) {
|
|
23
17
|
delete credential.password;
|
|
24
18
|
}
|
|
25
|
-
if (MONGODB_V3 && credential.auth) {
|
|
26
|
-
if (!(0, util_1.hasBasicAuth)(item.uri)) {
|
|
27
|
-
const auth = (0, util_1.getBasicAuth)(credential.auth);
|
|
28
|
-
if (auth) {
|
|
29
|
-
const [protocol, hostname] = item.uri.split('://');
|
|
30
|
-
item.uri = protocol + '://' + auth + hostname;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
delete credential.auth;
|
|
34
|
-
}
|
|
35
19
|
}
|
|
36
20
|
function validateDatabase(credential, data) {
|
|
37
21
|
const auth = credential.auth;
|
|
@@ -76,7 +60,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
76
60
|
limit = 1;
|
|
77
61
|
}
|
|
78
62
|
const renewCache = ignoreCache === 0;
|
|
79
|
-
const options = item.options ? length === 1
|
|
63
|
+
const options = item.options ? length === 1 ? Object.assign(item.options, credential) : { ...item.options, ...credential } : length === 1 ? credential : { ...credential };
|
|
80
64
|
let rows, queryString = caching && ignoreCache !== true || ignoreCache === false || ignoreCache === 1 || renewCache ? (name || '') + '_' + table + '_' + limit + Module.asString(options, true) + (sort ? Module.asString(sort, true) : '') + (client ? Module.asString(client, true) : '') : '', auth, pipeline;
|
|
81
65
|
if (queryString) {
|
|
82
66
|
sanitizeCredentials(item, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/atlas",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "MongoDB Atlas cloud functions for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/cloud": "^0.
|
|
24
|
-
"@e-mc/db": "^0.
|
|
25
|
-
"@e-mc/module": "^0.
|
|
26
|
-
"@e-mc/types": "^0.
|
|
27
|
-
"@pi-r/mongodb": "^0.
|
|
28
|
-
"mongodb": "^
|
|
23
|
+
"@e-mc/cloud": "^0.7.0",
|
|
24
|
+
"@e-mc/db": "^0.7.0",
|
|
25
|
+
"@e-mc/module": "^0.7.0",
|
|
26
|
+
"@e-mc/types": "^0.7.0",
|
|
27
|
+
"@pi-r/mongodb": "^0.5.0",
|
|
28
|
+
"mongodb": "^6.3.0"
|
|
29
29
|
}
|
|
30
30
|
}
|