1
- import type { UUID } from 'bson' ;
2
1
import Denque = require( 'denque' ) ;
3
2
import type { Readable } from 'stream' ;
4
3
import { setTimeout } from 'timers' ;
5
4
6
- import type { Document , Long , Timestamp } from './bson' ;
5
+ import type { Binary , Document , Long , Timestamp } from './bson' ;
7
6
import { Collection } from './collection' ;
8
7
import { CHANGE , CLOSE , END , ERROR , INIT , MORE , RESPONSE , RESUME_TOKEN_CHANGED } from './constants' ;
9
8
import {
@@ -240,28 +239,46 @@ export interface ChangeStreamDocumentCommon {
240
239
lsid ?: ServerSessionId ;
241
240
}
242
241
242
+ /** @public */
243
+ export interface ChangeStreamDocumentCollectionUUID {
244
+ /**
245
+ * The UUID of the collection that the operation was performed on.
246
+ *
247
+ * Only present when the `showExpandedEvents` flag is enabled.
248
+ *
249
+ * **NOTE:** collectionUUID will only be a UUID when the promoteBuffers flag is to true.
250
+ *
251
+ * @since 6.1.0
252
+ */
253
+ collectionUUID : Binary ;
254
+ }
255
+
256
+ /** @public */
257
+ export interface ChangeStreamDocumentOperationDescription {
258
+ /**
259
+ * An description of the operation.
260
+ *
261
+ * Only present when the `showExpandedEvents` flag is enabled.
262
+ *
263
+ * @since 6.1.0
264
+ */
265
+ operationDescription ?: Document ;
266
+ }
267
+
243
268
/**
244
269
* @public
245
270
* @see https://www.mongodb.com/docs/manual/reference/change-events/#insert-event
246
271
*/
247
272
export interface ChangeStreamInsertDocument < TSchema extends Document = Document >
248
273
extends ChangeStreamDocumentCommon ,
249
- ChangeStreamDocumentKey < TSchema > {
274
+ ChangeStreamDocumentKey < TSchema > ,
275
+ ChangeStreamDocumentCollectionUUID {
250
276
/** Describes the type of operation represented in this change notification */
251
277
operationType : 'insert' ;
252
278
/** This key will contain the document being inserted */
253
279
fullDocument : TSchema ;
254
280
/** Namespace the insert event occured on */
255
281
ns : ChangeStreamNameSpace ;
256
-
257
- /**
258
- * The UUID of the collection that the operation was performed on.
259
- *
260
- * Only present when the `showExpandedEvents` flag is enabled.
261
- *
262
- * @since 6.1.0
263
- */
264
- collectionUUID : UUID ;
265
282
}
266
283
267
284
/**
@@ -270,7 +287,8 @@ export interface ChangeStreamInsertDocument<TSchema extends Document = Document>
270
287
*/
271
288
export interface ChangeStreamUpdateDocument < TSchema extends Document = Document >
272
289
extends ChangeStreamDocumentCommon ,
273
- ChangeStreamDocumentKey < TSchema > {
290
+ ChangeStreamDocumentKey < TSchema > ,
291
+ ChangeStreamDocumentCollectionUUID {
274
292
/** Describes the type of operation represented in this change notification */
275
293
operationType : 'update' ;
276
294
/**
@@ -292,15 +310,6 @@ export interface ChangeStreamUpdateDocument<TSchema extends Document = Document>
292
310
* pre-image is unavailable, this will be explicitly set to null.
293
311
*/
294
312
fullDocumentBeforeChange ?: TSchema ;
295
-
296
- /**
297
- * The UUID of the collection that the operation was performed on.
298
- *
299
- * Only present when the `showExpandedEvents` flag is enabled.
300
- *
301
- * @since 6.1.0
302
- */
303
- collectionUUID : UUID ;
304
313
}
305
314
306
315
/**
@@ -332,7 +341,8 @@ export interface ChangeStreamReplaceDocument<TSchema extends Document = Document
332
341
*/
333
342
export interface ChangeStreamDeleteDocument < TSchema extends Document = Document >
334
343
extends ChangeStreamDocumentCommon ,
335
- ChangeStreamDocumentKey < TSchema > {
344
+ ChangeStreamDocumentKey < TSchema > ,
345
+ ChangeStreamDocumentCollectionUUID {
336
346
/** Describes the type of operation represented in this change notification */
337
347
operationType : 'delete' ;
338
348
/** Namespace the delete event occured on */
@@ -345,56 +355,34 @@ export interface ChangeStreamDeleteDocument<TSchema extends Document = Document>
345
355
* pre-image is unavailable, this will be explicitly set to null.
346
356
*/
347
357
fullDocumentBeforeChange ?: TSchema ;
348
-
349
- /**
350
- * The UUID of the collection that the operation was performed on.
351
- *
352
- * Only present when the `showExpandedEvents` flag is enabled.
353
- *
354
- * @since 6.1.0
355
- */
356
- collectionUUID : UUID ;
357
358
}
358
359
359
360
/**
360
361
* @public
361
362
* @see https://www.mongodb.com/docs/manual/reference/change-events/#drop-event
362
363
*/
363
- export interface ChangeStreamDropDocument extends ChangeStreamDocumentCommon {
364
+ export interface ChangeStreamDropDocument
365
+ extends ChangeStreamDocumentCommon ,
366
+ ChangeStreamDocumentCollectionUUID {
364
367
/** Describes the type of operation represented in this change notification */
365
368
operationType : 'drop' ;
366
369
/** Namespace the drop event occured on */
367
370
ns : ChangeStreamNameSpace ;
368
-
369
- /**
370
- * The UUID of the collection that the operation was performed on.
371
- *
372
- * Only present when the `showExpandedEvents` flag is enabled.
373
- *
374
- * @since 6.1.0
375
- */
376
- collectionUUID : UUID ;
377
371
}
378
372
379
373
/**
380
374
* @public
381
375
* @see https://www.mongodb.com/docs/manual/reference/change-events/#rename-event
382
376
*/
383
- export interface ChangeStreamRenameDocument extends ChangeStreamDocumentCommon {
377
+ export interface ChangeStreamRenameDocument
378
+ extends ChangeStreamDocumentCommon ,
379
+ ChangeStreamDocumentCollectionUUID {
384
380
/** Describes the type of operation represented in this change notification */
385
381
operationType : 'rename' ;
386
382
/** The new name for the `ns.coll` collection */
387
383
to : { db : string ; coll : string } ;
388
384
/** The "from" namespace that the rename occured on */
389
385
ns : ChangeStreamNameSpace ;
390
- /**
391
- * An description of the operation.
392
- *
393
- * Only present when the `showExpandedEvents` flag is enabled.
394
- *
395
- * @since 6.1.0
396
- */
397
- operationDescription ?: Document ;
398
386
}
399
387
400
388
/**
@@ -422,173 +410,84 @@ export interface ChangeStreamInvalidateDocument extends ChangeStreamDocumentComm
422
410
* @public
423
411
* @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
424
412
*/
425
- export interface ChangeStreamCreateIndexDocument extends ChangeStreamDocumentCommon {
413
+ export interface ChangeStreamCreateIndexDocument
414
+ extends ChangeStreamDocumentCommon ,
415
+ ChangeStreamDocumentCollectionUUID ,
416
+ ChangeStreamDocumentOperationDescription {
426
417
/** Describes the type of operation represented in this change notification */
427
418
operationType : 'createIndexes' ;
428
-
429
- /**
430
- * The UUID of the collection that the operation was performed on.
431
- *
432
- * Only present when the `showExpandedEvents` flag is enabled.
433
- *
434
- * @since 6.1.0
435
- */
436
- collectionUUID : UUID ;
437
-
438
- /**
439
- * An description of the operation.
440
- *
441
- * Only present when the `showExpandedEvents` flag is enabled.
442
- *
443
- * @since 6.1.0
444
- */
445
- operationDescription ?: Document ;
446
419
}
447
420
448
421
/**
449
422
* Only present when the `showExpandedEvents` flag is enabled.
450
423
* @public
451
424
* @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
452
425
*/
453
- export interface ChangeStreamDropIndexDocument extends ChangeStreamDocumentCommon {
426
+ export interface ChangeStreamDropIndexDocument
427
+ extends ChangeStreamDocumentCommon ,
428
+ ChangeStreamDocumentCollectionUUID ,
429
+ ChangeStreamDocumentOperationDescription {
454
430
/** Describes the type of operation represented in this change notification */
455
431
operationType : 'dropIndexes' ;
456
-
457
- /**
458
- * The UUID of the collection that the operation was performed on.
459
- *
460
- * Only present when the `showExpandedEvents` flag is enabled.
461
- *
462
- * @since 6.1.0
463
- */
464
- collectionUUID : UUID ;
465
-
466
- /**
467
- * An description of the operation.
468
- *
469
- * Only present when the `showExpandedEvents` flag is enabled.
470
- *
471
- * @since 6.1.0
472
- */
473
- operationDescription ?: Document ;
474
432
}
475
433
476
434
/**
477
435
* Only present when the `showExpandedEvents` flag is enabled.
478
436
* @public
479
437
* @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
480
438
*/
481
- export interface ChangeStreamCollModDocument extends ChangeStreamDocumentCommon {
439
+ export interface ChangeStreamCollModDocument
440
+ extends ChangeStreamDocumentCommon ,
441
+ ChangeStreamDocumentCollectionUUID {
482
442
/** Describes the type of operation represented in this change notification */
483
443
operationType : 'modify' ;
484
-
485
- /**
486
- * The UUID of the collection that the operation was performed on.
487
- *
488
- * Only present when the `showExpandedEvents` flag is enabled.
489
- *
490
- * @since 6.1.0
491
- */
492
- collectionUUID : UUID ;
493
444
}
494
445
495
446
/**
496
447
* @public
497
448
* @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
498
449
*/
499
- export interface ChangeStreamCreateDocument extends ChangeStreamDocumentCommon {
450
+ export interface ChangeStreamCreateDocument
451
+ extends ChangeStreamDocumentCommon ,
452
+ ChangeStreamDocumentCollectionUUID {
500
453
/** Describes the type of operation represented in this change notification */
501
454
operationType : 'create' ;
502
-
503
- /**
504
- * The UUID of the collection that the operation was performed on.
505
- *
506
- * Only present when the `showExpandedEvents` flag is enabled.
507
- *
508
- * @since 6.1.0
509
- */
510
- collectionUUID : UUID ;
511
455
}
512
456
513
457
/**
514
458
* @public
515
459
* @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
516
460
*/
517
- export interface ChangeStreamShardCollectionDocument extends ChangeStreamDocumentCommon {
461
+ export interface ChangeStreamShardCollectionDocument
462
+ extends ChangeStreamDocumentCommon ,
463
+ ChangeStreamDocumentCollectionUUID ,
464
+ ChangeStreamDocumentOperationDescription {
518
465
/** Describes the type of operation represented in this change notification */
519
466
operationType : 'shardCollection' ;
520
-
521
- /**
522
- * The UUID of the collection that the operation was performed on.
523
- *
524
- * Only present when the `showExpandedEvents` flag is enabled.
525
- *
526
- * @since 6.1.0
527
- */
528
- collectionUUID : UUID ;
529
-
530
- /**
531
- * An description of the operation.
532
- *
533
- * Only present when the `showExpandedEvents` flag is enabled.
534
- *
535
- * @since 6.1.0
536
- */
537
- operationDescription ?: Document ;
538
467
}
539
468
540
469
/**
541
470
* @public
542
471
* @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
543
472
*/
544
- export interface ChangeStreamReshardCollectionDocument extends ChangeStreamDocumentCommon {
473
+ export interface ChangeStreamReshardCollectionDocument
474
+ extends ChangeStreamDocumentCommon ,
475
+ ChangeStreamDocumentCollectionUUID ,
476
+ ChangeStreamDocumentOperationDescription {
545
477
/** Describes the type of operation represented in this change notification */
546
478
operationType : 'reshardCollection' ;
547
-
548
- /**
549
- * The UUID of the collection that the operation was performed on.
550
- *
551
- * Only present when the `showExpandedEvents` flag is enabled.
552
- *
553
- * @since 6.1.0
554
- */
555
- collectionUUID : UUID ;
556
-
557
- /**
558
- * An description of the operation.
559
- *
560
- * Only present when the `showExpandedEvents` flag is enabled.
561
- *
562
- * @since 6.1.0
563
- */
564
- operationDescription ?: Document ;
565
479
}
566
480
567
481
/**
568
482
* @public
569
483
* @see https://www.mongodb.com/docs/manual/reference/change-events/#invalidate-event
570
484
*/
571
- export interface ChangeStreamRefineCollectionShardKeyDocument extends ChangeStreamDocumentCommon {
485
+ export interface ChangeStreamRefineCollectionShardKeyDocument
486
+ extends ChangeStreamDocumentCommon ,
487
+ ChangeStreamDocumentCollectionUUID ,
488
+ ChangeStreamDocumentOperationDescription {
572
489
/** Describes the type of operation represented in this change notification */
573
490
operationType : 'refineCollectionShardKey' ;
574
-
575
- /**
576
- * The UUID of the collection that the operation was performed on.
577
- *
578
- * Only present when the `showExpandedEvents` flag is enabled.
579
- *
580
- * @since 6.1.0
581
- */
582
- collectionUUID ?: UUID ;
583
-
584
- /**
585
- * An description of the operation.
586
- *
587
- * Only present when the `showExpandedEvents` flag is enabled.
588
- *
589
- * @since 6.1.0
590
- */
591
- operationDescription ?: Document ;
592
491
}
593
492
594
493
/** @public */
0 commit comments