@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usearazzo/runner",
|
|
3
|
-
"version": "1.0.1-alpha.
|
|
3
|
+
"version": "1.0.1-alpha.16",
|
|
4
4
|
"description": "Runner for Arazzo Workflows.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arazzo",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"@swaggerexpert/json-pointer": "^3.0.2",
|
|
74
74
|
"@swaggerexpert/jsonpath": "^4.0.5",
|
|
75
75
|
"@swaggerexpert/media-types": "^1.0.1",
|
|
76
|
-
"@usearazzo/parser": "1.0.1-alpha.
|
|
77
|
-
"@usearazzo/resolver": "1.0.1-alpha.
|
|
76
|
+
"@usearazzo/parser": "1.0.1-alpha.16",
|
|
77
|
+
"@usearazzo/resolver": "1.0.1-alpha.16",
|
|
78
78
|
"@xmldom/xmldom": "^0.9.12",
|
|
79
79
|
"fontoxpath": "^3.34.0",
|
|
80
80
|
"ramda": "^0.32.0",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"swagger-client": "^3.38.4"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "9ff2a68d209a5d178658f9a568c2d136178d40b8"
|
|
98
98
|
}
|
|
@@ -159,23 +159,32 @@ class ArazzoWorkflowNormalizer {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
162
|
+
* Merges the workflow's `successActions` / `failureActions` into each step's
|
|
163
|
+
* `onSuccess` / `onFailure`.
|
|
164
164
|
*
|
|
165
|
-
* Per Arazzo
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* the
|
|
165
|
+
* Per Arazzo both lists are "applicable for all steps described under this
|
|
166
|
+
* workflow" and "can be overridden at the step level but cannot be removed
|
|
167
|
+
* there". The required action `name` is what makes both halves hold: a
|
|
168
|
+
* step's action replaces the workflow action of the same `name`, and every
|
|
169
|
+
* workflow action the step does not name still applies. The effective list is
|
|
170
|
+
* the step's own actions in order, then the workflow actions it did not
|
|
171
|
+
* override, in theirs — order matters, as selection is first-match-wins on
|
|
172
|
+
* `criteria`. So a step with no list, or with `[]`, gets every workflow
|
|
173
|
+
* action. The step's own list is kept exactly as written, even a duplicate
|
|
174
|
+
* `name` in it, which the validator reports: inheritance only adds to it.
|
|
175
|
+
* Within the workflow's list the first action with a given `name` wins.
|
|
176
|
+
* Success and failure merge independently.
|
|
171
177
|
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* is present but not a list
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
178
|
+
* An entry without a readable `name` (an unresolved Reusable Object, a
|
|
179
|
+
* scalar someone put in the list) neither overrides nor is overridden: it
|
|
180
|
+
* keeps its place, and is added only if that same element is not already in
|
|
181
|
+
* the list. A step whose `onSuccess` is present but not a list is left
|
|
182
|
+
* alone, for the same reason the parameters pass leaves a malformed list
|
|
183
|
+
* alone — overwriting it would erase what makes the document invalid.
|
|
184
|
+
*
|
|
185
|
+
* The pass is idempotent, so a workflow reached again through the registry
|
|
186
|
+
* cache is merged into once: on a second pass every inherited action is
|
|
187
|
+
* already in the step's list, under its own `name` or as the same element.
|
|
179
188
|
*
|
|
180
189
|
* Unlike parameters there is no step-kind filter — an action names a
|
|
181
190
|
* transition within the workflow, which is as meaningful for a step targeting
|
|
@@ -202,13 +211,34 @@ class ArazzoWorkflowNormalizer {
|
|
|
202
211
|
if (!inheritSuccess && !inheritFailure) return;
|
|
203
212
|
for (const step of workflow.steps) {
|
|
204
213
|
if (!(0, _apidomNsArazzo.isStepElement)(step)) continue;
|
|
205
|
-
if (inheritSuccess && !step.hasKey('onSuccess')) {
|
|
206
|
-
step.onSuccess = new _apidomNsArazzo.StepOnSuccessElement([...successActions]);
|
|
214
|
+
if (inheritSuccess && (!step.hasKey('onSuccess') || (0, _apidomDatamodel.isArrayElement)(step.onSuccess))) {
|
|
215
|
+
step.onSuccess = new _apidomNsArazzo.StepOnSuccessElement(ArazzoWorkflowNormalizer.#mergeActions([...(step.onSuccess ?? [])], [...successActions]));
|
|
216
|
+
}
|
|
217
|
+
if (inheritFailure && (!step.hasKey('onFailure') || (0, _apidomDatamodel.isArrayElement)(step.onFailure))) {
|
|
218
|
+
step.onFailure = new _apidomNsArazzo.StepOnFailureElement(ArazzoWorkflowNormalizer.#mergeActions([...(step.onFailure ?? [])], [...failureActions]));
|
|
207
219
|
}
|
|
208
|
-
|
|
209
|
-
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* The step's actions as written, followed by each workflow action whose
|
|
225
|
+
* `name` neither the step nor an earlier workflow action carries; a nameless
|
|
226
|
+
* workflow entry is added unless that same element is already present.
|
|
227
|
+
*/
|
|
228
|
+
static #mergeActions(own, inherited) {
|
|
229
|
+
const nameOf = action => (0, _apidomDatamodel.isObjectElement)(action) ? (0, _apidomCore.toValue)(action.get('name')) : undefined;
|
|
230
|
+
const names = new Set(own.map(nameOf));
|
|
231
|
+
const merged = [...own];
|
|
232
|
+
for (const action of inherited) {
|
|
233
|
+
const name = nameOf(action);
|
|
234
|
+
if (typeof name !== 'string') {
|
|
235
|
+
if (!merged.includes(action)) merged.push(action);
|
|
236
|
+
} else if (!names.has(name)) {
|
|
237
|
+
names.add(name);
|
|
238
|
+
merged.push(action);
|
|
210
239
|
}
|
|
211
240
|
}
|
|
241
|
+
return merged;
|
|
212
242
|
}
|
|
213
243
|
}
|
|
214
244
|
var _default = exports.default = ArazzoWorkflowNormalizer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { uniqWith } from 'ramda';
|
|
2
2
|
import { isParameterElement, isStepElement, StepParametersElement, StepOnSuccessElement, StepOnFailureElement } from '@speclynx/apidom-ns-arazzo-1';
|
|
3
3
|
import { toValue } from '@speclynx/apidom-core';
|
|
4
|
-
import { isArrayElement, isStringElement } from '@speclynx/apidom-datamodel';
|
|
4
|
+
import { isArrayElement, isObjectElement, isStringElement } from '@speclynx/apidom-datamodel';
|
|
5
5
|
import { dereferenceArazzoElement, defaultDereferenceArazzoOptions } from '@usearazzo/resolver';
|
|
6
6
|
import { mergeOptions } from '@speclynx/apidom-reference/configuration/empty';
|
|
7
7
|
import ParameterIdentity from "../document/ParameterIdentity.mjs";
|
|
@@ -151,23 +151,32 @@ class ArazzoWorkflowNormalizer {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
154
|
+
* Merges the workflow's `successActions` / `failureActions` into each step's
|
|
155
|
+
* `onSuccess` / `onFailure`.
|
|
156
156
|
*
|
|
157
|
-
* Per Arazzo
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* the
|
|
157
|
+
* Per Arazzo both lists are "applicable for all steps described under this
|
|
158
|
+
* workflow" and "can be overridden at the step level but cannot be removed
|
|
159
|
+
* there". The required action `name` is what makes both halves hold: a
|
|
160
|
+
* step's action replaces the workflow action of the same `name`, and every
|
|
161
|
+
* workflow action the step does not name still applies. The effective list is
|
|
162
|
+
* the step's own actions in order, then the workflow actions it did not
|
|
163
|
+
* override, in theirs — order matters, as selection is first-match-wins on
|
|
164
|
+
* `criteria`. So a step with no list, or with `[]`, gets every workflow
|
|
165
|
+
* action. The step's own list is kept exactly as written, even a duplicate
|
|
166
|
+
* `name` in it, which the validator reports: inheritance only adds to it.
|
|
167
|
+
* Within the workflow's list the first action with a given `name` wins.
|
|
168
|
+
* Success and failure merge independently.
|
|
163
169
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* is present but not a list
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
170
|
+
* An entry without a readable `name` (an unresolved Reusable Object, a
|
|
171
|
+
* scalar someone put in the list) neither overrides nor is overridden: it
|
|
172
|
+
* keeps its place, and is added only if that same element is not already in
|
|
173
|
+
* the list. A step whose `onSuccess` is present but not a list is left
|
|
174
|
+
* alone, for the same reason the parameters pass leaves a malformed list
|
|
175
|
+
* alone — overwriting it would erase what makes the document invalid.
|
|
176
|
+
*
|
|
177
|
+
* The pass is idempotent, so a workflow reached again through the registry
|
|
178
|
+
* cache is merged into once: on a second pass every inherited action is
|
|
179
|
+
* already in the step's list, under its own `name` or as the same element.
|
|
171
180
|
*
|
|
172
181
|
* Unlike parameters there is no step-kind filter — an action names a
|
|
173
182
|
* transition within the workflow, which is as meaningful for a step targeting
|
|
@@ -194,13 +203,34 @@ class ArazzoWorkflowNormalizer {
|
|
|
194
203
|
if (!inheritSuccess && !inheritFailure) return;
|
|
195
204
|
for (const step of workflow.steps) {
|
|
196
205
|
if (!isStepElement(step)) continue;
|
|
197
|
-
if (inheritSuccess && !step.hasKey('onSuccess')) {
|
|
198
|
-
step.onSuccess = new StepOnSuccessElement([...successActions]);
|
|
206
|
+
if (inheritSuccess && (!step.hasKey('onSuccess') || isArrayElement(step.onSuccess))) {
|
|
207
|
+
step.onSuccess = new StepOnSuccessElement(ArazzoWorkflowNormalizer.#mergeActions([...(step.onSuccess ?? [])], [...successActions]));
|
|
208
|
+
}
|
|
209
|
+
if (inheritFailure && (!step.hasKey('onFailure') || isArrayElement(step.onFailure))) {
|
|
210
|
+
step.onFailure = new StepOnFailureElement(ArazzoWorkflowNormalizer.#mergeActions([...(step.onFailure ?? [])], [...failureActions]));
|
|
199
211
|
}
|
|
200
|
-
|
|
201
|
-
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The step's actions as written, followed by each workflow action whose
|
|
217
|
+
* `name` neither the step nor an earlier workflow action carries; a nameless
|
|
218
|
+
* workflow entry is added unless that same element is already present.
|
|
219
|
+
*/
|
|
220
|
+
static #mergeActions(own, inherited) {
|
|
221
|
+
const nameOf = action => isObjectElement(action) ? toValue(action.get('name')) : undefined;
|
|
222
|
+
const names = new Set(own.map(nameOf));
|
|
223
|
+
const merged = [...own];
|
|
224
|
+
for (const action of inherited) {
|
|
225
|
+
const name = nameOf(action);
|
|
226
|
+
if (typeof name !== 'string') {
|
|
227
|
+
if (!merged.includes(action)) merged.push(action);
|
|
228
|
+
} else if (!names.has(name)) {
|
|
229
|
+
names.add(name);
|
|
230
|
+
merged.push(action);
|
|
202
231
|
}
|
|
203
232
|
}
|
|
233
|
+
return merged;
|
|
204
234
|
}
|
|
205
235
|
}
|
|
206
236
|
export default ArazzoWorkflowNormalizer;
|