@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 3.29 kB
Source Map (JSON)
{"version":3,"file":"get-overview.mjs","names":["formatter"],"sources":["../../../src/services/document-publish-operations/get-overview.ts"],"sourcesContent":["import formatter from \"../../libs/formatters/index.js\";\nimport { DocumentPublishOperationsRepository } from \"../../libs/repositories/index.js\";\nimport type { GetOverviewQueryParams } from \"../../schemas/publish-operation-management.js\";\nimport type { LucidAuth } from \"../../types/hono.js\";\nimport type { PublishOperationOverview } from \"../../types/response.js\";\nimport type { ServiceFn } from \"../../utils/services/types.js\";\nimport { getReviewableCollectionKeys } from \"./helpers/index.js\";\n\nconst getOverview: ServiceFn<\n\t[\n\t\t{\n\t\t\tuser: LucidAuth;\n\t\t\tquery: GetOverviewQueryParams;\n\t\t},\n\t],\n\tPublishOperationOverview\n> = async (context, data) => {\n\tconst collectionKeys = getReviewableCollectionKeys({\n\t\tconfig: context.config,\n\t\tuser: data.user,\n\t\ttenantKey: context.request.tenantKey,\n\t});\n\tconst emptyOverview: PublishOperationOverview = {\n\t\ttotal: 0,\n\t\tpending: 0,\n\t\tassignedToMe: 0,\n\t\trequestedByMe: 0,\n\t\tscheduled: 0,\n\t\tapproved: 0,\n\t\trejected: 0,\n\t\tfailed: 0,\n\t};\n\tif (collectionKeys.length === 0) {\n\t\treturn { error: undefined, data: emptyOverview };\n\t}\n\n\tconst Operations = new DocumentPublishOperationsRepository(\n\t\tcontext.db.client,\n\t\tcontext.config.db,\n\t);\n\n\tconst overviewRes = await Operations.selectOverview({\n\t\tuserId: data.user.id,\n\t\tcollectionKeys,\n\t\tcollectionKey: data.query.filter?.collectionKey?.value?.toString(),\n\t\ttarget: data.query.filter?.target?.value?.toString(),\n\t\ttenantKey: context.request.tenantKey,\n\t});\n\tif (overviewRes.error) return overviewRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: {\n\t\t\ttotal: formatter.parseCount(overviewRes.data?.total),\n\t\t\tpending: formatter.parseCount(overviewRes.data?.pending),\n\t\t\tassignedToMe: formatter.parseCount(overviewRes.data?.assignedToMe),\n\t\t\trequestedByMe: formatter.parseCount(overviewRes.data?.requestedByMe),\n\t\t\tscheduled: formatter.parseCount(overviewRes.data?.scheduled),\n\t\t\tapproved: formatter.parseCount(overviewRes.data?.approved),\n\t\t\trejected: formatter.parseCount(overviewRes.data?.rejected),\n\t\t\tfailed: formatter.parseCount(overviewRes.data?.failed),\n\t\t},\n\t};\n};\n\nexport default getOverview;\n"],"mappings":"wLAQA,MAAM,EAQF,MAAO,EAAS,IAAS,CAC5B,IAAM,EAAiB,EAA4B,CAClD,OAAQ,EAAQ,OAChB,KAAM,EAAK,KACX,UAAW,EAAQ,QAAQ,SAC5B,CAAC,EACK,EAA0C,CAC/C,MAAO,EACP,QAAS,EACT,aAAc,EACd,cAAe,EACf,UAAW,EACX,SAAU,EACV,SAAU,EACV,OAAQ,CACT,EACA,GAAI,EAAe,SAAW,EAC7B,MAAO,CAAE,MAAO,IAAA,GAAW,KAAM,CAAc,EAQhD,IAAM,EAAc,MAAM,IALH,EACtB,EAAQ,GAAG,OACX,EAAQ,OAAO,EAGmB,CAAC,CAAC,eAAe,CACnD,OAAQ,EAAK,KAAK,GAClB,iBACA,cAAe,EAAK,MAAM,QAAQ,eAAe,OAAO,SAAS,EACjE,OAAQ,EAAK,MAAM,QAAQ,QAAQ,OAAO,SAAS,EACnD,UAAW,EAAQ,QAAQ,SAC5B,CAAC,EAGD,OAFI,EAAY,MAAc,EAEvB,CACN,MAAO,IAAA,GACP,KAAM,CACL,MAAOA,EAAU,WAAW,EAAY,MAAM,KAAK,EACnD,QAASA,EAAU,WAAW,EAAY,MAAM,OAAO,EACvD,aAAcA,EAAU,WAAW,EAAY,MAAM,YAAY,EACjE,cAAeA,EAAU,WAAW,EAAY,MAAM,aAAa,EACnE,UAAWA,EAAU,WAAW,EAAY,MAAM,SAAS,EAC3D,SAAUA,EAAU,WAAW,EAAY,MAAM,QAAQ,EACzD,SAAUA,EAAU,WAAW,EAAY,MAAM,QAAQ,EACzD,OAAQA,EAAU,WAAW,EAAY,MAAM,MAAM,CACtD,CACD,CACD"}