/** * Function type that extracts a partition key from data. * @template D The data type to process */ export type PartitionHandler = (data: D) => string | Promise /** * Handler options that extend fetch configuration with optional partitioning support. * @template F The fetch configuration type (e.g., EthFetchConfig, MoveFetchConfig) * @template D The data type that will be processed (e.g., Event, Transaction, Block) */ export type HandlerOptions = Partial & { /** * Optional partition key for data partitioning. * Can be a static string or a function that computes the key from the data. */ partitionKey?: string | PartitionHandler /** * Optional whether to skip decoding * By default the processor will do decoding (e.g. replace string number to bigint, byte array to base64, etc), * however in some case you might skip the decoding (meaning no data_decoded field) and only access the raw data field */ skipDecoding?: boolean } /** * Merge two handler options, with the second options taking precedence over the first. * @param options1 First handler options * @param options2 Second handler options (takes precedence) * @returns Merged handler options */ export function mergeHandlerOptions( options1?: HandlerOptions, options2?: HandlerOptions ): HandlerOptions | undefined { if (!options1 && !options2) return undefined if (!options1) return options2 if (!options2) return options1 return { ...options1, ...options2, // For partitionKey, the second option takes precedence partitionKey: options2.partitionKey ?? options1.partitionKey } }