Skip to content

Commit 7edb948

Browse files
committed
fix: add correct ts to execute
1 parent 053f01f commit 7edb948

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/client-side-encryption/state_machine.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,29 @@ export class StateMachine {
153153
) {}
154154

155155
/**
156-
* Executes the state machine according to the specification
156+
* Executes the state machine according to the specification.
157+
* Will construct the result using `responseType`.
158+
*/
159+
async execute<R extends MongoDBResponseConstructor>(
160+
executor: StateMachineExecutable,
161+
context: MongoCryptContext,
162+
responseType?: R
163+
): Promise<InstanceType<R>>;
164+
165+
/**
166+
* Executes the state machine according to the specification.
167+
* Will return a document from the default BSON deserializer.
157168
*/
158169
async execute<T extends Document>(
170+
executor: StateMachineExecutable,
171+
context: MongoCryptContext
172+
): Promise<T>;
173+
174+
async execute<T extends Document, R extends MongoDBResponseConstructor>(
159175
executor: StateMachineExecutable,
160176
context: MongoCryptContext,
161-
responseType?: MongoDBResponseConstructor
162-
): Promise<T> {
177+
responseType?: R
178+
): Promise<T | InstanceType<R>> {
163179
const keyVaultNamespace = executor._keyVaultNamespace;
164180
const keyVaultClient = executor._keyVaultClient;
165181
const metaDataClient = executor._metaDataClient;

0 commit comments

Comments
 (0)