@usearazzo/runner 1.0.1-alpha.13 → 1.0.1-alpha.14

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.13",
3
+ "version": "1.0.1-alpha.14",
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.13",
77
- "@usearazzo/resolver": "1.0.1-alpha.13",
76
+ "@usearazzo/parser": "1.0.1-alpha.14",
77
+ "@usearazzo/resolver": "1.0.1-alpha.14",
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": "41c018418a867e1469de0b2393929f7ec129c447"
97
+ "gitHead": "40a494596c0eed2f984fb87f544f3cf69488a6a7"
98
98
  }
@@ -75,6 +75,14 @@ class ParameterIdentity {
75
75
  if (location === undefined || (0, _apidomDatamodel.isNullElement)(location)) return undefined;
76
76
  return (0, _apidomDatamodel.isStringElement)(location) ? (0, _apidomCore.toValue)(location) : null;
77
77
  }
78
+
79
+ /**
80
+ * The locations the Parameter Object defines: Arazzo 1.0.1's closed set plus
81
+ * 1.1.0's `querystring`. 1.0.0's field description also listed `body`, which
82
+ * its own summary of locations did not; 1.0.1 removed it as an erratum, so it
83
+ * is not a location in any version (a payload is the step's `requestBody`).
84
+ */
85
+ static LOCATIONS = ['path', 'query', 'header', 'cookie', 'querystring'];
78
86
  name;
79
87
  location;
80
88
  constructor(name, location) {
@@ -82,6 +90,14 @@ class ParameterIdentity {
82
90
  this.location = location;
83
91
  }
84
92
 
93
+ /**
94
+ * Whether the location is one the Parameter Object defines. An absent or
95
+ * malformed location is not.
96
+ */
97
+ get hasDefinedLocation() {
98
+ return ParameterIdentity.LOCATIONS.includes(this.location);
99
+ }
100
+
85
101
  /**
86
102
  * Whether this and the other identity name the same parameter. A malformed
87
103
  * location equals nothing, its own duplicate included.
@@ -70,6 +70,14 @@ class ParameterIdentity {
70
70
  if (location === undefined || isNullElement(location)) return undefined;
71
71
  return isStringElement(location) ? toValue(location) : null;
72
72
  }
73
+
74
+ /**
75
+ * The locations the Parameter Object defines: Arazzo 1.0.1's closed set plus
76
+ * 1.1.0's `querystring`. 1.0.0's field description also listed `body`, which
77
+ * its own summary of locations did not; 1.0.1 removed it as an erratum, so it
78
+ * is not a location in any version (a payload is the step's `requestBody`).
79
+ */
80
+ static LOCATIONS = ['path', 'query', 'header', 'cookie', 'querystring'];
73
81
  name;
74
82
  location;
75
83
  constructor(name, location) {
@@ -77,6 +85,14 @@ class ParameterIdentity {
77
85
  this.location = location;
78
86
  }
79
87
 
88
+ /**
89
+ * Whether the location is one the Parameter Object defines. An absent or
90
+ * malformed location is not.
91
+ */
92
+ get hasDefinedLocation() {
93
+ return ParameterIdentity.LOCATIONS.includes(this.location);
94
+ }
95
+
80
96
  /**
81
97
  * Whether this and the other identity name the same parameter. A malformed
82
98
  * location equals nothing, its own duplicate included.
@@ -35,7 +35,11 @@ var _StepParameterResolver = _interopRequireDefault(require("./StepParameterReso
35
35
  * instead would let it capture *every* declared location of that name — see
36
36
  * `ParameterDelivery` for the lookup order that makes it so. A
37
37
  * non-string location throws for the same reason it deduplicates with nothing
38
- * in the normalizer: it names no location. And two *different* parameters the
38
+ * in the normalizer: it names no location. So does a location outside
39
+ * `path`, `query`, `header`, `cookie` and `querystring`: Arazzo 1.0.1 removed
40
+ * `in: body`, and forwarding one would let it still deliver a request body
41
+ * against an OpenAPI 2.0 operation, bypassing the step's `requestBody`, while
42
+ * an unknown location reaches nothing at all. And two *different* parameters the
39
43
  * map reports as colliding cannot both be delivered, so a collision throws
40
44
  * rather than silently dropping one — whether they collide on one key (the
41
45
  * scheme is not injective: a `querystring` parameter named `header.token` and
@@ -96,6 +100,13 @@ class OpenAPIOperationParameterResolver extends _StepParameterResolver.default {
96
100
  reason: 'malformed-location'
97
101
  });
98
102
  }
103
+ if (!identity.hasDefinedLocation) {
104
+ throw new _ResolverError.default(`Parameter "${name}" has location "${location}", which is not one of ` + `${_ParameterIdentity.default.LOCATIONS.join(', ')}`, {
105
+ ...scope,
106
+ target: name,
107
+ reason: 'invalid-location'
108
+ });
109
+ }
99
110
  const {
100
111
  key,
101
112
  outcome
@@ -28,7 +28,11 @@ import StepParameterResolver from "./StepParameterResolver.mjs";
28
28
  * instead would let it capture *every* declared location of that name — see
29
29
  * `ParameterDelivery` for the lookup order that makes it so. A
30
30
  * non-string location throws for the same reason it deduplicates with nothing
31
- * in the normalizer: it names no location. And two *different* parameters the
31
+ * in the normalizer: it names no location. So does a location outside
32
+ * `path`, `query`, `header`, `cookie` and `querystring`: Arazzo 1.0.1 removed
33
+ * `in: body`, and forwarding one would let it still deliver a request body
34
+ * against an OpenAPI 2.0 operation, bypassing the step's `requestBody`, while
35
+ * an unknown location reaches nothing at all. And two *different* parameters the
32
36
  * map reports as colliding cannot both be delivered, so a collision throws
33
37
  * rather than silently dropping one — whether they collide on one key (the
34
38
  * scheme is not injective: a `querystring` parameter named `header.token` and
@@ -89,6 +93,13 @@ class OpenAPIOperationParameterResolver extends StepParameterResolver {
89
93
  reason: 'malformed-location'
90
94
  });
91
95
  }
96
+ if (!identity.hasDefinedLocation) {
97
+ throw new ResolverError(`Parameter "${name}" has location "${location}", which is not one of ` + `${ParameterIdentity.LOCATIONS.join(', ')}`, {
98
+ ...scope,
99
+ target: name,
100
+ reason: 'invalid-location'
101
+ });
102
+ }
92
103
  const {
93
104
  key,
94
105
  outcome
package/types/runner.d.ts CHANGED
@@ -1196,7 +1196,11 @@ export declare interface OpenAPIOperationNormalizerOptions {
1196
1196
  * instead would let it capture *every* declared location of that name — see
1197
1197
  * `ParameterDelivery` for the lookup order that makes it so. A
1198
1198
  * non-string location throws for the same reason it deduplicates with nothing
1199
- * in the normalizer: it names no location. And two *different* parameters the
1199
+ * in the normalizer: it names no location. So does a location outside
1200
+ * `path`, `query`, `header`, `cookie` and `querystring`: Arazzo 1.0.1 removed
1201
+ * `in: body`, and forwarding one would let it still deliver a request body
1202
+ * against an OpenAPI 2.0 operation, bypassing the step's `requestBody`, while
1203
+ * an unknown location reaches nothing at all. And two *different* parameters the
1200
1204
  * map reports as colliding cannot both be delivered, so a collision throws
1201
1205
  * rather than silently dropping one — whether they collide on one key (the
1202
1206
  * scheme is not injective: a `querystring` parameter named `header.token` and