@usearazzo/runner 1.0.1-alpha.20 → 1.0.1-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/runner.d.ts CHANGED
@@ -369,11 +369,12 @@ export declare interface ArazzoWorkflowLocator {
369
369
  * The `type` declared on a source description is not trusted (it may be
370
370
  * absent or wrong); a source is classified by what it actually parses to,
371
371
  * the same convention the OpenAPI operation locator follows. Source
372
- * documents are acquired from the registry on demand. Whether the resolved
373
- * document *defines* the workflow is deliberately left to the caller, which
374
- * owns the timing of that check (eager for a `dependsOn` list validated
375
- * before any prerequisite runs, lazy for a sub-workflow step resolved per
376
- * attempt).
372
+ * documents are acquired from the registry on demand. A reference to a
373
+ * workflow the resolved document does not define is rejected here, so every
374
+ * returned locator names an existing workflow; a caller controls when that
375
+ * check happens by when it normalizes (eagerly for a `dependsOn` list
376
+ * validated before any prerequisite runs, lazily for a sub-workflow step
377
+ * resolved on its first attempt).
377
378
  * @public
378
379
  */
379
380
  export declare class ArazzoWorkflowLocatorNormalizer extends SourceDescriptionsLocatorNormalizer {
@@ -382,7 +383,9 @@ export declare class ArazzoWorkflowLocatorNormalizer extends SourceDescriptionsL
382
383
  * Resolves a reference — a plain workflowId or a
383
384
  * `$sourceDescriptions.{name}.{workflowId}` expression, as written — to the
384
385
  * canonical locator: the Arazzo document that owns the target workflow,
385
- * and the bare id within it.
386
+ * and the bare id within it. Rejects a workflow that document does not
387
+ * define as `workflow-not-found`, attributed to the referencing context
388
+ * like every other error raised here.
386
389
  */
387
390
  normalize(reference: string, document: ArazzoDocument, context: WorkflowReferenceContext): Promise<ArazzoWorkflowLocator>;
388
391
  }
@@ -534,7 +537,45 @@ export declare class CriterionEvaluationError extends CriterionError {
534
537
  }
535
538
 
536
539
  /**
537
- * Evaluates an Arazzo Criterion Object to a boolean.
540
+ * The outcome of one criterion a step evaluated: one of its `successCriteria`,
541
+ * or one of the `criteria` of an action it considered.
542
+ * @public
543
+ */
544
+ export declare interface CriterionEvaluationRecord {
545
+ /**
546
+ * The criterion's `condition`, as written.
547
+ */
548
+ readonly condition: string;
549
+ /**
550
+ * Whether the condition is met.
551
+ */
552
+ readonly met: boolean;
553
+ /**
554
+ * The `name` of the action declaring the criterion — present only on an
555
+ * action criterion.
556
+ */
557
+ readonly actionName?: string;
558
+ /**
559
+ * Why the condition could not be evaluated — present only then, with `met`
560
+ * `false`.
561
+ */
562
+ readonly diagnostic?: {
563
+ /**
564
+ * Machine-readable: the `reason` of the error that failed the criterion, a
565
+ * `CriterionErrorReason` value or `'unavailable-expression'` for an
566
+ * HTTP-exchange expression in a step that calls a workflow.
567
+ */
568
+ readonly code?: CriterionErrorReason | 'unavailable-expression';
569
+ /**
570
+ * Human-readable: names the condition or expression and, for a syntax
571
+ * error, what is wrong with it; never request or response data.
572
+ */
573
+ readonly message: string;
574
+ };
575
+ }
576
+
577
+ /**
578
+ * Evaluates an Arazzo Criterion Object to a {@link CriterionOutcome}.
538
579
  *
539
580
  * Dispatches on the criterion's `type` (defaulting to `simple` when omitted):
540
581
  * - `simple` — evaluates the condition directly, resolving the runtime
@@ -554,12 +595,13 @@ export declare class CriterionEvaluationError extends CriterionError {
554
595
  * the 1.1.0 rule to every document, which accepts more but never evaluates a
555
596
  * query under the wrong dialect.
556
597
  *
557
- * A condition that cannot be evaluated fails the criterion (`false`), as
598
+ * A condition that cannot be evaluated fails the criterion (`met: false`), as
558
599
  * Arazzo 1.1.0 requires: a syntax error in the condition, a context the
559
600
  * condition cannot apply to (non-XML data for `xpath`), or an XPath evaluation
560
601
  * error. The type-specific evaluators report these as a
561
- * {@link CriterionEvaluationError}, which this facade absorbs; any other error
562
- * they raise propagates. A criterion that is malformed as written still throws: a
602
+ * {@link CriterionEvaluationError}, which this facade returns as the
603
+ * outcome's `error` so the caller can report it; any other error they raise
604
+ * propagates. A criterion that is malformed as written still throws: a
563
605
  * missing `condition`, an unknown or unreadable `type`, an unsupported
564
606
  * expression `version`, or a `context` that is missing or not a runtime
565
607
  * expression.
@@ -574,13 +616,14 @@ export declare class CriterionEvaluator {
574
616
  #private;
575
617
  constructor(options?: CriterionEvaluatorOptions);
576
618
  /**
577
- * Evaluates a criterion element, returning whether the condition is met.
619
+ * Evaluates a criterion element, returning whether the condition is met and,
620
+ * when it cannot be evaluated, why.
578
621
  *
579
622
  * `resolve` turns a runtime expression into a value: for `simple` it resolves
580
623
  * the expressions embedded in the condition; for the other types it resolves
581
624
  * the criterion's `context` expression that the condition is applied to.
582
625
  */
583
- evaluate(criterion: CriterionElement, resolve: CriterionContextResolver): boolean;
626
+ evaluate(criterion: CriterionElement, resolve: CriterionContextResolver): CriterionOutcome;
584
627
  }
585
628
 
586
629
  /**
@@ -611,14 +654,32 @@ export declare interface CriterionEvaluatorOptions {
611
654
  }
612
655
 
613
656
  /**
614
- * Determines whether a single criterion is met.
657
+ * The outcome of evaluating one criterion.
658
+ * @public
659
+ */
660
+ export declare interface CriterionOutcome {
661
+ /**
662
+ * Whether the condition is met. `false` when it evaluates to false or cannot
663
+ * be evaluated; only in the latter case is {@link CriterionOutcome.error}
664
+ * present, saying why.
665
+ */
666
+ readonly met: boolean;
667
+ /**
668
+ * Why the condition could not be evaluated: present only when it was not.
669
+ */
670
+ readonly error?: CriterionEvaluationError;
671
+ }
672
+
673
+ /**
674
+ * Determines whether a single criterion of an action is met. Receives the
675
+ * action declaring the criterion, so a caller can attribute the outcome to it.
615
676
  *
616
677
  * Bridged to a criterion evaluator
617
- * (`(criterion) => criterionEvaluator.evaluate(criterion, resolve)`); an
678
+ * (`(criterion) => criterionEvaluator.evaluate(criterion, resolve).met`); an
618
679
  * unresolvable/failing criterion is `false`, not an error.
619
680
  * @public
620
681
  */
621
- export declare type CriterionPredicate = (criterion: CriterionElement) => boolean;
682
+ export declare type CriterionPredicate = (criterion: CriterionElement, action: SelectedAction) => boolean;
622
683
 
623
684
  /** @public */
624
685
  export declare class DocumentLoadError extends ArazzoRunnerError {
@@ -1929,6 +1990,16 @@ export declare interface StepExecutionResult {
1929
1990
  * matching action. Empty when none matched.
1930
1991
  */
1931
1992
  readonly matchedActions: readonly SelectedAction[];
1993
+ /**
1994
+ * The outcome of each of the step's `successCriteria`, in list order.
1995
+ */
1996
+ readonly successCriteria: readonly CriterionEvaluationRecord[];
1997
+ /**
1998
+ * The outcome of each criterion of the actions the step considered — its
1999
+ * `onSuccess` actions when it succeeded, its `onFailure` actions otherwise —
2000
+ * in list order.
2001
+ */
2002
+ readonly actionCriteria: readonly CriterionEvaluationRecord[];
1932
2003
  }
1933
2004
 
1934
2005
  /**
@@ -1996,19 +2067,23 @@ export declare class StepExecutor {
1996
2067
  */
1997
2068
  assertSuccessCriteria(step: StepElement, workflowId?: string): void;
1998
2069
  /**
1999
- * Evaluates the step's `successCriteria`; all criteria must pass. A step with
2000
- * no criteria succeeds on a received response. An unreadable
2001
- * `successCriteria` throws, see {@link StepExecutor.assertSuccessCriteria}.
2070
+ * Evaluates the step's `successCriteria`, returning one record per criterion
2071
+ * in list order; the step succeeds when every record is met. Every criterion
2072
+ * is evaluated, so the records explain each unmet one, not only the first. A
2073
+ * step with no criteria returns no records and succeeds on a received
2074
+ * response. An unreadable `successCriteria` throws, see
2075
+ * {@link StepExecutor.assertSuccessCriteria}.
2002
2076
  *
2003
2077
  * Public for the same reason as {@link StepExecutor.selectActions}: a step
2004
2078
  * targeting a `workflowId` is run by the workflow executor and never reaches
2005
2079
  * {@link StepExecutor.execute}, but its criteria are still the author's
2006
2080
  * assertion about the step and must be evaluated somewhere.
2007
2081
  */
2008
- evaluateCriteria(step: StepElement, context: RuntimeExpressionContext): boolean;
2082
+ evaluateCriteria(step: StepElement, context: RuntimeExpressionContext): CriterionEvaluationRecord[];
2009
2083
  /**
2010
2084
  * Selects every matching `onSuccess` / `onFailure` action for the outcome, in
2011
- * list order, gating each action's criteria against the context.
2085
+ * list order, gating each action's criteria against the context, and records
2086
+ * the outcome of every action criterion evaluated.
2012
2087
  *
2013
2088
  * The step's own list is the whole story here: a step that declares none of
2014
2089
  * its own already carries the workflow-level defaults, inherited by
@@ -2026,7 +2101,7 @@ export declare class StepExecutor {
2026
2101
  * {@link StepExecutor.execute}. Both callers reach the criteria evaluator and
2027
2102
  * the expression context through this one method rather than wiring their own.
2028
2103
  */
2029
- selectActions(step: StepElement, successful: boolean, context: RuntimeExpressionContext): SelectedAction[];
2104
+ selectActions(step: StepElement, successful: boolean, context: RuntimeExpressionContext): Pick<StepExecutionResult, 'matchedActions' | 'actionCriteria'>;
2030
2105
  }
2031
2106
 
2032
2107
  /**
@@ -2104,6 +2179,17 @@ export declare interface StepRunRecord {
2104
2179
  * fractional and is unaffected by system clock changes.
2105
2180
  */
2106
2181
  readonly durationMs: number;
2182
+ /**
2183
+ * The outcome of each of the step's `successCriteria` in its last attempt, in
2184
+ * list order — why the step succeeded or failed.
2185
+ */
2186
+ readonly successCriteria: readonly CriterionEvaluationRecord[];
2187
+ /**
2188
+ * The outcome of each criterion of the actions the last attempt considered —
2189
+ * its `onSuccess` actions when it succeeded, its `onFailure` actions
2190
+ * otherwise — in list order: why an action matched or did not.
2191
+ */
2192
+ readonly actionCriteria: readonly CriterionEvaluationRecord[];
2107
2193
  /**
2108
2194
  * The sub-workflow runs this step produced, in attempt order — present only on
2109
2195
  * a step targeting a `workflowId`.