@mcp-abap-adt/adt-clients 36.0.0 → 36.0.1

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/README.md CHANGED
@@ -948,8 +948,10 @@ pair you choose. Two pure functions over the error are exported:
948
948
  - `extractSupportedAccept(error)` — the list SAP writes into its `406` body,
949
949
  `Accepted content types: …` (often empty; measured on an on-premise system).
950
950
  It reads no header and no other text.
951
- - `extractSupportedContentType(error)` — the types a `415` names (its headers
952
- and body; unchanged).
951
+ - `extractSupportedContentType(error)` — the list SAP writes into its `415`
952
+ body, `Supported Media Types: …` (absent from a bare `Unsupported Media
953
+ Type`; measured on an on-premise system). It reads no header — the `415`'s
954
+ own `content-type` is its error document's — and no other text (36.0.1).
953
955
 
954
956
  ```typescript
955
957
  import { extractSupportedAccept } from '@mcp-abap-adt/adt-clients';
@@ -1 +1 @@
1
- {"version":3,"file":"supportedMediaTypes.d.ts","sourceRoot":"","sources":["../../src/utils/supportedMediaTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAmBH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAsB/D;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAsCpE"}
1
+ {"version":3,"file":"supportedMediaTypes.d.ts","sourceRoot":"","sources":["../../src/utils/supportedMediaTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA0DH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAE/D;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAKpE"}
@@ -24,16 +24,31 @@ exports.extractSupportedContentType = extractSupportedContentType;
24
24
  * URI (`www.sap.com/abapxml`, `types/communicationframework`) on every 406.
25
25
  */
26
26
  const ACCEPTED_CONTENT_TYPES = 'Accepted content types:';
27
+ /**
28
+ * The text SAP's 415 puts before the types it accepts as a body.
29
+ *
30
+ * Measured on an on-premise system: SAP answers a 415 with its exception
31
+ * document (`content-type: application/xml`, the document's own type), whose
32
+ * message reads "Unsupported Media Type. Supported Media Types: …" — or a bare
33
+ * "Unsupported Media Type". Only that list is read. Until 36.0.0 the parser
34
+ * also read the response's headers and every `type/subtype` in the body, so it
35
+ * answered `application/xml` and two fragments of the document's namespace URI
36
+ * before the type SAP named.
37
+ */
38
+ const SUPPORTED_MEDIA_TYPES = 'Supported Media Types:';
27
39
  /** Where the list after the marker ends: the element, an attribute or the line. */
28
40
  const LIST_ENDS = ['<', '"', '\n'];
29
- function extractSupportedAccept(error) {
30
- const e = error;
31
- const data = e?.response?.data;
32
- const text = typeof data === 'string' ? data : data ? JSON.stringify(data) : '';
41
+ /** The body of a refusal as text. */
42
+ function bodyText(error) {
43
+ const data = error?.response?.data;
44
+ return typeof data === 'string' ? data : data ? JSON.stringify(data) : '';
45
+ }
46
+ /** Every type listed after `marker` in `text`, in order, each once. */
47
+ function listedAfter(text, marker) {
33
48
  const types = new Set();
34
- let at = text.indexOf(ACCEPTED_CONTENT_TYPES);
49
+ let at = text.indexOf(marker);
35
50
  while (at !== -1) {
36
- const start = at + ACCEPTED_CONTENT_TYPES.length;
51
+ const start = at + marker.length;
37
52
  let end = text.length;
38
53
  for (const stop of LIST_ENDS) {
39
54
  const found = text.indexOf(stop, start);
@@ -45,40 +60,16 @@ function extractSupportedAccept(error) {
45
60
  if (type)
46
61
  types.add(type);
47
62
  }
48
- at = text.indexOf(ACCEPTED_CONTENT_TYPES, end);
63
+ at = text.indexOf(marker, end);
49
64
  }
50
65
  return Array.from(types);
51
66
  }
67
+ function extractSupportedAccept(error) {
68
+ return listedAfter(bodyText(error), ACCEPTED_CONTENT_TYPES);
69
+ }
52
70
  function extractSupportedContentType(error) {
53
- const e = error;
54
- if (e?.response?.status !== 415) {
71
+ if (error?.response?.status !== 415) {
55
72
  return [];
56
73
  }
57
- const types = new Set();
58
- const headers = (e?.response?.headers || {});
59
- const headerCandidates = [
60
- headers['content-type'],
61
- headers['x-sap-adt-supported-content-type'],
62
- headers['supported-content-type'],
63
- ];
64
- for (const value of headerCandidates) {
65
- if (typeof value === 'string') {
66
- value
67
- .split(',')
68
- .map((entry) => entry.trim())
69
- .filter(Boolean)
70
- .forEach((entry) => {
71
- types.add(entry);
72
- });
73
- }
74
- }
75
- const data = e?.response?.data;
76
- const text = typeof data === 'string' ? data : data ? JSON.stringify(data) : '';
77
- if (text) {
78
- const matches = text.match(/[a-zA-Z0-9.+-]+\/[a-zA-Z0-9.+-]+(?:;[^,\s]+)?/g) || [];
79
- for (const match of matches) {
80
- types.add(match);
81
- }
82
- }
83
- return Array.from(types).filter(Boolean);
74
+ return listedAfter(bodyText(error), SUPPORTED_MEDIA_TYPES);
84
75
  }
@@ -140,7 +140,12 @@ nothing else. Until 35.x it also read five headers and every `type/subtype` in
140
140
  the body, which answered two fragments of the exception's namespace URI
141
141
  (`www.sap.com/abapxml`, `types/communicationframework`) for every `406`. A
142
142
  consumer that fed it a `406` carrying the types in a header gets `[]` now.
143
- `extractSupportedContentType` (`415`) is unchanged.
143
+ `extractSupportedContentType` (`415`) was unchanged in 36.0.0; since 36.0.1
144
+ it reads only SAP's list the same way — `Supported Media Types: …` in the
145
+ `415` body (measured on an on-premise system), no header and no other text.
146
+ Until then it answered the `415`'s own `content-type` (`application/xml`, the
147
+ error document's type) and the two namespace fragments before the type SAP
148
+ named.
144
149
 
145
150
  ## The completed pairs, measured
146
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/adt-clients",
3
- "version": "36.0.0",
3
+ "version": "36.0.1",
4
4
  "description": "ADT clients for SAP ABAP systems - AdtClient and AdtRuntimeClient",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",