@event-driven-io/pongo 0.14.4 → 0.15.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { DatabaseTransaction, SQLExecutor, DatabaseTransactionFactory, SchemaComponent, PostgresConnector, NodePostgresConnection, MigrationStyle } from '@event-driven-io/dumbo';
1
+ import { DatabaseTransaction, SQLExecutor, DatabaseTransactionFactory, SchemaComponent, QueryResultRow, SQL, QueryResult, PostgresConnector, NodePostgresConnection, MigrationStyle } from '@event-driven-io/dumbo';
2
2
  import pg from 'pg';
3
3
 
4
4
  interface PongoClient {
@@ -51,30 +51,58 @@ interface PongoDb<ConnectorType extends string = string> extends DatabaseTransac
51
51
  type CollectionOperationOptions = {
52
52
  session?: PongoSession;
53
53
  };
54
+ type InsertOneOptions = {
55
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK'>;
56
+ } & CollectionOperationOptions;
57
+ type InsertManyOptions = {
58
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK'>;
59
+ } & CollectionOperationOptions;
60
+ type UpdateOneOptions = {
61
+ expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
62
+ } & CollectionOperationOptions;
63
+ type UpdateManyOptions = {
64
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_EXISTS' | 'NO_CONCURRENCY_CHECK'>;
65
+ } & CollectionOperationOptions;
66
+ type HandleOptions = {
67
+ expectedVersion?: ExpectedDocumentVersion;
68
+ } & CollectionOperationOptions;
69
+ type ReplaceOneOptions = {
70
+ expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
71
+ } & CollectionOperationOptions;
72
+ type DeleteOneOptions = {
73
+ expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
74
+ } & CollectionOperationOptions;
75
+ type DeleteManyOptions = {
76
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_EXISTS' | 'NO_CONCURRENCY_CHECK'>;
77
+ } & CollectionOperationOptions;
54
78
  interface PongoCollection<T extends PongoDocument> {
55
79
  readonly dbName: string;
56
80
  readonly collectionName: string;
57
81
  createCollection(options?: CollectionOperationOptions): Promise<void>;
58
- insertOne(document: OptionalUnlessRequiredId<T>, options?: CollectionOperationOptions): Promise<PongoInsertOneResult>;
82
+ insertOne(document: OptionalUnlessRequiredId<T>, options?: InsertOneOptions): Promise<PongoInsertOneResult>;
59
83
  insertMany(documents: OptionalUnlessRequiredId<T>[], options?: CollectionOperationOptions): Promise<PongoInsertManyResult>;
60
- updateOne(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
61
- replaceOne(filter: PongoFilter<T>, document: WithoutId<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
62
- updateMany(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
63
- deleteOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<PongoDeleteResult>;
64
- deleteMany(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<PongoDeleteResult>;
84
+ updateOne(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: UpdateOneOptions): Promise<PongoUpdateResult>;
85
+ replaceOne(filter: PongoFilter<T>, document: WithoutId<T>, options?: ReplaceOneOptions): Promise<PongoUpdateResult>;
86
+ updateMany(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: UpdateManyOptions): Promise<PongoUpdateManyResult>;
87
+ deleteOne(filter?: PongoFilter<T>, options?: DeleteOneOptions): Promise<PongoDeleteResult>;
88
+ deleteMany(filter?: PongoFilter<T>, options?: DeleteManyOptions): Promise<PongoDeleteResult>;
65
89
  findOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
66
90
  find(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T[]>;
67
- findOneAndDelete(filter: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
68
- findOneAndReplace(filter: PongoFilter<T>, replacement: WithoutId<T>, options?: CollectionOperationOptions): Promise<T | null>;
69
- findOneAndUpdate(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<T | null>;
91
+ findOneAndDelete(filter: PongoFilter<T>, options?: DeleteOneOptions): Promise<T | null>;
92
+ findOneAndReplace(filter: PongoFilter<T>, replacement: WithoutId<T>, options?: ReplaceOneOptions): Promise<T | null>;
93
+ findOneAndUpdate(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: UpdateOneOptions): Promise<T | null>;
70
94
  countDocuments(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<number>;
71
95
  drop(options?: CollectionOperationOptions): Promise<boolean>;
72
96
  rename(newName: string, options?: CollectionOperationOptions): Promise<PongoCollection<T>>;
73
- handle(id: string, handle: DocumentHandler<T>, options?: CollectionOperationOptions): Promise<T | null>;
97
+ handle(id: string, handle: DocumentHandler<T>, options?: HandleOptions): Promise<PongoHandleResult<T>>;
74
98
  readonly schema: Readonly<{
75
99
  component: SchemaComponent;
76
100
  migrate(): Promise<void>;
77
101
  }>;
102
+ sql: {
103
+ query<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: CollectionOperationOptions): Promise<Result[]>;
104
+ command<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: CollectionOperationOptions): Promise<QueryResult<Result>>;
105
+ };
78
106
  }
79
107
  type ObjectId = string & {
80
108
  __brandId: 'ObjectId';
@@ -92,10 +120,18 @@ declare type EnhancedOmit<TRecordOrUnion, KeyUnion> = string extends keyof TReco
92
120
  declare type OptionalUnlessRequiredId<TSchema> = TSchema extends {
93
121
  _id: string | ObjectId;
94
122
  } ? TSchema : OptionalId<TSchema>;
123
+ declare type OptionalUnlessRequiredVersion<TSchema> = TSchema extends {
124
+ _version: bigint;
125
+ } ? TSchema : OptionalVersion<TSchema>;
126
+ declare type OptionalUnlessRequiredIdAndVersion<TSchema> = OptionalUnlessRequiredId<TSchema> & OptionalUnlessRequiredVersion<TSchema>;
95
127
  declare type WithId<TSchema> = EnhancedOmit<TSchema, '_id'> & {
96
128
  _id: string | ObjectId;
97
129
  };
98
130
  type WithoutId<T> = Omit<T, '_id'>;
131
+ declare type WithVersion<TSchema> = EnhancedOmit<TSchema, '_version'> & {
132
+ _version: bigint;
133
+ };
134
+ type WithoutVersion<T> = Omit<T, '_version'>;
99
135
  /** @public */
100
136
  declare type RegExpOrString<T> = T extends string ? RegExp | T : T;
101
137
  declare interface Document {
@@ -104,6 +140,9 @@ declare interface Document {
104
140
  declare type OptionalId<TSchema> = EnhancedOmit<TSchema, '_id'> & {
105
141
  _id?: string | ObjectId;
106
142
  };
143
+ declare type OptionalVersion<TSchema> = EnhancedOmit<TSchema, '_version'> & {
144
+ _version?: bigint;
145
+ };
107
146
  declare interface ObjectIdLike {
108
147
  __id?: string | ObjectId;
109
148
  }
@@ -143,42 +182,75 @@ type $unset<T> = {
143
182
  [P in keyof T]?: '';
144
183
  };
145
184
  type $inc<T> = {
146
- [P in keyof T]?: number;
185
+ [P in keyof T]?: number | bigint;
147
186
  };
148
187
  type $push<T> = {
149
188
  [P in keyof T]?: T[P];
150
189
  };
190
+ type ExpectedDocumentVersionGeneral = 'DOCUMENT_EXISTS' | 'DOCUMENT_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK';
191
+ type ExpectedDocumentVersionValue = bigint & {
192
+ __brand: 'sql';
193
+ };
194
+ type ExpectedDocumentVersion = (bigint & {
195
+ __brand: 'sql';
196
+ }) | bigint | ExpectedDocumentVersionGeneral;
197
+ declare const DOCUMENT_EXISTS: ExpectedDocumentVersionGeneral;
198
+ declare const DOCUMENT_DOES_NOT_EXIST: ExpectedDocumentVersionGeneral;
199
+ declare const NO_CONCURRENCY_CHECK: ExpectedDocumentVersionGeneral;
200
+ declare const isGeneralExpectedDocumentVersion: (version: ExpectedDocumentVersion) => version is ExpectedDocumentVersionGeneral;
201
+ declare const expectedVersionValue: (version: ExpectedDocumentVersion | undefined) => ExpectedDocumentVersionValue | null;
202
+ declare const expectedVersion: (version: number | bigint | string | undefined | null) => ExpectedDocumentVersion;
151
203
  type PongoUpdate<T> = {
152
204
  $set?: Partial<T>;
153
205
  $unset?: $unset<T>;
154
206
  $inc?: $inc<T>;
155
207
  $push?: $push<T>;
156
208
  };
157
- interface PongoInsertOneResult {
158
- insertedId: string | null;
209
+ type OperationResult = {
159
210
  acknowledged: boolean;
211
+ successful: boolean;
212
+ assertSuccessful: (errorMessage?: string) => void;
213
+ };
214
+ declare const operationResult: <T extends OperationResult>(result: Omit<T, "assertSuccess" | "acknowledged" | "assertSuccessful">, options: {
215
+ operationName: string;
216
+ collectionName: string;
217
+ errors?: {
218
+ throwOnOperationFailures?: boolean;
219
+ } | undefined;
220
+ }) => T;
221
+ interface PongoInsertOneResult extends OperationResult {
222
+ insertedId: string | null;
223
+ nextExpectedVersion: bigint;
160
224
  }
161
- interface PongoInsertManyResult {
162
- acknowledged: boolean;
225
+ interface PongoInsertManyResult extends OperationResult {
163
226
  insertedIds: string[];
164
227
  insertedCount: number;
165
228
  }
166
- interface PongoUpdateResult {
167
- acknowledged: boolean;
229
+ interface PongoUpdateResult extends OperationResult {
230
+ matchedCount: number;
168
231
  modifiedCount: number;
232
+ nextExpectedVersion: bigint;
169
233
  }
170
- interface PongoUpdateManyResult {
171
- acknowledged: boolean;
234
+ interface PongoUpdateManyResult extends OperationResult {
235
+ matchedCount: number;
172
236
  modifiedCount: number;
173
237
  }
174
- interface PongoDeleteResult {
175
- acknowledged: boolean;
238
+ interface PongoDeleteResult extends OperationResult {
239
+ matchedCount: number;
176
240
  deletedCount: number;
177
241
  }
178
- interface PongoDeleteManyResult {
179
- acknowledged: boolean;
242
+ interface PongoDeleteManyResult extends OperationResult {
180
243
  deletedCount: number;
181
244
  }
245
+ type PongoHandleResult<T> = (PongoInsertOneResult & {
246
+ document: T;
247
+ }) | (PongoUpdateResult & {
248
+ document: T;
249
+ }) | (PongoDeleteResult & {
250
+ document: null;
251
+ }) | (OperationResult & {
252
+ document: null;
253
+ });
182
254
  type PongoDocument = Record<string, unknown>;
183
255
  type DocumentHandler<T extends PongoDocument> = ((document: T | null) => T | null) | ((document: T | null) => Promise<T | null>);
184
256
 
@@ -263,6 +335,9 @@ type PongoClientOptions<TypedClientSchema extends PongoClientSchema = PongoClien
263
335
  autoMigration?: MigrationStyle;
264
336
  definition?: TypedClientSchema;
265
337
  };
338
+ errors?: {
339
+ throwOnOperationFailures?: boolean;
340
+ };
266
341
  connectionOptions?: PooledPongoClientOptions | NotPooledPongoOptions;
267
342
  };
268
343
  declare const pongoClient: <TypedClientSchema extends PongoClientSchema = PongoClientSchema<Record<string, PongoDbSchema<Record<string, PongoCollectionSchema<PongoDocument>>>>>, DbClientOptions extends AllowedDbClientOptions = PostgresDbClientOptions>(connectionString: string, options?: PongoClientOptions<TypedClientSchema>) => PongoClient & PongoClientWithSchema<TypedClientSchema>;
@@ -272,4 +347,4 @@ declare const clientToDbOptions: <DbClientOptions extends AllowedDbClientOptions
272
347
  clientOptions: PongoClientOptions;
273
348
  }) => DbClientOptions;
274
349
 
275
- export { type $set as $, type AllowedDbClientOptions as A, getPongoDb as B, type CollectionsMap as C, type DBsMap as D, type PongoClient as E, type CollectionOperationOptions as F, type ObjectId as G, type HasId as H, type InferIdType as I, type EnhancedOmit as J, type WithId as K, type Document as L, type OptionalId as M, type NotPooledPongoOptions as N, type OptionalUnlessRequiredId as O, type PongoDb as P, type ObjectIdLike as Q, type RegExpOrString as R, type NonObjectIdLikeDocument as S, type AlternativeType as T, type Condition as U, type RootFilterOperators as V, type WithoutId as W, type PongoFilterOperator as X, type $unset as Y, type $inc as Z, type $push as _, type PongoDocument as a, type PongoInsertOneResult as a0, type PongoInsertManyResult as a1, type PongoUpdateResult as a2, type PongoUpdateManyResult as a3, type PongoDeleteResult as a4, type PongoDeleteManyResult as a5, type DocumentHandler as a6, type PostgresDbClientOptions as a7, isPostgresClientOptions as a8, postgresDb as a9, pongoDbSchemaComponent as aa, type PongoCollection as b, type PongoFilter as c, type PongoUpdate as d, type PongoTransactionOptions as e, type PongoSession as f, type PongoDbTransaction as g, type PongoCollectionSchema as h, type PongoDbSchema as i, type PongoClientSchema as j, type PongoDbWithSchema as k, type PongoClientWithSchema as l, proxyPongoDbWithSchema as m, proxyClientWithSchema as n, type PongoCollectionSchemaMetadata as o, pongoSchema as p, type PongoDbSchemaMetadata as q, type PongoClientSchemaMetadata as r, toClientSchemaMetadata as s, toDbSchemaMetadata as t, type PongoSchemaConfig as u, type PooledPongoClientOptions as v, type PongoClientOptions as w, pongoClient as x, clientToDbOptions as y, type PongoDbClientOptions as z };
350
+ export { type RegExpOrString as $, type AllowedDbClientOptions as A, toClientSchemaMetadata as B, type CollectionsMap as C, type DeleteOneOptions as D, type PongoSchemaConfig as E, type PongoClient as F, type CollectionOperationOptions as G, type InsertManyOptions as H, type InsertOneOptions as I, type UpdateManyOptions as J, type HandleOptions as K, type DeleteManyOptions as L, type ObjectId as M, type NotPooledPongoOptions as N, type OptionalUnlessRequiredIdAndVersion as O, type PongoDb as P, type HasId as Q, type ReplaceOneOptions as R, type InferIdType as S, type EnhancedOmit as T, type UpdateOneOptions as U, type OptionalUnlessRequiredId as V, type WithoutId as W, type OptionalUnlessRequiredVersion as X, type WithId as Y, type WithVersion as Z, type WithoutVersion as _, type PongoDocument as a, type Document as a0, type OptionalId as a1, type OptionalVersion as a2, type ObjectIdLike as a3, type NonObjectIdLikeDocument as a4, type AlternativeType as a5, type Condition as a6, type RootFilterOperators as a7, type PongoFilterOperator as a8, type $set as a9, type $unset as aa, type $inc as ab, type $push as ac, type ExpectedDocumentVersionGeneral as ad, type ExpectedDocumentVersionValue as ae, type ExpectedDocumentVersion as af, DOCUMENT_EXISTS as ag, DOCUMENT_DOES_NOT_EXIST as ah, NO_CONCURRENCY_CHECK as ai, isGeneralExpectedDocumentVersion as aj, expectedVersionValue as ak, expectedVersion as al, type OperationResult as am, operationResult as an, type PongoInsertOneResult as ao, type PongoInsertManyResult as ap, type PongoUpdateResult as aq, type PongoUpdateManyResult as ar, type PongoDeleteResult as as, type PongoDeleteManyResult as at, type PongoHandleResult as au, type DocumentHandler as av, type PostgresDbClientOptions as aw, isPostgresClientOptions as ax, postgresDb as ay, pongoDbSchemaComponent as az, type PongoCollection as b, type PongoFilter as c, type PongoUpdate as d, type PongoTransactionOptions as e, type PongoSession as f, type PongoDbTransaction as g, type PooledPongoClientOptions as h, type PongoClientOptions as i, clientToDbOptions as j, type PongoDbClientOptions as k, getPongoDb as l, type PongoCollectionSchema as m, type PongoDbSchema as n, type PongoClientSchema as o, pongoClient as p, type PongoDbWithSchema as q, type DBsMap as r, type PongoClientWithSchema as s, pongoSchema as t, proxyPongoDbWithSchema as u, proxyClientWithSchema as v, type PongoCollectionSchemaMetadata as w, type PongoDbSchemaMetadata as x, type PongoClientSchemaMetadata as y, toDbSchemaMetadata as z };
@@ -1,4 +1,4 @@
1
- import { DatabaseTransaction, SQLExecutor, DatabaseTransactionFactory, SchemaComponent, PostgresConnector, NodePostgresConnection, MigrationStyle } from '@event-driven-io/dumbo';
1
+ import { DatabaseTransaction, SQLExecutor, DatabaseTransactionFactory, SchemaComponent, QueryResultRow, SQL, QueryResult, PostgresConnector, NodePostgresConnection, MigrationStyle } from '@event-driven-io/dumbo';
2
2
  import pg from 'pg';
3
3
 
4
4
  interface PongoClient {
@@ -51,30 +51,58 @@ interface PongoDb<ConnectorType extends string = string> extends DatabaseTransac
51
51
  type CollectionOperationOptions = {
52
52
  session?: PongoSession;
53
53
  };
54
+ type InsertOneOptions = {
55
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK'>;
56
+ } & CollectionOperationOptions;
57
+ type InsertManyOptions = {
58
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK'>;
59
+ } & CollectionOperationOptions;
60
+ type UpdateOneOptions = {
61
+ expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
62
+ } & CollectionOperationOptions;
63
+ type UpdateManyOptions = {
64
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_EXISTS' | 'NO_CONCURRENCY_CHECK'>;
65
+ } & CollectionOperationOptions;
66
+ type HandleOptions = {
67
+ expectedVersion?: ExpectedDocumentVersion;
68
+ } & CollectionOperationOptions;
69
+ type ReplaceOneOptions = {
70
+ expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
71
+ } & CollectionOperationOptions;
72
+ type DeleteOneOptions = {
73
+ expectedVersion?: Exclude<ExpectedDocumentVersion, 'DOCUMENT_DOES_NOT_EXIST'>;
74
+ } & CollectionOperationOptions;
75
+ type DeleteManyOptions = {
76
+ expectedVersion?: Extract<ExpectedDocumentVersion, 'DOCUMENT_EXISTS' | 'NO_CONCURRENCY_CHECK'>;
77
+ } & CollectionOperationOptions;
54
78
  interface PongoCollection<T extends PongoDocument> {
55
79
  readonly dbName: string;
56
80
  readonly collectionName: string;
57
81
  createCollection(options?: CollectionOperationOptions): Promise<void>;
58
- insertOne(document: OptionalUnlessRequiredId<T>, options?: CollectionOperationOptions): Promise<PongoInsertOneResult>;
82
+ insertOne(document: OptionalUnlessRequiredId<T>, options?: InsertOneOptions): Promise<PongoInsertOneResult>;
59
83
  insertMany(documents: OptionalUnlessRequiredId<T>[], options?: CollectionOperationOptions): Promise<PongoInsertManyResult>;
60
- updateOne(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
61
- replaceOne(filter: PongoFilter<T>, document: WithoutId<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
62
- updateMany(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
63
- deleteOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<PongoDeleteResult>;
64
- deleteMany(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<PongoDeleteResult>;
84
+ updateOne(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: UpdateOneOptions): Promise<PongoUpdateResult>;
85
+ replaceOne(filter: PongoFilter<T>, document: WithoutId<T>, options?: ReplaceOneOptions): Promise<PongoUpdateResult>;
86
+ updateMany(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: UpdateManyOptions): Promise<PongoUpdateManyResult>;
87
+ deleteOne(filter?: PongoFilter<T>, options?: DeleteOneOptions): Promise<PongoDeleteResult>;
88
+ deleteMany(filter?: PongoFilter<T>, options?: DeleteManyOptions): Promise<PongoDeleteResult>;
65
89
  findOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
66
90
  find(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T[]>;
67
- findOneAndDelete(filter: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
68
- findOneAndReplace(filter: PongoFilter<T>, replacement: WithoutId<T>, options?: CollectionOperationOptions): Promise<T | null>;
69
- findOneAndUpdate(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<T | null>;
91
+ findOneAndDelete(filter: PongoFilter<T>, options?: DeleteOneOptions): Promise<T | null>;
92
+ findOneAndReplace(filter: PongoFilter<T>, replacement: WithoutId<T>, options?: ReplaceOneOptions): Promise<T | null>;
93
+ findOneAndUpdate(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: UpdateOneOptions): Promise<T | null>;
70
94
  countDocuments(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<number>;
71
95
  drop(options?: CollectionOperationOptions): Promise<boolean>;
72
96
  rename(newName: string, options?: CollectionOperationOptions): Promise<PongoCollection<T>>;
73
- handle(id: string, handle: DocumentHandler<T>, options?: CollectionOperationOptions): Promise<T | null>;
97
+ handle(id: string, handle: DocumentHandler<T>, options?: HandleOptions): Promise<PongoHandleResult<T>>;
74
98
  readonly schema: Readonly<{
75
99
  component: SchemaComponent;
76
100
  migrate(): Promise<void>;
77
101
  }>;
102
+ sql: {
103
+ query<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: CollectionOperationOptions): Promise<Result[]>;
104
+ command<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: CollectionOperationOptions): Promise<QueryResult<Result>>;
105
+ };
78
106
  }
79
107
  type ObjectId = string & {
80
108
  __brandId: 'ObjectId';
@@ -92,10 +120,18 @@ declare type EnhancedOmit<TRecordOrUnion, KeyUnion> = string extends keyof TReco
92
120
  declare type OptionalUnlessRequiredId<TSchema> = TSchema extends {
93
121
  _id: string | ObjectId;
94
122
  } ? TSchema : OptionalId<TSchema>;
123
+ declare type OptionalUnlessRequiredVersion<TSchema> = TSchema extends {
124
+ _version: bigint;
125
+ } ? TSchema : OptionalVersion<TSchema>;
126
+ declare type OptionalUnlessRequiredIdAndVersion<TSchema> = OptionalUnlessRequiredId<TSchema> & OptionalUnlessRequiredVersion<TSchema>;
95
127
  declare type WithId<TSchema> = EnhancedOmit<TSchema, '_id'> & {
96
128
  _id: string | ObjectId;
97
129
  };
98
130
  type WithoutId<T> = Omit<T, '_id'>;
131
+ declare type WithVersion<TSchema> = EnhancedOmit<TSchema, '_version'> & {
132
+ _version: bigint;
133
+ };
134
+ type WithoutVersion<T> = Omit<T, '_version'>;
99
135
  /** @public */
100
136
  declare type RegExpOrString<T> = T extends string ? RegExp | T : T;
101
137
  declare interface Document {
@@ -104,6 +140,9 @@ declare interface Document {
104
140
  declare type OptionalId<TSchema> = EnhancedOmit<TSchema, '_id'> & {
105
141
  _id?: string | ObjectId;
106
142
  };
143
+ declare type OptionalVersion<TSchema> = EnhancedOmit<TSchema, '_version'> & {
144
+ _version?: bigint;
145
+ };
107
146
  declare interface ObjectIdLike {
108
147
  __id?: string | ObjectId;
109
148
  }
@@ -143,42 +182,75 @@ type $unset<T> = {
143
182
  [P in keyof T]?: '';
144
183
  };
145
184
  type $inc<T> = {
146
- [P in keyof T]?: number;
185
+ [P in keyof T]?: number | bigint;
147
186
  };
148
187
  type $push<T> = {
149
188
  [P in keyof T]?: T[P];
150
189
  };
190
+ type ExpectedDocumentVersionGeneral = 'DOCUMENT_EXISTS' | 'DOCUMENT_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK';
191
+ type ExpectedDocumentVersionValue = bigint & {
192
+ __brand: 'sql';
193
+ };
194
+ type ExpectedDocumentVersion = (bigint & {
195
+ __brand: 'sql';
196
+ }) | bigint | ExpectedDocumentVersionGeneral;
197
+ declare const DOCUMENT_EXISTS: ExpectedDocumentVersionGeneral;
198
+ declare const DOCUMENT_DOES_NOT_EXIST: ExpectedDocumentVersionGeneral;
199
+ declare const NO_CONCURRENCY_CHECK: ExpectedDocumentVersionGeneral;
200
+ declare const isGeneralExpectedDocumentVersion: (version: ExpectedDocumentVersion) => version is ExpectedDocumentVersionGeneral;
201
+ declare const expectedVersionValue: (version: ExpectedDocumentVersion | undefined) => ExpectedDocumentVersionValue | null;
202
+ declare const expectedVersion: (version: number | bigint | string | undefined | null) => ExpectedDocumentVersion;
151
203
  type PongoUpdate<T> = {
152
204
  $set?: Partial<T>;
153
205
  $unset?: $unset<T>;
154
206
  $inc?: $inc<T>;
155
207
  $push?: $push<T>;
156
208
  };
157
- interface PongoInsertOneResult {
158
- insertedId: string | null;
209
+ type OperationResult = {
159
210
  acknowledged: boolean;
211
+ successful: boolean;
212
+ assertSuccessful: (errorMessage?: string) => void;
213
+ };
214
+ declare const operationResult: <T extends OperationResult>(result: Omit<T, "assertSuccess" | "acknowledged" | "assertSuccessful">, options: {
215
+ operationName: string;
216
+ collectionName: string;
217
+ errors?: {
218
+ throwOnOperationFailures?: boolean;
219
+ } | undefined;
220
+ }) => T;
221
+ interface PongoInsertOneResult extends OperationResult {
222
+ insertedId: string | null;
223
+ nextExpectedVersion: bigint;
160
224
  }
161
- interface PongoInsertManyResult {
162
- acknowledged: boolean;
225
+ interface PongoInsertManyResult extends OperationResult {
163
226
  insertedIds: string[];
164
227
  insertedCount: number;
165
228
  }
166
- interface PongoUpdateResult {
167
- acknowledged: boolean;
229
+ interface PongoUpdateResult extends OperationResult {
230
+ matchedCount: number;
168
231
  modifiedCount: number;
232
+ nextExpectedVersion: bigint;
169
233
  }
170
- interface PongoUpdateManyResult {
171
- acknowledged: boolean;
234
+ interface PongoUpdateManyResult extends OperationResult {
235
+ matchedCount: number;
172
236
  modifiedCount: number;
173
237
  }
174
- interface PongoDeleteResult {
175
- acknowledged: boolean;
238
+ interface PongoDeleteResult extends OperationResult {
239
+ matchedCount: number;
176
240
  deletedCount: number;
177
241
  }
178
- interface PongoDeleteManyResult {
179
- acknowledged: boolean;
242
+ interface PongoDeleteManyResult extends OperationResult {
180
243
  deletedCount: number;
181
244
  }
245
+ type PongoHandleResult<T> = (PongoInsertOneResult & {
246
+ document: T;
247
+ }) | (PongoUpdateResult & {
248
+ document: T;
249
+ }) | (PongoDeleteResult & {
250
+ document: null;
251
+ }) | (OperationResult & {
252
+ document: null;
253
+ });
182
254
  type PongoDocument = Record<string, unknown>;
183
255
  type DocumentHandler<T extends PongoDocument> = ((document: T | null) => T | null) | ((document: T | null) => Promise<T | null>);
184
256
 
@@ -263,6 +335,9 @@ type PongoClientOptions<TypedClientSchema extends PongoClientSchema = PongoClien
263
335
  autoMigration?: MigrationStyle;
264
336
  definition?: TypedClientSchema;
265
337
  };
338
+ errors?: {
339
+ throwOnOperationFailures?: boolean;
340
+ };
266
341
  connectionOptions?: PooledPongoClientOptions | NotPooledPongoOptions;
267
342
  };
268
343
  declare const pongoClient: <TypedClientSchema extends PongoClientSchema = PongoClientSchema<Record<string, PongoDbSchema<Record<string, PongoCollectionSchema<PongoDocument>>>>>, DbClientOptions extends AllowedDbClientOptions = PostgresDbClientOptions>(connectionString: string, options?: PongoClientOptions<TypedClientSchema>) => PongoClient & PongoClientWithSchema<TypedClientSchema>;
@@ -272,4 +347,4 @@ declare const clientToDbOptions: <DbClientOptions extends AllowedDbClientOptions
272
347
  clientOptions: PongoClientOptions;
273
348
  }) => DbClientOptions;
274
349
 
275
- export { type $set as $, type AllowedDbClientOptions as A, getPongoDb as B, type CollectionsMap as C, type DBsMap as D, type PongoClient as E, type CollectionOperationOptions as F, type ObjectId as G, type HasId as H, type InferIdType as I, type EnhancedOmit as J, type WithId as K, type Document as L, type OptionalId as M, type NotPooledPongoOptions as N, type OptionalUnlessRequiredId as O, type PongoDb as P, type ObjectIdLike as Q, type RegExpOrString as R, type NonObjectIdLikeDocument as S, type AlternativeType as T, type Condition as U, type RootFilterOperators as V, type WithoutId as W, type PongoFilterOperator as X, type $unset as Y, type $inc as Z, type $push as _, type PongoDocument as a, type PongoInsertOneResult as a0, type PongoInsertManyResult as a1, type PongoUpdateResult as a2, type PongoUpdateManyResult as a3, type PongoDeleteResult as a4, type PongoDeleteManyResult as a5, type DocumentHandler as a6, type PostgresDbClientOptions as a7, isPostgresClientOptions as a8, postgresDb as a9, pongoDbSchemaComponent as aa, type PongoCollection as b, type PongoFilter as c, type PongoUpdate as d, type PongoTransactionOptions as e, type PongoSession as f, type PongoDbTransaction as g, type PongoCollectionSchema as h, type PongoDbSchema as i, type PongoClientSchema as j, type PongoDbWithSchema as k, type PongoClientWithSchema as l, proxyPongoDbWithSchema as m, proxyClientWithSchema as n, type PongoCollectionSchemaMetadata as o, pongoSchema as p, type PongoDbSchemaMetadata as q, type PongoClientSchemaMetadata as r, toClientSchemaMetadata as s, toDbSchemaMetadata as t, type PongoSchemaConfig as u, type PooledPongoClientOptions as v, type PongoClientOptions as w, pongoClient as x, clientToDbOptions as y, type PongoDbClientOptions as z };
350
+ export { type RegExpOrString as $, type AllowedDbClientOptions as A, toClientSchemaMetadata as B, type CollectionsMap as C, type DeleteOneOptions as D, type PongoSchemaConfig as E, type PongoClient as F, type CollectionOperationOptions as G, type InsertManyOptions as H, type InsertOneOptions as I, type UpdateManyOptions as J, type HandleOptions as K, type DeleteManyOptions as L, type ObjectId as M, type NotPooledPongoOptions as N, type OptionalUnlessRequiredIdAndVersion as O, type PongoDb as P, type HasId as Q, type ReplaceOneOptions as R, type InferIdType as S, type EnhancedOmit as T, type UpdateOneOptions as U, type OptionalUnlessRequiredId as V, type WithoutId as W, type OptionalUnlessRequiredVersion as X, type WithId as Y, type WithVersion as Z, type WithoutVersion as _, type PongoDocument as a, type Document as a0, type OptionalId as a1, type OptionalVersion as a2, type ObjectIdLike as a3, type NonObjectIdLikeDocument as a4, type AlternativeType as a5, type Condition as a6, type RootFilterOperators as a7, type PongoFilterOperator as a8, type $set as a9, type $unset as aa, type $inc as ab, type $push as ac, type ExpectedDocumentVersionGeneral as ad, type ExpectedDocumentVersionValue as ae, type ExpectedDocumentVersion as af, DOCUMENT_EXISTS as ag, DOCUMENT_DOES_NOT_EXIST as ah, NO_CONCURRENCY_CHECK as ai, isGeneralExpectedDocumentVersion as aj, expectedVersionValue as ak, expectedVersion as al, type OperationResult as am, operationResult as an, type PongoInsertOneResult as ao, type PongoInsertManyResult as ap, type PongoUpdateResult as aq, type PongoUpdateManyResult as ar, type PongoDeleteResult as as, type PongoDeleteManyResult as at, type PongoHandleResult as au, type DocumentHandler as av, type PostgresDbClientOptions as aw, isPostgresClientOptions as ax, postgresDb as ay, pongoDbSchemaComponent as az, type PongoCollection as b, type PongoFilter as c, type PongoUpdate as d, type PongoTransactionOptions as e, type PongoSession as f, type PongoDbTransaction as g, type PooledPongoClientOptions as h, type PongoClientOptions as i, clientToDbOptions as j, type PongoDbClientOptions as k, getPongoDb as l, type PongoCollectionSchema as m, type PongoDbSchema as n, type PongoClientSchema as o, pongoClient as p, type PongoDbWithSchema as q, type DBsMap as r, type PongoClientWithSchema as s, pongoSchema as t, proxyPongoDbWithSchema as u, proxyClientWithSchema as v, type PongoCollectionSchemaMetadata as w, type PongoDbSchemaMetadata as x, type PongoClientSchemaMetadata as y, toDbSchemaMetadata as z };
package/dist/shim.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var _chunkOOCCQKUBcjs = require('./chunk-OOCCQKUB.cjs');var s= (_class =class{__init() {this.documents=null}__init2() {this.index=0}constructor(e){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);this.findDocumentsPromise=e}async toArray(){return this.findDocuments()}async forEach(e){let n=await this.findDocuments();for(let t of n)e(t);return Promise.resolve()}hasNext(){if(this.documents===null)throw Error("Error while fetching documents");return this.index<this.documents.length}async next(){let e=await this.findDocuments();return this.hasNext()?_nullishCoalesce(e[this.index++], () => (null)):null}async findDocuments(){return this.documents=await this.findDocumentsPromise,this.documents}}, _class);require('mongodb');var o=r=>_optionalChain([r, 'optionalAccess', _ => _.session])?{session:r.session}:void 0,d= exports.Collection =class{constructor(e){this.collection=e}get dbName(){return this.collection.dbName}get collectionName(){return this.collection.collectionName}get namespace(){return`${this.dbName}.${this.collectionName}`}get readConcern(){}get readPreference(){}get bsonOptions(){return{}}get writeConcern(){}get hint(){}set hint(e){throw new Error("Method not implemented.")}async insertOne(e,n){let t=await this.collection.insertOne(e,o(n));return{acknowledged:t.acknowledged,insertedId:t.insertedId}}async insertMany(e,n){let t=await this.collection.insertMany(e,o(n));return{acknowledged:t.acknowledged,insertedIds:t.insertedIds,insertedCount:t.insertedCount}}bulkWrite(e,n){throw new Error("Method not implemented.")}async updateOne(e,n,t){let i=await this.collection.updateOne(e,n,o(t));return{acknowledged:i.acknowledged,matchedCount:i.modifiedCount,modifiedCount:i.modifiedCount,upsertedCount:i.modifiedCount,upsertedId:null}}replaceOne(e,n,t){return this.collection.replaceOne(e,n,o(t))}async updateMany(e,n,t){let i=await this.collection.updateMany(e,n,o(t));return{acknowledged:i.acknowledged,matchedCount:i.modifiedCount,modifiedCount:i.modifiedCount,upsertedCount:i.modifiedCount,upsertedId:null}}async deleteOne(e,n){let t=await this.collection.deleteOne(e,o(n));return{acknowledged:t.acknowledged,deletedCount:t.deletedCount}}async deleteMany(e,n){let t=await this.collection.deleteMany(e,o(n));return{acknowledged:t.acknowledged,deletedCount:t.deletedCount}}async rename(e,n){return await this.collection.rename(e,o(n)),this}drop(e){return this.collection.drop(o(e))}async findOne(e,n){return this.collection.findOne(e,o(n))}find(e,n){return new s(this.collection.find(e,o(n)))}options(e){throw new Error("Method not implemented.")}isCapped(e){throw new Error("Method not implemented.")}createIndex(e,n){throw new Error("Method not implemented.")}createIndexes(e,n){throw new Error("Method not implemented.")}dropIndex(e,n){throw new Error("Method not implemented.")}dropIndexes(e){throw new Error("Method not implemented.")}listIndexes(e){throw new Error("Method not implemented.")}indexExists(e,n){throw new Error("Method not implemented.")}indexInformation(e){throw new Error("Method not implemented.")}estimatedDocumentCount(e){return this.collection.countDocuments({},o(e))}countDocuments(e,n){return this.collection.countDocuments(e,o(n))}distinct(e,n,t){throw new Error("Method not implemented.")}indexes(e){throw new Error("Method not implemented.")}findOneAndDelete(e,n){return this.collection.findOneAndDelete(e,o(n))}findOneAndReplace(e,n,t){return this.collection.findOneAndReplace(e,n,o(t))}findOneAndUpdate(e,n,t){return this.collection.findOneAndUpdate(e,n,o(t))}aggregate(e,n){throw new Error("Method not implemented.")}watch(e,n){throw new Error("Method not implemented.")}initializeUnorderedBulkOp(e){throw new Error("Method not implemented.")}initializeOrderedBulkOp(e){throw new Error("Method not implemented.")}count(e,n){return this.collection.countDocuments(_nullishCoalesce(e, () => ({})),o(n))}listSearchIndexes(e,n){throw new Error("Method not implemented.")}createSearchIndex(e){throw new Error("Method not implemented.")}createSearchIndexes(e){throw new Error("Method not implemented.")}dropSearchIndex(e){throw new Error("Method not implemented.")}updateSearchIndex(e,n){throw new Error("Method not implemented.")}async createCollection(){await this.collection.createCollection()}async handle(e,n){return this.collection.handle(e.toString(),n)}};var l=class{constructor(e){this.pongoDb=e}get databaseName(){return this.pongoDb.databaseName}collection(e){return new d(this.pongoDb.collection(e))}};var u=class{constructor(e,n={}){this.pongoClient=_chunkOOCCQKUBcjs.u.call(void 0, e,n)}async connect(){return await this.pongoClient.connect(),this}async close(){await this.pongoClient.close()}db(e){return new l(this.pongoClient.db(e))}startSession(e){return _chunkOOCCQKUBcjs.t.call(void 0, )}async withSession(e,n){let t=typeof e=="function"?e:n,i=_chunkOOCCQKUBcjs.t.call(void 0, );try{return await t(i)}finally{await i.endSession()}}};exports.Collection = d; exports.Db = l; exports.FindCursor = s; exports.MongoClient = u;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var _chunk7GQ5BP22cjs = require('./chunk-7GQ5BP22.cjs');var s= (_class =class{__init() {this.documents=null}__init2() {this.index=0}constructor(e){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);this.findDocumentsPromise=e}async toArray(){return this.findDocuments()}async forEach(e){let n=await this.findDocuments();for(let t of n)e(t);return Promise.resolve()}hasNext(){if(this.documents===null)throw Error("Error while fetching documents");return this.index<this.documents.length}async next(){let e=await this.findDocuments();return this.hasNext()?_nullishCoalesce(e[this.index++], () => (null)):null}async findDocuments(){return this.documents=await this.findDocumentsPromise,this.documents}}, _class);require('mongodb');var o=r=>_optionalChain([r, 'optionalAccess', _ => _.session])?{session:r.session}:void 0,d= exports.Collection =class{constructor(e){this.collection=e}get dbName(){return this.collection.dbName}get collectionName(){return this.collection.collectionName}get namespace(){return`${this.dbName}.${this.collectionName}`}get readConcern(){}get readPreference(){}get bsonOptions(){return{}}get writeConcern(){}get hint(){}set hint(e){throw new Error("Method not implemented.")}async insertOne(e,n){let t=await this.collection.insertOne(e,o(n));return{acknowledged:t.acknowledged,insertedId:t.insertedId}}async insertMany(e,n){let t=await this.collection.insertMany(e,o(n));return{acknowledged:t.acknowledged,insertedIds:t.insertedIds,insertedCount:t.insertedCount}}bulkWrite(e,n){throw new Error("Method not implemented.")}async updateOne(e,n,t){let i=await this.collection.updateOne(e,n,o(t));return{acknowledged:i.acknowledged,matchedCount:i.modifiedCount,modifiedCount:i.modifiedCount,upsertedCount:i.modifiedCount,upsertedId:null}}replaceOne(e,n,t){return this.collection.replaceOne(e,n,o(t))}async updateMany(e,n,t){let i=await this.collection.updateMany(e,n,o(t));return{acknowledged:i.acknowledged,matchedCount:i.modifiedCount,modifiedCount:i.modifiedCount,upsertedCount:i.modifiedCount,upsertedId:null}}async deleteOne(e,n){let t=await this.collection.deleteOne(e,o(n));return{acknowledged:t.acknowledged,deletedCount:t.deletedCount}}async deleteMany(e,n){let t=await this.collection.deleteMany(e,o(n));return{acknowledged:t.acknowledged,deletedCount:t.deletedCount}}async rename(e,n){return await this.collection.rename(e,o(n)),this}drop(e){return this.collection.drop(o(e))}async findOne(e,n){return this.collection.findOne(e,o(n))}find(e,n){return new s(this.collection.find(e,o(n)))}options(e){throw new Error("Method not implemented.")}isCapped(e){throw new Error("Method not implemented.")}createIndex(e,n){throw new Error("Method not implemented.")}createIndexes(e,n){throw new Error("Method not implemented.")}dropIndex(e,n){throw new Error("Method not implemented.")}dropIndexes(e){throw new Error("Method not implemented.")}listIndexes(e){throw new Error("Method not implemented.")}indexExists(e,n){throw new Error("Method not implemented.")}indexInformation(e){throw new Error("Method not implemented.")}estimatedDocumentCount(e){return this.collection.countDocuments({},o(e))}countDocuments(e,n){return this.collection.countDocuments(e,o(n))}distinct(e,n,t){throw new Error("Method not implemented.")}indexes(e){throw new Error("Method not implemented.")}findOneAndDelete(e,n){return this.collection.findOneAndDelete(e,o(n))}findOneAndReplace(e,n,t){return this.collection.findOneAndReplace(e,n,o(t))}findOneAndUpdate(e,n,t){return this.collection.findOneAndUpdate(e,n,o(t))}aggregate(e,n){throw new Error("Method not implemented.")}watch(e,n){throw new Error("Method not implemented.")}initializeUnorderedBulkOp(e){throw new Error("Method not implemented.")}initializeOrderedBulkOp(e){throw new Error("Method not implemented.")}count(e,n){return this.collection.countDocuments(_nullishCoalesce(e, () => ({})),o(n))}listSearchIndexes(e,n){throw new Error("Method not implemented.")}createSearchIndex(e){throw new Error("Method not implemented.")}createSearchIndexes(e){throw new Error("Method not implemented.")}dropSearchIndex(e){throw new Error("Method not implemented.")}updateSearchIndex(e,n){throw new Error("Method not implemented.")}async createCollection(){await this.collection.createCollection()}async handle(e,n,t){return this.collection.handle(e.toString(),n,t)}};var l=class{constructor(e){this.pongoDb=e}get databaseName(){return this.pongoDb.databaseName}collection(e){return new d(this.pongoDb.collection(e))}};var u=class{constructor(e,n={}){this.pongoClient=_chunk7GQ5BP22cjs.F.call(void 0, e,n)}async connect(){return await this.pongoClient.connect(),this}async close(){await this.pongoClient.close()}db(e){return new l(this.pongoClient.db(e))}startSession(e){return _chunk7GQ5BP22cjs.r.call(void 0, )}async withSession(e,n){let t=typeof e=="function"?e:n,i=_chunk7GQ5BP22cjs.r.call(void 0, );try{return await t(i)}finally{await i.endSession()}}};exports.Collection = d; exports.Db = l; exports.FindCursor = s; exports.MongoClient = u;
2
2
  //# sourceMappingURL=shim.cjs.map
package/dist/shim.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/shim.cjs","../src/mongo/findCursor.ts","../src/mongo/mongoDb.ts","../src/mongo/mongoCollection.ts"],"names":["FindCursor","documents","callback","docs","doc","toCollectionOperationOptions","options","Collection","collection"],"mappings":"AAAA,qvBAA+C,ICAlCA,CAAAA,WAAN,KAAoB,CACjB,eACA,SAAA,CAAwB,KAAA,gBACxB,KAAA,CAAgB,EAAA,WAExB,CAAYC,CAAAA,CAAyB,yEACnC,IAAA,CAAK,oBAAA,CAAuBA,CAC9B,CAEA,MAAM,OAAA,CAAA,CAAwB,CAC5B,OAAO,IAAA,CAAK,aAAA,CAAc,CAC5B,CAEA,MAAM,OAAA,CAAQC,CAAAA,CAA2C,CACvD,IAAMC,CAAAA,CAAO,MAAM,IAAA,CAAK,aAAA,CAAc,CAAA,CAEtC,GAAA,CAAA,IAAWC,EAAAA,GAAOD,CAAAA,CAChBD,CAAAA,CAASE,CAAG,CAAA,CAEd,OAAO,OAAA,CAAQ,OAAA,CAAQ,CACzB,CAEA,OAAA,CAAA,CAAmB,CACjB,EAAA,CAAI,IAAA,CAAK,SAAA,GAAc,IAAA,CAAM,MAAM,KAAA,CAAM,gCAAgC,CAAA,CACzE,OAAO,IAAA,CAAK,KAAA,CAAQ,IAAA,CAAK,SAAA,CAAU,MACrC,CAEA,MAAM,IAAA,CAAA,CAA0B,CAC9B,IAAMD,CAAAA,CAAO,MAAM,IAAA,CAAK,aAAA,CAAc,CAAA,CACtC,OAAO,IAAA,CAAK,OAAA,CAAQ,CAAA,kBAAKA,CAAAA,CAAK,IAAA,CAAK,KAAA,EAAO,CAAA,SAAK,MAAA,CAAQ,IACzD,CAEA,MAAc,aAAA,CAAA,CAA8B,CAC1C,OAAA,IAAA,CAAK,SAAA,CAAY,MAAM,IAAA,CAAK,oBAAA,CACrB,IAAA,CAAK,SACd,CACF,UAAA,CCpCA,mBAIO,ICoEDE,CAAAA,CACJC,CAAAA,kBAEAA,CAAAA,2BAAS,SAAA,CACL,CAAE,OAAA,CAASA,CAAAA,CAAQ,OAAmC,CAAA,CACtD,KAAA,CAAA,CAEOC,CAAAA,sBAAN,KAAmE,CAChE,WAER,CAAYC,CAAAA,CAAgC,CAC1C,IAAA,CAAK,UAAA,CAAaA,CACpB,CACA,IAAI,MAAA,CAAA,CAAiB,CACnB,OAAO,IAAA,CAAK,UAAA,CAAW,MACzB,CACA,IAAI,cAAA,CAAA,CAAyB,CAC3B,OAAO,IAAA,CAAK,UAAA,CAAW,cACzB,CACA,IAAI,SAAA,CAAA,CAAoB,CACtB,MAAO,CAAA,EAAA","file":"/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/shim.cjs","sourcesContent":[null,"export class FindCursor<T> {\n private findDocumentsPromise: Promise<T[]>;\n private documents: T[] | null = null;\n private index: number = 0;\n\n constructor(documents: Promise<T[]>) {\n this.findDocumentsPromise = documents;\n }\n\n async toArray(): Promise<T[]> {\n return this.findDocuments();\n }\n\n async forEach(callback: (doc: T) => void): Promise<void> {\n const docs = await this.findDocuments();\n\n for (const doc of docs) {\n callback(doc);\n }\n return Promise.resolve();\n }\n\n hasNext(): boolean {\n if (this.documents === null) throw Error('Error while fetching documents');\n return this.index < this.documents.length;\n }\n\n async next(): Promise<T | null> {\n const docs = await this.findDocuments();\n return this.hasNext() ? (docs[this.index++] ?? null) : null;\n }\n\n private async findDocuments(): Promise<T[]> {\n this.documents = await this.findDocumentsPromise;\n return this.documents;\n }\n}\n","import {\n Collection as MongoCollection,\n ObjectId,\n type Document,\n} from 'mongodb';\nimport type { DocumentHandler, PongoDb } from '../core';\nimport { Collection } from './mongoCollection';\n\nexport class Db {\n constructor(private pongoDb: PongoDb) {}\n\n get databaseName(): string {\n return this.pongoDb.databaseName;\n }\n\n collection<T extends Document>(\n collectionName: string,\n ): MongoCollection<T> & {\n handle(id: ObjectId, handle: DocumentHandler<T>): Promise<T | null>;\n } {\n return new Collection<T>(this.pongoDb.collection<T>(collectionName));\n }\n}\n","import type {\n AbstractCursorOptions,\n AggregateOptions,\n AggregationCursor,\n AnyBulkWriteOperation,\n BSONSerializeOptions,\n BulkWriteOptions,\n BulkWriteResult,\n ChangeStream,\n ChangeStreamDocument,\n ChangeStreamOptions,\n CommandOperationOptions,\n CountDocumentsOptions,\n CountOptions,\n CreateIndexesOptions,\n DeleteOptions,\n DeleteResult,\n Document,\n DropCollectionOptions,\n EnhancedOmit,\n EstimatedDocumentCountOptions,\n Filter,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n FindOptions,\n Flatten,\n Hint,\n IndexDescription,\n IndexDescriptionCompact,\n IndexDescriptionInfo,\n IndexInformationOptions,\n IndexSpecification,\n InferIdType,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListSearchIndexesCursor,\n ListSearchIndexesOptions,\n ModifyResult,\n Collection as MongoCollection,\n FindCursor as MongoFindCursor,\n ObjectId,\n OperationOptions,\n OptionalUnlessRequiredId,\n OrderedBulkOperation,\n ReadConcern,\n ReadPreference,\n RenameOptions,\n ReplaceOptions,\n SearchIndexDescription,\n UnorderedBulkOperation,\n UpdateFilter,\n UpdateOptions,\n UpdateResult,\n WithId,\n WithoutId,\n WriteConcern,\n} from 'mongodb';\nimport type { Key } from 'readline';\nimport type {\n CollectionOperationOptions,\n DocumentHandler,\n PongoCollection,\n PongoFilter,\n OptionalUnlessRequiredId as PongoOptionalUnlessRequiredId,\n PongoSession,\n PongoUpdate,\n} from '../core';\nimport { FindCursor } from './findCursor';\n\nconst toCollectionOperationOptions = (\n options: OperationOptions | undefined,\n): CollectionOperationOptions | undefined =>\n options?.session\n ? { session: options.session as unknown as PongoSession }\n : undefined;\n\nexport class Collection<T extends Document> implements MongoCollection<T> {\n private collection: PongoCollection<T>;\n\n constructor(collection: PongoCollection<T>) {\n this.collection = collection;\n }\n get dbName(): string {\n return this.collection.dbName;\n }\n get collectionName(): string {\n return this.collection.collectionName;\n }\n get namespace(): string {\n return `${this.dbName}.${this.collectionName}`;\n }\n get readConcern(): ReadConcern | undefined {\n return undefined;\n }\n get readPreference(): ReadPreference | undefined {\n return undefined;\n }\n get bsonOptions(): BSONSerializeOptions {\n return {};\n }\n get writeConcern(): WriteConcern | undefined {\n return undefined;\n }\n get hint(): Hint | undefined {\n return undefined;\n }\n set hint(v: Hint | undefined) {\n throw new Error('Method not implemented.');\n }\n async insertOne(\n doc: OptionalUnlessRequiredId<T>,\n options?: InsertOneOptions | undefined,\n ): Promise<InsertOneResult<T>> {\n const result = await this.collection.insertOne(\n doc as unknown as PongoOptionalUnlessRequiredId<T>,\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedId: result.insertedId as unknown as InferIdType<T>,\n };\n }\n async insertMany(\n docs: OptionalUnlessRequiredId<T>[],\n options?: BulkWriteOptions | undefined,\n ): Promise<InsertManyResult<T>> {\n const result = await this.collection.insertMany(\n docs as unknown as PongoOptionalUnlessRequiredId<T>[],\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedIds: result.insertedIds as unknown as InferIdType<T>[],\n insertedCount: result.insertedCount,\n };\n }\n bulkWrite(\n _operations: AnyBulkWriteOperation<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<BulkWriteResult> {\n throw new Error('Method not implemented.');\n }\n async updateOne(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateOne(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n replaceOne(\n filter: Filter<T>,\n document: WithoutId<T>,\n options?: ReplaceOptions | undefined,\n ): Promise<Document | UpdateResult<T>> {\n return this.collection.replaceOne(\n filter as unknown as PongoFilter<T>,\n document,\n toCollectionOperationOptions(options),\n );\n }\n async updateMany(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateMany(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n async deleteOne(\n filter?: Filter<T> | undefined,\n options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteOne(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async deleteMany(\n filter?: Filter<T> | undefined,\n options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteMany(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async rename(\n newName: string,\n options?: RenameOptions | undefined,\n ): Promise<Collection<Document>> {\n await this.collection.rename(\n newName,\n toCollectionOperationOptions(options),\n );\n\n return this as unknown as Collection<Document>;\n }\n drop(options?: DropCollectionOptions | undefined): Promise<boolean> {\n return this.collection.drop(toCollectionOperationOptions(options));\n }\n findOne(): Promise<WithId<T> | null>;\n findOne(filter: Filter<T>): Promise<WithId<T> | null>;\n findOne(\n filter: Filter<T>,\n options: FindOptions<Document>,\n ): Promise<WithId<T> | null>;\n findOne<TS = T>(): Promise<TS | null>;\n findOne<TS = T>(filter: Filter<TS>): Promise<TS | null>;\n findOne<TS = T>(\n filter: Filter<TS>,\n options?: FindOptions<Document> | undefined,\n ): Promise<TS | null>;\n async findOne(\n filter?: unknown,\n options?: FindOptions<Document> | undefined,\n ): Promise<import('mongodb').WithId<T> | T | null> {\n return this.collection.findOne(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n }\n find(): MongoFindCursor<WithId<T>>;\n find(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>>;\n find<T extends Document>(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<T>;\n find(\n filter?: unknown,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>> | MongoFindCursor<T> {\n return new FindCursor(\n this.collection.find(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n ),\n ) as unknown as MongoFindCursor<T>;\n }\n options(_options?: OperationOptions | undefined): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n isCapped(_options?: OperationOptions | undefined): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n createIndex(\n _indexSpec: IndexSpecification,\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createIndexes(\n _indexSpecs: IndexDescription[],\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropIndex(\n _indexName: string,\n _options?: CommandOperationOptions | undefined,\n ): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n dropIndexes(\n _options?: CommandOperationOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n listIndexes(_options?: AbstractCursorOptions | undefined): ListIndexesCursor {\n throw new Error('Method not implemented.');\n }\n indexExists(\n _indexes: string | string[],\n _options?: AbstractCursorOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n indexInformation(\n options: IndexInformationOptions & { full: true },\n ): Promise<IndexDescriptionInfo[]>;\n indexInformation(\n options: IndexInformationOptions & { full?: false | undefined },\n ): Promise<IndexDescriptionCompact>;\n indexInformation(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexInformation(): Promise<IndexDescriptionCompact>;\n indexInformation(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n estimatedDocumentCount(\n options?: EstimatedDocumentCountOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n {},\n toCollectionOperationOptions(options),\n );\n }\n countDocuments(\n filter?: Filter<T> | undefined,\n options?: CountDocumentsOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n }\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n options: CommandOperationOptions,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string): Promise<any[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string, filter: Filter<T>): Promise<any[]>;\n distinct(\n key: string,\n filter: Filter<T>,\n options: CommandOperationOptions, // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<any[]>;\n distinct(\n _key: unknown,\n _filter?: unknown,\n _options?: unknown,\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Promise<any[]>\n | Promise<import('mongodb').Flatten<import('mongodb').WithId<T>[Key]>[]> {\n throw new Error('Method not implemented.');\n }\n indexes(\n options: IndexInformationOptions & { full?: true | undefined },\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n options: IndexInformationOptions & { full: false },\n ): Promise<IndexDescriptionCompact>;\n indexes(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexes(\n options?: AbstractCursorOptions | undefined,\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null>;\n findOneAndDelete(filter: Filter<T>): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: unknown,\n options?: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndDelete(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: unknown,\n replacement: unknown,\n options?: FindOneAndReplaceOptions | undefined,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndReplace(\n filter as PongoFilter<T>,\n replacement as WithoutId<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: unknown,\n update: unknown,\n options?: FindOneAndUpdateOptions | undefined,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndUpdate(\n filter as PongoFilter<T>,\n update as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n aggregate<T extends Document = Document>(\n _pipeline?: Document[] | undefined,\n _options?: AggregateOptions | undefined,\n ): AggregationCursor<T> {\n throw new Error('Method not implemented.');\n }\n watch<\n TLocal extends Document = T,\n TChange extends Document = ChangeStreamDocument<TLocal>,\n >(\n _pipeline?: Document[] | undefined,\n _options?: ChangeStreamOptions | undefined,\n ): ChangeStream<TLocal, TChange> {\n throw new Error('Method not implemented.');\n }\n initializeUnorderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): UnorderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n initializeOrderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): OrderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n count(\n filter?: Filter<T> | undefined,\n options?: CountOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n (filter as PongoFilter<T>) ?? {},\n toCollectionOperationOptions(options),\n );\n }\n listSearchIndexes(\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n name: string,\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n _name?: unknown,\n _options?: unknown,\n ): import('mongodb').ListSearchIndexesCursor {\n throw new Error('Method not implemented.');\n }\n createSearchIndex(_description: SearchIndexDescription): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createSearchIndexes(\n _descriptions: SearchIndexDescription[],\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropSearchIndex(_name: string): Promise<void> {\n throw new Error('Method not implemented.');\n }\n updateSearchIndex(_name: string, _definition: Document): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async createCollection(): Promise<void> {\n await this.collection.createCollection();\n }\n async handle(id: ObjectId, handle: DocumentHandler<T>): Promise<T | null> {\n return this.collection.handle(id.toString(), handle);\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/shim.cjs","../src/mongo/findCursor.ts","../src/mongo/mongoDb.ts","../src/mongo/mongoCollection.ts"],"names":["FindCursor","documents","callback","docs","doc","toCollectionOperationOptions","options","Collection","collection"],"mappings":"AAAA,qvBAA+C,ICAlCA,CAAAA,WAAN,KAAoB,CACjB,eACA,SAAA,CAAwB,KAAA,gBACxB,KAAA,CAAgB,EAAA,WAExB,CAAYC,CAAAA,CAAyB,yEACnC,IAAA,CAAK,oBAAA,CAAuBA,CAC9B,CAEA,MAAM,OAAA,CAAA,CAAwB,CAC5B,OAAO,IAAA,CAAK,aAAA,CAAc,CAC5B,CAEA,MAAM,OAAA,CAAQC,CAAAA,CAA2C,CACvD,IAAMC,CAAAA,CAAO,MAAM,IAAA,CAAK,aAAA,CAAc,CAAA,CAEtC,GAAA,CAAA,IAAWC,EAAAA,GAAOD,CAAAA,CAChBD,CAAAA,CAASE,CAAG,CAAA,CAEd,OAAO,OAAA,CAAQ,OAAA,CAAQ,CACzB,CAEA,OAAA,CAAA,CAAmB,CACjB,EAAA,CAAI,IAAA,CAAK,SAAA,GAAc,IAAA,CAAM,MAAM,KAAA,CAAM,gCAAgC,CAAA,CACzE,OAAO,IAAA,CAAK,KAAA,CAAQ,IAAA,CAAK,SAAA,CAAU,MACrC,CAEA,MAAM,IAAA,CAAA,CAA0B,CAC9B,IAAMD,CAAAA,CAAO,MAAM,IAAA,CAAK,aAAA,CAAc,CAAA,CACtC,OAAO,IAAA,CAAK,OAAA,CAAQ,CAAA,kBAAKA,CAAAA,CAAK,IAAA,CAAK,KAAA,EAAO,CAAA,SAAK,MAAA,CAAQ,IACzD,CAEA,MAAc,aAAA,CAAA,CAA8B,CAC1C,OAAA,IAAA,CAAK,SAAA,CAAY,MAAM,IAAA,CAAK,oBAAA,CACrB,IAAA,CAAK,SACd,CACF,UAAA,CCpCA,mBAIO,ICsEDE,CAAAA,CACJC,CAAAA,kBAEAA,CAAAA,2BAAS,SAAA,CACL,CAAE,OAAA,CAASA,CAAAA,CAAQ,OAAmC,CAAA,CACtD,KAAA,CAAA,CAEOC,CAAAA,sBAAN,KAAmE,CAChE,WAER,CAAYC,CAAAA,CAAgC,CAC1C,IAAA,CAAK,UAAA,CAAaA,CACpB,CACA,IAAI,MAAA,CAAA,CAAiB,CACnB,OAAO,IAAA,CAAK,UAAA,CAAW,MACzB,CACA,IAAI,cAAA,CAAA,CAAyB,CAC3B,OAAO,IAAA,CAAK,UAAA,CAAW,cACzB,CACA,IAAI,SAAA,CAAA,CAAoB,CACtB,MAAO,CAAA,EAAA","file":"/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/shim.cjs","sourcesContent":[null,"export class FindCursor<T> {\n private findDocumentsPromise: Promise<T[]>;\n private documents: T[] | null = null;\n private index: number = 0;\n\n constructor(documents: Promise<T[]>) {\n this.findDocumentsPromise = documents;\n }\n\n async toArray(): Promise<T[]> {\n return this.findDocuments();\n }\n\n async forEach(callback: (doc: T) => void): Promise<void> {\n const docs = await this.findDocuments();\n\n for (const doc of docs) {\n callback(doc);\n }\n return Promise.resolve();\n }\n\n hasNext(): boolean {\n if (this.documents === null) throw Error('Error while fetching documents');\n return this.index < this.documents.length;\n }\n\n async next(): Promise<T | null> {\n const docs = await this.findDocuments();\n return this.hasNext() ? (docs[this.index++] ?? null) : null;\n }\n\n private async findDocuments(): Promise<T[]> {\n this.documents = await this.findDocumentsPromise;\n return this.documents;\n }\n}\n","import {\n Collection as MongoCollection,\n ObjectId,\n type Document,\n} from 'mongodb';\nimport type {\n DocumentHandler,\n HandleOptions,\n PongoDb,\n PongoHandleResult,\n} from '../core';\nimport { Collection } from './mongoCollection';\n\nexport class Db {\n constructor(private pongoDb: PongoDb) {}\n\n get databaseName(): string {\n return this.pongoDb.databaseName;\n }\n\n collection<T extends Document>(\n collectionName: string,\n ): MongoCollection<T> & {\n handle(\n id: ObjectId,\n handle: DocumentHandler<T>,\n options?: HandleOptions,\n ): Promise<PongoHandleResult<T>>;\n } {\n return new Collection<T>(this.pongoDb.collection<T>(collectionName));\n }\n}\n","import type {\n AbstractCursorOptions,\n AggregateOptions,\n AggregationCursor,\n AnyBulkWriteOperation,\n BSONSerializeOptions,\n BulkWriteOptions,\n BulkWriteResult,\n ChangeStream,\n ChangeStreamDocument,\n ChangeStreamOptions,\n CommandOperationOptions,\n CountDocumentsOptions,\n CountOptions,\n CreateIndexesOptions,\n DeleteOptions,\n DeleteResult,\n Document,\n DropCollectionOptions,\n EnhancedOmit,\n EstimatedDocumentCountOptions,\n Filter,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n FindOptions,\n Flatten,\n Hint,\n IndexDescription,\n IndexDescriptionCompact,\n IndexDescriptionInfo,\n IndexInformationOptions,\n IndexSpecification,\n InferIdType,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListSearchIndexesCursor,\n ListSearchIndexesOptions,\n ModifyResult,\n Collection as MongoCollection,\n FindCursor as MongoFindCursor,\n ObjectId,\n OperationOptions,\n OptionalUnlessRequiredId,\n OrderedBulkOperation,\n ReadConcern,\n ReadPreference,\n RenameOptions,\n ReplaceOptions,\n SearchIndexDescription,\n UnorderedBulkOperation,\n UpdateFilter,\n UpdateOptions,\n UpdateResult,\n WithId,\n WithoutId,\n WriteConcern,\n} from 'mongodb';\nimport type { Key } from 'readline';\nimport type {\n CollectionOperationOptions,\n DocumentHandler,\n HandleOptions,\n PongoCollection,\n PongoFilter,\n PongoHandleResult,\n OptionalUnlessRequiredId as PongoOptionalUnlessRequiredId,\n PongoSession,\n PongoUpdate,\n} from '../core';\nimport { FindCursor } from './findCursor';\n\nconst toCollectionOperationOptions = (\n options: OperationOptions | undefined,\n): CollectionOperationOptions | undefined =>\n options?.session\n ? { session: options.session as unknown as PongoSession }\n : undefined;\n\nexport class Collection<T extends Document> implements MongoCollection<T> {\n private collection: PongoCollection<T>;\n\n constructor(collection: PongoCollection<T>) {\n this.collection = collection;\n }\n get dbName(): string {\n return this.collection.dbName;\n }\n get collectionName(): string {\n return this.collection.collectionName;\n }\n get namespace(): string {\n return `${this.dbName}.${this.collectionName}`;\n }\n get readConcern(): ReadConcern | undefined {\n return undefined;\n }\n get readPreference(): ReadPreference | undefined {\n return undefined;\n }\n get bsonOptions(): BSONSerializeOptions {\n return {};\n }\n get writeConcern(): WriteConcern | undefined {\n return undefined;\n }\n get hint(): Hint | undefined {\n return undefined;\n }\n set hint(v: Hint | undefined) {\n throw new Error('Method not implemented.');\n }\n async insertOne(\n doc: OptionalUnlessRequiredId<T>,\n options?: InsertOneOptions | undefined,\n ): Promise<InsertOneResult<T>> {\n const result = await this.collection.insertOne(\n doc as unknown as PongoOptionalUnlessRequiredId<T>,\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedId: result.insertedId as unknown as InferIdType<T>,\n };\n }\n async insertMany(\n docs: OptionalUnlessRequiredId<T>[],\n options?: BulkWriteOptions | undefined,\n ): Promise<InsertManyResult<T>> {\n const result = await this.collection.insertMany(\n docs as unknown as PongoOptionalUnlessRequiredId<T>[],\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedIds: result.insertedIds as unknown as InferIdType<T>[],\n insertedCount: result.insertedCount,\n };\n }\n bulkWrite(\n _operations: AnyBulkWriteOperation<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<BulkWriteResult> {\n throw new Error('Method not implemented.');\n }\n async updateOne(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateOne(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n replaceOne(\n filter: Filter<T>,\n document: WithoutId<T>,\n options?: ReplaceOptions | undefined,\n ): Promise<Document | UpdateResult<T>> {\n return this.collection.replaceOne(\n filter as unknown as PongoFilter<T>,\n document,\n toCollectionOperationOptions(options),\n );\n }\n async updateMany(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateMany(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n async deleteOne(\n filter?: Filter<T> | undefined,\n options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteOne(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async deleteMany(\n filter?: Filter<T> | undefined,\n options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteMany(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async rename(\n newName: string,\n options?: RenameOptions | undefined,\n ): Promise<Collection<Document>> {\n await this.collection.rename(\n newName,\n toCollectionOperationOptions(options),\n );\n\n return this as unknown as Collection<Document>;\n }\n drop(options?: DropCollectionOptions | undefined): Promise<boolean> {\n return this.collection.drop(toCollectionOperationOptions(options));\n }\n findOne(): Promise<WithId<T> | null>;\n findOne(filter: Filter<T>): Promise<WithId<T> | null>;\n findOne(\n filter: Filter<T>,\n options: FindOptions<Document>,\n ): Promise<WithId<T> | null>;\n findOne<TS = T>(): Promise<TS | null>;\n findOne<TS = T>(filter: Filter<TS>): Promise<TS | null>;\n findOne<TS = T>(\n filter: Filter<TS>,\n options?: FindOptions<Document> | undefined,\n ): Promise<TS | null>;\n async findOne(\n filter?: unknown,\n options?: FindOptions<Document> | undefined,\n ): Promise<import('mongodb').WithId<T> | T | null> {\n return this.collection.findOne(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n }\n find(): MongoFindCursor<WithId<T>>;\n find(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>>;\n find<T extends Document>(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<T>;\n find(\n filter?: unknown,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>> | MongoFindCursor<T> {\n return new FindCursor(\n this.collection.find(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n ),\n ) as unknown as MongoFindCursor<T>;\n }\n options(_options?: OperationOptions | undefined): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n isCapped(_options?: OperationOptions | undefined): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n createIndex(\n _indexSpec: IndexSpecification,\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createIndexes(\n _indexSpecs: IndexDescription[],\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropIndex(\n _indexName: string,\n _options?: CommandOperationOptions | undefined,\n ): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n dropIndexes(\n _options?: CommandOperationOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n listIndexes(_options?: AbstractCursorOptions | undefined): ListIndexesCursor {\n throw new Error('Method not implemented.');\n }\n indexExists(\n _indexes: string | string[],\n _options?: AbstractCursorOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n indexInformation(\n options: IndexInformationOptions & { full: true },\n ): Promise<IndexDescriptionInfo[]>;\n indexInformation(\n options: IndexInformationOptions & { full?: false | undefined },\n ): Promise<IndexDescriptionCompact>;\n indexInformation(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexInformation(): Promise<IndexDescriptionCompact>;\n indexInformation(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n estimatedDocumentCount(\n options?: EstimatedDocumentCountOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n {},\n toCollectionOperationOptions(options),\n );\n }\n countDocuments(\n filter?: Filter<T> | undefined,\n options?: CountDocumentsOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n );\n }\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n options: CommandOperationOptions,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string): Promise<any[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string, filter: Filter<T>): Promise<any[]>;\n distinct(\n key: string,\n filter: Filter<T>,\n options: CommandOperationOptions, // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<any[]>;\n distinct(\n _key: unknown,\n _filter?: unknown,\n _options?: unknown,\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Promise<any[]>\n | Promise<import('mongodb').Flatten<import('mongodb').WithId<T>[Key]>[]> {\n throw new Error('Method not implemented.');\n }\n indexes(\n options: IndexInformationOptions & { full?: true | undefined },\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n options: IndexInformationOptions & { full: false },\n ): Promise<IndexDescriptionCompact>;\n indexes(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexes(\n options?: AbstractCursorOptions | undefined,\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null>;\n findOneAndDelete(filter: Filter<T>): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: unknown,\n options?: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndDelete(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n options: FindOneAndReplaceOptions,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: Filter<T>,\n replacement: WithoutId<T>,\n ): Promise<WithId<T> | null>;\n findOneAndReplace(\n filter: unknown,\n replacement: unknown,\n options?: FindOneAndReplaceOptions | undefined,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndReplace(\n filter as PongoFilter<T>,\n replacement as WithoutId<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n options: FindOneAndUpdateOptions,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: Filter<T>,\n update: UpdateFilter<T>,\n ): Promise<WithId<T> | null>;\n findOneAndUpdate(\n filter: unknown,\n update: unknown,\n options?: FindOneAndUpdateOptions | undefined,\n ): Promise<WithId<T> | null | ModifyResult<T>> {\n return this.collection.findOneAndUpdate(\n filter as PongoFilter<T>,\n update as PongoUpdate<T>,\n toCollectionOperationOptions(options),\n ) as Promise<WithId<T> | null>;\n }\n aggregate<T extends Document = Document>(\n _pipeline?: Document[] | undefined,\n _options?: AggregateOptions | undefined,\n ): AggregationCursor<T> {\n throw new Error('Method not implemented.');\n }\n watch<\n TLocal extends Document = T,\n TChange extends Document = ChangeStreamDocument<TLocal>,\n >(\n _pipeline?: Document[] | undefined,\n _options?: ChangeStreamOptions | undefined,\n ): ChangeStream<TLocal, TChange> {\n throw new Error('Method not implemented.');\n }\n initializeUnorderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): UnorderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n initializeOrderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): OrderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n count(\n filter?: Filter<T> | undefined,\n options?: CountOptions | undefined,\n ): Promise<number> {\n return this.collection.countDocuments(\n (filter as PongoFilter<T>) ?? {},\n toCollectionOperationOptions(options),\n );\n }\n listSearchIndexes(\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n name: string,\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n _name?: unknown,\n _options?: unknown,\n ): import('mongodb').ListSearchIndexesCursor {\n throw new Error('Method not implemented.');\n }\n createSearchIndex(_description: SearchIndexDescription): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createSearchIndexes(\n _descriptions: SearchIndexDescription[],\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropSearchIndex(_name: string): Promise<void> {\n throw new Error('Method not implemented.');\n }\n updateSearchIndex(_name: string, _definition: Document): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async createCollection(): Promise<void> {\n await this.collection.createCollection();\n }\n async handle(\n id: ObjectId,\n handle: DocumentHandler<T>,\n options?: HandleOptions,\n ): Promise<PongoHandleResult<T>> {\n return this.collection.handle(id.toString(), handle, options);\n }\n}\n"]}
package/dist/shim.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ClientSessionOptions } from 'http2';
2
2
  import { Document, Collection as Collection$1, ObjectId, ClientSession, WithSessionCallback, ReadConcern, ReadPreference, BSONSerializeOptions, WriteConcern, Hint, OptionalUnlessRequiredId, InsertOneOptions, InsertOneResult, BulkWriteOptions, InsertManyResult, AnyBulkWriteOperation, BulkWriteResult, Filter, UpdateFilter, UpdateOptions, UpdateResult, WithoutId, ReplaceOptions, DeleteOptions, DeleteResult, RenameOptions, DropCollectionOptions, WithId, FindOptions, FindCursor as FindCursor$1, OperationOptions, IndexSpecification, CreateIndexesOptions, IndexDescription, CommandOperationOptions, AbstractCursorOptions, ListIndexesCursor, IndexInformationOptions, IndexDescriptionInfo, IndexDescriptionCompact, EstimatedDocumentCountOptions, CountDocumentsOptions, EnhancedOmit, Flatten, FindOneAndDeleteOptions, ModifyResult, FindOneAndReplaceOptions, FindOneAndUpdateOptions, AggregateOptions, AggregationCursor, ChangeStreamDocument, ChangeStreamOptions, ChangeStream, UnorderedBulkOperation, OrderedBulkOperation, CountOptions, ListSearchIndexesOptions, ListSearchIndexesCursor, SearchIndexDescription } from 'mongodb';
3
- import { P as PongoDb, a6 as DocumentHandler, w as PongoClientOptions, b as PongoCollection } from './pongoClient-BsMs5Zc7.cjs';
3
+ import { P as PongoDb, av as DocumentHandler, K as HandleOptions, au as PongoHandleResult, i as PongoClientOptions, b as PongoCollection } from './pongoClient-BY509WFi.cjs';
4
4
  import '@event-driven-io/dumbo';
5
5
  import 'pg';
6
6
 
@@ -21,7 +21,7 @@ declare class Db {
21
21
  constructor(pongoDb: PongoDb);
22
22
  get databaseName(): string;
23
23
  collection<T extends Document>(collectionName: string): Collection$1<T> & {
24
- handle(id: ObjectId, handle: DocumentHandler<T>): Promise<T | null>;
24
+ handle(id: ObjectId, handle: DocumentHandler<T>, options?: HandleOptions): Promise<PongoHandleResult<T>>;
25
25
  };
26
26
  }
27
27
 
@@ -135,7 +135,7 @@ declare class Collection<T extends Document> implements Collection$1<T> {
135
135
  dropSearchIndex(_name: string): Promise<void>;
136
136
  updateSearchIndex(_name: string, _definition: Document): Promise<void>;
137
137
  createCollection(): Promise<void>;
138
- handle(id: ObjectId, handle: DocumentHandler<T>): Promise<T | null>;
138
+ handle(id: ObjectId, handle: DocumentHandler<T>, options?: HandleOptions): Promise<PongoHandleResult<T>>;
139
139
  }
140
140
 
141
141
  export { Collection, Db, FindCursor, MongoClient };
package/dist/shim.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ClientSessionOptions } from 'http2';
2
2
  import { Document, Collection as Collection$1, ObjectId, ClientSession, WithSessionCallback, ReadConcern, ReadPreference, BSONSerializeOptions, WriteConcern, Hint, OptionalUnlessRequiredId, InsertOneOptions, InsertOneResult, BulkWriteOptions, InsertManyResult, AnyBulkWriteOperation, BulkWriteResult, Filter, UpdateFilter, UpdateOptions, UpdateResult, WithoutId, ReplaceOptions, DeleteOptions, DeleteResult, RenameOptions, DropCollectionOptions, WithId, FindOptions, FindCursor as FindCursor$1, OperationOptions, IndexSpecification, CreateIndexesOptions, IndexDescription, CommandOperationOptions, AbstractCursorOptions, ListIndexesCursor, IndexInformationOptions, IndexDescriptionInfo, IndexDescriptionCompact, EstimatedDocumentCountOptions, CountDocumentsOptions, EnhancedOmit, Flatten, FindOneAndDeleteOptions, ModifyResult, FindOneAndReplaceOptions, FindOneAndUpdateOptions, AggregateOptions, AggregationCursor, ChangeStreamDocument, ChangeStreamOptions, ChangeStream, UnorderedBulkOperation, OrderedBulkOperation, CountOptions, ListSearchIndexesOptions, ListSearchIndexesCursor, SearchIndexDescription } from 'mongodb';
3
- import { P as PongoDb, a6 as DocumentHandler, w as PongoClientOptions, b as PongoCollection } from './pongoClient-BsMs5Zc7.js';
3
+ import { P as PongoDb, av as DocumentHandler, K as HandleOptions, au as PongoHandleResult, i as PongoClientOptions, b as PongoCollection } from './pongoClient-BY509WFi.js';
4
4
  import '@event-driven-io/dumbo';
5
5
  import 'pg';
6
6
 
@@ -21,7 +21,7 @@ declare class Db {
21
21
  constructor(pongoDb: PongoDb);
22
22
  get databaseName(): string;
23
23
  collection<T extends Document>(collectionName: string): Collection$1<T> & {
24
- handle(id: ObjectId, handle: DocumentHandler<T>): Promise<T | null>;
24
+ handle(id: ObjectId, handle: DocumentHandler<T>, options?: HandleOptions): Promise<PongoHandleResult<T>>;
25
25
  };
26
26
  }
27
27
 
@@ -135,7 +135,7 @@ declare class Collection<T extends Document> implements Collection$1<T> {
135
135
  dropSearchIndex(_name: string): Promise<void>;
136
136
  updateSearchIndex(_name: string, _definition: Document): Promise<void>;
137
137
  createCollection(): Promise<void>;
138
- handle(id: ObjectId, handle: DocumentHandler<T>): Promise<T | null>;
138
+ handle(id: ObjectId, handle: DocumentHandler<T>, options?: HandleOptions): Promise<PongoHandleResult<T>>;
139
139
  }
140
140
 
141
141
  export { Collection, Db, FindCursor, MongoClient };