{"version":3,"file":"uid-target.mjs","sources":["../../../server/src/utils/uid-target.ts"],"sourcesContent":["import { VALID_UID_TARGETS } from '../services/constants';\n\ntype AttributeLike = { type?: unknown; customField?: unknown };\n\n/**\n * The type an attribute is stored as. The admin sends custom fields as\n * `type: 'customField'`; they are resolved through the registry to their\n * underlying type. Returns `undefined` for an unknown custom field (plugin\n * removed, bad name).\n */\nexport const resolveStorageType = (attribute: AttributeLike): string | undefined => {\n  if (attribute.type !== 'customField' && typeof attribute.customField !== 'string') {\n    return typeof attribute.type === 'string' ? attribute.type : undefined;\n  }\n\n  if (typeof attribute.customField !== 'string') {\n    return undefined;\n  }\n\n  try {\n    const customField = strapi.get('custom-fields').get(attribute.customField) as\n      { type?: string } | undefined;\n    return customField?.type;\n  } catch {\n    return undefined;\n  }\n};\n\n/**\n * Whether a uid can be attached to this attribute: a string or text field,\n * including a custom field stored as one.\n */\nexport const isValidUidTarget = (attribute: AttributeLike): boolean => {\n  const type = resolveStorageType(attribute);\n  const validUidTargets: readonly string[] = VALID_UID_TARGETS;\n\n  return type !== undefined && validUidTargets.includes(type);\n};\n"],"names":["resolveStorageType","attribute","type","customField","undefined","strapi","get","isValidUidTarget","validUidTargets","VALID_UID_TARGETS","includes"],"mappings":";;AAIA;;;;;IAMO,MAAMA,kBAAAA,GAAqB,CAACC,SAAAA,GAAAA;IACjC,IAAIA,SAAAA,CAAUC,IAAI,KAAK,aAAA,IAAiB,OAAOD,SAAAA,CAAUE,WAAW,KAAK,QAAA,EAAU;AACjF,QAAA,OAAO,OAAOF,SAAAA,CAAUC,IAAI,KAAK,QAAA,GAAWD,SAAAA,CAAUC,IAAI,GAAGE,SAAAA;AAC/D,IAAA;AAEA,IAAA,IAAI,OAAOH,SAAAA,CAAUE,WAAW,KAAK,QAAA,EAAU;QAC7C,OAAOC,SAAAA;AACT,IAAA;IAEA,IAAI;QACF,MAAMD,WAAAA,GAAcE,OAAOC,GAAG,CAAC,iBAAiBA,GAAG,CAACL,UAAUE,WAAW,CAAA;AAEzE,QAAA,OAAOA,WAAAA,EAAaD,IAAAA;AACtB,IAAA,CAAA,CAAE,OAAM;QACN,OAAOE,SAAAA;AACT,IAAA;AACF;AAEA;;;IAIO,MAAMG,gBAAAA,GAAmB,CAACN,SAAAA,GAAAA;AAC/B,IAAA,MAAMC,OAAOF,kBAAAA,CAAmBC,SAAAA,CAAAA;AAChC,IAAA,MAAMO,eAAAA,GAAqCC,iBAAAA;AAE3C,IAAA,OAAOP,IAAAA,KAASE,SAAAA,IAAaI,eAAAA,CAAgBE,QAAQ,CAACR,IAAAA,CAAAA;AACxD;;;;"}