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..ec6f5a1bf33 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, 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);