Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/sdam/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
10 changes: 8 additions & 2 deletions test/types/sessions.test-d.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -25,3 +25,9 @@ const unknownFn: () => Promise<unknown> = async () => 2;
expectType<unknown>(await client.withSession(unknownFn));
// Not a promise returning function
expectError(await client.withSession(() => null));

declare const ct: ClusterTime;
expectType<Timestamp>(ct.clusterTime);
expectAssignable<ClusterTime['signature']>(undefined);
expectType<Binary | undefined>(ct.signature?.hash);
expectType<Long | undefined>(ct.signature?.keyId);