From bd00c349cb3f851dfa9cab4d2ef30bcf00b2b9f9 Mon Sep 17 00:00:00 2001 From: Quentin Hello <9997584+qhello@users.noreply.github.com> Date: Tue, 20 May 2025 16:03:56 +0200 Subject: [PATCH 1/5] fix(NODE-6955): add missing wallTime property to ChangeStreamDocumentCommon --- src/change_stream.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/change_stream.ts b/src/change_stream.ts index 403c464edd..1db52eb617 100644 --- a/src/change_stream.ts +++ b/src/change_stream.ts @@ -183,6 +183,14 @@ export interface ChangeStreamDocumentCommon { */ clusterTime?: Timestamp; + /** + * The server date and time of the database operation. + * wallTime differs from clusterTime in that clusterTime is a timestamp taken from the oplog entry associated with the database operation event. + * The format is "YYYY-MM-DD HH:MM.SS.millis". + */ + wallTime?: string; + + /** * The transaction number. * Only present if the operation is part of a multi-document transaction. From c808ad21dddb4b743e446595d38bea1bb0b52f8e Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Tue, 27 May 2025 14:44:40 +0100 Subject: [PATCH 2/5] chore: fix lint --- src/change_stream.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/change_stream.ts b/src/change_stream.ts index 1db52eb617..b4136edd4a 100644 --- a/src/change_stream.ts +++ b/src/change_stream.ts @@ -184,13 +184,12 @@ export interface ChangeStreamDocumentCommon { clusterTime?: Timestamp; /** - * The server date and time of the database operation. + * The server date and time of the database operation. * wallTime differs from clusterTime in that clusterTime is a timestamp taken from the oplog entry associated with the database operation event. * The format is "YYYY-MM-DD HH:MM.SS.millis". */ wallTime?: string; - /** * The transaction number. * Only present if the operation is part of a multi-document transaction. From 1e9b269e9399707bc2bb5be4ac50ccede4ff5d14 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Tue, 27 May 2025 14:46:38 +0100 Subject: [PATCH 3/5] test: add type test --- test/types/change_stream.test-d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/types/change_stream.test-d.ts b/test/types/change_stream.test-d.ts index 02815cefd6..c61fde533b 100644 --- a/test/types/change_stream.test-d.ts +++ b/test/types/change_stream.test-d.ts @@ -63,6 +63,7 @@ expectType(change._id); expectType(change.clusterTime); expectType(change.txnNumber); // Could be a Long if promoteLongs is off expectType(change.lsid); +expectType(change.wallTime); type CrudChangeDoc = | ChangeStreamInsertDocument // C From 5fc176c1022a09d852ef78f8fbafd6c6e6470c9d Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Tue, 27 May 2025 20:46:41 +0100 Subject: [PATCH 4/5] test: add wallTime tests --- src/change_stream.ts | 1 + test/integration/change-streams/change_stream.test.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/change_stream.ts b/src/change_stream.ts index b4136edd4a..c38024172b 100644 --- a/src/change_stream.ts +++ b/src/change_stream.ts @@ -187,6 +187,7 @@ export interface ChangeStreamDocumentCommon { * The server date and time of the database operation. * wallTime differs from clusterTime in that clusterTime is a timestamp taken from the oplog entry associated with the database operation event. * The format is "YYYY-MM-DD HH:MM.SS.millis". + * @sinceServerVersion 6.0.0 */ wallTime?: string; diff --git a/test/integration/change-streams/change_stream.test.ts b/test/integration/change-streams/change_stream.test.ts index 7a188b2e33..d4ce3d8099 100644 --- a/test/integration/change-streams/change_stream.test.ts +++ b/test/integration/change-streams/change_stream.test.ts @@ -1259,7 +1259,8 @@ describe('Change Streams', function () { // Running on replicaset because other topologies are finiky with the cluster-wide events // Dropping and renaming and creating collections in order to achieve a clean slate isn't worth the goal of these tests // We just want to show that the new ChangeStreamDocument type information can reproduced in a real env - topologies: ['replicaset'] + topologies: ['replicaset'], + minServerVersion: '6.0' }) .createEntities([ { client: { id: 'client0' } }, @@ -1325,6 +1326,7 @@ describe('Change Streams', function () { operationType: 'drop', ns: { db: 'dbToDrop', coll: 'collInDbToDrop' }, clusterTime: { $$type: 'timestamp' }, + wallTime: { $$type: 'date' }, txnNumber: { $$exists: false }, lsid: { $$exists: false } } @@ -1337,6 +1339,7 @@ describe('Change Streams', function () { operationType: 'dropDatabase', ns: { db: 'dbToDrop', coll: { $$exists: false } }, clusterTime: { $$type: 'timestamp' }, + wallTime: { $$type: 'date' }, txnNumber: { $$exists: false }, lsid: { $$exists: false } } @@ -1349,6 +1352,7 @@ describe('Change Streams', function () { operationType: 'drop', ns: { db: 'dbToDrop', coll: 'collInDbToDrop' }, clusterTime: { $$type: 'timestamp' }, + wallTime: { $$type: 'date' }, txnNumber: { $$exists: false }, lsid: { $$exists: false } } @@ -1360,6 +1364,7 @@ describe('Change Streams', function () { _id: { $$exists: true }, operationType: 'invalidate', clusterTime: { $$type: 'timestamp' }, + wallTime: { $$type: 'date' }, txnNumber: { $$exists: false }, lsid: { $$exists: false } } @@ -1420,6 +1425,7 @@ describe('Change Streams', function () { documentKey: { _id: 3 }, ns: { db: 'changeStreamDocShape', coll: 'collection0' }, clusterTime: { $$type: 'timestamp' }, + wallTime: { $$type: 'date' }, txnNumber: { $$type: ['long', 'int'] }, lsid: { $$sessionLsid: 'session0' } } @@ -1472,6 +1478,7 @@ describe('Change Streams', function () { documentKey: { _id: 3 }, ns: { db: 'renameDb', coll: 'collToRename' }, clusterTime: { $$type: 'timestamp' }, + wallTime: { $$type: 'date' }, txnNumber: { $$exists: false }, lsid: { $$exists: false } } @@ -1497,6 +1504,7 @@ describe('Change Streams', function () { ns: { db: 'renameDb', coll: 'collToRename' }, to: { db: 'renameDb', coll: 'newCollectionName' }, clusterTime: { $$type: 'timestamp' }, + wallTime: { $$type: 'date' }, txnNumber: { $$exists: false }, lsid: { $$exists: false } } From 7c4d9f35ec96331056992ca17c62c094b3865d15 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Tue, 27 May 2025 21:35:26 +0100 Subject: [PATCH 5/5] fix: type --- src/change_stream.ts | 2 +- test/types/change_stream.test-d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/change_stream.ts b/src/change_stream.ts index c38024172b..9248a5da6e 100644 --- a/src/change_stream.ts +++ b/src/change_stream.ts @@ -189,7 +189,7 @@ export interface ChangeStreamDocumentCommon { * The format is "YYYY-MM-DD HH:MM.SS.millis". * @sinceServerVersion 6.0.0 */ - wallTime?: string; + wallTime?: Date; /** * The transaction number. diff --git a/test/types/change_stream.test-d.ts b/test/types/change_stream.test-d.ts index c61fde533b..f4a398f7c6 100644 --- a/test/types/change_stream.test-d.ts +++ b/test/types/change_stream.test-d.ts @@ -63,7 +63,7 @@ expectType(change._id); expectType(change.clusterTime); expectType(change.txnNumber); // Could be a Long if promoteLongs is off expectType(change.lsid); -expectType(change.wallTime); +expectType(change.wallTime); type CrudChangeDoc = | ChangeStreamInsertDocument // C