@mongosh/shell-api 2.1.0 → 2.1.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.
- package/lib/abstract-cursor.js +176 -132
- package/lib/abstract-cursor.js.map +1 -1
- package/lib/aggregate-or-find-cursor.js +102 -51
- package/lib/aggregate-or-find-cursor.js.map +1 -1
- package/lib/aggregation-cursor.js +59 -13
- package/lib/aggregation-cursor.js.map +1 -1
- package/lib/bulk.js +248 -197
- package/lib/bulk.js.map +1 -1
- package/lib/change-stream-cursor.js +145 -101
- package/lib/change-stream-cursor.js.map +1 -1
- package/lib/collection.d.ts +2 -1
- package/lib/collection.js +1185 -1245
- package/lib/collection.js.map +1 -1
- package/lib/cursor.js +238 -203
- package/lib/cursor.js.map +1 -1
- package/lib/database.js +1180 -1206
- package/lib/database.js.map +1 -1
- package/lib/dbquery.js +68 -22
- package/lib/dbquery.js.map +1 -1
- package/lib/decorators.d.ts +39 -13
- package/lib/decorators.js +34 -34
- package/lib/decorators.js.map +1 -1
- package/lib/explainable-cursor.js +66 -20
- package/lib/explainable-cursor.js.map +1 -1
- package/lib/explainable.js +214 -179
- package/lib/explainable.js.map +1 -1
- package/lib/field-level-encryption.js +286 -235
- package/lib/field-level-encryption.js.map +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/interruptor.js.map +1 -1
- package/lib/log-entry.js.map +1 -1
- package/lib/mongo-errors.js.map +1 -1
- package/lib/mongo.d.ts +1 -1
- package/lib/mongo.js +582 -547
- package/lib/mongo.js.map +1 -1
- package/lib/plan-cache.js +108 -64
- package/lib/plan-cache.js.map +1 -1
- package/lib/replica-set.js +290 -277
- package/lib/replica-set.js.map +1 -1
- package/lib/result.js +228 -91
- package/lib/result.js.map +1 -1
- package/lib/run-command-cursor.js +59 -13
- package/lib/run-command-cursor.js.map +1 -1
- package/lib/session.js +123 -76
- package/lib/session.js.map +1 -1
- package/lib/shard.js +507 -514
- package/lib/shard.js.map +1 -1
- package/lib/shell-api.d.ts +1 -0
- package/lib/shell-api.js +313 -260
- package/lib/shell-api.js.map +1 -1
- package/lib/shell-bson.js.map +1 -1
- package/lib/shell-instance-state.js.map +1 -1
- package/lib/stream-processor.js +139 -92
- package/lib/stream-processor.js.map +1 -1
- package/lib/streams.js +158 -110
- package/lib/streams.js.map +1 -1
- package/package.json +8 -8
package/lib/session.js
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
7
39
|
};
|
|
8
40
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -14,78 +46,93 @@ const enums_1 = require("./enums");
|
|
|
14
46
|
const database_1 = __importDefault(require("./database"));
|
|
15
47
|
const errors_1 = require("@mongosh/errors");
|
|
16
48
|
const helpers_1 = require("./helpers");
|
|
17
|
-
let Session =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
let Session = (() => {
|
|
50
|
+
let _classDecorators = [decorators_1.shellApiClassDefault, (0, decorators_1.classPlatforms)(['CLI'])];
|
|
51
|
+
let _classDescriptor;
|
|
52
|
+
let _classExtraInitializers = [];
|
|
53
|
+
let _classThis;
|
|
54
|
+
let _classSuper = decorators_1.ShellApiWithMongoClass;
|
|
55
|
+
let _instanceExtraInitializers = [];
|
|
56
|
+
let _endSession_decorators;
|
|
57
|
+
let _commitTransaction_decorators;
|
|
58
|
+
let _abortTransaction_decorators;
|
|
59
|
+
let _withTransaction_decorators;
|
|
60
|
+
var Session = _classThis = class extends _classSuper {
|
|
61
|
+
constructor(mongo, options, session) {
|
|
62
|
+
super();
|
|
63
|
+
this.id = (__runInitializers(this, _instanceExtraInitializers), void 0);
|
|
64
|
+
this._session = session;
|
|
65
|
+
this._options = options;
|
|
66
|
+
this._mongo = mongo;
|
|
67
|
+
this._databases = {};
|
|
68
|
+
this.id = session.id;
|
|
33
69
|
}
|
|
34
|
-
|
|
35
|
-
this.
|
|
70
|
+
[enums_1.asPrintable]() {
|
|
71
|
+
return this._session.id;
|
|
36
72
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
]
|
|
73
|
+
getDatabase(name) {
|
|
74
|
+
(0, helpers_1.assertArgsDefinedType)([name], ['string'], 'Session.getDatabase');
|
|
75
|
+
if (!(0, helpers_1.isValidDatabaseName)(name)) {
|
|
76
|
+
throw new errors_1.MongoshInvalidInputError(`Invalid database name: ${name}`, errors_1.CommonErrors.InvalidArgument);
|
|
77
|
+
}
|
|
78
|
+
if (!(name in this._databases)) {
|
|
79
|
+
this._databases[name] = new database_1.default(this._mongo, name, this);
|
|
80
|
+
}
|
|
81
|
+
return this._databases[name];
|
|
82
|
+
}
|
|
83
|
+
advanceOperationTime(ts) {
|
|
84
|
+
this._session.advanceOperationTime(ts);
|
|
85
|
+
}
|
|
86
|
+
advanceClusterTime(clusterTime) {
|
|
87
|
+
this._session.advanceClusterTime(clusterTime);
|
|
88
|
+
}
|
|
89
|
+
async endSession() {
|
|
90
|
+
return await this._session.endSession();
|
|
91
|
+
}
|
|
92
|
+
hasEnded() {
|
|
93
|
+
return this._session.hasEnded;
|
|
94
|
+
}
|
|
95
|
+
getClusterTime() {
|
|
96
|
+
return this._session.clusterTime;
|
|
97
|
+
}
|
|
98
|
+
getOperationTime() {
|
|
99
|
+
return this._session.operationTime;
|
|
100
|
+
}
|
|
101
|
+
getOptions() {
|
|
102
|
+
return this._options;
|
|
103
|
+
}
|
|
104
|
+
startTransaction(options = {}) {
|
|
105
|
+
return this._session.startTransaction(options);
|
|
106
|
+
}
|
|
107
|
+
async commitTransaction() {
|
|
108
|
+
await this._session.commitTransaction();
|
|
109
|
+
}
|
|
110
|
+
async abortTransaction() {
|
|
111
|
+
await this._session.abortTransaction();
|
|
112
|
+
}
|
|
113
|
+
async withTransaction(fn, options = {}) {
|
|
114
|
+
(0, helpers_1.assertArgsDefinedType)([fn, options], ['function', [undefined, 'object']]);
|
|
115
|
+
return await this._session.withTransaction(async () => await fn(), options);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
__setFunctionName(_classThis, "Session");
|
|
119
|
+
(() => {
|
|
120
|
+
var _a;
|
|
121
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
122
|
+
_endSession_decorators = [decorators_1.returnsPromise];
|
|
123
|
+
_commitTransaction_decorators = [decorators_1.returnsPromise];
|
|
124
|
+
_abortTransaction_decorators = [decorators_1.returnsPromise];
|
|
125
|
+
_withTransaction_decorators = [decorators_1.returnsPromise];
|
|
126
|
+
__esDecorate(_classThis, null, _endSession_decorators, { kind: "method", name: "endSession", static: false, private: false, access: { has: obj => "endSession" in obj, get: obj => obj.endSession }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
127
|
+
__esDecorate(_classThis, null, _commitTransaction_decorators, { kind: "method", name: "commitTransaction", static: false, private: false, access: { has: obj => "commitTransaction" in obj, get: obj => obj.commitTransaction }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
128
|
+
__esDecorate(_classThis, null, _abortTransaction_decorators, { kind: "method", name: "abortTransaction", static: false, private: false, access: { has: obj => "abortTransaction" in obj, get: obj => obj.abortTransaction }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
129
|
+
__esDecorate(_classThis, null, _withTransaction_decorators, { kind: "method", name: "withTransaction", static: false, private: false, access: { has: obj => "withTransaction" in obj, get: obj => obj.withTransaction }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
130
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
131
|
+
Session = _classThis = _classDescriptor.value;
|
|
132
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
133
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
134
|
+
})();
|
|
135
|
+
return Session = _classThis;
|
|
136
|
+
})();
|
|
90
137
|
exports.default = Session;
|
|
91
138
|
//# sourceMappingURL=session.js.map
|
package/lib/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAKsB;AAStB,mCAAsC;AAEtC,0DAAkC;AAClC,4CAAyE;AACzE,uCAAuE;;4BAEtE,iCAAoB,EACpB,IAAA,2BAAc,EAAC,CAAC,KAAK,CAAC,CAAC;;;;sBACa,mCAAsB;;;;;;oCAA9B,SAAQ,WAAsB;QAOzD,YACE,KAAY,EACZ,OAA6B,EAC7B,OAAsB;YAEtB,KAAK,EAAE,CAAC;YAXH,OAAE,iEAA8B;YAYrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YACxB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACpB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;YACrB,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;QACvB,CAAC;QAKD,CAAC,mBAAW,CAAC;YACX,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,CAAC;QAED,WAAW,CAAC,IAAY;YACtB,IAAA,+BAAqB,EAAC,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC,CAAC;YAEjE,IAAI,CAAC,IAAA,6BAAmB,EAAC,IAAI,CAAC,EAAE,CAAC;gBAC/B,MAAM,IAAI,iCAAwB,CAChC,0BAA0B,IAAI,EAAE,EAChC,qBAAY,CAAC,eAAe,CAC7B,CAAC;YACJ,CAAC;YAED,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC/B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,kBAAQ,CAAC,IAA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