@pi-r/atlas 0.3.3 → 0.3.5
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/LICENSE +1 -1
- package/client/index.js +8 -6
- package/package.json +6 -6
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/client/index.js
CHANGED
|
@@ -8,11 +8,12 @@ const mongodb_1 = require("@pi-r/mongodb");
|
|
|
8
8
|
const Module = require("@e-mc/module");
|
|
9
9
|
const MONGODB_V3 = Module.checkSemVer('mongodb', 1, 4);
|
|
10
10
|
function sanitizeCredentials(item, credential) {
|
|
11
|
+
var _a;
|
|
11
12
|
const { username, password } = credential;
|
|
12
13
|
if (username) {
|
|
13
14
|
const auth = password ? { username, password } : { username };
|
|
14
15
|
if (MONGODB_V3) {
|
|
15
|
-
credential.auth = password || !credential.auth
|
|
16
|
+
credential.auth = password || !((_a = credential.auth) === null || _a === void 0 ? void 0 : _a.password) ? auth : credential.auth;
|
|
16
17
|
}
|
|
17
18
|
else {
|
|
18
19
|
credential.auth || (credential.auth = auth);
|
|
@@ -35,7 +36,7 @@ function sanitizeCredentials(item, credential) {
|
|
|
35
36
|
}
|
|
36
37
|
function validateDatabase(credential, data) {
|
|
37
38
|
const auth = credential.auth;
|
|
38
|
-
return !!(data.table && (auth
|
|
39
|
+
return !!(data.table && ((auth === null || auth === void 0 ? void 0 : auth.username) || credential.username || Module.isURL(data.uri) && (0, util_1.hasBasicAuth)(data.uri)));
|
|
39
40
|
}
|
|
40
41
|
exports.validateDatabase = validateDatabase;
|
|
41
42
|
function createDatabaseClient(credential, data) {
|
|
@@ -48,6 +49,7 @@ async function executeQuery(credential, data, sessionKey) {
|
|
|
48
49
|
}
|
|
49
50
|
exports.executeQuery = executeQuery;
|
|
50
51
|
async function executeBatchQuery(credential, batch, sessionKey) {
|
|
52
|
+
var _a, _b;
|
|
51
53
|
const length = batch.length;
|
|
52
54
|
const result = new Array(length);
|
|
53
55
|
const clients = {};
|
|
@@ -89,7 +91,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
89
91
|
cacheValue.renewCache = renewCache;
|
|
90
92
|
return this.getQueryResult(service, auth, queryString, cacheValue);
|
|
91
93
|
};
|
|
92
|
-
const getCollection = (mongoClient) => mongoClient.db(name, client
|
|
94
|
+
const getCollection = (mongoClient) => mongoClient.db(name, client === null || client === void 0 ? void 0 : client.db).collection(table, client === null || client === void 0 ? void 0 : client.collection);
|
|
93
95
|
if (aggregate) {
|
|
94
96
|
pipeline = Array.isArray(aggregate) ? aggregate : aggregate.pipeline;
|
|
95
97
|
}
|
|
@@ -103,7 +105,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
103
105
|
}
|
|
104
106
|
const collection = getCollection(await createClient(item, options));
|
|
105
107
|
if (pipeline) {
|
|
106
|
-
const aggregateOptions = aggregate
|
|
108
|
+
const aggregateOptions = aggregate === null || aggregate === void 0 ? void 0 : aggregate.options;
|
|
107
109
|
if (coercing) {
|
|
108
110
|
pipeline.forEach(doc => (0, types_1.coerceObject)(doc));
|
|
109
111
|
if (aggregateOptions) {
|
|
@@ -126,7 +128,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
126
128
|
(0, types_1.coerceObject)(update);
|
|
127
129
|
}
|
|
128
130
|
if ((0, types_1.isArray)(update)) {
|
|
129
|
-
const insertOptions = item.execute
|
|
131
|
+
const insertOptions = (_a = item.execute) === null || _a === void 0 ? void 0 : _a.insert;
|
|
130
132
|
if (insertOptions && coercing) {
|
|
131
133
|
(0, types_1.coerceObject)(insertOptions);
|
|
132
134
|
}
|
|
@@ -147,7 +149,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
147
149
|
}
|
|
148
150
|
else {
|
|
149
151
|
if (update) {
|
|
150
|
-
const updateOptions = item.execute
|
|
152
|
+
const updateOptions = (_b = item.execute) === null || _b === void 0 ? void 0 : _b.update;
|
|
151
153
|
if (updateOptions && coercing) {
|
|
152
154
|
(0, types_1.coerceObject)(updateOptions);
|
|
153
155
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/atlas",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
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.6.
|
|
24
|
-
"@e-mc/db": "^0.6.
|
|
25
|
-
"@e-mc/module": "^0.6.
|
|
26
|
-
"@e-mc/types": "^0.6.
|
|
27
|
-
"@pi-r/mongodb": "^0.3.
|
|
23
|
+
"@e-mc/cloud": "^0.6.7",
|
|
24
|
+
"@e-mc/db": "^0.6.7",
|
|
25
|
+
"@e-mc/module": "^0.6.7",
|
|
26
|
+
"@e-mc/types": "^0.6.7",
|
|
27
|
+
"@pi-r/mongodb": "^0.3.5",
|
|
28
28
|
"mongodb": "^5.9.2"
|
|
29
29
|
}
|
|
30
30
|
}
|