@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 5.19 kB
JavaScript
import{activeMediaCropSelect as e}from"./helpers/media-selects.mjs";import t from"./parents/static-repository.mjs";import n from"zod";var r=class extends t{constructor(e,t){super(e,t,`lucid_document_workflows`)}tableSchema=n.object({id:n.number(),collection_key:n.string(),document_id:n.number(),stage_key:n.string(),created_by:n.number().nullable(),updated_by:n.number().nullable(),created_at:n.union([n.string(),n.date()]),updated_at:n.union([n.string(),n.date()]).nullable()});columnFormats={id:this.dbAdapter.getDataType(`primary`),collection_key:this.dbAdapter.getDataType(`text`),document_id:this.dbAdapter.getDataType(`integer`),stage_key:this.dbAdapter.getDataType(`text`),created_by:this.dbAdapter.getDataType(`integer`),updated_by:this.dbAdapter.getDataType(`integer`),created_at:this.dbAdapter.getDataType(`timestamp`),updated_at:this.dbAdapter.getDataType(`timestamp`)};queryConfig=void 0;async selectSingleDetailed(t){let n=this.db.selectFrom(`lucid_document_workflows`).where(`collection_key`,`=`,t.collectionKey).where(`document_id`,`=`,t.documentId).selectAll(`lucid_document_workflows`).select(t=>[this.dbAdapter.jsonArrayFrom(t.selectFrom(`lucid_document_workflow_assignees`).leftJoin(`lucid_users`,`lucid_users.id`,`lucid_document_workflow_assignees.user_id`).select(t=>[`lucid_document_workflow_assignees.id`,`lucid_document_workflow_assignees.workflow_id`,`lucid_document_workflow_assignees.user_id`,`lucid_document_workflow_assignees.assigned_by`,`lucid_document_workflow_assignees.assigned_at`,`lucid_users.email`,`lucid_users.username`,`lucid_users.first_name`,`lucid_users.last_name`,this.dbAdapter.jsonArrayFrom(t.selectFrom(`lucid_media`).select(t=>[`lucid_media.id`,`lucid_media.key`,`lucid_media.origin`,`lucid_media.type`,`lucid_media.mime_type`,`lucid_media.file_extension`,`lucid_media.file_name`,`lucid_media.file_size`,`lucid_media.width`,`lucid_media.height`,`lucid_media.focal_x`,`lucid_media.focal_y`,`lucid_media.blur_hash`,`lucid_media.average_color`,`lucid_media.base64`,`lucid_media.is_dark`,`lucid_media.is_light`,e(this.db,this.dbAdapter,`lucid_media.id`),this.dbAdapter.jsonArrayFrom(t.selectFrom(`lucid_media_translations`).select([`lucid_media_translations.title`,`lucid_media_translations.alt`,`lucid_media_translations.description`,`lucid_media_translations.summary`,`lucid_media_translations.locale_code`]).whereRef(`lucid_media_translations.media_id`,`=`,`lucid_media.id`)).as(`translations`)]).whereRef(`lucid_media.id`,`=`,`lucid_users.profile_picture_media_id`).where(`lucid_media.is_deleted`,`=`,this.dbAdapter.getDefault(`boolean`,`false`))).as(`profile_picture`)]).whereRef(`lucid_document_workflow_assignees.workflow_id`,`=`,`lucid_document_workflows.id`).orderBy(`lucid_document_workflow_assignees.assigned_at`,`asc`)).as(`assignees`)]),r=await this.executeQuery(()=>n.executeTakeFirst(),{method:`selectSingleDetailed`});return r.response.error?r.response:this.validateResponse(r,{...t.validation,mode:`single`})}async selectMultipleDetailedByDocumentIds(t){if(t.documentIds.length===0)return{error:void 0,data:[]};let n=this.db.selectFrom(`lucid_document_workflows`).where(`collection_key`,`=`,t.collectionKey).where(`document_id`,`in`,t.documentIds).selectAll(`lucid_document_workflows`).select(t=>[this.dbAdapter.jsonArrayFrom(t.selectFrom(`lucid_document_workflow_assignees`).leftJoin(`lucid_users`,`lucid_users.id`,`lucid_document_workflow_assignees.user_id`).select(t=>[`lucid_document_workflow_assignees.id`,`lucid_document_workflow_assignees.workflow_id`,`lucid_document_workflow_assignees.user_id`,`lucid_document_workflow_assignees.assigned_by`,`lucid_document_workflow_assignees.assigned_at`,`lucid_users.email`,`lucid_users.username`,`lucid_users.first_name`,`lucid_users.last_name`,this.dbAdapter.jsonArrayFrom(t.selectFrom(`lucid_media`).select(t=>[`lucid_media.id`,`lucid_media.key`,`lucid_media.origin`,`lucid_media.type`,`lucid_media.mime_type`,`lucid_media.file_extension`,`lucid_media.file_name`,`lucid_media.file_size`,`lucid_media.width`,`lucid_media.height`,`lucid_media.focal_x`,`lucid_media.focal_y`,`lucid_media.blur_hash`,`lucid_media.average_color`,`lucid_media.base64`,`lucid_media.is_dark`,`lucid_media.is_light`,e(this.db,this.dbAdapter,`lucid_media.id`),this.dbAdapter.jsonArrayFrom(t.selectFrom(`lucid_media_translations`).select([`lucid_media_translations.title`,`lucid_media_translations.alt`,`lucid_media_translations.description`,`lucid_media_translations.summary`,`lucid_media_translations.locale_code`]).whereRef(`lucid_media_translations.media_id`,`=`,`lucid_media.id`)).as(`translations`)]).whereRef(`lucid_media.id`,`=`,`lucid_users.profile_picture_media_id`).where(`lucid_media.is_deleted`,`=`,this.dbAdapter.getDefault(`boolean`,`false`))).as(`profile_picture`)]).whereRef(`lucid_document_workflow_assignees.workflow_id`,`=`,`lucid_document_workflows.id`).orderBy(`lucid_document_workflow_assignees.assigned_at`,`asc`)).as(`assignees`)]),r=await this.executeQuery(()=>n.execute(),{method:`selectMultipleDetailedByDocumentIds`});return r.response.error?r.response:this.validateResponse(r,{...t.validation,mode:`multiple`})}};export{r as default};
//# sourceMappingURL=document-workflows.mjs.map