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.66 kB
import{copy as e}from"../../libs/i18n/copy.mjs";import t from"../../libs/repositories/documents.mjs";import{tenantAccessAllowed as n}from"../../utils/helpers/tenants.mjs";import{getTableNames as r}from"../../libs/collection/schema/runtime/runtime-schema-selectors.mjs";import i from"../../libs/collection/get-collection-migration-status.mjs";import a from"../../libs/formatters/collections.mjs";const o=async(o,s)=>{let c=o.config.collections?.find(e=>e.key===s.key);if(c===void 0||!n(c.getData.tenants,o.request.tenantKey))return{error:{type:`basic`,message:e(`server:core.collections.not.found.message`),status:404},data:void 0};let l=await r(o,c.key);if(l.error)return l;let u=await i(o,{collection:c});if(u.error)return u;let d=o.translate.forLocale(o.config.i18n.defaultLocale).adminBundle();if(c.getData.mode===`single`){let e=await new t(o.db.client,o.config.db).selectSingle({select:[`id`],where:[{key:`is_deleted`,operator:`=`,value:o.config.db.getDefault(`boolean`,`false`)}]},{tableName:l.data.document});return e.error?e:{error:void 0,data:a.formatSingle({collection:c,allCollections:o.config.collections??[],tenantKey:o.request.tenantKey,queueSupportsScheduling:o.queue.support.scheduling,adminTranslations:d,include:{bricks:!0,fields:!0,documentId:!0},documents:e.data?[{id:e.data.id,collection_key:c.key}]:void 0})}}return{error:void 0,data:a.formatSingle({collection:c,allCollections:o.config.collections??[],tenantKey:o.request.tenantKey,queueSupportsScheduling:o.queue.support.scheduling,adminTranslations:d,migrationStatus:u.data,include:{bricks:!0,fields:!0,documentId:!0}})}};export{o as default}; //# sourceMappingURL=get-single.mjs.map