{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/libs/toolkit/documents/index.ts"],"sourcesContent":["import type {\n\tCollectionDocument,\n\tCollectionDocumentKey,\n\tCollectionDocumentVersionKey,\n} from \"../../../types.js\";\nimport type {\n\tServiceContext,\n\tServiceResponse,\n} from \"../../../utils/services/types.js\";\nimport type {\n\tToolkitDocumentsGetMultipleInput,\n\tToolkitDocumentsGetMultipleResult,\n} from \"./get-multiple.js\";\nimport getMultiple from \"./get-multiple.js\";\nimport type { ToolkitDocumentsGetSingleInput } from \"./get-single.js\";\nimport getSingle from \"./get-single.js\";\n\nexport type ToolkitDocumentVersion<\n\tTCollectionKey extends CollectionDocumentKey = CollectionDocumentKey,\n> = CollectionDocumentVersionKey<TCollectionKey>;\n\n/**\n * Document helpers for reading collection content.\n */\nexport type ToolkitDocuments = {\n\t/**\n\t * Returns multiple documents from a collection.\n\t *\n\t * The response includes the matching documents and a total count.\n\t * Pass an array to `query.filter` when each object should be an OR branch.\n\t *\n\t * @example\n\t * ```ts\n\t * await toolkit.documents.getMultiple({\n\t *   collectionKey: \"page\",\n\t *   tenantKey: \"marketing\",\n\t *   version: \"published\",\n\t *   query: {\n\t *     perPage: 50,\n\t *   },\n\t * });\n\t * ```\n\t */\n\tgetMultiple: <TCollectionKey extends CollectionDocumentKey>(\n\t\tinput: ToolkitDocumentsGetMultipleInput<TCollectionKey>,\n\t) => ServiceResponse<ToolkitDocumentsGetMultipleResult<TCollectionKey>>;\n\t/**\n\t * Returns a single document from a collection.\n\t *\n\t * Useful when you expect one matching document for a slug, ID, or other filter.\n\t * Pass an array to `query.filter` when each object should be an OR branch.\n\t *\n\t * @example\n\t * ```ts\n\t * await toolkit.documents.getSingle({\n\t *   collectionKey: \"page\",\n\t *   tenantKey: \"marketing\",\n\t *   version: \"published\",\n\t *   query: {\n\t *     filter: {\n\t *       _fullSlug: {\n\t *         value: \"/about\",\n\t *       },\n\t *     },\n\t *   },\n\t * });\n\t * ```\n\t */\n\tgetSingle: <TCollectionKey extends CollectionDocumentKey>(\n\t\tinput: ToolkitDocumentsGetSingleInput<TCollectionKey>,\n\t) => ServiceResponse<CollectionDocument<TCollectionKey>>;\n};\n\n/** Creates document helpers for a toolkit instance. */\nexport const createDocumentsToolkit = (\n\tcontext: ServiceContext,\n): ToolkitDocuments => ({\n\tgetMultiple: (input) => getMultiple(context, input),\n\tgetSingle: (input) => getSingle(context, input),\n});\n\nexport default createDocumentsToolkit;\n"],"mappings":"kEA0EA,MAAa,EACZ,IACuB,CACvB,YAAc,GAAU,EAAY,EAAS,CAAK,EAClD,UAAY,GAAU,EAAU,EAAS,CAAK,CAC/C"}