xray-core
    Preparing search index...

    Class StepBuilder

    Builder class for creating X-Ray steps with a fluent API.

    const step = new StepBuilder('apply_filters', 'filter')
    .input({ candidatesCount: 50 })
    .addFilter('price_range', '0.5x-2x of reference', { min: 15, max: 60 })
    .evaluate('candidate-1', candidate, [
    { criterion: 'price_range', passed: true, detail: '$44.99 within range' }
    ])
    .output({ passed: 12, failed: 38 })
    .reasoning('Applied filters to narrow candidates')
    .complete();
    Index

    Constructors

    • Creates a new StepBuilder.

      Parameters

      • name: string

        Step name (e.g., 'apply_filters', 'keyword_generation')

      • type: XRayStepType = 'custom'

        Step type for categorization (default: 'custom')

      • OptionalonComplete: (step: XRayStep) => void

        Callback invoked when step is completed

      Returns StepBuilder

    Methods

    • Adds a filter definition to this step.

      Parameters

      • name: string

        Filter identifier (e.g., 'price_range', 'min_rating')

      • rule: string

        Human-readable rule description (e.g., '0.5x-2x of reference')

      • config: Record<string, unknown> = {}

        Filter configuration parameters

      Returns this

      this for method chaining

    • Evaluates a candidate against criteria and records the result.

      Parameters

      • candidateId: string

        Unique identifier for the candidate

      • candidate: Record<string, unknown>

        The candidate data being evaluated

      • results: XRayCriterionResult[]

        Array of criterion results with pass/fail details

      • Optionalsummary: string

        Optional summary override (auto-generated if not provided)

      Returns this

      this for method chaining

    • Sets multiple evaluations at once, replacing any existing evaluations.

      Parameters

      Returns this

      this for method chaining

    • Marks the step as failed with an error message.

      Parameters

      • error: string

        Error message describing what went wrong

      Returns XRayStep

      The final step data

    • Sets multiple filters at once, replacing any existing filters.

      Parameters

      • filterList: XRayFilter[]

        Array of filter definitions

      Returns this

      this for method chaining

    • Sets the input data for this step.

      Parameters

      • data: Record<string, unknown>

        Input data object (e.g., candidates, parameters)

      Returns this

      this for method chaining

    • Sets the output data for this step.

      Parameters

      • data: Record<string, unknown>

        Output data object (e.g., results, selected items)

      Returns this

      this for method chaining

    • Sets the reasoning/explanation for this step's decision.

      Parameters

      • explanation: string

        Human-readable explanation of why this decision was made

      Returns this

      this for method chaining

    • Marks the step as skipped.

      Parameters

      • Optionalreason: string

        Optional reason for skipping

      Returns XRayStep

      The final step data