UNPKG

@lucidcms/core

Version:

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

2 lines 8.59 kB
import{resolvedAdminCopySchema as e}from"../libs/i18n/copy.mjs";import t from"zod";const n=t.object({key:t.string(),type:t.union([t.literal(`text`),t.literal(`rich-text`),t.literal(`media`),t.literal(`number`),t.literal(`range`),t.literal(`checkbox`),t.literal(`select`),t.literal(`textarea`),t.literal(`json`),t.literal(`code`),t.literal(`color`),t.literal(`datetime`),t.literal(`link`),t.literal(`repeater`),t.literal(`user`),t.literal(`relation`)]),translations:t.record(t.string(),t.any()).optional(),value:t.any().optional(),get groups(){return t.array(t.object({ref:t.string(),order:t.number().optional(),open:t.boolean().optional(),get fields(){return t.array(n)}})).optional()}}),r=t.object({key:t.string().meta({description:`Unique identifier for the field`,example:`pageTitle`}),type:t.string().meta({description:`Type of the field (text, checkbox, media, etc.)`,example:`text`}),collection:t.union([t.string(),t.array(t.string())]).nullable().meta({description:`Collection key for relation fields`,example:[`page`,`blog`]}).optional(),details:t.object({label:e.meta({description:`Display label for the field`,example:{type:`lucid.copy`,scope:`admin`,key:`collections.page.fields.pageTitle.label`,defaultMessage:`Page title`}}).optional(),summary:e.meta({description:`Description text for the field`,example:{type:`lucid.copy`,scope:`admin`,key:`collections.page.fields.pageTitle.summary`,defaultMessage:`The title of the page.`}}).optional(),placeholder:e.meta({description:`Placeholder text for input fields`,example:{type:`lucid.copy`,scope:`admin`,key:`collections.page.fields.pageTitle.placeholder`,defaultMessage:`Enter page title...`}}).optional(),true:e.meta({description:`Label for true value in boolean fields`,example:{type:`lucid.copy`,scope:`admin`,key:`collections.page.fields.featured.trueLabel`,defaultMessage:`Yes`}}).optional(),false:e.meta({description:`Label for false value in boolean fields`,example:{type:`lucid.copy`,scope:`admin`,key:`collections.page.fields.featured.falseLabel`,defaultMessage:`No`}}).optional()}),ai:t.object({enabled:t.boolean().meta({description:`Whether AI generation is enabled for this field`,example:!0}),guidance:t.array(t.object({key:t.string().meta({description:`Unique key for the guidance option`,example:`improve`}),label:e.meta({description:`Display label for the guidance option`,example:{type:`lucid.copy`,scope:`admin`,key:`core.ai.guidance.improve.label`,defaultMessage:`Improve`}})}))}).optional(),localized:t.boolean().meta({description:`Whether the field supports localized content`,example:!0}).nullable().optional(),time:t.boolean().meta({description:`Whether datetime fields include time selection`,example:!0}).nullable().optional(),multiple:t.boolean().meta({description:`Whether relation fields can store more than one related item`,example:!0}).nullable().optional(),thumbs:t.union([t.literal(1),t.literal(2)]).meta({description:`Number of slider thumbs used by range fields`,example:2}).nullable().optional(),min:t.number().meta({description:`Minimum value for range fields`,example:0}).nullable().optional(),max:t.number().meta({description:`Maximum value for range fields`,example:100}).nullable().optional(),step:t.number().meta({description:`Step size for range fields`,example:.5}).nullable().optional(),index:t.literal(!0).meta({description:`Whether Lucid generates an index for the field`,example:!0}).nullable().optional(),default:t.any().meta({description:`Default value for the field`,example:`Welcome to our website`}).nullable().optional(),output:t.enum([`nested`,`inline`]).meta({description:`How section/collapsible fields shape their children in client document responses`,example:`nested`}).nullable().optional(),defaultOpen:t.boolean().meta({description:`Whether a collapsible renders expanded by default`,example:!1}).nullable().optional(),ui:t.object({hidden:t.boolean().meta({description:`Whether the field is hidden in the UI`,example:!1}).nullable().optional(),width:t.union([t.literal(12),t.literal(8),t.literal(6),t.literal(4),t.literal(3)]).meta({description:`Admin layout width on a fixed 12-column grid`,example:6}).nullable().optional(),disabled:t.boolean().meta({description:`Whether the field is disabled for editing`,example:!1}).nullable().optional(),condition:t.object({action:t.enum([`show`,`hide`]).meta({description:`Whether matching the condition shows or hides the field`,example:`show`}).optional(),translationScope:t.enum([`same`,`default`,`any`]).meta({description:`How localized target field values are resolved while evaluating the condition`,example:`same`}).optional(),groups:t.array(t.array(t.object({field:t.string().meta({description:`Key of the sibling or ancestor-scope field the rule evaluates against`,example:`menuType`}),operator:t.enum([`equals`,`notEquals`,`isEmpty`,`isNotEmpty`,`contains`,`notContains`]).meta({description:`Comparison operator for the rule`,example:`equals`}),value:t.union([t.string(),t.number(),t.boolean(),t.null()]).meta({description:`Value the rule compares against`,example:`docs`}).optional()}))).meta({description:`Condition rule groups. Groups are OR'd, rules within a group are AND'd`})}).nullable().optional()}).optional(),validation:t.object({required:t.boolean().nullable().meta({description:`Whether the field is required`,example:!0}).optional(),zod:t.any().nullable().meta({description:`Custom Zod validation schema for the field`,example:`z.string().min(2).max(128)`}).optional(),type:t.string().nullable().meta({description:`Media type constraint for media fields`,example:`image`}).optional(),maxGroups:t.number().nullable().meta({description:`Maximum groups allowed in a repeater`,example:3}).optional(),minGroups:t.number().nullable().meta({description:`Minimum groups required in a repeater`,example:1}).optional(),extensions:t.array(t.string()).nullable().meta({description:`Allowed file extensions for media fields`,example:[`jpg`,`png`,`webp`]}).optional(),width:t.object({min:t.number().nullable().meta({description:`Minimum width for media`,example:800}),max:t.number().nullable().meta({description:`Maximum width for media`,example:1920})}).optional().nullable(),height:t.object({min:t.number().nullable().meta({description:`Minimum height for media`,example:600}),max:t.number().nullable().meta({description:`Maximum height for media`,example:1080})}).optional().nullable()}).optional(),fields:t.any().meta({description:`Nested fields for repeater or tab field types`,example:[]}).optional(),options:t.array(t.object({label:e.meta({description:`Display label for the option`,example:{type:`lucid.copy`,scope:`admin`,key:`collections.page.fields.status.options.draft.label`,defaultMessage:`Draft`}}),value:t.string().meta({description:`Value of the option when selected`,example:`option_a`})})).nullable().meta({description:`Options for select field types`,example:[{label:{en:`Option A`},value:`option_a`}]}).optional(),presets:t.array(t.string()).nullable().meta({description:`Preset values for color fields`,example:[`#ff0000`,`#00ff00`,`#0000ff`]}).optional(),languages:t.array(t.string()).nullable().meta({description:`Language options for code fields`,example:[`javascript`,`typescript`,`css`]}).optional()}),i=t.object({ref:t.string().meta({description:`Unique reference for this field group`,example:`3243243`}),order:t.number().meta({description:`The order/position of this group in its parent`,example:0}),open:t.boolean().meta({description:`Whether this group is expanded in the UI`,example:!0})}),a=i.extend({get fields(){return t.array(t.any())}}),o=i.extend({get fields(){return t.record(t.any(),t.any())}}),s=t.object({key:t.string().meta({description:`The fields key`,example:`pageTitle`}),type:t.string().meta({description:`The type of field (e.g., text, number, media)`,example:`text`}),groupRef:t.string().meta({description:`Reference to the group this field belongs to, if applicable`,example:`3243243`}).optional(),translations:t.record(t.any(),t.any()).meta({description:`Translations of the field value for different locales`,example:{en:`Welcome to our website`,fr:`Bienvenue sur notre site web`}}).optional(),value:t.any().meta({description:`The value of the field`,example:`Welcome to our website`}).optional()}),c=s.extend({get groups(){return t.array(a)}}),l=s.extend({get groups(){return t.array(o)}});export{l as fieldClientResponseSchema,r as fieldConfigSchema,n as fieldInputSchema,s as fieldResponseBaseSchema,c as fieldResponseSchema,o as groupClientResponseSchema,i as groupResponseBaseSchema,a as groupResponseSchema}; //# sourceMappingURL=collection-fields.mjs.map