import type { $ } from "hkts/src"; import type { Collections } from "./collections"; import type { Process } from "./process"; export type Configure = (options: Options) => , O extends Output>(inputs: Inputs) => Process>; /** * Configure a batch process to query and/or mutate resources. * * Batch processes take structured inputs, split those up and extract a list * of entries that can be passed to some process. Given the results of that * process, each result is then converted back to some output form and arranged * into the same given structure as outputs. * * This abstraction makes it easier to build bulk iteractions with @truffle/db, * rather than, say, submitting multiple separate add mutations. * * For instance, Truffle artifacts each contain two bytecodes - to minimize the * number of `bytecodesAdd` queries, one might want to convert each input * artifact to a flat list of bytecodes, execute a single mutation request to * @truffle/db, and then automatically pair the resulting bytecode IDs with the * respective artifact bytecodes. * * The process is roughly as follows: * * * ,--------. iterate() ,----------. extract() ,---------. * | Inputs | --> | Input... | --> | Entry[] | * `--------' `----------' `---------' * * | | * | initialize() | process() * V V * * ,---------. merge() ,----------. convert() ,----------. * | Outputs | <-- | Output[] | <-- | Result[] | * `---------' `----------' `----------' * * */ export declare const configure: Configure; /** * Describes a batch process for querying and/or mutating resources */ export type Options = Input, O extends Output = Output> = { /** * Describes how to traverse the particular Inputs structure to produce * an Iterable of each Input along with a breadcrumb to describe how to * place that input in the parent structure. */ iterate(options: { inputs: Inputs; }): Iterable<{ input: I; breadcrumb: Breadcrumb; }>; /** */ find(options: { inputs: Inputs; breadcrumb: Breadcrumb; }): I; /** */ extract(options: { input: I; inputs: Inputs; breadcrumb: Breadcrumb; }): Entry; /** */ process(options: { entries: Entries; inputs: Inputs; }): Process>; /** */ initialize(options: { inputs: Inputs; }): Outputs; /** */ convert(options: { result: Result; inputs: Inputs; input: I; }): O; /** */ merge(options: { outputs: Outputs; breadcrumb: Breadcrumb; output: O; }): Outputs; }; export type Batch = { structure: any; breadcrumb: any; input: any; entry?: any; result?: any; output: any; }; type Structure = B["structure"]; type Breadcrumb = B["breadcrumb"]; export type Input = B["input"]; export type Inputs> = $, [I]>; type Entry = B["entry"]; type Entries = Entry[]; export type Output = B["output"]; export type Outputs> = $, [ O ]>; type Result = B["result"]; type Results = Result[]; export {};