@mcp-abap-adt/connection 19.0.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +138 -1
  2. package/README.md +91 -25
  3. package/dist/config/sapConfig.d.ts +6 -1
  4. package/dist/config/sapConfig.d.ts.map +1 -1
  5. package/dist/config/sapConfig.js +11 -0
  6. package/dist/connection/AbstractAbapConnection.d.ts +8 -2
  7. package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
  8. package/dist/connection/AbstractAbapConnection.js +17 -8
  9. package/dist/connection/CloudHttpTransport.js +2 -2
  10. package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
  11. package/dist/connection/CredentialAbapConnection.js +0 -1
  12. package/dist/connection/HttpTransport.d.ts +91 -20
  13. package/dist/connection/HttpTransport.d.ts.map +1 -1
  14. package/dist/connection/HttpTransport.js +235 -46
  15. package/dist/connection/IAdtTransport.d.ts +3 -2
  16. package/dist/connection/IAdtTransport.d.ts.map +1 -1
  17. package/dist/connection/createConnection.d.ts +20 -4
  18. package/dist/connection/createConnection.d.ts.map +1 -1
  19. package/dist/connection/createConnection.js +45 -28
  20. package/dist/connection/rfcConversation.d.ts +25 -25
  21. package/dist/connection/rfcConversation.d.ts.map +1 -1
  22. package/dist/connection/rfcConversation.js +24 -45
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2 -1
  26. package/docs/INDEX.md +2 -0
  27. package/docs/INSTALLATION.md +7 -1
  28. package/docs/MIGRATION-18.0.md +2 -0
  29. package/docs/MIGRATION-20.0.md +121 -0
  30. package/docs/MIGRATION-6.0.md +2 -0
  31. package/docs/STATEFUL_SESSION_GUIDE.md +8 -0
  32. package/docs/USAGE.md +53 -14
  33. package/package.json +14 -19
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(config))` |
167
-
168
- Any other combination is refused at construction with a `TypeError`.
169
- `client` and `baseUrl` reach the HTTP wires from `config`. `agentOptions`,
170
- `rfc`, `wireLogger`, `logger` and `sessionId` are passed through exactly as
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
- > config,
434
+ > rfcConfig, // a SapRfcConfig: its stated address, client and language
432
435
  > provider,
433
- > new RfcTransport(rfcConversationFrom(config), logger),
436
+ > new RfcTransport(rfcConversationFrom(rfcConfig), logger),
434
437
  > logger,
435
438
  > );
436
439
  > tearDownAfter(overRfc); // ✅ also checked — same class, different wire
@@ -683,7 +686,9 @@ carry on over a session the caller never opened.
683
686
 
684
687
  In both cases the connector does **not** retry the request internally. Retrying
685
688
  blindly is what produced further orphaned locks in the field. That decision is
686
- yours.
689
+ yours. (The one resend the HTTP wire makes is of a request that never reached
690
+ an answer on a dead pooled socket — see "Kept-alive connections, and the one
691
+ resend" under the transports; it never resends a request the server answered.)
687
692
 
688
693
  **A lost session spends the instance** (since 16.0.0), as `disconnect()` does.
689
694
  After either of these, `connect()` and every request on the instance reject
@@ -863,7 +868,7 @@ try {
863
868
 
864
869
  ### Network Error Detection
865
870
 
866
- The connection automatically detects network-level errors and prevents unnecessary retry attempts. Network errors include:
871
+ The connection automatically detects network-level errors and prevents unnecessary retry attempts (the HTTP wire's one exception: a request whose pooled kept-alive socket ended before any byte of an answer is sent once more on a new connection — see "Kept-alive connections, and the one resend"; a second failure is the error). Network errors include:
867
872
 
868
873
  - `ECONNREFUSED` - Connection refused (server not reachable)
869
874
  - `ETIMEDOUT` - Connection timeout
@@ -928,7 +933,7 @@ interface AbapConnection {
928
933
  makeAdtRequest<T = unknown, D = unknown>(
929
934
  options: AbapRequestOptions,
930
935
  ): Promise<IAdtWireResponse<T, D>>;
931
- getBaseUrl(): Promise<string>;
936
+ getBaseUrl(): Promise<string | undefined>; // undefined over RFC: no HTTP origin
932
937
  setSessionType(type: "stateless" | "stateful"): void;
933
938
  getSessionId(): string | null; // client-side conversation id
934
939
  }
@@ -996,7 +1001,7 @@ What a request travels over, and everything true of that wire: addressing,
996
1001
  establishing, and whatever session state it keeps.
997
1002
 
998
1003
  ```text
999
- new HttpTransport(agentOptions?, logger?, { client?, baseUrl? })
1004
+ new HttpTransport(agentOptions?, logger?, { client?, baseUrl, httpClient? })
1000
1005
  new RfcTransport(
1001
1006
  connect: (logon: Readonly<Record<string, string>>) => IRfcConversation,
1002
1007
  logger?,
@@ -1007,9 +1012,23 @@ new RfcTransport(
1007
1012
  `HttpTransport` is the ordinary wire, and you name it because the connector
1008
1013
  takes no default. In practice you name one of its two subclasses — the session
1009
1014
  mechanism is what differs, and `OnPremHttpTransport` / `CloudHttpTransport` are
1010
- what the connectors' type parameters admit. `RfcTransport`
1011
- you build with `rfcConversationFrom(config)`, which derives `ashost` and `sysnr`
1012
- and loads the SAP NW RFC SDK only when a conversation opens.
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.
1013
1032
 
1014
1033
  **What the wire takes from the credential.** The provider writes it, the wire
1015
1034
  carries it; the wire never reads `config.username` or `config.password`.
@@ -1023,6 +1042,26 @@ carries it; the wire never reads `config.username` or `config.password`.
1023
1042
  (see [MIGRATION-11.0.md](./MIGRATION-11.0.md)). A later logon offering different material
1024
1043
  replaces the client; the cookie jar and CSRF token are the session's and stay.
1025
1044
  HTTP refuses logon parameters.
1045
+ - **Kept-alive connections, and the one resend** (19.0.1). The HTTP wires pool
1046
+ their sockets over `http:` and `https:` alike (Node.js's global-agent options:
1047
+ `keepAlive`, `lifo`, an idle socket closed after 5 s; your `agentOptions` win
1048
+ over `https:`, so `keepAlive: false` there turns the pool off). A server may
1049
+ close an idle kept-alive connection just as a request is written onto it; that
1050
+ request is lost unread. So, as a **named exception to "no retries"**: a request
1051
+ that went out on a socket taken from the pool, and whose socket ended with no
1052
+ byte of an answer read (`ECONNRESET` — "socket hang up" — or `EPIPE`), is sent
1053
+ once more, on a new connection, with the same cookies, session headers, CSRF
1054
+ token and body — the ABAP session and its locks are the cookies', not the
1055
+ socket's (measured on-premise, 2026-10-23). Nothing else is resent: not a
1056
+ request on a socket opened for it, not one that read any byte of an answer, not
1057
+ one after a redirect, not a stream body, not the logoff, and never a second
1058
+ time. The resend is visible only as a `debug` line in fixed words. **The risk,
1059
+ stated:** a server that read the request and died before writing a byte of its
1060
+ answer would run it twice; for a socket the server closed while it was idle,
1061
+ that does not happen. Without the resend, a cleanup `UNLOCK` died so and the
1062
+ enqueue lock stayed until SM12 (mcp-abap-adt#314).
1063
+ The logoff goes out on a connection of its own, with `Connection: close`,
1064
+ whatever your `agentOptions` say.
1026
1065
  - RFC takes logon parameters (a password, or SNC settings) on every conversation
1027
1066
  it opens, the session's own and each per-call one. RFC refuses TLS material,
1028
1067
  and a provider that writes no logon parameters (a bearer token) cannot log on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-abap-adt/connection",
3
- "version": "19.0.0",
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",
@@ -34,26 +34,27 @@
34
34
  "scripts": {
35
35
  "chrono": "node scripts/version-stats.mjs",
36
36
  "clean": "node scripts/clean.mjs",
37
- "lint": "npx biome check --write src scripts",
38
- "lint:check": "npx biome check src scripts --error-on-warnings",
39
- "test:shape": "jest src/__tests__/shapeCheck.test.ts",
40
- "format": "npx biome format --write src scripts",
41
- "build": "npm run --silent clean && npx biome check src scripts --diagnostic-level=error && npx tsc -p tsconfig.json && npm run --silent typecheck:scripts",
42
- "build:fast": "npx tsc -p tsconfig.json",
43
- "test": "npm run --silent check:docs && jest",
37
+ "lint": "biome check --write src scripts",
38
+ "lint:check": "biome check src scripts --error-on-warnings",
39
+ "test:shape": "node scripts/run-tests.mjs src/__tests__/shapeCheck.test.ts",
40
+ "format": "biome format --write src scripts",
41
+ "build": "npm run --silent clean && biome check src scripts --diagnostic-level=error && tsc -p tsconfig.json && npm run --silent typecheck:scripts",
42
+ "build:fast": "tsc -p tsconfig.json",
43
+ "test": "npm run --silent check:docs && node scripts/run-tests.mjs",
44
44
  "prepublishOnly": "npm run build && npm run lint:check && npm run test:shape && npm run check:docs && npm run --silent check:pack",
45
45
  "check:docs": "node scripts/check-docs.mjs",
46
- "typecheck:scripts": "npx tsc -p tsconfig.scripts.json",
47
- "check:pack": "node scripts/check-pack.mjs"
46
+ "typecheck:scripts": "tsc -p tsconfig.scripts.json",
47
+ "check:pack": "node scripts/check-pack.mjs",
48
+ "test:ci": "node scripts/run-tests.mjs"
48
49
  },
49
50
  "engines": {
50
51
  "node": "^22 || ^24 || ^26"
51
52
  },
52
53
  "dependencies": {
53
54
  "@mcp-abap-adt/auth-errors": "^2.2.1",
54
- "@mcp-abap-adt/interfaces-adt-connection": "^3.0.0",
55
+ "@mcp-abap-adt/interfaces-adt-connection": "^4.0.0",
55
56
  "@mcp-abap-adt/interfaces-auth": "^7.5.0",
56
- "@mcp-abap-adt/interfaces-auth-sap": "^3.4.0",
57
+ "@mcp-abap-adt/interfaces-auth-sap": "^4.0.0",
57
58
  "@mcp-abap-adt/interfaces-network": "^2.0.1",
58
59
  "@mcp-abap-adt/interfaces-utils": "^1.1.1",
59
60
  "axios": "^1.16.0"
@@ -64,15 +65,9 @@
64
65
  "devDependencies": {
65
66
  "@biomejs/biome": "^2.3.14",
66
67
  "@mcp-abap-adt/auth-providers": "^6.0.2",
67
- "@types/jest": "^30.0.0",
68
68
  "@types/node": "^25.2.3",
69
69
  "dotenv": "^17.3.1",
70
- "jest": "^30.2.0",
71
- "jest-util": "^30.2.0",
72
- "ts-jest": "^29.2.5",
73
70
  "typescript": "^5.9.2"
74
71
  },
75
- "overrides": {
76
- "brace-expansion": "^5.0.8"
77
- }
72
+ "allowScripts": {}
78
73
  }