{"version":3,"file":"query-Dl7KSBFU.mjs","names":[],"sources":["../src/schema/query.ts"],"sourcesContent":["/**\n * Collection info query for Astro templates.\n *\n * Same pattern as getMenu() / getComments() — uses getDb() for ambient DB access.\n */\n\nimport type { Kysely } from \"kysely\";\n\nimport type { Database } from \"../database/types.js\";\nimport { getDb } from \"../loader.js\";\nimport { cachedQuery, CacheNamespace } from \"../object-cache/index.js\";\nimport { requestCached } from \"../request-cache.js\";\nimport { SchemaRegistry } from \"./registry.js\";\nimport type { Collection } from \"./types.js\";\n\n/**\n * Get collection metadata by slug.\n *\n * @example\n * ```ts\n * import { getCollectionInfo } from \"@premium-cms/emdash\";\n *\n * const info = await getCollectionInfo(\"posts\");\n * if (info?.commentsEnabled) {\n *   // render comment UI\n * }\n * ```\n */\nexport async function getCollectionInfo(slug: string): Promise<Collection | null> {\n\treturn requestCached(`collection-info:${slug}`, () =>\n\t\tcachedQuery({\n\t\t\tnamespace: CacheNamespace.SCHEMA,\n\t\t\tkey: `collection-info:${slug}`,\n\t\t\tload: async () => {\n\t\t\t\tconst db = await getDb();\n\t\t\t\treturn getCollectionInfoWithDb(db, slug);\n\t\t\t},\n\t\t}),\n\t);\n}\n\n/**\n * Get collection metadata with an explicit db handle.\n *\n * @internal Use `getCollectionInfo()` in templates. This variant is for\n * routes that already have a database handle.\n */\nexport async function getCollectionInfoWithDb(\n\tdb: Kysely<Database>,\n\tslug: string,\n): Promise<Collection | null> {\n\tconst registry = new SchemaRegistry(db);\n\treturn registry.getCollection(slug);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4BA,eAAsB,kBAAkB,MAA0C;AACjF,QAAO,cAAc,mBAAmB,cACvC,YAAY;EACX,WAAW,eAAe;EAC1B,KAAK,mBAAmB;EACxB,MAAM,YAAY;AAEjB,UAAO,wBADI,MAAM,OAAO,EACW,KAAK;;EAEzC,CAAC,CACF;;;;;;;;AASF,eAAsB,wBACrB,IACA,MAC6B;AAE7B,QADiB,IAAI,eAAe,GAAG,CACvB,cAAc,KAAK"}