{"version":3,"file":"stores.d.cts","names":["Serializable","BaseStore","K","V","Promise","AsyncGenerator","InMemoryStore","T","Record"],"sources":["../src/stores.d.ts"],"sourcesContent":["import { Serializable } from \"./load/serializable.js\";\n/**\n * Abstract interface for a key-value store.\n */\nexport declare abstract class BaseStore<K, V> extends Serializable {\n    /**\n     * Abstract method to get multiple values for a set of keys.\n     * @param {K[]} keys - An array of keys.\n     * @returns {Promise<(V | undefined)[]>} - A Promise that resolves with array of values or undefined if key not found.\n     */\n    abstract mget(keys: K[]): Promise<(V | undefined)[]>;\n    /**\n     * Abstract method to set a value for multiple keys.\n     * @param {[K, V][]} keyValuePairs - An array of key-value pairs.\n     * @returns {Promise<void>} - A Promise that resolves when the operation is complete.\n     */\n    abstract mset(keyValuePairs: [K, V][]): Promise<void>;\n    /**\n     * Abstract method to delete multiple keys.\n     * @param {K[]} keys - An array of keys to delete.\n     * @returns {Promise<void>} - A Promise that resolves when the operation is complete.\n     */\n    abstract mdelete(keys: K[]): Promise<void>;\n    /**\n     * Abstract method to yield keys optionally based on a prefix.\n     * @param {string} prefix - Optional prefix to filter keys.\n     * @returns {AsyncGenerator<K | string>} - An asynchronous generator that yields keys on iteration.\n     */\n    abstract yieldKeys(prefix?: string): AsyncGenerator<K | string>;\n}\n/**\n * In-memory implementation of the BaseStore using a dictionary. Used for\n * storing key-value pairs in memory.\n * @example\n * ```typescript\n * const store = new InMemoryStore<BaseMessage>();\n * await store.mset(\n *   Array.from({ length: 5 }).map((_, index) => [\n *     `message:id:${index}`,\n *     index % 2 === 0\n *       ? new AIMessage(\"ai stuff...\")\n *       : new HumanMessage(\"human stuff...\"),\n *   ]),\n * );\n *\n * const retrievedMessages = await store.mget([\"message:id:0\", \"message:id:1\"]);\n * await store.mdelete(await store.yieldKeys(\"message:id:\").toArray());\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare class InMemoryStore<T = any> extends BaseStore<string, T> {\n    lc_namespace: string[];\n    protected store: Record<string, T>;\n    /**\n     * Retrieves the values associated with the given keys from the store.\n     * @param keys Keys to retrieve values for.\n     * @returns Array of values associated with the given keys.\n     */\n    mget(keys: string[]): Promise<T[]>;\n    /**\n     * Sets the values for the given keys in the store.\n     * @param keyValuePairs Array of key-value pairs to set in the store.\n     * @returns Promise that resolves when all key-value pairs have been set.\n     */\n    mset(keyValuePairs: [string, T][]): Promise<void>;\n    /**\n     * Deletes the given keys and their associated values from the store.\n     * @param keys Keys to delete from the store.\n     * @returns Promise that resolves when all keys have been deleted.\n     */\n    mdelete(keys: string[]): Promise<void>;\n    /**\n     * Asynchronous generator that yields keys from the store. If a prefix is\n     * provided, it only yields keys that start with the prefix.\n     * @param prefix Optional prefix to filter keys.\n     * @returns AsyncGenerator that yields keys from the store.\n     */\n    yieldKeys(prefix?: string | undefined): AsyncGenerator<string>;\n}\n"],"mappings":";;;;;;AAIA;AAAuC,uBAATC,SAAS,CAAA,CAAA,EAAA,CAAA,CAAA,SAAeD,YAAAA,CAAf;EAAA;;;;;EAYD,SAAMI,IAAAA,CAAAA,IAAAA,EANpBF,CAMoBE,EAAAA,CAAAA,EANdA,OAMcA,CAAAA,CANLD,CAMKC,GAAAA,SAAAA,CAAAA,EAAAA,CAAAA;EAAO;;;;;EAZe,SAAA,IAAA,CAAA,aAAA,EAAA,CAYhCF,CAZgC,EAY7BC,CAZ6B,CAAA,EAAA,CAAA,EAYtBC,OAZsB,CAAA,IAAA,CAAA;EA8C7CE;;;;;EAEM,SAMOC,OAAAA,CAAAA,IAAAA,EApCPL,CAoCOK,EAAAA,CAAAA,EApCDH,OAoCCG,CAAAA,IAAAA,CAAAA;EAAC;;;;;EAmBuB,SA3BNN,SAAAA,CAAAA,MAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EAtBXI,cAsBWJ,CAtBIC,CAsBJD,GAAAA,MAAAA,CAAAA;AAAS;;;;;;;;;;;;;;;;;;;;;cAAxCK,+BAA+BL,kBAAkBM;;mBAEjDC,eAAeD;;;;;;wBAMVH,QAAQG;;;;;;+BAMDA,OAAOH;;;;;;2BAMXA;;;;;;;0CAOeC"}