{"version":3,"file":"document-publish-operations.mjs","names":["mediaFormatter","formatter"],"sources":["../../../src/libs/formatters/document-publish-operations.ts"],"sourcesContent":["import type { PublishOperation } from \"../../types/response.js\";\nimport type { PublishOperationDetailedQueryResponse } from \"../repositories/document-publish-operations.js\";\nimport formatter, { mediaFormatter } from \"./index.js\";\nimport type { MediaPosterPropsT } from \"./media.js\";\n\nconst formatUser = (params: {\n\tid: number | null | undefined;\n\temail?: string | null;\n\tusername?: string | null;\n\tfirstName?: string | null;\n\tlastName?: string | null;\n\tprofilePicture?: MediaPosterPropsT[];\n\thost: string;\n}): PublishOperation[\"requestedBy\"] => {\n\tif (!params.id) return null;\n\treturn {\n\t\tid: params.id,\n\t\temail: params.email ?? null,\n\t\tusername: params.username ?? null,\n\t\tfirstName: params.firstName ?? null,\n\t\tlastName: params.lastName ?? null,\n\t\tprofilePicture: mediaFormatter.formatProfilePicture({\n\t\t\tposter: params.profilePicture?.[0],\n\t\t\thost: params.host,\n\t\t}),\n\t};\n};\n\ntype FormatSingleProps = {\n\toperation: PublishOperationDetailedQueryResponse;\n\tdocumentLabel?: string | null;\n\tlatestContentId?: string | null;\n\tpermissions?: PublishOperation[\"permissions\"];\n\thost: string;\n};\n\nconst formatSingle = (props: FormatSingleProps): PublishOperation => ({\n\tid: props.operation.id,\n\tcollectionKey: props.operation.collection_key,\n\tdocumentId: props.operation.document_id,\n\tdocumentLabel: props.documentLabel ?? null,\n\ttarget: props.operation.target,\n\toperationType: props.operation.operation_type,\n\tstatus: props.operation.status,\n\texecutionStatus: props.operation.execution_status,\n\tsourceVersionId: props.operation.source_version_id,\n\tsourceContentId: props.operation.source_content_id,\n\tsnapshotVersionId: props.operation.snapshot_version_id,\n\tisOutdated:\n\t\tprops.latestContentId !== undefined &&\n\t\tprops.latestContentId !== null &&\n\t\tprops.latestContentId !== props.operation.source_content_id,\n\trequestedBy: formatUser({\n\t\tid: props.operation.requested_by,\n\t\temail: props.operation.requested_by_email,\n\t\tusername: props.operation.requested_by_username,\n\t\tfirstName: props.operation.requested_by_first_name,\n\t\tlastName: props.operation.requested_by_last_name,\n\t\tprofilePicture: props.operation.requested_by_profile_picture,\n\t\thost: props.host,\n\t}),\n\trequestComment: props.operation.request_comment,\n\tdecidedBy: formatUser({\n\t\tid: props.operation.decided_by,\n\t\temail: props.operation.decided_by_email,\n\t\tusername: props.operation.decided_by_username,\n\t\tfirstName: props.operation.decided_by_first_name,\n\t\tlastName: props.operation.decided_by_last_name,\n\t\tprofilePicture: props.operation.decided_by_profile_picture,\n\t\thost: props.host,\n\t}),\n\tdecisionComment: props.operation.decision_comment,\n\tdecidedAt: formatter.formatDate(props.operation.decided_at),\n\tscheduledAt: formatter.formatDate(props.operation.scheduled_at),\n\tscheduledTimezone: props.operation.scheduled_timezone,\n\texecutedAt: formatter.formatDate(props.operation.executed_at),\n\tfailedAt: formatter.formatDate(props.operation.failed_at),\n\texecutionErrorMessage: props.operation.execution_error_message,\n\texecutionErrorData: props.operation.execution_error_data,\n\tscheduledJobId: props.operation.scheduled_job_id,\n\tcreatedAt: formatter.formatDate(props.operation.created_at),\n\tupdatedAt: formatter.formatDate(props.operation.updated_at),\n\tpermissions: props.permissions ?? {\n\t\treview: false,\n\t\tcancel: false,\n\t\treschedule: false,\n\t\tretry: false,\n\t\tupdateReviewers: false,\n\t},\n\tassignees: (props.operation.assignees ?? []).map((assignee) => ({\n\t\tid: assignee.id,\n\t\tuser: {\n\t\t\tid: assignee.user_id,\n\t\t\temail: assignee.email ?? null,\n\t\t\tusername: assignee.username ?? null,\n\t\t\tfirstName: assignee.first_name ?? null,\n\t\t\tlastName: assignee.last_name ?? null,\n\t\t\tprofilePicture: mediaFormatter.formatProfilePicture({\n\t\t\t\tposter: assignee.profile_picture?.[0],\n\t\t\t\thost: props.host,\n\t\t\t}),\n\t\t},\n\t\tassignedBy: assignee.assigned_by,\n\t\tassignedAt: formatter.formatDate(assignee.assigned_at),\n\t})),\n\tevents: (props.operation.events ?? []).map((event) => ({\n\t\tid: event.id,\n\t\ttype: event.event_type,\n\t\tuserId: event.user_id,\n\t\tcomment: event.comment,\n\t\tmetadata: event.metadata,\n\t\tcreatedAt: formatter.formatDate(event.created_at),\n\t})),\n});\n\nconst formatMultiple = (props: {\n\toperations: FormatSingleProps[];\n}): PublishOperation[] =>\n\tprops.operations.map((operation) => formatSingle(operation));\n\nexport default {\n\tformatMultiple,\n\tformatSingle,\n};\n"],"mappings":"sDAKA,MAAM,EAAc,GASd,EAAO,GACL,CACN,GAAI,EAAO,GACX,MAAO,EAAO,OAAS,KACvB,SAAU,EAAO,UAAY,KAC7B,UAAW,EAAO,WAAa,KAC/B,SAAU,EAAO,UAAY,KAC7B,eAAgBA,EAAe,qBAAqB,CACnD,OAAQ,EAAO,iBAAiB,GAChC,KAAM,EAAO,IACd,CAAC,CACF,EAXuB,KAsBlB,EAAgB,IAAgD,CACrE,GAAI,EAAM,UAAU,GACpB,cAAe,EAAM,UAAU,eAC/B,WAAY,EAAM,UAAU,YAC5B,cAAe,EAAM,eAAiB,KACtC,OAAQ,EAAM,UAAU,OACxB,cAAe,EAAM,UAAU,eAC/B,OAAQ,EAAM,UAAU,OACxB,gBAAiB,EAAM,UAAU,iBACjC,gBAAiB,EAAM,UAAU,kBACjC,gBAAiB,EAAM,UAAU,kBACjC,kBAAmB,EAAM,UAAU,oBACnC,WACC,EAAM,kBAAoB,IAAA,IAC1B,EAAM,kBAAoB,MAC1B,EAAM,kBAAoB,EAAM,UAAU,kBAC3C,YAAa,EAAW,CACvB,GAAI,EAAM,UAAU,aACpB,MAAO,EAAM,UAAU,mBACvB,SAAU,EAAM,UAAU,sBAC1B,UAAW,EAAM,UAAU,wBAC3B,SAAU,EAAM,UAAU,uBAC1B,eAAgB,EAAM,UAAU,6BAChC,KAAM,EAAM,IACb,CAAC,EACD,eAAgB,EAAM,UAAU,gBAChC,UAAW,EAAW,CACrB,GAAI,EAAM,UAAU,WACpB,MAAO,EAAM,UAAU,iBACvB,SAAU,EAAM,UAAU,o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