{"version":3,"file":"models-store.d.ts","sourceRoot":"","sources":["../src/models-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9B,qEAAqE;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC3B,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;IAChE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,6FAA6F;AAC7F,MAAM,WAAW,mBAAmB;IACnC,IAAI,IAAI,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;IAC9C,KAAK,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,qBAAa,mBAAoB,YAAW,WAAW;IACtD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAEzD,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAGpE;IAEK,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtE;IAEK,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9C;CACD","sourcesContent":["import type { Api, Model } from \"./types.ts\";\n\nexport interface ModelsStoreEntry {\n\tmodels: readonly Model<Api>[];\n\t/** Unix timestamp from the remote catalog's Last-Modified header. */\n\tlastModified?: number;\n\t/** Unix timestamp of the last completed remote check. */\n\tcheckedAt?: number;\n}\n\n/** Persistent model catalogs keyed by provider ID. */\nexport interface ModelsStore {\n\tread(providerId: string): Promise<ModelsStoreEntry | undefined>;\n\twrite(providerId: string, entry: ModelsStoreEntry): Promise<void>;\n\tdelete(providerId: string): Promise<void>;\n}\n\n/** ModelsStore scoped to one provider. Providers cannot access other providers' catalogs. */\nexport interface ProviderModelsStore {\n\tread(): Promise<ModelsStoreEntry | undefined>;\n\twrite(entry: ModelsStoreEntry): Promise<void>;\n\tdelete(): Promise<void>;\n}\n\nexport class InMemoryModelsStore implements ModelsStore {\n\tprivate readonly entries = new Map<string, ModelsStoreEntry>();\n\n\tasync read(providerId: string): Promise<ModelsStoreEntry | undefined> {\n\t\tconst entry = this.entries.get(providerId);\n\t\treturn entry ? structuredClone(entry) : undefined;\n\t}\n\n\tasync write(providerId: string, entry: ModelsStoreEntry): Promise<void> {\n\t\tthis.entries.set(providerId, structuredClone(entry));\n\t}\n\n\tasync delete(providerId: string): Promise<void> {\n\t\tthis.entries.delete(providerId);\n\t}\n}\n"]}