interface TransformationHookContext

Shared context object passed to every hook callback.

Both beforeTransform and onError hooks receive exactly this shape. The afterTransform hook extends it with inputCount, outputCount, and durationMs (see AfterTransformHook).

Examples

Example 1

manager.onBeforeTransform((ctx) => {
  console.log(`About to run ${ctx.name} on ${ctx.ruleCount} rules`);
});

Properties

name: string

Name of the transformation (same string as the TransformationType enum value)

Transformation type enum value — use this for type-safe comparisons

ruleCount: number

Number of rules at the time the hook is called.

  • In beforeTransform hooks this equals the input rule count for the current transformation.
  • In onError hooks this equals the input count at the point of failure.
  • In afterTransform hooks this equals the output count; use inputCount / outputCount on the extended context instead for clarity.
timestamp: number

Unix millisecond timestamp captured immediately before hook execution

optional
durationMs: number

Duration in milliseconds — present only on afterTransform extended context

optional
metadata: Record<string, unknown>

Optional free-form metadata that hook producers can attach for consumers

Usage

import { type TransformationHookContext } from ".";