@usearazzo/runner 1.0.1-alpha.15 → 1.0.1-alpha.16

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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.1-alpha.16](https://github.com/usearazzo/arazzo-toolkit/compare/v1.0.1-alpha.15...v1.0.1-alpha.16) (2026-10-28)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **runner:** merge workflow default actions into steps by name ([#288](https://github.com/usearazzo/arazzo-toolkit/issues/288)) ([8ee0ba3](https://github.com/usearazzo/arazzo-toolkit/commit/8ee0ba387c475fef329c7d094e10ed3b2b0753c1)), closes [#117](https://github.com/usearazzo/arazzo-toolkit/issues/117)
11
+
6
12
  ## [1.0.1-alpha.15](https://github.com/usearazzo/arazzo-toolkit/compare/v1.0.1-alpha.14...v1.0.1-alpha.15) (2026-10-28)
7
13
 
8
14
  ### Bug Fixes
@@ -14959,23 +14959,32 @@ class ArazzoWorkflowNormalizer {
14959
14959
  }
14960
14960
 
14961
14961
  /**
14962
- * Inherits the workflow's `successActions` / `failureActions` into each step
14963
- * that declares no `onSuccess` / `onFailure` of its own.
14962
+ * Merges the workflow's `successActions` / `failureActions` into each step's
14963
+ * `onSuccess` / `onFailure`.
14964
14964
  *
14965
- * Per Arazzo 1.0.1 both lists are "applicable for all steps described under
14966
- * this workflow", and a step's own list **overrides** the corresponding
14967
- * workflow one — wholesale, with no per-action merge, which is where this
14968
- * differs from the parameters above. Success and failure fall back
14969
- * independently: a step may override only its `onFailure` and still inherit
14970
- * the workflow's `successActions`.
14965
+ * Per Arazzo both lists are "applicable for all steps described under this
14966
+ * workflow" and "can be overridden at the step level but cannot be removed
14967
+ * there". The required action `name` is what makes both halves hold: a
14968
+ * step's action replaces the workflow action of the same `name`, and every
14969
+ * workflow action the step does not name still applies. The effective list is
14970
+ * the step's own actions in order, then the workflow actions it did not
14971
+ * override, in theirs — order matters, as selection is first-match-wins on
14972
+ * `criteria`. So a step with no list, or with `[]`, gets every workflow
14973
+ * action. The step's own list is kept exactly as written, even a duplicate
14974
+ * `name` in it, which the validator reports: inheritance only adds to it.
14975
+ * Within the workflow's list the first action with a given `name` wins.
14976
+ * Success and failure merge independently.
14971
14977
  *
14972
- * Presence is tested with `hasKey`, not truthiness: a step declaring an empty
14973
- * list (`onSuccess: []`) has *overridden* the default with an empty set of
14974
- * actions, not asked for one — it is skipped, as is a step whose `onSuccess`
14975
- * is present but not a list, for the same reason the parameters pass leaves a
14976
- * malformed list alone. Testing the key is also what makes the pass
14977
- * idempotent: after the first run the step has it, so a workflow reached again
14978
- * through the registry cache is skipped.
14978
+ * An entry without a readable `name` (an unresolved Reusable Object, a
14979
+ * scalar someone put in the list) neither overrides nor is overridden: it
14980
+ * keeps its place, and is added only if that same element is not already in
14981
+ * the list. A step whose `onSuccess` is present but not a list is left
14982
+ * alone, for the same reason the parameters pass leaves a malformed list
14983
+ * alone — overwriting it would erase what makes the document invalid.
14984
+ *
14985
+ * The pass is idempotent, so a workflow reached again through the registry
14986
+ * cache is merged into once: on a second pass every inherited action is
14987
+ * already in the step's list, under its own `name` or as the same element.
14979
14988
  *
14980
14989
  * Unlike parameters there is no step-kind filter — an action names a
14981
14990
  * transition within the workflow, which is as meaningful for a step targeting
@@ -15002,13 +15011,34 @@ class ArazzoWorkflowNormalizer {
15002
15011
  if (!inheritSuccess && !inheritFailure) return;
15003
15012
  for (const step of workflow.steps) {
15004
15013
  if (!(0,_speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_1__.isStepElement)(step)) continue;
15005
- if (inheritSuccess && !step.hasKey('onSuccess')) {
15006
- step.onSuccess = new _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_3__["default"]([...successActions]);
15014
+ if (inheritSuccess && (!step.hasKey('onSuccess') || (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_6__.isArrayElement)(step.onSuccess))) {
15015
+ step.onSuccess = new _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_3__["default"](ArazzoWorkflowNormalizer.#mergeActions([...(step.onSuccess ?? [])], [...successActions]));
15016
+ }
15017
+ if (inheritFailure && (!step.hasKey('onFailure') || (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_6__.isArrayElement)(step.onFailure))) {
15018
+ step.onFailure = new _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_2__["default"](ArazzoWorkflowNormalizer.#mergeActions([...(step.onFailure ?? [])], [...failureActions]));
15007
15019
  }
15008
- if (inheritFailure && !step.hasKey('onFailure')) {
15009
- step.onFailure = new _speclynx_apidom_ns_arazzo_1__WEBPACK_IMPORTED_MODULE_2__["default"]([...failureActions]);
15020
+ }
15021
+ }
15022
+
15023
+ /**
15024
+ * The step's actions as written, followed by each workflow action whose
15025
+ * `name` neither the step nor an earlier workflow action carries; a nameless
15026
+ * workflow entry is added unless that same element is already present.
15027
+ */
15028
+ static #mergeActions(own, inherited) {
15029
+ const nameOf = action => (0,_speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_6__.isObjectElement)(action) ? (0,_speclynx_apidom_core__WEBPACK_IMPORTED_MODULE_5__["default"])(action.get('name')) : undefined;
15030
+ const names = new Set(own.map(nameOf));
15031
+ const merged = [...own];
15032
+ for (const action of inherited) {
15033
+ const name = nameOf(action);
15034
+ if (typeof name !== 'string') {
15035
+ if (!merged.includes(action)) merged.push(action);
15036
+ } else if (!names.has(name)) {
15037
+ names.add(name);
15038
+ merged.push(action);
15010
15039
  }
15011
15040
  }
15041
+ return merged;
15012
15042
  }
15013
15043
  }
15014
15044
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ArazzoWorkflowNormalizer);