@event-driven-io/pongo 0.1.1 → 0.2.1

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.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/postgres/pool.ts","../src/postgres/postgresCollection.ts","../src/postgres/execute/index.ts","../src/main/typing/entries.ts","../src/postgres/filter/queryOperators.ts","../src/postgres/filter/index.ts","../src/postgres/sql/index.ts","../src/postgres/update/index.ts","../src/postgres/client.ts","../src/main/dbClient.ts","../src/main/client.ts","../src/mongo/findCursor.ts","../src/mongo/mongoDb.ts","../src/mongo/mongoCollection.ts","../src/mongo/mongoClient.ts"],"sourcesContent":["import pg from 'pg';\n\nconst pools: Map<string, pg.Pool> = new Map();\n\nexport const getPool = (\n connectionStringOrOptions: string | pg.PoolConfig,\n): pg.Pool => {\n const connectionString =\n typeof connectionStringOrOptions === 'string'\n ? connectionStringOrOptions\n : connectionStringOrOptions.connectionString!;\n\n const poolOptions =\n typeof connectionStringOrOptions === 'string'\n ? { connectionString }\n : connectionStringOrOptions;\n\n //TODO: this should include database name resolution for key\n return (\n pools.get(connectionString) ??\n pools.set(connectionString, new pg.Pool(poolOptions)).get(connectionString)!\n );\n};\n\nexport const endPool = async (connectionString: string): Promise<void> => {\n const pool = pools.get(connectionString);\n if (pool) {\n await pool.end();\n pools.delete(connectionString);\n }\n};\n\nexport const endAllPools = () =>\n Promise.all(\n [...pools.keys()].map((connectionString) => endPool(connectionString)),\n );\n","import pg from 'pg';\nimport { v4 as uuid } from 'uuid';\nimport {\n type PongoCollection,\n type PongoDeleteResult,\n type PongoFilter,\n type PongoInsertOneResult,\n type PongoUpdate,\n type PongoUpdateResult,\n} from '../main';\nimport { executeSQL } from './execute';\nimport { constructFilterQuery } from './filter';\nimport { sql, type SQL } from './sql';\nimport { buildUpdateQuery } from './update';\n\nexport const postgresCollection = <T>(\n collectionName: string,\n pool: pg.Pool,\n): PongoCollection<T> => {\n const execute = (sql: SQL) => executeSQL(pool, sql);\n const SqlFor = collectionSQLBuilder(collectionName);\n\n const createCollection = execute(SqlFor.createCollection());\n\n return {\n createCollection: async () => {\n await createCollection;\n },\n insertOne: async (document: T): Promise<PongoInsertOneResult> => {\n await createCollection;\n\n const id = uuid();\n\n const result = await execute(SqlFor.insertOne(id, document));\n\n return result.rowCount\n ? { insertedId: id, acknowledged: true }\n : { insertedId: null, acknowledged: false };\n },\n updateOne: async (\n filter: PongoFilter<T>,\n update: PongoUpdate<T>,\n ): Promise<PongoUpdateResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.updateOne(filter, update));\n return result.rowCount\n ? { acknowledged: true, modifiedCount: result.rowCount }\n : { acknowledged: false, modifiedCount: 0 };\n },\n deleteOne: async (filter: PongoFilter<T>): Promise<PongoDeleteResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.deleteOne(filter));\n return result.rowCount\n ? { acknowledged: true, deletedCount: result.rowCount }\n : { acknowledged: false, deletedCount: 0 };\n },\n findOne: async (filter: PongoFilter<T>): Promise<T | null> => {\n await createCollection;\n\n const result = await execute(SqlFor.findOne(filter));\n return (result.rows[0]?.data ?? null) as T | null;\n },\n find: async (filter: PongoFilter<T>): Promise<T[]> => {\n await createCollection;\n\n const result = await execute(SqlFor.find(filter));\n return result.rows.map((row) => row.data as T);\n },\n };\n};\n\nexport const collectionSQLBuilder = (collectionName: string) => ({\n createCollection: (): SQL =>\n sql(\n 'CREATE TABLE IF NOT EXISTS %I (_id UUID PRIMARY KEY, data JSONB)',\n collectionName,\n ),\n insertOne: <T>(id: string, document: T): SQL =>\n sql(\n 'INSERT INTO %I (_id, data) VALUES (%L, %L)',\n collectionName,\n id,\n JSON.stringify({ ...document, _id: id }),\n ),\n updateOne: <T>(filter: PongoFilter<T>, update: PongoUpdate<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n const updateQuery = buildUpdateQuery(update);\n\n return sql(\n 'UPDATE %I SET data = %s WHERE %s',\n collectionName,\n updateQuery,\n filterQuery,\n );\n },\n deleteOne: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql('DELETE FROM %I WHERE %s', collectionName, filterQuery);\n },\n findOne: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql(\n 'SELECT data FROM %I WHERE %s LIMIT 1',\n collectionName,\n filterQuery,\n );\n },\n find: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql('SELECT data FROM %I WHERE %s', collectionName, filterQuery);\n },\n});\n","import type pg from 'pg';\nimport type { SQL } from '../sql';\n\nexport const execute = async <Result = void>(\n pool: pg.Pool,\n handle: (client: pg.PoolClient) => Promise<Result>,\n) => {\n const client = await pool.connect();\n try {\n return await handle(client);\n } finally {\n client.release();\n }\n};\n\nexport const executeSQL = async <\n Result extends pg.QueryResultRow = pg.QueryResultRow,\n>(\n pool: pg.Pool,\n sql: SQL,\n): Promise<pg.QueryResult<Result>> =>\n execute(pool, (client) => client.query<Result>(sql));\n","type Entry<T> = {\n [K in keyof Required<T>]: [K, Required<T>[K]];\n}[keyof Required<T>];\n\ntype IterableEntry<T> = Entry<T> & {\n [Symbol.iterator](): Iterator<Entry<T>>;\n};\n\nexport const entries = <T extends object>(obj: T): IterableEntry<T>[] =>\n Object.entries(obj).map(([key, value]) => [key as keyof T, value]);\n\nexport type NonPartial<T> = { [K in keyof Required<T>]: T[K] };\n","import format from 'pg-format';\nimport { entries } from '../../main/typing';\n\nexport const Operators = {\n $eq: '$eq',\n $gt: '$gt',\n $gte: '$gte',\n $lt: '$lt',\n $lte: '$lte',\n $ne: '$ne',\n $in: '$in',\n $nin: '$nin',\n $elemMatch: '$elemMatch',\n $all: '$all',\n $size: '$size',\n};\n\nconst OperatorMap = {\n $gt: '>',\n $gte: '>=',\n $lt: '<',\n $lte: '<=',\n $ne: '!=',\n};\n\nexport const isOperator = (key: string) => key.startsWith('$');\n\nexport const hasOperators = (value: Record<string, unknown>) =>\n Object.keys(value).some(isOperator);\n\nexport const handleOperator = (\n path: string,\n operator: string,\n value: unknown,\n): string => {\n if (path === '_id') {\n return handleIdOperator(operator, value);\n }\n\n switch (operator) {\n case '$eq':\n return format(\n `(data @> %L::jsonb OR jsonb_path_exists(data, '$.%s[*] ? (@ == %s)'))`,\n JSON.stringify(buildNestedObject(path, value)),\n path,\n JSON.stringify(value),\n );\n case '$gt':\n case '$gte':\n case '$lt':\n case '$lte':\n case '$ne':\n return format(\n `data #>> %L ${OperatorMap[operator]} %L`,\n `{${path.split('.').join(',')}}`,\n value,\n );\n case '$in':\n return format(\n 'data #>> %L IN (%s)',\n `{${path.split('.').join(',')}}`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$nin':\n return format(\n 'data #>> %L NOT IN (%s)',\n `{${path.split('.').join(',')}}`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$elemMatch': {\n const subQuery = entries(value as Record<string, unknown>)\n .map(([subKey, subValue]) =>\n format(`@.\"%s\" == %s`, subKey, JSON.stringify(subValue)),\n )\n .join(' && ');\n return format(\n `jsonb_path_exists(data, '$.%s[*] ? (%s)')`,\n path,\n subQuery,\n );\n }\n case '$all':\n return format(\n 'data @> %L::jsonb',\n JSON.stringify(buildNestedObject(path, value)),\n );\n case '$size':\n return format(\n 'jsonb_array_length(data #> %L) = %L',\n `{${path.split('.').join(',')}}`,\n value,\n );\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n};\n\nconst handleIdOperator = (operator: string, value: unknown): string => {\n switch (operator) {\n case '$eq':\n return format(`_id = %L`, value);\n case '$gt':\n case '$gte':\n case '$lt':\n case '$lte':\n case '$ne':\n return format(`_id ${OperatorMap[operator]} %L`, value);\n case '$in':\n return format(\n `_id IN (%s)`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$nin':\n return format(\n `_id NOT IN (%s)`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n};\n\nconst buildNestedObject = (\n path: string,\n value: unknown,\n): Record<string, unknown> =>\n path\n .split('.')\n .reverse()\n .reduce((acc, key) => ({ [key]: acc }), value as Record<string, unknown>);\n","import type { PongoFilter } from '../../main';\nimport { entries } from '../../main/typing';\nimport { Operators, handleOperator, hasOperators } from './queryOperators';\n\nconst AND = 'AND';\n\nexport const constructFilterQuery = <T>(filter: PongoFilter<T>): string =>\n Object.entries(filter)\n .map(([key, value]) =>\n isRecord(value)\n ? constructComplexFilterQuery(key, value)\n : handleOperator(key, '$eq', value),\n )\n .join(` ${AND} `);\n\nconst constructComplexFilterQuery = (\n key: string,\n value: Record<string, unknown>,\n): string => {\n const isEquality = !hasOperators(value);\n\n return entries(value)\n .map(\n ([nestedKey, val]) =>\n isEquality\n ? handleOperator(`${key}.${nestedKey}`, Operators.$eq, val) // regular value\n : handleOperator(key, nestedKey, val), // operator\n )\n .join(` ${AND} `);\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n","import format from 'pg-format';\n\nexport type SQL = string & { __brand: 'sql' };\n\nexport const sql = (sqlQuery: string, ...params: unknown[]): SQL => {\n return format(sqlQuery, ...params) as SQL;\n};\n","import type { $inc, $push, $set, $unset, PongoUpdate } from '../../main';\nimport { entries } from '../../main/typing';\nimport { sql, type SQL } from '../sql';\n\nexport const buildUpdateQuery = <T>(update: PongoUpdate<T>): SQL =>\n entries(update).reduce((currentUpdateQuery, [op, value]) => {\n switch (op) {\n case '$set':\n return buildSetQuery(value, currentUpdateQuery);\n case '$unset':\n return buildUnsetQuery(value, currentUpdateQuery);\n case '$inc':\n return buildIncQuery(value, currentUpdateQuery);\n case '$push':\n return buildPushQuery(value, currentUpdateQuery);\n default:\n return currentUpdateQuery;\n }\n }, sql('data'));\n\nexport const buildSetQuery = <T>(set: $set<T>, currentUpdateQuery: SQL): SQL =>\n sql(\n 'jsonb_set(%s, %L, data || %L)',\n currentUpdateQuery,\n '{}',\n JSON.stringify(set),\n );\n\nexport const buildUnsetQuery = <T>(\n unset: $unset<T>,\n currentUpdateQuery: SQL,\n): SQL => sql('%s - %L', currentUpdateQuery, Object.keys(unset).join(', '));\n\nexport const buildIncQuery = <T>(\n inc: $inc<T>,\n currentUpdateQuery: SQL,\n): SQL => {\n for (const [key, value] of Object.entries(inc)) {\n currentUpdateQuery = sql(\n \"jsonb_set(%s, '{%s}', to_jsonb((data->>'%s')::numeric + %L))\",\n currentUpdateQuery,\n key,\n key,\n value,\n );\n }\n return currentUpdateQuery;\n};\n\nexport const buildPushQuery = <T>(\n push: $push<T>,\n currentUpdateQuery: SQL,\n): SQL => {\n for (const [key, value] of Object.entries(push)) {\n currentUpdateQuery = sql(\n \"jsonb_set(%s, '{%s}', (COALESCE(data->'%s', '[]'::jsonb) || '[%s]'::jsonb))\",\n currentUpdateQuery,\n key,\n key,\n JSON.stringify(value),\n );\n }\n return currentUpdateQuery;\n};\n","import { type DbClient } from '../main';\nimport { endPool, getPool } from './pool';\nimport { postgresCollection } from './postgresCollection';\n\nexport const postgresClient = (\n connectionString: string,\n database?: string,\n): DbClient => {\n const pool = getPool({ connectionString, database });\n\n return {\n connect: () => Promise.resolve(),\n close: () => endPool(connectionString),\n collection: <T>(name: string) => postgresCollection<T>(name, pool),\n };\n};\n","import { postgresClient } from '../postgres';\nimport type { PongoCollection } from './typing/operations';\n\nexport interface DbClient {\n connect(): Promise<void>;\n close(): Promise<void>;\n collection: <T>(name: string) => PongoCollection<T>;\n}\n\nexport const getDbClient = (\n connectionString: string,\n database?: string,\n): DbClient => {\n // This is the place where in the future could come resolution of other database types\n return postgresClient(connectionString, database);\n};\n","import { getDbClient } from './dbClient';\nimport type { PongoClient, PongoDb } from './typing/operations';\n\nexport const pongoClient = (connectionString: string): PongoClient => {\n const dbClient = getDbClient(connectionString);\n\n const pongoClient: PongoClient = {\n connect: async () => {\n await dbClient.connect();\n return pongoClient;\n },\n close: () => dbClient.close(),\n db: (dbName?: string): PongoDb =>\n dbName ? getDbClient(connectionString, dbName) : dbClient,\n };\n\n return pongoClient;\n};\n","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 { Collection as MongoCollection, type Document } from 'mongodb';\nimport type { PongoDb } from '../main';\nimport { Collection } from './mongoCollection';\n\nexport class Db {\n constructor(private pongoDb: PongoDb) {}\n\n collection<T extends Document>(collectionName: string): MongoCollection<T> {\n return new Collection<T>(this.pongoDb.collection<T>(collectionName));\n }\n}\n","import type {\n AbstractCursorOptions,\n AggregateOptions,\n AggregationCursor,\n AnyBulkWriteOperation,\n BSONSerializeOptions,\n BulkWriteOptions,\n BulkWriteResult,\n ChangeStream,\n ChangeStreamDocument,\n ChangeStreamOptions,\n CommandOperationOptions,\n CountDocumentsOptions,\n CountOptions,\n CreateIndexesOptions,\n DeleteOptions,\n DeleteResult,\n Document,\n DropCollectionOptions,\n EnhancedOmit,\n EstimatedDocumentCountOptions,\n Filter,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n FindOptions,\n Flatten,\n Hint,\n IndexDescription,\n IndexDescriptionCompact,\n IndexDescriptionInfo,\n IndexInformationOptions,\n IndexSpecification,\n InferIdType,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListSearchIndexesCursor,\n ListSearchIndexesOptions,\n ModifyResult,\n Collection as MongoCollection,\n FindCursor as MongoFindCursor,\n 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 { PongoCollection, PongoFilter, PongoUpdate } from '../main';\nimport { FindCursor } from './findCursor';\n\nexport class Collection<T extends Document> implements MongoCollection<T> {\n private collection: PongoCollection<T>;\n\n constructor(collection: PongoCollection<T>) {\n this.collection = collection;\n }\n get dbName(): string {\n throw new Error('Method not implemented.');\n }\n get collectionName(): string {\n throw new Error('Method not implemented.');\n }\n get namespace(): string {\n throw new Error('Method not implemented.');\n }\n get readConcern(): ReadConcern | undefined {\n throw new Error('Method not implemented.');\n }\n get readPreference(): ReadPreference | undefined {\n throw new Error('Method not implemented.');\n }\n get bsonOptions(): BSONSerializeOptions {\n throw new Error('Method not implemented.');\n }\n get writeConcern(): WriteConcern | undefined {\n throw new Error('Method not implemented.');\n }\n get hint(): Hint | undefined {\n throw new Error('Method not implemented.');\n }\n set hint(v: Hint | undefined) {\n throw new Error('Method not implemented.');\n }\n async insertOne(\n doc: OptionalUnlessRequiredId<T>,\n _options?: InsertOneOptions | undefined,\n ): Promise<InsertOneResult<T>> {\n const result = await this.collection.insertOne(doc as T);\n return {\n acknowledged: result.acknowledged,\n insertedId: result.insertedId as unknown as InferIdType<T>,\n };\n }\n insertMany(\n _docs: OptionalUnlessRequiredId<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<InsertManyResult<T>> {\n throw new Error('Method not implemented.');\n }\n bulkWrite(\n _operations: AnyBulkWriteOperation<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<BulkWriteResult> {\n throw new Error('Method not implemented.');\n }\n async updateOne(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n _options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateOne(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n );\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 _: WithoutId<T>,\n _options?: ReplaceOptions | undefined,\n ): Promise<Document | UpdateResult<T>> {\n throw new Error('Method not implemented.');\n }\n updateMany(\n _filter: Filter<T>,\n _update: Document[] | UpdateFilter<T>,\n _options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n throw new Error('Method not implemented.');\n }\n async deleteOne(\n filter?: Filter<T> | undefined,\n _options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteOne(\n filter as unknown as PongoFilter<T>,\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n deleteMany(\n _filter?: Filter<T> | undefined,\n _options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n throw new Error('Method not implemented.');\n }\n rename(\n _newName: string,\n _options?: RenameOptions | undefined,\n ): Promise<Collection<Document>> {\n throw new Error('Method not implemented.');\n }\n drop(_options?: DropCollectionOptions | undefined): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n findOne(): Promise<WithId<T> | null>;\n findOne(filter: Filter<T>): Promise<WithId<T> | null>;\n findOne(\n filter: Filter<T>,\n options: FindOptions<Document>,\n ): Promise<WithId<T> | null>;\n findOne<TS = T>(): Promise<TS | null>;\n findOne<TS = T>(filter: Filter<TS>): Promise<TS | null>;\n findOne<TS = T>(\n filter: Filter<TS>,\n options?: FindOptions<Document> | undefined,\n ): Promise<TS | null>;\n async findOne(\n filter?: unknown,\n _options?: unknown,\n ): Promise<import('mongodb').WithId<T> | T | null> {\n return this.collection.findOne(filter as PongoFilter<T>);\n }\n find(): MongoFindCursor<WithId<T>>;\n find(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>>;\n find<T extends Document>(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<T>;\n find(\n filter?: unknown,\n _options?: unknown,\n ): MongoFindCursor<WithId<T>> | MongoFindCursor<T> {\n return new FindCursor(\n this.collection.find(filter as PongoFilter<T>),\n ) as unknown as MongoFindCursor<T>;\n }\n options(_options?: OperationOptions | undefined): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n isCapped(_options?: OperationOptions | undefined): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n createIndex(\n _indexSpec: IndexSpecification,\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createIndexes(\n _indexSpecs: IndexDescription[],\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropIndex(\n _indexName: string,\n _options?: CommandOperationOptions | undefined,\n ): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n dropIndexes(\n _options?: CommandOperationOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n listIndexes(_options?: AbstractCursorOptions | undefined): ListIndexesCursor {\n throw new Error('Method not implemented.');\n }\n indexExists(\n _indexes: string | string[],\n _options?: AbstractCursorOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n indexInformation(\n options: IndexInformationOptions & { full: true },\n ): Promise<IndexDescriptionInfo[]>;\n indexInformation(\n options: IndexInformationOptions & { full?: false | undefined },\n ): Promise<IndexDescriptionCompact>;\n indexInformation(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexInformation(): Promise<IndexDescriptionCompact>;\n indexInformation(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n estimatedDocumentCount(\n _options?: EstimatedDocumentCountOptions | undefined,\n ): Promise<number> {\n throw new Error('Method not implemented.');\n }\n countDocuments(\n _filter?: Filter<T> | undefined,\n _options?: CountDocumentsOptions | undefined,\n ): Promise<number> {\n throw new Error('Method not implemented.');\n }\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n options: CommandOperationOptions,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string): Promise<any[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string, filter: Filter<T>): Promise<any[]>;\n distinct(\n key: string,\n filter: Filter<T>,\n options: CommandOperationOptions, // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<any[]>;\n distinct(\n _key: unknown,\n _filter?: unknown,\n _options?: unknown,\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Promise<any[]>\n | Promise<import('mongodb').Flatten<import('mongodb').WithId<T>[Key]>[]> {\n throw new Error('Method not implemented.');\n }\n indexes(\n options: IndexInformationOptions & { full?: true | undefined },\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n options: IndexInformationOptions & { full: false },\n ): Promise<IndexDescriptionCompact>;\n indexes(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexes(\n options?: AbstractCursorOptions | undefined,\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null>;\n findOneAndDelete(filter: Filter<T>): Promise<WithId<T> | null>;\n findOneAndDelete(\n _filter: unknown,\n _options?: unknown,\n ):\n | Promise<import('mongodb').WithId<T> | null>\n | Promise<import('mongodb').ModifyResult<T>> {\n throw new Error('Method not implemented.');\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?: unknown,\n ):\n | Promise<import('mongodb').WithId<T> | null>\n | Promise<import('mongodb').ModifyResult<T>> {\n throw new Error('Method not implemented.');\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?: unknown,\n ):\n | Promise<import('mongodb').WithId<T> | null>\n | Promise<import('mongodb').ModifyResult<T>> {\n throw new Error('Method not implemented.');\n }\n aggregate<T extends Document = Document>(\n _pipeline?: Document[] | undefined,\n _options?: AggregateOptions | undefined,\n ): AggregationCursor<T> {\n throw new Error('Method not implemented.');\n }\n watch<\n TLocal extends Document = T,\n TChange extends Document = ChangeStreamDocument<TLocal>,\n >(\n _pipeline?: Document[] | undefined,\n _options?: ChangeStreamOptions | undefined,\n ): ChangeStream<TLocal, TChange> {\n throw new Error('Method not implemented.');\n }\n initializeUnorderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): UnorderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n initializeOrderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): OrderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n count(\n _filter?: Filter<T> | undefined,\n _options?: CountOptions | undefined,\n ): Promise<number> {\n throw new Error('Method not implemented.');\n }\n listSearchIndexes(\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n name: string,\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n _name?: unknown,\n _options?: unknown,\n ): import('mongodb').ListSearchIndexesCursor {\n throw new Error('Method not implemented.');\n }\n createSearchIndex(_description: SearchIndexDescription): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createSearchIndexes(\n _descriptions: SearchIndexDescription[],\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropSearchIndex(_name: string): Promise<void> {\n throw new Error('Method not implemented.');\n }\n updateSearchIndex(_name: string, _definition: Document): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async createCollection(): Promise<void> {\n await this.collection.createCollection();\n }\n}\n","// src/MongoClientShim.ts\nimport { pongoClient, type PongoClient } from '../main';\nimport { Db } from './mongoDb';\n\nexport class MongoClient {\n private pongoClient: PongoClient;\n\n constructor(connectionString: string) {\n this.pongoClient = pongoClient(connectionString);\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}\n"],"mappings":"AAAA,OAAOA,MAAQ,KAEf,IAAMC,EAA8B,IAAI,IAE3BC,EACXC,GACY,CACZ,IAAMC,EACJ,OAAOD,GAA8B,SACjCA,EACAA,EAA0B,iBAE1BE,EACJ,OAAOF,GAA8B,SACjC,CAAE,iBAAAC,CAAiB,EACnBD,EAGN,OACEF,EAAM,IAAIG,CAAgB,GAC1BH,EAAM,IAAIG,EAAkB,IAAIJ,EAAG,KAAKK,CAAW,CAAC,EAAE,IAAID,CAAgB,CAE9E,EAEaE,EAAU,MAAOF,GAA4C,CACxE,IAAMG,EAAON,EAAM,IAAIG,CAAgB,EACnCG,IACF,MAAMA,EAAK,IAAI,EACfN,EAAM,OAAOG,CAAgB,EAEjC,EAEaI,EAAc,IACzB,QAAQ,IACN,CAAC,GAAGP,EAAM,KAAK,CAAC,EAAE,IAAKG,GAAqBE,EAAQF,CAAgB,CAAC,CACvE,ECnCF,MAAe,KACf,OAAS,MAAMK,MAAY,OCEpB,IAAMC,EAAU,MACrBC,EACAC,IACG,CACH,IAAMC,EAAS,MAAMF,EAAK,QAAQ,EAClC,GAAI,CACF,OAAO,MAAMC,EAAOC,CAAM,CAC5B,QAAE,CACAA,EAAO,QAAQ,CACjB,CACF,EAEaC,EAAa,MAGxBH,EACAI,IAEAL,EAAQC,EAAOE,G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ACvE,MAAM,IAAI,MAAM,yBAAyB,CAC3C,CACA,oBACEC,EACmB,CACnB,MAAM,IAAI,MAAM,yBAAyB,CAC3C,CACA,gBAAgBF,EAA8B,CAC5C,MAAM,IAAI,MAAM,yBAAyB,CAC3C,CACA,kBAAkBA,EAAeG,EAAsC,CACrE,MAAM,IAAI,MAAM,yBAAyB,CAC3C,CAEA,MAAM,kBAAkC,CACtC,MAAM,KAAK,WAAW,iBAAiB,CACzC,CACF,EDvdO,IAAMC,EAAN,KAAS,CACd,YAAoBC,EAAkB,CAAlB,aAAAA,CAAmB,CAEvC,WAA+BC,EAA4C,CACzE,OAAO,IAAIC,EAAc,KAAK,QAAQ,WAAcD,CAAc,CAAC,CACrE,CACF,EENO,IAAME,EAAN,KAAkB,CACf,YAER,YAAYC,EAA0B,CACpC,KAAK,YAAcC,EAAYD,CAAgB,CACjD,CAEA,MAAM,SAAU,CACd,aAAM,KAAK,YAAY,QAAQ,EACxB,IACT,CAEA,MAAM,OAAQ,CACZ,MAAM,KAAK,YAAY,MAAM,CAC/B,CAEA,GAAGE,EAAoB,CACrB,OAAO,IAAIC,EAAG,KAAK,YAAY,GAAGD,CAAM,CAAC,CAC3C,CACF","names":["pg","pools","getPool","connectionStringOrOptions","connectionString","poolOptions","endPool","pool","endAllPools","uuid","execute","pool","handle","client","executeSQL","sql","entries","obj","key","value","format","Operators","OperatorMap","isOperator","key","hasOperators","value","handleOperator","path","operator","handleIdOperator","format","buildNestedObject","v","subQuery","entries","subKey","subValue","acc","AND","constructFilterQuery","filter","key","value","isRecord","constructComplexFilterQuery","handleOperator","isEquality","hasOperators","entries","nestedKey","val","Operators","format","sql","sqlQuery","params","buildUpdateQuery","update","entries","currentUpdateQuery","op","value","buildSetQuery","buildUnsetQuery","buildIncQuery","buildPushQuery","sql","set","unset","inc","key","push","postgresCollection","collectionName","pool","execute","sql","executeSQL","SqlFor","collectionSQLBuilder","createCollection","document","id","uuid","filter","update","result","row","filterQuery","constructFilterQuery","updateQuery","buildUpdateQuery","postgresClient","connectionString","database","pool","getPool","endPool","name","postgresCollection","getDbClient","connectionString","database","postgresClient","pongoClient","connectionString","dbClient","getDbClient","dbName","FindCursor","documents","callback","docs","doc","Collection","collection","v","doc","_options","result","_docs","_operations","filter","update","_filter","_","_update","_newName","FindCursor","_indexSpec","_indexSpecs","_indexName","_indexes","_key","_replacement","_pipeline","_name","_description","_descriptions","_definition","Db","pongoDb","collectionName","Collection","MongoClient","connectionString","pongoClient","dbName","Db"]}
1
+ {"version":3,"sources":["../src/postgres/pool.ts","../src/postgres/postgresCollection.ts","../src/postgres/execute/index.ts","../src/main/typing/entries.ts","../src/postgres/filter/queryOperators.ts","../src/postgres/filter/index.ts","../src/postgres/sql/index.ts","../src/postgres/update/index.ts","../src/postgres/client.ts","../src/main/dbClient.ts","../src/main/client.ts","../src/mongo/findCursor.ts","../src/mongo/mongoDb.ts","../src/mongo/mongoCollection.ts","../src/mongo/mongoClient.ts"],"sourcesContent":["import pg from 'pg';\n\nconst pools: Map<string, pg.Pool> = new Map();\n\nexport const getPool = (\n connectionStringOrOptions: string | pg.PoolConfig,\n): pg.Pool => {\n const connectionString =\n typeof connectionStringOrOptions === 'string'\n ? connectionStringOrOptions\n : connectionStringOrOptions.connectionString!;\n\n const poolOptions =\n typeof connectionStringOrOptions === 'string'\n ? { connectionString }\n : connectionStringOrOptions;\n\n //TODO: this should include database name resolution for key\n return (\n pools.get(connectionString) ??\n pools.set(connectionString, new pg.Pool(poolOptions)).get(connectionString)!\n );\n};\n\nexport const endPool = async (connectionString: string): Promise<void> => {\n const pool = pools.get(connectionString);\n if (pool) {\n await pool.end();\n pools.delete(connectionString);\n }\n};\n\nexport const endAllPools = () =>\n Promise.all(\n [...pools.keys()].map((connectionString) => endPool(connectionString)),\n );\n","import pg from 'pg';\nimport format from 'pg-format';\nimport { v4 as uuid } from 'uuid';\nimport {\n type PongoCollection,\n type PongoDeleteResult,\n type PongoFilter,\n type PongoInsertManyResult,\n type PongoInsertOneResult,\n type PongoUpdate,\n type PongoUpdateResult,\n type WithId,\n} from '../main';\nimport { executeSQL } from './execute';\nimport { constructFilterQuery } from './filter';\nimport { sql, type SQL } from './sql';\nimport { buildUpdateQuery } from './update';\n\nexport const postgresCollection = <T>(\n collectionName: string,\n pool: pg.Pool,\n): PongoCollection<T> => {\n const execute = (sql: SQL) => executeSQL(pool, sql);\n const SqlFor = collectionSQLBuilder(collectionName);\n\n const createCollection = execute(SqlFor.createCollection());\n\n return {\n createCollection: async () => {\n await createCollection;\n },\n insertOne: async (document: T): Promise<PongoInsertOneResult> => {\n await createCollection;\n\n const _id = uuid();\n\n const result = await execute(SqlFor.insertOne({ _id, ...document }));\n\n return result.rowCount\n ? { insertedId: _id, acknowledged: true }\n : { insertedId: null, acknowledged: false };\n },\n insertMany: async (documents: T[]): Promise<PongoInsertManyResult> => {\n await createCollection;\n\n const rows = documents.map((doc) => ({\n _id: uuid(),\n ...doc,\n }));\n\n const result = await execute(SqlFor.insertMany(rows));\n\n return {\n acknowledged: result.rowCount === rows.length,\n insertedCount: result.rowCount ?? 0,\n insertedIds: rows.map((d) => d._id),\n };\n },\n updateOne: async (\n filter: PongoFilter<T>,\n update: PongoUpdate<T>,\n ): Promise<PongoUpdateResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.updateOne(filter, update));\n return result.rowCount\n ? { acknowledged: true, modifiedCount: result.rowCount }\n : { acknowledged: false, modifiedCount: 0 };\n },\n updateMany: async (\n filter: PongoFilter<T>,\n update: PongoUpdate<T>,\n ): Promise<PongoUpdateResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.updateMany(filter, update));\n return result.rowCount\n ? { acknowledged: true, modifiedCount: result.rowCount }\n : { acknowledged: false, modifiedCount: 0 };\n },\n deleteOne: async (filter: PongoFilter<T>): Promise<PongoDeleteResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.deleteOne(filter));\n return result.rowCount\n ? { acknowledged: true, deletedCount: result.rowCount }\n : { acknowledged: false, deletedCount: 0 };\n },\n deleteMany: async (filter: PongoFilter<T>): Promise<PongoDeleteResult> => {\n await createCollection;\n\n const result = await execute(SqlFor.deleteMany(filter));\n return result.rowCount\n ? { acknowledged: true, deletedCount: result.rowCount }\n : { acknowledged: false, deletedCount: 0 };\n },\n findOne: async (filter: PongoFilter<T>): Promise<T | null> => {\n await createCollection;\n\n const result = await execute(SqlFor.findOne(filter));\n return (result.rows[0]?.data ?? null) as T | null;\n },\n find: async (filter: PongoFilter<T>): Promise<T[]> => {\n await createCollection;\n\n const result = await execute(SqlFor.find(filter));\n return result.rows.map((row) => row.data as T);\n },\n };\n};\n\nexport const collectionSQLBuilder = (collectionName: string) => ({\n createCollection: (): SQL =>\n sql(\n 'CREATE TABLE IF NOT EXISTS %I (_id UUID PRIMARY KEY, data JSONB)',\n collectionName,\n ),\n insertOne: <T>(document: WithId<T>): SQL =>\n sql(\n 'INSERT INTO %I (_id, data) VALUES (%L, %L)',\n collectionName,\n document._id,\n JSON.stringify(document),\n ),\n insertMany: <T>(documents: WithId<T>[]): SQL => {\n const values = documents\n .map((doc) => format('(%L, %L)', doc._id, JSON.stringify(doc)))\n .join(', ');\n return sql('INSERT INTO %I (_id, data) VALUES %s', collectionName, values);\n },\n updateOne: <T>(filter: PongoFilter<T>, update: PongoUpdate<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n const updateQuery = buildUpdateQuery(update);\n\n return sql(\n `WITH cte AS (\n SELECT _id FROM %I WHERE %s LIMIT 1\n )\n UPDATE %I SET data = %s FROM cte WHERE %I._id = cte._id`,\n collectionName,\n filterQuery,\n collectionName,\n updateQuery,\n collectionName,\n );\n },\n updateMany: <T>(filter: PongoFilter<T>, update: PongoUpdate<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n const updateQuery = buildUpdateQuery(update);\n\n return sql(\n 'UPDATE %I SET data = %s WHERE %s',\n collectionName,\n updateQuery,\n filterQuery,\n );\n },\n deleteOne: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql('DELETE FROM %I WHERE %s', collectionName, filterQuery);\n },\n deleteMany: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql('DELETE FROM %I WHERE %s', collectionName, filterQuery);\n },\n findOne: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql(\n 'SELECT data FROM %I WHERE %s LIMIT 1',\n collectionName,\n filterQuery,\n );\n },\n find: <T>(filter: PongoFilter<T>): SQL => {\n const filterQuery = constructFilterQuery(filter);\n return sql('SELECT data FROM %I WHERE %s', collectionName, filterQuery);\n },\n});\n","import type pg from 'pg';\nimport type { SQL } from '../sql';\n\nexport const execute = async <Result = void>(\n pool: pg.Pool,\n handle: (client: pg.PoolClient) => Promise<Result>,\n) => {\n const client = await pool.connect();\n try {\n return await handle(client);\n } finally {\n client.release();\n }\n};\n\nexport const executeSQL = async <\n Result extends pg.QueryResultRow = pg.QueryResultRow,\n>(\n pool: pg.Pool,\n sql: SQL,\n): Promise<pg.QueryResult<Result>> =>\n execute(pool, (client) => client.query<Result>(sql));\n","type Entry<T> = {\n [K in keyof Required<T>]: [K, Required<T>[K]];\n}[keyof Required<T>];\n\ntype IterableEntry<T> = Entry<T> & {\n [Symbol.iterator](): Iterator<Entry<T>>;\n};\n\nexport const entries = <T extends object>(obj: T): IterableEntry<T>[] =>\n Object.entries(obj).map(([key, value]) => [key as keyof T, value]);\n\nexport type NonPartial<T> = { [K in keyof Required<T>]: T[K] };\n","import format from 'pg-format';\nimport { entries } from '../../main/typing';\n\nexport const Operators = {\n $eq: '$eq',\n $gt: '$gt',\n $gte: '$gte',\n $lt: '$lt',\n $lte: '$lte',\n $ne: '$ne',\n $in: '$in',\n $nin: '$nin',\n $elemMatch: '$elemMatch',\n $all: '$all',\n $size: '$size',\n};\n\nconst OperatorMap = {\n $gt: '>',\n $gte: '>=',\n $lt: '<',\n $lte: '<=',\n $ne: '!=',\n};\n\nexport const isOperator = (key: string) => key.startsWith('$');\n\nexport const hasOperators = (value: Record<string, unknown>) =>\n Object.keys(value).some(isOperator);\n\nexport const handleOperator = (\n path: string,\n operator: string,\n value: unknown,\n): string => {\n if (path === '_id') {\n return handleIdOperator(operator, value);\n }\n\n switch (operator) {\n case '$eq':\n return format(\n `(data @> %L::jsonb OR jsonb_path_exists(data, '$.%s[*] ? (@ == %s)'))`,\n JSON.stringify(buildNestedObject(path, value)),\n path,\n JSON.stringify(value),\n );\n case '$gt':\n case '$gte':\n case '$lt':\n case '$lte':\n case '$ne':\n return format(\n `data #>> %L ${OperatorMap[operator]} %L`,\n `{${path.split('.').join(',')}}`,\n value,\n );\n case '$in':\n return format(\n 'data #>> %L IN (%s)',\n `{${path.split('.').join(',')}}`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$nin':\n return format(\n 'data #>> %L NOT IN (%s)',\n `{${path.split('.').join(',')}}`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$elemMatch': {\n const subQuery = entries(value as Record<string, unknown>)\n .map(([subKey, subValue]) =>\n format(`@.\"%s\" == %s`, subKey, JSON.stringify(subValue)),\n )\n .join(' && ');\n return format(\n `jsonb_path_exists(data, '$.%s[*] ? (%s)')`,\n path,\n subQuery,\n );\n }\n case '$all':\n return format(\n 'data @> %L::jsonb',\n JSON.stringify(buildNestedObject(path, value)),\n );\n case '$size':\n return format(\n 'jsonb_array_length(data #> %L) = %L',\n `{${path.split('.').join(',')}}`,\n value,\n );\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n};\n\nconst handleIdOperator = (operator: string, value: unknown): string => {\n switch (operator) {\n case '$eq':\n return format(`_id = %L`, value);\n case '$gt':\n case '$gte':\n case '$lt':\n case '$lte':\n case '$ne':\n return format(`_id ${OperatorMap[operator]} %L`, value);\n case '$in':\n return format(\n `_id IN (%s)`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n case '$nin':\n return format(\n `_id NOT IN (%s)`,\n (value as unknown[]).map((v) => format('%L', v)).join(', '),\n );\n default:\n throw new Error(`Unsupported operator: ${operator}`);\n }\n};\n\nconst buildNestedObject = (\n path: string,\n value: unknown,\n): Record<string, unknown> =>\n path\n .split('.')\n .reverse()\n .reduce((acc, key) => ({ [key]: acc }), value as Record<string, unknown>);\n","import type { PongoFilter } from '../../main';\nimport { entries } from '../../main/typing';\nimport { Operators, handleOperator, hasOperators } from './queryOperators';\n\nexport * from './queryOperators';\n\nconst AND = 'AND';\n\nexport const constructFilterQuery = <T>(filter: PongoFilter<T>): string =>\n Object.entries(filter)\n .map(([key, value]) =>\n isRecord(value)\n ? constructComplexFilterQuery(key, value)\n : handleOperator(key, '$eq', value),\n )\n .join(` ${AND} `);\n\nconst constructComplexFilterQuery = (\n key: string,\n value: Record<string, unknown>,\n): string => {\n const isEquality = !hasOperators(value);\n\n return entries(value)\n .map(\n ([nestedKey, val]) =>\n isEquality\n ? handleOperator(`${key}.${nestedKey}`, Operators.$eq, val) // regular value\n : handleOperator(key, nestedKey, val), // operator\n )\n .join(` ${AND} `);\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n","import format from 'pg-format';\n\nexport type SQL = string & { __brand: 'sql' };\n\nexport const sql = (sqlQuery: string, ...params: unknown[]): SQL => {\n return format(sqlQuery, ...params) as SQL;\n};\n","import type { $inc, $push, $set, $unset, PongoUpdate } from '../../main';\nimport { entries } from '../../main/typing';\nimport { sql, type SQL } from '../sql';\n\nexport const buildUpdateQuery = <T>(update: PongoUpdate<T>): SQL =>\n entries(update).reduce((currentUpdateQuery, [op, value]) => {\n switch (op) {\n case '$set':\n return buildSetQuery(value, currentUpdateQuery);\n case '$unset':\n return buildUnsetQuery(value, currentUpdateQuery);\n case '$inc':\n return buildIncQuery(value, currentUpdateQuery);\n case '$push':\n return buildPushQuery(value, currentUpdateQuery);\n default:\n return currentUpdateQuery;\n }\n }, sql('data'));\n\nexport const buildSetQuery = <T>(set: $set<T>, currentUpdateQuery: SQL): SQL =>\n sql(\n 'jsonb_set(%s, %L, data || %L)',\n currentUpdateQuery,\n '{}',\n JSON.stringify(set),\n );\n\nexport const buildUnsetQuery = <T>(\n unset: $unset<T>,\n currentUpdateQuery: SQL,\n): SQL => sql('%s - %L', currentUpdateQuery, Object.keys(unset).join(', '));\n\nexport const buildIncQuery = <T>(\n inc: $inc<T>,\n currentUpdateQuery: SQL,\n): SQL => {\n for (const [key, value] of Object.entries(inc)) {\n currentUpdateQuery = sql(\n \"jsonb_set(%s, '{%s}', to_jsonb((data->>'%s')::numeric + %L))\",\n currentUpdateQuery,\n key,\n key,\n value,\n );\n }\n return currentUpdateQuery;\n};\n\nexport const buildPushQuery = <T>(\n push: $push<T>,\n currentUpdateQuery: SQL,\n): SQL => {\n for (const [key, value] of Object.entries(push)) {\n currentUpdateQuery = sql(\n \"jsonb_set(%s, '{%s}', (COALESCE(data->'%s', '[]'::jsonb) || '[%s]'::jsonb))\",\n currentUpdateQuery,\n key,\n key,\n JSON.stringify(value),\n );\n }\n return currentUpdateQuery;\n};\n","import { type DbClient } from '../main';\nimport { endPool, getPool } from './pool';\nimport { postgresCollection } from './postgresCollection';\n\nexport const postgresClient = (\n connectionString: string,\n database?: string,\n): DbClient => {\n const pool = getPool({ connectionString, database });\n\n return {\n connect: () => Promise.resolve(),\n close: () => endPool(connectionString),\n collection: <T>(name: string) => postgresCollection<T>(name, pool),\n };\n};\n","import { postgresClient } from '../postgres';\nimport type { PongoCollection } from './typing/operations';\n\nexport interface DbClient {\n connect(): Promise<void>;\n close(): Promise<void>;\n collection: <T>(name: string) => PongoCollection<T>;\n}\n\nexport const getDbClient = (\n connectionString: string,\n database?: string,\n): DbClient => {\n // This is the place where in the future could come resolution of other database types\n return postgresClient(connectionString, database);\n};\n","import { getDbClient } from './dbClient';\nimport type { PongoClient, PongoDb } from './typing/operations';\n\nexport const pongoClient = (connectionString: string): PongoClient => {\n const dbClient = getDbClient(connectionString);\n\n const pongoClient: PongoClient = {\n connect: async () => {\n await dbClient.connect();\n return pongoClient;\n },\n close: () => dbClient.close(),\n db: (dbName?: string): PongoDb =>\n dbName ? getDbClient(connectionString, dbName) : dbClient,\n };\n\n return pongoClient;\n};\n","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 { Collection as MongoCollection, type Document } from 'mongodb';\nimport type { PongoDb } from '../main';\nimport { Collection } from './mongoCollection';\n\nexport class Db {\n constructor(private pongoDb: PongoDb) {}\n\n collection<T extends Document>(collectionName: string): MongoCollection<T> {\n return new Collection<T>(this.pongoDb.collection<T>(collectionName));\n }\n}\n","import type {\n AbstractCursorOptions,\n AggregateOptions,\n AggregationCursor,\n AnyBulkWriteOperation,\n BSONSerializeOptions,\n BulkWriteOptions,\n BulkWriteResult,\n ChangeStream,\n ChangeStreamDocument,\n ChangeStreamOptions,\n CommandOperationOptions,\n CountDocumentsOptions,\n CountOptions,\n CreateIndexesOptions,\n DeleteOptions,\n DeleteResult,\n Document,\n DropCollectionOptions,\n EnhancedOmit,\n EstimatedDocumentCountOptions,\n Filter,\n FindOneAndDeleteOptions,\n FindOneAndReplaceOptions,\n FindOneAndUpdateOptions,\n FindOptions,\n Flatten,\n Hint,\n IndexDescription,\n IndexDescriptionCompact,\n IndexDescriptionInfo,\n IndexInformationOptions,\n IndexSpecification,\n InferIdType,\n InsertManyResult,\n InsertOneOptions,\n InsertOneResult,\n ListIndexesCursor,\n ListSearchIndexesCursor,\n ListSearchIndexesOptions,\n ModifyResult,\n Collection as MongoCollection,\n FindCursor as MongoFindCursor,\n 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 { PongoCollection, PongoFilter, PongoUpdate } from '../main';\nimport { FindCursor } from './findCursor';\n\nexport class Collection<T extends Document> implements MongoCollection<T> {\n private collection: PongoCollection<T>;\n\n constructor(collection: PongoCollection<T>) {\n this.collection = collection;\n }\n get dbName(): string {\n throw new Error('Method not implemented.');\n }\n get collectionName(): string {\n throw new Error('Method not implemented.');\n }\n get namespace(): string {\n throw new Error('Method not implemented.');\n }\n get readConcern(): ReadConcern | undefined {\n throw new Error('Method not implemented.');\n }\n get readPreference(): ReadPreference | undefined {\n throw new Error('Method not implemented.');\n }\n get bsonOptions(): BSONSerializeOptions {\n throw new Error('Method not implemented.');\n }\n get writeConcern(): WriteConcern | undefined {\n throw new Error('Method not implemented.');\n }\n get hint(): Hint | undefined {\n throw new Error('Method not implemented.');\n }\n set hint(v: Hint | undefined) {\n throw new Error('Method not implemented.');\n }\n async insertOne(\n doc: OptionalUnlessRequiredId<T>,\n _options?: InsertOneOptions | undefined,\n ): Promise<InsertOneResult<T>> {\n const result = await this.collection.insertOne(doc as T);\n return {\n acknowledged: result.acknowledged,\n insertedId: result.insertedId as unknown as InferIdType<T>,\n };\n }\n async insertMany(\n docs: OptionalUnlessRequiredId<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<InsertManyResult<T>> {\n const result = await this.collection.insertMany(docs as T[]);\n return {\n acknowledged: result.acknowledged,\n insertedIds: result.insertedIds as unknown as InferIdType<T>[],\n insertedCount: result.insertedCount,\n };\n }\n bulkWrite(\n _operations: AnyBulkWriteOperation<T>[],\n _options?: BulkWriteOptions | undefined,\n ): Promise<BulkWriteResult> {\n throw new Error('Method not implemented.');\n }\n async updateOne(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n _options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateOne(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n );\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 _: WithoutId<T>,\n _options?: ReplaceOptions | undefined,\n ): Promise<Document | UpdateResult<T>> {\n throw new Error('Method not implemented.');\n }\n async updateMany(\n filter: Filter<T>,\n update: Document[] | UpdateFilter<T>,\n _options?: UpdateOptions | undefined,\n ): Promise<UpdateResult<T>> {\n const result = await this.collection.updateMany(\n filter as unknown as PongoFilter<T>,\n update as unknown as PongoUpdate<T>,\n );\n\n return {\n acknowledged: result.acknowledged,\n matchedCount: result.modifiedCount,\n modifiedCount: result.modifiedCount,\n upsertedCount: result.modifiedCount,\n upsertedId: null,\n };\n }\n async deleteOne(\n filter?: Filter<T> | undefined,\n _options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteOne(\n filter as unknown as PongoFilter<T>,\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n async deleteMany(\n filter?: Filter<T> | undefined,\n _options?: DeleteOptions | undefined,\n ): Promise<DeleteResult> {\n const result = await this.collection.deleteMany(\n filter as unknown as PongoFilter<T>,\n );\n\n return {\n acknowledged: result.acknowledged,\n deletedCount: result.deletedCount,\n };\n }\n rename(\n _newName: string,\n _options?: RenameOptions | undefined,\n ): Promise<Collection<Document>> {\n throw new Error('Method not implemented.');\n }\n drop(_options?: DropCollectionOptions | undefined): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n findOne(): Promise<WithId<T> | null>;\n findOne(filter: Filter<T>): Promise<WithId<T> | null>;\n findOne(\n filter: Filter<T>,\n options: FindOptions<Document>,\n ): Promise<WithId<T> | null>;\n findOne<TS = T>(): Promise<TS | null>;\n findOne<TS = T>(filter: Filter<TS>): Promise<TS | null>;\n findOne<TS = T>(\n filter: Filter<TS>,\n options?: FindOptions<Document> | undefined,\n ): Promise<TS | null>;\n async findOne(\n filter?: unknown,\n _options?: unknown,\n ): Promise<import('mongodb').WithId<T> | T | null> {\n return this.collection.findOne(filter as PongoFilter<T>);\n }\n find(): MongoFindCursor<WithId<T>>;\n find(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<WithId<T>>;\n find<T extends Document>(\n filter: Filter<T>,\n options?: FindOptions<Document> | undefined,\n ): MongoFindCursor<T>;\n find(\n filter?: unknown,\n _options?: unknown,\n ): MongoFindCursor<WithId<T>> | MongoFindCursor<T> {\n return new FindCursor(\n this.collection.find(filter as PongoFilter<T>),\n ) as unknown as MongoFindCursor<T>;\n }\n options(_options?: OperationOptions | undefined): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n isCapped(_options?: OperationOptions | undefined): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n createIndex(\n _indexSpec: IndexSpecification,\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createIndexes(\n _indexSpecs: IndexDescription[],\n _options?: CreateIndexesOptions | undefined,\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropIndex(\n _indexName: string,\n _options?: CommandOperationOptions | undefined,\n ): Promise<Document> {\n throw new Error('Method not implemented.');\n }\n dropIndexes(\n _options?: CommandOperationOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n listIndexes(_options?: AbstractCursorOptions | undefined): ListIndexesCursor {\n throw new Error('Method not implemented.');\n }\n indexExists(\n _indexes: string | string[],\n _options?: AbstractCursorOptions | undefined,\n ): Promise<boolean> {\n throw new Error('Method not implemented.');\n }\n indexInformation(\n options: IndexInformationOptions & { full: true },\n ): Promise<IndexDescriptionInfo[]>;\n indexInformation(\n options: IndexInformationOptions & { full?: false | undefined },\n ): Promise<IndexDescriptionCompact>;\n indexInformation(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexInformation(): Promise<IndexDescriptionCompact>;\n indexInformation(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n estimatedDocumentCount(\n _options?: EstimatedDocumentCountOptions | undefined,\n ): Promise<number> {\n throw new Error('Method not implemented.');\n }\n countDocuments(\n _filter?: Filter<T> | undefined,\n _options?: CountDocumentsOptions | undefined,\n ): Promise<number> {\n throw new Error('Method not implemented.');\n }\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n distinct<Key extends '_id' | keyof EnhancedOmit<T, '_id'>>(\n key: Key,\n filter: Filter<T>,\n options: CommandOperationOptions,\n ): Promise<Flatten<WithId<T>[Key]>[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string): Promise<any[]>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n distinct(key: string, filter: Filter<T>): Promise<any[]>;\n distinct(\n key: string,\n filter: Filter<T>,\n options: CommandOperationOptions, // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<any[]>;\n distinct(\n _key: unknown,\n _filter?: unknown,\n _options?: unknown,\n ): // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Promise<any[]>\n | Promise<import('mongodb').Flatten<import('mongodb').WithId<T>[Key]>[]> {\n throw new Error('Method not implemented.');\n }\n indexes(\n options: IndexInformationOptions & { full?: true | undefined },\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n options: IndexInformationOptions & { full: false },\n ): Promise<IndexDescriptionCompact>;\n indexes(\n options: IndexInformationOptions,\n ): Promise<IndexDescriptionCompact | IndexDescriptionInfo[]>;\n indexes(\n options?: AbstractCursorOptions | undefined,\n ): Promise<IndexDescriptionInfo[]>;\n indexes(\n _options?: unknown,\n ):\n | Promise<import('mongodb').IndexDescriptionInfo[]>\n | Promise<import('mongodb').IndexDescriptionCompact>\n | Promise<\n | import('mongodb').IndexDescriptionCompact\n | import('mongodb').IndexDescriptionInfo[]\n > {\n throw new Error('Method not implemented.');\n }\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: true },\n ): Promise<ModifyResult<T>>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions & { includeResultMetadata: false },\n ): Promise<WithId<T> | null>;\n findOneAndDelete(\n filter: Filter<T>,\n options: FindOneAndDeleteOptions,\n ): Promise<WithId<T> | null>;\n findOneAndDelete(filter: Filter<T>): Promise<WithId<T> | null>;\n findOneAndDelete(\n _filter: unknown,\n _options?: unknown,\n ):\n | Promise<import('mongodb').WithId<T> | null>\n | Promise<import('mongodb').ModifyResult<T>> {\n throw new Error('Method not implemented.');\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?: unknown,\n ):\n | Promise<import('mongodb').WithId<T> | null>\n | Promise<import('mongodb').ModifyResult<T>> {\n throw new Error('Method not implemented.');\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?: unknown,\n ):\n | Promise<import('mongodb').WithId<T> | null>\n | Promise<import('mongodb').ModifyResult<T>> {\n throw new Error('Method not implemented.');\n }\n aggregate<T extends Document = Document>(\n _pipeline?: Document[] | undefined,\n _options?: AggregateOptions | undefined,\n ): AggregationCursor<T> {\n throw new Error('Method not implemented.');\n }\n watch<\n TLocal extends Document = T,\n TChange extends Document = ChangeStreamDocument<TLocal>,\n >(\n _pipeline?: Document[] | undefined,\n _options?: ChangeStreamOptions | undefined,\n ): ChangeStream<TLocal, TChange> {\n throw new Error('Method not implemented.');\n }\n initializeUnorderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): UnorderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n initializeOrderedBulkOp(\n _options?: BulkWriteOptions | undefined,\n ): OrderedBulkOperation {\n throw new Error('Method not implemented.');\n }\n count(\n _filter?: Filter<T> | undefined,\n _options?: CountOptions | undefined,\n ): Promise<number> {\n throw new Error('Method not implemented.');\n }\n listSearchIndexes(\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n name: string,\n options?: ListSearchIndexesOptions | undefined,\n ): ListSearchIndexesCursor;\n listSearchIndexes(\n _name?: unknown,\n _options?: unknown,\n ): import('mongodb').ListSearchIndexesCursor {\n throw new Error('Method not implemented.');\n }\n createSearchIndex(_description: SearchIndexDescription): Promise<string> {\n throw new Error('Method not implemented.');\n }\n createSearchIndexes(\n _descriptions: SearchIndexDescription[],\n ): Promise<string[]> {\n throw new Error('Method not implemented.');\n }\n dropSearchIndex(_name: string): Promise<void> {\n throw new Error('Method not implemented.');\n }\n updateSearchIndex(_name: string, _definition: Document): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async createCollection(): Promise<void> {\n await this.collection.createCollection();\n }\n}\n","// src/MongoClientShim.ts\nimport { pongoClient, type PongoClient } from '../main';\nimport { Db } from './mongoDb';\n\nexport class MongoClient {\n private pongoClient: PongoClient;\n\n constructor(connectionString: string) {\n this.pongoClient = pongoClient(connectionString);\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}\n"],"mappings":"AAAA,OAAOA,MAAQ,KAEf,IAAMC,EAA8B,IAAI,IAE3BC,EACXC,GACY,CACZ,IAAMC,EACJ,OAAOD,GAA8B,SACjCA,EACAA,EAA0B,iBAE1BE,EACJ,OAAOF,GAA8B,SACjC,CAAE,iBAAAC,CAAiB,EACnBD,EAGN,OACEF,EAAM,IAAIG,CAAgB,GAC1BH,EAAM,IAAIG,EAAkB,IAAIJ,EAAG,KAAKK,CAAW,CAAC,EAAE,IAAID,CAAgB,CAE9E,EAEaE,EAAU,MAAOF,GAA4C,CACxE,IAAMG,EAAON,EAAM,IAAIG,CAAgB,EACnCG,IACF,MAAMA,EAAK,IAAI,EACfN,EAAM,OAAOG,CAAg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YAAY,QAAQ,EACxB,IACT,CAEA,MAAM,OAAQ,CACZ,MAAM,KAAK,YAAY,MAAM,CAC/B,CAEA,GAAGE,EAAoB,CACrB,OAAO,IAAIC,EAAG,KAAK,YAAY,GAAGD,CAAM,CAAC,CAC3C,CACF","names":["pg","pools","getPool","connectionStringOrOptions","connectionString","poolOptions","endPool","pool","endAllPools","format","uuid","execute","pool","handle","client","executeSQL","sql","entries","obj","key","value","format","Operators","OperatorMap","isOperator","key","hasOperators","value","handleOperator","path","operator","handleIdOperator","format","buildNestedObject","v","subQuery","entries","subKey","subValue","acc","AND","constructFilterQuery","filter","key","value","isRecord","constructComplexFilterQuery","handleOperator","isEquality","hasOperators","entries","nestedKey","val","Operators","format","sql","sqlQuery","params","buildUpdateQuery","update","entries","currentUpdateQuery","op","value","buildSetQuery","buildUnsetQuery","buildIncQuery","buildPushQuery","sql","set","unset","inc","key","push","postgresCollection","collectionName","pool","execute","sql","executeSQL","SqlFor","collectionSQLBuilder","createCollection","document","_id","uuid","documents","rows","doc","result","d","filter","update","row","values","format","filterQuery","constructFilterQuery","updateQuery","buildUpdateQuery","postgresClient","connectionString","database","pool","getPool","endPool","name","postgresCollection","getDbClient","connectionString","database","postgresClient","pongoClient","connectionString","dbClient","getDbClient","dbName","FindCursor","documents","callback","docs","doc","Collection","collection","v","doc","_options","result","docs","_operations","filter","update","_filter","_","_newName","FindCursor","_indexSpec","_indexSpecs","_indexName","_indexes","_key","_replacement","_update","_pipeline","_name","_description","_descriptions","_definition","Db","pongoDb","collectionName","Collection","MongoClient","connectionString","pongoClient","dbName","Db"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@event-driven-io/pongo",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Pongo - Mongo with strong consistency on top of Postgres",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -47,13 +47,12 @@
47
47
  "dist"
48
48
  ],
49
49
  "peerDependencies": {
50
- "@types/uuid": "^9.0.8",
51
- "close-with-grace": "^1.3.0",
52
50
  "pg": "^8.12.0",
53
51
  "pg-format": "^1.0.4",
54
52
  "uuid": "^9.0.1"
55
53
  },
56
54
  "devDependencies": {
55
+ "@types/uuid": "^9.0.8",
57
56
  "@types/node": "20.11.30",
58
57
  "@types/pg": "^8.11.6",
59
58
  "@types/pg-format": "^1.0.5"