@xylabs/mongo 5.1.1 → 5.1.3

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.
@@ -169,4 +169,4 @@ export {
169
169
  BaseMongoSdk,
170
170
  MongoClientWrapper
171
171
  };
172
- //# sourceMappingURL=index.mjs.map
172
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1,7 @@
1
- {"version":3,"sources":["../../src/Base.ts","../../src/Wrapper.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type {\n BulkWriteOptions,\n Collection,\n DeleteResult,\n Document,\n Filter,\n FindCursor,\n InsertOneOptions,\n MongoClient,\n OptionalUnlessRequiredId,\n ReplaceOptions,\n UpdateFilter,\n WithId,\n} from 'mongodb'\n\nimport type { BaseMongoSdkConfig } from './Config.js'\nimport { MongoClientWrapper } from './Wrapper.js'\n\n/** Provides a typed wrapper around common MongoDB collection operations. */\nexport class BaseMongoSdk<T extends Document> {\n /** The MongoDB SDK configuration for this instance. */\n config: BaseMongoSdkConfig\n\n constructor(config: BaseMongoSdkConfig) {\n this.config = config\n }\n\n /** Returns the MongoDB connection URI, either from the config or constructed from individual credential fields. */\n get uri() {\n return (\n this.config.dbConnectionString\n ?? `mongodb+srv://${this.config.dbUserName}:${this.config.dbPassword}@${this.config.dbDomain}.mongodb.net/${this.config.dbName}?retryWrites=true&w=majority`\n )\n }\n\n /**\n * Deletes all documents matching the filter.\n * @param filter - The query filter to match documents for deletion\n */\n async deleteMany(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteMany(filter)\n })\n }\n\n /**\n * Deletes the first document matching the filter.\n * @param filter - The query filter to match a document for deletion\n */\n async deleteOne(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteOne(filter)\n })\n }\n\n /**\n * Finds all documents matching the filter and returns a cursor.\n * @param filter - The query filter\n */\n async find(filter: Filter<T>) {\n return await this.useCollection<FindCursor<WithId<T>>>((collection: Collection<T>) => {\n return collection.find(filter)\n })\n }\n\n /**\n * Finds a single document matching the filter.\n * @param filter - The query filter\n * @returns The matched document, or `null` if not found\n */\n async findOne(filter: Filter<T>) {\n return await this.useCollection<WithId<T> | null>(async (collection: Collection<T>) => {\n return await collection.findOne(filter)\n })\n }\n\n /**\n * Inserts multiple documents into the collection.\n * @param items - The documents to insert\n * @param options - Optional bulk write options\n */\n async insertMany(items: OptionalUnlessRequiredId<T>[], options?: BulkWriteOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertMany(items, options)\n })\n }\n\n /**\n * Inserts a single document into the collection.\n * @param item - The document to insert\n * @param options - Optional insert options\n */\n async insertOne(item: OptionalUnlessRequiredId<T>, options?: InsertOneOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertOne(item, options)\n })\n }\n\n /**\n * Replaces a single document matching the filter.\n * @param filter - The query filter to match the document\n * @param item - The replacement document\n * @param options - Optional replace options\n */\n async replaceOne(filter: Filter<T>, item: OptionalUnlessRequiredId<T>, options?: ReplaceOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.replaceOne(filter, item, options)\n })\n }\n\n /**\n * Updates a single document matching the filter without upserting.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async updateOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: false })\n })\n }\n\n /**\n * Updates a single document matching the filter, inserting it if it does not exist.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async upsertOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: true })\n })\n }\n\n /**\n * Executes a callback with access to the configured MongoDB collection.\n * @param func - A callback receiving the typed collection\n * @returns The result of the callback\n */\n async useCollection<R>(func: (collection: Collection<T>) => Promise<R> | R) {\n return await this.useMongo<R>(async (client: MongoClient) => {\n return await func(client.db(this.config.dbName).collection<T>(this.config.collection))\n })\n }\n\n /**\n * Executes a callback with a connected MongoClient, handling connection and disconnection.\n * @param func - A callback receiving the connected MongoClient\n * @returns The result of the callback\n */\n async useMongo<R>(func: (client: MongoClient) => Promise<R> | R) {\n const wrapper = MongoClientWrapper.get(this.uri, this.config.maxPoolSize, this.config.closeDelay)\n const connection = await wrapper.connect()\n assertEx(connection, () => 'Connection failed')\n try {\n return await func(connection)\n } finally {\n await wrapper.disconnect()\n }\n }\n}\n","import type { MongoClientOptions } from 'mongodb'\nimport { MongoClient } from 'mongodb'\n\n/** Manages a shared pool of MongoClient instances, reusing connections by URI. */\nexport class MongoClientWrapper {\n /** Global cache of wrapper instances keyed by connection URI. */\n static readonly clients = new Map<string, MongoClientWrapper>()\n\n private client: MongoClient\n\n constructor(uri: string, maxPoolSize?: number, closeDelay?: number) {\n const options: MongoClientOptions = { maxPoolSize, maxIdleTimeMS: closeDelay }\n this.client = new MongoClient(uri, options)\n }\n\n /**\n * Gets or creates a cached MongoClientWrapper for the given URI.\n * @param uri - The MongoDB connection URI\n * @param poolSize - Maximum connection pool size\n * @param closeDelay - Delay in milliseconds before closing idle connections\n * @returns A cached or newly created wrapper instance\n */\n static get(uri: string, poolSize?: number, closeDelay?: number) {\n let client = this.clients.get(uri)\n if (!client) {\n client = new MongoClientWrapper(uri, poolSize, closeDelay)\n this.clients.set(uri, client)\n }\n return client\n }\n\n /** Connects to MongoDB and returns the underlying MongoClient. */\n async connect() {\n return await Promise.resolve(this.client)\n }\n\n /** Disconnects from MongoDB. */\n async disconnect() {\n return await Promise.resolve(0)\n }\n\n /** Initiates a graceful close of the connection. */\n async initiateClose() {\n await Promise.resolve()\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;;;ACCzB,SAAS,mBAAmB;AAGrB,IAAM,qBAAN,MAAM,oBAAmB;AAAA;AAAA,EAE9B,OAAgB,UAAU,oBAAI,IAA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AAC1D,WAAO,MAAM,KAAK,cAAc,OAAO,eAA8B;AACnE,aAAO,MAAM,WAAW,UAAU,QAAQ,QAAQ,EAAE,QAAQ,KAAK,CAAC;AAAA,IACpE,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAiB,MAAqD;AAC1E,WAAO,MAAM,KAAK,SAAY,OAAO,WAAwB;AAC3D,aAAO,MAAM,KAAK,OAAO,GAAG,KAAK,OAAO,MAAM,EAAE,WAAc,KAAK,OAAO,UAAU,CAAC;AAAA,IACvF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,SAAY,MAA+C;AAC/D,UAAM,UAAU,mBAAmB,IAAI,KAAK,KAAK,KAAK,OAAO,aAAa,KAAK,OAAO,UAAU;AAChG,UAAM,aAAa,MAAM,QAAQ,QAAQ;AACzC,aAAS,YAAY,MAAM,mBAAmB;AAC9C,QAAI;AACF,aAAO,MAAM,KAAK,UAAU;AAAA,IAC9B,UAAE;AACA,YAAM,QAAQ,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;","names":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Base.ts", "../../src/Wrapper.ts"],
4
+ "sourcesContent": ["import { assertEx } from '@xylabs/assert'\nimport type {\n BulkWriteOptions,\n Collection,\n DeleteResult,\n Document,\n Filter,\n FindCursor,\n InsertOneOptions,\n MongoClient,\n OptionalUnlessRequiredId,\n ReplaceOptions,\n UpdateFilter,\n WithId,\n} from 'mongodb'\n\nimport type { BaseMongoSdkConfig } from './Config.js'\nimport { MongoClientWrapper } from './Wrapper.js'\n\n/** Provides a typed wrapper around common MongoDB collection operations. */\nexport class BaseMongoSdk<T extends Document> {\n /** The MongoDB SDK configuration for this instance. */\n config: BaseMongoSdkConfig\n\n constructor(config: BaseMongoSdkConfig) {\n this.config = config\n }\n\n /** Returns the MongoDB connection URI, either from the config or constructed from individual credential fields. */\n get uri() {\n return (\n this.config.dbConnectionString\n ?? `mongodb+srv://${this.config.dbUserName}:${this.config.dbPassword}@${this.config.dbDomain}.mongodb.net/${this.config.dbName}?retryWrites=true&w=majority`\n )\n }\n\n /**\n * Deletes all documents matching the filter.\n * @param filter - The query filter to match documents for deletion\n */\n async deleteMany(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteMany(filter)\n })\n }\n\n /**\n * Deletes the first document matching the filter.\n * @param filter - The query filter to match a document for deletion\n */\n async deleteOne(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteOne(filter)\n })\n }\n\n /**\n * Finds all documents matching the filter and returns a cursor.\n * @param filter - The query filter\n */\n async find(filter: Filter<T>) {\n return await this.useCollection<FindCursor<WithId<T>>>((collection: Collection<T>) => {\n return collection.find(filter)\n })\n }\n\n /**\n * Finds a single document matching the filter.\n * @param filter - The query filter\n * @returns The matched document, or `null` if not found\n */\n async findOne(filter: Filter<T>) {\n return await this.useCollection<WithId<T> | null>(async (collection: Collection<T>) => {\n return await collection.findOne(filter)\n })\n }\n\n /**\n * Inserts multiple documents into the collection.\n * @param items - The documents to insert\n * @param options - Optional bulk write options\n */\n async insertMany(items: OptionalUnlessRequiredId<T>[], options?: BulkWriteOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertMany(items, options)\n })\n }\n\n /**\n * Inserts a single document into the collection.\n * @param item - The document to insert\n * @param options - Optional insert options\n */\n async insertOne(item: OptionalUnlessRequiredId<T>, options?: InsertOneOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertOne(item, options)\n })\n }\n\n /**\n * Replaces a single document matching the filter.\n * @param filter - The query filter to match the document\n * @param item - The replacement document\n * @param options - Optional replace options\n */\n async replaceOne(filter: Filter<T>, item: OptionalUnlessRequiredId<T>, options?: ReplaceOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.replaceOne(filter, item, options)\n })\n }\n\n /**\n * Updates a single document matching the filter without upserting.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async updateOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: false })\n })\n }\n\n /**\n * Updates a single document matching the filter, inserting it if it does not exist.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async upsertOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: true })\n })\n }\n\n /**\n * Executes a callback with access to the configured MongoDB collection.\n * @param func - A callback receiving the typed collection\n * @returns The result of the callback\n */\n async useCollection<R>(func: (collection: Collection<T>) => Promise<R> | R) {\n return await this.useMongo<R>(async (client: MongoClient) => {\n return await func(client.db(this.config.dbName).collection<T>(this.config.collection))\n })\n }\n\n /**\n * Executes a callback with a connected MongoClient, handling connection and disconnection.\n * @param func - A callback receiving the connected MongoClient\n * @returns The result of the callback\n */\n async useMongo<R>(func: (client: MongoClient) => Promise<R> | R) {\n const wrapper = MongoClientWrapper.get(this.uri, this.config.maxPoolSize, this.config.closeDelay)\n const connection = await wrapper.connect()\n assertEx(connection, () => 'Connection failed')\n try {\n return await func(connection)\n } finally {\n await wrapper.disconnect()\n }\n }\n}\n", "import type { MongoClientOptions } from 'mongodb'\nimport { MongoClient } from 'mongodb'\n\n/** Manages a shared pool of MongoClient instances, reusing connections by URI. */\nexport class MongoClientWrapper {\n /** Global cache of wrapper instances keyed by connection URI. */\n static readonly clients = new Map<string, MongoClientWrapper>()\n\n private client: MongoClient\n\n constructor(uri: string, maxPoolSize?: number, closeDelay?: number) {\n const options: MongoClientOptions = { maxPoolSize, maxIdleTimeMS: closeDelay }\n this.client = new MongoClient(uri, options)\n }\n\n /**\n * Gets or creates a cached MongoClientWrapper for the given URI.\n * @param uri - The MongoDB connection URI\n * @param poolSize - Maximum connection pool size\n * @param closeDelay - Delay in milliseconds before closing idle connections\n * @returns A cached or newly created wrapper instance\n */\n static get(uri: string, poolSize?: number, closeDelay?: number) {\n let client = this.clients.get(uri)\n if (!client) {\n client = new MongoClientWrapper(uri, poolSize, closeDelay)\n this.clients.set(uri, client)\n }\n return client\n }\n\n /** Connects to MongoDB and returns the underlying MongoClient. */\n async connect() {\n return await Promise.resolve(this.client)\n }\n\n /** Disconnects from MongoDB. */\n async disconnect() {\n return await Promise.resolve(0)\n }\n\n /** Initiates a graceful close of the connection. */\n async initiateClose() {\n await Promise.resolve()\n }\n}\n"],
5
+ "mappings": ";AAAA,SAAS,gBAAgB;;;ACCzB,SAAS,mBAAmB;AAGrB,IAAM,qBAAN,MAAM,oBAAmB;AAAA;AAAA,EAE9B,OAAgB,UAAU,oBAAI,IAAgC;AAAA,EAEtD;AAAA,EAER,YAAY,KAAa,aAAsB,YAAqB;AAClE,UAAM,UAA8B,EAAE,aAAa,eAAe,WAAW;AAC7E,SAAK,SAAS,IAAI,YAAY,KAAK,OAAO;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,OAAO,IAAI,KAAa,UAAmB,YAAqB;AAC9D,QAAI,SAAS,KAAK,QAAQ,IAAI,GAAG;AACjC,QAAI,CAAC,QAAQ;AACX,eAAS,IAAI,oBAAmB,KAAK,UAAU,UAAU;AACzD,WAAK,QAAQ,IAAI,KAAK,MAAM;AAAA,IAC9B;AACA,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,MAAM,UAAU;AACd,WAAO,MAAM,QAAQ,QAAQ,KAAK,MAAM;AAAA,EAC1C;AAAA;AAAA,EAGA,MAAM,aAAa;AACjB,WAAO,MAAM,QAAQ,QAAQ,CAAC;AAAA,EAChC;AAAA;AAAA,EAGA,MAAM,gBAAgB;AACpB,UAAM,QAAQ,QAAQ;AAAA,EACxB;AACF;;;ADzBO,IAAM,eAAN,MAAuC;AAAA;AAAA,EAE5C;AAAA,EAEA,YAAY,QAA4B;AAC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
169
  BaseMongoSdk,
170
170
  MongoClientWrapper
171
171
  };
172
- //# sourceMappingURL=index.mjs.map
172
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1,7 @@
1
- {"version":3,"sources":["../../src/Base.ts","../../src/Wrapper.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type {\n BulkWriteOptions,\n Collection,\n DeleteResult,\n Document,\n Filter,\n FindCursor,\n InsertOneOptions,\n MongoClient,\n OptionalUnlessRequiredId,\n ReplaceOptions,\n UpdateFilter,\n WithId,\n} from 'mongodb'\n\nimport type { BaseMongoSdkConfig } from './Config.js'\nimport { MongoClientWrapper } from './Wrapper.js'\n\n/** Provides a typed wrapper around common MongoDB collection operations. */\nexport class BaseMongoSdk<T extends Document> {\n /** The MongoDB SDK configuration for this instance. */\n config: BaseMongoSdkConfig\n\n constructor(config: BaseMongoSdkConfig) {\n this.config = config\n }\n\n /** Returns the MongoDB connection URI, either from the config or constructed from individual credential fields. */\n get uri() {\n return (\n this.config.dbConnectionString\n ?? `mongodb+srv://${this.config.dbUserName}:${this.config.dbPassword}@${this.config.dbDomain}.mongodb.net/${this.config.dbName}?retryWrites=true&w=majority`\n )\n }\n\n /**\n * Deletes all documents matching the filter.\n * @param filter - The query filter to match documents for deletion\n */\n async deleteMany(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteMany(filter)\n })\n }\n\n /**\n * Deletes the first document matching the filter.\n * @param filter - The query filter to match a document for deletion\n */\n async deleteOne(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteOne(filter)\n })\n }\n\n /**\n * Finds all documents matching the filter and returns a cursor.\n * @param filter - The query filter\n */\n async find(filter: Filter<T>) {\n return await this.useCollection<FindCursor<WithId<T>>>((collection: Collection<T>) => {\n return collection.find(filter)\n })\n }\n\n /**\n * Finds a single document matching the filter.\n * @param filter - The query filter\n * @returns The matched document, or `null` if not found\n */\n async findOne(filter: Filter<T>) {\n return await this.useCollection<WithId<T> | null>(async (collection: Collection<T>) => {\n return await collection.findOne(filter)\n })\n }\n\n /**\n * Inserts multiple documents into the collection.\n * @param items - The documents to insert\n * @param options - Optional bulk write options\n */\n async insertMany(items: OptionalUnlessRequiredId<T>[], options?: BulkWriteOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertMany(items, options)\n })\n }\n\n /**\n * Inserts a single document into the collection.\n * @param item - The document to insert\n * @param options - Optional insert options\n */\n async insertOne(item: OptionalUnlessRequiredId<T>, options?: InsertOneOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertOne(item, options)\n })\n }\n\n /**\n * Replaces a single document matching the filter.\n * @param filter - The query filter to match the document\n * @param item - The replacement document\n * @param options - Optional replace options\n */\n async replaceOne(filter: Filter<T>, item: OptionalUnlessRequiredId<T>, options?: ReplaceOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.replaceOne(filter, item, options)\n })\n }\n\n /**\n * Updates a single document matching the filter without upserting.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async updateOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: false })\n })\n }\n\n /**\n * Updates a single document matching the filter, inserting it if it does not exist.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async upsertOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: true })\n })\n }\n\n /**\n * Executes a callback with access to the configured MongoDB collection.\n * @param func - A callback receiving the typed collection\n * @returns The result of the callback\n */\n async useCollection<R>(func: (collection: Collection<T>) => Promise<R> | R) {\n return await this.useMongo<R>(async (client: MongoClient) => {\n return await func(client.db(this.config.dbName).collection<T>(this.config.collection))\n })\n }\n\n /**\n * Executes a callback with a connected MongoClient, handling connection and disconnection.\n * @param func - A callback receiving the connected MongoClient\n * @returns The result of the callback\n */\n async useMongo<R>(func: (client: MongoClient) => Promise<R> | R) {\n const wrapper = MongoClientWrapper.get(this.uri, this.config.maxPoolSize, this.config.closeDelay)\n const connection = await wrapper.connect()\n assertEx(connection, () => 'Connection failed')\n try {\n return await func(connection)\n } finally {\n await wrapper.disconnect()\n }\n }\n}\n","import type { MongoClientOptions } from 'mongodb'\nimport { MongoClient } from 'mongodb'\n\n/** Manages a shared pool of MongoClient instances, reusing connections by URI. */\nexport class MongoClientWrapper {\n /** Global cache of wrapper instances keyed by connection URI. */\n static readonly clients = new Map<string, MongoClientWrapper>()\n\n private client: MongoClient\n\n constructor(uri: string, maxPoolSize?: number, closeDelay?: number) {\n const options: MongoClientOptions = { maxPoolSize, maxIdleTimeMS: closeDelay }\n this.client = new MongoClient(uri, options)\n }\n\n /**\n * Gets or creates a cached MongoClientWrapper for the given URI.\n * @param uri - The MongoDB connection URI\n * @param poolSize - Maximum connection pool size\n * @param closeDelay - Delay in milliseconds before closing idle connections\n * @returns A cached or newly created wrapper instance\n */\n static get(uri: string, poolSize?: number, closeDelay?: number) {\n let client = this.clients.get(uri)\n if (!client) {\n client = new MongoClientWrapper(uri, poolSize, closeDelay)\n this.clients.set(uri, client)\n }\n return client\n }\n\n /** Connects to MongoDB and returns the underlying MongoClient. */\n async connect() {\n return await Promise.resolve(this.client)\n }\n\n /** Disconnects from MongoDB. */\n async disconnect() {\n return await Promise.resolve(0)\n }\n\n /** Initiates a graceful close of the connection. */\n async initiateClose() {\n await Promise.resolve()\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;;;ACCzB,SAAS,mBAAmB;AAGrB,IAAM,qBAAN,MAAM,oBAAmB;AAAA;AAAA,EAE9B,OAAgB,UAAU,oBAAI,IAAgC;AAAA,EAEtD;AAAA,EAER,YAAY,KAAa,aAAsB,YAAqB;AAClE,UAAM,UAA8B,EAAE,aAAa,eAAe,WAAW;AAC7E,SAAK,SAAS,IAAI,YAAY,KAAK,O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A,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAiB,MAAqD;AAC1E,WAAO,MAAM,KAAK,SAAY,OAAO,WAAwB;AAC3D,aAAO,MAAM,KAAK,OAAO,GAAG,KAAK,OAAO,MAAM,EAAE,WAAc,KAAK,OAAO,UAAU,CAAC;AAAA,IACvF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,SAAY,MAA+C;AAC/D,UAAM,UAAU,mBAAmB,IAAI,KAAK,KAAK,KAAK,OAAO,aAAa,KAAK,OAAO,UAAU;AAChG,UAAM,aAAa,MAAM,QAAQ,QAAQ;AACzC,aAAS,YAAY,MAAM,mBAAmB;AAC9C,QAAI;AACF,aAAO,MAAM,KAAK,UAAU;AAAA,IAC9B,UAAE;AACA,YAAM,QAAQ,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;","names":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Base.ts", "../../src/Wrapper.ts"],
4
+ "sourcesContent": ["import { assertEx } from '@xylabs/assert'\nimport type {\n BulkWriteOptions,\n Collection,\n DeleteResult,\n Document,\n Filter,\n FindCursor,\n InsertOneOptions,\n MongoClient,\n OptionalUnlessRequiredId,\n ReplaceOptions,\n UpdateFilter,\n WithId,\n} from 'mongodb'\n\nimport type { BaseMongoSdkConfig } from './Config.js'\nimport { MongoClientWrapper } from './Wrapper.js'\n\n/** Provides a typed wrapper around common MongoDB collection operations. */\nexport class BaseMongoSdk<T extends Document> {\n /** The MongoDB SDK configuration for this instance. */\n config: BaseMongoSdkConfig\n\n constructor(config: BaseMongoSdkConfig) {\n this.config = config\n }\n\n /** Returns the MongoDB connection URI, either from the config or constructed from individual credential fields. */\n get uri() {\n return (\n this.config.dbConnectionString\n ?? `mongodb+srv://${this.config.dbUserName}:${this.config.dbPassword}@${this.config.dbDomain}.mongodb.net/${this.config.dbName}?retryWrites=true&w=majority`\n )\n }\n\n /**\n * Deletes all documents matching the filter.\n * @param filter - The query filter to match documents for deletion\n */\n async deleteMany(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteMany(filter)\n })\n }\n\n /**\n * Deletes the first document matching the filter.\n * @param filter - The query filter to match a document for deletion\n */\n async deleteOne(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteOne(filter)\n })\n }\n\n /**\n * Finds all documents matching the filter and returns a cursor.\n * @param filter - The query filter\n */\n async find(filter: Filter<T>) {\n return await this.useCollection<FindCursor<WithId<T>>>((collection: Collection<T>) => {\n return collection.find(filter)\n })\n }\n\n /**\n * Finds a single document matching the filter.\n * @param filter - The query filter\n * @returns The matched document, or `null` if not found\n */\n async findOne(filter: Filter<T>) {\n return await this.useCollection<WithId<T> | null>(async (collection: Collection<T>) => {\n return await collection.findOne(filter)\n })\n }\n\n /**\n * Inserts multiple documents into the collection.\n * @param items - The documents to insert\n * @param options - Optional bulk write options\n */\n async insertMany(items: OptionalUnlessRequiredId<T>[], options?: BulkWriteOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertMany(items, options)\n })\n }\n\n /**\n * Inserts a single document into the collection.\n * @param item - The document to insert\n * @param options - Optional insert options\n */\n async insertOne(item: OptionalUnlessRequiredId<T>, options?: InsertOneOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertOne(item, options)\n })\n }\n\n /**\n * Replaces a single document matching the filter.\n * @param filter - The query filter to match the document\n * @param item - The replacement document\n * @param options - Optional replace options\n */\n async replaceOne(filter: Filter<T>, item: OptionalUnlessRequiredId<T>, options?: ReplaceOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.replaceOne(filter, item, options)\n })\n }\n\n /**\n * Updates a single document matching the filter without upserting.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async updateOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: false })\n })\n }\n\n /**\n * Updates a single document matching the filter, inserting it if it does not exist.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async upsertOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: true })\n })\n }\n\n /**\n * Executes a callback with access to the configured MongoDB collection.\n * @param func - A callback receiving the typed collection\n * @returns The result of the callback\n */\n async useCollection<R>(func: (collection: Collection<T>) => Promise<R> | R) {\n return await this.useMongo<R>(async (client: MongoClient) => {\n return await func(client.db(this.config.dbName).collection<T>(this.config.collection))\n })\n }\n\n /**\n * Executes a callback with a connected MongoClient, handling connection and disconnection.\n * @param func - A callback receiving the connected MongoClient\n * @returns The result of the callback\n */\n async useMongo<R>(func: (client: MongoClient) => Promise<R> | R) {\n const wrapper = MongoClientWrapper.get(this.uri, this.config.maxPoolSize, this.config.closeDelay)\n const connection = await wrapper.connect()\n assertEx(connection, () => 'Connection failed')\n try {\n return await func(connection)\n } finally {\n await wrapper.disconnect()\n }\n }\n}\n", "import type { MongoClientOptions } from 'mongodb'\nimport { MongoClient } from 'mongodb'\n\n/** Manages a shared pool of MongoClient instances, reusing connections by URI. */\nexport class MongoClientWrapper {\n /** Global cache of wrapper instances keyed by connection URI. */\n static readonly clients = new Map<string, MongoClientWrapper>()\n\n private client: MongoClient\n\n constructor(uri: string, maxPoolSize?: number, closeDelay?: number) {\n const options: MongoClientOptions = { maxPoolSize, maxIdleTimeMS: closeDelay }\n this.client = new MongoClient(uri, options)\n }\n\n /**\n * Gets or creates a cached MongoClientWrapper for the given URI.\n * @param uri - The MongoDB connection URI\n * @param poolSize - Maximum connection pool size\n * @param closeDelay - Delay in milliseconds before closing idle connections\n * @returns A cached or newly created wrapper instance\n */\n static get(uri: string, poolSize?: number, closeDelay?: number) {\n let client = this.clients.get(uri)\n if (!client) {\n client = new MongoClientWrapper(uri, poolSize, closeDelay)\n this.clients.set(uri, client)\n }\n return client\n }\n\n /** Connects to MongoDB and returns the underlying MongoClient. */\n async connect() {\n return await Promise.resolve(this.client)\n }\n\n /** Disconnects from MongoDB. */\n async disconnect() {\n return await Promise.resolve(0)\n }\n\n /** Initiates a graceful close of the connection. */\n async initiateClose() {\n await Promise.resolve()\n }\n}\n"],
5
+ "mappings": ";AAAA,SAAS,gBAAgB;;;ACCzB,SAAS,mBAAmB;AAGrB,IAAM,qBAAN,MAAM,oBAAmB;AAAA;AAAA,EAE9B,OAAgB,UAAU,oBAAI,IAAgC;AAAA,EAEtD;AAAA,EAER,YAAY,KAAa,aAAsB,YAAqB;AAClE,UAAM,UAA8B,EAAE,aAAa,eAAe,WAAW;AAC7E,SAAK,SAAS,IAAI,YAAY,KAAK,OAAO;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,OAAO,IAAI,KAAa,UAAmB,YAAqB;AAC9D,QAAI,SAAS,KAAK,QAAQ,IAAI,GAAG;AACjC,QAAI,CAAC,QAAQ;AACX,eAAS,IAAI,oBAAmB,KAAK,UAAU,UAAU;AACzD,WAAK,QAAQ,IAAI,KAAK,MAAM;AAAA,IAC9B;AACA,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,MAAM,UAAU;AACd,WAAO,MAAM,QAAQ,QAAQ,KAAK,MAAM;AAAA,EAC1C;AAAA;AAAA,EAGA,MAAM,aAAa;AACjB,WAAO,MAAM,QAAQ,QAAQ,CAAC;AAAA,EAChC;AAAA;AAAA,EAGA,MAAM,gBAAgB;AACpB,UAAM,QAAQ,QAAQ;AAAA,EACxB;AACF;;;ADzBO,IAAM,eAAN,MAAuC;AAAA;AAAA,EAE5C;AAAA,EAEA,YAAY,QAA4B;AACtC,SAAK,SAAS;AAAA,EAChB;AAAA;AAAA,EAGA,IAAI,MAAM;AACR,WACE,KAAK,OAAO,sBACT,iBAAiB,KAAK,OAAO,UAAU,IAAI,KAAK,OAAO,UAAU,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AAO,MAAM,WAAW,WAAW,QAAQ,MAAM,OAAO;AAAA,IAC1D,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,UAAU,QAAmB,QAAyB;AAC1D,WAAO,MAAM,KAAK,cAAc,OAAO,eAA8B;AACnE,aAAO,MAAM,WAAW,UAAU,QAAQ,QAAQ,EAAE,QAAQ,MAAM,CAAC;AAAA,IACrE,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,UAAU,QAAmB,QAAyB;AAC1D,WAAO,MAAM,KAAK,cAAc,OAAO,eAA8B;AACnE,aAAO,MAAM,WAAW,UAAU,QAAQ,QAAQ,EAAE,QAAQ,KAAK,CAAC;AAAA,IACpE,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAiB,MAAqD;AAC1E,WAAO,MAAM,KAAK,SAAY,OAAO,WAAwB;AAC3D,aAAO,MAAM,KAAK,OAAO,GAAG,KAAK,OAAO,MAAM,EAAE,WAAc,KAAK,OAAO,UAAU,CAAC;AAAA,IACvF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,SAAY,MAA+C;AAC/D,UAAM,UAAU,mBAAmB,IAAI,KAAK,KAAK,KAAK,OAAO,aAAa,KAAK,OAAO,UAAU;AAChG,UAAM,aAAa,MAAM,QAAQ,QAAQ;AACzC,aAAS,YAAY,MAAM,mBAAmB;AAC9C,QAAI;AACF,aAAO,MAAM,KAAK,UAAU;AAAA,IAC9B,UAAE;AACA,YAAM,QAAQ,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -169,4 +169,4 @@ export {
169
169
  BaseMongoSdk,
170
170
  MongoClientWrapper
171
171
  };
172
- //# sourceMappingURL=index.mjs.map
172
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1,7 @@
1
- {"version":3,"sources":["../../src/Base.ts","../../src/Wrapper.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type {\n BulkWriteOptions,\n Collection,\n DeleteResult,\n Document,\n Filter,\n FindCursor,\n InsertOneOptions,\n MongoClient,\n OptionalUnlessRequiredId,\n ReplaceOptions,\n UpdateFilter,\n WithId,\n} from 'mongodb'\n\nimport type { BaseMongoSdkConfig } from './Config.js'\nimport { MongoClientWrapper } from './Wrapper.js'\n\n/** Provides a typed wrapper around common MongoDB collection operations. */\nexport class BaseMongoSdk<T extends Document> {\n /** The MongoDB SDK configuration for this instance. */\n config: BaseMongoSdkConfig\n\n constructor(config: BaseMongoSdkConfig) {\n this.config = config\n }\n\n /** Returns the MongoDB connection URI, either from the config or constructed from individual credential fields. */\n get uri() {\n return (\n this.config.dbConnectionString\n ?? `mongodb+srv://${this.config.dbUserName}:${this.config.dbPassword}@${this.config.dbDomain}.mongodb.net/${this.config.dbName}?retryWrites=true&w=majority`\n )\n }\n\n /**\n * Deletes all documents matching the filter.\n * @param filter - The query filter to match documents for deletion\n */\n async deleteMany(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteMany(filter)\n })\n }\n\n /**\n * Deletes the first document matching the filter.\n * @param filter - The query filter to match a document for deletion\n */\n async deleteOne(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteOne(filter)\n })\n }\n\n /**\n * Finds all documents matching the filter and returns a cursor.\n * @param filter - The query filter\n */\n async find(filter: Filter<T>) {\n return await this.useCollection<FindCursor<WithId<T>>>((collection: Collection<T>) => {\n return collection.find(filter)\n })\n }\n\n /**\n * Finds a single document matching the filter.\n * @param filter - The query filter\n * @returns The matched document, or `null` if not found\n */\n async findOne(filter: Filter<T>) {\n return await this.useCollection<WithId<T> | null>(async (collection: Collection<T>) => {\n return await collection.findOne(filter)\n })\n }\n\n /**\n * Inserts multiple documents into the collection.\n * @param items - The documents to insert\n * @param options - Optional bulk write options\n */\n async insertMany(items: OptionalUnlessRequiredId<T>[], options?: BulkWriteOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertMany(items, options)\n })\n }\n\n /**\n * Inserts a single document into the collection.\n * @param item - The document to insert\n * @param options - Optional insert options\n */\n async insertOne(item: OptionalUnlessRequiredId<T>, options?: InsertOneOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertOne(item, options)\n })\n }\n\n /**\n * Replaces a single document matching the filter.\n * @param filter - The query filter to match the document\n * @param item - The replacement document\n * @param options - Optional replace options\n */\n async replaceOne(filter: Filter<T>, item: OptionalUnlessRequiredId<T>, options?: ReplaceOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.replaceOne(filter, item, options)\n })\n }\n\n /**\n * Updates a single document matching the filter without upserting.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async updateOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: false })\n })\n }\n\n /**\n * Updates a single document matching the filter, inserting it if it does not exist.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async upsertOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: true })\n })\n }\n\n /**\n * Executes a callback with access to the configured MongoDB collection.\n * @param func - A callback receiving the typed collection\n * @returns The result of the callback\n */\n async useCollection<R>(func: (collection: Collection<T>) => Promise<R> | R) {\n return await this.useMongo<R>(async (client: MongoClient) => {\n return await func(client.db(this.config.dbName).collection<T>(this.config.collection))\n })\n }\n\n /**\n * Executes a callback with a connected MongoClient, handling connection and disconnection.\n * @param func - A callback receiving the connected MongoClient\n * @returns The result of the callback\n */\n async useMongo<R>(func: (client: MongoClient) => Promise<R> | R) {\n const wrapper = MongoClientWrapper.get(this.uri, this.config.maxPoolSize, this.config.closeDelay)\n const connection = await wrapper.connect()\n assertEx(connection, () => 'Connection failed')\n try {\n return await func(connection)\n } finally {\n await wrapper.disconnect()\n }\n }\n}\n","import type { MongoClientOptions } from 'mongodb'\nimport { MongoClient } from 'mongodb'\n\n/** Manages a shared pool of MongoClient instances, reusing connections by URI. */\nexport class MongoClientWrapper {\n /** Global cache of wrapper instances keyed by connection URI. */\n static readonly clients = new Map<string, MongoClientWrapper>()\n\n private client: MongoClient\n\n constructor(uri: string, maxPoolSize?: number, closeDelay?: number) {\n const options: MongoClientOptions = { maxPoolSize, maxIdleTimeMS: closeDelay }\n this.client = new MongoClient(uri, options)\n }\n\n /**\n * Gets or creates a cached MongoClientWrapper for the given URI.\n * @param uri - The MongoDB connection URI\n * @param poolSize - Maximum connection pool size\n * @param closeDelay - Delay in milliseconds before closing idle connections\n * @returns A cached or newly created wrapper instance\n */\n static get(uri: string, poolSize?: number, closeDelay?: number) {\n let client = this.clients.get(uri)\n if (!client) {\n client = new MongoClientWrapper(uri, poolSize, closeDelay)\n this.clients.set(uri, client)\n }\n return client\n }\n\n /** Connects to MongoDB and returns the underlying MongoClient. */\n async connect() {\n return await Promise.resolve(this.client)\n }\n\n /** Disconnects from MongoDB. */\n async disconnect() {\n return await Promise.resolve(0)\n }\n\n /** Initiates a graceful close of the connection. */\n async initiateClose() {\n await Promise.resolve()\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;;;ACCzB,SAAS,mBAAmB;AAGrB,IAAM,qBAAN,MAAM,oBAAmB;AAAA;AAAA,EAE9B,OAAgB,UAAU,oBAAI,IAAgC;AAAA,EAEtD;AAAA,EAER,YAAY,KAAa,aAAsB,YAAqB;AAClE,UAAM,UAA8B,EAAE,aAAa,eAAe,WAAW;AAC7E,SAAK,SAAS,IAAI,YAAY,KAAK,OAAO;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,OAAO,IAAI,KAAa,UAAmB,YAAqB;AAC9D,QAAI,SAAS,KAAK,QAAQ,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AK,OAAO,GAAG,KAAK,OAAO,MAAM,EAAE,WAAc,KAAK,OAAO,UAAU,CAAC;AAAA,IACvF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,SAAY,MAA+C;AAC/D,UAAM,UAAU,mBAAmB,IAAI,KAAK,KAAK,KAAK,OAAO,aAAa,KAAK,OAAO,UAAU;AAChG,UAAM,aAAa,MAAM,QAAQ,QAAQ;AACzC,aAAS,YAAY,MAAM,mBAAmB;AAC9C,QAAI;AACF,aAAO,MAAM,KAAK,UAAU;AAAA,IAC9B,UAAE;AACA,YAAM,QAAQ,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;","names":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Base.ts", "../../src/Wrapper.ts"],
4
+ "sourcesContent": ["import { assertEx } from '@xylabs/assert'\nimport type {\n BulkWriteOptions,\n Collection,\n DeleteResult,\n Document,\n Filter,\n FindCursor,\n InsertOneOptions,\n MongoClient,\n OptionalUnlessRequiredId,\n ReplaceOptions,\n UpdateFilter,\n WithId,\n} from 'mongodb'\n\nimport type { BaseMongoSdkConfig } from './Config.js'\nimport { MongoClientWrapper } from './Wrapper.js'\n\n/** Provides a typed wrapper around common MongoDB collection operations. */\nexport class BaseMongoSdk<T extends Document> {\n /** The MongoDB SDK configuration for this instance. */\n config: BaseMongoSdkConfig\n\n constructor(config: BaseMongoSdkConfig) {\n this.config = config\n }\n\n /** Returns the MongoDB connection URI, either from the config or constructed from individual credential fields. */\n get uri() {\n return (\n this.config.dbConnectionString\n ?? `mongodb+srv://${this.config.dbUserName}:${this.config.dbPassword}@${this.config.dbDomain}.mongodb.net/${this.config.dbName}?retryWrites=true&w=majority`\n )\n }\n\n /**\n * Deletes all documents matching the filter.\n * @param filter - The query filter to match documents for deletion\n */\n async deleteMany(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteMany(filter)\n })\n }\n\n /**\n * Deletes the first document matching the filter.\n * @param filter - The query filter to match a document for deletion\n */\n async deleteOne(filter: Filter<T>) {\n return await this.useCollection<DeleteResult>(async (collection: Collection<T>) => {\n return await collection.deleteOne(filter)\n })\n }\n\n /**\n * Finds all documents matching the filter and returns a cursor.\n * @param filter - The query filter\n */\n async find(filter: Filter<T>) {\n return await this.useCollection<FindCursor<WithId<T>>>((collection: Collection<T>) => {\n return collection.find(filter)\n })\n }\n\n /**\n * Finds a single document matching the filter.\n * @param filter - The query filter\n * @returns The matched document, or `null` if not found\n */\n async findOne(filter: Filter<T>) {\n return await this.useCollection<WithId<T> | null>(async (collection: Collection<T>) => {\n return await collection.findOne(filter)\n })\n }\n\n /**\n * Inserts multiple documents into the collection.\n * @param items - The documents to insert\n * @param options - Optional bulk write options\n */\n async insertMany(items: OptionalUnlessRequiredId<T>[], options?: BulkWriteOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertMany(items, options)\n })\n }\n\n /**\n * Inserts a single document into the collection.\n * @param item - The document to insert\n * @param options - Optional insert options\n */\n async insertOne(item: OptionalUnlessRequiredId<T>, options?: InsertOneOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.insertOne(item, options)\n })\n }\n\n /**\n * Replaces a single document matching the filter.\n * @param filter - The query filter to match the document\n * @param item - The replacement document\n * @param options - Optional replace options\n */\n async replaceOne(filter: Filter<T>, item: OptionalUnlessRequiredId<T>, options?: ReplaceOptions) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.replaceOne(filter, item, options)\n })\n }\n\n /**\n * Updates a single document matching the filter without upserting.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async updateOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: false })\n })\n }\n\n /**\n * Updates a single document matching the filter, inserting it if it does not exist.\n * @param filter - The query filter to match the document\n * @param fields - The update operations to apply\n */\n async upsertOne(filter: Filter<T>, fields: UpdateFilter<T>) {\n return await this.useCollection(async (collection: Collection<T>) => {\n return await collection.updateOne(filter, fields, { upsert: true })\n })\n }\n\n /**\n * Executes a callback with access to the configured MongoDB collection.\n * @param func - A callback receiving the typed collection\n * @returns The result of the callback\n */\n async useCollection<R>(func: (collection: Collection<T>) => Promise<R> | R) {\n return await this.useMongo<R>(async (client: MongoClient) => {\n return await func(client.db(this.config.dbName).collection<T>(this.config.collection))\n })\n }\n\n /**\n * Executes a callback with a connected MongoClient, handling connection and disconnection.\n * @param func - A callback receiving the connected MongoClient\n * @returns The result of the callback\n */\n async useMongo<R>(func: (client: MongoClient) => Promise<R> | R) {\n const wrapper = MongoClientWrapper.get(this.uri, this.config.maxPoolSize, this.config.closeDelay)\n const connection = await wrapper.connect()\n assertEx(connection, () => 'Connection failed')\n try {\n return await func(connection)\n } finally {\n await wrapper.disconnect()\n }\n }\n}\n", "import type { MongoClientOptions } from 'mongodb'\nimport { MongoClient } from 'mongodb'\n\n/** Manages a shared pool of MongoClient instances, reusing connections by URI. */\nexport class MongoClientWrapper {\n /** Global cache of wrapper instances keyed by connection URI. */\n static readonly clients = new Map<string, MongoClientWrapper>()\n\n private client: MongoClient\n\n constructor(uri: string, maxPoolSize?: number, closeDelay?: number) {\n const options: MongoClientOptions = { maxPoolSize, maxIdleTimeMS: closeDelay }\n this.client = new MongoClient(uri, options)\n }\n\n /**\n * Gets or creates a cached MongoClientWrapper for the given URI.\n * @param uri - The MongoDB connection URI\n * @param poolSize - Maximum connection pool size\n * @param closeDelay - Delay in milliseconds before closing idle connections\n * @returns A cached or newly created wrapper instance\n */\n static get(uri: string, poolSize?: number, closeDelay?: number) {\n let client = this.clients.get(uri)\n if (!client) {\n client = new MongoClientWrapper(uri, poolSize, closeDelay)\n this.clients.set(uri, client)\n }\n return client\n }\n\n /** Connects to MongoDB and returns the underlying MongoClient. */\n async connect() {\n return await Promise.resolve(this.client)\n }\n\n /** Disconnects from MongoDB. */\n async disconnect() {\n return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AyB;AAC1D,WAAO,MAAM,KAAK,cAAc,OAAO,eAA8B;AACnE,aAAO,MAAM,WAAW,UAAU,QAAQ,QAAQ,EAAE,QAAQ,MAAM,CAAC;AAAA,IACrE,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,UAAU,QAAmB,QAAyB;AAC1D,WAAO,MAAM,KAAK,cAAc,OAAO,eAA8B;AACnE,aAAO,MAAM,WAAW,UAAU,QAAQ,QAAQ,EAAE,QAAQ,KAAK,CAAC;AAAA,IACpE,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAiB,MAAqD;AAC1E,WAAO,MAAM,KAAK,SAAY,OAAO,WAAwB;AAC3D,aAAO,MAAM,KAAK,OAAO,GAAG,KAAK,OAAO,MAAM,EAAE,WAAc,KAAK,OAAO,UAAU,CAAC;AAAA,IACvF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,SAAY,MAA+C;AAC/D,UAAM,UAAU,mBAAmB,IAAI,KAAK,KAAK,KAAK,OAAO,aAAa,KAAK,OAAO,UAAU;AAChG,UAAM,aAAa,MAAM,QAAQ,QAAQ;AACzC,aAAS,YAAY,MAAM,mBAAmB;AAC9C,QAAI;AACF,aAAO,MAAM,KAAK,UAAU;AAAA,IAC9B,UAAE;AACA,YAAM,QAAQ,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/mongo",
3
- "version": "5.1.1",
3
+ "version": "5.1.3",
4
4
  "description": "Base functionality used throughout XYO TypeScript/JavaScript libraries that access Mongo DB",
5
5
  "keywords": [
6
6
  "mongo",
@@ -45,17 +45,18 @@
45
45
  "README.md"
46
46
  ],
47
47
  "dependencies": {
48
- "@xylabs/assert": "~5.1.1"
48
+ "@xylabs/assert": "~5.1.3"
49
49
  },
50
50
  "devDependencies": {
51
- "@xylabs/tsconfig": "~7.13.2",
51
+ "@types/node": "^25.8.0",
52
+ "@xylabs/tsconfig": "~8.0.4",
52
53
  "mongodb": "^7.2.0",
53
- "typescript": "^5.9.3",
54
- "vite": "^8.0.10",
55
- "vitest": "^4.1.5"
54
+ "typescript": "^6.0.3",
55
+ "vite": "^8.0.13",
56
+ "vitest": "^4.1.6"
56
57
  },
57
58
  "peerDependencies": {
58
- "mongodb": ">=7.2.0 <8"
59
+ "mongodb": "^7.2"
59
60
  },
60
61
  "engines": {
61
62
  "node": ">=18"