Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 0f73940

Browse files
committed
feat: Adds response typings to assist with mocking at the network level
1 parent b451189 commit 0f73940

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
export * from "./authTypes.js";
21
export * from "./client.js";
32
export * from "./errors.js";
3+
4+
export * from "./authTypes.js";
5+
export * from "./responseTypes.js";

src/responseTypes.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { type MongoDataAPIError } from "./errors.js";
66
// eslint-disable-next-line @typescript-eslint/ban-types
77
type Nullable<T> = T | null;
88

9-
/** A data API response object */
9+
/** A generic data API response object */
1010
export type DataAPIResponse<T> = { data?: T; error?: MongoDataAPIError };
1111

1212
export type FindOneRequestOptions = { projection?: Document; sort?: Document };
@@ -16,33 +16,33 @@ export type FindOneResponse<TSchema> = Promise<
1616
DataAPIResponse<Nullable<WithId<TSchema>>>
1717
>;
1818

19-
/** The MongoDB-specific options for this API method */
19+
/** The MongoDB-specific options for the find() method */
2020
export type FindRequestOptions = {
2121
projection?: Document;
2222
sort?: Sort;
2323
limit?: number;
2424
skip?: number;
2525
};
2626

27-
/** A data API response object */
27+
/** A data API response object for the find() method */
2828
export type FindResponse<TSchema> = Promise<
2929
DataAPIResponse<Array<WithId<TSchema>>>
3030
>;
3131

32-
/** A data API response object */
32+
/** A data API response object for the insertOne() method */
3333
export type InsertOneResponse = Promise<
3434
DataAPIResponse<{ insertedId: ObjectId }>
3535
>;
3636

37-
/** A data API response object */
37+
/** A data API response object for the insertMany() method */
3838
export type InsertManyResponse = Promise<
3939
DataAPIResponse<{ insertedIds: string[] }>
4040
>;
4141

42-
/** The MongoDB-specific options for this API method */
42+
/** The MongoDB-specific options for the updateOne() method */
4343
export type UpdateOneRequestOptions = { upsert?: boolean };
4444

45-
/** A data API response object */
45+
/** A data API response object for the updateOne() method */
4646
export type UpdateOneResponse = Promise<
4747
DataAPIResponse<{
4848
matchedCount: number;
@@ -51,10 +51,10 @@ export type UpdateOneResponse = Promise<
5151
}>
5252
>;
5353

54-
/** The MongoDB-specific options for this API method */
54+
/** The MongoDB-specific options for the updateMany() method */
5555
export type UpdateManyRequestOptions = { upsert?: boolean };
5656

57-
/** A data API response object */
57+
/** A data API response object for the updateMany() method */
5858
export type UpdateManyResponse = Promise<
5959
DataAPIResponse<{
6060
matchedCount: number;
@@ -63,10 +63,10 @@ export type UpdateManyResponse = Promise<
6363
}>
6464
>;
6565

66-
/** The MongoDB-specific options for this API method */
66+
/** The MongoDB-specific options for the replaceOne() method */
6767
export type ReplaceOneRequestOptions = { upsert?: boolean };
6868

69-
/** A data API response object */
69+
/** A data API response object for the replaceOne() method */
7070
export type ReplaceOneResponse = Promise<
7171
DataAPIResponse<{
7272
matchedCount: number;
@@ -75,17 +75,17 @@ export type ReplaceOneResponse = Promise<
7575
}>
7676
>;
7777

78-
/** A data API response object */
78+
/** A data API response object for the deleteOne() method */
7979
export type DeleteOneResponse = Promise<
8080
DataAPIResponse<{ deletedCount: number }>
8181
>;
8282

83-
/** A data API response object */
83+
/** A data API response object for the deleteMany() method */
8484
export type DeleteManyResponse = Promise<
8585
DataAPIResponse<{ deletedCount: number }>
8686
>;
8787

88-
/** A data API response object */
88+
/** A data API response object for the aggregate() method */
8989
export type AggregateResponse<TOutput = Document> = Promise<
9090
DataAPIResponse<TOutput[]>
9191
>;

0 commit comments

Comments
 (0)