@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 1.78 kB
Source Map (JSON)
{"version":3,"file":"check-field.mjs","names":[],"sources":["../../../../src/libs/config/checks/check-field.ts"],"sourcesContent":["import type { Config } from \"../../../types.js\";\nimport { normalizeRelationCollections } from \"../../collection/custom-fields/fields/relation/utils/normalize-relation-collections.js\";\nimport type {\n\tCFConfig,\n\tFieldTypes,\n} from \"../../collection/custom-fields/types.js\";\nimport { translate } from \"../../i18n/index.js\";\n\n// TODO: Handle this within the custom field class\n\nconst checkField = (field: CFConfig<FieldTypes>, config: Config) => {\n\tswitch (field.type) {\n\t\tcase \"relation\": {\n\t\t\tconst allMultipleCollections = config.collections\n\t\t\t\t.filter((collection) => collection.getData.mode === \"multiple\")\n\t\t\t\t.map((collection) => collection.key);\n\n\t\t\tfor (const collectionKey of normalizeRelationCollections(\n\t\t\t\tfield.collection,\n\t\t\t)) {\n\t\t\t\tif (allMultipleCollections.includes(collectionKey)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tthrow new Error(\n\t\t\t\t\ttranslate(\n\t\t\t\t\t\t\"server:core.fields.relation.validation.collection.not.found\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tcollection: collectionKey,\n\t\t\t\t\t\t\t\tfield: field.key,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\treturn;\n\t\t}\n\t}\n};\n\nexport default checkField;\n"],"mappings":"4LAUA,MAAM,GAAc,EAA6B,IAAmB,CACnE,OAAQ,EAAM,KAAd,CACC,IAAK,WAAY,CAChB,IAAM,EAAyB,EAAO,YACpC,OAAQ,GAAe,EAAW,QAAQ,OAAS,UAAU,CAAC,CAC9D,IAAK,GAAe,EAAW,GAAG,EAEpC,IAAK,IAAM,KAAiB,EAC3B,EAAM,UACP,EACK,MAAuB,SAAS,CAAa,EAIjD,MAAU,MACT,EACC,8DACA,CACC,KAAM,CACL,WAAY,EACZ,MAAO,EAAM,GACd,CACD,CACD,CACD,EAGD,KACD,CACA,QACC,MAEF,CACD"}