{"version":3,"file":"get-single.mjs","names":["getCollectionInstance","documentWorkflowsFormatter"],"sources":["../../../src/services/document-workflows/get-single.ts"],"sourcesContent":["import type { DocumentWorkflow } from \"@lucidcms/types\";\nimport { documentWorkflowsFormatter } from \"../../libs/formatters/index.js\";\nimport { DocumentWorkflowsRepository } from \"../../libs/repositories/index.js\";\nimport { getBaseUrl } from \"../../utils/helpers/index.js\";\nimport type { ServiceFn } from \"../../utils/services/types.js\";\nimport getCollectionInstance from \"../collections/get-single-instance.js\";\nimport { getWorkflowConfig } from \"./helpers/index.js\";\n\nconst getSingle: ServiceFn<\n\t[\n\t\t{\n\t\t\tcollectionKey: string;\n\t\t\tdocumentId: number;\n\t\t},\n\t],\n\tDocumentWorkflow | null\n> = async (context, data) => {\n\tconst collectionRes = getCollectionInstance(context, {\n\t\tkey: data.collectionKey,\n\t});\n\tif (collectionRes.error) return collectionRes;\n\n\tif (!getWorkflowConfig(collectionRes.data)) {\n\t\treturn {\n\t\t\terror: undefined,\n\t\t\tdata: null,\n\t\t};\n\t}\n\n\tconst Workflows = new DocumentWorkflowsRepository(\n\t\tcontext.db.client,\n\t\tcontext.config.db,\n\t);\n\n\tconst workflowRes = await Workflows.selectSingleDetailed({\n\t\tcollectionKey: data.collectionKey,\n\t\tdocumentId: data.documentId,\n\t});\n\tif (workflowRes.error) return workflowRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: documentWorkflowsFormatter.formatSingle({\n\t\t\tcollection: collectionRes.data,\n\t\t\tworkflow: workflowRes.data,\n\t\t\thost: getBaseUrl(context),\n\t\t}),\n\t};\n};\n\nexport default getSingle;\n"],"mappings":"4RAQA,MAAM,EAQF,MAAO,EAAS,IAAS,CAC5B,IAAM,EAAgBA,EAAsB,EAAS,CACpD,IAAK,EAAK,aACX,CAAC,EACD,GAAI,EAAc,MAAO,OAAO,EAEhC,GAAI,CAAC,EAAkB,EAAc,IAAI,EACxC,MAAO,CACN,MAAO,IAAA,GACP,KAAM,IACP,EAQD,IAAM,EAAc,MAAM,IALJ,EACrB,EAAQ,GAAG,OACX,EAAQ,OAAO,EAGkB,CAAC,CAAC,qBAAqB,CACxD,cAAe,EAAK,cACpB,WAAY,EAAK,UAClB,CAAC,EAGD,OAFI,EAAY,MAAc,EAEvB,CACN,MAAO,IAAA,GACP,KAAMC,EAA2B,aAAa,CAC7C,WAAY,EAAc,KAC1B,SAAU,EAAY,KACtB,KAAM,EAAW,CAAO,CACzB,CAAC,CACF,CACD"}