1
+ import type { UUID } from 'bson' ;
1
2
import Denque = require( 'denque' ) ;
2
3
import type { Readable } from 'stream' ;
3
4
@@ -50,7 +51,8 @@ const CHANGE_STREAM_OPTIONS = [
50
51
'resumeAfter' ,
51
52
'startAfter' ,
52
53
'startAtOperationTime' ,
53
- 'fullDocument'
54
+ 'fullDocument' ,
55
+ 'showExpandedEvents'
54
56
] as const ;
55
57
56
58
const CURSOR_OPTIONS = [
@@ -155,6 +157,20 @@ export interface ChangeStreamOptions extends AggregateOptions {
155
157
* @see https://docs.mongodb.com/manual/reference/command/aggregate
156
158
*/
157
159
batchSize ?: number ;
160
+
161
+ /**
162
+ * When enabled, configures the change stream to include extra change events.
163
+ *
164
+ * - createIndex
165
+ * - dropIndex
166
+ * - collMod
167
+ * - create
168
+ * - shardCollection
169
+ * - reshardCollection
170
+ * - refineCollectionShardKey
171
+ * - chunkMigrated
172
+ */
173
+ showExpandedEvents ?: boolean ;
158
174
}
159
175
160
176
/** @public */
@@ -291,6 +307,25 @@ export interface ChangeStreamRenameDocument extends ChangeStreamDocumentCommon {
291
307
to : { db : string ; coll : string } ;
292
308
/** The "from" namespace that the rename occured on */
293
309
ns : ChangeStreamNameSpace ;
310
+ /**
311
+ * An operation description representing the changes in a `rename` event.
312
+ *
313
+ * Only present when the `showExpandedEvents` flag is enabled.
314
+ *
315
+ * @since 6.0.0
316
+ */
317
+ operationDescription ?: {
318
+ /**
319
+ * Contains two fields: "db" and "coll" containing the database and
320
+ * collection name in which the change happened.
321
+ */
322
+ to ?: { db : string ; coll : string } ;
323
+
324
+ /**
325
+ * The uuid of the target collection that was dropped.
326
+ */
327
+ dropTarget ?: UUID ; // TODO - confirm that this value is optional
328
+ } ;
294
329
}
295
330
296
331
/**
@@ -313,6 +348,45 @@ export interface ChangeStreamInvalidateDocument extends ChangeStreamDocumentComm
313
348
operationType : 'invalidate' ;
314
349
}
315
350
351
+ /**
352
+ * Only present when the `showExpandedEvents` flag is enabled.
353
+ * @public
354
+ * @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
355
+ */
356
+ export interface ChangeStreamCreateIndexDocument extends ChangeStreamDocumentCommon {
357
+ /** Describes the type of operation represented in this change notification */
358
+ operationType : 'createIndexes' ;
359
+ }
360
+
361
+ /**
362
+ * Only present when the `showExpandedEvents` flag is enabled.
363
+ * @public
364
+ * @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
365
+ */
366
+ export interface ChangeStreamDropIndexDocument extends ChangeStreamDocumentCommon {
367
+ /** Describes the type of operation represented in this change notification */
368
+ operationType : 'dropIndexes' ;
369
+ }
370
+
371
+ /**
372
+ * Only present when the `showExpandedEvents` flag is enabled.
373
+ * @public
374
+ * @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
375
+ */
376
+ export interface ChangeStreamCollModDocument extends ChangeStreamDocumentCommon {
377
+ /** Describes the type of operation represented in this change notification */
378
+ operationType : 'modify' ;
379
+ }
380
+
381
+ /**
382
+ * @public
383
+ * @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
384
+ */
385
+ export interface ChangeStreamCreateDocument extends ChangeStreamDocumentCommon {
386
+ /** Describes the type of operation represented in this change notification */
387
+ operationType : 'create' ;
388
+ }
389
+
316
390
/** @public */
317
391
export type ChangeStreamDocument < TSchema extends Document = Document > =
318
392
| ChangeStreamInsertDocument < TSchema >
@@ -322,7 +396,11 @@ export type ChangeStreamDocument<TSchema extends Document = Document> =
322
396
| ChangeStreamDropDocument
323
397
| ChangeStreamRenameDocument
324
398
| ChangeStreamDropDatabaseDocument
325
- | ChangeStreamInvalidateDocument ;
399
+ | ChangeStreamInvalidateDocument
400
+ | ChangeStreamCreateIndexDocument
401
+ | ChangeStreamCreateDocument
402
+ | ChangeStreamCollModDocument
403
+ | ChangeStreamDropIndexDocument ;
326
404
327
405
/** @public */
328
406
export interface UpdateDescription < TSchema extends Document = Document > {
0 commit comments