@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.
Files changed (152) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +20 -0
  4. package/README.md +777 -2
  5. package/dist/arazzo-runner.browser.js +111247 -0
  6. package/dist/arazzo-runner.browser.min.js +1 -0
  7. package/package.json +90 -4
  8. package/src/action/ActionResolver.cjs +160 -0
  9. package/src/action/ActionResolver.mjs +150 -0
  10. package/src/assembler/OpenAPI2DocumentAssembler.cjs +111 -0
  11. package/src/assembler/OpenAPI2DocumentAssembler.mjs +104 -0
  12. package/src/assembler/OpenAPI30DocumentAssembler.cjs +110 -0
  13. package/src/assembler/OpenAPI30DocumentAssembler.mjs +103 -0
  14. package/src/assembler/OpenAPI31DocumentAssembler.cjs +111 -0
  15. package/src/assembler/OpenAPI31DocumentAssembler.mjs +104 -0
  16. package/src/assembler/OpenAPIDocumentAssembler.cjs +58 -0
  17. package/src/assembler/OpenAPIDocumentAssembler.mjs +50 -0
  18. package/src/client/HTTPClient.cjs +5 -0
  19. package/src/client/HTTPClient.mjs +1 -0
  20. package/src/client/HTTPClientFetch.cjs +16 -0
  21. package/src/client/HTTPClientFetch.mjs +10 -0
  22. package/src/client/OpenAPIOperationRequest.cjs +5 -0
  23. package/src/client/OpenAPIOperationRequest.mjs +1 -0
  24. package/src/client/OpenAPIOperationResponse.cjs +42 -0
  25. package/src/client/OpenAPIOperationResponse.mjs +36 -0
  26. package/src/client/OpenAPIOperationResponseNormalizer.cjs +48 -0
  27. package/src/client/OpenAPIOperationResponseNormalizer.mjs +40 -0
  28. package/src/client/ParameterDelivery.cjs +119 -0
  29. package/src/client/ParameterDelivery.mjs +113 -0
  30. package/src/constants.cjs +9 -0
  31. package/src/constants.mjs +3 -0
  32. package/src/criterion/CriterionEvaluator.cjs +205 -0
  33. package/src/criterion/CriterionEvaluator.mjs +196 -0
  34. package/src/criterion/JSONPathCriterionEvaluator.cjs +47 -0
  35. package/src/criterion/JSONPathCriterionEvaluator.mjs +40 -0
  36. package/src/criterion/RegexCriterionEvaluator.cjs +67 -0
  37. package/src/criterion/RegexCriterionEvaluator.mjs +60 -0
  38. package/src/criterion/SimpleCriterionEvaluator.cjs +50 -0
  39. package/src/criterion/SimpleCriterionEvaluator.mjs +43 -0
  40. package/src/criterion/XPathCriterionEvaluator.cjs +117 -0
  41. package/src/criterion/XPathCriterionEvaluator.mjs +109 -0
  42. package/src/document/APIDocument.cjs +35 -0
  43. package/src/document/APIDocument.mjs +30 -0
  44. package/src/document/ArazzoDocument.cjs +81 -0
  45. package/src/document/ArazzoDocument.mjs +74 -0
  46. package/src/document/ArazzoSourceDescriptionIndex.cjs +26 -0
  47. package/src/document/ArazzoSourceDescriptionIndex.mjs +20 -0
  48. package/src/document/ArazzoStepIndex.cjs +25 -0
  49. package/src/document/ArazzoStepIndex.mjs +19 -0
  50. package/src/document/ArazzoWorkflowIndex.cjs +17 -0
  51. package/src/document/ArazzoWorkflowIndex.mjs +11 -0
  52. package/src/document/OpenAPIDocument.cjs +28 -0
  53. package/src/document/OpenAPIDocument.mjs +21 -0
  54. package/src/document/OpenAPIOperationIndex.cjs +24 -0
  55. package/src/document/OpenAPIOperationIndex.mjs +18 -0
  56. package/src/document/ParameterIdentity.cjs +93 -0
  57. package/src/document/ParameterIdentity.mjs +88 -0
  58. package/src/document/openapi-types.cjs +5 -0
  59. package/src/document/openapi-types.mjs +1 -0
  60. package/src/errors/ArazzoRunnerError.cjs +10 -0
  61. package/src/errors/ArazzoRunnerError.mjs +5 -0
  62. package/src/errors/AssemblerError.cjs +11 -0
  63. package/src/errors/AssemblerError.mjs +4 -0
  64. package/src/errors/ClientError.cjs +11 -0
  65. package/src/errors/ClientError.mjs +4 -0
  66. package/src/errors/CriterionError.cjs +11 -0
  67. package/src/errors/CriterionError.mjs +4 -0
  68. package/src/errors/ExecutionError.cjs +11 -0
  69. package/src/errors/ExecutionError.mjs +4 -0
  70. package/src/errors/ExtractionError.cjs +11 -0
  71. package/src/errors/ExtractionError.mjs +4 -0
  72. package/src/errors/InvalidEntryDocumentError.cjs +11 -0
  73. package/src/errors/InvalidEntryDocumentError.mjs +4 -0
  74. package/src/errors/NormalizationError.cjs +11 -0
  75. package/src/errors/NormalizationError.mjs +4 -0
  76. package/src/errors/ResolverError.cjs +11 -0
  77. package/src/errors/ResolverError.mjs +4 -0
  78. package/src/errors/RuntimeExpressionError.cjs +11 -0
  79. package/src/errors/RuntimeExpressionError.mjs +4 -0
  80. package/src/errors/UnmatchedProviderError.cjs +11 -0
  81. package/src/errors/UnmatchedProviderError.mjs +4 -0
  82. package/src/executor/ArazzoWorkflowLocatorNormalizer.cjs +147 -0
  83. package/src/executor/ArazzoWorkflowLocatorNormalizer.mjs +137 -0
  84. package/src/executor/OpenAPIOperationExecutor.cjs +457 -0
  85. package/src/executor/OpenAPIOperationExecutor.mjs +446 -0
  86. package/src/executor/OpenAPIOperationLocatorNormalizer.cjs +197 -0
  87. package/src/executor/OpenAPIOperationLocatorNormalizer.mjs +189 -0
  88. package/src/executor/SourceDescriptionsLocatorNormalizer.cjs +44 -0
  89. package/src/executor/SourceDescriptionsLocatorNormalizer.mjs +38 -0
  90. package/src/executor/StepExecutor.cjs +333 -0
  91. package/src/executor/StepExecutor.mjs +326 -0
  92. package/src/executor/StepRetryRunner.cjs +226 -0
  93. package/src/executor/StepRetryRunner.mjs +215 -0
  94. package/src/executor/StepTransitionInterpreter.cjs +159 -0
  95. package/src/executor/StepTransitionInterpreter.mjs +151 -0
  96. package/src/executor/WorkflowCallStack.cjs +116 -0
  97. package/src/executor/WorkflowCallStack.mjs +106 -0
  98. package/src/executor/WorkflowExecutor.cjs +1091 -0
  99. package/src/executor/WorkflowExecutor.mjs +1077 -0
  100. package/src/executor/abort.cjs +70 -0
  101. package/src/executor/abort.mjs +60 -0
  102. package/src/expression/RuntimeExpressionContext.cjs +5 -0
  103. package/src/expression/RuntimeExpressionContext.mjs +1 -0
  104. package/src/expression/RuntimeExpressionEvaluator.cjs +337 -0
  105. package/src/expression/RuntimeExpressionEvaluator.mjs +328 -0
  106. package/src/extractor/ArazzoStepExtractor.cjs +48 -0
  107. package/src/extractor/ArazzoStepExtractor.mjs +41 -0
  108. package/src/extractor/ArazzoWorkflowExtractor.cjs +50 -0
  109. package/src/extractor/ArazzoWorkflowExtractor.mjs +43 -0
  110. package/src/extractor/OpenAPIOperationExtractor.cjs +84 -0
  111. package/src/extractor/OpenAPIOperationExtractor.mjs +77 -0
  112. package/src/index.cjs +419 -0
  113. package/src/index.mjs +73 -0
  114. package/src/normalizer/ArazzoStepNormalizer.cjs +23 -0
  115. package/src/normalizer/ArazzoStepNormalizer.mjs +17 -0
  116. package/src/normalizer/ArazzoWorkflowNormalizer.cjs +214 -0
  117. package/src/normalizer/ArazzoWorkflowNormalizer.mjs +206 -0
  118. package/src/normalizer/OpenAPI2OperationNormalizer.cjs +128 -0
  119. package/src/normalizer/OpenAPI2OperationNormalizer.mjs +120 -0
  120. package/src/normalizer/OpenAPI30OperationNormalizer.cjs +129 -0
  121. package/src/normalizer/OpenAPI30OperationNormalizer.mjs +121 -0
  122. package/src/normalizer/OpenAPI31OperationNormalizer.cjs +131 -0
  123. package/src/normalizer/OpenAPI31OperationNormalizer.mjs +123 -0
  124. package/src/normalizer/OpenAPIOperationNormalizer.cjs +58 -0
  125. package/src/normalizer/OpenAPIOperationNormalizer.mjs +50 -0
  126. package/src/registry/DocumentRegistry.cjs +160 -0
  127. package/src/registry/DocumentRegistry.mjs +151 -0
  128. package/src/registry/providers/ArazzoDocumentRegistryProvider.cjs +154 -0
  129. package/src/registry/providers/ArazzoDocumentRegistryProvider.mjs +146 -0
  130. package/src/registry/providers/DocumentRegistryProvider.cjs +31 -0
  131. package/src/registry/providers/DocumentRegistryProvider.mjs +25 -0
  132. package/src/registry/providers/OpenAPIDocumentRegistryProvider.cjs +122 -0
  133. package/src/registry/providers/OpenAPIDocumentRegistryProvider.mjs +114 -0
  134. package/src/resolver/ArazzoValueResolver.cjs +42 -0
  135. package/src/resolver/ArazzoValueResolver.mjs +37 -0
  136. package/src/resolver/OpenAPIOperationParameterResolver.cjs +117 -0
  137. package/src/resolver/OpenAPIOperationParameterResolver.mjs +110 -0
  138. package/src/resolver/OutputResolver.cjs +71 -0
  139. package/src/resolver/OutputResolver.mjs +64 -0
  140. package/src/resolver/RequestBodyResolver.cjs +227 -0
  141. package/src/resolver/RequestBodyResolver.mjs +220 -0
  142. package/src/resolver/ResolverScope.cjs +5 -0
  143. package/src/resolver/ResolverScope.mjs +1 -0
  144. package/src/resolver/StepParameterResolver.cjs +22 -0
  145. package/src/resolver/StepParameterResolver.mjs +15 -0
  146. package/src/resolver/WorkflowParameterResolver.cjs +73 -0
  147. package/src/resolver/WorkflowParameterResolver.mjs +66 -0
  148. package/src/state/WorkflowExecutionState.cjs +99 -0
  149. package/src/state/WorkflowExecutionState.mjs +93 -0
  150. package/src/vendor/swagger-client.cjs +1 -0
  151. package/src/vendor/swagger-client.mjs +1 -0
  152. 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;