const checkIfAttributeIsDisplayable = (attribute)=>{ const { type } = attribute; if (type === 'relation') { return !attribute.relation.toLowerCase().includes('morph'); } return ![ 'json', 'dynamiczone', 'richtext', 'password', 'blocks' ].includes(type) && !!type; }; /** * @internal * @description given an attribute, content-type schemas & component schemas, find the mainField name & type. * If the attribute does not need a `mainField` then we return undefined. If we do not find the type * of the field, we assume it's a string #sensible-defaults */ const getMainField = (attribute, mainFieldName, { schemas, components })=>{ if (!mainFieldName) { return undefined; } if (attribute.type === 'component') { const mainFieldType = components[attribute.component]?.attributes?.[mainFieldName]?.type; return { name: mainFieldType ? mainFieldName : 'id', type: mainFieldType ?? 'custom' }; } if (attribute.type === 'relation') { const target = 'targetModel' in attribute ? attribute.targetModel : 'target' in attribute ? attribute.target : undefined; const targetSchema = schemas.find((schema)=>schema.uid === target); const mainFieldType = targetSchema?.attributes?.[mainFieldName]?.type; return { name: !targetSchema || mainFieldType ? mainFieldName : 'id', type: mainFieldType ?? 'custom' }; } return { name: mainFieldName, type: 'string' }; }; export { checkIfAttributeIsDisplayable, getMainField }; //# sourceMappingURL=attributes.mjs.map