@mcp-abap-adt/connection 19.1.0 → 20.0.0
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/CHANGELOG.md +49 -1
- package/README.md +72 -25
- package/dist/config/sapConfig.d.ts +6 -1
- package/dist/config/sapConfig.d.ts.map +1 -1
- package/dist/config/sapConfig.js +11 -0
- package/dist/connection/AbstractAbapConnection.d.ts +8 -2
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +17 -8
- package/dist/connection/CloudHttpTransport.js +2 -2
- package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
- package/dist/connection/CredentialAbapConnection.js +0 -1
- package/dist/connection/HttpTransport.d.ts +60 -18
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +46 -27
- package/dist/connection/IAdtTransport.d.ts +3 -2
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/createConnection.d.ts +20 -4
- package/dist/connection/createConnection.d.ts.map +1 -1
- package/dist/connection/createConnection.js +45 -28
- package/dist/connection/rfcConversation.d.ts +25 -25
- package/dist/connection/rfcConversation.d.ts.map +1 -1
- package/dist/connection/rfcConversation.js +24 -45
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/docs/INDEX.md +2 -0
- package/docs/MIGRATION-18.0.md +2 -0
- package/docs/MIGRATION-20.0.md +121 -0
- package/docs/MIGRATION-6.0.md +2 -0
- package/docs/USAGE.md +29 -12
- package/package.json +3 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Migration to 20.0
|
|
2
|
+
|
|
3
|
+
20.0.0 takes an RFC destination's address as the config states it. An RFC
|
|
4
|
+
config has no URL: it names the server it dials — one application server, or a
|
|
5
|
+
message server and a logon group — and its client and logon language, and the
|
|
6
|
+
SAP NW RFC SDK gets exactly that. Nothing of the address is derived from a URL,
|
|
7
|
+
nothing is defaulted, nothing is read from the environment.
|
|
8
|
+
|
|
9
|
+
It rests on `@mcp-abap-adt/interfaces-auth-sap` 4.0.0, where `ISapConfig` is a
|
|
10
|
+
union by connection type, and `@mcp-abap-adt/interfaces-adt-connection` 4.0.0,
|
|
11
|
+
where `getBaseUrl()` may answer `undefined`. Both are required (`^4.0.0`).
|
|
12
|
+
|
|
13
|
+
## What changed
|
|
14
|
+
|
|
15
|
+
- **An RFC config is an `ISapRfcConfig`** (exported here as `SapRfcConfig`):
|
|
16
|
+
`connectionType: 'rfc'`, `client`, `language`, and one address:
|
|
17
|
+
- an application server: `ashost` and `sysnr`;
|
|
18
|
+
- a message server: `mshost`, its service as `msserv`, `sysid` or both, and
|
|
19
|
+
`group`.
|
|
20
|
+
|
|
21
|
+
`saprouter` goes with either. An RFC config takes no `url`; an HTTP config
|
|
22
|
+
(`ISapHttpConfig`, exported as `SapHttpConfig`: `connectionType` `'http'` or
|
|
23
|
+
absent, and `url`) takes none of the RFC keys, `saprouter` and `language`
|
|
24
|
+
included. The compiler refuses a config that states two addresses, an
|
|
25
|
+
incomplete one, or a key of the other shape.
|
|
26
|
+
- **`rfcParamsFrom(config)` and `rfcConversationFrom(config)` take an
|
|
27
|
+
`ISapRfcConfig` and read it as stated.** Gone:
|
|
28
|
+
- the host taken from `url` and the system number from its port (`80NN` →
|
|
29
|
+
`NN`);
|
|
30
|
+
- `SAP_SYSNR` read from `process.env`;
|
|
31
|
+
- the defaults `client` `'000'`, `lang` `'EN'` and `group` `'PUBLIC'`;
|
|
32
|
+
- the two throws (no `url`; `mshost` without `msserv` or `sysid`): the type
|
|
33
|
+
proves the address complete.
|
|
34
|
+
|
|
35
|
+
`language` reaches the SDK as `lang`; `msserv`, `sysid` and `saprouter` are
|
|
36
|
+
there exactly when the config states them; no value is trimmed. The
|
|
37
|
+
provider's logon parameters are still spread over the address at each open:
|
|
38
|
+
where they name a key of the address, the logon's value is the one sent.
|
|
39
|
+
- **`RfcMessageServerParams`** is the "`msserv`, `sysid` or both" shape: a
|
|
40
|
+
union in which at least one of the two is a `string`.
|
|
41
|
+
- **`createConnection`: each spec takes its own config shape.** `CloudHttpSpec`
|
|
42
|
+
and `OnPremHttpSpec` take an `ISapHttpConfig`, `OnPremRfcSpec` an
|
|
43
|
+
`ISapRfcConfig`; the other shape does not compile. A combination of `system`
|
|
44
|
+
and `transport` that does not exist does not compile either; built past the
|
|
45
|
+
types, it is still refused with the fixed `TypeError`, as is any other value
|
|
46
|
+
passed as the spec. Only a `null` or `undefined` spec now fails with the
|
|
47
|
+
runtime's own `TypeError` rather than those fixed words.
|
|
48
|
+
- **`getBaseUrl(): Promise<string | undefined>`.** An HTTP connection answers
|
|
49
|
+
the origin of its `url`, as before. An RFC connection answers `undefined`: it
|
|
50
|
+
has no HTTP origin, and none is invented. Construction no longer parses a URL
|
|
51
|
+
for an RFC config.
|
|
52
|
+
- **The HTTP transports own their base URL.** `HttpTransport`,
|
|
53
|
+
`OnPremHttpTransport`, `LegacyOnPremHttpTransport` and `CloudHttpTransport`
|
|
54
|
+
take `baseUrl` as a required option (`{ client?, baseUrl }`). A path a caller
|
|
55
|
+
sends is put on it; the requests the wire makes on its own — the CSRF fetch,
|
|
56
|
+
the cloud preflight, the logoff — go to its origin, as they did.
|
|
57
|
+
- **Added: `httpClient`, an optional HTTP-transport option** (`{ client?, baseUrl,
|
|
58
|
+
httpClient? }`): an `HttpClientFactory` that builds the axios instance the
|
|
59
|
+
wire sends through from its agents and opens the Node request a logoff goes
|
|
60
|
+
out on. Left out, it is `nodeHttpClient`, what the wire used before — nothing
|
|
61
|
+
to do unless you want something of your own under the wire, such as a test
|
|
62
|
+
double. `createConnection` takes it too, beside `agentOptions`, for its
|
|
63
|
+
three HTTP combinations.
|
|
64
|
+
- **`IAdtSessionContext` has no `baseUrl`.** The connection hands a wire no
|
|
65
|
+
address; `establishSession` no longer reads `getBaseUrl()`.
|
|
66
|
+
- **`sapConfigSignature`** also carries `connectionType`, the RFC address
|
|
67
|
+
fields and `language`: two configs that dial different servers never share a
|
|
68
|
+
signature.
|
|
69
|
+
|
|
70
|
+
## What to do
|
|
71
|
+
|
|
72
|
+
**An RFC config states its address, client and language.** Remove `url`; add
|
|
73
|
+
what was derived or defaulted:
|
|
74
|
+
|
|
75
|
+
```diff
|
|
76
|
+
const config = {
|
|
77
|
+
- url: 'http://saphost:8042',
|
|
78
|
+
+ connectionType: 'rfc',
|
|
79
|
+
+ ashost: 'saphost', // the host the URL named
|
|
80
|
+
+ sysnr: '42', // the two digits of its 80NN port, or the SAP_SYSNR you set
|
|
81
|
+
+ client: '000', // if you relied on the default
|
|
82
|
+
+ language: 'EN', // if you relied on the default
|
|
83
|
+
authType: 'basic',
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
A message-server config adds `connectionType: 'rfc'`, `client`, `language`, and
|
|
88
|
+
`group: 'PUBLIC'` if it relied on that default; it removes `url`. `SAP_SYSNR`
|
|
89
|
+
in the environment is no longer read: put its value in `sysnr`.
|
|
90
|
+
|
|
91
|
+
Type the config you build for RFC as `SapRfcConfig` (or `ISapRfcConfig`) and
|
|
92
|
+
the one for HTTP as `SapHttpConfig`; a value of the whole union narrows on
|
|
93
|
+
`connectionType === 'rfc'` before it is handed to `rfcConversationFrom` or an
|
|
94
|
+
RFC spec. Data you read from outside the type system — an env file, the
|
|
95
|
+
environment, YAML — is yours to check before you build the config: this package
|
|
96
|
+
refuses nothing about a typed config.
|
|
97
|
+
|
|
98
|
+
**`getBaseUrl()` may answer `undefined`.** Narrow before you use it:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
const origin = await connection.getBaseUrl();
|
|
102
|
+
if (origin !== undefined) {
|
|
103
|
+
// an HTTP connection: its origin
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**A hand-built HTTP transport takes `baseUrl`:**
|
|
108
|
+
|
|
109
|
+
```diff
|
|
110
|
+
-new OnPremHttpTransport(() => ({}), logger, { client: config.client })
|
|
111
|
+
+new OnPremHttpTransport(() => ({}), logger, {
|
|
112
|
+
+ client: config.client,
|
|
113
|
+
+ baseUrl: config.url,
|
|
114
|
+
+})
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**A custom wire or test double reading `context.baseUrl`** takes its address
|
|
118
|
+
from its own construction instead: the session context no longer carries one.
|
|
119
|
+
|
|
120
|
+
If you only pass an HTTP config to `createConnection` or the connectors, there
|
|
121
|
+
is nothing to do.
|
package/docs/MIGRATION-6.0.md
CHANGED
|
@@ -153,6 +153,8 @@ about the certificate.
|
|
|
153
153
|
|
|
154
154
|
## Taking the RFC wire
|
|
155
155
|
|
|
156
|
+
> Superseded by 20.0.0: the address is stated, see [MIGRATION-20.0](./MIGRATION-20.0.md).
|
|
157
|
+
|
|
156
158
|
`connectionType: 'rfc'` is gone. The wire is an argument now, which is what it
|
|
157
159
|
always was in fact:
|
|
158
160
|
|
package/docs/USAGE.md
CHANGED
|
@@ -163,11 +163,14 @@ the factory picks the connector and the transport. Nothing is inferred:
|
|
|
163
163
|
| `cloud` | `http` | `AdtCloudConnector` over `CloudHttpTransport` |
|
|
164
164
|
| `onprem` | `http` | `AdtOnPremConnector` over `OnPremHttpTransport` |
|
|
165
165
|
| `onprem` | `legacy-http` | `AdtOnPremConnector` over `LegacyOnPremHttpTransport` (BASIS 7.40) |
|
|
166
|
-
| `onprem` | `rfc` | `AdtOnPremConnector` over `RfcTransport(rfcConversationFrom(
|
|
167
|
-
|
|
168
|
-
Any other combination
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
| `onprem` | `rfc` | `AdtOnPremConnector` over `RfcTransport(rfcConversationFrom(rfcConfig))` |
|
|
167
|
+
|
|
168
|
+
Any other combination does not compile, and one built past the types is
|
|
169
|
+
refused at construction with a `TypeError`. Each wire takes its own config
|
|
170
|
+
shape: the HTTP wires a `SapHttpConfig` (its `url`), RFC a `SapRfcConfig` (its
|
|
171
|
+
stated address, `client` and `language`, no URL). `client` and `baseUrl` (the
|
|
172
|
+
config's `url`) reach the HTTP wires from `config`. `agentOptions`,
|
|
173
|
+
`httpClient` (HTTP), `rfc`, `wireLogger`, `logger` and `sessionId` are passed through exactly as
|
|
171
174
|
you give them; whatever you leave out takes the constructors' own defaults.
|
|
172
175
|
|
|
173
176
|
**A new instance on every call.** One instance is one SAP session. After its
|
|
@@ -428,9 +431,9 @@ implied. Four things follow from it.
|
|
|
428
431
|
> tearDownAfter(conn); // ✅ checked
|
|
429
432
|
>
|
|
430
433
|
> const overRfc = new AdtOnPremConnector(
|
|
431
|
-
>
|
|
434
|
+
> rfcConfig, // a SapRfcConfig: its stated address, client and language
|
|
432
435
|
> provider,
|
|
433
|
-
> new RfcTransport(rfcConversationFrom(
|
|
436
|
+
> new RfcTransport(rfcConversationFrom(rfcConfig), logger),
|
|
434
437
|
> logger,
|
|
435
438
|
> );
|
|
436
439
|
> tearDownAfter(overRfc); // ✅ also checked — same class, different wire
|
|
@@ -930,7 +933,7 @@ interface AbapConnection {
|
|
|
930
933
|
makeAdtRequest<T = unknown, D = unknown>(
|
|
931
934
|
options: AbapRequestOptions,
|
|
932
935
|
): Promise<IAdtWireResponse<T, D>>;
|
|
933
|
-
getBaseUrl(): Promise<string>;
|
|
936
|
+
getBaseUrl(): Promise<string | undefined>; // undefined over RFC: no HTTP origin
|
|
934
937
|
setSessionType(type: "stateless" | "stateful"): void;
|
|
935
938
|
getSessionId(): string | null; // client-side conversation id
|
|
936
939
|
}
|
|
@@ -998,7 +1001,7 @@ What a request travels over, and everything true of that wire: addressing,
|
|
|
998
1001
|
establishing, and whatever session state it keeps.
|
|
999
1002
|
|
|
1000
1003
|
```text
|
|
1001
|
-
new HttpTransport(agentOptions?, logger?, { client?, baseUrl? })
|
|
1004
|
+
new HttpTransport(agentOptions?, logger?, { client?, baseUrl, httpClient? })
|
|
1002
1005
|
new RfcTransport(
|
|
1003
1006
|
connect: (logon: Readonly<Record<string, string>>) => IRfcConversation,
|
|
1004
1007
|
logger?,
|
|
@@ -1009,9 +1012,23 @@ new RfcTransport(
|
|
|
1009
1012
|
`HttpTransport` is the ordinary wire, and you name it because the connector
|
|
1010
1013
|
takes no default. In practice you name one of its two subclasses — the session
|
|
1011
1014
|
mechanism is what differs, and `OnPremHttpTransport` / `CloudHttpTransport` are
|
|
1012
|
-
what the connectors' type parameters admit.
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
+
what the connectors' type parameters admit. An HTTP wire is built with its
|
|
1016
|
+
`baseUrl`, required: a path a caller sends is put on it, and the requests the
|
|
1017
|
+
wire makes on its own — the CSRF fetch, the cloud preflight, the logoff — go to
|
|
1018
|
+
its origin. The connection hands the wire no address. `httpClient`, optional
|
|
1019
|
+
(20.0.0), is how the wire reaches the network — an `HttpClientFactory`:
|
|
1020
|
+
`create(agents)` returns the axios instance every request goes through, built
|
|
1021
|
+
from the wire's two pooled agents (`{ httpAgent, httpsAgent }`) when it first
|
|
1022
|
+
sends, and anew when a logon offers other TLS material; `logoffRequest(options,
|
|
1023
|
+
onResponse)` returns the Node `ClientRequest` a logoff goes out on, whose
|
|
1024
|
+
`finish` is the write `disconnect()` resolves at. Left out, it is the exported
|
|
1025
|
+
`nodeHttpClient` — axios over those agents, Node's `http` / `https` for the
|
|
1026
|
+
logoff — so nothing changes for a wire built without it. A test double goes
|
|
1027
|
+
here, under the wire, so what the wire adds to its own requests still runs.
|
|
1028
|
+
`RfcTransport` you build
|
|
1029
|
+
with `rfcConversationFrom(rfcConfig)`, which takes the RFC config's stated
|
|
1030
|
+
address, `client` and `language` as they are and loads the SAP NW RFC SDK only
|
|
1031
|
+
when a conversation opens.
|
|
1015
1032
|
|
|
1016
1033
|
**What the wire takes from the credential.** The provider writes it, the wire
|
|
1017
1034
|
carries it; the wire never reads `config.username` or `config.password`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-abap-adt/connection",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "20.0.0",
|
|
4
4
|
"description": "ABAP connection layer for MCP ABAP ADT server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@mcp-abap-adt/auth-errors": "^2.2.1",
|
|
55
|
-
"@mcp-abap-adt/interfaces-adt-connection": "^
|
|
55
|
+
"@mcp-abap-adt/interfaces-adt-connection": "^4.0.0",
|
|
56
56
|
"@mcp-abap-adt/interfaces-auth": "^7.5.0",
|
|
57
|
-
"@mcp-abap-adt/interfaces-auth-sap": "^
|
|
57
|
+
"@mcp-abap-adt/interfaces-auth-sap": "^4.0.0",
|
|
58
58
|
"@mcp-abap-adt/interfaces-network": "^2.0.1",
|
|
59
59
|
"@mcp-abap-adt/interfaces-utils": "^1.1.1",
|
|
60
60
|
"axios": "^1.16.0"
|