@qp-mongosh/shell-api 0.0.0-dev.5 → 0.0.0-dev.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/.eslintignore +2 -2
  2. package/.eslintrc.js +1 -1
  3. package/AUTHORS +15 -15
  4. package/LICENSE +200 -200
  5. package/bin/report-missing-help.ts +24 -24
  6. package/bin/report-supported-api.ts +14 -14
  7. package/lib/abstract-cursor.d.ts +33 -33
  8. package/lib/abstract-cursor.js +191 -191
  9. package/lib/aggregation-cursor.d.ts +6 -6
  10. package/lib/aggregation-cursor.js +19 -19
  11. package/lib/bulk.d.ts +43 -43
  12. package/lib/bulk.js +223 -223
  13. package/lib/change-stream-cursor.d.ts +28 -28
  14. package/lib/change-stream-cursor.js +111 -111
  15. package/lib/collection.d.ts +95 -95
  16. package/lib/collection.js +964 -964
  17. package/lib/cursor.d.ts +32 -32
  18. package/lib/cursor.js +215 -215
  19. package/lib/database.d.ts +116 -116
  20. package/lib/database.js +1223 -1223
  21. package/lib/dbquery.d.ts +8 -8
  22. package/lib/dbquery.js +28 -28
  23. package/lib/decorators.d.ts +73 -73
  24. package/lib/decorators.js +395 -395
  25. package/lib/deprecation-warning.d.ts +2 -0
  26. package/lib/deprecation-warning.js +19 -0
  27. package/lib/deprecation-warning.js.map +1 -0
  28. package/lib/enums.d.ts +28 -28
  29. package/lib/enums.js +33 -33
  30. package/lib/error-codes.d.ts +12 -12
  31. package/lib/error-codes.js +19 -19
  32. package/lib/explainable-cursor.d.ts +11 -11
  33. package/lib/explainable-cursor.js +31 -31
  34. package/lib/explainable.d.ts +32 -32
  35. package/lib/explainable.js +166 -166
  36. package/lib/field-level-encryption.d.ts +50 -50
  37. package/lib/field-level-encryption.js +176 -176
  38. package/lib/help.d.ts +22 -22
  39. package/lib/help.js +26 -26
  40. package/lib/helpers.d.ts +71 -71
  41. package/lib/helpers.js +588 -588
  42. package/lib/index.d.ts +16 -16
  43. package/lib/index.js +45 -45
  44. package/lib/interruptor.d.ts +19 -19
  45. package/lib/interruptor.js +62 -62
  46. package/lib/mongo-errors.d.ts +5 -5
  47. package/lib/mongo-errors.js +37 -37
  48. package/lib/mongo.d.ts +75 -75
  49. package/lib/mongo.js +476 -476
  50. package/lib/no-db.d.ts +5 -5
  51. package/lib/no-db.js +28 -28
  52. package/lib/plan-cache.d.ts +16 -16
  53. package/lib/plan-cache.js +70 -70
  54. package/lib/replica-set.d.ts +45 -45
  55. package/lib/replica-set.js +314 -314
  56. package/lib/result.d.ts +61 -61
  57. package/lib/result.js +104 -104
  58. package/lib/session.d.ts +25 -25
  59. package/lib/session.js +88 -88
  60. package/lib/shard.d.ts +42 -42
  61. package/lib/shard.js +414 -414
  62. package/lib/shell-api.d.ts +52 -52
  63. package/lib/shell-api.js +298 -298
  64. package/lib/shell-bson.d.ts +40 -40
  65. package/lib/shell-bson.js +159 -159
  66. package/lib/shell-instance-state.d.ts +77 -77
  67. package/lib/shell-instance-state.js +392 -392
  68. package/lib/shell-internal-state.d.ts +74 -0
  69. package/lib/shell-internal-state.js +364 -0
  70. package/lib/shell-internal-state.js.map +1 -0
  71. package/package.json +47 -47
  72. 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 {};