@event-driven-io/pongo 0.17.0-beta.4 → 0.17.0-beta.40

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.
Files changed (67) hide show
  1. package/dist/cli.cjs +311 -487
  2. package/dist/cli.cjs.map +1 -1
  3. package/dist/cli.d.cts +4 -4
  4. package/dist/cli.d.ts +4 -3
  5. package/dist/cli.js +279 -487
  6. package/dist/cli.js.map +1 -1
  7. package/dist/cloudflare.cjs +41 -0
  8. package/dist/cloudflare.cjs.map +1 -0
  9. package/dist/cloudflare.d.cts +12 -0
  10. package/dist/cloudflare.d.ts +12 -0
  11. package/dist/cloudflare.js +35 -0
  12. package/dist/cloudflare.js.map +1 -0
  13. package/dist/core-BHdOCUrr.js +1429 -0
  14. package/dist/core-BHdOCUrr.js.map +1 -0
  15. package/dist/core-C9SB3XMx.cjs +1717 -0
  16. package/dist/core-C9SB3XMx.cjs.map +1 -0
  17. package/dist/core-CH0SOCr3.js +361 -0
  18. package/dist/core-CH0SOCr3.js.map +1 -0
  19. package/dist/core-CkmE5dkK.cjs +373 -0
  20. package/dist/core-CkmE5dkK.cjs.map +1 -0
  21. package/dist/index-C3pnS1S_.d.cts +720 -0
  22. package/dist/index-CZOmOsQt.d.ts +10 -0
  23. package/dist/index-FXnldVnn.d.cts +10 -0
  24. package/dist/index-r7V4paf_.d.ts +720 -0
  25. package/dist/index.cjs +67 -74
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +16 -105
  28. package/dist/index.d.ts +16 -105
  29. package/dist/index.js +17 -73
  30. package/dist/index.js.map +1 -1
  31. package/dist/pg.cjs +319 -288
  32. package/dist/pg.cjs.map +1 -1
  33. package/dist/pg.d.cts +29 -25
  34. package/dist/pg.d.ts +29 -25
  35. package/dist/pg.js +309 -284
  36. package/dist/pg.js.map +1 -1
  37. package/dist/shim.cjs +291 -368
  38. package/dist/shim.cjs.map +1 -1
  39. package/dist/shim.d.cts +141 -137
  40. package/dist/shim.d.ts +141 -137
  41. package/dist/shim.js +285 -367
  42. package/dist/shim.js.map +1 -1
  43. package/dist/sqlite3.cjs +43 -62
  44. package/dist/sqlite3.cjs.map +1 -1
  45. package/dist/sqlite3.d.cts +12 -11
  46. package/dist/sqlite3.d.ts +12 -11
  47. package/dist/sqlite3.js +36 -61
  48. package/dist/sqlite3.js.map +1 -1
  49. package/package.json +42 -44
  50. package/dist/chunk-4BL6YWLW.cjs +0 -872
  51. package/dist/chunk-4BL6YWLW.cjs.map +0 -1
  52. package/dist/chunk-ECQ2CKZE.cjs +0 -330
  53. package/dist/chunk-ECQ2CKZE.cjs.map +0 -1
  54. package/dist/chunk-NCNRRYVE.js +0 -872
  55. package/dist/chunk-NCNRRYVE.js.map +0 -1
  56. package/dist/chunk-Y7LRKJLJ.js +0 -330
  57. package/dist/chunk-Y7LRKJLJ.js.map +0 -1
  58. package/dist/d1.cjs +0 -53
  59. package/dist/d1.cjs.map +0 -1
  60. package/dist/d1.d.cts +0 -11
  61. package/dist/d1.d.ts +0 -11
  62. package/dist/d1.js +0 -53
  63. package/dist/d1.js.map +0 -1
  64. package/dist/index-BJopB-em.d.cts +0 -7
  65. package/dist/index-G5DECNb_.d.ts +0 -7
  66. package/dist/pongoCollectionSchemaComponent-t_e9n2Wc.d.cts +0 -426
  67. package/dist/pongoCollectionSchemaComponent-t_e9n2Wc.d.ts +0 -426
package/dist/shim.js CHANGED
@@ -1,381 +1,299 @@
1
- import {
2
- pongoClient,
3
- pongoSession
4
- } from "./chunk-NCNRRYVE.js";
1
+ import { o as pongoClient, s as pongoSession } from "./core-BHdOCUrr.js";
2
+ import { parseConnectionString, toDatabaseDriverType } from "@event-driven-io/dumbo";
5
3
 
6
- // src/mongo/findCursor.ts
4
+ //#region src/mongo/findCursor.ts
7
5
  var FindCursor = class {
8
- findDocumentsPromise;
9
- documents = null;
10
- index = 0;
11
- constructor(documents) {
12
- this.findDocumentsPromise = documents;
13
- }
14
- async toArray() {
15
- return this.findDocuments();
16
- }
17
- async forEach(callback) {
18
- const docs = await this.findDocuments();
19
- for (const doc of docs) {
20
- callback(doc);
21
- }
22
- return Promise.resolve();
23
- }
24
- hasNext() {
25
- if (this.documents === null) throw Error("Error while fetching documents");
26
- return this.index < this.documents.length;
27
- }
28
- async next() {
29
- const docs = await this.findDocuments();
30
- return this.hasNext() ? docs[this.index++] ?? null : null;
31
- }
32
- async findDocuments() {
33
- this.documents = await this.findDocumentsPromise;
34
- return this.documents;
35
- }
6
+ findDocumentsPromise;
7
+ documents = null;
8
+ index = 0;
9
+ constructor(documents) {
10
+ this.findDocumentsPromise = documents;
11
+ }
12
+ async toArray() {
13
+ return this.findDocuments();
14
+ }
15
+ async forEach(callback) {
16
+ const docs = await this.findDocuments();
17
+ for (const doc of docs) callback(doc);
18
+ return Promise.resolve();
19
+ }
20
+ hasNext() {
21
+ if (this.documents === null) throw Error("Error while fetching documents");
22
+ return this.index < this.documents.length;
23
+ }
24
+ async next() {
25
+ const docs = await this.findDocuments();
26
+ return this.hasNext() ? docs[this.index++] ?? null : null;
27
+ }
28
+ async findDocuments() {
29
+ this.documents = await this.findDocumentsPromise;
30
+ return this.documents;
31
+ }
36
32
  };
37
33
 
38
- // src/mongo/mongoClient.ts
39
- import {
40
- parseConnectionString,
41
- toDatabaseDriverType
42
- } from "@event-driven-io/dumbo";
43
- import "http2";
44
-
45
- // src/mongo/mongoDb.ts
46
- import "mongodb";
47
-
48
- // src/mongo/mongoCollection.ts
49
- var toCollectionOperationOptions = (options) => options?.session ? { session: options.session } : void 0;
50
- var toFindOptions = (options) => {
51
- if (!options?.session && !options?.limit && !options?.skip) {
52
- return void 0;
53
- }
54
- const pongoFindOptions = {};
55
- if (options?.session) {
56
- pongoFindOptions.session = options.session;
57
- }
58
- if (options?.limit !== void 0) {
59
- pongoFindOptions.limit = options.limit;
60
- }
61
- if (options?.skip !== void 0) {
62
- pongoFindOptions.skip = options.skip;
63
- }
64
- return pongoFindOptions;
34
+ //#endregion
35
+ //#region src/mongo/mongoCollection.ts
36
+ const toCollectionOperationOptions = (options) => options?.session ? { session: options.session } : void 0;
37
+ const toFindOptions = (options) => {
38
+ if (!options?.session && !options?.limit && !options?.skip && !options?.sort) return;
39
+ const pongoFindOptions = {};
40
+ if (options?.session) pongoFindOptions.session = options.session;
41
+ if (options?.limit !== void 0) pongoFindOptions.limit = options.limit;
42
+ if (options?.skip !== void 0) pongoFindOptions.skip = options.skip;
43
+ if (options?.sort !== void 0) pongoFindOptions.sort = options.sort;
44
+ return pongoFindOptions;
65
45
  };
66
46
  var Collection = class {
67
- collection;
68
- database;
69
- constructor(database, collection) {
70
- this.collection = collection;
71
- this.database = database;
72
- }
73
- get db() {
74
- return this.database;
75
- }
76
- get dbName() {
77
- return this.collection.dbName;
78
- }
79
- get collectionName() {
80
- return this.collection.collectionName;
81
- }
82
- get namespace() {
83
- return `${this.dbName}.${this.collectionName}`;
84
- }
85
- get readConcern() {
86
- return void 0;
87
- }
88
- get readPreference() {
89
- return void 0;
90
- }
91
- get bsonOptions() {
92
- return {};
93
- }
94
- get writeConcern() {
95
- return void 0;
96
- }
97
- get hint() {
98
- return void 0;
99
- }
100
- get timeoutMS() {
101
- return void 0;
102
- }
103
- set hint(v) {
104
- throw new Error("Method not implemented.");
105
- }
106
- async insertOne(doc, options) {
107
- const result = await this.collection.insertOne(
108
- doc,
109
- toCollectionOperationOptions(options)
110
- );
111
- return {
112
- acknowledged: result.acknowledged,
113
- insertedId: result.insertedId
114
- };
115
- }
116
- async insertMany(docs, options) {
117
- const result = await this.collection.insertMany(
118
- docs,
119
- toCollectionOperationOptions(options)
120
- );
121
- return {
122
- acknowledged: result.acknowledged,
123
- insertedIds: result.insertedIds,
124
- insertedCount: result.insertedCount
125
- };
126
- }
127
- bulkWrite(_operations, _options) {
128
- throw new Error("Method not implemented.");
129
- }
130
- async updateOne(filter, update, options) {
131
- const result = await this.collection.updateOne(
132
- filter,
133
- update,
134
- toCollectionOperationOptions(options)
135
- );
136
- return {
137
- acknowledged: result.acknowledged,
138
- matchedCount: result.modifiedCount,
139
- modifiedCount: result.modifiedCount,
140
- upsertedCount: result.modifiedCount,
141
- upsertedId: null
142
- };
143
- }
144
- replaceOne(filter, document, options) {
145
- return this.collection.replaceOne(
146
- filter,
147
- document,
148
- toCollectionOperationOptions(options)
149
- );
150
- }
151
- async updateMany(filter, update, options) {
152
- const result = await this.collection.updateMany(
153
- filter,
154
- update,
155
- toCollectionOperationOptions(options)
156
- );
157
- return {
158
- acknowledged: result.acknowledged,
159
- matchedCount: result.modifiedCount,
160
- modifiedCount: result.modifiedCount,
161
- upsertedCount: result.modifiedCount,
162
- upsertedId: null
163
- };
164
- }
165
- async deleteOne(filter, options) {
166
- const result = await this.collection.deleteOne(
167
- filter,
168
- toCollectionOperationOptions(options)
169
- );
170
- return {
171
- acknowledged: result.acknowledged,
172
- deletedCount: result.deletedCount
173
- };
174
- }
175
- async deleteMany(filter, options) {
176
- const result = await this.collection.deleteMany(
177
- filter,
178
- toCollectionOperationOptions(options)
179
- );
180
- return {
181
- acknowledged: result.acknowledged,
182
- deletedCount: result.deletedCount
183
- };
184
- }
185
- async rename(newName, options) {
186
- await this.collection.rename(
187
- newName,
188
- toCollectionOperationOptions(options)
189
- );
190
- return this;
191
- }
192
- drop(options) {
193
- return this.collection.drop(toCollectionOperationOptions(options));
194
- }
195
- async findOne(filter, options) {
196
- return await this.collection.findOne(
197
- filter,
198
- toCollectionOperationOptions(options)
199
- );
200
- }
201
- find(filter, options) {
202
- return new FindCursor(
203
- this.collection.find(filter, toFindOptions(options))
204
- );
205
- }
206
- options(_options) {
207
- throw new Error("Method not implemented.");
208
- }
209
- isCapped(_options) {
210
- throw new Error("Method not implemented.");
211
- }
212
- createIndex(_indexSpec, _options) {
213
- throw new Error("Method not implemented.");
214
- }
215
- createIndexes(_indexSpecs, _options) {
216
- throw new Error("Method not implemented.");
217
- }
218
- dropIndex(_indexName, _options) {
219
- throw new Error("Method not implemented.");
220
- }
221
- dropIndexes(_options) {
222
- throw new Error("Method not implemented.");
223
- }
224
- listIndexes(_options) {
225
- throw new Error("Method not implemented.");
226
- }
227
- indexExists(_indexes, _options) {
228
- throw new Error("Method not implemented.");
229
- }
230
- indexInformation(_options) {
231
- throw new Error("Method not implemented.");
232
- }
233
- estimatedDocumentCount(options) {
234
- return this.collection.countDocuments(
235
- {},
236
- toCollectionOperationOptions(options)
237
- );
238
- }
239
- countDocuments(filter, options) {
240
- return this.collection.countDocuments(
241
- filter,
242
- toCollectionOperationOptions(options)
243
- );
244
- }
245
- distinct(_key, _filter, _options) {
246
- throw new Error("Method not implemented.");
247
- }
248
- indexes(_options) {
249
- throw new Error("Method not implemented.");
250
- }
251
- findOneAndDelete(filter, options) {
252
- return this.collection.findOneAndDelete(
253
- filter,
254
- toCollectionOperationOptions(options)
255
- );
256
- }
257
- findOneAndReplace(filter, replacement, options) {
258
- return this.collection.findOneAndReplace(
259
- filter,
260
- replacement,
261
- toCollectionOperationOptions(options)
262
- );
263
- }
264
- findOneAndUpdate(filter, update, options) {
265
- return this.collection.findOneAndUpdate(
266
- filter,
267
- update,
268
- toCollectionOperationOptions(options)
269
- );
270
- }
271
- aggregate(_pipeline, _options) {
272
- throw new Error("Method not implemented.");
273
- }
274
- watch(_pipeline, _options) {
275
- throw new Error("Method not implemented.");
276
- }
277
- initializeUnorderedBulkOp(_options) {
278
- throw new Error("Method not implemented.");
279
- }
280
- initializeOrderedBulkOp(_options) {
281
- throw new Error("Method not implemented.");
282
- }
283
- count(filter, options) {
284
- return this.collection.countDocuments(
285
- filter ?? {},
286
- toCollectionOperationOptions(options)
287
- );
288
- }
289
- listSearchIndexes(_name, _options) {
290
- throw new Error("Method not implemented.");
291
- }
292
- createSearchIndex(_description) {
293
- throw new Error("Method not implemented.");
294
- }
295
- createSearchIndexes(_descriptions) {
296
- throw new Error("Method not implemented.");
297
- }
298
- dropSearchIndex(_name) {
299
- throw new Error("Method not implemented.");
300
- }
301
- updateSearchIndex(_name, _definition) {
302
- throw new Error("Method not implemented.");
303
- }
304
- async createCollection() {
305
- await this.collection.createCollection();
306
- }
307
- async handle(id, handle, options) {
308
- return this.collection.handle(id.toString(), handle, options);
309
- }
47
+ collection;
48
+ database;
49
+ constructor(database, collection) {
50
+ this.collection = collection;
51
+ this.database = database;
52
+ }
53
+ get db() {
54
+ return this.database;
55
+ }
56
+ get dbName() {
57
+ return this.collection.dbName;
58
+ }
59
+ get collectionName() {
60
+ return this.collection.collectionName;
61
+ }
62
+ get namespace() {
63
+ return `${this.dbName}.${this.collectionName}`;
64
+ }
65
+ get readConcern() {}
66
+ get readPreference() {}
67
+ get bsonOptions() {
68
+ return {};
69
+ }
70
+ get writeConcern() {}
71
+ get hint() {}
72
+ get timeoutMS() {}
73
+ set hint(v) {
74
+ throw new Error("Method not implemented.");
75
+ }
76
+ async insertOne(doc, options) {
77
+ const result = await this.collection.insertOne(doc, toCollectionOperationOptions(options));
78
+ return {
79
+ acknowledged: result.acknowledged,
80
+ insertedId: result.insertedId
81
+ };
82
+ }
83
+ async insertMany(docs, options) {
84
+ const result = await this.collection.insertMany(docs, toCollectionOperationOptions(options));
85
+ return {
86
+ acknowledged: result.acknowledged,
87
+ insertedIds: result.insertedIds,
88
+ insertedCount: result.insertedCount
89
+ };
90
+ }
91
+ bulkWrite(_operations, _options) {
92
+ throw new Error("Method not implemented.");
93
+ }
94
+ async updateOne(filter, update, options) {
95
+ const result = await this.collection.updateOne(filter, update, toCollectionOperationOptions(options));
96
+ return {
97
+ acknowledged: result.acknowledged,
98
+ matchedCount: result.matchedCount,
99
+ modifiedCount: result.modifiedCount,
100
+ upsertedCount: result.upsertedCount,
101
+ upsertedId: result.upsertedId
102
+ };
103
+ }
104
+ async replaceOne(filter, document, options) {
105
+ const result = await this.collection.replaceOne(filter, document, {
106
+ ...toCollectionOperationOptions(options),
107
+ upsert: options?.upsert ?? false
108
+ });
109
+ return {
110
+ acknowledged: result.acknowledged,
111
+ matchedCount: result.matchedCount,
112
+ modifiedCount: result.modifiedCount,
113
+ upsertedCount: result.upsertedCount,
114
+ upsertedId: result.upsertedId
115
+ };
116
+ }
117
+ async updateMany(filter, update, options) {
118
+ const result = await this.collection.updateMany(filter, update, toCollectionOperationOptions(options));
119
+ return {
120
+ acknowledged: result.acknowledged,
121
+ matchedCount: result.matchedCount,
122
+ modifiedCount: result.modifiedCount,
123
+ upsertedCount: 0,
124
+ upsertedId: null
125
+ };
126
+ }
127
+ async deleteOne(filter, options) {
128
+ const result = await this.collection.deleteOne(filter, toCollectionOperationOptions(options));
129
+ return {
130
+ acknowledged: result.acknowledged,
131
+ deletedCount: result.deletedCount
132
+ };
133
+ }
134
+ async deleteMany(filter, options) {
135
+ const result = await this.collection.deleteMany(filter, toCollectionOperationOptions(options));
136
+ return {
137
+ acknowledged: result.acknowledged,
138
+ deletedCount: result.deletedCount
139
+ };
140
+ }
141
+ async rename(newName, options) {
142
+ await this.collection.rename(newName, toCollectionOperationOptions(options));
143
+ return this;
144
+ }
145
+ drop(options) {
146
+ return this.collection.drop(toCollectionOperationOptions(options));
147
+ }
148
+ async findOne(filter, options) {
149
+ return await this.collection.findOne(filter, toCollectionOperationOptions(options));
150
+ }
151
+ find(filter, options) {
152
+ return new FindCursor(this.collection.find(filter, toFindOptions(options)));
153
+ }
154
+ options(_options) {
155
+ throw new Error("Method not implemented.");
156
+ }
157
+ isCapped(_options) {
158
+ throw new Error("Method not implemented.");
159
+ }
160
+ createIndex(_indexSpec, _options) {
161
+ throw new Error("Method not implemented.");
162
+ }
163
+ createIndexes(_indexSpecs, _options) {
164
+ throw new Error("Method not implemented.");
165
+ }
166
+ dropIndex(_indexName, _options) {
167
+ throw new Error("Method not implemented.");
168
+ }
169
+ dropIndexes(_options) {
170
+ throw new Error("Method not implemented.");
171
+ }
172
+ listIndexes(_options) {
173
+ throw new Error("Method not implemented.");
174
+ }
175
+ indexExists(_indexes, _options) {
176
+ throw new Error("Method not implemented.");
177
+ }
178
+ indexInformation(_options) {
179
+ throw new Error("Method not implemented.");
180
+ }
181
+ estimatedDocumentCount(options) {
182
+ return this.collection.countDocuments({}, toCollectionOperationOptions(options));
183
+ }
184
+ countDocuments(filter, options) {
185
+ return this.collection.countDocuments(filter, toCollectionOperationOptions(options));
186
+ }
187
+ distinct(_key, _filter, _options) {
188
+ throw new Error("Method not implemented.");
189
+ }
190
+ indexes(_options) {
191
+ throw new Error("Method not implemented.");
192
+ }
193
+ findOneAndDelete(filter, options) {
194
+ return this.collection.findOneAndDelete(filter, toCollectionOperationOptions(options));
195
+ }
196
+ findOneAndReplace(filter, replacement, options) {
197
+ return this.collection.findOneAndReplace(filter, replacement, toCollectionOperationOptions(options));
198
+ }
199
+ findOneAndUpdate(filter, update, options) {
200
+ return this.collection.findOneAndUpdate(filter, update, toCollectionOperationOptions(options));
201
+ }
202
+ aggregate(_pipeline, _options) {
203
+ throw new Error("Method not implemented.");
204
+ }
205
+ watch(_pipeline, _options) {
206
+ throw new Error("Method not implemented.");
207
+ }
208
+ initializeUnorderedBulkOp(_options) {
209
+ throw new Error("Method not implemented.");
210
+ }
211
+ initializeOrderedBulkOp(_options) {
212
+ throw new Error("Method not implemented.");
213
+ }
214
+ count(filter, options) {
215
+ return this.collection.countDocuments(filter ?? {}, toCollectionOperationOptions(options));
216
+ }
217
+ listSearchIndexes(_name, _options) {
218
+ throw new Error("Method not implemented.");
219
+ }
220
+ createSearchIndex(_description) {
221
+ throw new Error("Method not implemented.");
222
+ }
223
+ createSearchIndexes(_descriptions) {
224
+ throw new Error("Method not implemented.");
225
+ }
226
+ dropSearchIndex(_name) {
227
+ throw new Error("Method not implemented.");
228
+ }
229
+ updateSearchIndex(_name, _definition) {
230
+ throw new Error("Method not implemented.");
231
+ }
232
+ async createCollection() {
233
+ await this.collection.createCollection();
234
+ }
235
+ async handle(id, handle, options) {
236
+ return this.collection.handle(id.toString(), handle, options);
237
+ }
310
238
  };
311
239
 
312
- // src/mongo/mongoDb.ts
240
+ //#endregion
241
+ //#region src/mongo/mongoDb.ts
313
242
  var Db = class {
314
- pongoDb;
315
- constructor(pongoDb) {
316
- this.pongoDb = pongoDb;
317
- }
318
- get databaseName() {
319
- return this.pongoDb.databaseName;
320
- }
321
- collection(collectionName) {
322
- return new Collection(this, this.pongoDb.collection(collectionName));
323
- }
243
+ pongoDb;
244
+ constructor(pongoDb) {
245
+ this.pongoDb = pongoDb;
246
+ }
247
+ get databaseName() {
248
+ return this.pongoDb.databaseName;
249
+ }
250
+ collection(collectionName, options) {
251
+ return new Collection(this, this.pongoDb.collection(collectionName, options));
252
+ }
324
253
  };
325
254
 
326
- // src/mongo/mongoClient.ts
255
+ //#endregion
256
+ //#region src/mongo/mongoClient.ts
327
257
  var MongoClient = class {
328
- pongoClient;
329
- constructor(connectionStringOrOptions, options) {
330
- if (typeof connectionStringOrOptions !== "string") {
331
- this.pongoClient = pongoClient(connectionStringOrOptions);
332
- return;
333
- }
334
- const { databaseType, driverName } = parseConnectionString(
335
- connectionStringOrOptions
336
- );
337
- const driver = options?.driver ?? pongoDatabaseDriverRegistry.tryGet(
338
- toDatabaseDriverType(databaseType, driverName)
339
- );
340
- if (driver === null) {
341
- throw new Error(
342
- `No database driver registered for ${databaseType} with name ${driverName}`
343
- );
344
- }
345
- this.pongoClient = pongoClient({
346
- ...options ?? {},
347
- ...{ connectionString: connectionStringOrOptions },
348
- driver
349
- });
350
- }
351
- async connect() {
352
- await this.pongoClient.connect();
353
- return this;
354
- }
355
- async close() {
356
- await this.pongoClient.close();
357
- }
358
- db(dbName) {
359
- return new Db(this.pongoClient.db(dbName));
360
- }
361
- startSession(_options) {
362
- return pongoSession();
363
- }
364
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
365
- async withSession(optionsOrExecutor, executor) {
366
- const callback = typeof optionsOrExecutor === "function" ? optionsOrExecutor : executor;
367
- const session = pongoSession();
368
- try {
369
- return await callback(session);
370
- } finally {
371
- await session.endSession();
372
- }
373
- }
374
- };
375
- export {
376
- Collection,
377
- Db,
378
- FindCursor,
379
- MongoClient
258
+ pongoClient;
259
+ constructor(connectionStringOrOptions, options) {
260
+ if (typeof connectionStringOrOptions !== "string") {
261
+ this.pongoClient = pongoClient(connectionStringOrOptions);
262
+ return;
263
+ }
264
+ const { databaseType, driverName } = parseConnectionString(connectionStringOrOptions);
265
+ const driver = options?.driver ?? pongoDriverRegistry.tryGet(toDatabaseDriverType(databaseType, driverName));
266
+ if (driver === null) throw new Error(`No database driver registered for ${databaseType} with name ${driverName}`);
267
+ this.pongoClient = pongoClient({
268
+ ...options ?? {},
269
+ connectionString: connectionStringOrOptions,
270
+ driver
271
+ });
272
+ }
273
+ async connect() {
274
+ await this.pongoClient.connect();
275
+ return this;
276
+ }
277
+ async close() {
278
+ await this.pongoClient.close();
279
+ }
280
+ db(dbName) {
281
+ return new Db(this.pongoClient.db(dbName));
282
+ }
283
+ startSession(_options) {
284
+ return pongoSession();
285
+ }
286
+ async withSession(optionsOrExecutor, executor) {
287
+ const callback = typeof optionsOrExecutor === "function" ? optionsOrExecutor : executor;
288
+ const session = pongoSession();
289
+ try {
290
+ return await callback(session);
291
+ } finally {
292
+ await session.endSession();
293
+ }
294
+ }
380
295
  };
296
+
297
+ //#endregion
298
+ export { Collection, Db, FindCursor, MongoClient };
381
299
  //# sourceMappingURL=shim.js.map