@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 2.87 kB
Source Map (JSON)
{"version":3,"file":"get-multiple.mjs","names":["documentServices.client.getMultiple"],"sources":["../../../../src/libs/toolkit/documents/get-multiple.ts"],"sourcesContent":["import { documentServices } from \"../../../services/index.js\";\nimport type {\n\tCollectionDocument,\n\tCollectionDocumentKey,\n\tCollectionDocumentMultipleQuery,\n} from \"../../../types.js\";\nimport type {\n\tServiceContext,\n\tServiceResponse,\n} from \"../../../utils/services/types.js\";\nimport type { ToolkitTenantOptions } from \"../types.js\";\nimport {\n\tnormalizePaginatedDocumentQuery,\n\trunToolkitService,\n\twithToolkitTenant,\n} from \"../utils.js\";\nimport type { ToolkitDocumentVersion } from \"./index.js\";\n\nexport type ToolkitDocumentsGetMultipleQuery<\n\tTCollectionKey extends CollectionDocumentKey = CollectionDocumentKey,\n> = Omit<\n\tCollectionDocumentMultipleQuery<TCollectionKey>,\n\t\"page\" | \"perPage\"\n> & {\n\tpage?: number;\n\tperPage?: number;\n};\n\nexport type ToolkitDocumentsGetMultipleInput<\n\tTCollectionKey extends CollectionDocumentKey = CollectionDocumentKey,\n> = ToolkitTenantOptions & {\n\tcollectionKey: TCollectionKey;\n\tversion: ToolkitDocumentVersion<TCollectionKey>;\n\t/** Optional preview context that may override the requested version. */\n\tpreview?: string | null;\n\tquery?: ToolkitDocumentsGetMultipleQuery<TCollectionKey>;\n};\n\nexport type ToolkitDocumentsGetMultipleResult<\n\tTCollectionKey extends CollectionDocumentKey = CollectionDocumentKey,\n> = {\n\tdata: CollectionDocument<TCollectionKey>[];\n\tcount: number;\n};\n\nconst getMultiple = async <TCollectionKey extends CollectionDocumentKey>(\n\tcontext: ServiceContext,\n\tinput: ToolkitDocumentsGetMultipleInput<TCollectionKey>,\n): ServiceResponse<ToolkitDocumentsGetMultipleResult<TCollectionKey>> => {\n\tconst serviceContext = withToolkitTenant(context, input);\n\n\treturn runToolkitService(\n\t\t() =>\n\t\t\tdocumentServices.client.getMultiple(serviceContext, {\n\t\t\t\tcollectionKey: input.collectionKey,\n\t\t\t\tversionType: input.version,\n\t\t\t\tpreview: input.preview ?? undefined,\n\t\t\t\tquery: normalizePaginatedDocumentQuery(input.query),\n\t\t\t}),\n\t\t{\n\t\t\tname: {\n\t\t\t\tkey: \"core.toolkit.documents.get.multiple.error.name\",\n\t\t\t\tdefaultMessage: \"Documents Toolkit Error\",\n\t\t\t},\n\t\t\tmessage: {\n\t\t\t\tkey: \"core.toolkit.documents.get.multiple.error.message\",\n\t\t\t\tdefaultMessage: \"Lucid toolkit could not fetch multiple documents.\",\n\t\t\t},\n\t\t},\n\t);\n};\n\nexport default getMultiple;\n"],"mappings":"gLA6CA,MAAM,EAAc,MACnB,EACA,IACwE,CACxE,IAAM,EAAiB,EAAkB,EAAS,CAAK,EAEvD,OAAO,MAELA,EAAoC,EAAgB,CACnD,cAAe,EAAM,cACrB,YAAa,EAAM,QACnB,QAAS,EAAM,SAAW,IAAA,GAC1B,MAAO,EAAgC,EAAM,KAAK,CACnD,CAAC,EACF,CACC,KAAM,CACL,IAAK,iDACL,eAAgB,yBACjB,EACA,QAAS,CACR,IAAK,oDACL,eAAgB,mDACjB,CACD,CACD,CACD"}