@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.65 kB
Source Map (JSON)
{"version":3,"file":"check-collection.mjs","names":[],"sources":["../../../../src/services/documents/checks/check-collection.ts"],"sourcesContent":["import type CollectionBuilder from \"../../../libs/collection/builders/collection-builder/index.js\";\nimport { copy } from \"../../../libs/i18n/index.js\";\nimport { tenantAccessAllowed } from \"../../../utils/helpers/index.js\";\nimport type { ServiceFn } from \"../../../utils/services/types.js\";\n\nconst checkCollection: ServiceFn<\n\t[\n\t\t{\n\t\t\tkey: string;\n\t\t},\n\t],\n\tCollectionBuilder\n> = async (context, data) => {\n\tconst collectionInstance = context.config.collections?.find(\n\t\t(c) => c.key === data.key,\n\t);\n\n\tif (!collectionInstance) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tmessage: copy(\"server:core.collections.not.found.message\"),\n\t\t\t\tstatus: 404,\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\tif (\n\t\t!tenantAccessAllowed(\n\t\t\tcollectionInstance.getData.tenants,\n\t\t\tcontext.request.tenantKey,\n\t\t)\n\t) {\n\t\treturn {\n\t\t\terror: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tmessage: copy(\"server:core.collections.not.found.message\"),\n\t\t\t\tstatus: 404,\n\t\t\t},\n\t\t\tdata: undefined,\n\t\t};\n\t}\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: collectionInstance,\n\t};\n};\n\nexport default checkCollection;\n"],"mappings":"4HAKA,MAAM,EAOF,MAAO,EAAS,IAAS,CAC5B,IAAM,EAAqB,EAAQ,OAAO,aAAa,KACrD,GAAM,EAAE,MAAQ,EAAK,GACvB,EA6BA,MA3BI,CAAC,GAYJ,CAAC,EACA,EAAmB,QAAQ,QAC3B,EAAQ,QAAQ,SACjB,EAEO,CACN,MAAO,CACN,KAAM,QACN,QAAS,EAAK,2CAA2C,EACzD,OAAQ,GACT,EACA,KAAM,IAAA,EACP,EAGM,CACN,MAAO,IAAA,GACP,KAAM,CACP,CACD"}