@qp-mongosh/service-provider-core 0.0.0-dev.28 → 0.0.0-dev.29
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/lib/admin.d.ts +28 -0
- package/lib/admin.js +3 -0
- package/lib/admin.js.map +1 -0
- package/lib/all-fle-types.d.ts +2 -0
- package/lib/all-fle-types.js +3 -0
- package/lib/all-fle-types.js.map +1 -0
- package/lib/all-transport-types.d.ts +1 -0
- package/lib/all-transport-types.js +3 -0
- package/lib/all-transport-types.js.map +1 -0
- package/lib/cli-options.d.ts +43 -0
- package/lib/cli-options.js +3 -0
- package/lib/cli-options.js.map +1 -0
- package/lib/closable.d.ts +4 -0
- package/lib/closable.js +3 -0
- package/lib/closable.js.map +1 -0
- package/lib/connect-info.d.ts +19 -0
- package/lib/connect-info.js +35 -0
- package/lib/connect-info.js.map +1 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.js +56 -0
- package/lib/index.js.map +1 -0
- package/lib/platform.d.ts +6 -0
- package/lib/platform.js +11 -0
- package/lib/platform.js.map +1 -0
- package/lib/printable-bson.d.ts +3 -0
- package/lib/printable-bson.js +82 -0
- package/lib/printable-bson.js.map +1 -0
- package/lib/readable.d.ts +18 -0
- package/lib/readable.js +3 -0
- package/lib/readable.js.map +1 -0
- package/lib/service-provider.d.ts +11 -0
- package/lib/service-provider.js +19 -0
- package/lib/service-provider.js.map +1 -0
- package/lib/shell-auth-options.d.ts +7 -0
- package/lib/shell-auth-options.js +3 -0
- package/lib/shell-auth-options.js.map +1 -0
- package/lib/textencoder-polyfill.d.ts +2 -0
- package/lib/textencoder-polyfill.js +22 -0
- package/lib/textencoder-polyfill.js.map +1 -0
- package/lib/uri-generator.d.ts +8 -0
- package/lib/uri-generator.js +176 -0
- package/lib/uri-generator.js.map +1 -0
- package/lib/writable.d.ts +22 -0
- package/lib/writable.js +3 -0
- package/lib/writable.js.map +1 -0
- package/package.json +1 -1
package/lib/admin.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import ShellAuthOptions from './shell-auth-options';
|
|
2
|
+
import type { MongoClientOptions, ReadConcern, ReadPreference, WriteConcern, Document, CreateCollectionOptions, ClientSession, DbOptions, ClientSessionOptions, ListDatabasesOptions, AutoEncryptionOptions } from './all-transport-types';
|
|
3
|
+
import type { bson as BSON } from './index';
|
|
4
|
+
import { ReplPlatform } from './platform';
|
|
5
|
+
import { FLE } from './all-fle-types';
|
|
6
|
+
export default interface Admin {
|
|
7
|
+
platform: ReplPlatform;
|
|
8
|
+
initialDb: string;
|
|
9
|
+
bsonLibrary: typeof BSON;
|
|
10
|
+
listDatabases(database: string, options?: ListDatabasesOptions): Promise<Document>;
|
|
11
|
+
getNewConnection(uri: string, options: MongoClientOptions): Promise<any>;
|
|
12
|
+
getURI(): string | undefined;
|
|
13
|
+
getConnectionInfo(): Promise<Document>;
|
|
14
|
+
authenticate(authDoc: ShellAuthOptions): Promise<{
|
|
15
|
+
ok: number;
|
|
16
|
+
}>;
|
|
17
|
+
createCollection(dbName: string, collName: string, options: CreateCollectionOptions, dbOptions?: DbOptions): Promise<{
|
|
18
|
+
ok: number;
|
|
19
|
+
}>;
|
|
20
|
+
getReadPreference(): ReadPreference;
|
|
21
|
+
getReadConcern(): ReadConcern | undefined;
|
|
22
|
+
getWriteConcern(): WriteConcern | undefined;
|
|
23
|
+
resetConnectionOptions(options: MongoClientOptions): Promise<void>;
|
|
24
|
+
startSession(options: ClientSessionOptions): ClientSession;
|
|
25
|
+
getRawClient(): any;
|
|
26
|
+
fle?: FLE | undefined;
|
|
27
|
+
getFleOptions?: () => AutoEncryptionOptions | undefined;
|
|
28
|
+
}
|
package/lib/admin.js
ADDED
package/lib/admin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { AWSEncryptionKeyOptions, AzureEncryptionKeyOptions, GCPEncryptionKeyOptions, ClientEncryption, ClientEncryptionCreateDataKeyCallback, ClientEncryptionCreateDataKeyProviderOptions, ClientEncryptionDataKeyProvider, ClientEncryptionDecryptCallback, ClientEncryptionEncryptCallback, ClientEncryptionEncryptOptions, ClientEncryptionOptions, ClientEncryptionTlsOptions, KMSProviders } from 'mongodb-client-encryption';
|
|
2
|
+
export type FLE = typeof import('mongodb-client-encryption');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all-fle-types.js","sourceRoot":"","sources":["../src/all-fle-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { AggregateOptions, AggregationCursor, AnyBulkWriteOperation, Batch, BulkResult, BulkWriteOptions, BulkWriteResult, ChangeStream, ChangeStreamOptions, ClientSession, CloseOptions, CollationOptions, CollStatsOptions, Collection, CommandOperationOptions, CountDocumentsOptions, CountOptions, CreateCollectionOptions, CreateIndexesOptions, ClientSessionOptions, ClusterTime, FindCursor, CursorFlag, Db, DbOptions, DeleteOptions, DeleteResult, DistinctOptions, Document, DropCollectionOptions, DropDatabaseOptions, EstimatedDocumentCountOptions, ExplainOptions, ExplainVerbosityLike, FindOneAndDeleteOptions, FindOneAndUpdateOptions, FindOneAndReplaceOptions, FindOperators, FindOptions, HedgeOptions, IndexDescription, InsertManyResult, InsertOneOptions, InsertOneResult, ListCollectionsOptions, ListDatabasesOptions, ListIndexesOptions, MapReduceOptions, 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 'qp-mongodb';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all-transport-types.js","sourceRoot":"","sources":["../src/all-transport-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export default interface CliOptions {
|
|
2
|
+
connectionSpecifier?: string;
|
|
3
|
+
fileNames?: string[];
|
|
4
|
+
apiDeprecationErrors?: boolean;
|
|
5
|
+
apiStrict?: boolean;
|
|
6
|
+
apiVersion?: string;
|
|
7
|
+
authenticationDatabase?: string;
|
|
8
|
+
authenticationMechanism?: string;
|
|
9
|
+
awsAccessKeyId?: string;
|
|
10
|
+
awsIamSessionToken?: string;
|
|
11
|
+
awsSecretAccessKey?: string;
|
|
12
|
+
awsSessionToken?: string;
|
|
13
|
+
db?: string;
|
|
14
|
+
eval?: string;
|
|
15
|
+
gssapiServiceName?: string;
|
|
16
|
+
sspiHostnameCanonicalization?: string;
|
|
17
|
+
sspiRealmOverride?: string;
|
|
18
|
+
help?: boolean;
|
|
19
|
+
host?: string;
|
|
20
|
+
ipv6?: boolean;
|
|
21
|
+
keyVaultNamespace?: string;
|
|
22
|
+
kmsURL?: string;
|
|
23
|
+
nodb?: boolean;
|
|
24
|
+
norc?: boolean;
|
|
25
|
+
password?: string;
|
|
26
|
+
port?: string;
|
|
27
|
+
quiet?: boolean;
|
|
28
|
+
retryWrites?: boolean;
|
|
29
|
+
shell?: boolean;
|
|
30
|
+
tls?: boolean;
|
|
31
|
+
tlsAllowInvalidCertificates?: boolean;
|
|
32
|
+
tlsAllowInvalidHostnames?: boolean;
|
|
33
|
+
tlsCAFile?: string;
|
|
34
|
+
tlsCertificateKeyFile?: string;
|
|
35
|
+
tlsCertificateKeyFilePassword?: string;
|
|
36
|
+
tlsCertificateSelector?: string;
|
|
37
|
+
tlsCRLFile?: string;
|
|
38
|
+
tlsDisabledProtocols?: boolean;
|
|
39
|
+
tlsFIPSMode?: boolean;
|
|
40
|
+
username?: string;
|
|
41
|
+
verbose?: boolean;
|
|
42
|
+
version?: boolean;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-options.js","sourceRoot":"","sources":["../src/cli-options.ts"],"names":[],"mappings":""}
|
package/lib/closable.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closable.js","sourceRoot":"","sources":["../src/closable.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +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;
|
|
35
|
+
//# sourceMappingURL=connect-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-info.js","sourceRoot":"","sources":["../src/connect-info.ts"],"names":[],"mappings":";;;;;AAGA,4EAA8C;AAqB9C,SAAwB,cAAc,CAAC,GAAW,EAAE,cAAsB,EAAE,SAAc,EAAE,WAAgB,EAAE,YAAiB,EAAE,QAAa;;IAC5I,SAAS,aAAT,SAAS,cAAT,SAAS,IAA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-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
ADDED
|
@@ -0,0 +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;
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kCAAgC;AAChC,yDAA0E;AAwDxE,oGAxDwB,sCAAmB,OAwDxB;AAvDrB,kEAA6D;AAkD3D,yBAlDK,sBAAc,CAkDL;AAjDhB,yCAA0C;AAkDxC,6FAlDO,uBAAY,OAkDP;AAhDd,oEAA0C;AAkDxC,sBAlDK,uBAAW,CAkDL;AAjDb,MAAM,UAAU,GAAG,MAAM,CAAC;AAkDxB,gCAAU;AAjDZ,+BAiBc;AACd,qDAAoD;AAkClD,iGAlCO,iCAAgB,OAkCP;AAhClB,wDAAsC;AACtC,kDAAgC;AAEhC,MAAM,IAAI,GAAG;IACX,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,GAAG,EAAH,UAAG;IACH,mBAAmB,EAAnB,0BAAmB;IACnB,MAAM,EAAN,aAAM;IACN,KAAK,EAAL,YAAK;IACL,UAAU,EAAV,iBAAU;CACX,CAAC;AAWA,oBAAI"}
|
package/lib/platform.js
ADDED
|
@@ -0,0 +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 = {}));
|
|
11
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,qDAAO,CAAA;IACP,qDAAO,CAAA;IACP,6CAAG,CAAA;IACH,yDAAS,CAAA;AACX,CAAC,EALW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAKvB"}
|
|
@@ -0,0 +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;
|
|
82
|
+
//# sourceMappingURL=printable-bson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"printable-bson.js","sourceRoot":"","sources":["../src/printable-bson.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AACvC,+BAA+B;AAC/B,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B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CAAC,EAAE;YAClB,SAAS;SACV;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAwB,CAAC,CAAC;QAC3C,KAAK,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE;YAC5C,IAAI;gBACD,GAAW,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;aAC3C;YAAC,WAAM;aAKP;SACF;KACF;AACH,CAAC;AArBD,4BAqBC"}
|
|
@@ -0,0 +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
|
+
}
|
package/lib/readable.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readable.js","sourceRoot":"","sources":["../src/readable.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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;
|
|
19
|
+
//# sourceMappingURL=service-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-provider.js","sourceRoot":"","sources":["../src/service-provider.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA0D;AAG1D,sEAAiD;AAUjD,MAAa,mBAAmB;IAE9B,YAAY,WAAyB;QACnC,IAAI,WAAW,KAAK,SAAS,EAAE;YAC7B,MAAM,IAAI,6BAAoB,CAAC,4BAA4B,CAAC,CAAC;SAC9D;QACD,IAAA,wBAAiB,EAAC,WAAW,CAAC,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF;AATD,kDASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-auth-options.js","sourceRoot":"","sources":["../src/shell-auth-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textEncodingPolyfill = void 0;
|
|
4
|
+
if (typeof TextDecoder !== 'function' || typeof TextEncoder !== 'function') {
|
|
5
|
+
Object.assign(Function('return this')(), textEncodingPolyfill());
|
|
6
|
+
}
|
|
7
|
+
function textEncodingPolyfill() {
|
|
8
|
+
class TextEncoder {
|
|
9
|
+
encode(string) {
|
|
10
|
+
return Buffer.from(string, 'utf8');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
class TextDecoder {
|
|
14
|
+
decode(bytes) {
|
|
15
|
+
const str = Buffer.from(bytes).toString('utf8');
|
|
16
|
+
return str.slice(+str.startsWith('\ufeff'));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return { TextDecoder, TextEncoder };
|
|
20
|
+
}
|
|
21
|
+
exports.textEncodingPolyfill = textEncodingPolyfill;
|
|
22
|
+
//# sourceMappingURL=textencoder-polyfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textencoder-polyfill.js","sourceRoot":"","sources":["../src/textencoder-polyfill.ts"],"names":[],"mappings":";;;AAIA,IAGE,OAAO,WAAW,KAAK,UAAU,IAAI,OAAO,WAAW,KAAK,UAAU,EACtE;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"}
|
|
@@ -0,0 +1,176 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.Scheme = void 0;
|
|
30
|
+
const errors_1 = require("@qp-mongosh/errors");
|
|
31
|
+
const i18n_1 = __importDefault(require("@qp-mongosh/i18n"));
|
|
32
|
+
const mongodb_connection_string_url_1 = __importStar(require("mongodb-connection-string-url"));
|
|
33
|
+
const index_1 = require("./index");
|
|
34
|
+
var Scheme;
|
|
35
|
+
(function (Scheme) {
|
|
36
|
+
Scheme["Mongo"] = "mongodb://";
|
|
37
|
+
Scheme["MongoSrv"] = "mongodb+srv://";
|
|
38
|
+
})(Scheme || (Scheme = {}));
|
|
39
|
+
exports.Scheme = Scheme;
|
|
40
|
+
const DEFAULT_HOST = '127.0.0.1';
|
|
41
|
+
const DEFAULT_PORT = '27017';
|
|
42
|
+
const CONFLICT = 'cli-repl.uri-generator.no-host-port';
|
|
43
|
+
const INVALID_HOST = 'cli-repl.uri-generator.invalid-host';
|
|
44
|
+
const HOST_LIST_PORT_MISMATCH = 'cli-repl.uri-generator.host-list-port-mismatch';
|
|
45
|
+
const DIVERGING_SERVICE_NAME = 'cli-repl.uri-generator.diverging-service-name';
|
|
46
|
+
const GSSAPI_SERVICE_NAME_UNSUPPORTED = 'cli-repl.uri-generator.gssapi-service-name-unsupported';
|
|
47
|
+
function validateConflicts(options, connectionString) {
|
|
48
|
+
if (options.host || options.port) {
|
|
49
|
+
throw new errors_1.MongoshInvalidInputError(i18n_1.default.__(CONFLICT), errors_1.CommonErrors.InvalidArgument);
|
|
50
|
+
}
|
|
51
|
+
if (options.gssapiServiceName && (connectionString === null || connectionString === void 0 ? void 0 : connectionString.searchParams.has('authMechanismProperties'))) {
|
|
52
|
+
const authProperties = new mongodb_connection_string_url_1.CommaAndColonSeparatedRecord(connectionString.searchParams.get('authMechanismProperties'));
|
|
53
|
+
const serviceName = authProperties.get('SERVICE_NAME');
|
|
54
|
+
if (serviceName !== undefined && options.gssapiServiceName !== serviceName) {
|
|
55
|
+
throw new errors_1.MongoshInvalidInputError(i18n_1.default.__(DIVERGING_SERVICE_NAME), errors_1.CommonErrors.InvalidArgument);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (connectionString === null || connectionString === void 0 ? void 0 : connectionString.searchParams.has('gssapiServiceName')) {
|
|
59
|
+
throw new errors_1.MongoshInvalidInputError(i18n_1.default.__(GSSAPI_SERVICE_NAME_UNSUPPORTED), errors_1.CommonErrors.InvalidArgument);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function validateHost(host) {
|
|
63
|
+
const invalidCharacter = host.match(/[^a-zA-Z0-9.:\[\]_-]/);
|
|
64
|
+
if (invalidCharacter) {
|
|
65
|
+
throw new errors_1.MongoshInvalidInputError(i18n_1.default.__(INVALID_HOST) + ': ' + invalidCharacter[0], errors_1.CommonErrors.InvalidArgument);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function validateHostSeedList(hosts, fixedPort) {
|
|
69
|
+
const trimmedHosts = hosts.split(',').map(h => h.trim()).filter(h => !!h);
|
|
70
|
+
const hostList = [];
|
|
71
|
+
trimmedHosts.forEach(h => {
|
|
72
|
+
const [host, port] = h.split(':');
|
|
73
|
+
if (fixedPort && port !== undefined && port !== fixedPort) {
|
|
74
|
+
throw new errors_1.MongoshInvalidInputError(i18n_1.default.__(HOST_LIST_PORT_MISMATCH), errors_1.CommonErrors.InvalidArgument);
|
|
75
|
+
}
|
|
76
|
+
hostList.push(`${host}${(port || fixedPort) ? ':' + (port || fixedPort) : ''}`);
|
|
77
|
+
});
|
|
78
|
+
return hostList;
|
|
79
|
+
}
|
|
80
|
+
function generateHost(options) {
|
|
81
|
+
if (options.host) {
|
|
82
|
+
validateHost(options.host);
|
|
83
|
+
if (options.host.includes(':')) {
|
|
84
|
+
return options.host.split(':')[0];
|
|
85
|
+
}
|
|
86
|
+
return options.host;
|
|
87
|
+
}
|
|
88
|
+
return DEFAULT_HOST;
|
|
89
|
+
}
|
|
90
|
+
function generatePort(options) {
|
|
91
|
+
if (options.host && options.host.includes(':')) {
|
|
92
|
+
validateHost(options.host);
|
|
93
|
+
const port = options.host.split(':')[1];
|
|
94
|
+
if (!options.port || options.port === port) {
|
|
95
|
+
return port;
|
|
96
|
+
}
|
|
97
|
+
throw new errors_1.MongoshInvalidInputError(i18n_1.default.__(CONFLICT), errors_1.CommonErrors.InvalidArgument);
|
|
98
|
+
}
|
|
99
|
+
return options.port ? options.port : DEFAULT_PORT;
|
|
100
|
+
}
|
|
101
|
+
function generateUri(options) {
|
|
102
|
+
if (options.nodb) {
|
|
103
|
+
return '';
|
|
104
|
+
}
|
|
105
|
+
const connectionString = generateUriNormalized(options);
|
|
106
|
+
if (connectionString.hosts.every(host => ['localhost', '127.0.0.1'].includes(host.split(':')[0]))) {
|
|
107
|
+
const params = connectionString.searchParams;
|
|
108
|
+
if (!params.has('serverSelectionTimeoutMS')) {
|
|
109
|
+
params.set('serverSelectionTimeoutMS', '2000');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return connectionString.toString();
|
|
113
|
+
}
|
|
114
|
+
function generateUriNormalized(options) {
|
|
115
|
+
var _a, _b, _c;
|
|
116
|
+
const uri = options.connectionSpecifier;
|
|
117
|
+
const replSetHostMatch = ((_a = options.host) !== null && _a !== void 0 ? _a : '').match(/^(?<replSetName>[^/]+)\/(?<hosts>([A-Za-z0-9._-]+(:\d+)?,?)+)$/);
|
|
118
|
+
if (replSetHostMatch) {
|
|
119
|
+
const { replSetName, hosts } = replSetHostMatch.groups;
|
|
120
|
+
const connectionString = new mongodb_connection_string_url_1.default(`${Scheme.Mongo}replacemeHost/${encodeURIComponent(uri || '')}`);
|
|
121
|
+
connectionString.hosts = validateHostSeedList(hosts, options.port);
|
|
122
|
+
connectionString.searchParams.set('replicaSet', replSetName);
|
|
123
|
+
return addShellConnectionStringParameters(connectionString);
|
|
124
|
+
}
|
|
125
|
+
const seedList = ((_b = options.host) !== null && _b !== void 0 ? _b : '').match(/^(?<hosts>([A-Za-z0-9._-]+(:\d+)?,?)+)$/);
|
|
126
|
+
if (seedList && ((_c = options.host) === null || _c === void 0 ? void 0 : _c.includes(','))) {
|
|
127
|
+
const { hosts } = seedList.groups;
|
|
128
|
+
const connectionString = new mongodb_connection_string_url_1.default(`${Scheme.Mongo}replacemeHost/${encodeURIComponent(uri || '')}`);
|
|
129
|
+
connectionString.hosts = validateHostSeedList(hosts, options.port);
|
|
130
|
+
return addShellConnectionStringParameters(connectionString);
|
|
131
|
+
}
|
|
132
|
+
if (!uri) {
|
|
133
|
+
return new mongodb_connection_string_url_1.default(`${Scheme.Mongo}${generateHost(options)}:${generatePort(options)}/?directConnection=true`);
|
|
134
|
+
}
|
|
135
|
+
if (uri.startsWith(Scheme.MongoSrv)) {
|
|
136
|
+
const connectionString = new mongodb_connection_string_url_1.default(uri);
|
|
137
|
+
validateConflicts(options, connectionString);
|
|
138
|
+
return connectionString;
|
|
139
|
+
}
|
|
140
|
+
else if (uri.startsWith(Scheme.Mongo)) {
|
|
141
|
+
const connectionString = new mongodb_connection_string_url_1.default(uri);
|
|
142
|
+
validateConflicts(options, connectionString);
|
|
143
|
+
return addShellConnectionStringParameters(connectionString);
|
|
144
|
+
}
|
|
145
|
+
const uriMatch = /^([A-Za-z0-9][A-Za-z0-9._-]+):?(\d+)?(?:\/(\S*))?$/gi;
|
|
146
|
+
let parts = uriMatch.exec(uri);
|
|
147
|
+
if (parts === null) {
|
|
148
|
+
if (/[/\\. "$]/.test(uri)) {
|
|
149
|
+
throw new errors_1.MongoshInvalidInputError(`Invalid URI: ${uri}`, errors_1.CommonErrors.InvalidArgument);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
parts = [uri, uri];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
let host = parts === null || parts === void 0 ? void 0 : parts[1];
|
|
156
|
+
const port = parts === null || parts === void 0 ? void 0 : parts[2];
|
|
157
|
+
let dbAndQueryString = parts === null || parts === void 0 ? void 0 : parts[3];
|
|
158
|
+
if (!port && !dbAndQueryString && host.indexOf('.') < 0) {
|
|
159
|
+
dbAndQueryString = host;
|
|
160
|
+
host = undefined;
|
|
161
|
+
}
|
|
162
|
+
if (host || port) {
|
|
163
|
+
validateConflicts(options);
|
|
164
|
+
}
|
|
165
|
+
return addShellConnectionStringParameters(new mongodb_connection_string_url_1.default(`${Scheme.Mongo}${host || generateHost(options)}:${port || generatePort(options)}/${encodeURIComponent(dbAndQueryString || index_1.DEFAULT_DB)}`));
|
|
166
|
+
}
|
|
167
|
+
function addShellConnectionStringParameters(uri) {
|
|
168
|
+
uri = uri.clone();
|
|
169
|
+
const params = uri.searchParams;
|
|
170
|
+
if (!params.has('replicaSet') && !params.has('directConnection') && !params.has('loadBalanced') && uri.hosts.length === 1) {
|
|
171
|
+
params.set('directConnection', 'true');
|
|
172
|
+
}
|
|
173
|
+
return uri;
|
|
174
|
+
}
|
|
175
|
+
exports.default = generateUri;
|
|
176
|
+
//# sourceMappingURL=uri-generator.js.map
|
|
@@ -0,0 +1 @@
|
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C,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACzH,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;KACxC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Document, InsertOneOptions, InsertOneResult, Collection, RenameOptions, FindOneAndDeleteOptions, FindOneAndReplaceOptions, FindOneAndUpdateOptions, BulkWriteOptions, AnyBulkWriteOperation, DeleteOptions, DeleteResult, InsertManyResult, ReplaceOptions, UpdateResult, UpdateOptions, DropDatabaseOptions, CreateIndexesOptions, DropCollectionOptions, BulkWriteResult, RunCommandOptions, DbOptions, OrderedBulkOperation, UnorderedBulkOperation } from './all-transport-types';
|
|
2
|
+
export default interface Writable {
|
|
3
|
+
runCommand(db: string, spec: Document, options: RunCommandOptions, dbOptions?: DbOptions): Promise<Document>;
|
|
4
|
+
runCommandWithCheck(db: string, spec: Document, options: RunCommandOptions, dbOptions?: DbOptions): Promise<Document>;
|
|
5
|
+
dropDatabase(database: string, options: DropDatabaseOptions, dbOptions?: DbOptions): Promise<Document>;
|
|
6
|
+
bulkWrite(database: string, collection: string, requests: AnyBulkWriteOperation[], options: BulkWriteOptions, dbOptions?: DbOptions): Promise<BulkWriteResult>;
|
|
7
|
+
deleteMany(database: string, collection: string, filter: Document, options: DeleteOptions, dbOptions?: DbOptions): Promise<DeleteResult>;
|
|
8
|
+
deleteOne(database: string, collection: string, filter: Document, options: DeleteOptions, dbOptions?: DbOptions): Promise<DeleteResult>;
|
|
9
|
+
findOneAndDelete(database: string, collection: string, filter: Document, options: FindOneAndDeleteOptions, dbOptions?: DbOptions): Promise<Document>;
|
|
10
|
+
findOneAndReplace(database: string, collection: string, filter: Document, replacement: Document, options: FindOneAndReplaceOptions, dbOptions?: DbOptions): Promise<Document>;
|
|
11
|
+
findOneAndUpdate(database: string, collection: string, filter: Document, update: Document | Document[], options: FindOneAndUpdateOptions, dbOptions?: DbOptions): Promise<Document>;
|
|
12
|
+
insertMany(database: string, collection: string, docs: Document[], options: BulkWriteOptions, dbOptions?: DbOptions): Promise<InsertManyResult>;
|
|
13
|
+
insertOne(database: string, collection: string, doc: Document, options: InsertOneOptions, dbOptions?: DbOptions): Promise<InsertOneResult>;
|
|
14
|
+
replaceOne(database: string, collection: string, filter: Document, replacement: Document, options?: ReplaceOptions, dbOptions?: DbOptions): Promise<UpdateResult>;
|
|
15
|
+
updateMany(database: string, collection: string, filter: Document, update: Document, options?: UpdateOptions, dbOptions?: DbOptions): Promise<UpdateResult>;
|
|
16
|
+
updateOne(database: string, collection: string, filter: Document, update: Document, options?: UpdateOptions, dbOptions?: DbOptions): Promise<UpdateResult>;
|
|
17
|
+
remove(database: string, collection: string, query: Document, options?: DeleteOptions, dbOptions?: DbOptions): Promise<DeleteResult>;
|
|
18
|
+
createIndexes(database: string, collection: string, indexSpecs: Document[], options?: CreateIndexesOptions, dbOptions?: DbOptions): Promise<string[]>;
|
|
19
|
+
dropCollection(database: string, collection: string, options: DropCollectionOptions, dbOptions?: DbOptions): Promise<boolean>;
|
|
20
|
+
renameCollection(database: string, oldName: string, newName: string, options?: RenameOptions, dbOptions?: DbOptions): Promise<Collection>;
|
|
21
|
+
initializeBulkOp(dbName: string, collName: string, ordered: boolean, options?: BulkWriteOptions, dbOptions?: DbOptions): Promise<OrderedBulkOperation | UnorderedBulkOperation>;
|
|
22
|
+
}
|
package/lib/writable.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writable.js","sourceRoot":"","sources":["../src/writable.ts"],"names":[],"mappings":""}
|