@qp-mongosh/service-provider-core 0.0.0-dev.0 → 0.0.0-dev.3

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.
Files changed (56) hide show
  1. package/.eslintignore +2 -2
  2. package/.eslintrc.js +1 -1
  3. package/AUTHORS +11 -11
  4. package/LICENSE +200 -200
  5. package/lib/admin.d.ts +28 -28
  6. package/lib/admin.js +2 -2
  7. package/lib/all-fle-types.d.ts +2 -2
  8. package/lib/all-fle-types.js +2 -2
  9. package/lib/all-transport-types.d.ts +1 -1
  10. package/lib/all-transport-types.js +2 -2
  11. package/lib/cli-options.d.ts +43 -43
  12. package/lib/cli-options.js +2 -2
  13. package/lib/closable.d.ts +4 -4
  14. package/lib/closable.js +2 -2
  15. package/lib/connect-info.d.ts +19 -19
  16. package/lib/connect-info.js +34 -34
  17. package/lib/index.d.ts +31 -31
  18. package/lib/index.js +55 -55
  19. package/lib/platform.d.ts +6 -6
  20. package/lib/platform.js +10 -10
  21. package/lib/printable-bson.d.ts +3 -3
  22. package/lib/printable-bson.js +81 -81
  23. package/lib/readable.d.ts +18 -18
  24. package/lib/readable.js +2 -2
  25. package/lib/service-provider.d.ts +11 -11
  26. package/lib/service-provider.js +18 -18
  27. package/lib/shell-auth-options.d.ts +7 -7
  28. package/lib/shell-auth-options.js +2 -2
  29. package/lib/textencoder-polyfill.d.ts +2 -2
  30. package/lib/textencoder-polyfill.js +21 -21
  31. package/lib/uri-generator.d.ts +8 -8
  32. package/lib/uri-generator.js +175 -175
  33. package/lib/writable.d.ts +22 -22
  34. package/lib/writable.js +2 -2
  35. package/package.json +54 -54
  36. package/src/admin.ts +119 -119
  37. package/src/all-fle-types.ts +17 -17
  38. package/src/all-transport-types.ts +80 -80
  39. package/src/cli-options.ts +49 -49
  40. package/src/closable.ts +14 -14
  41. package/src/connect-info.spec.ts +192 -192
  42. package/src/connect-info.ts +57 -57
  43. package/src/index.ts +62 -62
  44. package/src/platform.ts +6 -6
  45. package/src/printable-bson.spec.ts +75 -75
  46. package/src/printable-bson.ts +103 -103
  47. package/src/readable.ts +242 -242
  48. package/src/service-provider.ts +23 -23
  49. package/src/shell-auth-options.ts +7 -7
  50. package/src/textencoder-polyfill.spec.ts +11 -11
  51. package/src/textencoder-polyfill.ts +30 -30
  52. package/src/uri-generator.spec.ts +481 -481
  53. package/src/uri-generator.ts +265 -265
  54. package/src/writable.ts +367 -367
  55. package/tsconfig.json +12 -12
  56. package/tsconfig.lint.json +8 -8
package/lib/closable.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=closable.js.map
@@ -1,19 +1,19 @@
1
- export interface ConnectInfo {
2
- is_atlas: boolean;
3
- is_localhost: boolean;
4
- is_do: boolean;
5
- server_version: string;
6
- mongosh_version: string;
7
- server_os?: string;
8
- server_arch?: string;
9
- is_enterprise: boolean;
10
- auth_type?: string;
11
- is_data_lake: boolean;
12
- dl_version?: string;
13
- atlas_version?: string;
14
- is_genuine: boolean;
15
- non_genuine_server_name: string;
16
- node_version: string;
17
- uri: string;
18
- }
19
- export default function getConnectInfo(uri: string, mongoshVersion: string, buildInfo: any, cmdLineOpts: any, atlasVersion: any, topology: any): ConnectInfo;
1
+ export interface ConnectInfo {
2
+ is_atlas: boolean;
3
+ is_localhost: boolean;
4
+ is_do: boolean;
5
+ server_version: string;
6
+ mongosh_version: string;
7
+ server_os?: string;
8
+ server_arch?: string;
9
+ is_enterprise: boolean;
10
+ auth_type?: string;
11
+ is_data_lake: boolean;
12
+ dl_version?: string;
13
+ atlas_version?: string;
14
+ is_genuine: boolean;
15
+ non_genuine_server_name: string;
16
+ node_version: string;
17
+ uri: string;
18
+ }
19
+ export default function getConnectInfo(uri: string, mongoshVersion: string, buildInfo: any, cmdLineOpts: any, atlasVersion: any, topology: any): ConnectInfo;
@@ -1,35 +1,35 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const mongodb_build_info_1 = __importDefault(require("mongodb-build-info"));
7
- function getConnectInfo(uri, mongoshVersion, buildInfo, cmdLineOpts, atlasVersion, topology) {
8
- var _a;
9
- buildInfo !== null && buildInfo !== void 0 ? buildInfo : (buildInfo = {});
10
- const { isGenuine: is_genuine, serverName: non_genuine_server_name } = mongodb_build_info_1.default.getGenuineMongoDB(buildInfo, cmdLineOpts);
11
- const { isDataLake: is_data_lake, dlVersion: dl_version } = mongodb_build_info_1.default.getDataLake(buildInfo);
12
- const auth_type = topology.s.credentials
13
- ? topology.s.credentials.mechanism : null;
14
- const { serverOs: server_os, serverArch: server_arch } = mongodb_build_info_1.default.getBuildEnv(buildInfo);
15
- return {
16
- is_atlas: !!(atlasVersion === null || atlasVersion === void 0 ? void 0 : atlasVersion.atlasVersion) || mongodb_build_info_1.default.isAtlas(uri),
17
- is_localhost: mongodb_build_info_1.default.isLocalhost(uri),
18
- is_do: mongodb_build_info_1.default.isDigitalOcean(uri),
19
- server_version: buildInfo.version,
20
- node_version: process.version,
21
- mongosh_version: mongoshVersion,
22
- server_os,
23
- uri,
24
- server_arch,
25
- is_enterprise: mongodb_build_info_1.default.isEnterprise(buildInfo),
26
- auth_type,
27
- is_data_lake,
28
- dl_version,
29
- atlas_version: (_a = atlasVersion === null || atlasVersion === void 0 ? void 0 : atlasVersion.atlasVersion) !== null && _a !== void 0 ? _a : null,
30
- is_genuine,
31
- non_genuine_server_name
32
- };
33
- }
34
- exports.default = getConnectInfo;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const mongodb_build_info_1 = __importDefault(require("mongodb-build-info"));
7
+ function getConnectInfo(uri, mongoshVersion, buildInfo, cmdLineOpts, atlasVersion, topology) {
8
+ var _a;
9
+ buildInfo !== null && buildInfo !== void 0 ? buildInfo : (buildInfo = {});
10
+ const { isGenuine: is_genuine, serverName: non_genuine_server_name } = mongodb_build_info_1.default.getGenuineMongoDB(buildInfo, cmdLineOpts);
11
+ const { isDataLake: is_data_lake, dlVersion: dl_version } = mongodb_build_info_1.default.getDataLake(buildInfo);
12
+ const auth_type = topology.s.credentials
13
+ ? topology.s.credentials.mechanism : null;
14
+ const { serverOs: server_os, serverArch: server_arch } = mongodb_build_info_1.default.getBuildEnv(buildInfo);
15
+ return {
16
+ is_atlas: !!(atlasVersion === null || atlasVersion === void 0 ? void 0 : atlasVersion.atlasVersion) || mongodb_build_info_1.default.isAtlas(uri),
17
+ is_localhost: mongodb_build_info_1.default.isLocalhost(uri),
18
+ is_do: mongodb_build_info_1.default.isDigitalOcean(uri),
19
+ server_version: buildInfo.version,
20
+ node_version: process.version,
21
+ mongosh_version: mongoshVersion,
22
+ server_os,
23
+ uri,
24
+ server_arch,
25
+ is_enterprise: mongodb_build_info_1.default.isEnterprise(buildInfo),
26
+ auth_type,
27
+ is_data_lake,
28
+ dl_version,
29
+ atlas_version: (_a = atlasVersion === null || atlasVersion === void 0 ? void 0 : atlasVersion.atlasVersion) !== null && _a !== void 0 ? _a : null,
30
+ is_genuine,
31
+ non_genuine_server_name
32
+ };
33
+ }
34
+ exports.default = getConnectInfo;
35
35
  //# sourceMappingURL=connect-info.js.map
package/lib/index.d.ts CHANGED
@@ -1,31 +1,31 @@
1
- import './textencoder-polyfill';
2
- import ServiceProvider, { ServiceProviderCore } from './service-provider';
3
- import getConnectInfo, { ConnectInfo } from './connect-info';
4
- import { ReplPlatform } from './platform';
5
- import CliOptions from './cli-options';
6
- import generateUri from './uri-generator';
7
- declare const DEFAULT_DB = "test";
8
- import { ObjectId, DBRef, MaxKey, MinKey, Timestamp, BSONSymbol, Code, Decimal128, Int32, Long, Binary, calculateObjectSize, Double, EJSON, BSONRegExp } from 'bson';
9
- import { bsonStringifiers } from './printable-bson';
10
- import ShellAuthOptions from './shell-auth-options';
11
- export * from './all-transport-types';
12
- export * from './all-fle-types';
13
- declare const bson: {
14
- ObjectId: typeof ObjectId;
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
- Map: MapConstructor;
26
- calculateObjectSize: typeof calculateObjectSize;
27
- Double: typeof Double;
28
- EJSON: typeof EJSON;
29
- BSONRegExp: typeof BSONRegExp;
30
- };
31
- export { ServiceProvider, ShellAuthOptions, getConnectInfo, ReplPlatform, CliOptions, generateUri, DEFAULT_DB, ServiceProviderCore, bson, bsonStringifiers, ConnectInfo };
1
+ import './textencoder-polyfill';
2
+ import ServiceProvider, { ServiceProviderCore } from './service-provider';
3
+ import getConnectInfo, { ConnectInfo } from './connect-info';
4
+ import { ReplPlatform } from './platform';
5
+ import CliOptions from './cli-options';
6
+ import generateUri from './uri-generator';
7
+ declare const DEFAULT_DB = "test";
8
+ import { ObjectId, DBRef, MaxKey, MinKey, Timestamp, BSONSymbol, Code, Decimal128, Int32, Long, Binary, calculateObjectSize, Double, EJSON, BSONRegExp } from 'bson';
9
+ import { bsonStringifiers } from './printable-bson';
10
+ import ShellAuthOptions from './shell-auth-options';
11
+ export * from './all-transport-types';
12
+ export * from './all-fle-types';
13
+ declare const bson: {
14
+ ObjectId: typeof ObjectId;
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
+ Map: MapConstructor;
26
+ calculateObjectSize: typeof calculateObjectSize;
27
+ Double: typeof Double;
28
+ EJSON: typeof EJSON;
29
+ BSONRegExp: typeof BSONRegExp;
30
+ };
31
+ export { ServiceProvider, ShellAuthOptions, getConnectInfo, ReplPlatform, CliOptions, generateUri, DEFAULT_DB, ServiceProviderCore, bson, bsonStringifiers, ConnectInfo };
package/lib/index.js CHANGED
@@ -1,56 +1,56 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.bsonStringifiers = exports.bson = exports.ServiceProviderCore = exports.DEFAULT_DB = exports.generateUri = exports.ReplPlatform = exports.getConnectInfo = void 0;
21
- require("./textencoder-polyfill");
22
- const service_provider_1 = require("./service-provider");
23
- Object.defineProperty(exports, "ServiceProviderCore", { enumerable: true, get: function () { return service_provider_1.ServiceProviderCore; } });
24
- const connect_info_1 = __importDefault(require("./connect-info"));
25
- exports.getConnectInfo = connect_info_1.default;
26
- const platform_1 = require("./platform");
27
- Object.defineProperty(exports, "ReplPlatform", { enumerable: true, get: function () { return platform_1.ReplPlatform; } });
28
- const uri_generator_1 = __importDefault(require("./uri-generator"));
29
- exports.generateUri = uri_generator_1.default;
30
- const DEFAULT_DB = 'test';
31
- exports.DEFAULT_DB = DEFAULT_DB;
32
- const bson_1 = require("bson");
33
- const printable_bson_1 = require("./printable-bson");
34
- Object.defineProperty(exports, "bsonStringifiers", { enumerable: true, get: function () { return printable_bson_1.bsonStringifiers; } });
35
- __exportStar(require("./all-transport-types"), exports);
36
- __exportStar(require("./all-fle-types"), exports);
37
- const bson = {
38
- ObjectId: bson_1.ObjectId,
39
- DBRef: bson_1.DBRef,
40
- MaxKey: bson_1.MaxKey,
41
- MinKey: bson_1.MinKey,
42
- Timestamp: bson_1.Timestamp,
43
- BSONSymbol: bson_1.BSONSymbol,
44
- Code: bson_1.Code,
45
- Decimal128: bson_1.Decimal128,
46
- Int32: bson_1.Int32,
47
- Long: bson_1.Long,
48
- Binary: bson_1.Binary,
49
- Map: bson_1.Map,
50
- calculateObjectSize: bson_1.calculateObjectSize,
51
- Double: bson_1.Double,
52
- EJSON: bson_1.EJSON,
53
- BSONRegExp: bson_1.BSONRegExp
54
- };
55
- exports.bson = bson;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.bsonStringifiers = exports.bson = exports.ServiceProviderCore = exports.DEFAULT_DB = exports.generateUri = exports.ReplPlatform = exports.getConnectInfo = void 0;
21
+ require("./textencoder-polyfill");
22
+ const service_provider_1 = require("./service-provider");
23
+ Object.defineProperty(exports, "ServiceProviderCore", { enumerable: true, get: function () { return service_provider_1.ServiceProviderCore; } });
24
+ const connect_info_1 = __importDefault(require("./connect-info"));
25
+ exports.getConnectInfo = connect_info_1.default;
26
+ const platform_1 = require("./platform");
27
+ Object.defineProperty(exports, "ReplPlatform", { enumerable: true, get: function () { return platform_1.ReplPlatform; } });
28
+ const uri_generator_1 = __importDefault(require("./uri-generator"));
29
+ exports.generateUri = uri_generator_1.default;
30
+ const DEFAULT_DB = 'test';
31
+ exports.DEFAULT_DB = DEFAULT_DB;
32
+ const bson_1 = require("bson");
33
+ const printable_bson_1 = require("./printable-bson");
34
+ Object.defineProperty(exports, "bsonStringifiers", { enumerable: true, get: function () { return printable_bson_1.bsonStringifiers; } });
35
+ __exportStar(require("./all-transport-types"), exports);
36
+ __exportStar(require("./all-fle-types"), exports);
37
+ const bson = {
38
+ ObjectId: bson_1.ObjectId,
39
+ DBRef: bson_1.DBRef,
40
+ MaxKey: bson_1.MaxKey,
41
+ MinKey: bson_1.MinKey,
42
+ Timestamp: bson_1.Timestamp,
43
+ BSONSymbol: bson_1.BSONSymbol,
44
+ Code: bson_1.Code,
45
+ Decimal128: bson_1.Decimal128,
46
+ Int32: bson_1.Int32,
47
+ Long: bson_1.Long,
48
+ Binary: bson_1.Binary,
49
+ Map: bson_1.Map,
50
+ calculateObjectSize: bson_1.calculateObjectSize,
51
+ Double: bson_1.Double,
52
+ EJSON: bson_1.EJSON,
53
+ BSONRegExp: bson_1.BSONRegExp
54
+ };
55
+ exports.bson = bson;
56
56
  //# sourceMappingURL=index.js.map
package/lib/platform.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export declare enum ReplPlatform {
2
- Compass = 0,
3
- Browser = 1,
4
- CLI = 2,
5
- JavaShell = 3
6
- }
1
+ export declare enum ReplPlatform {
2
+ Compass = 0,
3
+ Browser = 1,
4
+ CLI = 2,
5
+ JavaShell = 3
6
+ }
package/lib/platform.js CHANGED
@@ -1,11 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReplPlatform = void 0;
4
- var ReplPlatform;
5
- (function (ReplPlatform) {
6
- ReplPlatform[ReplPlatform["Compass"] = 0] = "Compass";
7
- ReplPlatform[ReplPlatform["Browser"] = 1] = "Browser";
8
- ReplPlatform[ReplPlatform["CLI"] = 2] = "CLI";
9
- ReplPlatform[ReplPlatform["JavaShell"] = 3] = "JavaShell";
10
- })(ReplPlatform = exports.ReplPlatform || (exports.ReplPlatform = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReplPlatform = void 0;
4
+ var ReplPlatform;
5
+ (function (ReplPlatform) {
6
+ ReplPlatform[ReplPlatform["Compass"] = 0] = "Compass";
7
+ ReplPlatform[ReplPlatform["Browser"] = 1] = "Browser";
8
+ ReplPlatform[ReplPlatform["CLI"] = 2] = "CLI";
9
+ ReplPlatform[ReplPlatform["JavaShell"] = 3] = "JavaShell";
10
+ })(ReplPlatform = exports.ReplPlatform || (exports.ReplPlatform = {}));
11
11
  //# sourceMappingURL=platform.js.map
@@ -1,3 +1,3 @@
1
- import { bson as BSON } from './index';
2
- export declare const bsonStringifiers: Record<string, (this: any, depth: any, options: any) => string>;
3
- export default function (bson?: typeof BSON): void;
1
+ import { bson as BSON } from './index';
2
+ export declare const bsonStringifiers: Record<string, (this: any, depth: any, options: any) => string>;
3
+ export default function (bson?: typeof BSON): void;
@@ -1,82 +1,82 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bsonStringifiers = void 0;
4
- const index_1 = require("./index");
5
- const util_1 = require("util");
6
- const inspectCustom = Symbol.for('nodejs.util.inspect.custom');
7
- exports.bsonStringifiers = {
8
- ObjectId: function () {
9
- return `ObjectId("${this.toHexString()}")`;
10
- },
11
- DBRef: function (depth, options) {
12
- return `DBRef("${this.namespace}", ` +
13
- (0, util_1.inspect)(this.oid, options) +
14
- (this.db ? `, "${this.db}"` : '') +
15
- ')';
16
- },
17
- MaxKey: function () {
18
- return 'MaxKey()';
19
- },
20
- MinKey: function () {
21
- return 'MinKey()';
22
- },
23
- Timestamp: function () {
24
- return `Timestamp({ t: ${this.getHighBits()}, i: ${this.getLowBits()} })`;
25
- },
26
- BSONSymbol: function () {
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
- },
45
- Binary: function () {
46
- const asBuffer = this.value(true);
47
- switch (this.sub_type) {
48
- case index_1.bson.Binary.SUBTYPE_MD5:
49
- return `MD5("${asBuffer.toString('hex')}")`;
50
- case index_1.bson.Binary.SUBTYPE_UUID:
51
- if (asBuffer.length === 16) {
52
- const hex = asBuffer.toString('hex');
53
- const asUUID = hex.match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/)
54
- .slice(1, 6).join('-');
55
- return `UUID("${asUUID}")`;
56
- }
57
- default:
58
- return `Binary(Buffer.from("${asBuffer.toString('hex')}", "hex"), ${this.sub_type})`;
59
- }
60
- },
61
- };
62
- exports.bsonStringifiers.ObjectID = exports.bsonStringifiers.ObjectId;
63
- function default_1(bson) {
64
- if (!bson) {
65
- bson = index_1.bson;
66
- }
67
- for (const [key, stringifier] of Object.entries(exports.bsonStringifiers)) {
68
- if (!(key in bson)) {
69
- continue;
70
- }
71
- const cls = bson[key];
72
- for (const key of [inspectCustom, 'inspect']) {
73
- try {
74
- cls.prototype[key] = stringifier;
75
- }
76
- catch (_a) {
77
- }
78
- }
79
- }
80
- }
81
- exports.default = default_1;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bsonStringifiers = void 0;
4
+ const index_1 = require("./index");
5
+ const util_1 = require("util");
6
+ const inspectCustom = Symbol.for('nodejs.util.inspect.custom');
7
+ exports.bsonStringifiers = {
8
+ ObjectId: function () {
9
+ return `ObjectId("${this.toHexString()}")`;
10
+ },
11
+ DBRef: function (depth, options) {
12
+ return `DBRef("${this.namespace}", ` +
13
+ (0, util_1.inspect)(this.oid, options) +
14
+ (this.db ? `, "${this.db}"` : '') +
15
+ ')';
16
+ },
17
+ MaxKey: function () {
18
+ return 'MaxKey()';
19
+ },
20
+ MinKey: function () {
21
+ return 'MinKey()';
22
+ },
23
+ Timestamp: function () {
24
+ return `Timestamp({ t: ${this.getHighBits()}, i: ${this.getLowBits()} })`;
25
+ },
26
+ BSONSymbol: function () {
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
+ },
45
+ Binary: function () {
46
+ const asBuffer = this.value(true);
47
+ switch (this.sub_type) {
48
+ case index_1.bson.Binary.SUBTYPE_MD5:
49
+ return `MD5("${asBuffer.toString('hex')}")`;
50
+ case index_1.bson.Binary.SUBTYPE_UUID:
51
+ if (asBuffer.length === 16) {
52
+ const hex = asBuffer.toString('hex');
53
+ const asUUID = hex.match(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/)
54
+ .slice(1, 6).join('-');
55
+ return `UUID("${asUUID}")`;
56
+ }
57
+ default:
58
+ return `Binary(Buffer.from("${asBuffer.toString('hex')}", "hex"), ${this.sub_type})`;
59
+ }
60
+ },
61
+ };
62
+ exports.bsonStringifiers.ObjectID = exports.bsonStringifiers.ObjectId;
63
+ function default_1(bson) {
64
+ if (!bson) {
65
+ bson = index_1.bson;
66
+ }
67
+ for (const [key, stringifier] of Object.entries(exports.bsonStringifiers)) {
68
+ if (!(key in bson)) {
69
+ continue;
70
+ }
71
+ const cls = bson[key];
72
+ for (const key of [inspectCustom, 'inspect']) {
73
+ try {
74
+ cls.prototype[key] = stringifier;
75
+ }
76
+ catch (_a) {
77
+ }
78
+ }
79
+ }
80
+ }
81
+ exports.default = default_1;
82
82
  //# sourceMappingURL=printable-bson.js.map
package/lib/readable.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- import type { Document, AggregateOptions, CountOptions, CountDocumentsOptions, DistinctOptions, EstimatedDocumentCountOptions, FindOptions, ListCollectionsOptions, CollStatsOptions, ListIndexesOptions, AggregationCursor, FindCursor, DbOptions, ReadPreferenceFromOptions, ReadPreferenceLike } from './all-transport-types';
2
- import { ChangeStream, ChangeStreamOptions } from './all-transport-types';
3
- export default interface Readable {
4
- aggregate(database: string, collection: string, pipeline: Document[], options?: AggregateOptions, dbOptions?: DbOptions): AggregationCursor;
5
- aggregateDb(database: string, pipeline: Document[], options?: AggregateOptions, dbOptions?: DbOptions): AggregationCursor;
6
- count(db: string, coll: string, query?: Document, options?: CountOptions, dbOptions?: DbOptions): Promise<number>;
7
- countDocuments(database: string, collection: string, filter?: Document, options?: CountDocumentsOptions, dbOptions?: DbOptions): Promise<number>;
8
- distinct(database: string, collection: string, fieldName: string, filter?: Document, options?: DistinctOptions, dbOptions?: DbOptions): Promise<Document>;
9
- estimatedDocumentCount(database: string, collection: string, options?: EstimatedDocumentCountOptions, dbOptions?: DbOptions): Promise<number>;
10
- find(database: string, collection: string, filter?: Document, options?: FindOptions, dbOptions?: DbOptions): FindCursor;
11
- getTopology(): any;
12
- isCapped(database: string, collection: string, dbOptions?: DbOptions): Promise<boolean>;
13
- getIndexes(database: string, collection: string, options: ListIndexesOptions, dbOptions?: DbOptions): Promise<Document[]>;
14
- listCollections(database: string, filter?: Document, options?: ListCollectionsOptions, dbOptions?: DbOptions): Promise<Document[]>;
15
- readPreferenceFromOptions(options?: Omit<ReadPreferenceFromOptions, 'session'>): ReadPreferenceLike | undefined;
16
- stats(database: string, collection: string, options?: CollStatsOptions, dbOptions?: DbOptions): Promise<Document>;
17
- watch(pipeline: Document[], options: ChangeStreamOptions, dbOptions?: DbOptions, db?: string, coll?: string): ChangeStream<Document>;
18
- }
1
+ import type { Document, AggregateOptions, CountOptions, CountDocumentsOptions, DistinctOptions, EstimatedDocumentCountOptions, FindOptions, ListCollectionsOptions, CollStatsOptions, ListIndexesOptions, AggregationCursor, FindCursor, DbOptions, ReadPreferenceFromOptions, ReadPreferenceLike } from './all-transport-types';
2
+ import { ChangeStream, ChangeStreamOptions } from './all-transport-types';
3
+ export default interface Readable {
4
+ aggregate(database: string, collection: string, pipeline: Document[], options?: AggregateOptions, dbOptions?: DbOptions): AggregationCursor;
5
+ aggregateDb(database: string, pipeline: Document[], options?: AggregateOptions, dbOptions?: DbOptions): AggregationCursor;
6
+ count(db: string, coll: string, query?: Document, options?: CountOptions, dbOptions?: DbOptions): Promise<number>;
7
+ countDocuments(database: string, collection: string, filter?: Document, options?: CountDocumentsOptions, dbOptions?: DbOptions): Promise<number>;
8
+ distinct(database: string, collection: string, fieldName: string, filter?: Document, options?: DistinctOptions, dbOptions?: DbOptions): Promise<Document>;
9
+ estimatedDocumentCount(database: string, collection: string, options?: EstimatedDocumentCountOptions, dbOptions?: DbOptions): Promise<number>;
10
+ find(database: string, collection: string, filter?: Document, options?: FindOptions, dbOptions?: DbOptions): FindCursor;
11
+ getTopology(): any;
12
+ isCapped(database: string, collection: string, dbOptions?: DbOptions): Promise<boolean>;
13
+ getIndexes(database: string, collection: string, options: ListIndexesOptions, dbOptions?: DbOptions): Promise<Document[]>;
14
+ listCollections(database: string, filter?: Document, options?: ListCollectionsOptions, dbOptions?: DbOptions): Promise<Document[]>;
15
+ readPreferenceFromOptions(options?: Omit<ReadPreferenceFromOptions, 'session'>): ReadPreferenceLike | undefined;
16
+ stats(database: string, collection: string, options?: CollStatsOptions, dbOptions?: DbOptions): Promise<Document>;
17
+ watch(pipeline: Document[], options: ChangeStreamOptions, dbOptions?: DbOptions, db?: string, coll?: string): ChangeStream<Document>;
18
+ }
package/lib/readable.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=readable.js.map
@@ -1,11 +1,11 @@
1
- import Admin from './admin';
2
- import Closable from './closable';
3
- import Readable from './readable';
4
- import Writable from './writable';
5
- import type { bson as BSON } from './index';
6
- export default interface ServiceProvider extends Readable, Writable, Closable, Admin {
7
- }
8
- export declare class ServiceProviderCore {
9
- bsonLibrary: typeof BSON;
10
- constructor(bsonLibrary?: typeof BSON);
11
- }
1
+ import Admin from './admin';
2
+ import Closable from './closable';
3
+ import Readable from './readable';
4
+ import Writable from './writable';
5
+ import type { bson as BSON } from './index';
6
+ export default interface ServiceProvider extends Readable, Writable, Closable, Admin {
7
+ }
8
+ export declare class ServiceProviderCore {
9
+ bsonLibrary: typeof BSON;
10
+ constructor(bsonLibrary?: typeof BSON);
11
+ }
@@ -1,19 +1,19 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ServiceProviderCore = void 0;
7
- const errors_1 = require("@qp-mongosh/errors");
8
- const printable_bson_1 = __importDefault(require("./printable-bson"));
9
- class ServiceProviderCore {
10
- constructor(bsonLibrary) {
11
- if (bsonLibrary === undefined) {
12
- throw new errors_1.MongoshInternalError('BSON Library is undefined.');
13
- }
14
- (0, printable_bson_1.default)(bsonLibrary);
15
- this.bsonLibrary = bsonLibrary;
16
- }
17
- }
18
- exports.ServiceProviderCore = ServiceProviderCore;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ServiceProviderCore = void 0;
7
+ const errors_1 = require("@qp-mongosh/errors");
8
+ const printable_bson_1 = __importDefault(require("./printable-bson"));
9
+ class ServiceProviderCore {
10
+ constructor(bsonLibrary) {
11
+ if (bsonLibrary === undefined) {
12
+ throw new errors_1.MongoshInternalError('BSON Library is undefined.');
13
+ }
14
+ (0, printable_bson_1.default)(bsonLibrary);
15
+ this.bsonLibrary = bsonLibrary;
16
+ }
17
+ }
18
+ exports.ServiceProviderCore = ServiceProviderCore;
19
19
  //# sourceMappingURL=service-provider.js.map
@@ -1,7 +1,7 @@
1
- export default interface ShellAuthOptions {
2
- user: string;
3
- pwd: string;
4
- mechanism?: string;
5
- digestPassword?: boolean;
6
- authDb?: string;
7
- }
1
+ export default interface ShellAuthOptions {
2
+ user: string;
3
+ pwd: string;
4
+ mechanism?: string;
5
+ digestPassword?: boolean;
6
+ authDb?: string;
7
+ }
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=shell-auth-options.js.map
@@ -1,2 +1,2 @@
1
- declare function textEncodingPolyfill(): any;
2
- export { textEncodingPolyfill };
1
+ declare function textEncodingPolyfill(): any;
2
+ export { textEncodingPolyfill };