@qp-mongosh/shell-api 0.0.0-dev.5 → 0.0.0-dev.9
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/.eslintignore +2 -2
- package/.eslintrc.js +1 -1
- package/AUTHORS +15 -15
- package/LICENSE +200 -200
- package/bin/report-missing-help.ts +24 -24
- package/bin/report-supported-api.ts +14 -14
- package/lib/abstract-cursor.d.ts +33 -33
- package/lib/abstract-cursor.js +191 -191
- package/lib/aggregation-cursor.d.ts +6 -6
- package/lib/aggregation-cursor.js +19 -19
- package/lib/bulk.d.ts +43 -43
- package/lib/bulk.js +223 -223
- package/lib/change-stream-cursor.d.ts +28 -28
- package/lib/change-stream-cursor.js +111 -111
- package/lib/collection.d.ts +95 -95
- package/lib/collection.js +964 -964
- package/lib/cursor.d.ts +32 -32
- package/lib/cursor.js +215 -215
- package/lib/database.d.ts +116 -116
- package/lib/database.js +1223 -1223
- package/lib/dbquery.d.ts +8 -8
- package/lib/dbquery.js +28 -28
- package/lib/decorators.d.ts +73 -73
- package/lib/decorators.js +395 -395
- package/lib/enums.d.ts +28 -28
- package/lib/enums.js +33 -33
- package/lib/error-codes.d.ts +12 -12
- package/lib/error-codes.js +19 -19
- package/lib/explainable-cursor.d.ts +11 -11
- package/lib/explainable-cursor.js +31 -31
- package/lib/explainable.d.ts +32 -32
- package/lib/explainable.js +166 -166
- package/lib/field-level-encryption.d.ts +50 -50
- package/lib/field-level-encryption.js +176 -176
- package/lib/help.d.ts +22 -22
- package/lib/help.js +26 -26
- package/lib/helpers.d.ts +71 -71
- package/lib/helpers.js +588 -588
- package/lib/index.d.ts +16 -16
- package/lib/index.js +45 -45
- package/lib/interruptor.d.ts +19 -19
- package/lib/interruptor.js +62 -62
- package/lib/mongo-errors.d.ts +5 -5
- package/lib/mongo-errors.js +37 -37
- package/lib/mongo.d.ts +75 -75
- package/lib/mongo.js +476 -476
- package/lib/no-db.d.ts +5 -5
- package/lib/no-db.js +28 -28
- package/lib/plan-cache.d.ts +16 -16
- package/lib/plan-cache.js +70 -70
- package/lib/replica-set.d.ts +45 -45
- package/lib/replica-set.js +314 -314
- package/lib/result.d.ts +61 -61
- package/lib/result.js +104 -104
- package/lib/session.d.ts +25 -25
- package/lib/session.js +88 -88
- package/lib/shard.d.ts +42 -42
- package/lib/shard.js +414 -414
- package/lib/shell-api.d.ts +52 -52
- package/lib/shell-api.js +298 -298
- package/lib/shell-bson.d.ts +40 -40
- package/lib/shell-bson.js +159 -159
- package/lib/shell-instance-state.d.ts +77 -77
- package/lib/shell-instance-state.js +392 -392
- package/package.json +47 -47
- package/tsconfig.lint.json +8 -8
package/lib/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import AggregationCursor from './aggregation-cursor';
|
|
2
|
-
import Collection from './collection';
|
|
3
|
-
import Cursor from './cursor';
|
|
4
|
-
import Database, { CollectionNamesWithTypes } from './database';
|
|
5
|
-
import Explainable from './explainable';
|
|
6
|
-
import ExplainableCursor from './explainable-cursor';
|
|
7
|
-
import Help, { HelpProperties } from './help';
|
|
8
|
-
import ShellInstanceState, { EvaluationListener, ShellCliOptions, OnLoadResult, ShellPlugin } from './shell-instance-state';
|
|
9
|
-
import Shard from './shard';
|
|
10
|
-
import ReplicaSet from './replica-set';
|
|
11
|
-
import ShellApi from './shell-api';
|
|
12
|
-
import { BulkWriteResult, CommandResult, CursorIterationResult, DeleteResult, InsertManyResult, InsertOneResult, UpdateResult } from './result';
|
|
13
|
-
import Mongo from './mongo';
|
|
14
|
-
import { signatures, ShellResult, toShellResult, getShellApiType, TypeSignature } from './decorators';
|
|
15
|
-
import { Topologies, ServerVersions } from './enums';
|
|
16
|
-
export { AggregationCursor, CollectionNamesWithTypes, Cursor, CursorIterationResult, Database, Collection, Explainable, ExplainableCursor, Help, HelpProperties, ShellInstanceState, EvaluationListener, BulkWriteResult, CommandResult, DeleteResult, InsertManyResult, InsertOneResult, Mongo, Shard, ReplicaSet, UpdateResult, signatures, ShellApi, ServerVersions, Topologies, toShellResult, getShellApiType, ShellResult, ShellCliOptions, TypeSignature, OnLoadResult, ShellPlugin };
|
|
1
|
+
import AggregationCursor from './aggregation-cursor';
|
|
2
|
+
import Collection from './collection';
|
|
3
|
+
import Cursor from './cursor';
|
|
4
|
+
import Database, { CollectionNamesWithTypes } from './database';
|
|
5
|
+
import Explainable from './explainable';
|
|
6
|
+
import ExplainableCursor from './explainable-cursor';
|
|
7
|
+
import Help, { HelpProperties } from './help';
|
|
8
|
+
import ShellInstanceState, { EvaluationListener, ShellCliOptions, OnLoadResult, ShellPlugin } from './shell-instance-state';
|
|
9
|
+
import Shard from './shard';
|
|
10
|
+
import ReplicaSet from './replica-set';
|
|
11
|
+
import ShellApi from './shell-api';
|
|
12
|
+
import { BulkWriteResult, CommandResult, CursorIterationResult, DeleteResult, InsertManyResult, InsertOneResult, UpdateResult } from './result';
|
|
13
|
+
import Mongo from './mongo';
|
|
14
|
+
import { signatures, ShellResult, toShellResult, getShellApiType, TypeSignature } from './decorators';
|
|
15
|
+
import { Topologies, ServerVersions } from './enums';
|
|
16
|
+
export { AggregationCursor, CollectionNamesWithTypes, Cursor, CursorIterationResult, Database, Collection, Explainable, ExplainableCursor, Help, HelpProperties, ShellInstanceState, EvaluationListener, BulkWriteResult, CommandResult, DeleteResult, InsertManyResult, InsertOneResult, Mongo, Shard, ReplicaSet, UpdateResult, signatures, ShellApi, ServerVersions, Topologies, toShellResult, getShellApiType, ShellResult, ShellCliOptions, TypeSignature, OnLoadResult, ShellPlugin };
|
package/lib/index.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
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.getShellApiType = exports.toShellResult = exports.Topologies = exports.ServerVersions = exports.ShellApi = exports.signatures = exports.UpdateResult = exports.ReplicaSet = exports.Shard = exports.Mongo = exports.InsertOneResult = exports.InsertManyResult = exports.DeleteResult = exports.CommandResult = exports.BulkWriteResult = exports.ShellInstanceState = exports.Help = exports.ExplainableCursor = exports.Explainable = exports.Collection = exports.Database = exports.CursorIterationResult = exports.Cursor = exports.AggregationCursor = void 0;
|
|
7
|
-
const aggregation_cursor_1 = __importDefault(require("./aggregation-cursor"));
|
|
8
|
-
exports.AggregationCursor = aggregation_cursor_1.default;
|
|
9
|
-
const collection_1 = __importDefault(require("./collection"));
|
|
10
|
-
exports.Collection = collection_1.default;
|
|
11
|
-
const cursor_1 = __importDefault(require("./cursor"));
|
|
12
|
-
exports.Cursor = cursor_1.default;
|
|
13
|
-
const database_1 = __importDefault(require("./database"));
|
|
14
|
-
exports.Database = database_1.default;
|
|
15
|
-
const explainable_1 = __importDefault(require("./explainable"));
|
|
16
|
-
exports.Explainable = explainable_1.default;
|
|
17
|
-
const explainable_cursor_1 = __importDefault(require("./explainable-cursor"));
|
|
18
|
-
exports.ExplainableCursor = explainable_cursor_1.default;
|
|
19
|
-
const help_1 = __importDefault(require("./help"));
|
|
20
|
-
exports.Help = help_1.default;
|
|
21
|
-
const shell_instance_state_1 = __importDefault(require("./shell-instance-state"));
|
|
22
|
-
exports.ShellInstanceState = shell_instance_state_1.default;
|
|
23
|
-
const shard_1 = __importDefault(require("./shard"));
|
|
24
|
-
exports.Shard = shard_1.default;
|
|
25
|
-
const replica_set_1 = __importDefault(require("./replica-set"));
|
|
26
|
-
exports.ReplicaSet = replica_set_1.default;
|
|
27
|
-
const shell_api_1 = __importDefault(require("./shell-api"));
|
|
28
|
-
exports.ShellApi = shell_api_1.default;
|
|
29
|
-
const result_1 = require("./result");
|
|
30
|
-
Object.defineProperty(exports, "BulkWriteResult", { enumerable: true, get: function () { return result_1.BulkWriteResult; } });
|
|
31
|
-
Object.defineProperty(exports, "CommandResult", { enumerable: true, get: function () { return result_1.CommandResult; } });
|
|
32
|
-
Object.defineProperty(exports, "CursorIterationResult", { enumerable: true, get: function () { return result_1.CursorIterationResult; } });
|
|
33
|
-
Object.defineProperty(exports, "DeleteResult", { enumerable: true, get: function () { return result_1.DeleteResult; } });
|
|
34
|
-
Object.defineProperty(exports, "InsertManyResult", { enumerable: true, get: function () { return result_1.InsertManyResult; } });
|
|
35
|
-
Object.defineProperty(exports, "InsertOneResult", { enumerable: true, get: function () { return result_1.InsertOneResult; } });
|
|
36
|
-
Object.defineProperty(exports, "UpdateResult", { enumerable: true, get: function () { return result_1.UpdateResult; } });
|
|
37
|
-
const mongo_1 = __importDefault(require("./mongo"));
|
|
38
|
-
exports.Mongo = mongo_1.default;
|
|
39
|
-
const decorators_1 = require("./decorators");
|
|
40
|
-
Object.defineProperty(exports, "signatures", { enumerable: true, get: function () { return decorators_1.signatures; } });
|
|
41
|
-
Object.defineProperty(exports, "toShellResult", { enumerable: true, get: function () { return decorators_1.toShellResult; } });
|
|
42
|
-
Object.defineProperty(exports, "getShellApiType", { enumerable: true, get: function () { return decorators_1.getShellApiType; } });
|
|
43
|
-
const enums_1 = require("./enums");
|
|
44
|
-
Object.defineProperty(exports, "Topologies", { enumerable: true, get: function () { return enums_1.Topologies; } });
|
|
45
|
-
Object.defineProperty(exports, "ServerVersions", { enumerable: true, get: function () { return enums_1.ServerVersions; } });
|
|
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.getShellApiType = exports.toShellResult = exports.Topologies = exports.ServerVersions = exports.ShellApi = exports.signatures = exports.UpdateResult = exports.ReplicaSet = exports.Shard = exports.Mongo = exports.InsertOneResult = exports.InsertManyResult = exports.DeleteResult = exports.CommandResult = exports.BulkWriteResult = exports.ShellInstanceState = exports.Help = exports.ExplainableCursor = exports.Explainable = exports.Collection = exports.Database = exports.CursorIterationResult = exports.Cursor = exports.AggregationCursor = void 0;
|
|
7
|
+
const aggregation_cursor_1 = __importDefault(require("./aggregation-cursor"));
|
|
8
|
+
exports.AggregationCursor = aggregation_cursor_1.default;
|
|
9
|
+
const collection_1 = __importDefault(require("./collection"));
|
|
10
|
+
exports.Collection = collection_1.default;
|
|
11
|
+
const cursor_1 = __importDefault(require("./cursor"));
|
|
12
|
+
exports.Cursor = cursor_1.default;
|
|
13
|
+
const database_1 = __importDefault(require("./database"));
|
|
14
|
+
exports.Database = database_1.default;
|
|
15
|
+
const explainable_1 = __importDefault(require("./explainable"));
|
|
16
|
+
exports.Explainable = explainable_1.default;
|
|
17
|
+
const explainable_cursor_1 = __importDefault(require("./explainable-cursor"));
|
|
18
|
+
exports.ExplainableCursor = explainable_cursor_1.default;
|
|
19
|
+
const help_1 = __importDefault(require("./help"));
|
|
20
|
+
exports.Help = help_1.default;
|
|
21
|
+
const shell_instance_state_1 = __importDefault(require("./shell-instance-state"));
|
|
22
|
+
exports.ShellInstanceState = shell_instance_state_1.default;
|
|
23
|
+
const shard_1 = __importDefault(require("./shard"));
|
|
24
|
+
exports.Shard = shard_1.default;
|
|
25
|
+
const replica_set_1 = __importDefault(require("./replica-set"));
|
|
26
|
+
exports.ReplicaSet = replica_set_1.default;
|
|
27
|
+
const shell_api_1 = __importDefault(require("./shell-api"));
|
|
28
|
+
exports.ShellApi = shell_api_1.default;
|
|
29
|
+
const result_1 = require("./result");
|
|
30
|
+
Object.defineProperty(exports, "BulkWriteResult", { enumerable: true, get: function () { return result_1.BulkWriteResult; } });
|
|
31
|
+
Object.defineProperty(exports, "CommandResult", { enumerable: true, get: function () { return result_1.CommandResult; } });
|
|
32
|
+
Object.defineProperty(exports, "CursorIterationResult", { enumerable: true, get: function () { return result_1.CursorIterationResult; } });
|
|
33
|
+
Object.defineProperty(exports, "DeleteResult", { enumerable: true, get: function () { return result_1.DeleteResult; } });
|
|
34
|
+
Object.defineProperty(exports, "InsertManyResult", { enumerable: true, get: function () { return result_1.InsertManyResult; } });
|
|
35
|
+
Object.defineProperty(exports, "InsertOneResult", { enumerable: true, get: function () { return result_1.InsertOneResult; } });
|
|
36
|
+
Object.defineProperty(exports, "UpdateResult", { enumerable: true, get: function () { return result_1.UpdateResult; } });
|
|
37
|
+
const mongo_1 = __importDefault(require("./mongo"));
|
|
38
|
+
exports.Mongo = mongo_1.default;
|
|
39
|
+
const decorators_1 = require("./decorators");
|
|
40
|
+
Object.defineProperty(exports, "signatures", { enumerable: true, get: function () { return decorators_1.signatures; } });
|
|
41
|
+
Object.defineProperty(exports, "toShellResult", { enumerable: true, get: function () { return decorators_1.toShellResult; } });
|
|
42
|
+
Object.defineProperty(exports, "getShellApiType", { enumerable: true, get: function () { return decorators_1.getShellApiType; } });
|
|
43
|
+
const enums_1 = require("./enums");
|
|
44
|
+
Object.defineProperty(exports, "Topologies", { enumerable: true, get: function () { return enums_1.Topologies; } });
|
|
45
|
+
Object.defineProperty(exports, "ServerVersions", { enumerable: true, get: function () { return enums_1.ServerVersions; } });
|
|
46
46
|
//# sourceMappingURL=index.js.map
|
package/lib/interruptor.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { MongoshBaseError } from '@qp-mongosh/errors';
|
|
2
|
-
declare const kUncatchable: unique symbol;
|
|
3
|
-
export declare class MongoshInterruptedError extends MongoshBaseError {
|
|
4
|
-
[kUncatchable]: boolean;
|
|
5
|
-
constructor();
|
|
6
|
-
}
|
|
7
|
-
export declare class InterruptFlag {
|
|
8
|
-
private interrupted;
|
|
9
|
-
private onInterruptListeners;
|
|
10
|
-
isSet(): boolean;
|
|
11
|
-
checkpoint(): void;
|
|
12
|
-
asPromise(): {
|
|
13
|
-
destroy: () => void;
|
|
14
|
-
promise: Promise<never>;
|
|
15
|
-
};
|
|
16
|
-
set(): void;
|
|
17
|
-
reset(): void;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
1
|
+
import { MongoshBaseError } from '@qp-mongosh/errors';
|
|
2
|
+
declare const kUncatchable: unique symbol;
|
|
3
|
+
export declare class MongoshInterruptedError extends MongoshBaseError {
|
|
4
|
+
[kUncatchable]: boolean;
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class InterruptFlag {
|
|
8
|
+
private interrupted;
|
|
9
|
+
private onInterruptListeners;
|
|
10
|
+
isSet(): boolean;
|
|
11
|
+
checkpoint(): void;
|
|
12
|
+
asPromise(): {
|
|
13
|
+
destroy: () => void;
|
|
14
|
+
promise: Promise<never>;
|
|
15
|
+
};
|
|
16
|
+
set(): void;
|
|
17
|
+
reset(): void;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
package/lib/interruptor.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.InterruptFlag = exports.MongoshInterruptedError = void 0;
|
|
5
|
-
const errors_1 = require("@qp-mongosh/errors");
|
|
6
|
-
const kUncatchable = Symbol.for('@@mongosh.uncatchable');
|
|
7
|
-
class MongoshInterruptedError extends errors_1.MongoshBaseError {
|
|
8
|
-
constructor() {
|
|
9
|
-
super('MongoshInterruptedError', 'execution was interrupted');
|
|
10
|
-
this[_a] = true;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.MongoshInterruptedError = MongoshInterruptedError;
|
|
14
|
-
_a = kUncatchable;
|
|
15
|
-
class InterruptFlag {
|
|
16
|
-
constructor() {
|
|
17
|
-
this.interrupted = false;
|
|
18
|
-
this.onInterruptListeners = [];
|
|
19
|
-
}
|
|
20
|
-
isSet() {
|
|
21
|
-
return this.interrupted;
|
|
22
|
-
}
|
|
23
|
-
checkpoint() {
|
|
24
|
-
if (this.interrupted) {
|
|
25
|
-
throw new MongoshInterruptedError();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
asPromise() {
|
|
29
|
-
if (this.interrupted) {
|
|
30
|
-
return {
|
|
31
|
-
destroy: () => { },
|
|
32
|
-
promise: Promise.reject(new MongoshInterruptedError())
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
let destroy;
|
|
36
|
-
const promise = new Promise((_, reject) => {
|
|
37
|
-
destroy = () => {
|
|
38
|
-
const index = this.onInterruptListeners.indexOf(reject);
|
|
39
|
-
if (index !== -1) {
|
|
40
|
-
this.onInterruptListeners.splice(index, 1);
|
|
41
|
-
}
|
|
42
|
-
reject(null);
|
|
43
|
-
};
|
|
44
|
-
this.onInterruptListeners.push(reject);
|
|
45
|
-
});
|
|
46
|
-
return {
|
|
47
|
-
destroy: destroy,
|
|
48
|
-
promise
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
set() {
|
|
52
|
-
this.interrupted = true;
|
|
53
|
-
const err = new MongoshInterruptedError();
|
|
54
|
-
for (const listener of [...this.onInterruptListeners]) {
|
|
55
|
-
listener(err);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
reset() {
|
|
59
|
-
this.interrupted = false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.InterruptFlag = InterruptFlag;
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.InterruptFlag = exports.MongoshInterruptedError = void 0;
|
|
5
|
+
const errors_1 = require("@qp-mongosh/errors");
|
|
6
|
+
const kUncatchable = Symbol.for('@@mongosh.uncatchable');
|
|
7
|
+
class MongoshInterruptedError extends errors_1.MongoshBaseError {
|
|
8
|
+
constructor() {
|
|
9
|
+
super('MongoshInterruptedError', 'execution was interrupted');
|
|
10
|
+
this[_a] = true;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.MongoshInterruptedError = MongoshInterruptedError;
|
|
14
|
+
_a = kUncatchable;
|
|
15
|
+
class InterruptFlag {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.interrupted = false;
|
|
18
|
+
this.onInterruptListeners = [];
|
|
19
|
+
}
|
|
20
|
+
isSet() {
|
|
21
|
+
return this.interrupted;
|
|
22
|
+
}
|
|
23
|
+
checkpoint() {
|
|
24
|
+
if (this.interrupted) {
|
|
25
|
+
throw new MongoshInterruptedError();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
asPromise() {
|
|
29
|
+
if (this.interrupted) {
|
|
30
|
+
return {
|
|
31
|
+
destroy: () => { },
|
|
32
|
+
promise: Promise.reject(new MongoshInterruptedError())
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
let destroy;
|
|
36
|
+
const promise = new Promise((_, reject) => {
|
|
37
|
+
destroy = () => {
|
|
38
|
+
const index = this.onInterruptListeners.indexOf(reject);
|
|
39
|
+
if (index !== -1) {
|
|
40
|
+
this.onInterruptListeners.splice(index, 1);
|
|
41
|
+
}
|
|
42
|
+
reject(null);
|
|
43
|
+
};
|
|
44
|
+
this.onInterruptListeners.push(reject);
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
destroy: destroy,
|
|
48
|
+
promise
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
set() {
|
|
52
|
+
this.interrupted = true;
|
|
53
|
+
const err = new MongoshInterruptedError();
|
|
54
|
+
for (const listener of [...this.onInterruptListeners]) {
|
|
55
|
+
listener(err);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
reset() {
|
|
59
|
+
this.interrupted = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.InterruptFlag = InterruptFlag;
|
|
63
63
|
//# sourceMappingURL=interruptor.js.map
|
package/lib/mongo-errors.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ShellPlugin } from './';
|
|
2
|
-
export declare function rephraseMongoError(error: any): any;
|
|
3
|
-
export declare class TransformMongoErrorPlugin implements ShellPlugin {
|
|
4
|
-
transformError(err: Error): Error;
|
|
5
|
-
}
|
|
1
|
+
import type { ShellPlugin } from './';
|
|
2
|
+
export declare function rephraseMongoError(error: any): any;
|
|
3
|
+
export declare class TransformMongoErrorPlugin implements ShellPlugin {
|
|
4
|
+
transformError(err: Error): Error;
|
|
5
|
+
}
|
package/lib/mongo-errors.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransformMongoErrorPlugin = exports.rephraseMongoError = void 0;
|
|
4
|
-
const ERROR_REPHRASES = [
|
|
5
|
-
{
|
|
6
|
-
code: 13435,
|
|
7
|
-
replacement: 'not primary and secondaryOk=false - consider using db.getMongo().setReadPref() or readPreference in the connection string'
|
|
8
|
-
}
|
|
9
|
-
];
|
|
10
|
-
function rephraseMongoError(error) {
|
|
11
|
-
if (!isMongoError(error)) {
|
|
12
|
-
return error;
|
|
13
|
-
}
|
|
14
|
-
const e = error;
|
|
15
|
-
const message = e.message;
|
|
16
|
-
const rephrase = ERROR_REPHRASES.find(m => {
|
|
17
|
-
if (m.matchMessage) {
|
|
18
|
-
return typeof m.matchMessage === 'string' ? message.includes(m.matchMessage) : m.matchMessage.test(message);
|
|
19
|
-
}
|
|
20
|
-
return m.code !== undefined && e.code === m.code;
|
|
21
|
-
});
|
|
22
|
-
if (rephrase) {
|
|
23
|
-
e.message = typeof rephrase.replacement === 'function' ? rephrase.replacement(message) : rephrase.replacement;
|
|
24
|
-
}
|
|
25
|
-
return e;
|
|
26
|
-
}
|
|
27
|
-
exports.rephraseMongoError = rephraseMongoError;
|
|
28
|
-
function isMongoError(error) {
|
|
29
|
-
var _a, _b, _c;
|
|
30
|
-
return /^Mongo([A-Z].*)?Error$/.test((_c = (_b = (_a = Object.getPrototypeOf(error)) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : '');
|
|
31
|
-
}
|
|
32
|
-
class TransformMongoErrorPlugin {
|
|
33
|
-
transformError(err) {
|
|
34
|
-
return rephraseMongoError(err);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.TransformMongoErrorPlugin = TransformMongoErrorPlugin;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransformMongoErrorPlugin = exports.rephraseMongoError = void 0;
|
|
4
|
+
const ERROR_REPHRASES = [
|
|
5
|
+
{
|
|
6
|
+
code: 13435,
|
|
7
|
+
replacement: 'not primary and secondaryOk=false - consider using db.getMongo().setReadPref() or readPreference in the connection string'
|
|
8
|
+
}
|
|
9
|
+
];
|
|
10
|
+
function rephraseMongoError(error) {
|
|
11
|
+
if (!isMongoError(error)) {
|
|
12
|
+
return error;
|
|
13
|
+
}
|
|
14
|
+
const e = error;
|
|
15
|
+
const message = e.message;
|
|
16
|
+
const rephrase = ERROR_REPHRASES.find(m => {
|
|
17
|
+
if (m.matchMessage) {
|
|
18
|
+
return typeof m.matchMessage === 'string' ? message.includes(m.matchMessage) : m.matchMessage.test(message);
|
|
19
|
+
}
|
|
20
|
+
return m.code !== undefined && e.code === m.code;
|
|
21
|
+
});
|
|
22
|
+
if (rephrase) {
|
|
23
|
+
e.message = typeof rephrase.replacement === 'function' ? rephrase.replacement(message) : rephrase.replacement;
|
|
24
|
+
}
|
|
25
|
+
return e;
|
|
26
|
+
}
|
|
27
|
+
exports.rephraseMongoError = rephraseMongoError;
|
|
28
|
+
function isMongoError(error) {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
return /^Mongo([A-Z].*)?Error$/.test((_c = (_b = (_a = Object.getPrototypeOf(error)) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : '');
|
|
31
|
+
}
|
|
32
|
+
class TransformMongoErrorPlugin {
|
|
33
|
+
transformError(err) {
|
|
34
|
+
return rephraseMongoError(err);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.TransformMongoErrorPlugin = TransformMongoErrorPlugin;
|
|
38
38
|
//# sourceMappingURL=mongo-errors.js.map
|
package/lib/mongo.d.ts
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { ShellApiClass } from './decorators';
|
|
2
|
-
import { ChangeStreamOptions, Document, ListDatabasesOptions, ReadConcernLevel, ReadPreference, ReadPreferenceLike, ReadPreferenceMode, ServiceProvider, AutoEncryptionOptions as SPAutoEncryption, ServerApi, ServerApiVersion, WriteConcern } from '@qp-mongosh/service-provider-core';
|
|
3
|
-
import type Collection from './collection';
|
|
4
|
-
import Database from './database';
|
|
5
|
-
import ShellInstanceState from './shell-instance-state';
|
|
6
|
-
import { CommandResult } from './result';
|
|
7
|
-
import { asPrintable } from './enums';
|
|
8
|
-
import Session from './session';
|
|
9
|
-
import ChangeStreamCursor from './change-stream-cursor';
|
|
10
|
-
import { ClientSideFieldLevelEncryptionOptions, KeyVault, ClientEncryption } from './field-level-encryption';
|
|
11
|
-
export default class Mongo extends ShellApiClass {
|
|
12
|
-
private __serviceProvider;
|
|
13
|
-
_databases: Record<string, Database>;
|
|
14
|
-
_instanceState: ShellInstanceState;
|
|
15
|
-
_uri: string;
|
|
16
|
-
_fleOptions: SPAutoEncryption | undefined;
|
|
17
|
-
_apiOptions?: ServerApi;
|
|
18
|
-
private _keyVault;
|
|
19
|
-
private _clientEncryption;
|
|
20
|
-
private _readPreferenceWasExplicitlyRequested;
|
|
21
|
-
private _explicitEncryptionOnly;
|
|
22
|
-
private _cachedDatabaseNames;
|
|
23
|
-
constructor(instanceState: ShellInstanceState, uri?: string, fleOptions?: ClientSideFieldLevelEncryptionOptions, otherOptions?: {
|
|
24
|
-
api?: ServerApi | ServerApiVersion;
|
|
25
|
-
}, sp?: ServiceProvider);
|
|
26
|
-
get _serviceProvider(): ServiceProvider;
|
|
27
|
-
set _serviceProvider(sp: ServiceProvider);
|
|
28
|
-
_displayBatchSize(): Promise<number>;
|
|
29
|
-
[asPrintable](): string;
|
|
30
|
-
private _emitMongoApiCall;
|
|
31
|
-
connect(user?: string, pwd?: string): Promise<void>;
|
|
32
|
-
_getDb(name: string): Database;
|
|
33
|
-
getDB(db: string): Database;
|
|
34
|
-
getCollection(name: string): Collection;
|
|
35
|
-
use(db: string): string;
|
|
36
|
-
_listDatabases(opts?: ListDatabasesOptions): Promise<{
|
|
37
|
-
databases: {
|
|
38
|
-
name: string;
|
|
39
|
-
sizeOnDisk: number;
|
|
40
|
-
empty: boolean;
|
|
41
|
-
}[];
|
|
42
|
-
}>;
|
|
43
|
-
_getDatabaseNamesForCompletion(): Promise<string[]>;
|
|
44
|
-
getDBs(options?: ListDatabasesOptions): Promise<{
|
|
45
|
-
databases: {
|
|
46
|
-
name: string;
|
|
47
|
-
sizeOnDisk: number;
|
|
48
|
-
empty: boolean;
|
|
49
|
-
}[];
|
|
50
|
-
}>;
|
|
51
|
-
getDBNames(options?: ListDatabasesOptions): Promise<string[]>;
|
|
52
|
-
show(cmd: string, arg?: string): Promise<CommandResult>;
|
|
53
|
-
close(force: boolean): Promise<void>;
|
|
54
|
-
_suspend(): Promise<() => Promise<void>>;
|
|
55
|
-
getReadPrefMode(): ReadPreferenceMode;
|
|
56
|
-
getReadPrefTagSet(): Record<string, string>[] | undefined;
|
|
57
|
-
getReadPref(): ReadPreference;
|
|
58
|
-
_getExplicitlyRequestedReadPref(): {
|
|
59
|
-
readPreference: ReadPreference;
|
|
60
|
-
} | undefined;
|
|
61
|
-
getReadConcern(): string | undefined;
|
|
62
|
-
getWriteConcern(): WriteConcern | undefined;
|
|
63
|
-
setReadPref(mode: ReadPreferenceLike, tagSet?: Record<string, string>[], hedgeOptions?: Document): Promise<void>;
|
|
64
|
-
setReadConcern(level: ReadConcernLevel): Promise<void>;
|
|
65
|
-
setWriteConcern(concern: WriteConcern): Promise<void>;
|
|
66
|
-
setWriteConcern(wValue: string | number, wtimeoutMSValue?: number | undefined, jValue?: boolean | undefined): Promise<void>;
|
|
67
|
-
startSession(options?: Document): Session;
|
|
68
|
-
setCausalConsistency(): void;
|
|
69
|
-
isCausalConsistency(): void;
|
|
70
|
-
setSlaveOk(): void;
|
|
71
|
-
setSecondaryOk(): Promise<void>;
|
|
72
|
-
watch(pipeline?: Document[] | ChangeStreamOptions, options?: ChangeStreamOptions): Promise<ChangeStreamCursor>;
|
|
73
|
-
getClientEncryption(): ClientEncryption;
|
|
74
|
-
getKeyVault(): KeyVault;
|
|
75
|
-
}
|
|
1
|
+
import { ShellApiClass } from './decorators';
|
|
2
|
+
import { ChangeStreamOptions, Document, ListDatabasesOptions, ReadConcernLevel, ReadPreference, ReadPreferenceLike, ReadPreferenceMode, ServiceProvider, AutoEncryptionOptions as SPAutoEncryption, ServerApi, ServerApiVersion, WriteConcern } from '@qp-mongosh/service-provider-core';
|
|
3
|
+
import type Collection from './collection';
|
|
4
|
+
import Database from './database';
|
|
5
|
+
import ShellInstanceState from './shell-instance-state';
|
|
6
|
+
import { CommandResult } from './result';
|
|
7
|
+
import { asPrintable } from './enums';
|
|
8
|
+
import Session from './session';
|
|
9
|
+
import ChangeStreamCursor from './change-stream-cursor';
|
|
10
|
+
import { ClientSideFieldLevelEncryptionOptions, KeyVault, ClientEncryption } from './field-level-encryption';
|
|
11
|
+
export default class Mongo extends ShellApiClass {
|
|
12
|
+
private __serviceProvider;
|
|
13
|
+
_databases: Record<string, Database>;
|
|
14
|
+
_instanceState: ShellInstanceState;
|
|
15
|
+
_uri: string;
|
|
16
|
+
_fleOptions: SPAutoEncryption | undefined;
|
|
17
|
+
_apiOptions?: ServerApi;
|
|
18
|
+
private _keyVault;
|
|
19
|
+
private _clientEncryption;
|
|
20
|
+
private _readPreferenceWasExplicitlyRequested;
|
|
21
|
+
private _explicitEncryptionOnly;
|
|
22
|
+
private _cachedDatabaseNames;
|
|
23
|
+
constructor(instanceState: ShellInstanceState, uri?: string, fleOptions?: ClientSideFieldLevelEncryptionOptions, otherOptions?: {
|
|
24
|
+
api?: ServerApi | ServerApiVersion;
|
|
25
|
+
}, sp?: ServiceProvider);
|
|
26
|
+
get _serviceProvider(): ServiceProvider;
|
|
27
|
+
set _serviceProvider(sp: ServiceProvider);
|
|
28
|
+
_displayBatchSize(): Promise<number>;
|
|
29
|
+
[asPrintable](): string;
|
|
30
|
+
private _emitMongoApiCall;
|
|
31
|
+
connect(user?: string, pwd?: string): Promise<void>;
|
|
32
|
+
_getDb(name: string): Database;
|
|
33
|
+
getDB(db: string): Database;
|
|
34
|
+
getCollection(name: string): Collection;
|
|
35
|
+
use(db: string): string;
|
|
36
|
+
_listDatabases(opts?: ListDatabasesOptions): Promise<{
|
|
37
|
+
databases: {
|
|
38
|
+
name: string;
|
|
39
|
+
sizeOnDisk: number;
|
|
40
|
+
empty: boolean;
|
|
41
|
+
}[];
|
|
42
|
+
}>;
|
|
43
|
+
_getDatabaseNamesForCompletion(): Promise<string[]>;
|
|
44
|
+
getDBs(options?: ListDatabasesOptions): Promise<{
|
|
45
|
+
databases: {
|
|
46
|
+
name: string;
|
|
47
|
+
sizeOnDisk: number;
|
|
48
|
+
empty: boolean;
|
|
49
|
+
}[];
|
|
50
|
+
}>;
|
|
51
|
+
getDBNames(options?: ListDatabasesOptions): Promise<string[]>;
|
|
52
|
+
show(cmd: string, arg?: string): Promise<CommandResult>;
|
|
53
|
+
close(force: boolean): Promise<void>;
|
|
54
|
+
_suspend(): Promise<() => Promise<void>>;
|
|
55
|
+
getReadPrefMode(): ReadPreferenceMode;
|
|
56
|
+
getReadPrefTagSet(): Record<string, string>[] | undefined;
|
|
57
|
+
getReadPref(): ReadPreference;
|
|
58
|
+
_getExplicitlyRequestedReadPref(): {
|
|
59
|
+
readPreference: ReadPreference;
|
|
60
|
+
} | undefined;
|
|
61
|
+
getReadConcern(): string | undefined;
|
|
62
|
+
getWriteConcern(): WriteConcern | undefined;
|
|
63
|
+
setReadPref(mode: ReadPreferenceLike, tagSet?: Record<string, string>[], hedgeOptions?: Document): Promise<void>;
|
|
64
|
+
setReadConcern(level: ReadConcernLevel): Promise<void>;
|
|
65
|
+
setWriteConcern(concern: WriteConcern): Promise<void>;
|
|
66
|
+
setWriteConcern(wValue: string | number, wtimeoutMSValue?: number | undefined, jValue?: boolean | undefined): Promise<void>;
|
|
67
|
+
startSession(options?: Document): Session;
|
|
68
|
+
setCausalConsistency(): void;
|
|
69
|
+
isCausalConsistency(): void;
|
|
70
|
+
setSlaveOk(): void;
|
|
71
|
+
setSecondaryOk(): Promise<void>;
|
|
72
|
+
watch(pipeline?: Document[] | ChangeStreamOptions, options?: ChangeStreamOptions): Promise<ChangeStreamCursor>;
|
|
73
|
+
getClientEncryption(): ClientEncryption;
|
|
74
|
+
getKeyVault(): KeyVault;
|
|
75
|
+
}
|