@event-driven-io/pongo 0.10.0 → 0.12.0

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.
@@ -0,0 +1,172 @@
1
+ import { PostgresConnector, PostgresPoolOptions, DatabaseTransaction, SQLExecutor, DatabaseTransactionFactory, NodePostgresConnection } from '@event-driven-io/dumbo';
2
+ import pg from 'pg';
3
+
4
+ type PostgresDbClientOptions = PongoDbClientOptions<PostgresConnector> & PostgresPoolOptions;
5
+ declare const isPostgresClientOptions: (options: PongoDbClientOptions) => options is PostgresDbClientOptions;
6
+ declare const postgresDb: (options: PostgresDbClientOptions) => PongoDb<PostgresConnector>;
7
+
8
+ interface PongoClient {
9
+ connect(): Promise<this>;
10
+ close(): Promise<void>;
11
+ db(dbName?: string): PongoDb;
12
+ startSession(): PongoSession;
13
+ withSession<T = unknown>(callback: (session: PongoSession) => Promise<T>): Promise<T>;
14
+ }
15
+ declare interface PongoTransactionOptions {
16
+ get snapshotEnabled(): boolean;
17
+ maxCommitTimeMS?: number;
18
+ }
19
+ interface PongoDbTransaction {
20
+ get databaseName(): string | null;
21
+ options: PongoTransactionOptions;
22
+ enlistDatabase: (database: PongoDb) => Promise<DatabaseTransaction>;
23
+ commit: () => Promise<void>;
24
+ rollback: (error?: unknown) => Promise<void>;
25
+ get sqlExecutor(): SQLExecutor;
26
+ get isStarting(): boolean;
27
+ get isActive(): boolean;
28
+ get isCommitted(): boolean;
29
+ }
30
+ interface PongoSession {
31
+ hasEnded: boolean;
32
+ explicit: boolean;
33
+ defaultTransactionOptions: PongoTransactionOptions;
34
+ transaction: PongoDbTransaction | null;
35
+ get snapshotEnabled(): boolean;
36
+ endSession(): Promise<void>;
37
+ incrementTransactionNumber(): void;
38
+ inTransaction(): boolean;
39
+ startTransaction(options?: PongoTransactionOptions): void;
40
+ commitTransaction(): Promise<void>;
41
+ abortTransaction(): Promise<void>;
42
+ withTransaction<T = unknown>(fn: (session: PongoSession) => Promise<T>, options?: PongoTransactionOptions): Promise<T>;
43
+ }
44
+ interface PongoDb<ConnectorType extends string = string> extends DatabaseTransactionFactory<ConnectorType> {
45
+ get connectorType(): ConnectorType;
46
+ get databaseName(): string;
47
+ connect(): Promise<void>;
48
+ close(): Promise<void>;
49
+ collection<T extends PongoDocument>(name: string): PongoCollection<T>;
50
+ }
51
+ type CollectionOperationOptions = {
52
+ session?: PongoSession;
53
+ };
54
+ interface PongoCollection<T extends PongoDocument> {
55
+ readonly dbName: string;
56
+ readonly collectionName: string;
57
+ createCollection(options?: CollectionOperationOptions): Promise<void>;
58
+ insertOne(document: T, options?: CollectionOperationOptions): Promise<PongoInsertOneResult>;
59
+ insertMany(documents: 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>;
65
+ findOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
66
+ 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>;
70
+ countDocuments(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<number>;
71
+ drop(options?: CollectionOperationOptions): Promise<boolean>;
72
+ rename(newName: string, options?: CollectionOperationOptions): Promise<PongoCollection<T>>;
73
+ handle(id: string, handle: DocumentHandler<T>, options?: CollectionOperationOptions): Promise<T | null>;
74
+ }
75
+ type HasId = {
76
+ _id: string;
77
+ };
78
+ type WithId<T> = T & HasId;
79
+ type WithoutId<T> = Omit<T, '_id'>;
80
+ type PongoFilter<T> = {
81
+ [P in keyof T]?: T[P] | PongoFilterOperator<T[P]>;
82
+ } | HasId;
83
+ type PongoFilterOperator<T> = {
84
+ $eq?: T;
85
+ $gt?: T;
86
+ $gte?: T;
87
+ $lt?: T;
88
+ $lte?: T;
89
+ $ne?: T;
90
+ $in?: T[];
91
+ $nin?: T[];
92
+ };
93
+ type $set<T> = Partial<T>;
94
+ type $unset<T> = {
95
+ [P in keyof T]?: '';
96
+ };
97
+ type $inc<T> = {
98
+ [P in keyof T]?: number;
99
+ };
100
+ type $push<T> = {
101
+ [P in keyof T]?: T[P];
102
+ };
103
+ type PongoUpdate<T> = {
104
+ $set?: Partial<T>;
105
+ $unset?: $unset<T>;
106
+ $inc?: $inc<T>;
107
+ $push?: $push<T>;
108
+ };
109
+ interface PongoInsertOneResult {
110
+ insertedId: string | null;
111
+ acknowledged: boolean;
112
+ }
113
+ interface PongoInsertManyResult {
114
+ acknowledged: boolean;
115
+ insertedIds: string[];
116
+ insertedCount: number;
117
+ }
118
+ interface PongoUpdateResult {
119
+ acknowledged: boolean;
120
+ modifiedCount: number;
121
+ }
122
+ interface PongoUpdateManyResult {
123
+ acknowledged: boolean;
124
+ modifiedCount: number;
125
+ }
126
+ interface PongoDeleteResult {
127
+ acknowledged: boolean;
128
+ deletedCount: number;
129
+ }
130
+ interface PongoDeleteManyResult {
131
+ acknowledged: boolean;
132
+ deletedCount: number;
133
+ }
134
+ type PongoDocument = Record<string, unknown>;
135
+ type DocumentHandler<T extends PongoDocument> = ((document: T | null) => T | null) | ((document: T | null) => Promise<T | null>);
136
+
137
+ type PooledPongoClientOptions = {
138
+ pool: pg.Pool;
139
+ } | {
140
+ pooled: true;
141
+ } | {
142
+ pool: pg.Pool;
143
+ pooled: true;
144
+ } | {};
145
+ type NotPooledPongoOptions = {
146
+ client: pg.Client;
147
+ } | {
148
+ pooled: false;
149
+ } | {
150
+ client: pg.Client;
151
+ pooled: false;
152
+ } | {
153
+ connection: NodePostgresConnection;
154
+ pooled?: false;
155
+ };
156
+ type PongoClientOptions = PooledPongoClientOptions | NotPooledPongoOptions;
157
+ declare const pongoClient: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(connectionString: string, options?: PongoClientOptions) => PongoClient;
158
+ declare const clientToDbOptions: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(options: {
159
+ connectionString: string;
160
+ dbName?: string;
161
+ clientOptions: PongoClientOptions;
162
+ }) => DbClientOptions;
163
+
164
+ type PongoDbClientOptions<ConnectorType extends string = string> = {
165
+ connectorType: ConnectorType;
166
+ connectionString: string;
167
+ dbName: string | undefined;
168
+ };
169
+ type AllowedDbClientOptions = PostgresDbClientOptions;
170
+ declare const getPongoDb: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(options: DbClientOptions) => PongoDb;
171
+
172
+ export { type $set as $, type AllowedDbClientOptions as A, isPostgresClientOptions as B, type CollectionOperationOptions as C, type DocumentHandler as D, postgresDb as E, type HasId as H, type NotPooledPongoOptions as N, type PongoDb as P, type WithId as W, type PongoDocument as a, type PongoCollection as b, type PongoFilter as c, type PongoUpdate as d, type WithoutId as e, type PongoTransactionOptions as f, type PongoSession as g, type PongoDbTransaction as h, type PooledPongoClientOptions as i, type PongoClientOptions as j, clientToDbOptions as k, type PongoDbClientOptions as l, getPongoDb as m, type PongoClient as n, type PongoFilterOperator as o, pongoClient as p, type $unset as q, type $inc as r, type $push as s, type PongoInsertOneResult as t, type PongoInsertManyResult as u, type PongoUpdateResult as v, type PongoUpdateManyResult as w, type PongoDeleteResult as x, type PongoDeleteManyResult as y, type PostgresDbClientOptions as z };
@@ -0,0 +1,172 @@
1
+ import { PostgresConnector, PostgresPoolOptions, DatabaseTransaction, SQLExecutor, DatabaseTransactionFactory, NodePostgresConnection } from '@event-driven-io/dumbo';
2
+ import pg from 'pg';
3
+
4
+ type PostgresDbClientOptions = PongoDbClientOptions<PostgresConnector> & PostgresPoolOptions;
5
+ declare const isPostgresClientOptions: (options: PongoDbClientOptions) => options is PostgresDbClientOptions;
6
+ declare const postgresDb: (options: PostgresDbClientOptions) => PongoDb<PostgresConnector>;
7
+
8
+ interface PongoClient {
9
+ connect(): Promise<this>;
10
+ close(): Promise<void>;
11
+ db(dbName?: string): PongoDb;
12
+ startSession(): PongoSession;
13
+ withSession<T = unknown>(callback: (session: PongoSession) => Promise<T>): Promise<T>;
14
+ }
15
+ declare interface PongoTransactionOptions {
16
+ get snapshotEnabled(): boolean;
17
+ maxCommitTimeMS?: number;
18
+ }
19
+ interface PongoDbTransaction {
20
+ get databaseName(): string | null;
21
+ options: PongoTransactionOptions;
22
+ enlistDatabase: (database: PongoDb) => Promise<DatabaseTransaction>;
23
+ commit: () => Promise<void>;
24
+ rollback: (error?: unknown) => Promise<void>;
25
+ get sqlExecutor(): SQLExecutor;
26
+ get isStarting(): boolean;
27
+ get isActive(): boolean;
28
+ get isCommitted(): boolean;
29
+ }
30
+ interface PongoSession {
31
+ hasEnded: boolean;
32
+ explicit: boolean;
33
+ defaultTransactionOptions: PongoTransactionOptions;
34
+ transaction: PongoDbTransaction | null;
35
+ get snapshotEnabled(): boolean;
36
+ endSession(): Promise<void>;
37
+ incrementTransactionNumber(): void;
38
+ inTransaction(): boolean;
39
+ startTransaction(options?: PongoTransactionOptions): void;
40
+ commitTransaction(): Promise<void>;
41
+ abortTransaction(): Promise<void>;
42
+ withTransaction<T = unknown>(fn: (session: PongoSession) => Promise<T>, options?: PongoTransactionOptions): Promise<T>;
43
+ }
44
+ interface PongoDb<ConnectorType extends string = string> extends DatabaseTransactionFactory<ConnectorType> {
45
+ get connectorType(): ConnectorType;
46
+ get databaseName(): string;
47
+ connect(): Promise<void>;
48
+ close(): Promise<void>;
49
+ collection<T extends PongoDocument>(name: string): PongoCollection<T>;
50
+ }
51
+ type CollectionOperationOptions = {
52
+ session?: PongoSession;
53
+ };
54
+ interface PongoCollection<T extends PongoDocument> {
55
+ readonly dbName: string;
56
+ readonly collectionName: string;
57
+ createCollection(options?: CollectionOperationOptions): Promise<void>;
58
+ insertOne(document: T, options?: CollectionOperationOptions): Promise<PongoInsertOneResult>;
59
+ insertMany(documents: 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>;
65
+ findOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
66
+ 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>;
70
+ countDocuments(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<number>;
71
+ drop(options?: CollectionOperationOptions): Promise<boolean>;
72
+ rename(newName: string, options?: CollectionOperationOptions): Promise<PongoCollection<T>>;
73
+ handle(id: string, handle: DocumentHandler<T>, options?: CollectionOperationOptions): Promise<T | null>;
74
+ }
75
+ type HasId = {
76
+ _id: string;
77
+ };
78
+ type WithId<T> = T & HasId;
79
+ type WithoutId<T> = Omit<T, '_id'>;
80
+ type PongoFilter<T> = {
81
+ [P in keyof T]?: T[P] | PongoFilterOperator<T[P]>;
82
+ } | HasId;
83
+ type PongoFilterOperator<T> = {
84
+ $eq?: T;
85
+ $gt?: T;
86
+ $gte?: T;
87
+ $lt?: T;
88
+ $lte?: T;
89
+ $ne?: T;
90
+ $in?: T[];
91
+ $nin?: T[];
92
+ };
93
+ type $set<T> = Partial<T>;
94
+ type $unset<T> = {
95
+ [P in keyof T]?: '';
96
+ };
97
+ type $inc<T> = {
98
+ [P in keyof T]?: number;
99
+ };
100
+ type $push<T> = {
101
+ [P in keyof T]?: T[P];
102
+ };
103
+ type PongoUpdate<T> = {
104
+ $set?: Partial<T>;
105
+ $unset?: $unset<T>;
106
+ $inc?: $inc<T>;
107
+ $push?: $push<T>;
108
+ };
109
+ interface PongoInsertOneResult {
110
+ insertedId: string | null;
111
+ acknowledged: boolean;
112
+ }
113
+ interface PongoInsertManyResult {
114
+ acknowledged: boolean;
115
+ insertedIds: string[];
116
+ insertedCount: number;
117
+ }
118
+ interface PongoUpdateResult {
119
+ acknowledged: boolean;
120
+ modifiedCount: number;
121
+ }
122
+ interface PongoUpdateManyResult {
123
+ acknowledged: boolean;
124
+ modifiedCount: number;
125
+ }
126
+ interface PongoDeleteResult {
127
+ acknowledged: boolean;
128
+ deletedCount: number;
129
+ }
130
+ interface PongoDeleteManyResult {
131
+ acknowledged: boolean;
132
+ deletedCount: number;
133
+ }
134
+ type PongoDocument = Record<string, unknown>;
135
+ type DocumentHandler<T extends PongoDocument> = ((document: T | null) => T | null) | ((document: T | null) => Promise<T | null>);
136
+
137
+ type PooledPongoClientOptions = {
138
+ pool: pg.Pool;
139
+ } | {
140
+ pooled: true;
141
+ } | {
142
+ pool: pg.Pool;
143
+ pooled: true;
144
+ } | {};
145
+ type NotPooledPongoOptions = {
146
+ client: pg.Client;
147
+ } | {
148
+ pooled: false;
149
+ } | {
150
+ client: pg.Client;
151
+ pooled: false;
152
+ } | {
153
+ connection: NodePostgresConnection;
154
+ pooled?: false;
155
+ };
156
+ type PongoClientOptions = PooledPongoClientOptions | NotPooledPongoOptions;
157
+ declare const pongoClient: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(connectionString: string, options?: PongoClientOptions) => PongoClient;
158
+ declare const clientToDbOptions: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(options: {
159
+ connectionString: string;
160
+ dbName?: string;
161
+ clientOptions: PongoClientOptions;
162
+ }) => DbClientOptions;
163
+
164
+ type PongoDbClientOptions<ConnectorType extends string = string> = {
165
+ connectorType: ConnectorType;
166
+ connectionString: string;
167
+ dbName: string | undefined;
168
+ };
169
+ type AllowedDbClientOptions = PostgresDbClientOptions;
170
+ declare const getPongoDb: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(options: DbClientOptions) => PongoDb;
171
+
172
+ export { type $set as $, type AllowedDbClientOptions as A, isPostgresClientOptions as B, type CollectionOperationOptions as C, type DocumentHandler as D, postgresDb as E, type HasId as H, type NotPooledPongoOptions as N, type PongoDb as P, type WithId as W, type PongoDocument as a, type PongoCollection as b, type PongoFilter as c, type PongoUpdate as d, type WithoutId as e, type PongoTransactionOptions as f, type PongoSession as g, type PongoDbTransaction as h, type PooledPongoClientOptions as i, type PongoClientOptions as j, clientToDbOptions as k, type PongoDbClientOptions as l, getPongoDb as m, type PongoClient as n, type PongoFilterOperator as o, pongoClient as p, type $unset as q, type $inc as r, type $push as s, type PongoInsertOneResult as t, type PongoInsertManyResult as u, type PongoUpdateResult as v, type PongoUpdateManyResult as w, type PongoDeleteResult as x, type PongoDeleteManyResult as y, type PostgresDbClientOptions as z };
@@ -0,0 +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 _chunkHFPYXMZRcjs = require('../chunk-HFPYXMZR.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=_chunkHFPYXMZRcjs.l.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 _chunkHFPYXMZRcjs.k.call(void 0, )}async withSession(e,n){let t=typeof e=="function"?e:n,i=_chunkHFPYXMZRcjs.k.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
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/shim/findCursor.ts","../../src/shim/mongoDb.ts","../../src/shim/mongoCollection.ts","../../src/shim/mongoClient.ts"],"names":["FindCursor","documents","callback","docs","doc","toCollectionOperationOptions","options","Collection","collection","v","result","_operations","_options","filter","update","document","newName","_indexSpec","_indexSpecs","_indexName","_indexes","_key","_filter","replacement","_pipeline","_name","_description","_descriptions","_definition","id","handle","Db","pongoDb","collectionName","MongoClient","connectionString","pongoClient","dbName","pongoSession","optionsOrExecutor","executor","session"],"mappings":"iDAAO,IAAMA,EAAN,KAAoB,CACjB,qBACA,UAAwB,KACxB,MAAgB,EAExB,YAAYC,EAAyB,CACnC,KAAK,qBAAuBA,CAC9B,CAEA,MAAM,SAAwB,CAC5B,OAAO,KAAK,cAAc,CAC5B,CAEA,MAAM,QAAQC,EAA2C,CACvD,IAAMC,EAAO,MAAM,KAAK,cAAc,EAEtC,QAAWC,KAAOD,EAChBD,EAASE,CAAG,EAEd,OAAO,QAAQ,QAAQ,CACzB,CAEA,SAAmB,CACjB,GAAI,KAAK,YAAc,KAAM,MAAM,MAAM,gCAAgC,EACzE,OAAO,KAAK,MAAQ,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,OAAO0B,EAAa,CACtB,CASA,MAAM,YACJC,EACAC,EACY,CACZ,IAAMtC,EACJ,OAAOqC,GAAsB,WAAaA,EAAoBC,EAE1DC,EAAUH,EAAa,EAE7B,GAAI,CACF,OAAO,MAAMpC,EAASuC,CAAO,CAC/B,QAAE,CACA,MAAMA,EAAQ,WAAW,CAC3B,CACF,CACF","sourcesContent":["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 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 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 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","import type { ClientSessionOptions } from 'http2';\nimport type { ClientSession, WithSessionCallback } from 'mongodb';\nimport {\n pongoClient,\n pongoSession,\n type PongoClient,\n type PongoClientOptions,\n} from '../core';\nimport { Db } from './mongoDb';\n\nexport class MongoClient {\n private pongoClient: PongoClient;\n\n constructor(connectionString: string, options: PongoClientOptions = {}) {\n this.pongoClient = pongoClient(connectionString, options);\n }\n\n async connect() {\n await this.pongoClient.connect();\n return this;\n }\n\n async close() {\n await this.pongoClient.close();\n }\n\n db(dbName?: string): Db {\n return new Db(this.pongoClient.db(dbName));\n }\n startSession(_options?: ClientSessionOptions): ClientSession {\n return pongoSession() as unknown as ClientSession;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n withSession<T = any>(_executor: WithSessionCallback<T>): Promise<T>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n withSession<T = any>(\n _options: ClientSessionOptions,\n _executor: WithSessionCallback<T>,\n ): Promise<T>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async withSession<T = any>(\n optionsOrExecutor: ClientSessionOptions | WithSessionCallback<T>,\n executor?: WithSessionCallback<T>,\n ): Promise<T> {\n const callback =\n typeof optionsOrExecutor === 'function' ? optionsOrExecutor : executor!;\n\n const session = pongoSession() as unknown as ClientSession;\n\n try {\n return await callback(session);\n } finally {\n await session.endSession();\n }\n }\n}\n"]}
@@ -0,0 +1,145 @@
1
+ import { ClientSessionOptions } from 'http2';
2
+ import { Document, Collection as Collection$1, ObjectId as ObjectId$1, 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, D as DocumentHandler, j as PongoClientOptions, b as PongoCollection } from '../pongoDb-C4vfKipo.cjs';
4
+ import '@event-driven-io/dumbo';
5
+ import 'pg';
6
+
7
+ declare class FindCursor<T> {
8
+ private findDocumentsPromise;
9
+ private documents;
10
+ private index;
11
+ constructor(documents: Promise<T[]>);
12
+ toArray(): Promise<T[]>;
13
+ forEach(callback: (doc: T) => void): Promise<void>;
14
+ hasNext(): boolean;
15
+ next(): Promise<T | null>;
16
+ private findDocuments;
17
+ }
18
+
19
+ declare class Db {
20
+ private pongoDb;
21
+ constructor(pongoDb: PongoDb);
22
+ get databaseName(): string;
23
+ collection<T extends Document>(collectionName: string): Collection$1<T> & {
24
+ handle(id: ObjectId$1, handle: DocumentHandler<T>): Promise<T | null>;
25
+ };
26
+ }
27
+
28
+ declare class MongoClient {
29
+ private pongoClient;
30
+ constructor(connectionString: string, options?: PongoClientOptions);
31
+ connect(): Promise<this>;
32
+ close(): Promise<void>;
33
+ db(dbName?: string): Db;
34
+ startSession(_options?: ClientSessionOptions): ClientSession;
35
+ withSession<T = any>(_executor: WithSessionCallback<T>): Promise<T>;
36
+ withSession<T = any>(_options: ClientSessionOptions, _executor: WithSessionCallback<T>): Promise<T>;
37
+ }
38
+
39
+ declare class Collection<T extends Document> implements Collection$1<T> {
40
+ private collection;
41
+ constructor(collection: PongoCollection<T>);
42
+ get dbName(): string;
43
+ get collectionName(): string;
44
+ get namespace(): string;
45
+ get readConcern(): ReadConcern | undefined;
46
+ get readPreference(): ReadPreference | undefined;
47
+ get bsonOptions(): BSONSerializeOptions;
48
+ get writeConcern(): WriteConcern | undefined;
49
+ get hint(): Hint | undefined;
50
+ set hint(v: Hint | undefined);
51
+ insertOne(doc: OptionalUnlessRequiredId<T>, options?: InsertOneOptions | undefined): Promise<InsertOneResult<T>>;
52
+ insertMany(docs: OptionalUnlessRequiredId<T>[], options?: BulkWriteOptions | undefined): Promise<InsertManyResult<T>>;
53
+ bulkWrite(_operations: AnyBulkWriteOperation<T>[], _options?: BulkWriteOptions | undefined): Promise<BulkWriteResult>;
54
+ updateOne(filter: Filter<T>, update: Document[] | UpdateFilter<T>, options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
55
+ replaceOne(filter: Filter<T>, document: WithoutId<T>, options?: ReplaceOptions | undefined): Promise<Document | UpdateResult<T>>;
56
+ updateMany(filter: Filter<T>, update: Document[] | UpdateFilter<T>, options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
57
+ deleteOne(filter?: Filter<T> | undefined, options?: DeleteOptions | undefined): Promise<DeleteResult>;
58
+ deleteMany(filter?: Filter<T> | undefined, options?: DeleteOptions | undefined): Promise<DeleteResult>;
59
+ rename(newName: string, options?: RenameOptions | undefined): Promise<Collection<Document>>;
60
+ drop(options?: DropCollectionOptions | undefined): Promise<boolean>;
61
+ findOne(): Promise<WithId<T> | null>;
62
+ findOne(filter: Filter<T>): Promise<WithId<T> | null>;
63
+ findOne(filter: Filter<T>, options: FindOptions<Document>): Promise<WithId<T> | null>;
64
+ findOne<TS = T>(): Promise<TS | null>;
65
+ findOne<TS = T>(filter: Filter<TS>): Promise<TS | null>;
66
+ findOne<TS = T>(filter: Filter<TS>, options?: FindOptions<Document> | undefined): Promise<TS | null>;
67
+ find(): FindCursor$1<WithId<T>>;
68
+ find(filter: Filter<T>, options?: FindOptions<Document> | undefined): FindCursor$1<WithId<T>>;
69
+ find<T extends Document>(filter: Filter<T>, options?: FindOptions<Document> | undefined): FindCursor$1<T>;
70
+ options(_options?: OperationOptions | undefined): Promise<Document>;
71
+ isCapped(_options?: OperationOptions | undefined): Promise<boolean>;
72
+ createIndex(_indexSpec: IndexSpecification, _options?: CreateIndexesOptions | undefined): Promise<string>;
73
+ createIndexes(_indexSpecs: IndexDescription[], _options?: CreateIndexesOptions | undefined): Promise<string[]>;
74
+ dropIndex(_indexName: string, _options?: CommandOperationOptions | undefined): Promise<Document>;
75
+ dropIndexes(_options?: CommandOperationOptions | undefined): Promise<boolean>;
76
+ listIndexes(_options?: AbstractCursorOptions | undefined): ListIndexesCursor;
77
+ indexExists(_indexes: string | string[], _options?: AbstractCursorOptions | undefined): Promise<boolean>;
78
+ indexInformation(options: IndexInformationOptions & {
79
+ full: true;
80
+ }): Promise<IndexDescriptionInfo[]>;
81
+ indexInformation(options: IndexInformationOptions & {
82
+ full?: false | undefined;
83
+ }): Promise<IndexDescriptionCompact>;
84
+ indexInformation(options: IndexInformationOptions): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;
85
+ indexInformation(): Promise<IndexDescriptionCompact>;
86
+ estimatedDocumentCount(options?: EstimatedDocumentCountOptions | undefined): Promise<number>;
87
+ countDocuments(filter?: Filter<T> | undefined, options?: CountDocumentsOptions | undefined): Promise<number>;
88
+ distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key): Promise<Flatten<WithId<T>[Key]>[]>;
89
+ distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key, filter: Filter<T>): Promise<Flatten<WithId<T>[Key]>[]>;
90
+ distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key, filter: Filter<T>, options: CommandOperationOptions): Promise<Flatten<WithId<T>[Key]>[]>;
91
+ distinct(key: string): Promise<any[]>;
92
+ distinct(key: string, filter: Filter<T>): Promise<any[]>;
93
+ distinct(key: string, filter: Filter<T>, options: CommandOperationOptions): Promise<any[]>;
94
+ indexes(options: IndexInformationOptions & {
95
+ full?: true | undefined;
96
+ }): Promise<IndexDescriptionInfo[]>;
97
+ indexes(options: IndexInformationOptions & {
98
+ full: false;
99
+ }): Promise<IndexDescriptionCompact>;
100
+ indexes(options: IndexInformationOptions): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;
101
+ indexes(options?: AbstractCursorOptions | undefined): Promise<IndexDescriptionInfo[]>;
102
+ findOneAndDelete(filter: Filter<T>, options: FindOneAndDeleteOptions & {
103
+ includeResultMetadata: true;
104
+ }): Promise<ModifyResult<T>>;
105
+ findOneAndDelete(filter: Filter<T>, options: FindOneAndDeleteOptions & {
106
+ includeResultMetadata: false;
107
+ }): Promise<WithId<T> | null>;
108
+ findOneAndDelete(filter: Filter<T>, options: FindOneAndDeleteOptions): Promise<WithId<T> | null>;
109
+ findOneAndDelete(filter: Filter<T>): Promise<WithId<T> | null>;
110
+ findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions & {
111
+ includeResultMetadata: true;
112
+ }): Promise<ModifyResult<T>>;
113
+ findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions & {
114
+ includeResultMetadata: false;
115
+ }): Promise<WithId<T> | null>;
116
+ findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>, options: FindOneAndReplaceOptions): Promise<WithId<T> | null>;
117
+ findOneAndReplace(filter: Filter<T>, replacement: WithoutId<T>): Promise<WithId<T> | null>;
118
+ findOneAndUpdate(filter: Filter<T>, update: UpdateFilter<T>, options: FindOneAndUpdateOptions & {
119
+ includeResultMetadata: true;
120
+ }): Promise<ModifyResult<T>>;
121
+ findOneAndUpdate(filter: Filter<T>, update: UpdateFilter<T>, options: FindOneAndUpdateOptions & {
122
+ includeResultMetadata: false;
123
+ }): Promise<WithId<T> | null>;
124
+ findOneAndUpdate(filter: Filter<T>, update: UpdateFilter<T>, options: FindOneAndUpdateOptions): Promise<WithId<T> | null>;
125
+ findOneAndUpdate(filter: Filter<T>, update: UpdateFilter<T>): Promise<WithId<T> | null>;
126
+ aggregate<T extends Document = Document>(_pipeline?: Document[] | undefined, _options?: AggregateOptions | undefined): AggregationCursor<T>;
127
+ watch<TLocal extends Document = T, TChange extends Document = ChangeStreamDocument<TLocal>>(_pipeline?: Document[] | undefined, _options?: ChangeStreamOptions | undefined): ChangeStream<TLocal, TChange>;
128
+ initializeUnorderedBulkOp(_options?: BulkWriteOptions | undefined): UnorderedBulkOperation;
129
+ initializeOrderedBulkOp(_options?: BulkWriteOptions | undefined): OrderedBulkOperation;
130
+ count(filter?: Filter<T> | undefined, options?: CountOptions | undefined): Promise<number>;
131
+ listSearchIndexes(options?: ListSearchIndexesOptions | undefined): ListSearchIndexesCursor;
132
+ listSearchIndexes(name: string, options?: ListSearchIndexesOptions | undefined): ListSearchIndexesCursor;
133
+ createSearchIndex(_description: SearchIndexDescription): Promise<string>;
134
+ createSearchIndexes(_descriptions: SearchIndexDescription[]): Promise<string[]>;
135
+ dropSearchIndex(_name: string): Promise<void>;
136
+ updateSearchIndex(_name: string, _definition: Document): Promise<void>;
137
+ createCollection(): Promise<void>;
138
+ handle(id: ObjectId$1, handle: DocumentHandler<T>): Promise<T | null>;
139
+ }
140
+
141
+ type ObjectId = string & {
142
+ __brandId: 'ObjectId';
143
+ };
144
+
145
+ export { Collection, Db, FindCursor, MongoClient, type ObjectId };