@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 25.1 kB
JavaScript
import{constants_default as e,tidy_zod_errors_default as t,translations_default as n}from"./errors-RyYO6qM6.js";import{create_media_url_default as r,formatters_default as i}from"./formatters-CNwZ581Q.js";import{build_table_name_default as a}from"./build-table-name-yLR81YJn.js";import o from"zod/v4";import s from"lodash.merge";import{isValid as c}from"date-fns";const l=e=>e.replace(/\n/g,` `).trim().replaceAll(` →`,` →`),u=(e,r)=>{let i=r.safeParse(e);return i?.success?{valid:!0}:{valid:!1,message:l(t(i.error))??n(`an_unknown_error_occurred_validating_the_field`)}};var d=u,f=class{repeater=null;validate(e){if(this.config.type===`tab`)return{valid:!0};let t=this.fieldTypeValidation(e.type);if(t.valid===!1)return t;let n=this.requiredCheck(e.value);if(!n.valid)return n;let r=this.zodCheck(e.value);return r.valid?e.value===null||e.value===void 0?{valid:!0}:this.cfSpecificValidation(e.value,e.relationData):r}fieldTypeValidation(e){return this.errors.fieldType.condition?.(e)?{valid:!1,message:n(`field_type_mismatch`,{received:e,expected:this.config.type})}:{valid:!0}}requiredCheck(e){return this.config.type===`tab`||this.config.type===`repeater`?{valid:!0}:this.config.validation?.required===!0&&this.errors.required.condition?.(e)?{valid:!1,message:this.errors.required.message}:{valid:!0}}zodCheck(e){return this.config.type===`tab`||this.config.type===`repeater`||this.config.type===`media`||this.config.type===`checkbox`||this.config.type===`select`||this.config.type===`colour`||this.config.type===`link`||this.config.type===`user`||this.config.type===`wysiwyg`||this.config.type===`document`||!this.config.validation?.zod?{valid:!0}:d(e,this.config.validation?.zod)}get errors(){return{fieldType:{condition:e=>e!==this.type,message:n(`field_type_mismatch`,{received:`unknown`,expected:this.config.type})},required:{condition:e=>e==null||e===``,message:n(`generic_field_required`)},zod:{message:n(`generic_field_invalid`)}}}},p=f;const m=e=>{if(typeof e!=`string`)return e;let t=e.split(/[-_]/g).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `);return t};var h=m,g=class extends p{type=`checkbox`;column=`bool_value`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary,true:this.props?.details?.true,false:this.props?.details?.false},config:{useTranslations:this.props?.config?.useTranslations??!1,default:this.props?.config?.default??!1,isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`boolean`),nullable:!0,default:e.db.formatInsertValue(`boolean`,this.config.config.default)}]},error:void 0}}formatResponseValue(e){return i.formatBoolean(!!e)}formatResponseMeta(){return null}cfSpecificValidation(e){let t=o.union([o.literal(1),o.literal(0),o.boolean()]),n=d(e,t);return n.valid?{valid:!0}:n}get errors(){return s(super.errors,{required:{condition:e=>e==null||e===0,message:n(`checkbox_field_required`)}})}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return this.config.config.default}},_=g,v=class extends p{type=`colour`;column=`text_value`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary},presets:this.props?.presets??[],config:{useTranslations:this.props?.config?.useTranslations??!1,default:this.props?.config?.default??``,isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`text`),nullable:!0,default:this.config.config.default}]},error:void 0}}formatResponseValue(e){return e??this.config.config.default??null}formatResponseMeta(){return null}cfSpecificValidation(e){let t=o.string(),n=d(e,t);return n.valid?{valid:!0}:n}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return this.config.config.default}},y=v,b=class extends p{type=`datetime`;column=`text_value`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary,placeholder:this.props?.details?.placeholder},config:{useTranslations:this.props?.config?.useTranslations??!1,default:this.props?.config?.default??``,isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`timestamp`),nullable:!0,default:this.config.config.default}]},error:void 0}}formatResponseValue(e){return e??this.config.config.default??null}formatResponseMeta(){return null}cfSpecificValidation(e){let t=o.union([o.string(),o.number(),o.date()]),r=d(e,t);if(!r.valid)return r;let i=new Date(e);return c(i)?{valid:!0}:{valid:!1,message:n(`field_date_invalid`)}}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return this.config.config.default}},x=b,S=class extends p{type=`json`;column=`json_value`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary,placeholder:this.props?.details?.placeholder},config:{useTranslations:this.props?.config?.useTranslations??!1,default:this.props?.config?.default||{},isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`json`),nullable:!0,default:this.config.config.default}]},error:void 0}}formatResponseValue(e){return e??this.config.config.default??null}formatResponseMeta(){return null}cfSpecificValidation(e){let t=o.record(o.union([o.string(),o.number(),o.symbol()]),o.unknown()),n=d(e,t);return n.valid?{valid:!0}:n}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return this.config.config.default}},C=S,w=class extends p{type=`link`;column=`text_value`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary,placeholder:this.props?.details?.placeholder},config:{useTranslations:this.props?.config?.useTranslations??!1,default:this.props?.config?.default??{url:null,label:null,target:null},isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`json`),nullable:!0,default:this.config.config.default}]},error:void 0}}formatResponseValue(e){return{url:e?.url??this.config.config.default.url??null,label:e?.label??this.config.config.default.label??null,target:e?.target??this.config.config.default.target??null}}formatResponseMeta(){return null}cfSpecificValidation(t){let r=o.object({url:o.string().optional().nullable(),target:o.string().optional().nullable(),label:o.string().optional().nullable()}),i=d(t,r);if(!i.valid)return i;let a=t;return a.target&&!e.customFields.link.targets.includes(a.target)?{valid:!1,message:n(`field_link_target_error_message`,{valid:e.customFields.link.targets.join(`, `)})}:{valid:!0}}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return this.config.config.default}},T=w;const E=(e,t)=>t.reduce((t,n)=>{let r=e.find(e=>e.locale_code===n);return r?t[n]=r.value??``:t[n]=``,t},{});var D=E,O=class extends p{type=`media`;column=`media_id`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary},config:{useTranslations:this.props?.config?.useTranslations??!1,isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`integer`),nullable:!0,foreignKey:{table:`lucid_media`,column:`id`,onDelete:`set null`}}]},error:void 0}}formatResponseValue(e){return e??null}formatResponseMeta(e,t){return e==null?null:{id:e?.id??null,url:r({key:e?.key??``,host:t.host,urlStrategy:t.config.media?.urlStrategy}),key:e?.key??null,mimeType:e?.mime_type??null,extension:e?.file_extension??null,fileSize:e?.file_size??null,width:e?.width??null,height:e?.height??null,blurHash:e?.blur_hash??null,averageColour:e?.average_colour??null,isDark:i.formatBoolean(e?.is_dark??null),isLight:i.formatBoolean(e?.is_light??null),title:D(e?.title_translations||[],t.localisation.locales),alt:D(e?.alt_translations||[],t.localisation.locales),type:e?.type??null}}cfSpecificValidation(e,t){let r=o.number(),i=d(e,r);if(!i.valid)return i;let a=t?.find(t=>t.id===e);if(a===void 0)return{valid:!1,message:n(`field_media_not_found`)};if(this.config.validation?.extensions?.length){let e=a.file_extension;if(!this.config.validation.extensions.includes(e))return{valid:!1,message:n(`field_media_extension`,{extensions:this.config.validation.extensions.join(`, `)})}}if(this.config.validation?.type){let e=a.type;if(!e)return{valid:!1,message:n(`field_media_doenst_have_type`)};if(this.config.validation.type!==e)return{valid:!1,message:n(`field_media_type`,{type:this.config.validation.type})}}if(this.config.validation?.width&&a.type===`image`){let e=a.width;if(!e)return{valid:!1,message:n(`field_media_doenst_have_width`)};if(this.config.validation.width.min&&e<this.config.validation.width.min)return{valid:!1,message:n(`field_media_min_width`,{min:this.config.validation.width.min})};if(this.config.validation.width.max&&e>this.config.validation.width.max)return{valid:!1,message:n(`field_media_max_width`,{max:this.config.validation.width.max})}}if(this.config.validation?.height&&a.type===`image`){let e=a.height;if(!e)return{valid:!1,message:n(`field_media_doenst_have_height`)};if(this.config.validation.height.min&&e<this.config.validation.height.min)return{valid:!1,message:n(`field_media_min_height`,{min:this.config.validation.height.min})};if(this.config.validation.height.max&&e>this.config.validation.height.max)return{valid:!1,message:n(`field_media_max_height`,{max:this.config.validation.height.max})}}return{valid:!0}}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return null}},k=O,A=class extends p{type=`number`;column=`int_value`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary,placeholder:this.props?.details?.placeholder},config:{useTranslations:this.props?.config?.useTranslations??!1,default:this.props?.config?.default,isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`integer`),nullable:!0,default:this.config.config.default}]},error:void 0}}formatResponseValue(e){return e??this.config.config.default??null}formatResponseMeta(){return null}cfSpecificValidation(e){let t=o.number(),n=d(e,t);return n.valid?{valid:!0}:n}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return this.config.config.default}},j=A,M=class extends p{type=`repeater`;column=null;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary},config:{isDisabled:this.props?.config?.isDisabled},fields:[],validation:this.props?.validation}}getSchemaDefinition(){return{data:{columns:[]},error:void 0}}formatResponseValue(){return null}formatResponseMeta(){return null}cfSpecificValidation(e){return Array.isArray(e)&&typeof this.config.validation?.maxGroups==`number`&&e.length>this.config.validation?.maxGroups?{valid:!1,message:n(`repeater_max_groups_exceeded`,{groups:this.config.validation.maxGroups})}:Array.isArray(e)&&typeof this.config.validation?.minGroups==`number`&&this.config.validation?.minGroups>e.length?{valid:!1,message:n(`repeater_groups_exceeded_min`,{groups:this.config.validation.minGroups})}:{valid:!0}}get translationsEnabled(){return!1}get defaultValue(){return null}},N=M,ee=class extends p{type=`select`;column=`text_value`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary,placeholder:this.props?.details?.placeholder},options:this.props?.options??[],config:{useTranslations:this.props?.config?.useTranslations??!1,default:this.props?.config?.default??``,isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`text`),nullable:!0}]},error:void 0}}formatResponseValue(e){return e??this.config.config.default??null}formatResponseMeta(){return null}cfSpecificValidation(e){let t=o.string(),r=d(e,t);if(!r.valid)return r;if(this.config.options){let t=this.config.options.map(e=>e.value);if(!t.includes(e))return{valid:!1,message:n(`please_ensure_a_valid_option_is_selected`)}}return{valid:!0}}get errors(){return s(super.errors,{required:{message:n(`select_field_required`)}})}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return this.config.config.default}},P=ee,F=class extends p{type=`text`;column=`text_value`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary,placeholder:this.props?.details?.placeholder},config:{useTranslations:this.props?.config?.useTranslations??!0,default:this.props?.config?.default??``,isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`text`),nullable:!0,default:this.config.config.default}]},error:void 0}}formatResponseValue(e){return e??this.config.config.default??null}formatResponseMeta(){return null}cfSpecificValidation(e){let t=o.string(),n=d(e,t);return n.valid?{valid:!0}:n}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return this.config.config.default}},I=F,L=class extends p{type=`textarea`;column=`text_value`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary,placeholder:this.props?.details?.placeholder},config:{useTranslations:this.props?.config?.useTranslations??!0,default:this.props?.config?.default??``,isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`text`),nullable:!0,default:this.config.config.default}]},error:void 0}}formatResponseValue(e){return e??this.config.config.default??null}formatResponseMeta(){return null}cfSpecificValidation(e){let t=o.string(),n=d(e,t);return n.valid?{valid:!0}:n}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return this.config.config.default}},R=L,z=class extends p{type=`user`;column=`user_id`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary},config:{useTranslations:this.props?.config?.useTranslations??!1,isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`integer`),nullable:!0,foreignKey:{table:`lucid_users`,column:`id`,onDelete:`set null`}}]},error:void 0}}formatResponseValue(e){return e??null}formatResponseMeta(e,t){return e==null?null:{email:e?.email??null,username:e?.username??null,firstName:e?.first_name??null,lastName:e?.last_name??null}}cfSpecificValidation(e,t){let r=o.number(),i=d(e,r);if(!i.valid)return i;let a=t?.find(t=>t.id===e);return a===void 0?{valid:!1,message:n(`field_user_not_found`)}:{valid:!0}}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return null}},B=z,V=class extends p{type=`wysiwyg`;column=`text_value`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary,placeholder:this.props?.details?.placeholder},config:{useTranslations:this.props?.config?.useTranslations??!0,default:this.props?.config?.default??``,isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`text`),nullable:!0,default:this.config.config.default}]},error:void 0}}formatResponseValue(e){return e??this.config.config.default??null}formatResponseMeta(){return null}cfSpecificValidation(e){let t=o.string(),n=d(e,t);return n.valid?this.config.validation?.zod?d(e,this.config.validation?.zod):{valid:!0}:n}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return this.config.config.default}},H=V;const U=i.get(`document-fields`),W=i.get(`document-bricks`);var G=class extends p{type=`document`;column=`document_id`;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,collection:this.props.collection,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary},config:{useTranslations:this.props?.config?.useTranslations??!1,isHidden:this.props?.config?.isHidden,isDisabled:this.props?.config?.isDisabled},validation:this.props?.validation}}getSchemaDefinition(e){let t=a(`document`,{collection:this.config.collection});return t.error?t:{data:{columns:[{name:this.key,type:e.db.getDataType(`integer`),nullable:!0,foreignKey:{table:t.data,column:`id`,onDelete:`set null`}}]},error:void 0}}formatResponseValue(e){return e??null}formatResponseMeta(e,t){if(e==null)return null;let n=t.config.collections.find(e=>e.key===this.props.collection);if(!n||!e)return{id:e?.document_id??null,collectionKey:e?.collection_key??null,fields:null};let r=U.objectifyFields(W.formatDocumentFields({bricksQuery:e,bricksSchema:t.bricksTableSchema,relationMetaData:{},collection:n,config:t.config}));return{id:e?.id??null,collectionKey:e?.collection_key??null,fields:Object.keys(r).length>0?r:null}}cfSpecificValidation(e,t){let r=o.number(),i=d(e,r);if(!i.valid)return i;let a=t?.find(t=>t.id===e&&t.collection_key===this.config.collection);return a===void 0?{valid:!1,message:n(`field_document_not_found`)}:{valid:!0}}get translationsEnabled(){return this.config.config.useTranslations}get defaultValue(){return null}},K=G,q=class{fields=new Map;repeaterStack=[];meta={fieldKeys:[],repeaterDepth:{}};addRepeater(e,t){return this.meta.repeaterDepth[e]=this.repeaterStack.length,this.fields.set(e,new N(e,t)),this.repeaterStack.push(e),this}addText(e,t){return this.fields.set(e,new I(e,t)),this.meta.fieldKeys.push(e),this}addWysiwyg(e,t){return this.fields.set(e,new H(e,t)),this.meta.fieldKeys.push(e),this}addMedia(e,t){return this.fields.set(e,new k(e,t)),this.meta.fieldKeys.push(e),this}addDocument(e,t){return this.fields.set(e,new K(e,t)),this.meta.fieldKeys.push(e),this}addNumber(e,t){return this.fields.set(e,new j(e,t)),this.meta.fieldKeys.push(e),this}addCheckbox(e,t){return this.fields.set(e,new _(e,t)),this.meta.fieldKeys.push(e),this}addSelect(e,t){return this.fields.set(e,new P(e,t)),this.meta.fieldKeys.push(e),this}addTextarea(e,t){return this.fields.set(e,new R(e,t)),this.meta.fieldKeys.push(e),this}addJSON(e,t){return this.fields.set(e,new C(e,t)),this.meta.fieldKeys.push(e),this}addColour(e,t){return this.fields.set(e,new y(e,t)),this.meta.fieldKeys.push(e),this}addDateTime(e,t){return this.fields.set(e,new x(e,t)),this.meta.fieldKeys.push(e),this}addLink(e,t){return this.fields.set(e,new T(e,t)),this.meta.fieldKeys.push(e),this}addUser(e,t){return this.fields.set(e,new B(e,t)),this.meta.fieldKeys.push(e),this}endRepeater(){let e=this.repeaterStack.pop();if(!e)return this;let t=Array.from(this.fields.values()),n=t.findIndex(t=>t.type===`repeater`&&t.key===e);if(n===-1)return this;let r=t.slice(n+1);for(let t of r){if(t.type===`tab`||t.repeater)continue;t.repeater=e}return this}nestFields(e){let t=Array.from(this.fields.values()).filter(t=>e?t.type!==`tab`:!0),n=[],r=null,i=new Map;for(let e of t){let t=JSON.parse(JSON.stringify(e.config));if(e.type===`tab`){r&&n.push(r),r=t;continue}e.type===`repeater`&&i.set(e.key,t);let a=r?r.fields:n;if(e.repeater){let n=i.get(e.repeater);n&&n.fields.push(t)}else a.push(t)}return r&&n.push(r),n}get fieldTree(){return this.nestFields(!1)}get fieldTreeNoTab(){return this.nestFields(!0)}get flatFields(){let e=[];for(let[t,n]of this.fields)e.push(n.config);return e}},J=q,Y=class extends p{type=`tab`;column=null;config;key;props;constructor(e,t){super(),this.key=e,this.props=t,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??h(this.key),summary:this.props?.details?.summary},fields:[]}}getSchemaDefinition(){return{data:{columns:[]},error:void 0}}formatResponseValue(){return null}formatResponseMeta(){return null}cfSpecificValidation(){return{valid:!0}}get translationsEnabled(){return!1}get defaultValue(){return null}},X=Y,Z=class extends J{key;config;constructor(e,t){super(),this.key=e,this.config={key:this.key,details:{name:t?.details?.name||e,summary:t?.details?.summary},preview:t?.preview||{}}}addFields(e){let t=Array.from(e.fields.values());for(let e of t)this.fields.set(e.key,e),this.meta.fieldKeys.push(e.key);return this}addTab(e,t){return this.fields.set(e,new X(e,t)),this.meta.fieldKeys.push(e),this}},Q=Z,$=class extends J{key;config;displayInListing=[];constructor(e,t){super(),this.key=e,this.config={key:this.key,...t},this.config.bricks?.fixed&&(this.config.bricks.fixed=this.#removeDuplicateBricks(t.bricks?.fixed)),this.config.bricks?.builder&&(this.config.bricks.builder=this.#removeDuplicateBricks(t.bricks?.builder))}addText(e,t){return this.#fieldCollectionHelper(e,t?.displayInListing),super.addText(e,t),this}addNumber(e,t){return this.#fieldCollectionHelper(e,t?.displayInListing),super.addNumber(e,t),this}addCheckbox(e,t){return this.#fieldCollectionHelper(e,t?.displayInListing),super.addCheckbox(e,t),this}addSelect(e,t){return this.#fieldCollectionHelper(e,t?.displayInListing),super.addSelect(e,t),this}addTextarea(e,t){return this.#fieldCollectionHelper(e,t?.displayInListing),super.addTextarea(e,t),this}addDateTime(e,t){return this.#fieldCollectionHelper(e,t?.displayInListing),super.addDateTime(e,t),this}addUser(e,t){return this.#fieldCollectionHelper(e,t?.displayInListing),super.addUser(e,t),this}addMedia(e,t){return this.#fieldCollectionHelper(e,t?.displayInListing),super.addMedia(e,t),this}#removeDuplicateBricks=e=>{if(e)return e.filter((t,n)=>e.findIndex(e=>e.key===t.key)===n)};#fieldCollectionHelper=(e,t)=>{t&&this.displayInListing.push(e)};get getData(){return{key:this.key,mode:this.config.mode,details:{name:this.config.details.name,singularName:this.config.details.singularName,summary:this.config.details.summary??null},config:{isLocked:this.config.config?.isLocked??e.collectionBuilder.isLocked,useDrafts:this.config.config?.useDrafts??e.collectionBuilder.useDrafts,useRevisions:this.config.config?.useRevisions??e.collectionBuilder.useRevisions,useTranslations:this.config.config?.useTranslations??e.collectionBuilder.useTranslations,useAutoSave:this.config.config?.useAutoSave??e.collectionBuilder.useAutoSave,displayInListing:this.displayInListing}}}get fixedBricks(){return this.config.bricks?.fixed?.map(e=>({key:e.key,details:e.config.details,preview:e.config.preview,fields:e.fieldTree}))??[]}get builderBricks(){return this.config.bricks?.builder?.map(e=>({key:e.key,details:e.config.details,preview:e.config.preview,fields:e.fieldTree}))??[]}get brickInstances(){return(this.config.bricks?.builder||[]).concat(this.config.bricks?.fixed||[])}},te=$;export{Q as BrickBuilder,te as CollectionBuilder,J as FieldBuilder};
//# sourceMappingURL=builders.js.map