@usearazzo/runner 0.0.0-stage → 1.0.1-alpha.9
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 +25 -0
- package/LICENSE +202 -0
- package/NOTICE +20 -0
- package/README.md +777 -2
- package/dist/arazzo-runner.browser.js +111247 -0
- package/dist/arazzo-runner.browser.min.js +1 -0
- package/package.json +90 -4
- package/src/action/ActionResolver.cjs +160 -0
- package/src/action/ActionResolver.mjs +150 -0
- package/src/assembler/OpenAPI2DocumentAssembler.cjs +111 -0
- package/src/assembler/OpenAPI2DocumentAssembler.mjs +104 -0
- package/src/assembler/OpenAPI30DocumentAssembler.cjs +110 -0
- package/src/assembler/OpenAPI30DocumentAssembler.mjs +103 -0
- package/src/assembler/OpenAPI31DocumentAssembler.cjs +111 -0
- package/src/assembler/OpenAPI31DocumentAssembler.mjs +104 -0
- package/src/assembler/OpenAPIDocumentAssembler.cjs +58 -0
- package/src/assembler/OpenAPIDocumentAssembler.mjs +50 -0
- package/src/client/HTTPClient.cjs +5 -0
- package/src/client/HTTPClient.mjs +1 -0
- package/src/client/HTTPClientFetch.cjs +16 -0
- package/src/client/HTTPClientFetch.mjs +10 -0
- package/src/client/OpenAPIOperationRequest.cjs +5 -0
- package/src/client/OpenAPIOperationRequest.mjs +1 -0
- package/src/client/OpenAPIOperationResponse.cjs +42 -0
- package/src/client/OpenAPIOperationResponse.mjs +36 -0
- package/src/client/OpenAPIOperationResponseNormalizer.cjs +48 -0
- package/src/client/OpenAPIOperationResponseNormalizer.mjs +40 -0
- package/src/client/ParameterDelivery.cjs +119 -0
- package/src/client/ParameterDelivery.mjs +113 -0
- package/src/constants.cjs +9 -0
- package/src/constants.mjs +3 -0
- package/src/criterion/CriterionEvaluator.cjs +205 -0
- package/src/criterion/CriterionEvaluator.mjs +196 -0
- package/src/criterion/JSONPathCriterionEvaluator.cjs +47 -0
- package/src/criterion/JSONPathCriterionEvaluator.mjs +40 -0
- package/src/criterion/RegexCriterionEvaluator.cjs +67 -0
- package/src/criterion/RegexCriterionEvaluator.mjs +60 -0
- package/src/criterion/SimpleCriterionEvaluator.cjs +50 -0
- package/src/criterion/SimpleCriterionEvaluator.mjs +43 -0
- package/src/criterion/XPathCriterionEvaluator.cjs +117 -0
- package/src/criterion/XPathCriterionEvaluator.mjs +109 -0
- package/src/document/APIDocument.cjs +35 -0
- package/src/document/APIDocument.mjs +30 -0
- package/src/document/ArazzoDocument.cjs +81 -0
- package/src/document/ArazzoDocument.mjs +74 -0
- package/src/document/ArazzoSourceDescriptionIndex.cjs +26 -0
- package/src/document/ArazzoSourceDescriptionIndex.mjs +20 -0
- package/src/document/ArazzoStepIndex.cjs +25 -0
- package/src/document/ArazzoStepIndex.mjs +19 -0
- package/src/document/ArazzoWorkflowIndex.cjs +17 -0
- package/src/document/ArazzoWorkflowIndex.mjs +11 -0
- package/src/document/OpenAPIDocument.cjs +28 -0
- package/src/document/OpenAPIDocument.mjs +21 -0
- package/src/document/OpenAPIOperationIndex.cjs +24 -0
- package/src/document/OpenAPIOperationIndex.mjs +18 -0
- package/src/document/ParameterIdentity.cjs +93 -0
- package/src/document/ParameterIdentity.mjs +88 -0
- package/src/document/openapi-types.cjs +5 -0
- package/src/document/openapi-types.mjs +1 -0
- package/src/errors/ArazzoRunnerError.cjs +10 -0
- package/src/errors/ArazzoRunnerError.mjs +5 -0
- package/src/errors/AssemblerError.cjs +11 -0
- package/src/errors/AssemblerError.mjs +4 -0
- package/src/errors/ClientError.cjs +11 -0
- package/src/errors/ClientError.mjs +4 -0
- package/src/errors/CriterionError.cjs +11 -0
- package/src/errors/CriterionError.mjs +4 -0
- package/src/errors/ExecutionError.cjs +11 -0
- package/src/errors/ExecutionError.mjs +4 -0
- package/src/errors/ExtractionError.cjs +11 -0
- package/src/errors/ExtractionError.mjs +4 -0
- package/src/errors/InvalidEntryDocumentError.cjs +11 -0
- package/src/errors/InvalidEntryDocumentError.mjs +4 -0
- package/src/errors/NormalizationError.cjs +11 -0
- package/src/errors/NormalizationError.mjs +4 -0
- package/src/errors/ResolverError.cjs +11 -0
- package/src/errors/ResolverError.mjs +4 -0
- package/src/errors/RuntimeExpressionError.cjs +11 -0
- package/src/errors/RuntimeExpressionError.mjs +4 -0
- package/src/errors/UnmatchedProviderError.cjs +11 -0
- package/src/errors/UnmatchedProviderError.mjs +4 -0
- package/src/executor/ArazzoWorkflowLocatorNormalizer.cjs +147 -0
- package/src/executor/ArazzoWorkflowLocatorNormalizer.mjs +137 -0
- package/src/executor/OpenAPIOperationExecutor.cjs +457 -0
- package/src/executor/OpenAPIOperationExecutor.mjs +446 -0
- package/src/executor/OpenAPIOperationLocatorNormalizer.cjs +197 -0
- package/src/executor/OpenAPIOperationLocatorNormalizer.mjs +189 -0
- package/src/executor/SourceDescriptionsLocatorNormalizer.cjs +44 -0
- package/src/executor/SourceDescriptionsLocatorNormalizer.mjs +38 -0
- package/src/executor/StepExecutor.cjs +333 -0
- package/src/executor/StepExecutor.mjs +326 -0
- package/src/executor/StepRetryRunner.cjs +226 -0
- package/src/executor/StepRetryRunner.mjs +215 -0
- package/src/executor/StepTransitionInterpreter.cjs +159 -0
- package/src/executor/StepTransitionInterpreter.mjs +151 -0
- package/src/executor/WorkflowCallStack.cjs +116 -0
- package/src/executor/WorkflowCallStack.mjs +106 -0
- package/src/executor/WorkflowExecutor.cjs +1091 -0
- package/src/executor/WorkflowExecutor.mjs +1077 -0
- package/src/executor/abort.cjs +70 -0
- package/src/executor/abort.mjs +60 -0
- package/src/expression/RuntimeExpressionContext.cjs +5 -0
- package/src/expression/RuntimeExpressionContext.mjs +1 -0
- package/src/expression/RuntimeExpressionEvaluator.cjs +337 -0
- package/src/expression/RuntimeExpressionEvaluator.mjs +328 -0
- package/src/extractor/ArazzoStepExtractor.cjs +48 -0
- package/src/extractor/ArazzoStepExtractor.mjs +41 -0
- package/src/extractor/ArazzoWorkflowExtractor.cjs +50 -0
- package/src/extractor/ArazzoWorkflowExtractor.mjs +43 -0
- package/src/extractor/OpenAPIOperationExtractor.cjs +84 -0
- package/src/extractor/OpenAPIOperationExtractor.mjs +77 -0
- package/src/index.cjs +419 -0
- package/src/index.mjs +73 -0
- package/src/normalizer/ArazzoStepNormalizer.cjs +23 -0
- package/src/normalizer/ArazzoStepNormalizer.mjs +17 -0
- package/src/normalizer/ArazzoWorkflowNormalizer.cjs +214 -0
- package/src/normalizer/ArazzoWorkflowNormalizer.mjs +206 -0
- package/src/normalizer/OpenAPI2OperationNormalizer.cjs +128 -0
- package/src/normalizer/OpenAPI2OperationNormalizer.mjs +120 -0
- package/src/normalizer/OpenAPI30OperationNormalizer.cjs +129 -0
- package/src/normalizer/OpenAPI30OperationNormalizer.mjs +121 -0
- package/src/normalizer/OpenAPI31OperationNormalizer.cjs +131 -0
- package/src/normalizer/OpenAPI31OperationNormalizer.mjs +123 -0
- package/src/normalizer/OpenAPIOperationNormalizer.cjs +58 -0
- package/src/normalizer/OpenAPIOperationNormalizer.mjs +50 -0
- package/src/registry/DocumentRegistry.cjs +160 -0
- package/src/registry/DocumentRegistry.mjs +151 -0
- package/src/registry/providers/ArazzoDocumentRegistryProvider.cjs +154 -0
- package/src/registry/providers/ArazzoDocumentRegistryProvider.mjs +146 -0
- package/src/registry/providers/DocumentRegistryProvider.cjs +31 -0
- package/src/registry/providers/DocumentRegistryProvider.mjs +25 -0
- package/src/registry/providers/OpenAPIDocumentRegistryProvider.cjs +122 -0
- package/src/registry/providers/OpenAPIDocumentRegistryProvider.mjs +114 -0
- package/src/resolver/ArazzoValueResolver.cjs +42 -0
- package/src/resolver/ArazzoValueResolver.mjs +37 -0
- package/src/resolver/OpenAPIOperationParameterResolver.cjs +117 -0
- package/src/resolver/OpenAPIOperationParameterResolver.mjs +110 -0
- package/src/resolver/OutputResolver.cjs +71 -0
- package/src/resolver/OutputResolver.mjs +64 -0
- package/src/resolver/RequestBodyResolver.cjs +227 -0
- package/src/resolver/RequestBodyResolver.mjs +220 -0
- package/src/resolver/ResolverScope.cjs +5 -0
- package/src/resolver/ResolverScope.mjs +1 -0
- package/src/resolver/StepParameterResolver.cjs +22 -0
- package/src/resolver/StepParameterResolver.mjs +15 -0
- package/src/resolver/WorkflowParameterResolver.cjs +73 -0
- package/src/resolver/WorkflowParameterResolver.mjs +66 -0
- package/src/state/WorkflowExecutionState.cjs +99 -0
- package/src/state/WorkflowExecutionState.mjs +93 -0
- package/src/vendor/swagger-client.cjs +1 -0
- package/src/vendor/swagger-client.mjs +1 -0
- package/types/runner.d.ts +2341 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import ExecutionError from "../errors/ExecutionError.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* How a workflow invocation was entered.
|
|
4
|
+
*
|
|
5
|
+
* Recorded per call so a detected loop can be named for the mechanism that formed
|
|
6
|
+
* it: a repeat reached purely through `dependsOn` edges is a dependency cycle,
|
|
7
|
+
* one involving a sub-workflow step call — a `retry` action's `workflowId`
|
|
8
|
+
* reference — or a `goto`'s one-way transfer to a `workflowId` — is a call
|
|
9
|
+
* cycle. `retry` and `goto` are grouped with `step` for that classification, not
|
|
10
|
+
* `dependsOn`: each is a call the current step makes, not a stated precondition.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* One workflow invocation in progress. Its identity is the (documentURI,
|
|
15
|
+
* workflowId) pair: two documents may each define a workflow of one id, and
|
|
16
|
+
* those are different workflows — comparing bare ids would call their meeting
|
|
17
|
+
* a cycle.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Options for the WorkflowCallStack.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* The chain of workflow invocations in progress, as an immutable value.
|
|
25
|
+
*
|
|
26
|
+
* {@link WorkflowCallStack.enter} returns a *new* stack with the given workflow
|
|
27
|
+
* pushed, or throws if entering it cannot be legitimate. Because entering yields
|
|
28
|
+
* a new value rather than mutating this one, leaving is implicit: an unwinding
|
|
29
|
+
* throw cannot leave a stale entry behind, and sibling calls each see only their
|
|
30
|
+
* own chain — so a diamond (a workflow reached twice on separate paths, having
|
|
31
|
+
* completed and unwound in between) is not a cycle, while a genuine re-entry is.
|
|
32
|
+
*
|
|
33
|
+
* Two distinct failures are guarded, in this order:
|
|
34
|
+
*
|
|
35
|
+
* - a **cycle** — the workflow is already in progress on this chain, so it can
|
|
36
|
+
* never terminate. Checked *first* deliberately: a cycle would eventually trip
|
|
37
|
+
* the depth ceiling too, but only after exhausting the whole budget of frames
|
|
38
|
+
* and then reporting the wrong cause.
|
|
39
|
+
* - **excessive depth** — distinct workflows nested past `maxDepth`, which is
|
|
40
|
+
* legitimate nesting that simply has to be bounded.
|
|
41
|
+
*
|
|
42
|
+
* Both carry the offending `path`, since the workflow the error names is rarely
|
|
43
|
+
* the one whose authoring needs looking at.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
class WorkflowCallStack {
|
|
47
|
+
#calls;
|
|
48
|
+
#maxDepth;
|
|
49
|
+
#entryDocumentURI;
|
|
50
|
+
constructor(options, calls = []) {
|
|
51
|
+
this.#maxDepth = options.maxDepth;
|
|
52
|
+
this.#entryDocumentURI = options.entryDocumentURI;
|
|
53
|
+
this.#calls = calls;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The workflows in progress, outermost first — bare ids for entry-document
|
|
58
|
+
* frames, `{documentURI}#{workflowId}` for foreign ones.
|
|
59
|
+
*/
|
|
60
|
+
get path() {
|
|
61
|
+
return this.#calls.map(call => this.#display(call.workflowId, call.documentURI));
|
|
62
|
+
}
|
|
63
|
+
#display(workflowId, documentURI) {
|
|
64
|
+
return documentURI === this.#entryDocumentURI ? workflowId : `${documentURI}#${workflowId}`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns the stack with the workflow pushed — identified by its bare id
|
|
69
|
+
* together with the canonical URI of the document that owns it — or throws
|
|
70
|
+
* when entering it would form a cycle or exceed the nesting ceiling.
|
|
71
|
+
*/
|
|
72
|
+
enter(workflowId, via, documentURI) {
|
|
73
|
+
const repeated = this.#calls.findIndex(call => call.workflowId === workflowId && call.documentURI === documentURI);
|
|
74
|
+
if (repeated !== -1) {
|
|
75
|
+
const path = [...this.path, this.#display(workflowId, documentURI)];
|
|
76
|
+
// name the loop for the mechanism that formed it: every edge closing the
|
|
77
|
+
// cycle being a `dependsOn` edge makes it a dependency cycle, while any
|
|
78
|
+
// sub-workflow step call in the loop makes it a call cycle. One stack
|
|
79
|
+
// detects both, so a loop crossing the two mechanisms cannot slip between
|
|
80
|
+
// them.
|
|
81
|
+
const closingEdges = [...this.#calls.slice(repeated + 1).map(call => call.via), via];
|
|
82
|
+
const reason = closingEdges.every(edge => edge === 'dependsOn') ? 'dependsOn-cycle' : 'workflow-cycle';
|
|
83
|
+
throw new ExecutionError(`workflow "${workflowId}" is already in progress; its call chain forms a cycle (${path.join(' -> ')})`, {
|
|
84
|
+
workflowId,
|
|
85
|
+
reason,
|
|
86
|
+
path
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (this.#calls.length >= this.#maxDepth) {
|
|
90
|
+
throw new ExecutionError(`workflow "${workflowId}" nests deeper than the limit of ${this.#maxDepth} workflows`, {
|
|
91
|
+
workflowId,
|
|
92
|
+
reason: 'workflow-depth',
|
|
93
|
+
path: [...this.path, this.#display(workflowId, documentURI)]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return new WorkflowCallStack({
|
|
97
|
+
maxDepth: this.#maxDepth,
|
|
98
|
+
entryDocumentURI: this.#entryDocumentURI
|
|
99
|
+
}, [...this.#calls, {
|
|
100
|
+
workflowId,
|
|
101
|
+
documentURI,
|
|
102
|
+
via
|
|
103
|
+
}]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export default WorkflowCallStack;
|