Kaizen
Browse modulesFormsforms/sharedFunctions

Function: getStepCountToLastStep()

function getStepCountToLastStep(__namedParameters: WalkProps & {
  getNextStepFromKey?: (fromKey: string) => string | null;
}): number;

Defined in: shared/forms/dag.ts:243

Step count from formStepKey to a terminal step (no outgoing).

Caller supplies an optional getNextStepFromKey resolver that decides the next edge given known draft data + condition evaluation. When provided, the walk follows the resolver edge-for-edge while it returns a concrete next-step key — yielding an honest count that incorporates previous answers (especially relevant after a back-nav, where every upstream answer is known and the path is deterministic).

Where the resolver returns null (no transition fires given current data — typically because a condition depends on a field the user hasn't filled yet) the function falls back to a condition-ignoring BFS from that step onward, so the denominator degrades to a best- effort estimate rather than silently treating the step as terminal.

Without a resolver, behavior is the pure-topology BFS shortest-path estimate — same as before.

Returns Infinity if no terminal is reachable (publish validator should have rejected such schemas).

Parameters

ParameterType
__namedParametersWalkProps & { getNextStepFromKey?: (fromKey: string) => string | null; }

Returns

number

On this page