import { TypedDocumentNode } from "@graphql-typed-document-node/core"; import { DateTimeFormatType } from "@trackunit/shared-utils"; type ValuePathType = { [key: string]: string; }; export interface BaseExportable { /** * The accessor to use for the value or array of accessors to use for the value. * If not provided, the value will not be accessed. */ accessor: string | Array; /** * The translation map to use for the value. * If not provided, the value will not be translated. */ translationMap?: ValuePathType | null; /** * The transformer to use for the value. * If not provided, the value will not be transformed. */ transformer?: { type: "customFields"; id: string; } | { type: "date"; format: DateTimeFormatType; } | { type: "number"; method: "floor" | "ceil" | "round"; decimalPlaces?: number; } | { type: "math"; operation: "add" | "subtract" | "multiply" | "divide" | "modulo" | "power"; decimalPlaces?: number; /** * Optional constant value to use as the second operand in the math operation. * Use this when the second value is a client-side constant not available in the GraphQL response. * If not provided, accessor must be an array with 2 elements to access both operands from data. * Example: To calculate price (quantity × unitPrice) where unitPrice is client-side: * { accessor: "quantity", transformer: { type: "math", operation: "multiply", constantValue: 3.50 } } */ constantValue?: number; }; /** * The prefix to add to the value only if the value is not empty */ prefix?: string; /** * The postfix to add to the value only if the value is not empty */ postfix?: string; } export type ExportableColumn = BaseExportable & { id: string; header: string; }; export interface ExportDataProps { document: TypedDocumentNode; variables: TVariables; columns: Array; name: string; headers?: Record; maxItems?: number; } export interface ExportDataRuntimeApi { exportData: (props: ExportDataProps) => Promise; } export {};