@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 1.47 kB
JavaScript
import e from"../../libs/repositories/documents.mjs";import{tenantAccessAllowed as t}from"../../utils/helpers/tenants.mjs";import n from"../../libs/collection/schema/runtime/prime-runtime-schemas.mjs";import{getDocumentTableSchema as r}from"../../libs/collection/schema/runtime/runtime-schema-selectors.mjs";import i from"../../libs/formatters/collections.mjs";const a=async(a,o)=>{let s=(a.config.collections??[]).filter(e=>t(e.getData.tenants,a.request.tenantKey)),c=a.translate.forLocale(a.config.i18n.defaultLocale).adminBundle();if(o.includeDocumentId===!0){let t=s.filter(e=>e.getData.mode===`single`),l=new e(a.db.client,a.config.db);await n(a,{collectionKeys:t.map(e=>e.key)});let u=await l.selectMultipleUnion({tables:(await Promise.all(t.map(async e=>{let t=await r(a,e.key);return t.error||!t.data?null:t.data.name}))).filter(e=>e!==null)});return u.error?u:{error:void 0,data:i.formatMultiple({collections:s,allCollections:a.config.collections??[],tenantKey:a.request.tenantKey,queueSupportsScheduling:a.queue.support.scheduling,adminTranslations:c,include:{bricks:!1,fields:o.includeFields===!0,documentId:!0},documents:u.data})}}return{error:void 0,data:i.formatMultiple({collections:s,allCollections:a.config.collections??[],tenantKey:a.request.tenantKey,queueSupportsScheduling:a.queue.support.scheduling,adminTranslations:c,include:{bricks:!1,fields:o.includeFields===!0,documentId:!1}})}};export{a as default};
//# sourceMappingURL=get-all.mjs.map