@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 1.43 kB
JavaScript
import e from"zod";const t=e.record(e.string(),e.union([e.string(),e.number()]).optional()).optional(),n=e=>{let t=e.indexOf(`:`),n=e.slice(0,t),r=e.slice(t+1);if(t===-1||n!==`admin`&&n!==`server`||r.trim().length===0)throw Error(`Lucid copy keys must start with "admin:" or "server:". Received "${e}".`);return{scope:n,key:r}},r=e.object({type:e.literal(`lucid.copy`),scope:e.enum([`admin`,`server`]),key:e.string().trim().min(1),values:t,defaultMessage:e.string().optional()}).strict(),i=r.extend({scope:e.literal(`admin`)});r.extend({scope:e.literal(`server`)});const a=e.object({type:e.literal(`lucid.literal`),value:e.string(),values:t}).strict(),o=e.union([r,a]);function s(e){return e==null?e:typeof e==`string`?{type:`lucid.literal`,value:e}:e}e.union([e.string(),r,a]).transform(e=>s(e));const c=e.union([e.string(),i,a]).transform(e=>s(e)),l=e.union([i,a]);function u(e,t){let{scope:r,key:i}=n(e);return{type:`lucid.copy`,scope:r,key:i,...t?.data?{values:t.data}:{},...t?.defaultMessage?{defaultMessage:t.defaultMessage}:{}}}const d=Object.assign(u,{literal:(e,t)=>({type:`lucid.literal`,value:e,...t?{values:t}:{}})}),f=e=>o.safeParse(e).success;export{i as adminCopyDescriptorSchema,c as adminCopyInputSchema,d as copy,r as copyDescriptorSchema,f as isTranslatableCopy,a as literalCopySchema,s as normalizeCopy,n as parseCopyKey,l as resolvedAdminCopySchema,o as translatableCopySchema};
//# sourceMappingURL=copy.mjs.map