@pi-r/atlas 0.6.6 → 0.7.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2024 An Pham
1
+ Copyright 2023 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/README.md CHANGED
@@ -1,10 +1,7 @@
1
- # @pi-r/atlas
1
+ ### @pi-r/atlas
2
2
 
3
- ## Documentation
3
+ https://e-mc.readthedocs.io/en/latest/cloud/atlas.html
4
4
 
5
- - [E-mc](https://e-mc.readthedocs.io/en/latest/cloud/atlas.html)
6
- - [squared](https://squared.readthedocs.io)
7
-
8
- ## LICENSE
5
+ ### LICENSE
9
6
 
10
7
  MIT
package/client/index.js CHANGED
@@ -4,11 +4,11 @@ const mongodb = require("mongodb");
4
4
  const types_1 = require("@e-mc/types");
5
5
  const util_1 = require("@e-mc/cloud/util");
6
6
  const mongodb_1 = require("@pi-r/mongodb");
7
- const Module = require("@e-mc/module");
7
+ const Cloud = require("@e-mc/cloud");
8
8
  function sanitizeCredentials(credential) {
9
9
  const { username, password } = credential;
10
10
  if (username) {
11
- credential.auth || (credential.auth = password ? { username, password } : { username });
11
+ credential.auth ||= password ? { username, password } : { username };
12
12
  delete credential.username;
13
13
  }
14
14
  if (password) {
@@ -17,7 +17,7 @@ function sanitizeCredentials(credential) {
17
17
  }
18
18
  function validateDatabase(credential, data) {
19
19
  const auth = credential.auth;
20
- return !!(data.table && Module.isURL(data.uri) && (auth?.username || credential.username || (0, util_1.hasBasicAuth)(data.uri)));
20
+ return !!(data.table && Cloud.isURL(data.uri) && (auth?.username || credential.username || (0, util_1.hasBasicAuth)(data.uri)));
21
21
  }
22
22
  exports.validateDatabase = validateDatabase;
23
23
  function createDatabaseClient(credential, data) {
@@ -37,8 +37,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
37
37
  const coercing = this.hasCoerce("atlas", 'options');
38
38
  const cacheValue = { value: this.valueOfKey(credential, 'cache'), sessionKey };
39
39
  const createClient = async (item, options) => {
40
- var _a;
41
- return clients[_a = item.uri + Module.asString(options, true)] || (clients[_a] = await createDatabaseClient.call(this, options, item).connect());
40
+ return clients[item.uri + Cloud.asString(options, true)] ||= await createDatabaseClient.call(this, options, item).connect();
42
41
  };
43
42
  const closeClient = () => {
44
43
  for (const key in clients) {
@@ -58,7 +57,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
58
57
  limit = 1;
59
58
  }
60
59
  const options = item.options ? length === 1 ? Object.assign(item.options, credential) : { ...item.options, ...credential } : length === 1 ? credential : { ...credential };
61
- let rows, queryString = caching && ignoreCache !== true ? (name || '') + '_' + table + '_' + limit + Module.asString(options, true) + (sort ? Module.asString(sort, true) : '') + (client ? Module.asString(client, true) : '') : '', auth, pipeline;
60
+ let rows, queryString = caching && ignoreCache !== true ? (name || '') + '_' + table + '_' + limit + Cloud.asString(options, true) + (sort ? Cloud.asString(sort, true) : '') + (client ? Cloud.asString(client, true) : '') : '', auth, pipeline;
62
61
  if (queryString) {
63
62
  sanitizeCredentials(options);
64
63
  auth = { uri: item.uri, options };
@@ -101,7 +100,7 @@ async function executeBatchQuery(credential, batch, sessionKey) {
101
100
  }
102
101
  if (pipeline || query) {
103
102
  if (queryString) {
104
- queryString += Module.asString(aggregate || query, true);
103
+ queryString += Cloud.asString(aggregate || query, true);
105
104
  if ((aggregate || !update) && (rows = getCache())) {
106
105
  result[i] = rows;
107
106
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/atlas",
3
- "version": "0.6.6",
3
+ "version": "0.7.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.8.7",
24
- "@e-mc/db": "^0.8.7",
25
- "@e-mc/module": "^0.8.7",
26
- "@e-mc/types": "^0.8.7",
27
- "@pi-r/mongodb": "^0.6.6",
23
+ "@e-mc/cloud": "^0.9.0",
24
+ "@e-mc/db": "^0.9.0",
25
+ "@e-mc/module": "^0.9.0",
26
+ "@e-mc/types": "^0.9.0",
27
+ "@pi-r/mongodb": "^0.7.0",
28
28
  "mongodb": "^6.5.0"
29
29
  }
30
30
  }
@@ -0,0 +1,14 @@
1
+ import type { CloudDatabase } from '@e-mc/types/lib/cloud';
2
+
3
+ import type { MongoDBClientDBOptions, MongoDBFilterValue } from '@pi-r/mongodb/types';
4
+
5
+ import type { Document, Filter, MongoClientOptions, OptionalUnlessRequiredId, UpdateFilter } from 'mongodb';
6
+
7
+ export interface AtlasDatabaseQuery extends CloudDatabase<Filter<Document> | MongoDBFilterValue, MongoClientOptions, UpdateFilter<Document> | OptionalUnlessRequiredId<unknown>[], AtlasDatabaseCredential>, MongoDBClientDBOptions {
8
+ source: "cloud";
9
+ service: "atlas";
10
+ uri: string;
11
+ updateType?: 0 | 1 | 2 | 3;
12
+ }
13
+
14
+ export interface AtlasDatabaseCredential extends AuthValue, MongoClientOptions {}