UNPKG

@lucidcms/core

Version:

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

2 lines 3.63 kB
import{normalizeCopy as e}from"../../../i18n/copy.mjs";import t from"../../../../constants/constants.mjs";import n from"../field-builder/index.mjs";var r=class extends n{key;config;listing=[];labelFields=[];constructor(e,t){super(),this.key=e,this.config={key:this.key,...t},this.config.bricks?.fixed&&(this.config.bricks.fixed=this.#e(t.bricks?.fixed)),this.config.bricks?.builder&&(this.config.bricks.builder=this.#e(t.bricks?.builder))}addText(e,t){return this.#t(e,t),super.addText(e,t),this}addNumber(e,t){return this.#t(e,t),super.addNumber(e,t),this}addRange(e,t){return this.#t(e,t),super.addRange(e,t),this}addCheckbox(e,t){return this.#t(e,t),super.addCheckbox(e,t),this}addSelect(e,t){return this.#t(e,t),super.addSelect(e,t),this}addTextarea(e,t){return this.#t(e,t),super.addTextarea(e,t),this}addDateTime(e,t){return this.#t(e,t),super.addDateTime(e,t),this}addUser(e,t){return this.#t(e,t),super.addUser(e,t),this}addMedia(e,t){return this.#t(e,t),super.addMedia(e,t),this}addRelation(e,t){return this.#t(e,t),super.addRelation(e,t),this}addColor(e,t){return this.#t(e,t),super.addColor(e,t),this}#e=e=>{if(e)return e.filter((t,n)=>e.findIndex(e=>e.key===t.key)===n)};#t=(e,t)=>{t?.showInList&&this.listing.push(e),t?.useAsLabel&&this.labelFields.push(e)};#n=()=>{let t=this.config.group;return t===void 0?null:typeof t==`string`?{key:t,name:null,order:null}:{key:t.key,name:e(t.name)??null,order:t.order??null}};get getData(){return{key:this.key,mode:this.config.mode,group:this.#n(),details:{name:e(this.config.details.name),singularName:e(this.config.details.singularName),summary:e(this.config.details.summary)??null},locked:this.config.locked??t.collectionBuilder.locked,revisions:this.config.revisions??t.collectionBuilder.revisions,localized:this.config.localized??t.collectionBuilder.localized,autoSave:this.config.autoSave??t.collectionBuilder.autoSave,scheduling:this.config.scheduling??t.collectionBuilder.scheduling,orderable:this.config.orderable??t.collectionBuilder.orderable,...this.config.review?{review:{requiredFor:this.config.review?.requiredFor??[],allowSelfApproval:this.config.review?.allowSelfApproval??t.collectionBuilder.publishing.allowSelfApproval,comments:{request:this.config.review?.comments?.request??t.collectionBuilder.publishing.comments.request,decision:this.config.review?.comments?.decision??t.collectionBuilder.publishing.comments.decision}}}:{},...this.config.workflow?{workflow:{initial:this.config.workflow.initial??this.config.workflow.stages[0]?.key??``,stages:this.config.workflow.stages.map(n=>({key:n.key,name:e(n.name),color:n.color??t.collectionBuilder.publishing.workflow.color,publishTargets:n.publishTargets??[]}))}}:{},listing:this.listing,labelFields:this.labelFields,environments:this.config.environments?.map(t=>({...t,name:e(t.name),requires:t.requires??[],collectionVersions:t.collectionVersions??{}}))??[],revisionRetentionDays:this.config.revisionRetentionDays??t.collectionBuilder.revisionRetentionDays,preview:this.config.preview?{breakpoints:this.config.preview.breakpoints?.map(t=>({...t,label:e(t.label)}))??[]}:null,tenants:this.config.tenants??[]}}get fixedBricks(){return this.config.bricks?.fixed?.map(e=>({key:e.key,details:e.config.details,preview:e.config.preview,tenants:e.config.tenants,fields:e.fieldTree}))??[]}get builderBricks(){return this.config.bricks?.builder?.map(e=>({key:e.key,details:e.config.details,preview:e.config.preview,tenants:e.config.tenants,fields:e.fieldTree}))??[]}get brickInstances(){return(this.config.bricks?.builder||[]).concat(this.config.bricks?.fixed||[])}};export{r as default}; //# sourceMappingURL=index.mjs.map