@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
|
@@ -1,177 +1,177 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.KeyVault = exports.ClientEncryption = void 0;
|
|
10
|
-
const decorators_1 = require("./decorators");
|
|
11
|
-
const service_provider_core_1 = require("@qp-mongosh/service-provider-core");
|
|
12
|
-
const helpers_1 = require("./helpers");
|
|
13
|
-
const enums_1 = require("./enums");
|
|
14
|
-
const history_1 = require("@qp-mongosh/history");
|
|
15
|
-
const errors_1 = require("@qp-mongosh/errors");
|
|
16
|
-
let ClientEncryption = class ClientEncryption extends decorators_1.ShellApiWithMongoClass {
|
|
17
|
-
constructor(mongo) {
|
|
18
|
-
super();
|
|
19
|
-
this._mongo = mongo;
|
|
20
|
-
const fle = mongo._serviceProvider.fle;
|
|
21
|
-
if (!fle) {
|
|
22
|
-
throw new errors_1.MongoshRuntimeError('FLE API is not available');
|
|
23
|
-
}
|
|
24
|
-
const fleOptions = { ...this._mongo._fleOptions };
|
|
25
|
-
delete fleOptions.schemaMap;
|
|
26
|
-
this._libmongocrypt = new fle.ClientEncryption(mongo._serviceProvider.getRawClient(), fleOptions);
|
|
27
|
-
}
|
|
28
|
-
[enums_1.asPrintable]() {
|
|
29
|
-
return `ClientEncryption class for ${(0, history_1.redactURICredentials)(this._mongo._uri)}`;
|
|
30
|
-
}
|
|
31
|
-
async encrypt(encryptionId, value, encryptionAlgorithm) {
|
|
32
|
-
(0, helpers_1.assertArgsDefinedType)([encryptionId, value, encryptionAlgorithm], [true, true, true], 'ClientEncryption.encrypt');
|
|
33
|
-
return await this._libmongocrypt.encrypt(value, {
|
|
34
|
-
keyId: encryptionId,
|
|
35
|
-
algorithm: encryptionAlgorithm
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
async decrypt(encryptedValue) {
|
|
39
|
-
(0, helpers_1.assertArgsDefinedType)([encryptedValue], [true], 'ClientEncryption.decrypt');
|
|
40
|
-
return await this._libmongocrypt.decrypt(encryptedValue);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
__decorate([
|
|
44
|
-
decorators_1.returnsPromise
|
|
45
|
-
], ClientEncryption.prototype, "encrypt", null);
|
|
46
|
-
__decorate([
|
|
47
|
-
decorators_1.returnsPromise
|
|
48
|
-
], ClientEncryption.prototype, "decrypt", null);
|
|
49
|
-
ClientEncryption = __decorate([
|
|
50
|
-
decorators_1.shellApiClassDefault,
|
|
51
|
-
(0, decorators_1.classPlatforms)([service_provider_core_1.ReplPlatform.CLI])
|
|
52
|
-
], ClientEncryption);
|
|
53
|
-
exports.ClientEncryption = ClientEncryption;
|
|
54
|
-
let KeyVault = class KeyVault extends decorators_1.ShellApiWithMongoClass {
|
|
55
|
-
constructor(clientEncryption) {
|
|
56
|
-
super();
|
|
57
|
-
this._mongo = clientEncryption._mongo;
|
|
58
|
-
this._clientEncryption = clientEncryption;
|
|
59
|
-
if (!this._mongo._fleOptions || !this._mongo._fleOptions.keyVaultNamespace) {
|
|
60
|
-
throw new errors_1.MongoshInvalidInputError('FLE options must be passed to the Mongo object');
|
|
61
|
-
}
|
|
62
|
-
const [db, coll] = this._mongo._fleOptions.keyVaultNamespace.split('.');
|
|
63
|
-
this._keyColl = this._mongo.getDB(db).getCollection(coll);
|
|
64
|
-
}
|
|
65
|
-
[enums_1.asPrintable]() {
|
|
66
|
-
return `KeyVault class for ${(0, history_1.redactURICredentials)(this._mongo._uri)}`;
|
|
67
|
-
}
|
|
68
|
-
async createKey(kms, masterKeyOrAltNames, keyAltNames) {
|
|
69
|
-
(0, helpers_1.assertArgsDefinedType)([kms], [true], 'KeyVault.createKey');
|
|
70
|
-
if (typeof masterKeyOrAltNames === 'string') {
|
|
71
|
-
if (kms === 'local' && masterKeyOrAltNames === '') {
|
|
72
|
-
masterKeyOrAltNames = undefined;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
throw new errors_1.MongoshInvalidInputError('KeyVault.createKey does not support providing masterKey as string anymore. For AWS please use createKey("aws", { region: ..., key: ... })', errors_1.CommonErrors.Deprecated);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if (Array.isArray(masterKeyOrAltNames)) {
|
|
79
|
-
if (kms !== 'local') {
|
|
80
|
-
throw new errors_1.MongoshInvalidInputError('KeyVault.createKey requires masterKey to be given as second argument if KMS is not local', errors_1.CommonErrors.InvalidArgument);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
if (keyAltNames) {
|
|
84
|
-
throw new errors_1.MongoshInvalidInputError('KeyVault.createKey was supplied with an array for the masterKey and keyAltNames - either specify keyAltNames as second argument or set undefined for masterKey', errors_1.CommonErrors.InvalidArgument);
|
|
85
|
-
}
|
|
86
|
-
keyAltNames = masterKeyOrAltNames;
|
|
87
|
-
masterKeyOrAltNames = undefined;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
let options;
|
|
91
|
-
if (masterKeyOrAltNames) {
|
|
92
|
-
options = {
|
|
93
|
-
masterKey: masterKeyOrAltNames
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
if (keyAltNames) {
|
|
97
|
-
options = {
|
|
98
|
-
...(options !== null && options !== void 0 ? options : {}),
|
|
99
|
-
keyAltNames
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
return await this._clientEncryption._libmongocrypt.createDataKey(kms, options);
|
|
103
|
-
}
|
|
104
|
-
async getKey(keyId) {
|
|
105
|
-
(0, helpers_1.assertArgsDefinedType)([keyId], [true], 'KeyVault.getKey');
|
|
106
|
-
return this._keyColl.find({ '_id': keyId });
|
|
107
|
-
}
|
|
108
|
-
async getKeyByAltName(keyAltName) {
|
|
109
|
-
(0, helpers_1.assertArgsDefinedType)([keyAltName], ['string'], 'KeyVault.getKeyByAltName');
|
|
110
|
-
return this._keyColl.find({ 'keyAltNames': keyAltName });
|
|
111
|
-
}
|
|
112
|
-
async getKeys() {
|
|
113
|
-
return this._keyColl.find({});
|
|
114
|
-
}
|
|
115
|
-
async deleteKey(keyId) {
|
|
116
|
-
(0, helpers_1.assertArgsDefinedType)([keyId], [true], 'KeyVault.deleteKey');
|
|
117
|
-
return this._keyColl.deleteOne({ '_id': keyId });
|
|
118
|
-
}
|
|
119
|
-
async addKeyAlternateName(keyId, keyAltName) {
|
|
120
|
-
(0, helpers_1.assertArgsDefinedType)([keyId, keyAltName], [true, 'string'], 'KeyVault.addKeyAlternateName');
|
|
121
|
-
return this._keyColl.findAndModify({
|
|
122
|
-
query: { '_id': keyId },
|
|
123
|
-
update: { $push: { 'keyAltNames': keyAltName }, $currentDate: { 'updateDate': true } },
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
async removeKeyAlternateName(keyId, keyAltName) {
|
|
127
|
-
(0, helpers_1.assertArgsDefinedType)([keyId, keyAltName], [true, 'string'], 'KeyVault.removeKeyAlternateName');
|
|
128
|
-
const ret = await this._keyColl.findAndModify({
|
|
129
|
-
query: { '_id': keyId },
|
|
130
|
-
update: { $pull: { 'keyAltNames': keyAltName }, $currentDate: { 'updateDate': true } }
|
|
131
|
-
});
|
|
132
|
-
if (ret !== null && ret.keyAltNames !== undefined && ret.keyAltNames.length === 1 && ret.keyAltNames[0] === keyAltName) {
|
|
133
|
-
return this._keyColl.findAndModify({
|
|
134
|
-
query: { '_id': keyId, 'keyAltNames': undefined },
|
|
135
|
-
update: { $unset: { 'keyAltNames': '' }, $currentDate: { 'updateDate': true } }
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return ret;
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
__decorate([
|
|
142
|
-
decorators_1.returnsPromise,
|
|
143
|
-
(0, decorators_1.apiVersions)([1])
|
|
144
|
-
], KeyVault.prototype, "createKey", null);
|
|
145
|
-
__decorate([
|
|
146
|
-
(0, decorators_1.returnType)('Cursor'),
|
|
147
|
-
(0, decorators_1.apiVersions)([1]),
|
|
148
|
-
decorators_1.returnsPromise
|
|
149
|
-
], KeyVault.prototype, "getKey", null);
|
|
150
|
-
__decorate([
|
|
151
|
-
(0, decorators_1.returnType)('Cursor'),
|
|
152
|
-
(0, decorators_1.apiVersions)([1]),
|
|
153
|
-
decorators_1.returnsPromise
|
|
154
|
-
], KeyVault.prototype, "getKeyByAltName", null);
|
|
155
|
-
__decorate([
|
|
156
|
-
(0, decorators_1.returnType)('Cursor'),
|
|
157
|
-
(0, decorators_1.apiVersions)([1]),
|
|
158
|
-
decorators_1.returnsPromise
|
|
159
|
-
], KeyVault.prototype, "getKeys", null);
|
|
160
|
-
__decorate([
|
|
161
|
-
decorators_1.returnsPromise,
|
|
162
|
-
(0, decorators_1.apiVersions)([1])
|
|
163
|
-
], KeyVault.prototype, "deleteKey", null);
|
|
164
|
-
__decorate([
|
|
165
|
-
decorators_1.returnsPromise,
|
|
166
|
-
(0, decorators_1.apiVersions)([1])
|
|
167
|
-
], KeyVault.prototype, "addKeyAlternateName", null);
|
|
168
|
-
__decorate([
|
|
169
|
-
decorators_1.returnsPromise,
|
|
170
|
-
(0, decorators_1.apiVersions)([1])
|
|
171
|
-
], KeyVault.prototype, "removeKeyAlternateName", null);
|
|
172
|
-
KeyVault = __decorate([
|
|
173
|
-
decorators_1.shellApiClassDefault,
|
|
174
|
-
(0, decorators_1.classPlatforms)([service_provider_core_1.ReplPlatform.CLI])
|
|
175
|
-
], KeyVault);
|
|
176
|
-
exports.KeyVault = KeyVault;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.KeyVault = exports.ClientEncryption = void 0;
|
|
10
|
+
const decorators_1 = require("./decorators");
|
|
11
|
+
const service_provider_core_1 = require("@qp-mongosh/service-provider-core");
|
|
12
|
+
const helpers_1 = require("./helpers");
|
|
13
|
+
const enums_1 = require("./enums");
|
|
14
|
+
const history_1 = require("@qp-mongosh/history");
|
|
15
|
+
const errors_1 = require("@qp-mongosh/errors");
|
|
16
|
+
let ClientEncryption = class ClientEncryption extends decorators_1.ShellApiWithMongoClass {
|
|
17
|
+
constructor(mongo) {
|
|
18
|
+
super();
|
|
19
|
+
this._mongo = mongo;
|
|
20
|
+
const fle = mongo._serviceProvider.fle;
|
|
21
|
+
if (!fle) {
|
|
22
|
+
throw new errors_1.MongoshRuntimeError('FLE API is not available');
|
|
23
|
+
}
|
|
24
|
+
const fleOptions = { ...this._mongo._fleOptions };
|
|
25
|
+
delete fleOptions.schemaMap;
|
|
26
|
+
this._libmongocrypt = new fle.ClientEncryption(mongo._serviceProvider.getRawClient(), fleOptions);
|
|
27
|
+
}
|
|
28
|
+
[enums_1.asPrintable]() {
|
|
29
|
+
return `ClientEncryption class for ${(0, history_1.redactURICredentials)(this._mongo._uri)}`;
|
|
30
|
+
}
|
|
31
|
+
async encrypt(encryptionId, value, encryptionAlgorithm) {
|
|
32
|
+
(0, helpers_1.assertArgsDefinedType)([encryptionId, value, encryptionAlgorithm], [true, true, true], 'ClientEncryption.encrypt');
|
|
33
|
+
return await this._libmongocrypt.encrypt(value, {
|
|
34
|
+
keyId: encryptionId,
|
|
35
|
+
algorithm: encryptionAlgorithm
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async decrypt(encryptedValue) {
|
|
39
|
+
(0, helpers_1.assertArgsDefinedType)([encryptedValue], [true], 'ClientEncryption.decrypt');
|
|
40
|
+
return await this._libmongocrypt.decrypt(encryptedValue);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
__decorate([
|
|
44
|
+
decorators_1.returnsPromise
|
|
45
|
+
], ClientEncryption.prototype, "encrypt", null);
|
|
46
|
+
__decorate([
|
|
47
|
+
decorators_1.returnsPromise
|
|
48
|
+
], ClientEncryption.prototype, "decrypt", null);
|
|
49
|
+
ClientEncryption = __decorate([
|
|
50
|
+
decorators_1.shellApiClassDefault,
|
|
51
|
+
(0, decorators_1.classPlatforms)([service_provider_core_1.ReplPlatform.CLI])
|
|
52
|
+
], ClientEncryption);
|
|
53
|
+
exports.ClientEncryption = ClientEncryption;
|
|
54
|
+
let KeyVault = class KeyVault extends decorators_1.ShellApiWithMongoClass {
|
|
55
|
+
constructor(clientEncryption) {
|
|
56
|
+
super();
|
|
57
|
+
this._mongo = clientEncryption._mongo;
|
|
58
|
+
this._clientEncryption = clientEncryption;
|
|
59
|
+
if (!this._mongo._fleOptions || !this._mongo._fleOptions.keyVaultNamespace) {
|
|
60
|
+
throw new errors_1.MongoshInvalidInputError('FLE options must be passed to the Mongo object');
|
|
61
|
+
}
|
|
62
|
+
const [db, coll] = this._mongo._fleOptions.keyVaultNamespace.split('.');
|
|
63
|
+
this._keyColl = this._mongo.getDB(db).getCollection(coll);
|
|
64
|
+
}
|
|
65
|
+
[enums_1.asPrintable]() {
|
|
66
|
+
return `KeyVault class for ${(0, history_1.redactURICredentials)(this._mongo._uri)}`;
|
|
67
|
+
}
|
|
68
|
+
async createKey(kms, masterKeyOrAltNames, keyAltNames) {
|
|
69
|
+
(0, helpers_1.assertArgsDefinedType)([kms], [true], 'KeyVault.createKey');
|
|
70
|
+
if (typeof masterKeyOrAltNames === 'string') {
|
|
71
|
+
if (kms === 'local' && masterKeyOrAltNames === '') {
|
|
72
|
+
masterKeyOrAltNames = undefined;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
throw new errors_1.MongoshInvalidInputError('KeyVault.createKey does not support providing masterKey as string anymore. For AWS please use createKey("aws", { region: ..., key: ... })', errors_1.CommonErrors.Deprecated);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (Array.isArray(masterKeyOrAltNames)) {
|
|
79
|
+
if (kms !== 'local') {
|
|
80
|
+
throw new errors_1.MongoshInvalidInputError('KeyVault.createKey requires masterKey to be given as second argument if KMS is not local', errors_1.CommonErrors.InvalidArgument);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
if (keyAltNames) {
|
|
84
|
+
throw new errors_1.MongoshInvalidInputError('KeyVault.createKey was supplied with an array for the masterKey and keyAltNames - either specify keyAltNames as second argument or set undefined for masterKey', errors_1.CommonErrors.InvalidArgument);
|
|
85
|
+
}
|
|
86
|
+
keyAltNames = masterKeyOrAltNames;
|
|
87
|
+
masterKeyOrAltNames = undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
let options;
|
|
91
|
+
if (masterKeyOrAltNames) {
|
|
92
|
+
options = {
|
|
93
|
+
masterKey: masterKeyOrAltNames
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (keyAltNames) {
|
|
97
|
+
options = {
|
|
98
|
+
...(options !== null && options !== void 0 ? options : {}),
|
|
99
|
+
keyAltNames
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return await this._clientEncryption._libmongocrypt.createDataKey(kms, options);
|
|
103
|
+
}
|
|
104
|
+
async getKey(keyId) {
|
|
105
|
+
(0, helpers_1.assertArgsDefinedType)([keyId], [true], 'KeyVault.getKey');
|
|
106
|
+
return this._keyColl.find({ '_id': keyId });
|
|
107
|
+
}
|
|
108
|
+
async getKeyByAltName(keyAltName) {
|
|
109
|
+
(0, helpers_1.assertArgsDefinedType)([keyAltName], ['string'], 'KeyVault.getKeyByAltName');
|
|
110
|
+
return this._keyColl.find({ 'keyAltNames': keyAltName });
|
|
111
|
+
}
|
|
112
|
+
async getKeys() {
|
|
113
|
+
return this._keyColl.find({});
|
|
114
|
+
}
|
|
115
|
+
async deleteKey(keyId) {
|
|
116
|
+
(0, helpers_1.assertArgsDefinedType)([keyId], [true], 'KeyVault.deleteKey');
|
|
117
|
+
return this._keyColl.deleteOne({ '_id': keyId });
|
|
118
|
+
}
|
|
119
|
+
async addKeyAlternateName(keyId, keyAltName) {
|
|
120
|
+
(0, helpers_1.assertArgsDefinedType)([keyId, keyAltName], [true, 'string'], 'KeyVault.addKeyAlternateName');
|
|
121
|
+
return this._keyColl.findAndModify({
|
|
122
|
+
query: { '_id': keyId },
|
|
123
|
+
update: { $push: { 'keyAltNames': keyAltName }, $currentDate: { 'updateDate': true } },
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
async removeKeyAlternateName(keyId, keyAltName) {
|
|
127
|
+
(0, helpers_1.assertArgsDefinedType)([keyId, keyAltName], [true, 'string'], 'KeyVault.removeKeyAlternateName');
|
|
128
|
+
const ret = await this._keyColl.findAndModify({
|
|
129
|
+
query: { '_id': keyId },
|
|
130
|
+
update: { $pull: { 'keyAltNames': keyAltName }, $currentDate: { 'updateDate': true } }
|
|
131
|
+
});
|
|
132
|
+
if (ret !== null && ret.keyAltNames !== undefined && ret.keyAltNames.length === 1 && ret.keyAltNames[0] === keyAltName) {
|
|
133
|
+
return this._keyColl.findAndModify({
|
|
134
|
+
query: { '_id': keyId, 'keyAltNames': undefined },
|
|
135
|
+
update: { $unset: { 'keyAltNames': '' }, $currentDate: { 'updateDate': true } }
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return ret;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
__decorate([
|
|
142
|
+
decorators_1.returnsPromise,
|
|
143
|
+
(0, decorators_1.apiVersions)([1])
|
|
144
|
+
], KeyVault.prototype, "createKey", null);
|
|
145
|
+
__decorate([
|
|
146
|
+
(0, decorators_1.returnType)('Cursor'),
|
|
147
|
+
(0, decorators_1.apiVersions)([1]),
|
|
148
|
+
decorators_1.returnsPromise
|
|
149
|
+
], KeyVault.prototype, "getKey", null);
|
|
150
|
+
__decorate([
|
|
151
|
+
(0, decorators_1.returnType)('Cursor'),
|
|
152
|
+
(0, decorators_1.apiVersions)([1]),
|
|
153
|
+
decorators_1.returnsPromise
|
|
154
|
+
], KeyVault.prototype, "getKeyByAltName", null);
|
|
155
|
+
__decorate([
|
|
156
|
+
(0, decorators_1.returnType)('Cursor'),
|
|
157
|
+
(0, decorators_1.apiVersions)([1]),
|
|
158
|
+
decorators_1.returnsPromise
|
|
159
|
+
], KeyVault.prototype, "getKeys", null);
|
|
160
|
+
__decorate([
|
|
161
|
+
decorators_1.returnsPromise,
|
|
162
|
+
(0, decorators_1.apiVersions)([1])
|
|
163
|
+
], KeyVault.prototype, "deleteKey", null);
|
|
164
|
+
__decorate([
|
|
165
|
+
decorators_1.returnsPromise,
|
|
166
|
+
(0, decorators_1.apiVersions)([1])
|
|
167
|
+
], KeyVault.prototype, "addKeyAlternateName", null);
|
|
168
|
+
__decorate([
|
|
169
|
+
decorators_1.returnsPromise,
|
|
170
|
+
(0, decorators_1.apiVersions)([1])
|
|
171
|
+
], KeyVault.prototype, "removeKeyAlternateName", null);
|
|
172
|
+
KeyVault = __decorate([
|
|
173
|
+
decorators_1.shellApiClassDefault,
|
|
174
|
+
(0, decorators_1.classPlatforms)([service_provider_core_1.ReplPlatform.CLI])
|
|
175
|
+
], KeyVault);
|
|
176
|
+
exports.KeyVault = KeyVault;
|
|
177
177
|
//# sourceMappingURL=field-level-encryption.js.map
|
package/lib/help.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { shellApiType, asPrintable } from './enums';
|
|
2
|
-
declare type HelpPropertiesAttr = {
|
|
3
|
-
name?: string;
|
|
4
|
-
description: string;
|
|
5
|
-
};
|
|
6
|
-
export declare type HelpProperties = {
|
|
7
|
-
help: string;
|
|
8
|
-
docs?: string;
|
|
9
|
-
attr?: HelpPropertiesAttr[];
|
|
10
|
-
};
|
|
11
|
-
declare type HelpOptions = {
|
|
12
|
-
translate(key: string): string | undefined;
|
|
13
|
-
};
|
|
14
|
-
export default class Help {
|
|
15
|
-
private help;
|
|
16
|
-
private docs;
|
|
17
|
-
private attr;
|
|
18
|
-
constructor(properties: HelpProperties, options?: HelpOptions);
|
|
19
|
-
[asPrintable](): HelpProperties;
|
|
20
|
-
get [shellApiType](): string;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
1
|
+
import { shellApiType, asPrintable } from './enums';
|
|
2
|
+
declare type HelpPropertiesAttr = {
|
|
3
|
+
name?: string;
|
|
4
|
+
description: string;
|
|
5
|
+
};
|
|
6
|
+
export declare type HelpProperties = {
|
|
7
|
+
help: string;
|
|
8
|
+
docs?: string;
|
|
9
|
+
attr?: HelpPropertiesAttr[];
|
|
10
|
+
};
|
|
11
|
+
declare type HelpOptions = {
|
|
12
|
+
translate(key: string): string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export default class Help {
|
|
15
|
+
private help;
|
|
16
|
+
private docs;
|
|
17
|
+
private attr;
|
|
18
|
+
constructor(properties: HelpProperties, options?: HelpOptions);
|
|
19
|
+
[asPrintable](): HelpProperties;
|
|
20
|
+
get [shellApiType](): string;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
package/lib/help.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
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 i18n_1 = __importDefault(require("@qp-mongosh/i18n"));
|
|
7
|
-
const enums_1 = require("./enums");
|
|
8
|
-
const DEFAULT_TRANSLATE = i18n_1.default.translateApiHelp.bind(i18n_1.default);
|
|
9
|
-
class Help {
|
|
10
|
-
constructor(properties, options = { translate: DEFAULT_TRANSLATE }) {
|
|
11
|
-
this.attr = [];
|
|
12
|
-
this.help = options.translate(properties.help);
|
|
13
|
-
this.docs = options.translate(properties.docs);
|
|
14
|
-
this.attr = (properties.attr || [])
|
|
15
|
-
.map((attr) => ({
|
|
16
|
-
name: attr.name,
|
|
17
|
-
description: options.translate(attr.description),
|
|
18
|
-
})).filter(attr => attr.description);
|
|
19
|
-
}
|
|
20
|
-
[enums_1.asPrintable]() {
|
|
21
|
-
const { help, docs, attr } = this;
|
|
22
|
-
return { help, docs, attr };
|
|
23
|
-
}
|
|
24
|
-
get [enums_1.shellApiType]() { return 'Help'; }
|
|
25
|
-
}
|
|
26
|
-
exports.default = Help;
|
|
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 i18n_1 = __importDefault(require("@qp-mongosh/i18n"));
|
|
7
|
+
const enums_1 = require("./enums");
|
|
8
|
+
const DEFAULT_TRANSLATE = i18n_1.default.translateApiHelp.bind(i18n_1.default);
|
|
9
|
+
class Help {
|
|
10
|
+
constructor(properties, options = { translate: DEFAULT_TRANSLATE }) {
|
|
11
|
+
this.attr = [];
|
|
12
|
+
this.help = options.translate(properties.help);
|
|
13
|
+
this.docs = options.translate(properties.docs);
|
|
14
|
+
this.attr = (properties.attr || [])
|
|
15
|
+
.map((attr) => ({
|
|
16
|
+
name: attr.name,
|
|
17
|
+
description: options.translate(attr.description),
|
|
18
|
+
})).filter(attr => attr.description);
|
|
19
|
+
}
|
|
20
|
+
[enums_1.asPrintable]() {
|
|
21
|
+
const { help, docs, attr } = this;
|
|
22
|
+
return { help, docs, attr };
|
|
23
|
+
}
|
|
24
|
+
get [enums_1.shellApiType]() { return 'Help'; }
|
|
25
|
+
}
|
|
26
|
+
exports.default = Help;
|
|
27
27
|
//# sourceMappingURL=help.js.map
|
package/lib/helpers.d.ts
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import type { DbOptions, Document, ExplainVerbosityLike, FindOneAndDeleteOptions, FindOneAndReplaceOptions, FindOneAndUpdateOptions, DeleteOptions, MapReduceOptions, ExplainOptions } from '@qp-mongosh/service-provider-core';
|
|
2
|
-
import type Database from './database';
|
|
3
|
-
import type Collection from './collection';
|
|
4
|
-
import { CursorIterationResult } from './result';
|
|
5
|
-
import { ReplPlatform } from '@qp-mongosh/service-provider-core';
|
|
6
|
-
import { ClientSideFieldLevelEncryptionOptions } from './field-level-encryption';
|
|
7
|
-
import { AutoEncryptionOptions } from 'qp-mongodb';
|
|
8
|
-
import type { AbstractCursor } from './abstract-cursor';
|
|
9
|
-
import type ChangeStreamCursor from './change-stream-cursor';
|
|
10
|
-
import type { ShellBson } from './shell-bson';
|
|
11
|
-
export declare function adaptAggregateOptions(options?: any): {
|
|
12
|
-
aggOptions: Document;
|
|
13
|
-
dbOptions: DbOptions;
|
|
14
|
-
explain?: ExplainVerbosityLike & string;
|
|
15
|
-
};
|
|
16
|
-
export declare function validateExplainableVerbosity(verbosity: ExplainVerbosityLike): ExplainVerbosityLike & string;
|
|
17
|
-
export declare function assertArgsDefinedType(args: any[], expectedTypes: Array<true | string | Array<string | undefined>>, func?: string): void;
|
|
18
|
-
export declare function assertKeysDefined(object: any, keys: string[]): void;
|
|
19
|
-
export declare function adaptOptions(shellToCommand: any, additions: any, shellDoc: any): any;
|
|
20
|
-
export declare function processDigestPassword(username: string, passwordDigestor: 'server' | 'client', command: {
|
|
21
|
-
pwd: string;
|
|
22
|
-
}): {
|
|
23
|
-
digestPassword?: boolean;
|
|
24
|
-
pwd?: string;
|
|
25
|
-
};
|
|
26
|
-
export declare function getPrintableShardStatus(configDB: Database, verbose: boolean): Promise<Document>;
|
|
27
|
-
export declare function getConfigDB(db: Database): Promise<Database>;
|
|
28
|
-
export declare function dataFormat(bytes?: number): string;
|
|
29
|
-
export declare function tsToSeconds(x: any): number;
|
|
30
|
-
export declare function addHiddenDataProperty<T = any>(target: T, key: string | symbol, value: any): T;
|
|
31
|
-
export declare function iterate(results: CursorIterationResult, cursor: AbstractCursor<any> | ChangeStreamCursor, batchSize: number): Promise<CursorIterationResult>;
|
|
32
|
-
export declare type FindAndModifyMethodShellOptions = {
|
|
33
|
-
query: Document;
|
|
34
|
-
sort?: (FindOneAndDeleteOptions | FindOneAndReplaceOptions | FindOneAndUpdateOptions)['sort'];
|
|
35
|
-
update?: Document | Document[];
|
|
36
|
-
remove?: boolean;
|
|
37
|
-
new?: boolean;
|
|
38
|
-
fields?: Document;
|
|
39
|
-
upsert?: boolean;
|
|
40
|
-
bypassDocumentValidation?: boolean;
|
|
41
|
-
writeConcern?: Document;
|
|
42
|
-
collation?: (FindOneAndDeleteOptions | FindOneAndReplaceOptions | FindOneAndUpdateOptions)['collation'];
|
|
43
|
-
arrayFilters?: Document[];
|
|
44
|
-
explain?: ExplainVerbosityLike;
|
|
45
|
-
};
|
|
46
|
-
export declare type FindAndModifyShellOptions<BaseOptions extends FindOneAndReplaceOptions | FindOneAndUpdateOptions> = BaseOptions & {
|
|
47
|
-
returnOriginal?: boolean;
|
|
48
|
-
returnNewDocument?: boolean;
|
|
49
|
-
new?: boolean;
|
|
50
|
-
};
|
|
51
|
-
export declare function processFindAndModifyOptions<BaseOptions extends FindOneAndReplaceOptions | FindOneAndUpdateOptions>(options: FindAndModifyShellOptions<BaseOptions>): BaseOptions;
|
|
52
|
-
export declare type RemoveShellOptions = DeleteOptions & {
|
|
53
|
-
justOne?: boolean;
|
|
54
|
-
};
|
|
55
|
-
export declare function processRemoveOptions(options: boolean | RemoveShellOptions): RemoveShellOptions;
|
|
56
|
-
export declare type MapReduceShellOptions = Document | string;
|
|
57
|
-
export declare function processMapReduceOptions(optionsOrOutString: MapReduceShellOptions): MapReduceOptions;
|
|
58
|
-
export declare function setHideIndex(coll: Collection, index: string | Document, hidden: boolean): Promise<Document>;
|
|
59
|
-
export declare function assertCLI(platform: ReplPlatform, features: string): void;
|
|
60
|
-
export declare function processFLEOptions(fleOptions: ClientSideFieldLevelEncryptionOptions): AutoEncryptionOptions;
|
|
61
|
-
declare type NotAPromise = {
|
|
62
|
-
[key: string]: any;
|
|
63
|
-
then?: never;
|
|
64
|
-
};
|
|
65
|
-
export declare function maybeMarkAsExplainOutput<T extends NotAPromise>(value: T, options: ExplainOptions): T;
|
|
66
|
-
export declare function markAsExplainOutput<T extends NotAPromise>(value: T): T;
|
|
67
|
-
export declare function isValidDatabaseName(name: string): boolean;
|
|
68
|
-
export declare function isValidCollectionName(name: string): boolean;
|
|
69
|
-
export declare function shouldRunAggregationImmediately(pipeline: Document[]): boolean;
|
|
70
|
-
export declare function adjustRunCommand(cmd: Document, shellBson: ShellBson): Document;
|
|
71
|
-
export {};
|
|
1
|
+
import type { DbOptions, Document, ExplainVerbosityLike, FindOneAndDeleteOptions, FindOneAndReplaceOptions, FindOneAndUpdateOptions, DeleteOptions, MapReduceOptions, ExplainOptions } from '@qp-mongosh/service-provider-core';
|
|
2
|
+
import type Database from './database';
|
|
3
|
+
import type Collection from './collection';
|
|
4
|
+
import { CursorIterationResult } from './result';
|
|
5
|
+
import { ReplPlatform } from '@qp-mongosh/service-provider-core';
|
|
6
|
+
import { ClientSideFieldLevelEncryptionOptions } from './field-level-encryption';
|
|
7
|
+
import { AutoEncryptionOptions } from 'qp-mongodb';
|
|
8
|
+
import type { AbstractCursor } from './abstract-cursor';
|
|
9
|
+
import type ChangeStreamCursor from './change-stream-cursor';
|
|
10
|
+
import type { ShellBson } from './shell-bson';
|
|
11
|
+
export declare function adaptAggregateOptions(options?: any): {
|
|
12
|
+
aggOptions: Document;
|
|
13
|
+
dbOptions: DbOptions;
|
|
14
|
+
explain?: ExplainVerbosityLike & string;
|
|
15
|
+
};
|
|
16
|
+
export declare function validateExplainableVerbosity(verbosity: ExplainVerbosityLike): ExplainVerbosityLike & string;
|
|
17
|
+
export declare function assertArgsDefinedType(args: any[], expectedTypes: Array<true | string | Array<string | undefined>>, func?: string): void;
|
|
18
|
+
export declare function assertKeysDefined(object: any, keys: string[]): void;
|
|
19
|
+
export declare function adaptOptions(shellToCommand: any, additions: any, shellDoc: any): any;
|
|
20
|
+
export declare function processDigestPassword(username: string, passwordDigestor: 'server' | 'client', command: {
|
|
21
|
+
pwd: string;
|
|
22
|
+
}): {
|
|
23
|
+
digestPassword?: boolean;
|
|
24
|
+
pwd?: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function getPrintableShardStatus(configDB: Database, verbose: boolean): Promise<Document>;
|
|
27
|
+
export declare function getConfigDB(db: Database): Promise<Database>;
|
|
28
|
+
export declare function dataFormat(bytes?: number): string;
|
|
29
|
+
export declare function tsToSeconds(x: any): number;
|
|
30
|
+
export declare function addHiddenDataProperty<T = any>(target: T, key: string | symbol, value: any): T;
|
|
31
|
+
export declare function iterate(results: CursorIterationResult, cursor: AbstractCursor<any> | ChangeStreamCursor, batchSize: number): Promise<CursorIterationResult>;
|
|
32
|
+
export declare type FindAndModifyMethodShellOptions = {
|
|
33
|
+
query: Document;
|
|
34
|
+
sort?: (FindOneAndDeleteOptions | FindOneAndReplaceOptions | FindOneAndUpdateOptions)['sort'];
|
|
35
|
+
update?: Document | Document[];
|
|
36
|
+
remove?: boolean;
|
|
37
|
+
new?: boolean;
|
|
38
|
+
fields?: Document;
|
|
39
|
+
upsert?: boolean;
|
|
40
|
+
bypassDocumentValidation?: boolean;
|
|
41
|
+
writeConcern?: Document;
|
|
42
|
+
collation?: (FindOneAndDeleteOptions | FindOneAndReplaceOptions | FindOneAndUpdateOptions)['collation'];
|
|
43
|
+
arrayFilters?: Document[];
|
|
44
|
+
explain?: ExplainVerbosityLike;
|
|
45
|
+
};
|
|
46
|
+
export declare type FindAndModifyShellOptions<BaseOptions extends FindOneAndReplaceOptions | FindOneAndUpdateOptions> = BaseOptions & {
|
|
47
|
+
returnOriginal?: boolean;
|
|
48
|
+
returnNewDocument?: boolean;
|
|
49
|
+
new?: boolean;
|
|
50
|
+
};
|
|
51
|
+
export declare function processFindAndModifyOptions<BaseOptions extends FindOneAndReplaceOptions | FindOneAndUpdateOptions>(options: FindAndModifyShellOptions<BaseOptions>): BaseOptions;
|
|
52
|
+
export declare type RemoveShellOptions = DeleteOptions & {
|
|
53
|
+
justOne?: boolean;
|
|
54
|
+
};
|
|
55
|
+
export declare function processRemoveOptions(options: boolean | RemoveShellOptions): RemoveShellOptions;
|
|
56
|
+
export declare type MapReduceShellOptions = Document | string;
|
|
57
|
+
export declare function processMapReduceOptions(optionsOrOutString: MapReduceShellOptions): MapReduceOptions;
|
|
58
|
+
export declare function setHideIndex(coll: Collection, index: string | Document, hidden: boolean): Promise<Document>;
|
|
59
|
+
export declare function assertCLI(platform: ReplPlatform, features: string): void;
|
|
60
|
+
export declare function processFLEOptions(fleOptions: ClientSideFieldLevelEncryptionOptions): AutoEncryptionOptions;
|
|
61
|
+
declare type NotAPromise = {
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
then?: never;
|
|
64
|
+
};
|
|
65
|
+
export declare function maybeMarkAsExplainOutput<T extends NotAPromise>(value: T, options: ExplainOptions): T;
|
|
66
|
+
export declare function markAsExplainOutput<T extends NotAPromise>(value: T): T;
|
|
67
|
+
export declare function isValidDatabaseName(name: string): boolean;
|
|
68
|
+
export declare function isValidCollectionName(name: string): boolean;
|
|
69
|
+
export declare function shouldRunAggregationImmediately(pipeline: Document[]): boolean;
|
|
70
|
+
export declare function adjustRunCommand(cmd: Document, shellBson: ShellBson): Document;
|
|
71
|
+
export {};
|