@event-driven-io/pongo 0.17.0-beta.3 → 0.17.0-beta.6

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/shim.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/mongo/findCursor.ts","../src/mongo/mongoClient.ts","../src/mongo/mongoDb.ts","../src/mongo/mongoCollection.ts"],"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 parseConnectionString,\n toDatabaseDriverType,\n} from '@event-driven-io/dumbo';\nimport { type ClientSessionOptions } from 'http2';\nimport type { ClientSession, WithSessionCallback } from 'mongodb';\nimport {\n pongoClient,\n pongoSession,\n type AnyPongoDatabaseDriver,\n type PongoClient,\n type PongoClientOptions,\n type PongoClientSchema,\n} from '../core';\nimport { Db } from './mongoDb';\n\nexport class MongoClient<\n DatabaseDriverType extends AnyPongoDatabaseDriver = AnyPongoDatabaseDriver,\n TypedClientSchema extends PongoClientSchema = PongoClientSchema,\n> {\n private pongoClient: PongoClient;\n\n constructor(\n options: PongoClientOptions<DatabaseDriverType, TypedClientSchema>,\n );\n constructor(\n connectionString: string,\n options?: Omit<\n PongoClientOptions<DatabaseDriverType, TypedClientSchema>,\n 'connectionString'\n > & {\n driver?: AnyPongoDatabaseDriver;\n },\n );\n constructor(\n connectionStringOrOptions:\n | string\n | PongoClientOptions<DatabaseDriverType, TypedClientSchema>,\n options?: Omit<\n PongoClientOptions<DatabaseDriverType, TypedClientSchema>,\n 'connectionString'\n > & {\n driver?: AnyPongoDatabaseDriver;\n },\n ) {\n if (typeof connectionStringOrOptions !== 'string') {\n this.pongoClient = pongoClient(connectionStringOrOptions);\n return;\n }\n\n const { databaseType, driverName } = parseConnectionString(\n connectionStringOrOptions,\n );\n\n const driver =\n options?.driver ??\n pongoDatabaseDriverRegistry.tryGet(\n toDatabaseDriverType(databaseType, driverName),\n );\n\n if (driver === null) {\n throw new Error(\n `No database driver registered for ${databaseType} with name ${driverName}`,\n );\n }\n\n this.pongoClient = pongoClient({\n ...(options ?? {}),\n ...{ connectionString: connectionStringOrOptions },\n driver,\n });\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","import {\n Collection as MongoCollection,\n ObjectId,\n type Document,\n} from 'mongodb';\nimport type {\n DocumentHandler,\n HandleOptions,\n PongoDb,\n PongoHandleResult,\n} from '../core';\nimport { Collection } from './mongoCollection';\n\nexport class Db {\n private pongoDb: PongoDb;\n constructor(pongoDb: PongoDb) {\n this.pongoDb = pongoDb;\n }\n\n get databaseName(): string {\n return this.pongoDb.databaseName;\n }\n\n collection<T extends Document>(\n collectionName: string,\n ): MongoCollection<T> & {\n handle(\n id: ObjectId,\n handle: DocumentHandler<T>,\n options?: HandleOptions,\n ): Promise<PongoHandleResult<T>>;\n } {\n return new Collection<T>(this, 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 Db,\n DeleteOptions,\n DeleteResult,\n Document,\n DropCollectionOptions,\n EnhancedOmit,\n EstimatedDocumentCountOptions,\n Filter,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n FindOptions,\n Flatten,\n Hint,\n IndexDescription,\n IndexDescriptionCompact,\n IndexDescriptionInfo,\n IndexInformationOptions,\n IndexSpecification,\n InferIdType,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListSearchIndexesCursor,\n ListSearchIndexesOptions,\n ModifyResult,\n Collection as MongoCollection,\n FindCursor as MongoFindCursor,\n ObjectId,\n OperationOptions,\n OptionalUnlessRequiredId,\n OrderedBulkOperation,\n ReadConcern,\n ReadPreference,\n RenameOptions,\n ReplaceOptions,\n SearchIndexDescription,\n UnorderedBulkOperation,\n UpdateFilter,\n UpdateOptions,\n UpdateResult,\n WithId,\n WithoutId,\n WriteConcern,\n} from 'mongodb';\nimport type { Key } from 'readline';\nimport type {\n CollectionOperationOptions,\n DocumentHandler,\n HandleOptions,\n PongoCollection,\n PongoFilter,\n FindOptions as PongoFindOptions,\n PongoHandleResult,\n OptionalUnlessRequiredId as PongoOptionalUnlessRequiredId,\n PongoSession,\n PongoUpdate,\n} from '../core';\nimport type { Db as ShimDb } from '../shim';\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\nconst toFindOptions = (\n options: FindOptions | undefined,\n): PongoFindOptions | undefined => {\n if (!options?.session && !options?.limit && !options?.skip) {\n return undefined;\n }\n\n const pongoFindOptions: PongoFindOptions = {};\n\n if (options?.session) {\n pongoFindOptions.session = options.session as unknown as PongoSession;\n }\n if (options?.limit !== undefined) {\n pongoFindOptions.limit = options.limit;\n }\n if (options?.skip !== undefined) {\n pongoFindOptions.skip = options.skip;\n }\n\n return pongoFindOptions;\n};\n\nexport class Collection<T extends Document> implements MongoCollection<T> {\n private collection: PongoCollection<T>;\n private database: ShimDb;\n\n constructor(database: ShimDb, collection: PongoCollection<T>) {\n this.collection = collection;\n this.database = database;\n }\n get db(): Db {\n return this.database as unknown as Db;\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 get timeoutMS(): number | 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,\n ): Promise<InsertOneResult<T>> {\n const result = await this.collection.insertOne(\n doc as unknown as PongoOptionalUnlessRequiredId<T>,\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedId: result.insertedId as unknown as InferIdType<T>,\n };\n }\n async insertMany(\n docs: OptionalUnlessRequiredId<T>[],\n options?: BulkWriteOptions,\n ): Promise<InsertManyResult<T>> {\n const result = await this.collection.insertMany(\n docs as unknown as PongoOptionalUnlessRequiredId<T>[],\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedIds: result.insertedIds as unknown as InferIdType<T>[],\n insertedCount: result.insertedCount,\n };\n }\n bulkWrite(\n _operations: AnyBulkWriteOperation<T>[],\n _options?: BulkWriteOptions,\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,\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,\n ): Promise<UpdateResult<T>> {\n return this.collection.replaceOne(\n filter as unknown as PongoFilter<T>,\n document,\n toCollectionOperationOptions(options),\n ) as unknown as Promise<UpdateResult<T>>;\n }\n async updateMany(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n options?: UpdateOptions,\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>,\n options?: DeleteOptions,\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>,\n options?: DeleteOptions,\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,\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): 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>,\n ): Promise<TS | null>;\n async findOne(\n filter?: unknown,\n options?: FindOptions<Document>,\n ): Promise<import('mongodb').WithId<T> | T | null> {\n return (await this.collection.findOne(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n )) as T;\n }\n find(): MongoFindCursor<WithId<T>>;\n find(\n filter: Filter<T>,\n options?: FindOptions<Document>,\n ): MongoFindCursor<WithId<T>>;\n find<T extends Document>(\n filter: Filter<T>,\n options?: FindOptions<Document>,\n ): MongoFindCursor<T>;\n find(\n filter?: unknown,\n options?: FindOptions<Document>,\n ): MongoFindCursor<WithId<T>> | MongoFindCursor<T> {\n return new FindCursor(\n this.collection.find(filter as PongoFilter<T>, toFindOptions(options)),\n ) as unknown as MongoFindCursor<T>;\n }\n options(_options?: OperationOptions): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n isCapped(_options?: OperationOptions): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n createIndex(\n _indexSpec: IndexSpecification,\n _options?: CreateIndexesOptions,\n ): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createIndexes(\n _indexSpecs: IndexDescription[],\n _options?: CreateIndexesOptions,\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropIndex(\n _indexName: string,\n _options?: CommandOperationOptions,\n ): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n dropIndexes(_options?: CommandOperationOptions): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n listIndexes(_options?: AbstractCursorOptions): ListIndexesCursor {\n throw new Error('Method not implemented.');\n }\n indexExists(\n _indexes: string | string[],\n _options?: AbstractCursorOptions,\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,\n ): Promise<number> {\n return this.collection.countDocuments(\n {},\n toCollectionOperationOptions(options),\n );\n }\n countDocuments(\n filter?: Filter<T>,\n options?: CountDocumentsOptions,\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(options?: AbstractCursorOptions): 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,\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,\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[],\n _options?: AggregateOptions,\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[],\n _options?: ChangeStreamOptions,\n ): ChangeStream<TLocal, TChange> {\n throw new Error('Method not implemented.');\n }\n initializeUnorderedBulkOp(\n _options?: BulkWriteOptions,\n ): UnorderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n initializeOrderedBulkOp(_options?: BulkWriteOptions): OrderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n count(filter?: Filter<T>, options?: CountOptions): Promise<number> {\n return this.collection.countDocuments(\n (filter as PongoFilter<T>) ?? {},\n toCollectionOperationOptions(options),\n );\n }\n listSearchIndexes(\n options?: ListSearchIndexesOptions,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n name: string,\n options?: ListSearchIndexesOptions,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n _name?: unknown,\n _options?: unknown,\n ): import('mongodb').ListSearchIndexesCursor {\n throw new Error('Method not implemented.');\n }\n createSearchIndex(_description: SearchIndexDescription): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createSearchIndexes(\n _descriptions: SearchIndexDescription[],\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropSearchIndex(_name: string): Promise<void> {\n throw new Error('Method not implemented.');\n }\n updateSearchIndex(_name: string, _definition: Document): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async createCollection(): Promise<void> {\n await this.collection.createCollection();\n }\n async handle(\n id: ObjectId,\n handle: DocumentHandler<T>,\n options?: HandleOptions,\n ): Promise<PongoHandleResult<T>> {\n return this.collection.handle(id.toString(), handle, options);\n }\n}\n"],"mappings":";;;;;;;AAAO,IAAM,aAAN,MAAoB;AAAA,EACjB;AAAA,EACA,YAAwB;AAAA,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EAC3C;AAAA,EACA,aAAa,UAAgD;AAC3D,WAAO,aAAa;AAAA,EACtB;AAAA;AAAA,EASA,MAAM,YACJ,mBACA,UACY;AACZ,UAAM,WACJ,OAAO,sBAAsB,aAAa,oBAAoB;AAEhE,UAAM,UAAU,aAAa;AAE7B,QAAI;AACF,aAAO,MAAM,SAAS,OAAO;AAAA,IAC/B,UAAE;AACA,YAAM,QAAQ,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/mongo/findCursor.ts","../src/mongo/mongoClient.ts","../src/mongo/mongoDb.ts","../src/mongo/mongoCollection.ts"],"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 parseConnectionString,\n toDatabaseDriverType,\n} from '@event-driven-io/dumbo';\nimport { type ClientSessionOptions } from 'http2';\nimport type { ClientSession, WithSessionCallback } from 'mongodb';\nimport {\n pongoClient,\n pongoSession,\n type AnyPongoDatabaseDriver,\n type PongoClient,\n type PongoClientOptions,\n type PongoClientSchema,\n} from '../core';\nimport { Db } from './mongoDb';\n\nexport class MongoClient<\n DatabaseDriverType extends AnyPongoDatabaseDriver = AnyPongoDatabaseDriver,\n TypedClientSchema extends PongoClientSchema = PongoClientSchema,\n> {\n private pongoClient: PongoClient;\n\n constructor(\n options: PongoClientOptions<DatabaseDriverType, TypedClientSchema>,\n );\n constructor(\n connectionString: string,\n options?: Omit<\n PongoClientOptions<DatabaseDriverType, TypedClientSchema>,\n 'connectionString'\n > & {\n driver?: AnyPongoDatabaseDriver;\n },\n );\n constructor(\n connectionStringOrOptions:\n | string\n | PongoClientOptions<DatabaseDriverType, TypedClientSchema>,\n options?: Omit<\n PongoClientOptions<DatabaseDriverType, TypedClientSchema>,\n 'connectionString'\n > & {\n driver?: AnyPongoDatabaseDriver;\n },\n ) {\n if (typeof connectionStringOrOptions !== 'string') {\n this.pongoClient = pongoClient(connectionStringOrOptions);\n return;\n }\n\n const { databaseType, driverName } = parseConnectionString(\n connectionStringOrOptions,\n );\n\n const driver =\n options?.driver ??\n pongoDatabaseDriverRegistry.tryGet(\n toDatabaseDriverType(databaseType, driverName),\n );\n\n if (driver === null) {\n throw new Error(\n `No database driver registered for ${databaseType} with name ${driverName}`,\n );\n }\n\n this.pongoClient = pongoClient({\n ...(options ?? {}),\n ...{ connectionString: connectionStringOrOptions },\n driver,\n });\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","import {\n Collection as MongoCollection,\n ObjectId,\n type Document,\n} from 'mongodb';\nimport type {\n DocumentHandler,\n HandleOptions,\n PongoDb,\n PongoHandleResult,\n} from '../core';\nimport { Collection } from './mongoCollection';\n\nexport class Db {\n private pongoDb: PongoDb;\n constructor(pongoDb: PongoDb) {\n this.pongoDb = pongoDb;\n }\n\n get databaseName(): string {\n return this.pongoDb.databaseName;\n }\n\n collection<T extends Document>(\n collectionName: string,\n ): MongoCollection<T> & {\n handle(\n id: ObjectId,\n handle: DocumentHandler<T>,\n options?: HandleOptions,\n ): Promise<PongoHandleResult<T>>;\n } {\n return new Collection<T>(this, 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 Db,\n DeleteOptions,\n DeleteResult,\n Document,\n DropCollectionOptions,\n EnhancedOmit,\n EstimatedDocumentCountOptions,\n Filter,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n FindOptions,\n Flatten,\n Hint,\n IndexDescription,\n IndexDescriptionCompact,\n IndexDescriptionInfo,\n IndexInformationOptions,\n IndexSpecification,\n InferIdType,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListSearchIndexesCursor,\n ListSearchIndexesOptions,\n ModifyResult,\n Collection as MongoCollection,\n FindCursor as MongoFindCursor,\n ObjectId,\n OperationOptions,\n OptionalUnlessRequiredId,\n OrderedBulkOperation,\n ReadConcern,\n ReadPreference,\n RenameOptions,\n ReplaceOptions,\n SearchIndexDescription,\n UnorderedBulkOperation,\n UpdateFilter,\n UpdateOptions,\n UpdateResult,\n WithId,\n WithoutId,\n WriteConcern,\n} from 'mongodb';\nimport type { Key } from 'readline';\nimport type {\n CollectionOperationOptions,\n DocumentHandler,\n HandleOptions,\n PongoCollection,\n PongoFilter,\n FindOptions as PongoFindOptions,\n PongoHandleResult,\n OptionalUnlessRequiredId as PongoOptionalUnlessRequiredId,\n PongoSession,\n PongoUpdate,\n} from '../core';\nimport type { Db as ShimDb } from '../shim';\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\nconst toFindOptions = (\n options: FindOptions | undefined,\n): PongoFindOptions | undefined => {\n if (!options?.session && !options?.limit && !options?.skip) {\n return undefined;\n }\n\n const pongoFindOptions: PongoFindOptions = {};\n\n if (options?.session) {\n pongoFindOptions.session = options.session as unknown as PongoSession;\n }\n if (options?.limit !== undefined) {\n pongoFindOptions.limit = options.limit;\n }\n if (options?.skip !== undefined) {\n pongoFindOptions.skip = options.skip;\n }\n\n return pongoFindOptions;\n};\n\nexport class Collection<T extends Document> implements MongoCollection<T> {\n private collection: PongoCollection<T>;\n private database: ShimDb;\n\n constructor(database: ShimDb, collection: PongoCollection<T>) {\n this.collection = collection;\n this.database = database;\n }\n get db(): Db {\n return this.database as unknown as Db;\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 get timeoutMS(): number | 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,\n ): Promise<InsertOneResult<T>> {\n const result = await this.collection.insertOne(\n doc as unknown as PongoOptionalUnlessRequiredId<T>,\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedId: result.insertedId as unknown as InferIdType<T>,\n };\n }\n async insertMany(\n docs: OptionalUnlessRequiredId<T>[],\n options?: BulkWriteOptions,\n ): Promise<InsertManyResult<T>> {\n const result = await this.collection.insertMany(\n docs as unknown as PongoOptionalUnlessRequiredId<T>[],\n toCollectionOperationOptions(options),\n );\n return {\n acknowledged: result.acknowledged,\n insertedIds: result.insertedIds as unknown as InferIdType<T>[],\n insertedCount: result.insertedCount,\n };\n }\n bulkWrite(\n _operations: AnyBulkWriteOperation<T>[],\n _options?: BulkWriteOptions,\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,\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,\n ): Promise<UpdateResult<T>> {\n return this.collection.replaceOne(\n filter as unknown as PongoFilter<T>,\n document,\n toCollectionOperationOptions(options),\n ) as unknown as Promise<UpdateResult<T>>;\n }\n async updateMany(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n options?: UpdateOptions,\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>,\n options?: DeleteOptions,\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>,\n options?: DeleteOptions,\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,\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): 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>,\n ): Promise<TS | null>;\n async findOne(\n filter?: unknown,\n options?: FindOptions<Document>,\n ): Promise<import('mongodb').WithId<T> | T | null> {\n return (await this.collection.findOne(\n filter as PongoFilter<T>,\n toCollectionOperationOptions(options),\n )) as T;\n }\n find(): MongoFindCursor<WithId<T>>;\n find(\n filter: Filter<T>,\n options?: FindOptions<Document>,\n ): MongoFindCursor<WithId<T>>;\n find<T extends Document>(\n filter: Filter<T>,\n options?: FindOptions<Document>,\n ): MongoFindCursor<T>;\n find(\n filter?: unknown,\n options?: FindOptions<Document>,\n ): MongoFindCursor<WithId<T>> | MongoFindCursor<T> {\n return new FindCursor(\n this.collection.find(filter as PongoFilter<T>, toFindOptions(options)),\n ) as unknown as MongoFindCursor<T>;\n }\n options(_options?: OperationOptions): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n isCapped(_options?: OperationOptions): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n createIndex(\n _indexSpec: IndexSpecification,\n _options?: CreateIndexesOptions,\n ): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createIndexes(\n _indexSpecs: IndexDescription[],\n _options?: CreateIndexesOptions,\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropIndex(\n _indexName: string,\n _options?: CommandOperationOptions,\n ): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n dropIndexes(_options?: CommandOperationOptions): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n listIndexes(_options?: AbstractCursorOptions): ListIndexesCursor {\n throw new Error('Method not implemented.');\n }\n indexExists(\n _indexes: string | string[],\n _options?: AbstractCursorOptions,\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,\n ): Promise<number> {\n return this.collection.countDocuments(\n {},\n toCollectionOperationOptions(options),\n );\n }\n countDocuments(\n filter?: Filter<T>,\n options?: CountDocumentsOptions,\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(options?: AbstractCursorOptions): 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,\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,\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[],\n _options?: AggregateOptions,\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[],\n _options?: ChangeStreamOptions,\n ): ChangeStream<TLocal, TChange> {\n throw new Error('Method not implemented.');\n }\n initializeUnorderedBulkOp(\n _options?: BulkWriteOptions,\n ): UnorderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n initializeOrderedBulkOp(_options?: BulkWriteOptions): OrderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n count(filter?: Filter<T>, options?: CountOptions): Promise<number> {\n return this.collection.countDocuments(\n (filter as PongoFilter<T>) ?? {},\n toCollectionOperationOptions(options),\n );\n }\n listSearchIndexes(\n options?: ListSearchIndexesOptions,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n name: string,\n options?: ListSearchIndexesOptions,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n _name?: unknown,\n _options?: unknown,\n ): import('mongodb').ListSearchIndexesCursor {\n throw new Error('Method not implemented.');\n }\n createSearchIndex(_description: SearchIndexDescription): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createSearchIndexes(\n _descriptions: SearchIndexDescription[],\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropSearchIndex(_name: string): Promise<void> {\n throw new Error('Method not implemented.');\n }\n updateSearchIndex(_name: string, _definition: Document): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async createCollection(): Promise<void> {\n await this.collection.createCollection();\n }\n async handle(\n id: ObjectId,\n handle: DocumentHandler<T>,\n options?: HandleOptions,\n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QAAQ;AACZ,UAAM,KAAK,YAAY,MAAM;AAAA,EAC/B;AAAA,EAEA,GAAG,QAAqB;AACtB,WAAO,IAAI,GAAG,KAAK,YAAY,GAAG,MAAM,CAAC;AAAA,EAC3C;AAAA,EACA,aAAa,UAAgD;AAC3D,WAAO,aAAa;AAAA,EACtB;AAAA;AAAA,EASA,MAAM,YACJ,mBACA,UACY;AACZ,UAAM,WACJ,OAAO,sBAAsB,aAAa,oBAAoB;AAEhE,UAAM,UAAU,aAAa;AAE7B,QAAI;AACF,aAAO,MAAM,SAAS,OAAO;AAAA,IAC/B,UAAE;AACA,YAAM,QAAQ,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;","names":[]}
package/dist/sqlite3.cjs CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
 
4
4
  var _chunkECQ2CKZEcjs = require('./chunk-ECQ2CKZE.cjs');
5
- require('./chunk-WKW4LGF6.cjs');
6
5
 
7
6
 
8
7
 
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/sqlite3.cjs","../src/storage/sqlite/sqlite3/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACbA,+CAAsB;AACtB;AACE;AACA;AAAA,yDACK;AAqBP,IAAM,yBAAA,EAA2B,CAAC,gBAAA,EAAA,GAChC,iBAAA,GAAoB,UAAA;AAEtB,IAAM,sBAAA,EAGF;AAAA,EACF,UAAA,EAAY,0BAAA;AAAA,EACZ,eAAA,EAAiB,CAAC,OAAA,EAAA,GAAY;AAC5B,IAAA,MAAM,aAAA,mBACJ,OAAA,CAAQ,YAAA,UACR,wBAAA,CAAyB,OAAA,CAAQ,gBAAgB,GAAA;AAEnD,IAAA,OAAO,6CAAA;AAAc,MACnB,GAAG,OAAA;AAAA,MACH,IAAA,EAAM,0BAAA;AAAM,QACV,gBAAA,EAAkB,OAAA,CAAQ,gBAAA;AAAA,QAC1B,MAAA,EAAQ,8BAAA;AAAA,QACR,GAAG,OAAA,CAAQ;AAAA,MACb,CAAC,CAAA;AAAA,MACD,eAAA,EAAiB,4DAAA;AAA6B,QAC5C,UAAA,EAAY,0BAAA;AAAA,QACZ,iBAAA,EAAmB,CAAC,MAAA,EAAA,GAClB,8DAAA;AAA+B,UAC7B,UAAA,EAAY,0BAAA;AAAA,UACZ,UAAA,EAAY,MAAA;AAAA,UACZ,4BAAA,EAA8B;AAAA,YAC5B,UAAA,EAAY,+DAAA,MAAgC,CAAO,IAAI;AAAA,UACzD,CAAA;AAAA,UACA,UAAA,EAAY,gDAAA,MAAiB,CAAO,IAAI;AAAA,QAC1C,CAAC,CAAA;AAAA,QACH,UAAA,mCACE,OAAA,mBAAQ,MAAA,6BAAQ,YAAA,UAAc,6BAAA,CAAY,EAAA,CAAG,YAAA,EAAc,CAAC,CAAC;AAAA,MACjE,CAAC,CAAA;AAAA,MACD;AAAA,IACF,CAAC,CAAA;AAAA,EACH,CAAA;AAAA,EACA,wBAAA,EAA0B,CAAC,OAAA,EAAA,GAAY;AACrC,IAAA,wBACE,OAAA,CAAQ,YAAA,UAAgB,wBAAA,CAAyB,OAAA,CAAQ,gBAAgB,GAAA;AAAA,EAE7E,CAAA;AAAA,EACA,uBAAA,EAAyB;AAC3B,CAAA;AAEO,IAAM,yBAAA,EAA2B,CAAA,EAAA,GAAM;AAC5C,EAAA,6CAAA,CAA4B,QAAA;AAAA,IAC1B,0BAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF,CAAA;AAEA,wBAAA,CAAyB,CAAA;ADnBzB;AACE;AACA;AACA;AACA;AACA;AACF,uTAAC","file":"/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/sqlite3.cjs","sourcesContent":[null,"import { dumbo } from '@event-driven-io/dumbo';\nimport {\n sqlite3DatabaseDriver as dumboDriver,\n SQLite3DriverType,\n} from '@event-driven-io/dumbo/sqlite3';\nimport {\n PongoCollectionSchemaComponent,\n PongoDatabase,\n pongoDatabaseDriverRegistry,\n PongoDatabaseSchemaComponent,\n pongoSchema,\n type PongoDatabaseDriver,\n type PongoDatabaseDriverOptions,\n type PongoDb,\n} from '../../../core';\nimport { pongoCollectionSQLiteMigrations, sqliteSQLBuilder } from '../core';\n\nexport type SQLitePongoClientOptions = object;\n\ntype SQLiteDatabaseDriverOptions =\n PongoDatabaseDriverOptions<SQLitePongoClientOptions> & {\n databaseName?: string | undefined;\n connectionString: string;\n };\n\nconst getDatabaseNameOrDefault = (connectionString?: string) =>\n connectionString || ':memory:';\n\nconst sqlite3DatabaseDriver: PongoDatabaseDriver<\n PongoDb<SQLite3DriverType>,\n SQLiteDatabaseDriverOptions\n> = {\n driverType: SQLite3DriverType,\n databaseFactory: (options) => {\n const databaseName =\n options.databaseName ??\n getDatabaseNameOrDefault(options.connectionString);\n\n return PongoDatabase({\n ...options,\n pool: dumbo({\n connectionString: options.connectionString,\n driver: dumboDriver,\n ...options.connectionOptions,\n }),\n schemaComponent: PongoDatabaseSchemaComponent({\n driverType: SQLite3DriverType,\n collectionFactory: (schema) =>\n PongoCollectionSchemaComponent({\n driverType: SQLite3DriverType,\n definition: schema,\n migrationsOrSchemaComponents: {\n migrations: pongoCollectionSQLiteMigrations(schema.name),\n },\n sqlBuilder: sqliteSQLBuilder(schema.name),\n }),\n definition:\n options.schema?.definition ?? pongoSchema.db(databaseName, {}),\n }),\n databaseName,\n });\n },\n getDatabaseNameOrDefault: (options) => {\n return (\n options.databaseName ?? getDatabaseNameOrDefault(options.connectionString)\n );\n },\n defaultConnectionString: ':memory:',\n};\n\nexport const useSqlite3DatabaseDriver = () => {\n pongoDatabaseDriverRegistry.register(\n SQLite3DriverType,\n sqlite3DatabaseDriver,\n );\n};\n\nuseSqlite3DatabaseDriver();\n\nexport {\n sqlite3DatabaseDriver as databaseDriver,\n sqlite3DatabaseDriver as sqlite3Driver,\n};\n"]}
1
+ {"version":3,"sources":["/home/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AAAA,EACH,CAAA;AAAA,EACA,wBAAA,EAA0B,CAAC,OAAA,EAAA,GAAY;AACrC,IAAA,wBACE,OAAA,CAAQ,YAAA,UAAgB,wBAAA,CAAyB,OAAA,CAAQ,gBAAgB,GAAA;AAAA,EAE7E,CAAA;AAAA,EACA,uBAAA,EAAyB;AAC3B,CAAA;AAEO,IAAM,yBAAA,EAA2B,CAAA,EAAA,GAAM;AAC5C,EAAA,6CAAA,CAA4B,QAAA;AAAA,IAC1B,0BAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF,CAAA;AAEA,wBAAA,CAAyB,CAAA;ADpBzB;AACE;AACA;AACA;AACA;AACA;AACF,uTAAC","file":"/home/runner/work/Pongo/Pongo/src/packages/pongo/dist/sqlite3.cjs","sourcesContent":[null,"import { dumbo } from '@event-driven-io/dumbo';\nimport {\n sqlite3DatabaseDriver as dumboDriver,\n SQLite3DriverType,\n} from '@event-driven-io/dumbo/sqlite3';\nimport {\n PongoCollectionSchemaComponent,\n PongoDatabase,\n pongoDatabaseDriverRegistry,\n PongoDatabaseSchemaComponent,\n pongoSchema,\n type PongoDatabaseDriver,\n type PongoDatabaseDriverOptions,\n type PongoDb,\n} from '../../../core';\nimport { pongoCollectionSQLiteMigrations, sqliteSQLBuilder } from '../core';\n\nexport type SQLitePongoClientOptions = object;\n\ntype SQLiteDatabaseDriverOptions =\n PongoDatabaseDriverOptions<SQLitePongoClientOptions> & {\n databaseName?: string | undefined;\n connectionString: string;\n };\n\nconst getDatabaseNameOrDefault = (connectionString?: string) =>\n connectionString || ':memory:';\n\nconst sqlite3DatabaseDriver: PongoDatabaseDriver<\n PongoDb<SQLite3DriverType>,\n SQLiteDatabaseDriverOptions\n> = {\n driverType: SQLite3DriverType,\n databaseFactory: (options) => {\n const databaseName =\n options.databaseName ??\n getDatabaseNameOrDefault(options.connectionString);\n\n return PongoDatabase({\n ...options,\n pool: dumbo({\n connectionString: options.connectionString,\n driver: dumboDriver,\n ...options.connectionOptions,\n }),\n schemaComponent: PongoDatabaseSchemaComponent({\n driverType: SQLite3DriverType,\n collectionFactory: (schema) =>\n PongoCollectionSchemaComponent({\n driverType: SQLite3DriverType,\n definition: schema,\n migrationsOrSchemaComponents: {\n migrations: pongoCollectionSQLiteMigrations(schema.name),\n },\n sqlBuilder: sqliteSQLBuilder(schema.name),\n }),\n definition:\n options.schema?.definition ?? pongoSchema.db(databaseName, {}),\n }),\n databaseName,\n });\n },\n getDatabaseNameOrDefault: (options) => {\n return (\n options.databaseName ?? getDatabaseNameOrDefault(options.connectionString)\n );\n },\n defaultConnectionString: ':memory:',\n};\n\nexport const useSqlite3DatabaseDriver = () => {\n pongoDatabaseDriverRegistry.register(\n SQLite3DriverType,\n sqlite3DatabaseDriver,\n );\n};\n\nuseSqlite3DatabaseDriver();\n\nexport {\n sqlite3DatabaseDriver as databaseDriver,\n sqlite3DatabaseDriver as sqlite3Driver,\n};\n"]}
package/dist/sqlite3.js CHANGED
@@ -2,7 +2,6 @@ import {
2
2
  pongoCollectionSQLiteMigrations,
3
3
  sqliteSQLBuilder
4
4
  } from "./chunk-Y7LRKJLJ.js";
5
- import "./chunk-WH26IXHN.js";
6
5
  import {
7
6
  PongoCollectionSchemaComponent,
8
7
  PongoDatabase,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/storage/sqlite/sqlite3/index.ts"],"sourcesContent":["import { dumbo } from '@event-driven-io/dumbo';\nimport {\n sqlite3DatabaseDriver as dumboDriver,\n SQLite3DriverType,\n} from '@event-driven-io/dumbo/sqlite3';\nimport {\n PongoCollectionSchemaComponent,\n PongoDatabase,\n pongoDatabaseDriverRegistry,\n PongoDatabaseSchemaComponent,\n pongoSchema,\n type PongoDatabaseDriver,\n type PongoDatabaseDriverOptions,\n type PongoDb,\n} from '../../../core';\nimport { pongoCollectionSQLiteMigrations, sqliteSQLBuilder } from '../core';\n\nexport type SQLitePongoClientOptions = object;\n\ntype SQLiteDatabaseDriverOptions =\n PongoDatabaseDriverOptions<SQLitePongoClientOptions> & {\n databaseName?: string | undefined;\n connectionString: string;\n };\n\nconst getDatabaseNameOrDefault = (connectionString?: string) =>\n connectionString || ':memory:';\n\nconst sqlite3DatabaseDriver: PongoDatabaseDriver<\n PongoDb<SQLite3DriverType>,\n SQLiteDatabaseDriverOptions\n> = {\n driverType: SQLite3DriverType,\n databaseFactory: (options) => {\n const databaseName =\n options.databaseName ??\n getDatabaseNameOrDefault(options.connectionString);\n\n return PongoDatabase({\n ...options,\n pool: dumbo({\n connectionString: options.connectionString,\n driver: dumboDriver,\n ...options.connectionOptions,\n }),\n schemaComponent: PongoDatabaseSchemaComponent({\n driverType: SQLite3DriverType,\n collectionFactory: (schema) =>\n PongoCollectionSchemaComponent({\n driverType: SQLite3DriverType,\n definition: schema,\n migrationsOrSchemaComponents: {\n migrations: pongoCollectionSQLiteMigrations(schema.name),\n },\n sqlBuilder: sqliteSQLBuilder(schema.name),\n }),\n definition:\n options.schema?.definition ?? pongoSchema.db(databaseName, {}),\n }),\n databaseName,\n });\n },\n getDatabaseNameOrDefault: (options) => {\n return (\n options.databaseName ?? getDatabaseNameOrDefault(options.connectionString)\n );\n },\n defaultConnectionString: ':memory:',\n};\n\nexport const useSqlite3DatabaseDriver = () => {\n pongoDatabaseDriverRegistry.register(\n SQLite3DriverType,\n sqlite3DatabaseDriver,\n );\n};\n\nuseSqlite3DatabaseDriver();\n\nexport {\n sqlite3DatabaseDriver as databaseDriver,\n sqlite3DatabaseDriver as sqlite3Driver,\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB;AAAA,EACE,yBAAyB;AAAA,EACzB;AAAA,OACK;AAqBP,IAAM,2BAA2B,CAAC,qBAChC,oBAAoB;AAEtB,IAAM,wBAGF;AAAA,EACF,YAAY;AAAA,EACZ,iBAAiB,CAAC,YAAY;AAC5B,UAAM,eACJ,QAAQ,gBACR,yBAAyB,QAAQ,gBAAgB;AAEnD,WAAO,cAAc;AAAA,MACnB,GAAG;AAAA,MACH,MAAM,MAAM;AAAA,QACV,kBAAkB,QAAQ;AAAA,QAC1B,QAAQ;AAAA,QACR,GAAG,QAAQ;AAAA,MACb,CAAC;AAAA,MACD,iBAAiB,6BAA6B;AAAA,QAC5C,YAAY;AAAA,QACZ,mBAAmB,CAAC,WAClB,+BAA+B;AAAA,UAC7B,YAAY;AAAA,UACZ,YAAY;AAAA,UACZ,8BAA8B;AAAA,YAC5B,YAAY,gCAAgC,OAAO,IAAI;AAAA,UACzD;AAAA,UACA,YAAY,iBAAiB,OAAO,IAAI;AAAA,QAC1C,CAAC;AAAA,QACH,YACE,QAAQ,QAAQ,cAAc,YAAY,GAAG,cAAc,CAAC,CAAC;AAAA,MACjE,CAAC;AAAA,MACD;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EACA,0BAA0B,CAAC,YAAY;AACrC,WACE,QAAQ,gBAAgB,yBAAyB,QAAQ,gBAAgB;AAAA,EAE7E;AAAA,EACA,yBAAyB;AAC3B;AAEO,IAAM,2BAA2B,MAAM;AAC5C,8BAA4B;AAAA,IAC1B;AAAA,IACA;AAAA,EACF;AACF;AAEA,yBAAyB;","names":[]}
1
+ {"version":3,"sources":["../src/storage/sqlite/sqlite3/index.ts"],"sourcesContent":["import { dumbo } from '@event-driven-io/dumbo';\nimport {\n sqlite3DatabaseDriver as dumboDriver,\n SQLite3DriverType,\n} from '@event-driven-io/dumbo/sqlite3';\nimport {\n PongoCollectionSchemaComponent,\n PongoDatabase,\n pongoDatabaseDriverRegistry,\n PongoDatabaseSchemaComponent,\n pongoSchema,\n type PongoDatabaseDriver,\n type PongoDatabaseDriverOptions,\n type PongoDb,\n} from '../../../core';\nimport { pongoCollectionSQLiteMigrations, sqliteSQLBuilder } from '../core';\n\nexport type SQLitePongoClientOptions = object;\n\ntype SQLiteDatabaseDriverOptions =\n PongoDatabaseDriverOptions<SQLitePongoClientOptions> & {\n databaseName?: string | undefined;\n connectionString: string;\n };\n\nconst getDatabaseNameOrDefault = (connectionString?: string) =>\n connectionString || ':memory:';\n\nconst sqlite3DatabaseDriver: PongoDatabaseDriver<\n PongoDb<SQLite3DriverType>,\n SQLiteDatabaseDriverOptions\n> = {\n driverType: SQLite3DriverType,\n databaseFactory: (options) => {\n const databaseName =\n options.databaseName ??\n getDatabaseNameOrDefault(options.connectionString);\n\n return PongoDatabase({\n ...options,\n pool: dumbo({\n connectionString: options.connectionString,\n driver: dumboDriver,\n ...options.connectionOptions,\n }),\n schemaComponent: PongoDatabaseSchemaComponent({\n driverType: SQLite3DriverType,\n collectionFactory: (schema) =>\n PongoCollectionSchemaComponent({\n driverType: SQLite3DriverType,\n definition: schema,\n migrationsOrSchemaComponents: {\n migrations: pongoCollectionSQLiteMigrations(schema.name),\n },\n sqlBuilder: sqliteSQLBuilder(schema.name),\n }),\n definition:\n options.schema?.definition ?? pongoSchema.db(databaseName, {}),\n }),\n databaseName,\n });\n },\n getDatabaseNameOrDefault: (options) => {\n return (\n options.databaseName ?? getDatabaseNameOrDefault(options.connectionString)\n );\n },\n defaultConnectionString: ':memory:',\n};\n\nexport const useSqlite3DatabaseDriver = () => {\n pongoDatabaseDriverRegistry.register(\n SQLite3DriverType,\n sqlite3DatabaseDriver,\n );\n};\n\nuseSqlite3DatabaseDriver();\n\nexport {\n sqlite3DatabaseDriver as databaseDriver,\n sqlite3DatabaseDriver as sqlite3Driver,\n};\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB;AAAA,EACE,yBAAyB;AAAA,EACzB;AAAA,OACK;AAqBP,IAAM,2BAA2B,CAAC,qBAChC,oBAAoB;AAEtB,IAAM,wBAGF;AAAA,EACF,YAAY;AAAA,EACZ,iBAAiB,CAAC,YAAY;AAC5B,UAAM,eACJ,QAAQ,gBACR,yBAAyB,QAAQ,gBAAgB;AAEnD,WAAO,cAAc;AAAA,MACnB,GAAG;AAAA,MACH,MAAM,MAAM;AAAA,QACV,kBAAkB,QAAQ;AAAA,QAC1B,QAAQ;AAAA,QACR,GAAG,QAAQ;AAAA,MACb,CAAC;AAAA,MACD,iBAAiB,6BAA6B;AAAA,QAC5C,YAAY;AAAA,QACZ,mBAAmB,CAAC,WAClB,+BAA+B;AAAA,UAC7B,YAAY;AAAA,UACZ,YAAY;AAAA,UACZ,8BAA8B;AAAA,YAC5B,YAAY,gCAAgC,OAAO,IAAI;AAAA,UACzD;AAAA,UACA,YAAY,iBAAiB,OAAO,IAAI;AAAA,QAC1C,CAAC;AAAA,QACH,YACE,QAAQ,QAAQ,cAAc,YAAY,GAAG,cAAc,CAAC,CAAC;AAAA,MACjE,CAAC;AAAA,MACD;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EACA,0BAA0B,CAAC,YAAY;AACrC,WACE,QAAQ,gBAAgB,yBAAyB,QAAQ,gBAAgB;AAAA,EAE7E;AAAA,EACA,yBAAyB;AAC3B;AAEO,IAAM,2BAA2B,MAAM;AAC5C,8BAA4B;AAAA,IAC1B;AAAA,IACA;AAAA,EACF;AACF;AAEA,yBAAyB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@event-driven-io/pongo",
3
- "version": "0.17.0-beta.3",
3
+ "version": "0.17.0-beta.6",
4
4
  "description": "Pongo - Mongo with strong consistency on top of Postgres",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -134,7 +134,7 @@
134
134
  "pongo": "./dist/cli.js"
135
135
  },
136
136
  "peerDependencies": {
137
- "@event-driven-io/dumbo": "0.13.0-beta.3",
137
+ "@event-driven-io/dumbo": "0.13.0-beta.6",
138
138
  "@cloudflare/workers-types": "^4.20260115.0",
139
139
  "@types/mongodb": "^4.0.7",
140
140
  "@types/pg": "^8.15.5",
@@ -1,364 +0,0 @@
1
- import {
2
- OperatorMap,
3
- PongoCollectionSchemaComponent,
4
- PongoDatabase,
5
- PongoDatabaseSchemaComponent,
6
- QueryOperators,
7
- expectedVersionValue,
8
- hasOperators,
9
- objectEntries,
10
- pongoDatabaseDriverRegistry,
11
- pongoSchema
12
- } from "./chunk-NCNRRYVE.js";
13
-
14
- // src/storage/postgresql/pg/index.ts
15
- import { dumbo } from "@event-driven-io/dumbo";
16
- import {
17
- pgDatabaseDriver as dumboDriver,
18
- getDatabaseNameOrDefault,
19
- NodePostgresDriverType
20
- } from "@event-driven-io/dumbo/pg";
21
- import "pg";
22
-
23
- // src/storage/postgresql/core/sqlBuilder/index.ts
24
- import {
25
- isSQL,
26
- JSONSerializer as JSONSerializer3,
27
- SQL as SQL4,
28
- sqlMigration
29
- } from "@event-driven-io/dumbo";
30
-
31
- // src/storage/postgresql/core/sqlBuilder/filter/index.ts
32
- import { SQL as SQL2 } from "@event-driven-io/dumbo";
33
-
34
- // src/storage/postgresql/core/sqlBuilder/filter/queryOperators.ts
35
- import { JSONSerializer, SQL } from "@event-driven-io/dumbo";
36
- var handleOperator = (path, operator, value) => {
37
- if (path === "_id" || path === "_version") {
38
- return handleMetadataOperator(path, operator, value);
39
- }
40
- switch (operator) {
41
- case "$eq": {
42
- const nestedPath = JSONSerializer.serialize(
43
- buildNestedObject(path, value)
44
- );
45
- const serializedValue = JSONSerializer.serialize(value);
46
- return SQL`(data @> ${nestedPath}::jsonb OR jsonb_path_exists(data, '$.${SQL.plain(path)}[*] ? (@ == ${SQL.plain(serializedValue)})'))`;
47
- }
48
- case "$gt":
49
- case "$gte":
50
- case "$lt":
51
- case "$lte":
52
- case "$ne": {
53
- const jsonPath = SQL.plain(path.split(".").join(","));
54
- return SQL`data ->> '${jsonPath}' ${SQL.plain(OperatorMap[operator])} ${value}`;
55
- }
56
- case "$in": {
57
- const jsonPath = `{${path.split(".").join(",")}}`;
58
- return SQL`data #>> ${jsonPath} IN ${value}`;
59
- }
60
- case "$nin": {
61
- const jsonPath = `{${path.split(".").join(",")}}`;
62
- return SQL`data #>> ${jsonPath} NOT IN ${value}`;
63
- }
64
- case "$elemMatch": {
65
- const subQuery = objectEntries(value).map(
66
- ([subKey, subValue]) => `@."${subKey}" == ${JSONSerializer.serialize(subValue)}`
67
- ).join(" && ");
68
- return SQL`jsonb_path_exists(data, '$.${SQL.plain(path)}[*] ? (${SQL.plain(subQuery)})')`;
69
- }
70
- case "$all": {
71
- const nestedPath = JSONSerializer.serialize(
72
- buildNestedObject(path, value)
73
- );
74
- return SQL`data @> ${nestedPath}::jsonb`;
75
- }
76
- case "$size": {
77
- const jsonPath = `{${path.split(".").join(",")}}`;
78
- return SQL`jsonb_array_length(data #> ${jsonPath}) = ${value}`;
79
- }
80
- default:
81
- throw new Error(`Unsupported operator: ${operator}`);
82
- }
83
- };
84
- var handleMetadataOperator = (fieldName, operator, value) => {
85
- switch (operator) {
86
- case "$eq":
87
- return SQL`${SQL.plain(fieldName)} = ${value}`;
88
- case "$gt":
89
- case "$gte":
90
- case "$lt":
91
- case "$lte":
92
- case "$ne":
93
- return SQL`${SQL.plain(fieldName)} ${SQL.plain(OperatorMap[operator])} ${value}`;
94
- case "$in":
95
- return SQL`${SQL.plain(fieldName)} IN ${value}`;
96
- case "$nin":
97
- return SQL`${SQL.plain(fieldName)} NOT IN ${value}`;
98
- default:
99
- throw new Error(`Unsupported operator: ${operator}`);
100
- }
101
- };
102
- var buildNestedObject = (path, value) => path.split(".").reverse().reduce((acc, key) => ({ [key]: acc }), value);
103
-
104
- // src/storage/postgresql/core/sqlBuilder/filter/index.ts
105
- var AND = "AND";
106
- var constructFilterQuery = (filter) => SQL2.merge(
107
- Object.entries(filter).map(
108
- ([key, value]) => isRecord(value) ? constructComplexFilterQuery(key, value) : handleOperator(key, "$eq", value)
109
- ),
110
- ` ${AND} `
111
- );
112
- var constructComplexFilterQuery = (key, value) => {
113
- const isEquality = !hasOperators(value);
114
- return SQL2.merge(
115
- objectEntries(value).map(
116
- ([nestedKey, val]) => isEquality ? handleOperator(`${key}.${nestedKey}`, QueryOperators.$eq, val) : handleOperator(key, nestedKey, val)
117
- ),
118
- ` ${AND} `
119
- );
120
- };
121
- var isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
122
-
123
- // src/storage/postgresql/core/sqlBuilder/update/index.ts
124
- import { JSONSerializer as JSONSerializer2, SQL as SQL3 } from "@event-driven-io/dumbo";
125
- var buildUpdateQuery = (update) => objectEntries(update).reduce(
126
- (currentUpdateQuery, [op, value]) => {
127
- switch (op) {
128
- case "$set":
129
- return buildSetQuery(value, currentUpdateQuery);
130
- case "$unset":
131
- return buildUnsetQuery(value, currentUpdateQuery);
132
- case "$inc":
133
- return buildIncQuery(value, currentUpdateQuery);
134
- case "$push":
135
- return buildPushQuery(value, currentUpdateQuery);
136
- default:
137
- return currentUpdateQuery;
138
- }
139
- },
140
- SQL3`data`
141
- );
142
- var buildSetQuery = (set, currentUpdateQuery) => SQL3`${currentUpdateQuery} || ${JSONSerializer2.serialize(set)}::jsonb`;
143
- var buildUnsetQuery = (unset, currentUpdateQuery) => SQL3`${currentUpdateQuery} - ${Object.keys(unset).map((k) => `{${k}}`).join(", ")}`;
144
- var buildIncQuery = (inc, currentUpdateQuery) => {
145
- for (const [key, value] of Object.entries(inc)) {
146
- currentUpdateQuery = typeof value === "bigint" ? SQL3`jsonb_set(${currentUpdateQuery}, '{${SQL3.plain(key)}}', to_jsonb((COALESCE((data->>'${SQL3.plain(key)}')::BIGINT, 0) + ${value})::TEXT), true)` : SQL3`jsonb_set(${currentUpdateQuery}, '{${SQL3.plain(key)}}', to_jsonb(COALESCE((data->>'${SQL3.plain(key)}')::NUMERIC, 0) + ${value}), true)`;
147
- }
148
- return currentUpdateQuery;
149
- };
150
- var buildPushQuery = (push, currentUpdateQuery) => {
151
- for (const [key, value] of Object.entries(push)) {
152
- const serializedValue = JSONSerializer2.serialize([value]);
153
- currentUpdateQuery = SQL3`jsonb_set(${currentUpdateQuery}, '{${SQL3.plain(key)}}', (coalesce(data->'${SQL3.plain(key)}', '[]'::jsonb) || ${serializedValue}::jsonb), true)`;
154
- }
155
- return currentUpdateQuery;
156
- };
157
-
158
- // src/storage/postgresql/core/sqlBuilder/index.ts
159
- var createCollection = (collectionName) => SQL4`
160
- CREATE TABLE IF NOT EXISTS ${SQL4.identifier(collectionName)} (
161
- _id TEXT PRIMARY KEY,
162
- data JSONB NOT NULL,
163
- metadata JSONB NOT NULL DEFAULT '{}',
164
- _version BIGINT NOT NULL DEFAULT 1,
165
- _partition TEXT NOT NULL DEFAULT 'png_global',
166
- _archived BOOLEAN NOT NULL DEFAULT FALSE,
167
- _created TIMESTAMPTZ NOT NULL DEFAULT now(),
168
- _updated TIMESTAMPTZ NOT NULL DEFAULT now()
169
- )`;
170
- var pongoCollectionPostgreSQLMigrations = (collectionName) => [
171
- sqlMigration(`pongoCollection:${collectionName}:001:createtable`, [
172
- createCollection(collectionName)
173
- ])
174
- ];
175
- var postgresSQLBuilder = (collectionName) => ({
176
- createCollection: () => createCollection(collectionName),
177
- insertOne: (document) => {
178
- const serialized = JSONSerializer3.serialize(document);
179
- const id = document._id;
180
- const version = document._version ?? 1n;
181
- return SQL4`
182
- INSERT INTO ${SQL4.identifier(collectionName)} (_id, data, _version)
183
- VALUES (${id}, ${serialized}, ${version}) ON CONFLICT(_id) DO NOTHING;`;
184
- },
185
- insertMany: (documents) => {
186
- const values = SQL4.merge(
187
- documents.map(
188
- (doc) => SQL4`(${doc._id}, ${JSONSerializer3.serialize(doc)}, ${doc._version ?? 1n})`
189
- ),
190
- ","
191
- );
192
- return SQL4`
193
- INSERT INTO ${SQL4.identifier(collectionName)} (_id, data, _version) VALUES ${values}
194
- ON CONFLICT(_id) DO NOTHING
195
- RETURNING _id;`;
196
- },
197
- updateOne: (filter, update, options) => {
198
- const expectedVersion = expectedVersionValue(options?.expectedVersion);
199
- const expectedVersionUpdate = expectedVersion != null ? SQL4`AND ${SQL4.identifier(collectionName)}._version = ${expectedVersion}` : SQL4``;
200
- const filterQuery = isSQL(filter) ? filter : constructFilterQuery(filter);
201
- const updateQuery = isSQL(update) ? update : buildUpdateQuery(update);
202
- return SQL4`
203
- WITH existing AS (
204
- SELECT _id, _version as current_version
205
- FROM ${SQL4.identifier(collectionName)} ${where(filterQuery)}
206
- LIMIT 1
207
- ),
208
- updated AS (
209
- UPDATE ${SQL4.identifier(collectionName)}
210
- SET
211
- data = ${updateQuery} || jsonb_build_object('_id', ${SQL4.identifier(collectionName)}._id) || jsonb_build_object('_version', (_version + 1)::text),
212
- _version = _version + 1
213
- FROM existing
214
- WHERE ${SQL4.identifier(collectionName)}._id = existing._id ${expectedVersionUpdate}
215
- RETURNING ${SQL4.identifier(collectionName)}._id, ${SQL4.identifier(collectionName)}._version
216
- )
217
- SELECT
218
- existing._id,
219
- COALESCE(updated._version, existing.current_version) AS version,
220
- COUNT(existing._id) over() AS matched,
221
- COUNT(updated._id) over() AS modified
222
- FROM existing
223
- LEFT JOIN updated
224
- ON existing._id = updated._id;`;
225
- },
226
- replaceOne: (filter, document, options) => {
227
- const expectedVersion = expectedVersionValue(options?.expectedVersion);
228
- const expectedVersionUpdate = expectedVersion != null ? SQL4`AND ${SQL4.identifier(collectionName)}._version = ${expectedVersion}` : SQL4``;
229
- const filterQuery = isSQL(filter) ? filter : constructFilterQuery(filter);
230
- return SQL4`
231
- WITH existing AS (
232
- SELECT _id, _version as current_version
233
- FROM ${SQL4.identifier(collectionName)} ${where(filterQuery)}
234
- LIMIT 1
235
- ),
236
- updated AS (
237
- UPDATE ${SQL4.identifier(collectionName)}
238
- SET
239
- data = ${JSONSerializer3.serialize(document)} || jsonb_build_object('_id', ${SQL4.identifier(collectionName)}._id) || jsonb_build_object('_version', (_version + 1)::text),
240
- _version = _version + 1
241
- FROM existing
242
- WHERE ${SQL4.identifier(collectionName)}._id = existing._id ${expectedVersionUpdate}
243
- RETURNING ${SQL4.identifier(collectionName)}._id, ${SQL4.identifier(collectionName)}._version
244
- )
245
- SELECT
246
- existing._id,
247
- COALESCE(updated._version, existing.current_version) AS version,
248
- COUNT(existing._id) over() AS matched,
249
- COUNT(updated._id) over() AS modified
250
- FROM existing
251
- LEFT JOIN updated
252
- ON existing._id = updated._id;`;
253
- },
254
- updateMany: (filter, update) => {
255
- const filterQuery = isSQL(filter) ? filter : constructFilterQuery(filter);
256
- const updateQuery = isSQL(update) ? update : buildUpdateQuery(update);
257
- return SQL4`
258
- UPDATE ${SQL4.identifier(collectionName)}
259
- SET
260
- data = ${updateQuery} || jsonb_build_object('_version', (_version + 1)::text),
261
- _version = _version + 1
262
- ${where(filterQuery)};`;
263
- },
264
- deleteOne: (filter, options) => {
265
- const expectedVersion = expectedVersionValue(options?.expectedVersion);
266
- const expectedVersionUpdate = expectedVersion != null ? SQL4`AND ${SQL4.identifier(collectionName)}._version = ${expectedVersion}` : SQL4``;
267
- const filterQuery = isSQL(filter) ? filter : constructFilterQuery(filter);
268
- return SQL4`
269
- WITH existing AS (
270
- SELECT _id
271
- FROM ${SQL4.identifier(collectionName)} ${where(filterQuery)}
272
- LIMIT 1
273
- ),
274
- deleted AS (
275
- DELETE FROM ${SQL4.identifier(collectionName)}
276
- USING existing
277
- WHERE ${SQL4.identifier(collectionName)}._id = existing._id ${expectedVersionUpdate}
278
- RETURNING ${SQL4.identifier(collectionName)}._id
279
- )
280
- SELECT
281
- existing._id,
282
- COUNT(existing._id) over() AS matched,
283
- COUNT(deleted._id) over() AS deleted
284
- FROM existing
285
- LEFT JOIN deleted
286
- ON existing._id = deleted._id;`;
287
- },
288
- deleteMany: (filter) => {
289
- const filterQuery = isSQL(filter) ? filter : constructFilterQuery(filter);
290
- return SQL4`DELETE FROM ${SQL4.identifier(collectionName)} ${where(filterQuery)}`;
291
- },
292
- findOne: (filter) => {
293
- const filterQuery = isSQL(filter) ? filter : constructFilterQuery(filter);
294
- return SQL4`SELECT data FROM ${SQL4.identifier(collectionName)} ${where(filterQuery)} LIMIT 1;`;
295
- },
296
- find: (filter, options) => {
297
- const filterQuery = isSQL(filter) ? filter : constructFilterQuery(filter);
298
- const query = [];
299
- query.push(SQL4`SELECT data FROM ${SQL4.identifier(collectionName)}`);
300
- query.push(where(filterQuery));
301
- if (options?.limit) {
302
- query.push(SQL4`LIMIT ${options.limit}`);
303
- }
304
- if (options?.skip) {
305
- query.push(SQL4`OFFSET ${options.skip}`);
306
- }
307
- return SQL4.merge([...query, SQL4`;`]);
308
- },
309
- countDocuments: (filter) => {
310
- const filterQuery = SQL4.check.isSQL(filter) ? filter : constructFilterQuery(filter);
311
- return SQL4`SELECT COUNT(1) as count FROM ${SQL4.identifier(collectionName)} ${where(filterQuery)};`;
312
- },
313
- rename: (newName) => SQL4`ALTER TABLE ${SQL4.identifier(collectionName)} RENAME TO ${SQL4.identifier(newName)};`,
314
- drop: (targetName = collectionName) => SQL4`DROP TABLE IF EXISTS ${SQL4.identifier(targetName)}`
315
- });
316
- var where = (filterQuery) => SQL4.check.isEmpty(filterQuery) ? SQL4.EMPTY : SQL4.merge([SQL4`WHERE `, filterQuery]);
317
-
318
- // src/storage/postgresql/pg/index.ts
319
- var pgDatabaseDriver = {
320
- driverType: NodePostgresDriverType,
321
- databaseFactory: (options) => {
322
- const databaseName = options.databaseName ?? getDatabaseNameOrDefault(options.connectionString);
323
- return PongoDatabase({
324
- ...options,
325
- pool: dumbo({
326
- connectionString: options.connectionString,
327
- driver: dumboDriver,
328
- ...options.connectionOptions
329
- }),
330
- schemaComponent: PongoDatabaseSchemaComponent({
331
- driverType: NodePostgresDriverType,
332
- collectionFactory: (schema) => PongoCollectionSchemaComponent({
333
- driverType: NodePostgresDriverType,
334
- definition: schema,
335
- migrationsOrSchemaComponents: {
336
- migrations: pongoCollectionPostgreSQLMigrations(schema.name)
337
- },
338
- sqlBuilder: postgresSQLBuilder(schema.name)
339
- }),
340
- definition: options.schema?.definition ?? pongoSchema.db(databaseName, {})
341
- }),
342
- databaseName
343
- });
344
- },
345
- getDatabaseNameOrDefault: (options) => {
346
- return options.databaseName ?? getDatabaseNameOrDefault(options.connectionString);
347
- },
348
- defaultConnectionString: "postgresql://localhost:5432/postgres"
349
- };
350
- var usePgDatabaseDriver = () => {
351
- pongoDatabaseDriverRegistry.register(
352
- NodePostgresDriverType,
353
- pgDatabaseDriver
354
- );
355
- };
356
- usePgDatabaseDriver();
357
-
358
- export {
359
- pongoCollectionPostgreSQLMigrations,
360
- postgresSQLBuilder,
361
- pgDatabaseDriver,
362
- usePgDatabaseDriver
363
- };
364
- //# sourceMappingURL=chunk-EYQDS752.js.map