@mongosh/service-provider-core 1.10.5 → 2.0.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/AUTHORS +3 -0
- package/lib/admin.d.ts +2 -2
- package/lib/all-fle-types.d.ts +1 -2
- package/lib/all-transport-types.d.ts +1 -1
- package/lib/bson-export.d.ts +23 -0
- package/lib/bson-export.js +22 -0
- package/lib/bson-export.js.map +1 -0
- package/lib/connect-info.d.ts +3 -1
- package/lib/connect-info.js +3 -1
- package/lib/connect-info.js.map +1 -1
- package/lib/index.d.ts +2 -24
- package/lib/index.js +3 -20
- package/lib/index.js.map +1 -1
- package/lib/printable-bson.d.ts +5 -3
- package/lib/printable-bson.js +31 -46
- package/lib/printable-bson.js.map +1 -1
- package/lib/service-provider.js +2 -5
- package/lib/service-provider.js.map +1 -1
- package/lib/textencoder-polyfill.js.map +1 -1
- package/lib/writable.d.ts +1 -1
- package/package.json +11 -9
- package/src/admin.ts +3 -2
- package/src/all-fle-types.ts +1 -6
- package/src/all-transport-types.ts +0 -1
- package/src/bson-export.ts +35 -0
- package/src/connect-info.spec.ts +56 -4
- package/src/connect-info.ts +6 -1
- package/src/index.ts +1 -35
- package/src/printable-bson.spec.ts +10 -10
- package/src/printable-bson.ts +43 -59
- package/src/service-provider.ts +1 -1
- package/src/textencoder-polyfill.ts +1 -0
- package/src/writable.ts +1 -1
package/AUTHORS
CHANGED
|
@@ -14,3 +14,6 @@ Le Roux Bodenstein <lerouxb@gmail.com>
|
|
|
14
14
|
Bailey Pearson <bailey.pearson@mongodb.com>
|
|
15
15
|
Himanshu Singh <himanshu.singhs@outlook.in>
|
|
16
16
|
Martin Rodriguez Reboredo <yakoyoku@gmail.com>
|
|
17
|
+
Kevin Mas Ruiz <kevin.mas@hey.com>
|
|
18
|
+
Hao <shaketbaby@gmail.com>
|
|
19
|
+
Basit <1305718+mabaasit@users.noreply.github.com>
|
package/lib/admin.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type ShellAuthOptions from './shell-auth-options';
|
|
|
2
2
|
import type { MongoClientOptions, ReadConcern, ReadPreference, WriteConcern, Document, CreateCollectionOptions, ClientSession, DbOptions, ClientSessionOptions, ListDatabasesOptions, AutoEncryptionOptions, Collection } from './all-transport-types';
|
|
3
3
|
import type { bson as BSON } from './index';
|
|
4
4
|
import type { ReplPlatform } from './platform';
|
|
5
|
-
import type { AWSEncryptionKeyOptions, AzureEncryptionKeyOptions, ClientEncryption as MongoCryptClientEncryption, ClientEncryptionDataKeyProvider,
|
|
5
|
+
import type { AWSEncryptionKeyOptions, AzureEncryptionKeyOptions, ClientEncryption as MongoCryptClientEncryption, ClientEncryptionDataKeyProvider, GCPEncryptionKeyOptions, ClientEncryption, ClientEncryptionOptions } from './all-fle-types';
|
|
6
6
|
export interface CreateEncryptedCollectionOptions {
|
|
7
7
|
provider: ClientEncryptionDataKeyProvider;
|
|
8
8
|
createCollectionOptions: Omit<CreateCollectionOptions, 'encryptedFields'> & {
|
|
@@ -36,7 +36,7 @@ export default interface Admin {
|
|
|
36
36
|
resetConnectionOptions(options: MongoClientOptions): Promise<void>;
|
|
37
37
|
startSession(options: ClientSessionOptions): ClientSession;
|
|
38
38
|
getRawClient(): any;
|
|
39
|
-
|
|
39
|
+
createClientEncryption?(options: ClientEncryptionOptions): ClientEncryption;
|
|
40
40
|
getFleOptions?: () => AutoEncryptionOptions | undefined;
|
|
41
41
|
createEncryptedCollection?(dbName: string, collName: string, options: CreateEncryptedCollectionOptions, libmongocrypt: MongoCryptClientEncryption): Promise<{
|
|
42
42
|
collection: Collection;
|
package/lib/all-fle-types.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export type { AWSEncryptionKeyOptions, AzureEncryptionKeyOptions, GCPEncryptionKeyOptions, ClientEncryption,
|
|
2
|
-
export type FLE = typeof import('mongodb-client-encryption');
|
|
1
|
+
export type { AWSEncryptionKeyOptions, AzureEncryptionKeyOptions, GCPEncryptionKeyOptions, ClientEncryption, ClientEncryptionCreateDataKeyProviderOptions, ClientEncryptionDataKeyProvider, ClientEncryptionEncryptOptions, ClientEncryptionOptions, ClientEncryptionTlsOptions, KMSProviders, } from 'mongodb';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { AggregateOptions, AggregationCursor, AnyBulkWriteOperation, Batch, BulkWriteOptions, BulkWriteResult, ChangeStream, ChangeStreamOptions, ClientSession, CloseOptions, CollationOptions,
|
|
1
|
+
export type { AggregateOptions, AggregationCursor, AnyBulkWriteOperation, Batch, BulkWriteOptions, BulkWriteResult, ChangeStream, ChangeStreamOptions, ClientSession, CloseOptions, CollationOptions, Collection, CommandOperationOptions, CountDocumentsOptions, CountOptions, CreateCollectionOptions, CreateIndexesOptions, ClientSessionOptions, ClusterTime, FindCursor, CursorFlag, RunCommandCursor, Db, DbOptions, DeleteOptions, DeleteResult, DistinctOptions, Document, DropCollectionOptions, DropDatabaseOptions, EstimatedDocumentCountOptions, ExplainOptions, ExplainVerbosityLike, FindOneAndDeleteOptions, FindOneAndUpdateOptions, FindOneAndReplaceOptions, FindOperators, FindOptions, HedgeOptions, IndexDescription, InsertManyResult, InsertOneOptions, InsertOneResult, ListCollectionsOptions, ListDatabasesOptions, ListIndexesOptions, MongoClientOptions, OrderedBulkOperation, ReadConcern, ReadConcernLike, ReadConcernLevel, ReadPreference, ReadPreferenceLike, ReadPreferenceFromOptions, ReadPreferenceMode, RenameOptions, ReplaceOptions, ResumeToken, RunCommandOptions, ServerSessionId, TagSet, TransactionOptions, UpdateOptions, UpdateResult, UnorderedBulkOperation, WriteConcern, ObjectId as ObjectIdType, Timestamp as TimestampType, Binary as BinaryType, TopologyDescription, TopologyType, ServerType, AutoEncryptionOptions, ServerApi, ServerApiVersion, MongoClient, } from 'mongodb';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ObjectId, DBRef, MaxKey, MinKey, Timestamp, BSONSymbol, Code, Decimal128, Int32, Long, Binary, calculateObjectSize, Double, BSONRegExp } from 'bson';
|
|
2
|
+
export declare const bson: {
|
|
3
|
+
ObjectId: typeof ObjectId;
|
|
4
|
+
DBRef: typeof DBRef;
|
|
5
|
+
MaxKey: typeof MaxKey;
|
|
6
|
+
MinKey: typeof MinKey;
|
|
7
|
+
Timestamp: typeof Timestamp;
|
|
8
|
+
BSONSymbol: typeof BSONSymbol;
|
|
9
|
+
Code: typeof Code;
|
|
10
|
+
Decimal128: typeof Decimal128;
|
|
11
|
+
Int32: typeof Int32;
|
|
12
|
+
Long: typeof Long;
|
|
13
|
+
Binary: typeof Binary;
|
|
14
|
+
calculateObjectSize: typeof calculateObjectSize;
|
|
15
|
+
Double: typeof Double;
|
|
16
|
+
EJSON: {
|
|
17
|
+
parse: (text: string, options?: import("bson").EJSONOptions | undefined) => any;
|
|
18
|
+
stringify: (value: any, replacer?: (string | number)[] | import("bson").EJSONOptions | ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined, options?: import("bson").EJSONOptions | undefined) => string;
|
|
19
|
+
serialize: (value: any, options?: import("bson").EJSONOptions | undefined) => import("bson").Document;
|
|
20
|
+
deserialize: (ejson: import("bson").Document, options?: import("bson").EJSONOptions | undefined) => any;
|
|
21
|
+
};
|
|
22
|
+
BSONRegExp: typeof BSONRegExp;
|
|
23
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bson = void 0;
|
|
4
|
+
const bson_1 = require("bson");
|
|
5
|
+
exports.bson = {
|
|
6
|
+
ObjectId: bson_1.ObjectId,
|
|
7
|
+
DBRef: bson_1.DBRef,
|
|
8
|
+
MaxKey: bson_1.MaxKey,
|
|
9
|
+
MinKey: bson_1.MinKey,
|
|
10
|
+
Timestamp: bson_1.Timestamp,
|
|
11
|
+
BSONSymbol: bson_1.BSONSymbol,
|
|
12
|
+
Code: bson_1.Code,
|
|
13
|
+
Decimal128: bson_1.Decimal128,
|
|
14
|
+
Int32: bson_1.Int32,
|
|
15
|
+
Long: bson_1.Long,
|
|
16
|
+
Binary: bson_1.Binary,
|
|
17
|
+
calculateObjectSize: bson_1.calculateObjectSize,
|
|
18
|
+
Double: bson_1.Double,
|
|
19
|
+
EJSON: bson_1.EJSON,
|
|
20
|
+
BSONRegExp: bson_1.BSONRegExp,
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=bson-export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bson-export.js","sourceRoot":"","sources":["../src/bson-export.ts"],"names":[],"mappings":";;;AAAA,+BAgBc;AAED,QAAA,IAAI,GAAG;IAClB,QAAQ,EAAR,eAAQ;IACR,KAAK,EAAL,YAAK;IACL,MAAM,EAAN,aAAM;IACN,MAAM,EAAN,aAAM;IACN,SAAS,EAAT,gBAAS;IACT,UAAU,EAAV,iBAAU;IACV,IAAI,EAAJ,WAAI;IACJ,UAAU,EAAV,iBAAU;IACV,KAAK,EAAL,YAAK;IACL,IAAI,EAAJ,WAAI;IACJ,MAAM,EAAN,aAAM;IACN,mBAAmB,EAAnB,0BAAmB;IACnB,MAAM,EAAN,aAAM;IACN,KAAK,EAAL,YAAK;IACL,UAAU,EAAV,iBAAU;CACX,CAAC"}
|
package/lib/connect-info.d.ts
CHANGED
|
@@ -9,11 +9,13 @@ export interface ConnectInfo {
|
|
|
9
9
|
is_enterprise: boolean;
|
|
10
10
|
auth_type?: string;
|
|
11
11
|
is_data_federation: boolean;
|
|
12
|
+
is_stream: boolean;
|
|
12
13
|
dl_version?: string;
|
|
13
14
|
atlas_version?: string;
|
|
14
15
|
is_genuine: boolean;
|
|
15
16
|
non_genuine_server_name: string;
|
|
16
17
|
node_version: string;
|
|
17
18
|
uri: string;
|
|
19
|
+
is_local_atlas: boolean;
|
|
18
20
|
}
|
|
19
|
-
export default function getConnectInfo(uri: string, mongoshVersion: string, buildInfo: any, atlasVersion: any, topology: any): ConnectInfo;
|
|
21
|
+
export default function getConnectInfo(uri: string, mongoshVersion: string, buildInfo: any, atlasVersion: any, topology: any, isLocalAtlas: boolean): ConnectInfo;
|
package/lib/connect-info.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const mongodb_build_info_1 = __importDefault(require("mongodb-build-info"));
|
|
7
|
-
function getConnectInfo(uri, mongoshVersion, buildInfo, atlasVersion, topology) {
|
|
7
|
+
function getConnectInfo(uri, mongoshVersion, buildInfo, atlasVersion, topology, isLocalAtlas) {
|
|
8
8
|
var _a;
|
|
9
9
|
buildInfo !== null && buildInfo !== void 0 ? buildInfo : (buildInfo = {});
|
|
10
10
|
const { isGenuine: is_genuine, serverName: non_genuine_server_name } = mongodb_build_info_1.default.getGenuineMongoDB(uri);
|
|
@@ -26,10 +26,12 @@ function getConnectInfo(uri, mongoshVersion, buildInfo, atlasVersion, topology)
|
|
|
26
26
|
is_enterprise: mongodb_build_info_1.default.isEnterprise(buildInfo),
|
|
27
27
|
auth_type,
|
|
28
28
|
is_data_federation,
|
|
29
|
+
is_stream: mongodb_build_info_1.default.isAtlasStream(uri),
|
|
29
30
|
dl_version,
|
|
30
31
|
atlas_version: (_a = atlasVersion === null || atlasVersion === void 0 ? void 0 : atlasVersion.atlasVersion) !== null && _a !== void 0 ? _a : null,
|
|
31
32
|
is_genuine,
|
|
32
33
|
non_genuine_server_name,
|
|
34
|
+
is_local_atlas: isLocalAtlas,
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
37
|
exports.default = getConnectInfo;
|
package/lib/connect-info.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-info.js","sourceRoot":"","sources":["../src/connect-info.ts"],"names":[],"mappings":";;;;;AAEA,4EAA8C;
|
|
1
|
+
{"version":3,"file":"connect-info.js","sourceRoot":"","sources":["../src/connect-info.ts"],"names":[],"mappings":";;;;;AAEA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A,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,YAAY,mCAAI,IAAI;QACjD,UAAU;QACV,uBAAuB;QACvB,cAAc,EAAE,YAAY;KAC7B,CAAC;AACJ,CAAC;AAzCD,iCAyCC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -3,33 +3,11 @@ import ServiceProvider, { ServiceProviderCore } from './service-provider';
|
|
|
3
3
|
import getConnectInfo, { ConnectInfo } from './connect-info';
|
|
4
4
|
import type { ReplPlatform } from './platform';
|
|
5
5
|
declare const DEFAULT_DB = "test";
|
|
6
|
-
import { ObjectId, DBRef, MaxKey, MinKey, Timestamp, BSONSymbol, Code, Decimal128, Int32, Long, Binary, calculateObjectSize, Double, BSONRegExp } from 'bson';
|
|
7
6
|
import { bsonStringifiers } from './printable-bson';
|
|
8
7
|
import ShellAuthOptions from './shell-auth-options';
|
|
9
8
|
export * from './all-transport-types';
|
|
10
9
|
export * from './all-fle-types';
|
|
11
10
|
export { MapReduceOptions, FinalizeFunction } from './map-reduce-options';
|
|
12
11
|
export { CreateEncryptedCollectionOptions, CheckMetadataConsistencyOptions, } from './admin';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
DBRef: typeof DBRef;
|
|
16
|
-
MaxKey: typeof MaxKey;
|
|
17
|
-
MinKey: typeof MinKey;
|
|
18
|
-
Timestamp: typeof Timestamp;
|
|
19
|
-
BSONSymbol: typeof BSONSymbol;
|
|
20
|
-
Code: typeof Code;
|
|
21
|
-
Decimal128: typeof Decimal128;
|
|
22
|
-
Int32: typeof Int32;
|
|
23
|
-
Long: typeof Long;
|
|
24
|
-
Binary: typeof Binary;
|
|
25
|
-
calculateObjectSize: typeof calculateObjectSize;
|
|
26
|
-
Double: typeof Double;
|
|
27
|
-
EJSON: {
|
|
28
|
-
parse: (text: string, options?: import("bson").EJSONOptions | undefined) => any;
|
|
29
|
-
stringify: (value: any, replacer?: (string | number)[] | import("bson").EJSONOptions | ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined, options?: import("bson").EJSONOptions | undefined) => string;
|
|
30
|
-
serialize: (value: any, options?: import("bson").EJSONOptions | undefined) => import("bson").Document;
|
|
31
|
-
deserialize: (ejson: import("bson").Document, options?: import("bson").EJSONOptions | undefined) => any;
|
|
32
|
-
};
|
|
33
|
-
BSONRegExp: typeof BSONRegExp;
|
|
34
|
-
};
|
|
35
|
-
export { ServiceProvider, ShellAuthOptions, getConnectInfo, ReplPlatform, DEFAULT_DB, ServiceProviderCore, bson, bsonStringifiers, ConnectInfo, };
|
|
12
|
+
export { bson } from './bson-export';
|
|
13
|
+
export { ServiceProvider, ShellAuthOptions, getConnectInfo, ReplPlatform, DEFAULT_DB, ServiceProviderCore, bsonStringifiers, ConnectInfo, };
|
package/lib/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.bsonStringifiers = exports.
|
|
20
|
+
exports.bsonStringifiers = exports.ServiceProviderCore = exports.DEFAULT_DB = exports.getConnectInfo = exports.bson = void 0;
|
|
21
21
|
require("./textencoder-polyfill");
|
|
22
22
|
const service_provider_1 = require("./service-provider");
|
|
23
23
|
Object.defineProperty(exports, "ServiceProviderCore", { enumerable: true, get: function () { return service_provider_1.ServiceProviderCore; } });
|
|
@@ -25,27 +25,10 @@ const connect_info_1 = __importDefault(require("./connect-info"));
|
|
|
25
25
|
exports.getConnectInfo = connect_info_1.default;
|
|
26
26
|
const DEFAULT_DB = 'test';
|
|
27
27
|
exports.DEFAULT_DB = DEFAULT_DB;
|
|
28
|
-
const bson_1 = require("bson");
|
|
29
28
|
const printable_bson_1 = require("./printable-bson");
|
|
30
29
|
Object.defineProperty(exports, "bsonStringifiers", { enumerable: true, get: function () { return printable_bson_1.bsonStringifiers; } });
|
|
31
30
|
__exportStar(require("./all-transport-types"), exports);
|
|
32
31
|
__exportStar(require("./all-fle-types"), exports);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
DBRef: bson_1.DBRef,
|
|
36
|
-
MaxKey: bson_1.MaxKey,
|
|
37
|
-
MinKey: bson_1.MinKey,
|
|
38
|
-
Timestamp: bson_1.Timestamp,
|
|
39
|
-
BSONSymbol: bson_1.BSONSymbol,
|
|
40
|
-
Code: bson_1.Code,
|
|
41
|
-
Decimal128: bson_1.Decimal128,
|
|
42
|
-
Int32: bson_1.Int32,
|
|
43
|
-
Long: bson_1.Long,
|
|
44
|
-
Binary: bson_1.Binary,
|
|
45
|
-
calculateObjectSize: bson_1.calculateObjectSize,
|
|
46
|
-
Double: bson_1.Double,
|
|
47
|
-
EJSON: bson_1.EJSON,
|
|
48
|
-
BSONRegExp: bson_1.BSONRegExp,
|
|
49
|
-
};
|
|
50
|
-
exports.bson = bson;
|
|
32
|
+
var bson_export_1 = require("./bson-export");
|
|
33
|
+
Object.defineProperty(exports, "bson", { enumerable: true, get: function () { return bson_export_1.bson; } });
|
|
51
34
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kCAAgC;AAChC,yDAA0E;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kCAAgC;AAChC,yDAA0E;AAwBxE,oGAxBwB,sCAAmB,OAwBxB;AAvBrB,kEAA6D;AAoB3D,yBApBK,sBAAc,CAoBL;AAlBhB,MAAM,UAAU,GAAG,MAAM,CAAC;AAoBxB,gCAAU;AAnBZ,qDAAoD;AAqBlD,iGArBO,iCAAgB,OAqBP;AAnBlB,wDAAsC;AACtC,kDAAgC;AAShC,6CAAqC;AAA5B,mGAAA,IAAI,OAAA"}
|
package/lib/printable-bson.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import { bson as BSON } from './
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import { bson as BSON } from './bson-export';
|
|
2
|
+
type BSONClassKey = (typeof BSON)[Exclude<keyof typeof BSON, 'EJSON' | 'calculateObjectSize'>]['prototype']['_bsontype'];
|
|
3
|
+
export declare const bsonStringifiers: Record<BSONClassKey | 'ObjectID', (this: any, depth: any, options: any) => string>;
|
|
4
|
+
export declare function makePrintableBson(bson?: typeof BSON): void;
|
|
5
|
+
export {};
|
package/lib/printable-bson.js
CHANGED
|
@@ -1,53 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bsonStringifiers = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.makePrintableBson = exports.bsonStringifiers = void 0;
|
|
4
|
+
const bson_export_1 = require("./bson-export");
|
|
5
5
|
const util_1 = require("util");
|
|
6
6
|
const inspectCustom = Symbol.for('nodejs.util.inspect.custom');
|
|
7
|
+
function removeNewFromInspectResult(str) {
|
|
8
|
+
return String(str).replace(/^(\s*)(new )/, '$1');
|
|
9
|
+
}
|
|
10
|
+
function makeClasslessInspect(className) {
|
|
11
|
+
const originalInspect = bson_export_1.bson[className].prototype.inspect;
|
|
12
|
+
return function (...args) {
|
|
13
|
+
return removeNewFromInspectResult(originalInspect.apply(this, args));
|
|
14
|
+
};
|
|
15
|
+
}
|
|
7
16
|
exports.bsonStringifiers = {
|
|
8
|
-
ObjectId:
|
|
9
|
-
|
|
10
|
-
},
|
|
17
|
+
ObjectId: makeClasslessInspect('ObjectId'),
|
|
18
|
+
ObjectID: makeClasslessInspect('ObjectId'),
|
|
11
19
|
DBRef: function (depth, options) {
|
|
12
20
|
return (`DBRef("${this.collection}", ` +
|
|
13
21
|
(0, util_1.inspect)(this.oid, options) +
|
|
14
|
-
(this.db ? `,
|
|
22
|
+
(this.db ? `, ${(0, util_1.inspect)(this.db, options)}` : '') +
|
|
15
23
|
')');
|
|
16
24
|
},
|
|
17
|
-
MaxKey:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return `BSONSymbol("${this.valueOf()}")`;
|
|
28
|
-
},
|
|
29
|
-
Code: function () {
|
|
30
|
-
const j = this.toJSON();
|
|
31
|
-
return `Code("${j.code}"${j.scope ? `, ${JSON.stringify(j.scope)}` : ''})`;
|
|
32
|
-
},
|
|
33
|
-
Decimal128: function () {
|
|
34
|
-
return `Decimal128("${this.toString()}")`;
|
|
35
|
-
},
|
|
36
|
-
Int32: function () {
|
|
37
|
-
return `Int32(${this.valueOf()})`;
|
|
38
|
-
},
|
|
39
|
-
Long: function () {
|
|
40
|
-
return `Long("${this.toString()}"${this.unsigned ? ', true' : ''})`;
|
|
41
|
-
},
|
|
42
|
-
BSONRegExp: function () {
|
|
43
|
-
return `BSONRegExp(${JSON.stringify(this.pattern)}, ${JSON.stringify(this.options)})`;
|
|
44
|
-
},
|
|
25
|
+
MaxKey: makeClasslessInspect('MaxKey'),
|
|
26
|
+
MinKey: makeClasslessInspect('MinKey'),
|
|
27
|
+
Timestamp: makeClasslessInspect('Timestamp'),
|
|
28
|
+
BSONSymbol: makeClasslessInspect('BSONSymbol'),
|
|
29
|
+
Code: makeClasslessInspect('Code'),
|
|
30
|
+
Decimal128: makeClasslessInspect('Decimal128'),
|
|
31
|
+
Int32: makeClasslessInspect('Int32'),
|
|
32
|
+
Long: makeClasslessInspect('Long'),
|
|
33
|
+
Double: makeClasslessInspect('Double'),
|
|
34
|
+
BSONRegExp: makeClasslessInspect('BSONRegExp'),
|
|
45
35
|
Binary: function () {
|
|
46
36
|
const hexString = this.toString('hex');
|
|
47
37
|
switch (this.sub_type) {
|
|
48
|
-
case
|
|
38
|
+
case bson_export_1.bson.Binary.SUBTYPE_MD5:
|
|
49
39
|
return `MD5("${hexString}")`;
|
|
50
|
-
case
|
|
40
|
+
case bson_export_1.bson.Binary.SUBTYPE_UUID:
|
|
51
41
|
if (hexString.length === 32) {
|
|
52
42
|
const asUUID = /^(.{8})(.{4})(.{4})(.{4})(.{12})$/
|
|
53
43
|
.exec(hexString)
|
|
@@ -56,14 +46,13 @@ exports.bsonStringifiers = {
|
|
|
56
46
|
return `UUID("${asUUID}")`;
|
|
57
47
|
}
|
|
58
48
|
default:
|
|
59
|
-
return `Binary
|
|
49
|
+
return `Binary.createFromBase64("${this.toString('base64')}", ${this.sub_type})`;
|
|
60
50
|
}
|
|
61
51
|
},
|
|
62
52
|
};
|
|
63
|
-
|
|
64
|
-
function default_1(bson) {
|
|
53
|
+
function makePrintableBson(bson) {
|
|
65
54
|
if (!bson) {
|
|
66
|
-
bson =
|
|
55
|
+
bson = bson_export_1.bson;
|
|
67
56
|
}
|
|
68
57
|
for (const [key, stringifier] of Object.entries(exports.bsonStringifiers)) {
|
|
69
58
|
if (!(key in bson)) {
|
|
@@ -71,13 +60,9 @@ function default_1(bson) {
|
|
|
71
60
|
}
|
|
72
61
|
const cls = bson[key];
|
|
73
62
|
for (const key of [inspectCustom, 'inspect']) {
|
|
74
|
-
|
|
75
|
-
cls.prototype[key] = stringifier;
|
|
76
|
-
}
|
|
77
|
-
catch (_a) {
|
|
78
|
-
}
|
|
63
|
+
cls.prototype[key] = stringifier;
|
|
79
64
|
}
|
|
80
65
|
}
|
|
81
66
|
}
|
|
82
|
-
exports.
|
|
67
|
+
exports.makePrintableBson = makePrintableBson;
|
|
83
68
|
//# sourceMappingURL=printable-bson.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printable-bson.js","sourceRoot":"","sources":["../src/printable-bson.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"printable-bson.js","sourceRoot":"","sources":["../src/printable-bson.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAC7C,+B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AC;AAdD,8CAcC"}
|
package/lib/service-provider.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.ServiceProviderCore = void 0;
|
|
7
4
|
const errors_1 = require("@mongosh/errors");
|
|
8
|
-
const printable_bson_1 =
|
|
5
|
+
const printable_bson_1 = require("./printable-bson");
|
|
9
6
|
class ServiceProviderCore {
|
|
10
7
|
constructor(bsonLibrary) {
|
|
11
8
|
if (bsonLibrary === undefined) {
|
|
12
9
|
throw new errors_1.MongoshInternalError('BSON Library is undefined.');
|
|
13
10
|
}
|
|
14
|
-
(0, printable_bson_1.
|
|
11
|
+
(0, printable_bson_1.makePrintableBson)(bsonLibrary);
|
|
15
12
|
this.bsonLibrary = bsonLibrary;
|
|
16
13
|
}
|
|
17
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-provider.js","sourceRoot":"","sources":["../src/service-provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service-provider.js","sourceRoot":"","sources":["../src/service-provider.ts"],"names":[],"mappings":";;;AAAA,4CAAuD;AAGvD,qDAAqD;AAcrD,MAAa,mBAAmB;IAE9B,YAAY,WAAyB;QACnC,IAAI,WAAW,KAAK,SAAS,EAAE;YAC7B,MAAM,IAAI,6BAAoB,CAAC,4BAA4B,CAAC,CAAC;SAC9D;QACD,IAAA,kCAAiB,EAAC,WAAW,CAAC,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF;AATD,kDASC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textencoder-polyfill.js","sourceRoot":"","sources":["../src/textencoder-polyfill.ts"],"names":[],"mappings":";;;AAIA,IAGE,OAAO,WAAW,KAAK,UAAU;IAGjC,OAAO,WAAW,KAAK,UAAU,EACjC;
|
|
1
|
+
{"version":3,"file":"textencoder-polyfill.js","sourceRoot":"","sources":["../src/textencoder-polyfill.ts"],"names":[],"mappings":";;;AAIA,IAGE,OAAO,WAAW,KAAK,UAAU;IAGjC,OAAO,WAAW,KAAK,UAAU,EACjC;IAEA,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,EAAE,oBAAoB,EAAE,CAAC,CAAC;CAClE;AAGD,SAAS,oBAAoB;IAC3B,MAAM,WAAW;QACf,MAAM,CAAC,MAAc;YACnB,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACrC,CAAC;KACF;IACD,MAAM,WAAW;QACf,MAAM,CAAC,KAAiB;YACtB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAChD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9C,CAAC;KACF;IACD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACtC,CAAC;AAEQ,oDAAoB"}
|
package/lib/writable.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export default interface Writable {
|
|
|
8
8
|
bulkWrite(database: string, collection: string, requests: AnyBulkWriteOperation[], options: BulkWriteOptions, dbOptions?: DbOptions): Promise<BulkWriteResult>;
|
|
9
9
|
deleteMany(database: string, collection: string, filter: Document, options: DeleteOptions, dbOptions?: DbOptions): Promise<DeleteResult>;
|
|
10
10
|
deleteOne(database: string, collection: string, filter: Document, options: DeleteOptions, dbOptions?: DbOptions): Promise<DeleteResult>;
|
|
11
|
-
findOneAndDelete(database: string, collection: string, filter: Document, options: FindOneAndDeleteOptions, dbOptions?: DbOptions): Promise<Document>;
|
|
11
|
+
findOneAndDelete(database: string, collection: string, filter: Document, options: FindOneAndDeleteOptions, dbOptions?: DbOptions): Promise<Document | null>;
|
|
12
12
|
findOneAndReplace(database: string, collection: string, filter: Document, replacement: Document, options: FindOneAndReplaceOptions, dbOptions?: DbOptions): Promise<Document>;
|
|
13
13
|
findOneAndUpdate(database: string, collection: string, filter: Document, update: Document | Document[], options: FindOneAndUpdateOptions, dbOptions?: DbOptions): Promise<Document>;
|
|
14
14
|
insertMany(database: string, collection: string, docs: Document[], options: BulkWriteOptions, dbOptions?: DbOptions): Promise<InsertManyResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mongosh/service-provider-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "MongoDB Shell Core Service Provider Package",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
"prepublish": "npm run compile",
|
|
17
17
|
"test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./src/**/*.spec.ts\"",
|
|
18
18
|
"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
|
|
19
|
+
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
|
|
20
|
+
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",
|
|
19
21
|
"eslint": "eslint",
|
|
20
22
|
"lint": "npm run eslint . && npm run prettier -- --check .",
|
|
21
23
|
"check": "npm run lint && npm run depcheck",
|
|
@@ -42,22 +44,22 @@
|
|
|
42
44
|
},
|
|
43
45
|
"dependencies": {
|
|
44
46
|
"@aws-sdk/credential-providers": "^3.347.1",
|
|
45
|
-
"@mongosh/errors": "
|
|
46
|
-
"bson": "^
|
|
47
|
-
"mongodb": "^
|
|
47
|
+
"@mongosh/errors": "2.0.0",
|
|
48
|
+
"bson": "^6.0.0",
|
|
49
|
+
"mongodb": "^6.0.0",
|
|
48
50
|
"mongodb-build-info": "^1.6.2",
|
|
49
|
-
"mongodb-client-encryption": "^
|
|
51
|
+
"mongodb-client-encryption": "^6.0.0"
|
|
50
52
|
},
|
|
51
53
|
"optionalDependencies": {
|
|
52
|
-
"mongodb-client-encryption": "^
|
|
54
|
+
"mongodb-client-encryption": "^6.0.0"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
|
-
"@mongodb-js/eslint-config-mongosh": "1.
|
|
57
|
+
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
|
|
56
58
|
"@mongodb-js/prettier-config-devtools": "^1.0.1",
|
|
57
|
-
"@mongodb-js/tsconfig-mongosh": "1.
|
|
59
|
+
"@mongodb-js/tsconfig-mongosh": "^1.0.0",
|
|
58
60
|
"depcheck": "^1.4.3",
|
|
59
61
|
"eslint": "^7.25.0",
|
|
60
62
|
"prettier": "^2.8.8"
|
|
61
63
|
},
|
|
62
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "60053aa2f37dc6c3e4fe059e806565ec51ece9e8"
|
|
63
65
|
}
|
package/src/admin.ts
CHANGED
|
@@ -20,8 +20,9 @@ import type {
|
|
|
20
20
|
AzureEncryptionKeyOptions,
|
|
21
21
|
ClientEncryption as MongoCryptClientEncryption,
|
|
22
22
|
ClientEncryptionDataKeyProvider,
|
|
23
|
-
FLE,
|
|
24
23
|
GCPEncryptionKeyOptions,
|
|
24
|
+
ClientEncryption,
|
|
25
|
+
ClientEncryptionOptions,
|
|
25
26
|
} from './all-fle-types';
|
|
26
27
|
|
|
27
28
|
export interface CreateEncryptedCollectionOptions {
|
|
@@ -139,7 +140,7 @@ export default interface Admin {
|
|
|
139
140
|
/**
|
|
140
141
|
* The FLE implementation for access to the client-side encryption API.
|
|
141
142
|
*/
|
|
142
|
-
|
|
143
|
+
createClientEncryption?(options: ClientEncryptionOptions): ClientEncryption;
|
|
143
144
|
|
|
144
145
|
/**
|
|
145
146
|
* The FLE options passed to the client, if any.
|
package/src/all-fle-types.ts
CHANGED
|
@@ -3,15 +3,10 @@ export type {
|
|
|
3
3
|
AzureEncryptionKeyOptions,
|
|
4
4
|
GCPEncryptionKeyOptions,
|
|
5
5
|
ClientEncryption,
|
|
6
|
-
ClientEncryptionCreateDataKeyCallback,
|
|
7
6
|
ClientEncryptionCreateDataKeyProviderOptions,
|
|
8
7
|
ClientEncryptionDataKeyProvider,
|
|
9
|
-
ClientEncryptionDecryptCallback,
|
|
10
|
-
ClientEncryptionEncryptCallback,
|
|
11
8
|
ClientEncryptionEncryptOptions,
|
|
12
9
|
ClientEncryptionOptions,
|
|
13
10
|
ClientEncryptionTlsOptions,
|
|
14
11
|
KMSProviders,
|
|
15
|
-
} from 'mongodb
|
|
16
|
-
|
|
17
|
-
export type FLE = typeof import('mongodb-client-encryption');
|
|
12
|
+
} from 'mongodb';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ObjectId,
|
|
3
|
+
DBRef,
|
|
4
|
+
MaxKey,
|
|
5
|
+
MinKey,
|
|
6
|
+
Timestamp,
|
|
7
|
+
BSONSymbol,
|
|
8
|
+
Code,
|
|
9
|
+
Decimal128,
|
|
10
|
+
Int32,
|
|
11
|
+
Long,
|
|
12
|
+
Binary,
|
|
13
|
+
calculateObjectSize,
|
|
14
|
+
Double,
|
|
15
|
+
EJSON,
|
|
16
|
+
BSONRegExp,
|
|
17
|
+
} from 'bson';
|
|
18
|
+
|
|
19
|
+
export const bson = {
|
|
20
|
+
ObjectId,
|
|
21
|
+
DBRef,
|
|
22
|
+
MaxKey,
|
|
23
|
+
MinKey,
|
|
24
|
+
Timestamp,
|
|
25
|
+
BSONSymbol,
|
|
26
|
+
Code,
|
|
27
|
+
Decimal128,
|
|
28
|
+
Int32,
|
|
29
|
+
Long,
|
|
30
|
+
Binary,
|
|
31
|
+
calculateObjectSize,
|
|
32
|
+
Double,
|
|
33
|
+
EJSON,
|
|
34
|
+
BSONRegExp,
|
|
35
|
+
};
|
package/src/connect-info.spec.ts
CHANGED
|
@@ -71,6 +71,7 @@ describe('getConnectInfo', function () {
|
|
|
71
71
|
is_enterprise: true,
|
|
72
72
|
auth_type: 'LDAP',
|
|
73
73
|
is_data_federation: false,
|
|
74
|
+
is_stream: false,
|
|
74
75
|
dl_version: null,
|
|
75
76
|
atlas_version: '20210330.0.0.1617063608',
|
|
76
77
|
is_genuine: true,
|
|
@@ -79,6 +80,7 @@ describe('getConnectInfo', function () {
|
|
|
79
80
|
node_version: process.version,
|
|
80
81
|
server_os: 'osx',
|
|
81
82
|
uri: ATLAS_URI,
|
|
83
|
+
is_local_atlas: false,
|
|
82
84
|
};
|
|
83
85
|
expect(
|
|
84
86
|
getConnectInfo(
|
|
@@ -86,7 +88,8 @@ describe('getConnectInfo', function () {
|
|
|
86
88
|
'0.0.6',
|
|
87
89
|
BUILD_INFO,
|
|
88
90
|
ATLAS_VERSION,
|
|
89
|
-
TOPOLOGY_WITH_CREDENTIALS
|
|
91
|
+
TOPOLOGY_WITH_CREDENTIALS,
|
|
92
|
+
false
|
|
90
93
|
)
|
|
91
94
|
).to.deep.equal(output);
|
|
92
95
|
});
|
|
@@ -101,6 +104,7 @@ describe('getConnectInfo', function () {
|
|
|
101
104
|
is_enterprise: true,
|
|
102
105
|
auth_type: null,
|
|
103
106
|
is_data_federation: false,
|
|
107
|
+
is_stream: false,
|
|
104
108
|
dl_version: null,
|
|
105
109
|
atlas_version: '20210330.0.0.1617063608',
|
|
106
110
|
is_genuine: true,
|
|
@@ -109,6 +113,7 @@ describe('getConnectInfo', function () {
|
|
|
109
113
|
node_version: process.version,
|
|
110
114
|
server_os: 'osx',
|
|
111
115
|
uri: ATLAS_URI,
|
|
116
|
+
is_local_atlas: false,
|
|
112
117
|
};
|
|
113
118
|
expect(
|
|
114
119
|
getConnectInfo(
|
|
@@ -116,7 +121,43 @@ describe('getConnectInfo', function () {
|
|
|
116
121
|
'0.0.6',
|
|
117
122
|
BUILD_INFO,
|
|
118
123
|
ATLAS_VERSION,
|
|
119
|
-
TOPOLOGY_NO_CREDENTIALS
|
|
124
|
+
TOPOLOGY_NO_CREDENTIALS,
|
|
125
|
+
false
|
|
126
|
+
)
|
|
127
|
+
).to.deep.equal(output);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('reports correct information when a stream uri is passed', function () {
|
|
131
|
+
const streamUri =
|
|
132
|
+
'mongodb://atlas-stream-67b8e1cd6d60357be377be7b-1dekw.virginia-usa.a.query.mongodb-dev.net/';
|
|
133
|
+
const output = {
|
|
134
|
+
is_atlas: true,
|
|
135
|
+
is_localhost: false,
|
|
136
|
+
is_do: false,
|
|
137
|
+
server_version: '3.2.0-rc2',
|
|
138
|
+
mongosh_version: '0.0.6',
|
|
139
|
+
is_enterprise: true,
|
|
140
|
+
auth_type: 'LDAP',
|
|
141
|
+
is_data_federation: false,
|
|
142
|
+
is_stream: true,
|
|
143
|
+
dl_version: null,
|
|
144
|
+
atlas_version: null,
|
|
145
|
+
is_genuine: true,
|
|
146
|
+
is_local_atlas: false,
|
|
147
|
+
non_genuine_server_name: 'mongodb',
|
|
148
|
+
server_arch: 'x86_64',
|
|
149
|
+
node_version: process.version,
|
|
150
|
+
server_os: 'osx',
|
|
151
|
+
uri: streamUri,
|
|
152
|
+
};
|
|
153
|
+
expect(
|
|
154
|
+
getConnectInfo(
|
|
155
|
+
streamUri,
|
|
156
|
+
'0.0.6',
|
|
157
|
+
BUILD_INFO,
|
|
158
|
+
null,
|
|
159
|
+
TOPOLOGY_WITH_CREDENTIALS,
|
|
160
|
+
false
|
|
120
161
|
)
|
|
121
162
|
).to.deep.equal(output);
|
|
122
163
|
});
|
|
@@ -131,6 +172,7 @@ describe('getConnectInfo', function () {
|
|
|
131
172
|
is_enterprise: true,
|
|
132
173
|
auth_type: 'LDAP',
|
|
133
174
|
is_data_federation: false,
|
|
175
|
+
is_stream: false,
|
|
134
176
|
dl_version: null,
|
|
135
177
|
atlas_version: null,
|
|
136
178
|
is_genuine: true,
|
|
@@ -139,9 +181,17 @@ describe('getConnectInfo', function () {
|
|
|
139
181
|
node_version: process.version,
|
|
140
182
|
server_os: 'osx',
|
|
141
183
|
uri: '',
|
|
184
|
+
is_local_atlas: true,
|
|
142
185
|
};
|
|
143
186
|
expect(
|
|
144
|
-
getConnectInfo(
|
|
187
|
+
getConnectInfo(
|
|
188
|
+
'',
|
|
189
|
+
'0.0.6',
|
|
190
|
+
BUILD_INFO,
|
|
191
|
+
null,
|
|
192
|
+
TOPOLOGY_WITH_CREDENTIALS,
|
|
193
|
+
true
|
|
194
|
+
)
|
|
145
195
|
).to.deep.equal(output);
|
|
146
196
|
});
|
|
147
197
|
|
|
@@ -155,6 +205,7 @@ describe('getConnectInfo', function () {
|
|
|
155
205
|
is_enterprise: false,
|
|
156
206
|
auth_type: 'LDAP',
|
|
157
207
|
is_data_federation: false,
|
|
208
|
+
is_stream: false,
|
|
158
209
|
dl_version: null,
|
|
159
210
|
atlas_version: null,
|
|
160
211
|
is_genuine: true,
|
|
@@ -163,9 +214,10 @@ describe('getConnectInfo', function () {
|
|
|
163
214
|
node_version: process.version,
|
|
164
215
|
server_os: null,
|
|
165
216
|
uri: '',
|
|
217
|
+
is_local_atlas: false,
|
|
166
218
|
};
|
|
167
219
|
expect(
|
|
168
|
-
getConnectInfo('', '0.0.6', null, null, TOPOLOGY_WITH_CREDENTIALS)
|
|
220
|
+
getConnectInfo('', '0.0.6', null, null, TOPOLOGY_WITH_CREDENTIALS, false)
|
|
169
221
|
).to.deep.equal(output);
|
|
170
222
|
});
|
|
171
223
|
});
|
package/src/connect-info.ts
CHANGED
|
@@ -13,12 +13,14 @@ export interface ConnectInfo {
|
|
|
13
13
|
is_enterprise: boolean;
|
|
14
14
|
auth_type?: string;
|
|
15
15
|
is_data_federation: boolean;
|
|
16
|
+
is_stream: boolean;
|
|
16
17
|
dl_version?: string;
|
|
17
18
|
atlas_version?: string;
|
|
18
19
|
is_genuine: boolean;
|
|
19
20
|
non_genuine_server_name: string;
|
|
20
21
|
node_version: string;
|
|
21
22
|
uri: string;
|
|
23
|
+
is_local_atlas: boolean;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export default function getConnectInfo(
|
|
@@ -26,7 +28,8 @@ export default function getConnectInfo(
|
|
|
26
28
|
mongoshVersion: string,
|
|
27
29
|
buildInfo: any,
|
|
28
30
|
atlasVersion: any,
|
|
29
|
-
topology: any
|
|
31
|
+
topology: any,
|
|
32
|
+
isLocalAtlas: boolean
|
|
30
33
|
): ConnectInfo {
|
|
31
34
|
buildInfo ??= {}; // We're currently not getting buildInfo with --apiStrict.
|
|
32
35
|
const { isGenuine: is_genuine, serverName: non_genuine_server_name } =
|
|
@@ -54,9 +57,11 @@ export default function getConnectInfo(
|
|
|
54
57
|
is_enterprise: getBuildInfo.isEnterprise(buildInfo),
|
|
55
58
|
auth_type,
|
|
56
59
|
is_data_federation,
|
|
60
|
+
is_stream: getBuildInfo.isAtlasStream(uri),
|
|
57
61
|
dl_version,
|
|
58
62
|
atlas_version: atlasVersion?.atlasVersion ?? null,
|
|
59
63
|
is_genuine,
|
|
60
64
|
non_genuine_server_name,
|
|
65
|
+
is_local_atlas: isLocalAtlas,
|
|
61
66
|
};
|
|
62
67
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,23 +3,6 @@ import ServiceProvider, { ServiceProviderCore } from './service-provider';
|
|
|
3
3
|
import getConnectInfo, { ConnectInfo } from './connect-info';
|
|
4
4
|
import type { ReplPlatform } from './platform';
|
|
5
5
|
const DEFAULT_DB = 'test';
|
|
6
|
-
import {
|
|
7
|
-
ObjectId,
|
|
8
|
-
DBRef,
|
|
9
|
-
MaxKey,
|
|
10
|
-
MinKey,
|
|
11
|
-
Timestamp,
|
|
12
|
-
BSONSymbol,
|
|
13
|
-
Code,
|
|
14
|
-
Decimal128,
|
|
15
|
-
Int32,
|
|
16
|
-
Long,
|
|
17
|
-
Binary,
|
|
18
|
-
calculateObjectSize,
|
|
19
|
-
Double,
|
|
20
|
-
EJSON,
|
|
21
|
-
BSONRegExp,
|
|
22
|
-
} from 'bson';
|
|
23
6
|
import { bsonStringifiers } from './printable-bson';
|
|
24
7
|
import ShellAuthOptions from './shell-auth-options';
|
|
25
8
|
export * from './all-transport-types';
|
|
@@ -32,23 +15,7 @@ export {
|
|
|
32
15
|
CheckMetadataConsistencyOptions,
|
|
33
16
|
} from './admin';
|
|
34
17
|
|
|
35
|
-
|
|
36
|
-
ObjectId,
|
|
37
|
-
DBRef,
|
|
38
|
-
MaxKey,
|
|
39
|
-
MinKey,
|
|
40
|
-
Timestamp,
|
|
41
|
-
BSONSymbol,
|
|
42
|
-
Code,
|
|
43
|
-
Decimal128,
|
|
44
|
-
Int32,
|
|
45
|
-
Long,
|
|
46
|
-
Binary,
|
|
47
|
-
calculateObjectSize,
|
|
48
|
-
Double,
|
|
49
|
-
EJSON,
|
|
50
|
-
BSONRegExp,
|
|
51
|
-
};
|
|
18
|
+
export { bson } from './bson-export';
|
|
52
19
|
|
|
53
20
|
export {
|
|
54
21
|
ServiceProvider,
|
|
@@ -57,7 +24,6 @@ export {
|
|
|
57
24
|
ReplPlatform,
|
|
58
25
|
DEFAULT_DB,
|
|
59
26
|
ServiceProviderCore,
|
|
60
|
-
bson,
|
|
61
27
|
bsonStringifiers,
|
|
62
28
|
ConnectInfo,
|
|
63
29
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
2
|
import { bson } from './index';
|
|
3
3
|
import { inspect } from 'util';
|
|
4
|
-
import makePrintableBson from './printable-bson';
|
|
4
|
+
import { makePrintableBson } from './printable-bson';
|
|
5
5
|
|
|
6
6
|
describe('BSON printers', function () {
|
|
7
7
|
before('make BSON objects printable', function () {
|
|
@@ -19,12 +19,12 @@ describe('BSON printers', function () {
|
|
|
19
19
|
inspect(
|
|
20
20
|
new bson.DBRef('a', new bson.ObjectId('5f16b8bebe434dc98cdfc9cb'), 'db')
|
|
21
21
|
)
|
|
22
|
-
).to.equal('DBRef("a", ObjectId("5f16b8bebe434dc98cdfc9cb"),
|
|
22
|
+
).to.equal('DBRef("a", ObjectId("5f16b8bebe434dc98cdfc9cb"), \'db\')');
|
|
23
23
|
expect(inspect(new bson.DBRef('a', 'foo' as any, 'db'))).to.equal(
|
|
24
|
-
|
|
24
|
+
"DBRef(\"a\", 'foo', 'db')"
|
|
25
25
|
);
|
|
26
26
|
expect(inspect(new bson.DBRef('a', { x: 1 } as any, 'db'))).to.equal(
|
|
27
|
-
'DBRef("a", { x: 1 },
|
|
27
|
+
'DBRef("a", { x: 1 }, \'db\')'
|
|
28
28
|
);
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -67,12 +67,6 @@ describe('BSON printers', function () {
|
|
|
67
67
|
expect(inspect(new bson.Code('abc'))).to.equal('Code("abc")');
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
it('formats BinData correctly', function () {
|
|
71
|
-
expect(inspect(new bson.Binary('abc'))).to.equal(
|
|
72
|
-
'Binary(Buffer.from("616263", "hex"), 0)'
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
70
|
it('formats BSONRegExp correctly', function () {
|
|
77
71
|
expect(inspect(new bson.BSONRegExp('(?-i)AA_', 'im'))).to.equal(
|
|
78
72
|
'BSONRegExp("(?-i)AA_", "im")'
|
|
@@ -100,4 +94,10 @@ describe('BSON printers', function () {
|
|
|
100
94
|
)
|
|
101
95
|
).to.equal('MD5("0123456789abcdef0123456789abcdef")');
|
|
102
96
|
});
|
|
97
|
+
|
|
98
|
+
it('formats any other value with the new format using createfromBase64', function () {
|
|
99
|
+
expect(
|
|
100
|
+
inspect(bson.Binary.createFromBase64('SGVsbG8sIFdvcmxkIQo='))
|
|
101
|
+
).to.equal('Binary.createFromBase64("SGVsbG8sIFdvcmxkIQo=", 0)');
|
|
102
|
+
});
|
|
103
103
|
});
|
package/src/printable-bson.ts
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
|
-
import { bson as BSON } from './
|
|
1
|
+
import { bson as BSON } from './bson-export';
|
|
2
2
|
import { inspect } from 'util';
|
|
3
3
|
const inspectCustom = Symbol.for('nodejs.util.inspect.custom');
|
|
4
|
+
type BSONClassKey = (typeof BSON)[Exclude<
|
|
5
|
+
keyof typeof BSON,
|
|
6
|
+
'EJSON' | 'calculateObjectSize'
|
|
7
|
+
>]['prototype']['_bsontype'];
|
|
8
|
+
|
|
9
|
+
// Turn e.g. 'new Double(...)' into 'Double(...)' but preserve possible leading whitespace
|
|
10
|
+
function removeNewFromInspectResult(str: string): string {
|
|
11
|
+
return String(str).replace(/^(\s*)(new )/, '$1');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Create a Node.js-util-inspect() style custom inspect function that
|
|
15
|
+
// strips 'new ' from inspect results but otherwise uses the Node.js
|
|
16
|
+
// driver's bson library's inspect functions.
|
|
17
|
+
function makeClasslessInspect<K extends BSONClassKey>(className: K) {
|
|
18
|
+
const originalInspect = BSON[className].prototype.inspect;
|
|
19
|
+
return function (
|
|
20
|
+
this: (typeof BSON)[typeof className]['prototype'],
|
|
21
|
+
...args: any
|
|
22
|
+
) {
|
|
23
|
+
return removeNewFromInspectResult(originalInspect.apply(this, args as any));
|
|
24
|
+
};
|
|
25
|
+
}
|
|
4
26
|
|
|
5
27
|
export const bsonStringifiers: Record<
|
|
6
|
-
|
|
28
|
+
BSONClassKey | 'ObjectID',
|
|
7
29
|
(this: any, depth: any, options: any) => string
|
|
8
30
|
> = {
|
|
9
|
-
ObjectId:
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
|
|
31
|
+
ObjectId: makeClasslessInspect('ObjectId'),
|
|
32
|
+
ObjectID: makeClasslessInspect('ObjectId'),
|
|
13
33
|
DBRef: function (
|
|
14
34
|
this: typeof BSON.DBRef.prototype,
|
|
15
35
|
depth: any,
|
|
@@ -17,51 +37,21 @@ export const bsonStringifiers: Record<
|
|
|
17
37
|
): string {
|
|
18
38
|
return (
|
|
19
39
|
`DBRef("${this.collection}", ` +
|
|
20
|
-
inspect(this.oid, options) +
|
|
21
|
-
(this.db ? `,
|
|
40
|
+
inspect(this.oid, options) + // The driver's inspect() does not account for non-ObjectID oid values
|
|
41
|
+
(this.db ? `, ${inspect(this.db, options)}` : '') +
|
|
22
42
|
')'
|
|
23
43
|
);
|
|
24
44
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return `Timestamp({ t: ${this.getHighBits()}, i: ${this.getLowBits()} })`;
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
BSONSymbol: function (this: typeof BSON.BSONSymbol.prototype): string {
|
|
39
|
-
return `BSONSymbol("${this.valueOf()}")`;
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
Code: function (this: typeof BSON.Code.prototype): string {
|
|
43
|
-
const j = this.toJSON();
|
|
44
|
-
return `Code("${j.code}"${j.scope ? `, ${JSON.stringify(j.scope)}` : ''})`;
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
Decimal128: function (this: typeof BSON.Decimal128.prototype): string {
|
|
48
|
-
return `Decimal128("${this.toString()}")`;
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
Int32: function (this: typeof BSON.Int32.prototype): string {
|
|
52
|
-
return `Int32(${this.valueOf()})`;
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
Long: function (this: typeof BSON.Long.prototype): string {
|
|
56
|
-
return `Long("${this.toString()}"${this.unsigned ? ', true' : ''})`;
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
BSONRegExp: function (this: typeof BSON.BSONRegExp.prototype): string {
|
|
60
|
-
return `BSONRegExp(${JSON.stringify(this.pattern)}, ${JSON.stringify(
|
|
61
|
-
this.options
|
|
62
|
-
)})`;
|
|
63
|
-
},
|
|
64
|
-
|
|
45
|
+
MaxKey: makeClasslessInspect('MaxKey'),
|
|
46
|
+
MinKey: makeClasslessInspect('MinKey'),
|
|
47
|
+
Timestamp: makeClasslessInspect('Timestamp'),
|
|
48
|
+
BSONSymbol: makeClasslessInspect('BSONSymbol'),
|
|
49
|
+
Code: makeClasslessInspect('Code'),
|
|
50
|
+
Decimal128: makeClasslessInspect('Decimal128'),
|
|
51
|
+
Int32: makeClasslessInspect('Int32'),
|
|
52
|
+
Long: makeClasslessInspect('Long'),
|
|
53
|
+
Double: makeClasslessInspect('Double'),
|
|
54
|
+
BSONRegExp: makeClasslessInspect('BSONRegExp'),
|
|
65
55
|
Binary: function (this: typeof BSON.Binary.prototype): string {
|
|
66
56
|
const hexString = this.toString('hex');
|
|
67
57
|
switch (this.sub_type) {
|
|
@@ -80,18 +70,19 @@ export const bsonStringifiers: Record<
|
|
|
80
70
|
// In case somebody did something weird and used an UUID with a
|
|
81
71
|
// non-standard length, fall through.
|
|
82
72
|
default:
|
|
83
|
-
return `Binary
|
|
73
|
+
return `Binary.createFromBase64("${this.toString('base64')}", ${
|
|
74
|
+
this.sub_type
|
|
75
|
+
})`;
|
|
84
76
|
}
|
|
85
77
|
},
|
|
86
78
|
};
|
|
87
|
-
bsonStringifiers.ObjectID = bsonStringifiers.ObjectId;
|
|
88
79
|
|
|
89
80
|
/**
|
|
90
81
|
* This method modifies the BSON class passed in as argument. This is required so that
|
|
91
82
|
* we can have the driver return our BSON classes without having to write our own serializer.
|
|
92
83
|
* @param {Object} bson
|
|
93
84
|
*/
|
|
94
|
-
export
|
|
85
|
+
export function makePrintableBson(bson?: typeof BSON): void {
|
|
95
86
|
if (!bson) {
|
|
96
87
|
bson = BSON;
|
|
97
88
|
}
|
|
@@ -102,14 +93,7 @@ export default function (bson?: typeof BSON): void {
|
|
|
102
93
|
}
|
|
103
94
|
const cls = bson[key as keyof typeof BSON];
|
|
104
95
|
for (const key of [inspectCustom, 'inspect']) {
|
|
105
|
-
|
|
106
|
-
(cls as any).prototype[key] = stringifier;
|
|
107
|
-
} catch {
|
|
108
|
-
// This may fail because bson.ObjectId.prototype[toString] can exist as a
|
|
109
|
-
// read-only property. https://github.com/mongodb/js-bson/pull/412 takes
|
|
110
|
-
// care of this. In the CLI repl and Compass this still works fine, because
|
|
111
|
-
// those are on bson@1.x.
|
|
112
|
-
}
|
|
96
|
+
(cls as any).prototype[key] = stringifier;
|
|
113
97
|
}
|
|
114
98
|
}
|
|
115
99
|
}
|
package/src/service-provider.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MongoshInternalError } from '@mongosh/errors';
|
|
2
2
|
import type Admin from './admin';
|
|
3
3
|
import type Closable from './closable';
|
|
4
|
-
import makePrintableBson from './printable-bson';
|
|
4
|
+
import { makePrintableBson } from './printable-bson';
|
|
5
5
|
import type Readable from './readable';
|
|
6
6
|
import type Writable from './writable';
|
|
7
7
|
import type { bson as BSON } from './index';
|
package/src/writable.ts
CHANGED