Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
4.4 KiB
Plaintext
1 line
4.4 KiB
Plaintext
{"version":3,"file":"index.js","names":["traverseFields","baseAuthFields","name","type","required","buildClientFieldSchemaMap","args","collectionSlug","config","globalSlug","i18n","payload","schemaMap","clientSchemaMap","Map","matchedCollection","collections","find","collection","slug","fieldsToSet","fields","auth","disableLocalStrategy","label","t","concat","set","parentIndexPath","parentSchemaPath","matchedGlobal","globals","global","clientFieldSchemaMap"],"sources":["../../../src/utilities/buildClientFieldSchemaMap/index.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type {\n ClientConfig,\n ClientField,\n ClientFieldSchemaMap,\n FieldSchemaMap,\n Payload,\n TextFieldClient,\n} from 'payload'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst baseAuthFields: ClientField[] = [\n {\n name: 'password',\n type: 'text',\n required: true,\n },\n {\n name: 'confirm-password',\n type: 'text',\n required: true,\n },\n]\n\n/**\n * Flattens the config fields into a map of field schemas\n */\nexport const buildClientFieldSchemaMap = (args: {\n collectionSlug?: string\n config: ClientConfig\n globalSlug?: string\n i18n: I18n\n payload: Payload\n schemaMap: FieldSchemaMap\n}): { clientFieldSchemaMap: ClientFieldSchemaMap } => {\n const { collectionSlug, config, globalSlug, i18n, payload, schemaMap } = args\n\n const clientSchemaMap: ClientFieldSchemaMap = new Map()\n\n if (collectionSlug) {\n const matchedCollection = config.collections.find(\n (collection) => collection.slug === collectionSlug,\n )\n\n if (matchedCollection) {\n let fieldsToSet = matchedCollection?.fields || []\n\n if (matchedCollection.auth && !matchedCollection.auth.disableLocalStrategy) {\n ;(baseAuthFields[0] as TextFieldClient).label = i18n.t('general:password')\n ;(baseAuthFields[1] as TextFieldClient).label = i18n.t('authentication:confirmPassword')\n // Place these fields _last_ to ensure they do not disrupt field paths in the field schema map\n fieldsToSet = fieldsToSet.concat(baseAuthFields)\n }\n\n clientSchemaMap.set(collectionSlug, {\n fields: fieldsToSet,\n })\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: fieldsToSet,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: collectionSlug,\n payload,\n schemaMap,\n })\n }\n } else if (globalSlug) {\n const matchedGlobal = config.globals.find((global) => global.slug === globalSlug)\n\n if (matchedGlobal) {\n clientSchemaMap.set(globalSlug, {\n fields: matchedGlobal.fields,\n })\n\n traverseFields({\n clientSchemaMap,\n config,\n fields: matchedGlobal.fields,\n i18n,\n parentIndexPath: '',\n parentSchemaPath: globalSlug,\n payload,\n schemaMap,\n })\n }\n }\n\n return { clientFieldSchemaMap: clientSchemaMap }\n}\n"],"mappings":"AAUA,SAASA,cAAc,QAAQ;AAE/B,MAAMC,cAAA,GAAgC,CACpC;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ,GACA;EACEF,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,QAAA,EAAU;AACZ,EACD;AAED;;;AAGA,OAAO,MAAMC,yBAAA,GAA6BC,IAAA;EAQxC,MAAM;IAAEC,cAAc;IAAEC,MAAM;IAAEC,UAAU;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAS,CAAE,GAAGN,IAAA;EAEzE,MAAMO,eAAA,GAAwC,IAAIC,GAAA;EAElD,IAAIP,cAAA,EAAgB;IAClB,MAAMQ,iBAAA,GAAoBP,MAAA,CAAOQ,WAAW,CAACC,IAAI,CAC9CC,UAAA,IAAeA,UAAA,CAAWC,IAAI,KAAKZ,cAAA;IAGtC,IAAIQ,iBAAA,EAAmB;MACrB,IAAIK,WAAA,GAAcL,iBAAA,EAAmBM,MAAA,IAAU,EAAE;MAEjD,IA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