@mongosh/shell-api 3.12.0 → 3.15.0

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.
@@ -3190,6 +3190,13 @@ declare class Collection<M extends GenericServerSideSchema = GenericServerSideSc
3190
3190
  */
3191
3191
  getShardDistribution(): CommandResult<GetShardDistributionResult>;
3192
3192
  /*
3193
+ Returns a document containing the shards where this collection is located as well as whether the collection itself is sharded.
3194
+ */
3195
+ getShardLocation(): {
3196
+ shards: string[];
3197
+ sharded: boolean;
3198
+ };
3199
+ /*
3193
3200
  Opens a change stream cursor on the collection
3194
3201
  */
3195
3202
  watch(pipeline?: Document_2[] | ChangeStreamOptions, options?: ChangeStreamOptions): ChangeStreamCursor;
@@ -4524,23 +4531,23 @@ declare class Cursor extends AggregateOrFindCursor<ServiceProviderFindCursor> {
4524
4531
  /*
4525
4532
  Adds OP_QUERY wire protocol flags, such as the tailable flag, to change the behavior of queries. Accepts: DBQuery.Option fields tailable, slaveOk, noTimeout, awaitData, exhaust, partial.
4526
4533
  */
4527
- addOption(optionFlagNumber: number): Cursor;
4534
+ addOption(optionFlagNumber: number): this;
4528
4535
  /*
4529
4536
  Sets the 'allowDiskUse' option. If no argument is passed, the default is true.
4530
4537
  */
4531
- allowDiskUse(allow?: boolean): Cursor;
4538
+ allowDiskUse(allow?: boolean): this;
4532
4539
  /*
4533
4540
  Sets the 'partial' option to true.
4534
4541
  */
4535
- allowPartialResults(): Cursor;
4542
+ allowPartialResults(): this;
4536
4543
  /*
4537
4544
  Specifies the collation for the cursor returned by the db.collection.find(). To use, append to the db.collection.find().
4538
4545
  */
4539
- collation(spec: CollationOptions): Cursor;
4546
+ collation(spec: CollationOptions): this;
4540
4547
  /*
4541
4548
  Adds a comment field to the query.
4542
4549
  */
4543
- comment(cmt: string): Cursor;
4550
+ comment(cmt: string): this;
4544
4551
  /*
4545
4552
  Counts the number of documents referenced by a cursor.
4546
4553
  */
@@ -4552,23 +4559,23 @@ declare class Cursor extends AggregateOrFindCursor<ServiceProviderFindCursor> {
4552
4559
  /*
4553
4560
  Call this method on a query to override MongoDB’s default index selection and query optimization process. Use db.collection.getIndexes() to return the list of current indexes on a collection.
4554
4561
  */
4555
- hint(index: string): Cursor;
4562
+ hint(index: string): this;
4556
4563
  /*
4557
4564
  Use the limit() method on a cursor to specify the maximum number of documents the cursor will return.
4558
4565
  */
4559
- limit(value: number): Cursor;
4566
+ limit(value: number): this;
4560
4567
  /*
4561
4568
  Specifies the exclusive upper bound for a specific index in order to constrain the results of find(). max() provides a way to specify an upper bound on compound key indexes.
4562
4569
  */
4563
- max(indexBounds: Document_2): Cursor;
4570
+ max(indexBounds: Document_2): this;
4564
4571
  /*
4565
4572
  Set a maxAwaitTimeMS on a tailing cursor query to allow to customize the timeout value for the option awaitData (Only supported on MongoDB 3.2 or higher, ignored otherwise)
4566
4573
  */
4567
- maxAwaitTimeMS(value: number): Cursor;
4574
+ maxAwaitTimeMS(value: number): this;
4568
4575
  /*
4569
4576
  Specifies the inclusive lower bound for a specific index in order to constrain the results of find(). min() provides a way to specify lower bounds on compound key indexes.
4570
4577
  */
4571
- min(indexBounds: Document_2): Cursor;
4578
+ min(indexBounds: Document_2): this;
4572
4579
  /*
4573
4580
  The next document in the cursor returned by the db.collection.find() method. NOTE: if the cursor is tailable with awaitData then hasNext will block until a document is returned. To check if a document is in the cursor's batch without waiting, use tryNext instead
4574
4581
  */
@@ -4576,19 +4583,19 @@ declare class Cursor extends AggregateOrFindCursor<ServiceProviderFindCursor> {
4576
4583
  /*
4577
4584
  Instructs the server to avoid closing a cursor automatically after a period of inactivity.
4578
4585
  */
4579
- noCursorTimeout(): Cursor;
4586
+ noCursorTimeout(): this;
4580
4587
  /*
4581
4588
  Sets oplogReplay cursor flag to true.
4582
4589
  */
4583
- oplogReplay(): Cursor;
4590
+ oplogReplay(): this;
4584
4591
  /*
4585
4592
  Append readPref() to a cursor to control how the client routes the query to members of the replica set.
4586
4593
  */
4587
- readPref(mode: ReadPreferenceLike, tagSet?: TagSet[], hedgeOptions?: HedgeOptions): Cursor;
4594
+ readPref(mode: ReadPreferenceLike, tagSet?: TagSet[], hedgeOptions?: HedgeOptions): this;
4588
4595
  /*
4589
4596
  Modifies the cursor to return index keys rather than the documents.
4590
4597
  */
4591
- returnKey(enabled: boolean): Cursor;
4598
+ returnKey(enabled: boolean): this;
4592
4599
  /*
4593
4600
  A count of the number of documents that match the db.collection.find() query after applying any cursor.skip() and cursor.limit() methods.
4594
4601
  */
@@ -4598,7 +4605,7 @@ declare class Cursor extends AggregateOrFindCursor<ServiceProviderFindCursor> {
4598
4605
  */
4599
4606
  tailable(opts?: {
4600
4607
  awaitData: boolean;
4601
- }): Cursor;
4608
+ }): this;
4602
4609
  /*
4603
4610
  deprecated, non-functional
4604
4611
  */
@@ -4606,11 +4613,11 @@ declare class Cursor extends AggregateOrFindCursor<ServiceProviderFindCursor> {
4606
4613
  /*
4607
4614
  Modifies the output of a query by adding a field $recordId to matching documents. $recordId is the internal key which uniquely identifies a document in a collection.
4608
4615
  */
4609
- showRecordId(): Cursor;
4616
+ showRecordId(): this;
4610
4617
  /*
4611
4618
  Specify a read concern for the db.collection.find() method.
4612
4619
  */
4613
- readConcern(level: ReadConcernLevel): Cursor;
4620
+ readConcern(level: ReadConcernLevel): this;
4614
4621
  }
4615
4622
 
4616
4623
  /** @public */
@@ -5633,6 +5640,7 @@ declare class ExplainableCursor_2 extends Cursor {
5633
5640
  _explained: any;
5634
5641
  constructor(mongo: Mongo, cursor: Cursor, verbosity: ExplainVerbosityLike);
5635
5642
  [asPrintable](): Promise<any>;
5643
+ finish(): Promise<any>;
5636
5644
  }
5637
5645
 
5638
5646
  /** @public */
@@ -7294,6 +7302,7 @@ declare interface MongoDBOIDCLogEventsMap {
7294
7302
  }) => void;
7295
7303
  'mongodb-oidc-plugin:state-updated': (event: {
7296
7304
  updateId: number;
7305
+ tokenSetId: string;
7297
7306
  timerDuration: number | undefined;
7298
7307
  }) => void;
7299
7308
  'mongodb-oidc-plugin:local-redirect-accessed': (event: {
@@ -7347,10 +7356,14 @@ declare interface MongoDBOIDCLogEventsMap {
7347
7356
  'mongodb-oidc-plugin:open-browser-complete': () => void;
7348
7357
  'mongodb-oidc-plugin:notify-device-flow': () => void;
7349
7358
  'mongodb-oidc-plugin:auth-attempt-started': (event: {
7359
+ authStateId: string;
7350
7360
  flow: string;
7351
7361
  }) => void;
7352
- 'mongodb-oidc-plugin:auth-attempt-succeeded': () => void;
7362
+ 'mongodb-oidc-plugin:auth-attempt-succeeded': (event: {
7363
+ authStateId: string;
7364
+ }) => void;
7353
7365
  'mongodb-oidc-plugin:auth-attempt-failed': (event: {
7366
+ authStateId: string;
7354
7367
  error: string;
7355
7368
  }) => void;
7356
7369
  'mongodb-oidc-plugin:refresh-skipped': (event: {
@@ -7372,12 +7385,15 @@ declare interface MongoDBOIDCLogEventsMap {
7372
7385
  refreshToken: string | null;
7373
7386
  }) => void;
7374
7387
  'mongodb-oidc-plugin:skip-auth-attempt': (event: {
7388
+ authStateId: string;
7375
7389
  reason: string;
7376
7390
  }) => void;
7377
7391
  'mongodb-oidc-plugin:auth-failed': (event: {
7392
+ authStateId: string;
7378
7393
  error: string;
7379
7394
  }) => void;
7380
7395
  'mongodb-oidc-plugin:auth-succeeded': (event: {
7396
+ authStateId: string;
7381
7397
  tokenType: string | null;
7382
7398
  refreshToken: string | null;
7383
7399
  expiresAt: string | null;
@@ -7387,6 +7403,30 @@ declare interface MongoDBOIDCLogEventsMap {
7387
7403
  idToken: string | undefined;
7388
7404
  refreshToken: string | undefined;
7389
7405
  };
7406
+ forceRefreshOrReauth: boolean;
7407
+ willRetryWithForceRefreshOrReauth: boolean;
7408
+ tokenSetId: string;
7409
+ }) => void;
7410
+ 'mongodb-oidc-plugin:request-token-started': (event: {
7411
+ authStateId: string;
7412
+ isCurrentAuthAttemptSet: boolean;
7413
+ tokenSetId: string | undefined;
7414
+ username: string | undefined;
7415
+ issuer: string;
7416
+ clientId: string;
7417
+ requestScopes: string[] | undefined;
7418
+ }) => void;
7419
+ 'mongodb-oidc-plugin:request-token-ended': (event: {
7420
+ authStateId: string;
7421
+ isCurrentAuthAttemptSet: boolean;
7422
+ tokenSetId: string | undefined;
7423
+ username: string | undefined;
7424
+ issuer: string;
7425
+ clientId: string;
7426
+ requestScopes: string[] | undefined;
7427
+ }) => void;
7428
+ 'mongodb-oidc-plugin:discarding-token-set': (event: {
7429
+ tokenSetId: string;
7390
7430
  }) => void;
7391
7431
  'mongodb-oidc-plugin:destroyed': () => void;
7392
7432
  'mongodb-oidc-plugin:missing-id-token': () => void;
package/lib/api-raw.d.ts CHANGED
@@ -2925,6 +2925,10 @@ declare class Collection<M extends GenericServerSideSchema = GenericServerSideSc
2925
2925
  getShardVersion(): Promise<Document_2>;
2926
2926
  _getShardedCollectionInfo(config: DatabaseWithSchema<M, D>, collStats: Document_2[]): Promise<Document_2>;
2927
2927
  getShardDistribution(): Promise<CommandResult<GetShardDistributionResult>>;
2928
+ getShardLocation(): Promise<{
2929
+ shards: string[];
2930
+ sharded: boolean;
2931
+ }>;
2928
2932
  watch(pipeline?: Document_2[] | ChangeStreamOptions, options?: ChangeStreamOptions): Promise<ChangeStreamCursor>;
2929
2933
  hideIndex(index: string | Document_2): Promise<Document_2>;
2930
2934
  unhideIndex(index: string | Document_2): Promise<Document_2>;
@@ -4242,30 +4246,30 @@ declare class Cursor extends AggregateOrFindCursor<ServiceProviderFindCursor> {
4242
4246
  constructor(mongo: Mongo, cursor: ServiceProviderFindCursor);
4243
4247
  toJSON(): void;
4244
4248
  private _addFlag;
4245
- addOption(optionFlagNumber: number): Cursor;
4246
- allowDiskUse(allow?: boolean): Cursor;
4247
- allowPartialResults(): Cursor;
4248
- collation(spec: CollationOptions): Cursor;
4249
- comment(cmt: string): Cursor;
4249
+ addOption(optionFlagNumber: number): this;
4250
+ allowDiskUse(allow?: boolean): this;
4251
+ allowPartialResults(): this;
4252
+ collation(spec: CollationOptions): this;
4253
+ comment(cmt: string): this;
4250
4254
  count(): Promise<number>;
4251
4255
  hasNext(): Promise<boolean>;
4252
- hint(index: string): Cursor;
4253
- limit(value: number): Cursor;
4254
- max(indexBounds: Document_2): Cursor;
4255
- maxAwaitTimeMS(value: number): Cursor;
4256
- min(indexBounds: Document_2): Cursor;
4256
+ hint(index: string): this;
4257
+ limit(value: number): this;
4258
+ max(indexBounds: Document_2): this;
4259
+ maxAwaitTimeMS(value: number): this;
4260
+ min(indexBounds: Document_2): this;
4257
4261
  next(): Promise<Document_2 | null>;
4258
- noCursorTimeout(): Cursor;
4259
- oplogReplay(): Cursor;
4260
- readPref(mode: ReadPreferenceLike, tagSet?: TagSet[], hedgeOptions?: HedgeOptions): Cursor;
4261
- returnKey(enabled: boolean): Cursor;
4262
+ noCursorTimeout(): this;
4263
+ oplogReplay(): this;
4264
+ readPref(mode: ReadPreferenceLike, tagSet?: TagSet[], hedgeOptions?: HedgeOptions): this;
4265
+ returnKey(enabled: boolean): this;
4262
4266
  size(): Promise<number>;
4263
4267
  tailable(opts?: {
4264
4268
  awaitData: boolean;
4265
- }): Cursor;
4269
+ }): this;
4266
4270
  maxScan(): void;
4267
- showRecordId(): Cursor;
4268
- readConcern(level: ReadConcernLevel): Cursor;
4271
+ showRecordId(): this;
4272
+ readConcern(level: ReadConcernLevel): this;
4269
4273
  }
4270
4274
 
4271
4275
  /** @public */
@@ -5039,6 +5043,7 @@ declare class ExplainableCursor_2 extends Cursor {
5039
5043
  _explained: any;
5040
5044
  constructor(mongo: Mongo, cursor: Cursor, verbosity: ExplainVerbosityLike);
5041
5045
  [asPrintable](): Promise<any>;
5046
+ finish(): Promise<any>;
5042
5047
  }
5043
5048
 
5044
5049
  /** @public */
@@ -6615,6 +6620,7 @@ declare interface MongoDBOIDCLogEventsMap {
6615
6620
  }) => void;
6616
6621
  'mongodb-oidc-plugin:state-updated': (event: {
6617
6622
  updateId: number;
6623
+ tokenSetId: string;
6618
6624
  timerDuration: number | undefined;
6619
6625
  }) => void;
6620
6626
  'mongodb-oidc-plugin:local-redirect-accessed': (event: {
@@ -6668,10 +6674,14 @@ declare interface MongoDBOIDCLogEventsMap {
6668
6674
  'mongodb-oidc-plugin:open-browser-complete': () => void;
6669
6675
  'mongodb-oidc-plugin:notify-device-flow': () => void;
6670
6676
  'mongodb-oidc-plugin:auth-attempt-started': (event: {
6677
+ authStateId: string;
6671
6678
  flow: string;
6672
6679
  }) => void;
6673
- 'mongodb-oidc-plugin:auth-attempt-succeeded': () => void;
6680
+ 'mongodb-oidc-plugin:auth-attempt-succeeded': (event: {
6681
+ authStateId: string;
6682
+ }) => void;
6674
6683
  'mongodb-oidc-plugin:auth-attempt-failed': (event: {
6684
+ authStateId: string;
6675
6685
  error: string;
6676
6686
  }) => void;
6677
6687
  'mongodb-oidc-plugin:refresh-skipped': (event: {
@@ -6693,12 +6703,15 @@ declare interface MongoDBOIDCLogEventsMap {
6693
6703
  refreshToken: string | null;
6694
6704
  }) => void;
6695
6705
  'mongodb-oidc-plugin:skip-auth-attempt': (event: {
6706
+ authStateId: string;
6696
6707
  reason: string;
6697
6708
  }) => void;
6698
6709
  'mongodb-oidc-plugin:auth-failed': (event: {
6710
+ authStateId: string;
6699
6711
  error: string;
6700
6712
  }) => void;
6701
6713
  'mongodb-oidc-plugin:auth-succeeded': (event: {
6714
+ authStateId: string;
6702
6715
  tokenType: string | null;
6703
6716
  refreshToken: string | null;
6704
6717
  expiresAt: string | null;
@@ -6708,6 +6721,30 @@ declare interface MongoDBOIDCLogEventsMap {
6708
6721
  idToken: string | undefined;
6709
6722
  refreshToken: string | undefined;
6710
6723
  };
6724
+ forceRefreshOrReauth: boolean;
6725
+ willRetryWithForceRefreshOrReauth: boolean;
6726
+ tokenSetId: string;
6727
+ }) => void;
6728
+ 'mongodb-oidc-plugin:request-token-started': (event: {
6729
+ authStateId: string;
6730
+ isCurrentAuthAttemptSet: boolean;
6731
+ tokenSetId: string | undefined;
6732
+ username: string | undefined;
6733
+ issuer: string;
6734
+ clientId: string;
6735
+ requestScopes: string[] | undefined;
6736
+ }) => void;
6737
+ 'mongodb-oidc-plugin:request-token-ended': (event: {
6738
+ authStateId: string;
6739
+ isCurrentAuthAttemptSet: boolean;
6740
+ tokenSetId: string | undefined;
6741
+ username: string | undefined;
6742
+ issuer: string;
6743
+ clientId: string;
6744
+ requestScopes: string[] | undefined;
6745
+ }) => void;
6746
+ 'mongodb-oidc-plugin:discarding-token-set': (event: {
6747
+ tokenSetId: string;
6711
6748
  }) => void;
6712
6749
  'mongodb-oidc-plugin:destroyed': () => void;
6713
6750
  'mongodb-oidc-plugin:missing-id-token': () => void;
@@ -92,6 +92,10 @@ export declare class Collection<M extends GenericServerSideSchema = GenericServe
92
92
  getShardVersion(): Promise<Document>;
93
93
  _getShardedCollectionInfo(config: DatabaseWithSchema<M, D>, collStats: Document[]): Promise<Document>;
94
94
  getShardDistribution(): Promise<CommandResult<GetShardDistributionResult>>;
95
+ getShardLocation(): Promise<{
96
+ shards: string[];
97
+ sharded: boolean;
98
+ }>;
95
99
  watch(pipeline?: Document[] | ChangeStreamOptions, options?: ChangeStreamOptions): Promise<ChangeStreamCursor>;
96
100
  hideIndex(index: string | Document): Promise<Document>;
97
101
  unhideIndex(index: string | Document): Promise<Document>;
package/lib/collection.js CHANGED
@@ -114,6 +114,7 @@ let Collection = (() => {
114
114
  let _validate_decorators;
115
115
  let _getShardVersion_decorators;
116
116
  let _getShardDistribution_decorators;
117
+ let _getShardLocation_decorators;
117
118
  let _watch_decorators;
118
119
  let _hideIndex_decorators;
119
120
  let _unhideIndex_decorators;
@@ -1059,6 +1060,35 @@ let Collection = (() => {
1059
1060
  result.Totals = totalValue;
1060
1061
  return new index_1.CommandResult('StatsResult', result);
1061
1062
  }
1063
+ async getShardLocation() {
1064
+ this._emitCollectionApiCall('getShardLocation', {});
1065
+ const result = await (await this._database.aggregate([
1066
+ {
1067
+ $listClusterCatalog: {
1068
+ shards: true,
1069
+ },
1070
+ },
1071
+ {
1072
+ $match: {
1073
+ ns: this.getFullName(),
1074
+ },
1075
+ },
1076
+ {
1077
+ $project: {
1078
+ _id: 0,
1079
+ shards: 1,
1080
+ sharded: 1,
1081
+ },
1082
+ },
1083
+ ])).toArray();
1084
+ if (result.length > 0) {
1085
+ return {
1086
+ shards: result[0].shards,
1087
+ sharded: result[0].sharded,
1088
+ };
1089
+ }
1090
+ throw new errors_1.MongoshRuntimeError(`Error finding location information for ${this.getFullName()}`, errors_1.CommonErrors.CommandFailed);
1091
+ }
1062
1092
  async watch(pipeline = [], options = {}) {
1063
1093
  if (!Array.isArray(pipeline)) {
1064
1094
  options = pipeline;
@@ -1244,6 +1274,7 @@ let Collection = (() => {
1244
1274
  _validate_decorators = [decorators_1.returnsPromise, (0, decorators_1.apiVersions)([])];
1245
1275
  _getShardVersion_decorators = [decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([])];
1246
1276
  _getShardDistribution_decorators = [decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([])];
1277
+ _getShardLocation_decorators = [decorators_1.returnsPromise, (0, decorators_1.topologies)([enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([]), (0, decorators_1.serverVersions)(['8.0.10', enums_1.ServerVersions.latest])];
1247
1278
  _watch_decorators = [(0, decorators_1.serverVersions)(['3.1.0', enums_1.ServerVersions.latest]), (0, decorators_1.topologies)([enums_1.Topologies.ReplSet, enums_1.Topologies.Sharded]), (0, decorators_1.apiVersions)([1]), decorators_1.returnsPromise];
1248
1279
  _hideIndex_decorators = [(0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
1249
1280
  _unhideIndex_decorators = [(0, decorators_1.serverVersions)(['4.4.0', enums_1.ServerVersions.latest]), decorators_1.returnsPromise, (0, decorators_1.apiVersions)([1])];
@@ -1310,6 +1341,7 @@ let Collection = (() => {
1310
1341
  __esDecorate(_classThis, null, _validate_decorators, { kind: "method", name: "validate", static: false, private: false, access: { has: obj => "validate" in obj, get: obj => obj.validate }, metadata: _metadata }, null, _instanceExtraInitializers);
1311
1342
  __esDecorate(_classThis, null, _getShardVersion_decorators, { kind: "method", name: "getShardVersion", static: false, private: false, access: { has: obj => "getShardVersion" in obj, get: obj => obj.getShardVersion }, metadata: _metadata }, null, _instanceExtraInitializers);
1312
1343
  __esDecorate(_classThis, null, _getShardDistribution_decorators, { kind: "method", name: "getShardDistribution", static: false, private: false, access: { has: obj => "getShardDistribution" in obj, get: obj => obj.getShardDistribution }, metadata: _metadata }, null, _instanceExtraInitializers);
1344
+ __esDecorate(_classThis, null, _getShardLocation_decorators, { kind: "method", name: "getShardLocation", static: false, private: false, access: { has: obj => "getShardLocation" in obj, get: obj => obj.getShardLocation }, metadata: _metadata }, null, _instanceExtraInitializers);
1313
1345
  __esDecorate(_classThis, null, _watch_decorators, { kind: "method", name: "watch", static: false, private: false, access: { has: obj => "watch" in obj, get: obj => obj.watch }, metadata: _metadata }, null, _instanceExtraInitializers);
1314
1346
  __esDecorate(_classThis, null, _hideIndex_decorators, { kind: "method", name: "hideIndex", static: false, private: false, access: { has: obj => "hideIndex" in obj, get: obj => obj.hideIndex }, metadata: _metadata }, null, _instanceExtraInitializers);
1315
1347
  __esDecorate(_classThis, null, _unhideIndex_decorators, { kind: "method", name: "unhideIndex", static: false, private: false, access: { has: obj => "unhideIndex" in obj, get: obj => obj.unhideIndex }, metadata: _metadata }, null, _instanceExtraInitializers);