UNPKG

@lucidcms/core

Version:

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

2 lines 1.51 kB
import e from"../../constants/constants.mjs";import t from"../../utils/media/create-share-link-url.mjs";import{formatFocalPoint as n}from"./media.mjs";import r from"./index.mjs";const i=t=>{let i=t.link,a=i.media_type??`unknown`,o=e.media.previewableTypes.includes(a);return t.passwordRequired?{token:i.token,passwordRequired:!0}:{token:i.token,name:i.name,description:i.description,expiresAt:r.formatDate(i.expires_at),hasExpired:!1,passwordRequired:!1,media:{key:i.media_key??``,sourceType:i.media_source_type,origin:i.media_origin??`human`,type:a,mimeType:i.media_mime_type??``,extension:i.media_file_extension??``,fileSize:i.media_file_size??0,width:i.media_width??null,height:i.media_height??null,focalPoint:n(i.media_focal_x,i.media_focal_y),previewable:o,shareUrl:t.shareUrl,poster:t.posterShareUrl&&i.media_poster_type===`image`?{shareUrl:t.posterShareUrl}:null}}},a=e=>e.links.map(t=>o({link:t,host:e.host})),o=e=>{let n=e.link.expires_at?new Date(e.link.expires_at).getTime()<Date.now():!1;return{id:e.link.id,token:e.link.token,url:t({token:e.link.token,host:e.host}),name:e.link.name,description:e.link.description,expiresAt:r.formatDate(e.link.expires_at),hasExpired:n,hasPassword:!!(e.link.password&&e.link.password.length>0),createdBy:e.link.created_by,updatedBy:e.link.updated_by,createdAt:r.formatDate(e.link.created_at),updatedAt:r.formatDate(e.link.updated_at)}};var s={formatMultiple:a,formatSingle:o,formatShareAccess:i};export{s as default}; //# sourceMappingURL=media-share-links.mjs.map