@event-driven-io/pongo 0.10.0 → 0.11.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.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { SQLExecutor, SQL, PostgresConnector, PostgresPoolOptions, DatabaseTransaction, DatabaseTransactionFactory, NodePostgresConnection } from '@event-driven-io/dumbo';
2
- import pg from 'pg';
3
- import { ClientSessionOptions } from 'http2';
4
- 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 as WithoutId$1, ReplaceOptions, DeleteOptions, DeleteResult, RenameOptions, DropCollectionOptions, WithId as WithId$1, 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';
1
+ import { SQLExecutor, SQL } from '@event-driven-io/dumbo';
2
+ import { P as PongoDb, a as PongoDocument, b as PongoCollection, W as WithId, c as PongoFilter, d as PongoUpdate, e as WithoutId, f as PongoTransactionOptions, g as PongoSession, h as PongoDbTransaction } from './pongoDb-C4vfKipo.cjs';
3
+ export { r as $inc, s as $push, $ as $set, q as $unset, A as AllowedDbClientOptions, C as CollectionOperationOptions, D as DocumentHandler, H as HasId, N as NotPooledPongoOptions, n as PongoClient, j as PongoClientOptions, l as PongoDbClientOptions, y as PongoDeleteManyResult, x as PongoDeleteResult, o as PongoFilterOperator, u as PongoInsertManyResult, t as PongoInsertOneResult, w as PongoUpdateManyResult, v as PongoUpdateResult, i as PooledPongoClientOptions, z as PostgresDbClientOptions, k as clientToDbOptions, m as getPongoDb, B as isPostgresClientOptions, p as pongoClient, E as postgresDb } from './pongoDb-C4vfKipo.cjs';
4
+ import 'pg';
5
5
 
6
6
  type PongoCollectionOptions<ConnectorType extends string = string> = {
7
7
  db: PongoDb<ConnectorType>;
@@ -49,168 +49,8 @@ declare const OperatorMap: {
49
49
  declare const isOperator: (key: string) => boolean;
50
50
  declare const hasOperators: (value: Record<string, unknown>) => boolean;
51
51
 
52
- type PostgresDbClientOptions = PongoDbClientOptions<PostgresConnector> & PostgresPoolOptions;
53
- declare const isPostgresClientOptions: (options: PongoDbClientOptions) => options is PostgresDbClientOptions;
54
- declare const postgresDb: (options: PostgresDbClientOptions) => PongoDb<PostgresConnector>;
55
-
56
52
  declare const postgresSQLBuilder: (collectionName: string) => PongoCollectionSQLBuilder;
57
53
 
58
- interface PongoClient {
59
- connect(): Promise<this>;
60
- close(): Promise<void>;
61
- db(dbName?: string): PongoDb;
62
- startSession(): PongoSession;
63
- withSession<T = unknown>(callback: (session: PongoSession) => Promise<T>): Promise<T>;
64
- }
65
- declare interface PongoTransactionOptions {
66
- get snapshotEnabled(): boolean;
67
- maxCommitTimeMS?: number;
68
- }
69
- interface PongoDbTransaction {
70
- get databaseName(): string | null;
71
- options: PongoTransactionOptions;
72
- enlistDatabase: (database: PongoDb) => Promise<DatabaseTransaction>;
73
- commit: () => Promise<void>;
74
- rollback: (error?: unknown) => Promise<void>;
75
- get sqlExecutor(): SQLExecutor;
76
- get isStarting(): boolean;
77
- get isActive(): boolean;
78
- get isCommitted(): boolean;
79
- }
80
- interface PongoSession {
81
- hasEnded: boolean;
82
- explicit: boolean;
83
- defaultTransactionOptions: PongoTransactionOptions;
84
- transaction: PongoDbTransaction | null;
85
- get snapshotEnabled(): boolean;
86
- endSession(): Promise<void>;
87
- incrementTransactionNumber(): void;
88
- inTransaction(): boolean;
89
- startTransaction(options?: PongoTransactionOptions): void;
90
- commitTransaction(): Promise<void>;
91
- abortTransaction(): Promise<void>;
92
- withTransaction<T = unknown>(fn: (session: PongoSession) => Promise<T>, options?: PongoTransactionOptions): Promise<T>;
93
- }
94
- interface PongoDb<ConnectorType extends string = string> extends DatabaseTransactionFactory<ConnectorType> {
95
- get connectorType(): ConnectorType;
96
- get databaseName(): string;
97
- connect(): Promise<void>;
98
- close(): Promise<void>;
99
- collection<T extends PongoDocument>(name: string): PongoCollection<T>;
100
- }
101
- type CollectionOperationOptions = {
102
- session?: PongoSession;
103
- };
104
- interface PongoCollection<T extends PongoDocument> {
105
- readonly dbName: string;
106
- readonly collectionName: string;
107
- createCollection(options?: CollectionOperationOptions): Promise<void>;
108
- insertOne(document: T, options?: CollectionOperationOptions): Promise<PongoInsertOneResult>;
109
- insertMany(documents: T[], options?: CollectionOperationOptions): Promise<PongoInsertManyResult>;
110
- updateOne(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
111
- replaceOne(filter: PongoFilter<T>, document: WithoutId<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
112
- updateMany(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<PongoUpdateResult>;
113
- deleteOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<PongoDeleteResult>;
114
- deleteMany(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<PongoDeleteResult>;
115
- findOne(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
116
- find(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T[]>;
117
- findOneAndDelete(filter: PongoFilter<T>, options?: CollectionOperationOptions): Promise<T | null>;
118
- findOneAndReplace(filter: PongoFilter<T>, replacement: WithoutId<T>, options?: CollectionOperationOptions): Promise<T | null>;
119
- findOneAndUpdate(filter: PongoFilter<T>, update: PongoUpdate<T>, options?: CollectionOperationOptions): Promise<T | null>;
120
- countDocuments(filter?: PongoFilter<T>, options?: CollectionOperationOptions): Promise<number>;
121
- drop(options?: CollectionOperationOptions): Promise<boolean>;
122
- rename(newName: string, options?: CollectionOperationOptions): Promise<PongoCollection<T>>;
123
- handle(id: string, handle: DocumentHandler<T>, options?: CollectionOperationOptions): Promise<T | null>;
124
- }
125
- type HasId = {
126
- _id: string;
127
- };
128
- type WithId<T> = T & HasId;
129
- type WithoutId<T> = Omit<T, '_id'>;
130
- type PongoFilter<T> = {
131
- [P in keyof T]?: T[P] | PongoFilterOperator<T[P]>;
132
- } | HasId;
133
- type PongoFilterOperator<T> = {
134
- $eq?: T;
135
- $gt?: T;
136
- $gte?: T;
137
- $lt?: T;
138
- $lte?: T;
139
- $ne?: T;
140
- $in?: T[];
141
- $nin?: T[];
142
- };
143
- type $set<T> = Partial<T>;
144
- type $unset<T> = {
145
- [P in keyof T]?: '';
146
- };
147
- type $inc<T> = {
148
- [P in keyof T]?: number;
149
- };
150
- type $push<T> = {
151
- [P in keyof T]?: T[P];
152
- };
153
- type PongoUpdate<T> = {
154
- $set?: Partial<T>;
155
- $unset?: $unset<T>;
156
- $inc?: $inc<T>;
157
- $push?: $push<T>;
158
- };
159
- interface PongoInsertOneResult {
160
- insertedId: string | null;
161
- acknowledged: boolean;
162
- }
163
- interface PongoInsertManyResult {
164
- acknowledged: boolean;
165
- insertedIds: string[];
166
- insertedCount: number;
167
- }
168
- interface PongoUpdateResult {
169
- acknowledged: boolean;
170
- modifiedCount: number;
171
- }
172
- interface PongoUpdateManyResult {
173
- acknowledged: boolean;
174
- modifiedCount: number;
175
- }
176
- interface PongoDeleteResult {
177
- acknowledged: boolean;
178
- deletedCount: number;
179
- }
180
- interface PongoDeleteManyResult {
181
- acknowledged: boolean;
182
- deletedCount: number;
183
- }
184
- type PongoDocument = Record<string, unknown>;
185
- type DocumentHandler<T extends PongoDocument> = ((document: T | null) => T | null) | ((document: T | null) => Promise<T | null>);
186
-
187
- type PooledPongoClientOptions = {
188
- pool: pg.Pool;
189
- } | {
190
- pooled: true;
191
- } | {
192
- pool: pg.Pool;
193
- pooled: true;
194
- } | {};
195
- type NotPooledPongoOptions = {
196
- client: pg.Client;
197
- } | {
198
- pooled: false;
199
- } | {
200
- client: pg.Client;
201
- pooled: false;
202
- } | {
203
- connection: NodePostgresConnection;
204
- pooled?: false;
205
- };
206
- type PongoClientOptions = PooledPongoClientOptions | NotPooledPongoOptions;
207
- declare const pongoClient: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(connectionString: string, options?: PongoClientOptions) => PongoClient;
208
- declare const clientToDbOptions: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(options: {
209
- connectionString: string;
210
- dbName?: string;
211
- clientOptions: PongoClientOptions;
212
- }) => DbClientOptions;
213
-
214
54
  type Entry<T> = {
215
55
  [K in keyof Required<T>]: [K, Required<T>[K]];
216
56
  }[keyof Required<T>];
@@ -222,14 +62,6 @@ type NonPartial<T> = {
222
62
  [K in keyof Required<T>]: T[K];
223
63
  };
224
64
 
225
- type PongoDbClientOptions<ConnectorType extends string = string> = {
226
- connectorType: ConnectorType;
227
- connectionString: string;
228
- dbName: string | undefined;
229
- };
230
- type AllowedDbClientOptions = PostgresDbClientOptions;
231
- declare const getPongoDb: <DbClientOptions extends PostgresDbClientOptions = PostgresDbClientOptions>(options: DbClientOptions) => PongoDb;
232
-
233
65
  type PongoSessionOptions = {
234
66
  explicit?: boolean;
235
67
  defaultTransactionOptions: PongoTransactionOptions;
@@ -238,142 +70,4 @@ declare const pongoSession: (options?: PongoSessionOptions) => PongoSession;
238
70
 
239
71
  declare const pongoTransaction: (options: PongoTransactionOptions) => PongoDbTransaction;
240
72
 
241
- declare class FindCursor<T> {
242
- private findDocumentsPromise;
243
- private documents;
244
- private index;
245
- constructor(documents: Promise<T[]>);
246
- toArray(): Promise<T[]>;
247
- forEach(callback: (doc: T) => void): Promise<void>;
248
- hasNext(): boolean;
249
- next(): Promise<T | null>;
250
- private findDocuments;
251
- }
252
-
253
- declare class Db {
254
- private pongoDb;
255
- constructor(pongoDb: PongoDb);
256
- get databaseName(): string;
257
- collection<T extends Document>(collectionName: string): Collection$1<T> & {
258
- handle(id: ObjectId$1, handle: DocumentHandler<T>): Promise<T | null>;
259
- };
260
- }
261
-
262
- declare class MongoClient {
263
- private pongoClient;
264
- constructor(connectionString: string, options?: PongoClientOptions);
265
- connect(): Promise<this>;
266
- close(): Promise<void>;
267
- db(dbName?: string): Db;
268
- startSession(_options?: ClientSessionOptions): ClientSession;
269
- withSession<T = any>(_executor: WithSessionCallback<T>): Promise<T>;
270
- withSession<T = any>(_options: ClientSessionOptions, _executor: WithSessionCallback<T>): Promise<T>;
271
- }
272
-
273
- declare class Collection<T extends Document> implements Collection$1<T> {
274
- private collection;
275
- constructor(collection: PongoCollection<T>);
276
- get dbName(): string;
277
- get collectionName(): string;
278
- get namespace(): string;
279
- get readConcern(): ReadConcern | undefined;
280
- get readPreference(): ReadPreference | undefined;
281
- get bsonOptions(): BSONSerializeOptions;
282
- get writeConcern(): WriteConcern | undefined;
283
- get hint(): Hint | undefined;
284
- set hint(v: Hint | undefined);
285
- insertOne(doc: OptionalUnlessRequiredId<T>, options?: InsertOneOptions | undefined): Promise<InsertOneResult<T>>;
286
- insertMany(docs: OptionalUnlessRequiredId<T>[], options?: BulkWriteOptions | undefined): Promise<InsertManyResult<T>>;
287
- bulkWrite(_operations: AnyBulkWriteOperation<T>[], _options?: BulkWriteOptions | undefined): Promise<BulkWriteResult>;
288
- updateOne(filter: Filter<T>, update: Document[] | UpdateFilter<T>, options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
289
- replaceOne(filter: Filter<T>, document: WithoutId$1<T>, options?: ReplaceOptions | undefined): Promise<Document | UpdateResult<T>>;
290
- updateMany(filter: Filter<T>, update: Document[] | UpdateFilter<T>, options?: UpdateOptions | undefined): Promise<UpdateResult<T>>;
291
- deleteOne(filter?: Filter<T> | undefined, options?: DeleteOptions | undefined): Promise<DeleteResult>;
292
- deleteMany(filter?: Filter<T> | undefined, options?: DeleteOptions | undefined): Promise<DeleteResult>;
293
- rename(newName: string, options?: RenameOptions | undefined): Promise<Collection<Document>>;
294
- drop(options?: DropCollectionOptions | undefined): Promise<boolean>;
295
- findOne(): Promise<WithId$1<T> | null>;
296
- findOne(filter: Filter<T>): Promise<WithId$1<T> | null>;
297
- findOne(filter: Filter<T>, options: FindOptions<Document>): Promise<WithId$1<T> | null>;
298
- findOne<TS = T>(): Promise<TS | null>;
299
- findOne<TS = T>(filter: Filter<TS>): Promise<TS | null>;
300
- findOne<TS = T>(filter: Filter<TS>, options?: FindOptions<Document> | undefined): Promise<TS | null>;
301
- find(): FindCursor$1<WithId$1<T>>;
302
- find(filter: Filter<T>, options?: FindOptions<Document> | undefined): FindCursor$1<WithId$1<T>>;
303
- find<T extends Document>(filter: Filter<T>, options?: FindOptions<Document> | undefined): FindCursor$1<T>;
304
- options(_options?: OperationOptions | undefined): Promise<Document>;
305
- isCapped(_options?: OperationOptions | undefined): Promise<boolean>;
306
- createIndex(_indexSpec: IndexSpecification, _options?: CreateIndexesOptions | undefined): Promise<string>;
307
- createIndexes(_indexSpecs: IndexDescription[], _options?: CreateIndexesOptions | undefined): Promise<string[]>;
308
- dropIndex(_indexName: string, _options?: CommandOperationOptions | undefined): Promise<Document>;
309
- dropIndexes(_options?: CommandOperationOptions | undefined): Promise<boolean>;
310
- listIndexes(_options?: AbstractCursorOptions | undefined): ListIndexesCursor;
311
- indexExists(_indexes: string | string[], _options?: AbstractCursorOptions | undefined): Promise<boolean>;
312
- indexInformation(options: IndexInformationOptions & {
313
- full: true;
314
- }): Promise<IndexDescriptionInfo[]>;
315
- indexInformation(options: IndexInformationOptions & {
316
- full?: false | undefined;
317
- }): Promise<IndexDescriptionCompact>;
318
- indexInformation(options: IndexInformationOptions): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;
319
- indexInformation(): Promise<IndexDescriptionCompact>;
320
- estimatedDocumentCount(options?: EstimatedDocumentCountOptions | undefined): Promise<number>;
321
- countDocuments(filter?: Filter<T> | undefined, options?: CountDocumentsOptions | undefined): Promise<number>;
322
- distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key): Promise<Flatten<WithId$1<T>[Key]>[]>;
323
- distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key, filter: Filter<T>): Promise<Flatten<WithId$1<T>[Key]>[]>;
324
- distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(key: Key, filter: Filter<T>, options: CommandOperationOptions): Promise<Flatten<WithId$1<T>[Key]>[]>;
325
- distinct(key: string): Promise<any[]>;
326
- distinct(key: string, filter: Filter<T>): Promise<any[]>;
327
- distinct(key: string, filter: Filter<T>, options: CommandOperationOptions): Promise<any[]>;
328
- indexes(options: IndexInformationOptions & {
329
- full?: true | undefined;
330
- }): Promise<IndexDescriptionInfo[]>;
331
- indexes(options: IndexInformationOptions & {
332
- full: false;
333
- }): Promise<IndexDescriptionCompact>;
334
- indexes(options: IndexInformationOptions): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;
335
- indexes(options?: AbstractCursorOptions | undefined): Promise<IndexDescriptionInfo[]>;
336
- findOneAndDelete(filter: Filter<T>, options: FindOneAndDeleteOptions & {
337
- includeResultMetadata: true;
338
- }): Promise<ModifyResult<T>>;
339
- findOneAndDelete(filter: Filter<T>, options: FindOneAndDeleteOptions & {
340
- includeResultMetadata: false;
341
- }): Promise<WithId$1<T> | null>;
342
- findOneAndDelete(filter: Filter<T>, options: FindOneAndDeleteOptions): Promise<WithId$1<T> | null>;
343
- findOneAndDelete(filter: Filter<T>): Promise<WithId$1<T> | null>;
344
- findOneAndReplace(filter: Filter<T>, replacement: WithoutId$1<T>, options: FindOneAndReplaceOptions & {
345
- includeResultMetadata: true;
346
- }): Promise<ModifyResult<T>>;
347
- findOneAndReplace(filter: Filter<T>, replacement: WithoutId$1<T>, options: FindOneAndReplaceOptions & {
348
- includeResultMetadata: false;
349
- }): Promise<WithId$1<T> | null>;
350
- findOneAndReplace(filter: Filter<T>, replacement: WithoutId$1<T>, options: FindOneAndReplaceOptions): Promise<WithId$1<T> | null>;
351
- findOneAndReplace(filter: Filter<T>, replacement: WithoutId$1<T>): Promise<WithId$1<T> | null>;
352
- findOneAndUpdate(filter: Filter<T>, update: UpdateFilter<T>, options: FindOneAndUpdateOptions & {
353
- includeResultMetadata: true;
354
- }): Promise<ModifyResult<T>>;
355
- findOneAndUpdate(filter: Filter<T>, update: UpdateFilter<T>, options: FindOneAndUpdateOptions & {
356
- includeResultMetadata: false;
357
- }): Promise<WithId$1<T> | null>;
358
- findOneAndUpdate(filter: Filter<T>, update: UpdateFilter<T>, options: FindOneAndUpdateOptions): Promise<WithId$1<T> | null>;
359
- findOneAndUpdate(filter: Filter<T>, update: UpdateFilter<T>): Promise<WithId$1<T> | null>;
360
- aggregate<T extends Document = Document>(_pipeline?: Document[] | undefined, _options?: AggregateOptions | undefined): AggregationCursor<T>;
361
- watch<TLocal extends Document = T, TChange extends Document = ChangeStreamDocument<TLocal>>(_pipeline?: Document[] | undefined, _options?: ChangeStreamOptions | undefined): ChangeStream<TLocal, TChange>;
362
- initializeUnorderedBulkOp(_options?: BulkWriteOptions | undefined): UnorderedBulkOperation;
363
- initializeOrderedBulkOp(_options?: BulkWriteOptions | undefined): OrderedBulkOperation;
364
- count(filter?: Filter<T> | undefined, options?: CountOptions | undefined): Promise<number>;
365
- listSearchIndexes(options?: ListSearchIndexesOptions | undefined): ListSearchIndexesCursor;
366
- listSearchIndexes(name: string, options?: ListSearchIndexesOptions | undefined): ListSearchIndexesCursor;
367
- createSearchIndex(_description: SearchIndexDescription): Promise<string>;
368
- createSearchIndexes(_descriptions: SearchIndexDescription[]): Promise<string[]>;
369
- dropSearchIndex(_name: string): Promise<void>;
370
- updateSearchIndex(_name: string, _definition: Document): Promise<void>;
371
- createCollection(): Promise<void>;
372
- handle(id: ObjectId$1, handle: DocumentHandler<T>): Promise<T | null>;
373
- }
374
-
375
- type ObjectId = string & {
376
- __brandId: 'ObjectId';
377
- };
378
-
379
- export { type $inc, type $push, type $set, type $unset, type AllowedDbClientOptions, Collection, type CollectionOperationOptions, Db, type DocumentHandler, FindCursor, type HasId, MongoClient, type NonPartial, type NotPooledPongoOptions, type ObjectId, OperatorMap, type PongoClient, type PongoClientOptions, type PongoCollection, type PongoCollectionOptions, type PongoCollectionSQLBuilder, type PongoDb, type PongoDbClientOptions, type PongoDbTransaction, type PongoDeleteManyResult, type PongoDeleteResult, type PongoDocument, type PongoFilter, type PongoFilterOperator, type PongoInsertManyResult, type PongoInsertOneResult, type PongoSession, type PongoSessionOptions, type PongoTransactionOptions, type PongoUpdate, type PongoUpdateManyResult, type PongoUpdateResult, type PooledPongoClientOptions, type PostgresDbClientOptions, QueryOperators, type WithId, type WithoutId, clientToDbOptions, entries, getPongoDb, hasOperators, isOperator, isPostgresClientOptions, pongoClient, pongoCollection, pongoSession, pongoTransaction, postgresDb, postgresSQLBuilder };
73
+ export { type NonPartial, OperatorMap, PongoCollection, type PongoCollectionOptions, type PongoCollectionSQLBuilder, PongoDb, PongoDbTransaction, PongoDocument, PongoFilter, PongoSession, type PongoSessionOptions, PongoTransactionOptions, PongoUpdate, QueryOperators, WithId, WithoutId, entries, hasOperators, isOperator, pongoCollection, pongoSession, pongoTransaction, postgresSQLBuilder };