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.02 kB
import{copy as e}from"../../../i18n/copy.mjs";import t from"../../../repositories/collection-migrations.mjs";import n from"../infer-schema.mjs";import r from"./build-runtime-schema.mjs";import i from"./diff-snapshot-vs-config.mjs";import{resolveRuntimeSchema as a}from"./runtime-schema-cache.mjs";const o=async(o,s)=>{let c=new t(o.db.client,o.config.db);return await a(o,s.collectionKey,async()=>{let t=o.config.collections.find(e=>e.key===s.collectionKey);if(!t)return{data:void 0,error:{message:e(`server:core.collections.not.found.message`)}};let a=n(t,o.config.db);if(a.error)return a;let l=await c.selectLatestByCollectionKey({collectionKey:s.collectionKey});if(l.error)return l;if(!l.data)return{data:void 0,error:{type:`basic`,name:e(`server:core.error.schema.migration.required.name`),message:e(`server:core.error.schema.migration.required.message`),status:400}};let u=i(l.data.collection_schema,a.data);return{data:r(a.data,u),error:void 0}})};export{o as default}; //# sourceMappingURL=get-runtime-schema.mjs.map