createTransformer
Construct a whole-pipe transformer.transform: (required)(data: I, ctx: BatchContext) => O | Promise<O>. Called once per batch.start: (optional)(ctx: StartContext) => void | Promise<void>. Called once when the pipe starts. Use this to load state, warm up caches, or query the portal for historical data before the main stream begins.stop: (optional)(ctx: StopContext) => void | Promise<void>. Called once when the pipe stops.rollback: (optional)(cursor: BlockCursor, ctx: HookContext) => void | Promise<void>. Called after the source detects a chain reorg and resolves the safe cursor.cursoridentifies the last safe slot; undo any internal state above it. See Fork handling.profiler: (optional){ name: string; hidden?: boolean }. Overrides the transformer’s node name in the profiler tree.
Context variables
Each callback receives a context object. The fields differ by callback.transform(data, ctx: BatchContext)
ctx is the full per-batch context. Fields:
ctx.stream: StreamInfo
ctx.batch: BatchMetadata
start(ctx: StartContext)
Fired once, before any batch. Use to warm up caches or run one-off queries.
rollback(cursor, ctx: HookContext)
Fired before the next batch whenever a reorg is detected, after the safe cursor has been resolved. cursor is the last slot to keep; drop state produced for anything after it.
stop(ctx: StopContext)
Fired once when the pipe stops.
The OutputOf type helper
OutputOf<T> infers the output type of a query-transform combo, a transformer, a transform function, or a record of named outputs. Use it to type downstream transform functions without spelling out intermediate types:
outputs record: OutputOf<typeof outputs> yields { name1: ..., name2: ... }.