@usearazzo/runner 1.0.1-alpha.31 → 1.0.1-alpha.32

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.31",
3
+ "version": "1.0.1-alpha.32",
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.2",
76
- "@usearazzo/parser": "1.0.1-alpha.31",
77
- "@usearazzo/resolver": "1.0.1-alpha.31",
76
+ "@usearazzo/parser": "1.0.1-alpha.32",
77
+ "@usearazzo/resolver": "1.0.1-alpha.32",
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.39.0"
96
96
  },
97
- "gitHead": "ff411e3bd2734c6f6c6d9b9cbe83e9b65dfe53f0"
97
+ "gitHead": "e19832b62ed4a938f9fdbd4c9072a94a247254d0"
98
98
  }
@@ -658,12 +658,19 @@ class OpenAPIOperationExecutor {
658
658
  finalized = (await this.#requestInterceptor?.(finalized, context)) ?? finalized;
659
659
  finalized = (await perCallInterceptor?.(finalized, context)) ?? finalized;
660
660
 
661
- // for multipart/form-data, remove the built content-type so the transport
662
- // sets one carrying the correct boundary
663
- const contentType = finalized.headers['content-type'] ?? finalized.headers['Content-Type'];
664
- if (typeof contentType === 'string' && /multipart\/form-data/i.test(contentType)) {
665
- delete finalized.headers['content-type'];
666
- delete finalized.headers['Content-Type'];
661
+ // for multipart/form-data, remove the content-type so the transport sets
662
+ // one carrying the boundary of the FormData it encodes. one that names a
663
+ // boundary is kept when the body is not a FormData: whoever built that
664
+ // body chose the boundary
665
+ const encodedByTransport = finalized.body instanceof FormData;
666
+ for (const name of Object.keys(finalized.headers)) {
667
+ const contentType = finalized.headers[name];
668
+ if (name.toLowerCase() !== 'content-type' || typeof contentType !== 'string') continue;
669
+ if (!/multipart\/form-data/i.test(contentType)) continue;
670
+ const boundary = (0, _mediaTypes.parse)(contentType, {
671
+ type: 'media-type'
672
+ }).tree?.parameters.boundary;
673
+ if (encodedByTransport || !boundary?.trim()) delete finalized.headers[name];
667
674
  }
668
675
  return finalized;
669
676
  }
@@ -4,7 +4,7 @@ import { isArrayElement, isObjectElement } from '@speclynx/apidom-datamodel';
4
4
  import { url as urlUtils } from '@speclynx/apidom-reference/configuration/empty';
5
5
  import { isSwaggerElement, isParameterElement } from '@speclynx/apidom-ns-openapi-2';
6
6
  import { serializeCookie, cookieNameLenientValidator, cookieValueStrictPercentEncoder } from '@swaggerexpert/cookie';
7
- import { identify, matches, selectBestMatch } from '@swaggerexpert/media-types';
7
+ import { identify, matches, parse, selectBestMatch } from '@swaggerexpert/media-types';
8
8
  import { isPlainObject } from 'ramda-adjunct';
9
9
 
10
10
  // @ts-expect-error vendored swagger-client bundle has no type declarations
@@ -646,12 +646,19 @@ class OpenAPIOperationExecutor {
646
646
  finalized = (await this.#requestInterceptor?.(finalized, context)) ?? finalized;
647
647
  finalized = (await perCallInterceptor?.(finalized, context)) ?? finalized;
648
648
 
649
- // for multipart/form-data, remove the built content-type so the transport
650
- // sets one carrying the correct boundary
651
- const contentType = finalized.headers['content-type'] ?? finalized.headers['Content-Type'];
652
- if (typeof contentType === 'string' && /multipart\/form-data/i.test(contentType)) {
653
- delete finalized.headers['content-type'];
654
- delete finalized.headers['Content-Type'];
649
+ // for multipart/form-data, remove the content-type so the transport sets
650
+ // one carrying the boundary of the FormData it encodes. one that names a
651
+ // boundary is kept when the body is not a FormData: whoever built that
652
+ // body chose the boundary
653
+ const encodedByTransport = finalized.body instanceof FormData;
654
+ for (const name of Object.keys(finalized.headers)) {
655
+ const contentType = finalized.headers[name];
656
+ if (name.toLowerCase() !== 'content-type' || typeof contentType !== 'string') continue;
657
+ if (!/multipart\/form-data/i.test(contentType)) continue;
658
+ const boundary = parse(contentType, {
659
+ type: 'media-type'
660
+ }).tree?.parameters.boundary;
661
+ if (encodedByTransport || !boundary?.trim()) delete finalized.headers[name];
655
662
  }
656
663
  return finalized;
657
664
  }
package/types/runner.d.ts CHANGED
@@ -904,7 +904,11 @@ export declare class ExtractionError extends ArazzoRunnerError {
904
904
  * Arazzo outcome judged by a step's `successCriteria`, never an error;
905
905
  * - throw (or reject) only on transport failure — the executor wraps the
906
906
  * error as a `ClientError`;
907
- * - honor `request.signal` when present.
907
+ * - honor `request.signal` when present;
908
+ * - encode a `FormData` body as `multipart/form-data` and set the
909
+ * `Content-Type` with its boundary, as `fetch` does — the executor removes
910
+ * the request's own multipart `Content-Type` for such a body, since only the
911
+ * encoder knows the boundary.
908
912
  *
909
913
  * Response normalization (content-type dispatch, header mapping) happens on
910
914
  * the executor side for every client, so `$response.body` semantics stay