From e4e687dd1889abdb84329c0cf368e944c5b799ba Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Thu, 4 Apr 2024 13:43:22 -0400 Subject: [PATCH 1/2] fix(NODE-6066): signature can be optional at runtime --- src/sdam/common.ts | 10 ++++++++-- test/types/sessions.test-d.ts | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/sdam/common.ts b/src/sdam/common.ts index e4b84d83f6e..fab8124d4c6 100644 --- a/src/sdam/common.ts +++ b/src/sdam/common.ts @@ -55,10 +55,16 @@ export function drainTimerQueue(queue: TimerQueue): void { queue.clear(); } -/** @public */ +/** + * @public + * Gossiped in component for the cluster time tracking the state of user databases + * across the cluster. It may optionally include a signature identifying the process that + * generated such a value. + */ export interface ClusterTime { clusterTime: Timestamp; - signature: { + /** Used to validate the identity of a request or response's ClusterTime. */ + signature?: { hash: Binary; keyId: Long; }; diff --git a/test/types/sessions.test-d.ts b/test/types/sessions.test-d.ts index 48c8fcb0dc5..7865f416339 100644 --- a/test/types/sessions.test-d.ts +++ b/test/types/sessions.test-d.ts @@ -1,6 +1,6 @@ -import { expectError, expectType } from 'tsd'; +import { expectAssignable, expectDocCommentIncludes, expectError, expectType } from 'tsd'; -import type { ClientSession } from '../mongodb'; +import type { Binary, ClientSession, ClusterTime, Long, Timestamp } from '../mongodb'; import { MongoClient, ReadConcern, ReadConcernLevel } from '../mongodb'; // test mapped cursor types @@ -25,3 +25,9 @@ const unknownFn: () => Promise = async () => 2; expectType(await client.withSession(unknownFn)); // Not a promise returning function expectError(await client.withSession(() => null)); + +declare const ct: ClusterTime; +expectType(ct.clusterTime); +expectAssignable(undefined); +expectType(ct.signature?.hash); +expectType(ct.signature?.keyId); From d9769ad2944bb7243473ec7fab8d24d13fe19ca7 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Thu, 4 Apr 2024 14:28:45 -0400 Subject: [PATCH 2/2] fix: lint --- test/types/sessions.test-d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/types/sessions.test-d.ts b/test/types/sessions.test-d.ts index 7865f416339..ec6f5a1bf33 100644 --- a/test/types/sessions.test-d.ts +++ b/test/types/sessions.test-d.ts @@ -1,4 +1,4 @@ -import { expectAssignable, expectDocCommentIncludes, expectError, expectType } from 'tsd'; +import { expectAssignable, expectError, expectType } from 'tsd'; import type { Binary, ClientSession, ClusterTime, Long, Timestamp } from '../mongodb'; import { MongoClient, ReadConcern, ReadConcernLevel } from '../mongodb'; @@ -29,5 +29,5 @@ expectError(await client.withSession(() => null)); declare const ct: ClusterTime; expectType(ct.clusterTime); expectAssignable(undefined); -expectType(ct.signature?.hash); -expectType(ct.signature?.keyId); +expectType(ct.signature?.hash); +expectType(ct.signature?.keyId);