UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.42 kB
{"version":3,"file":"format-ref.mjs","names":["mediaFormatter"],"sources":["../../../../../../src/libs/collection/custom-fields/fields/user/format-ref.ts"],"sourcesContent":["import mediaFormatter from \"../../../../formatters/media.js\";\nimport type { UserPropT } from \"../../../../formatters/users.js\";\nimport type { CFResponse, FieldRefParams } from \"../../types.js\";\n\nconst isUserRef = (value: unknown): value is UserPropT => {\n\tif (typeof value !== \"object\" || value === null) return false;\n\n\treturn \"id\" in value && \"email\" in value && \"username\" in value;\n};\n\nconst formatUserRef = (\n\tvalue: unknown,\n\tparams: FieldRefParams,\n): CFResponse<\"user\">[\"ref\"] => {\n\tif (!isUserRef(value)) return null;\n\n\treturn {\n\t\tid: value.id ?? null,\n\t\temail: value.email,\n\t\tusername: value.username,\n\t\tfirstName: value.first_name,\n\t\tlastName: value.last_name,\n\t\tprofilePicture: mediaFormatter.formatProfilePicture({\n\t\t\tposter: value.profile_picture?.[0],\n\t\t\thost: params.host,\n\t\t}),\n\t} satisfies CFResponse<\"user\">[\"ref\"];\n};\n\nexport default formatUserRef;\n"],"mappings":"gDAIA,MAAM,EAAa,GACd,OAAO,GAAU,WAAY,EAAuB,GAEjD,OAAQ,GAAS,UAAW,GAAS,aAAc,EAGrD,GACL,EACA,IAEK,EAAU,CAAK,EAEb,CACN,GAAI,EAAM,IAAM,KAChB,MAAO,EAAM,MACb,SAAU,EAAM,SAChB,UAAW,EAAM,WACjB,SAAU,EAAM,UAChB,eAAgBA,EAAe,qBAAqB,CACnD,OAAQ,EAAM,kBAAkB,GAChC,KAAM,EAAO,IACd,CAAC,CACF,EAZ8B"}