@usearazzo/runner 1.0.1-alpha.27 → 1.0.1-alpha.28

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.27",
3
+ "version": "1.0.1-alpha.28",
4
4
  "description": "Runner for Arazzo Workflows.",
5
5
  "keywords": [
6
6
  "arazzo",
@@ -57,24 +57,24 @@
57
57
  "license": "Apache-2.0",
58
58
  "dependencies": {
59
59
  "@babel/runtime-corejs3": "^8.1.0",
60
- "@speclynx/apidom-core": "^7.0.1",
61
- "@speclynx/apidom-datamodel": "^7.0.1",
62
- "@speclynx/apidom-error": "^7.0.1",
63
- "@speclynx/apidom-json-pointer": "^7.0.1",
64
- "@speclynx/apidom-ns-arazzo-1": "^7.0.1",
65
- "@speclynx/apidom-ns-openapi-2": "^7.0.1",
66
- "@speclynx/apidom-ns-openapi-3-0": "^7.0.1",
67
- "@speclynx/apidom-ns-openapi-3-1": "^7.0.1",
68
- "@speclynx/apidom-reference": "^7.0.1",
69
- "@speclynx/apidom-traverse": "^7.0.1",
60
+ "@speclynx/apidom-core": "^7.0.2",
61
+ "@speclynx/apidom-datamodel": "^7.0.2",
62
+ "@speclynx/apidom-error": "^7.0.2",
63
+ "@speclynx/apidom-json-pointer": "^7.0.2",
64
+ "@speclynx/apidom-ns-arazzo-1": "^7.0.2",
65
+ "@speclynx/apidom-ns-openapi-2": "^7.0.2",
66
+ "@speclynx/apidom-ns-openapi-3-0": "^7.0.2",
67
+ "@speclynx/apidom-ns-openapi-3-1": "^7.0.2",
68
+ "@speclynx/apidom-reference": "^7.0.2",
69
+ "@speclynx/apidom-traverse": "^7.0.2",
70
70
  "@swaggerexpert/arazzo-criterion": "^1.0.1",
71
71
  "@swaggerexpert/arazzo-runtime-expression": "^3.3.0",
72
72
  "@swaggerexpert/cookie": "^2.1.1",
73
73
  "@swaggerexpert/json-pointer": "^3.0.2",
74
74
  "@swaggerexpert/jsonpath": "^4.0.5",
75
75
  "@swaggerexpert/media-types": "^1.0.2",
76
- "@usearazzo/parser": "1.0.1-alpha.27",
77
- "@usearazzo/resolver": "1.0.1-alpha.27",
76
+ "@usearazzo/parser": "1.0.1-alpha.28",
77
+ "@usearazzo/resolver": "1.0.1-alpha.28",
78
78
  "@xmldom/xmldom": "^0.9.12",
79
79
  "fontoxpath": "^3.34.0",
80
80
  "ramda": "^0.32.0",
@@ -92,7 +92,7 @@
92
92
  "CHANGELOG.md"
93
93
  ],
94
94
  "devDependencies": {
95
- "swagger-client": "^3.38.4"
95
+ "swagger-client": "^3.39.0"
96
96
  },
97
- "gitHead": "c2017ebba31c3a95f6f6dd0ba75058f0a19a8d0d"
97
+ "gitHead": "a6908027adcc7a67f773a453431dae704eba60f7"
98
98
  }
@@ -5,19 +5,40 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _ramda = require("ramda");
8
9
  var _DocumentRegistry = _interopRequireDefault(require("./registry/DocumentRegistry.cjs"));
10
+ var _ArazzoDocumentRegistryProvider = _interopRequireDefault(require("./registry/providers/ArazzoDocumentRegistryProvider.cjs"));
11
+ var _OpenAPIDocumentRegistryProvider = _interopRequireDefault(require("./registry/providers/OpenAPIDocumentRegistryProvider.cjs"));
12
+ var _ArazzoWorkflowNormalizer = _interopRequireDefault(require("./normalizer/ArazzoWorkflowNormalizer.cjs"));
13
+ var _OpenAPIOperationNormalizer = _interopRequireDefault(require("./normalizer/OpenAPIOperationNormalizer.cjs"));
14
+ var _OpenAPI2OperationNormalizer = _interopRequireDefault(require("./normalizer/OpenAPI2OperationNormalizer.cjs"));
15
+ var _OpenAPI30OperationNormalizer = _interopRequireDefault(require("./normalizer/OpenAPI30OperationNormalizer.cjs"));
16
+ var _OpenAPI31OperationNormalizer = _interopRequireDefault(require("./normalizer/OpenAPI31OperationNormalizer.cjs"));
9
17
  var _OpenAPIOperationExecutor = _interopRequireDefault(require("./executor/OpenAPIOperationExecutor.cjs"));
10
18
  var _StepExecutor = _interopRequireDefault(require("./executor/StepExecutor.cjs"));
11
19
  var _WorkflowExecutor = _interopRequireDefault(require("./executor/WorkflowExecutor.cjs"));
12
20
  var _InvalidEntryDocumentError = _interopRequireDefault(require("./errors/InvalidEntryDocumentError.cjs"));
21
+ /**
22
+ * The options of ApiDOM reference the runner accepts: its `resolve` options,
23
+ * which mean the same for every building block that retrieves documents.
24
+ * `parse` and `dereference` options differ per building block, so the runner
25
+ * passes none of them on; set those on the building blocks themselves.
26
+ * @public
27
+ */
28
+
13
29
  /**
14
30
  * Options for {@link ArazzoRunner.load}.
15
31
  *
16
32
  * Every option is a seam of a building block the runner wires: `registry` is
17
33
  * the {@link DocumentRegistry} the documents load into (a fresh one with the
18
- * default providers when omitted), `httpClient` and `requestInterceptor` go to
34
+ * default providers when omitted), `reference` goes to everything the runner
35
+ * builds that retrieves documents, `httpClient` and `requestInterceptor` go to
19
36
  * the {@link OpenAPIOperationExecutor}, and the rest go to the
20
37
  * {@link WorkflowExecutor}.
38
+ *
39
+ * Retrieving documents and calling APIs are separate on purpose: `reference`
40
+ * never applies to API calls, and `httpClient` / `requestInterceptor` never
41
+ * apply to document retrieval, so credentials for one do not reach the other.
21
42
  * @public
22
43
  */
23
44
 
@@ -51,8 +72,12 @@ class ArazzoRunner {
51
72
  * document, or the given registry already backs another entry document
52
73
  */
53
74
  static async load(uri, options = {}) {
75
+ // `resolve` only, whatever else the given object carries
76
+ const referenceOptions = (0, _ramda.pick)(['resolve'], options.reference ?? {});
54
77
  const {
55
- registry = new _DocumentRegistry.default(),
78
+ registry = new _DocumentRegistry.default({
79
+ providers: [new _ArazzoDocumentRegistryProvider.default(referenceOptions), new _OpenAPIDocumentRegistryProvider.default(referenceOptions)]
80
+ }),
56
81
  ...rest
57
82
  } = options;
58
83
  // acquiring a second entry would pin it for good and, through the LRU
@@ -81,6 +106,7 @@ class ArazzoRunner {
81
106
  const {
82
107
  document,
83
108
  registry,
109
+ reference,
84
110
  httpClient,
85
111
  requestInterceptor,
86
112
  ...workflowExecutorOptions
@@ -93,9 +119,17 @@ class ArazzoRunner {
93
119
  uri: document.uri
94
120
  });
95
121
  }
122
+
123
+ // `resolve` only, whatever else the given object carries
124
+ const referenceOptions = (0, _ramda.pick)(['resolve'], reference ?? {});
96
125
  const operationExecutor = new _OpenAPIOperationExecutor.default({
97
126
  httpClient,
98
- requestInterceptor
127
+ requestInterceptor,
128
+ operationNormalizer: new _OpenAPIOperationNormalizer.default({
129
+ openapi2: new _OpenAPI2OperationNormalizer.default(referenceOptions),
130
+ openapi30: new _OpenAPI30OperationNormalizer.default(referenceOptions),
131
+ openapi31: new _OpenAPI31OperationNormalizer.default(referenceOptions)
132
+ })
99
133
  });
100
134
  const stepExecutor = new _StepExecutor.default({
101
135
  document,
@@ -108,7 +142,8 @@ class ArazzoRunner {
108
142
  ...workflowExecutorOptions,
109
143
  document,
110
144
  registry,
111
- stepExecutor
145
+ stepExecutor,
146
+ workflowNormalizer: new _ArazzoWorkflowNormalizer.default(referenceOptions)
112
147
  });
113
148
  }
114
149
 
@@ -1,16 +1,36 @@
1
+ import { pick } from 'ramda';
1
2
  import DocumentRegistry from "./registry/DocumentRegistry.mjs";
3
+ import ArazzoDocumentRegistryProvider from "./registry/providers/ArazzoDocumentRegistryProvider.mjs";
4
+ import OpenAPIDocumentRegistryProvider from "./registry/providers/OpenAPIDocumentRegistryProvider.mjs";
5
+ import ArazzoWorkflowNormalizer from "./normalizer/ArazzoWorkflowNormalizer.mjs";
6
+ import OpenAPIOperationNormalizer from "./normalizer/OpenAPIOperationNormalizer.mjs";
7
+ import OpenAPI2OperationNormalizer from "./normalizer/OpenAPI2OperationNormalizer.mjs";
8
+ import OpenAPI30OperationNormalizer from "./normalizer/OpenAPI30OperationNormalizer.mjs";
9
+ import OpenAPI31OperationNormalizer from "./normalizer/OpenAPI31OperationNormalizer.mjs";
2
10
  import OpenAPIOperationExecutor from "./executor/OpenAPIOperationExecutor.mjs";
3
11
  import StepExecutor from "./executor/StepExecutor.mjs";
4
12
  import WorkflowExecutor from "./executor/WorkflowExecutor.mjs";
5
13
  import InvalidEntryDocumentError from "./errors/InvalidEntryDocumentError.mjs";
14
+ /**
15
+ * The options of ApiDOM reference the runner accepts: its `resolve` options,
16
+ * which mean the same for every building block that retrieves documents.
17
+ * `parse` and `dereference` options differ per building block, so the runner
18
+ * passes none of them on; set those on the building blocks themselves.
19
+ * @public
20
+ */
6
21
  /**
7
22
  * Options for {@link ArazzoRunner.load}.
8
23
  *
9
24
  * Every option is a seam of a building block the runner wires: `registry` is
10
25
  * the {@link DocumentRegistry} the documents load into (a fresh one with the
11
- * default providers when omitted), `httpClient` and `requestInterceptor` go to
26
+ * default providers when omitted), `reference` goes to everything the runner
27
+ * builds that retrieves documents, `httpClient` and `requestInterceptor` go to
12
28
  * the {@link OpenAPIOperationExecutor}, and the rest go to the
13
29
  * {@link WorkflowExecutor}.
30
+ *
31
+ * Retrieving documents and calling APIs are separate on purpose: `reference`
32
+ * never applies to API calls, and `httpClient` / `requestInterceptor` never
33
+ * apply to document retrieval, so credentials for one do not reach the other.
14
34
  * @public
15
35
  */
16
36
  /**
@@ -42,8 +62,12 @@ class ArazzoRunner {
42
62
  * document, or the given registry already backs another entry document
43
63
  */
44
64
  static async load(uri, options = {}) {
65
+ // `resolve` only, whatever else the given object carries
66
+ const referenceOptions = pick(['resolve'], options.reference ?? {});
45
67
  const {
46
- registry = new DocumentRegistry(),
68
+ registry = new DocumentRegistry({
69
+ providers: [new ArazzoDocumentRegistryProvider(referenceOptions), new OpenAPIDocumentRegistryProvider(referenceOptions)]
70
+ }),
47
71
  ...rest
48
72
  } = options;
49
73
  // acquiring a second entry would pin it for good and, through the LRU
@@ -72,6 +96,7 @@ class ArazzoRunner {
72
96
  const {
73
97
  document,
74
98
  registry,
99
+ reference,
75
100
  httpClient,
76
101
  requestInterceptor,
77
102
  ...workflowExecutorOptions
@@ -84,9 +109,17 @@ class ArazzoRunner {
84
109
  uri: document.uri
85
110
  });
86
111
  }
112
+
113
+ // `resolve` only, whatever else the given object carries
114
+ const referenceOptions = pick(['resolve'], reference ?? {});
87
115
  const operationExecutor = new OpenAPIOperationExecutor({
88
116
  httpClient,
89
- requestInterceptor
117
+ requestInterceptor,
118
+ operationNormalizer: new OpenAPIOperationNormalizer({
119
+ openapi2: new OpenAPI2OperationNormalizer(referenceOptions),
120
+ openapi30: new OpenAPI30OperationNormalizer(referenceOptions),
121
+ openapi31: new OpenAPI31OperationNormalizer(referenceOptions)
122
+ })
90
123
  });
91
124
  const stepExecutor = new StepExecutor({
92
125
  document,
@@ -99,7 +132,8 @@ class ArazzoRunner {
99
132
  ...workflowExecutorOptions,
100
133
  document,
101
134
  registry,
102
- stepExecutor
135
+ stepExecutor,
136
+ workflowNormalizer: new ArazzoWorkflowNormalizer(referenceOptions)
103
137
  });
104
138
  }
105
139
 
@@ -163,7 +163,7 @@ class WorkflowExecutor {
163
163
  #maxWorkflowDepth;
164
164
  #now;
165
165
  #extractor = new _ArazzoWorkflowExtractor.default();
166
- #normalizer = new _ArazzoWorkflowNormalizer.default();
166
+ #normalizer;
167
167
  #outputResolver = new _OutputResolver.default();
168
168
  #parameterResolver = new _WorkflowParameterResolver.default();
169
169
  #stepExecutor;
@@ -174,6 +174,7 @@ class WorkflowExecutor {
174
174
  this.#document = options.document;
175
175
  this.#registry = options.registry;
176
176
  this.#workflowLocatorNormalizer = new _ArazzoWorkflowLocatorNormalizer.default(options.registry);
177
+ this.#normalizer = options.workflowNormalizer ?? new _ArazzoWorkflowNormalizer.default();
177
178
  this.#maxSteps = options.maxSteps ?? WorkflowExecutor.#DEFAULT_MAX_STEPS;
178
179
  this.#maxWorkflowDepth = options.maxWorkflowDepth ?? WorkflowExecutor.#DEFAULT_MAX_WORKFLOW_DEPTH;
179
180
  this.#now = options.now ?? WorkflowExecutor.#DEFAULT_NOW;
@@ -149,7 +149,7 @@ class WorkflowExecutor {
149
149
  #maxWorkflowDepth;
150
150
  #now;
151
151
  #extractor = new ArazzoWorkflowExtractor();
152
- #normalizer = new ArazzoWorkflowNormalizer();
152
+ #normalizer;
153
153
  #outputResolver = new OutputResolver();
154
154
  #parameterResolver = new WorkflowParameterResolver();
155
155
  #stepExecutor;
@@ -160,6 +160,7 @@ class WorkflowExecutor {
160
160
  this.#document = options.document;
161
161
  this.#registry = options.registry;
162
162
  this.#workflowLocatorNormalizer = new ArazzoWorkflowLocatorNormalizer(options.registry);
163
+ this.#normalizer = options.workflowNormalizer ?? new ArazzoWorkflowNormalizer();
163
164
  this.#maxSteps = options.maxSteps ?? WorkflowExecutor.#DEFAULT_MAX_STEPS;
164
165
  this.#maxWorkflowDepth = options.maxWorkflowDepth ?? WorkflowExecutor.#DEFAULT_MAX_WORKFLOW_DEPTH;
165
166
  this.#now = options.now ?? WorkflowExecutor.#DEFAULT_NOW;
package/types/runner.d.ts CHANGED
@@ -223,9 +223,14 @@ export declare class ArazzoRunnerError extends ApiDOMStructuredError {
223
223
  *
224
224
  * Every option is a seam of a building block the runner wires: `registry` is
225
225
  * the {@link DocumentRegistry} the documents load into (a fresh one with the
226
- * default providers when omitted), `httpClient` and `requestInterceptor` go to
226
+ * default providers when omitted), `reference` goes to everything the runner
227
+ * builds that retrieves documents, `httpClient` and `requestInterceptor` go to
227
228
  * the {@link OpenAPIOperationExecutor}, and the rest go to the
228
229
  * {@link WorkflowExecutor}.
230
+ *
231
+ * Retrieving documents and calling APIs are separate on purpose: `reference`
232
+ * never applies to API calls, and `httpClient` / `requestInterceptor` never
233
+ * apply to document retrieval, so credentials for one do not reach the other.
229
234
  * @public
230
235
  */
231
236
  export declare interface ArazzoRunnerLoadOptions extends Pick<OpenAPIOperationExecutorOptions, 'httpClient' | 'requestInterceptor'>, Pick<WorkflowExecutorOptions, 'maxSteps' | 'maxWorkflowDepth' | 'sleep' | 'now'> {
@@ -234,6 +239,20 @@ export declare interface ArazzoRunnerLoadOptions extends Pick<OpenAPIOperationEx
234
239
  * document: loading a different one into it throws.
235
240
  */
236
241
  readonly registry?: DocumentRegistry;
242
+ /**
243
+ * Options of ApiDOM reference, which retrieves the documents: the entry
244
+ * document, its source descriptions and every externally referenced
245
+ * document. Its `resolve` options say how, e.g. `resolverOpts.axiosConfig`
246
+ * for request headers or a TLS agent, or `resolvers` for a resolver list of
247
+ * your own.
248
+ *
249
+ * The runner gives them to the default registry providers and to the
250
+ * normalizers, which fetch external references lazily. A `registry` passed
251
+ * alongside is already configured through its own providers, so `reference`
252
+ * then reaches the normalizers only: give that registry's providers the
253
+ * same options.
254
+ */
255
+ readonly reference?: ArazzoRunnerReferenceOptions;
237
256
  }
238
257
 
239
258
  /**
@@ -251,6 +270,15 @@ export declare interface ArazzoRunnerOptions extends Omit<ArazzoRunnerLoadOption
251
270
  readonly registry: DocumentRegistry;
252
271
  }
253
272
 
273
+ /**
274
+ * The options of ApiDOM reference the runner accepts: its `resolve` options,
275
+ * which mean the same for every building block that retrieves documents.
276
+ * `parse` and `dereference` options differ per building block, so the runner
277
+ * passes none of them on; set those on the building blocks themselves.
278
+ * @public
279
+ */
280
+ export declare type ArazzoRunnerReferenceOptions = Pick<DocumentRegistryProviderOptions, 'resolve'>;
281
+
254
282
  /**
255
283
  * Index mapping a source description name to its element and canonical URI in
256
284
  * an Arazzo document.
@@ -2754,6 +2782,12 @@ export declare interface WorkflowExecutorOptions {
2754
2782
  * executor is agnostic to how a step reaches the live API.
2755
2783
  */
2756
2784
  readonly stepExecutor: StepExecutor;
2785
+ /**
2786
+ * Normalizes each workflow before it runs: dereferences it, which may fetch
2787
+ * externally referenced documents, and inherits its parameters and actions
2788
+ * into its steps. Defaults to a fresh {@link ArazzoWorkflowNormalizer}.
2789
+ */
2790
+ readonly workflowNormalizer?: ArazzoWorkflowNormalizer;
2757
2791
  /**
2758
2792
  * Upper bound on the number of step attempts in a single run — every attempt
2759
2793
  * of every step counts, including each `retry` and each entry into a