@mcp-abap-adt/connection 16.0.0 → 17.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 +44 -1
- package/README.md +74 -18
- package/dist/connection/AbstractAbapConnection.d.ts +51 -19
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +100 -32
- package/dist/connection/AdtCloudConnector.d.ts +6 -1
- package/dist/connection/AdtCloudConnector.d.ts.map +1 -1
- package/dist/connection/AdtCloudConnector.js +7 -2
- package/dist/connection/AdtOnPremConnector.d.ts +6 -1
- package/dist/connection/AdtOnPremConnector.d.ts.map +1 -1
- package/dist/connection/AdtOnPremConnector.js +7 -2
- package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
- package/dist/connection/CloudHttpTransport.js +2 -3
- package/dist/connection/CredentialAbapConnection.d.ts +3 -1
- package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
- package/dist/connection/CredentialAbapConnection.js +4 -2
- package/dist/connection/GenericWebSocketTransport.d.ts.map +1 -1
- package/dist/connection/GenericWebSocketTransport.js +7 -4
- package/dist/connection/HttpTransport.d.ts +19 -0
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +115 -5
- package/dist/connection/IAdtTransport.d.ts +34 -3
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.d.ts +7 -0
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +14 -3
- package/dist/connection/createConnection.d.ts +18 -0
- package/dist/connection/createConnection.d.ts.map +1 -1
- package/dist/connection/createConnection.js +8 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/docs/INDEX.md +2 -0
- package/docs/MIGRATION-17.0.md +119 -0
- package/docs/SCOPE.md +7 -2
- package/docs/STATEFUL_SESSION_GUIDE.md +12 -11
- package/docs/USAGE.md +88 -36
- package/package.json +1 -1
- package/dist/utils/timeouts.d.ts +0 -18
- package/dist/utils/timeouts.d.ts.map +0 -1
- package/dist/utils/timeouts.js +0 -37
package/docs/INDEX.md
CHANGED
|
@@ -15,6 +15,7 @@ mcp-abap-connection/
|
|
|
15
15
|
│ ├── INSTALLATION.md # Setup and installation guide
|
|
16
16
|
│ ├── USAGE.md # API documentation and examples
|
|
17
17
|
│ ├── MIGRATION-2.0.md # Moving to the explicit session lifecycle
|
|
18
|
+
│ ├── MIGRATION-17.0.md # no deadline of the package's own; an instance on an existing session
|
|
18
19
|
│ ├── MIGRATION-16.0.md # the request signal removed; disconnect() resolves once the logoff is written
|
|
19
20
|
│ ├── MIGRATION-15.0.md # interfaces-adt-connection 2: makeAdtRequest answers unknown
|
|
20
21
|
│ ├── MIGRATION-14.0.md # the sap-abap-auth CLI, open and commander are removed
|
|
@@ -47,6 +48,7 @@ mcp-abap-connection/
|
|
|
47
48
|
- 🧭 [Scope](./SCOPE.md) - What this package answers for, and only that
|
|
48
49
|
|
|
49
50
|
### Upgrading
|
|
51
|
+
- 🚚 [Migrating to 17.0.0](./MIGRATION-17.0.md) - `getTimeout`, `getTimeoutConfig` and `SAP_TIMEOUT_*` are gone; a request carries only the caller's `timeout`, and none inside a critical section; `createConnection({ …, session })` and `sessionCookies()`
|
|
50
52
|
- 🚚 [Migrating to 16.0.0](./MIGRATION-16.0.md) - the per-request `signal` and `ADT_REQUEST_ABORTED` are removed; `disconnect()` resolves once the logoff is written; `flushGoodbye()` waits for the answer
|
|
51
53
|
- 🚚 [Migrating to 15.0.0](./MIGRATION-15.0.md) - on `@mcp-abap-adt/interfaces-adt-connection` 2: `makeAdtRequest`'s answer is `unknown` unless its type is named
|
|
52
54
|
- 🚚 [Migrating to 14.0.0](./MIGRATION-14.0.md) - the `sap-abap-auth` CLI is removed; use `@mcp-abap-adt/auth-broker-cli`
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Migration to 17.0
|
|
2
|
+
|
|
3
|
+
17.0.0 does two things that [SCOPE.md](./SCOPE.md) lists: a request carries no
|
|
4
|
+
deadline but the caller's own, and an instance can be built on an existing SAP
|
|
5
|
+
session. For a consumer on 16.x that means the following.
|
|
6
|
+
|
|
7
|
+
## No deadline of the package's own
|
|
8
|
+
|
|
9
|
+
A client deadline closes the socket, and SAP then ends the synchronous request
|
|
10
|
+
that was running on it — a write in it is lost. So nothing this package sends
|
|
11
|
+
carries a deadline it chose.
|
|
12
|
+
|
|
13
|
+
### What changed
|
|
14
|
+
|
|
15
|
+
- **`getTimeout`, `getTimeoutConfig` and the `TimeoutConfig` type are no longer
|
|
16
|
+
exported**, and nothing reads `SAP_TIMEOUT_DEFAULT`, `SAP_TIMEOUT_CSRF`,
|
|
17
|
+
`SAP_TIMEOUT_LONG` or `SAP_TIMEOUT_CRITICAL` any more. Setting them changes
|
|
18
|
+
nothing.
|
|
19
|
+
- **A request carries the `timeout` you pass, unchanged, and nothing else.**
|
|
20
|
+
The CSRF fetch (in `connect()`, before a mutation, and the one a refused
|
|
21
|
+
token triggers) and the cloud session preflight carry none; before, each was
|
|
22
|
+
bounded by `SAP_TIMEOUT_CSRF` (15 s).
|
|
23
|
+
- **Inside a critical section a request carries no deadline at all — not even
|
|
24
|
+
yours.** Before, `beginCriticalSection()` raised the request's timeout to
|
|
25
|
+
`max(yours, SAP_TIMEOUT_CRITICAL)` (600 s by default). Now the `timeout` you
|
|
26
|
+
pass is not applied while a section is active, and applies again once the
|
|
27
|
+
outermost section ends. The critical section itself is unchanged.
|
|
28
|
+
- **`GenericWebSocketTransport.connect()` sets no timer** unless you pass
|
|
29
|
+
`connectTimeoutMs`; the 15 s default is gone. A `connectTimeoutMs` you pass is
|
|
30
|
+
honoured as before.
|
|
31
|
+
- **`IAdtEstablishContext.timeoutMs` is gone** from the transport seam.
|
|
32
|
+
- `ITimeoutConfig` in `@mcp-abap-adt/interfaces-adt-connection` is unchanged;
|
|
33
|
+
this package no longer uses it.
|
|
34
|
+
|
|
35
|
+
### What you do
|
|
36
|
+
|
|
37
|
+
- Replace `timeout: getTimeout('default')` (or `'csrf'`, `'long'`) with a number
|
|
38
|
+
of your own. `IAbapRequestOptions.timeout` is still a required field of the
|
|
39
|
+
contract; `0` means none over HTTP (axios reads it so), and the RFC wire does
|
|
40
|
+
not read it at all.
|
|
41
|
+
- Drop `SAP_TIMEOUT_*` from your environment, or read them yourself if you want
|
|
42
|
+
them to keep meaning something.
|
|
43
|
+
- If you relied on `connect()` giving up after 15 s against a host that does
|
|
44
|
+
not answer: it now waits for the network to fail. A bound on it is yours to
|
|
45
|
+
set around the call.
|
|
46
|
+
|
|
47
|
+
Before:
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
import { getTimeout } from '@mcp-abap-adt/connection';
|
|
51
|
+
await connection.makeAdtRequest({ method: 'GET', url, timeout: getTimeout('default') });
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
After:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { createConnection } from '@mcp-abap-adt/connection';
|
|
58
|
+
import type { SapConfig } from '@mcp-abap-adt/connection';
|
|
59
|
+
import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
60
|
+
|
|
61
|
+
const system: SapConfig = {
|
|
62
|
+
url: 'https://your-sap-system.com',
|
|
63
|
+
client: '100',
|
|
64
|
+
authType: 'basic',
|
|
65
|
+
username: 'your-username',
|
|
66
|
+
password: 'your-password',
|
|
67
|
+
};
|
|
68
|
+
const connection = createConnection({
|
|
69
|
+
system: 'onprem',
|
|
70
|
+
transport: 'http',
|
|
71
|
+
config: system,
|
|
72
|
+
credential: new BasicAuthProvider(system.username!, system.password!),
|
|
73
|
+
});
|
|
74
|
+
await connection.connect();
|
|
75
|
+
// Your own deadline, or 0 for none.
|
|
76
|
+
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery', timeout: 45_000 });
|
|
77
|
+
await connection.disconnect();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## An instance on an existing session
|
|
81
|
+
|
|
82
|
+
New, and nothing changes for a consumer that does not use it.
|
|
83
|
+
|
|
84
|
+
- **`sessionCookies()`** on every connector: the cookies of the instance's SAP
|
|
85
|
+
session as one `Cookie`-header string — `SAP_SESSIONID_*`, `sap-usercontext`,
|
|
86
|
+
`sap-contextid` when a stateful request opened a context, and whatever else
|
|
87
|
+
the server set to keep the session where it lives; everything the wire holds
|
|
88
|
+
but `sap-XSRF_*`. `null` before a session, after it ended, and over RFC. It
|
|
89
|
+
acts as the user while the session lives: keep it as a secret. The package
|
|
90
|
+
never logs it.
|
|
91
|
+
- **`createConnection({ …, session })`** (and a sixth constructor argument,
|
|
92
|
+
`session`, on `AdtOnPremConnector` / `AdtCloudConnector`) builds the instance
|
|
93
|
+
on that session. `connect()` does not log on: it makes one request in that
|
|
94
|
+
session without the credential — the CSRF fetch; on cloud with
|
|
95
|
+
`x-sap-security-session: use` and no preflight — following no redirect, and
|
|
96
|
+
SAP's answer says whether the session is alive. Alive: the session is the instance's, a stateful
|
|
97
|
+
request reaches its `sap-contextid`, and `disconnect()` logs it off as for any
|
|
98
|
+
instance. Gone (a `401`, a redirect — not followed, its target never asked —
|
|
99
|
+
or an answer that is not the session's):
|
|
100
|
+
`connect()` rejects with SAP's answer as it is, nothing is logged off, and the
|
|
101
|
+
instance is spent.
|
|
102
|
+
- **HTTP wires only.** Over RFC, `session` is refused by `createConnection` at
|
|
103
|
+
construction, and by the RFC wire at `connect()` when the connector was built
|
|
104
|
+
by hand, before anything is sent. An empty `session` is refused at
|
|
105
|
+
construction.
|
|
106
|
+
|
|
107
|
+
See [USAGE.md — An instance on an existing session](./USAGE.md#an-instance-on-an-existing-session-session-and-sessioncookies).
|
|
108
|
+
|
|
109
|
+
## A wire of your own
|
|
110
|
+
|
|
111
|
+
`IAdtTransport` has two new required members:
|
|
112
|
+
|
|
113
|
+
- `resume(context, session): Promise<void>` — take over the session `session`
|
|
114
|
+
names, without the credential, or reject with the server's answer. A wire
|
|
115
|
+
whose session no cookie names rejects without sending anything, as
|
|
116
|
+
`RfcTransport` does.
|
|
117
|
+
- `sessionCookies(): string | null` — what `resume()` takes, or `null`.
|
|
118
|
+
|
|
119
|
+
A wire built on `HttpTransport` inherits both.
|
package/docs/SCOPE.md
CHANGED
|
@@ -6,10 +6,15 @@
|
|
|
6
6
|
on-prem + HTTP, on-prem + legacy HTTP (BASIS 7.40), on-prem + RFC. The caller states
|
|
7
7
|
the system and the transport; nothing is inferred.
|
|
8
8
|
2. **One instance, one SAP session.** `connect()` logs on; the first authenticated request
|
|
9
|
-
opens the session. A new session is a new instance.
|
|
9
|
+
opens the session. A new session is a new instance. An instance may instead be built on
|
|
10
|
+
an existing session: `createConnection({ …, session })` takes that session's cookies;
|
|
11
|
+
`connect()` does not log on, and SAP's answer to the first request says whether the
|
|
12
|
+
session is alive. The cookies of the instance's session are readable (`sessionCookies()`),
|
|
13
|
+
for the caller to keep.
|
|
10
14
|
3. **Requests.** Each carries the credential the `IAuthProvider` hands over, the CSRF token
|
|
11
15
|
and the session's cookies. A request is sent stateful (`LOCK`, `UNLOCK`, activation) or
|
|
12
|
-
stateless; nothing else of the session is kept between requests.
|
|
16
|
+
stateless; nothing else of the session is kept between requests. A request carries no
|
|
17
|
+
deadline but the caller's own timeout.
|
|
13
18
|
4. **SAP's answer** reaches the caller as SAP gave it.
|
|
14
19
|
5. **`disconnect()`, once.** It sends the logoff when the instance holds a live
|
|
15
20
|
`SAP_SESSIONID` and resolves when the logoff is written. A `connect()` that failed after
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
> and context cookie. Another handler can flip it back while your lock is open. Nothing in this
|
|
6
6
|
> layer tracks locks: that belongs to `@mcp-abap-adt/adt-clients`, which holds the
|
|
7
7
|
> handles and pairs each LOCK with its UNLOCK per object. What the connection
|
|
8
|
-
> offers is `beginCriticalSection()` / `endCriticalSection()`,
|
|
9
|
-
>
|
|
8
|
+
> offers is `beginCriticalSection()` / `endCriticalSection()`, inside which a
|
|
9
|
+
> request carries no deadline at all, so nothing cuts it mid-span. See
|
|
10
10
|
> [USAGE.md — Session Lifecycle](./USAGE.md#session-lifecycle).
|
|
11
11
|
|
|
12
12
|
|
|
@@ -106,7 +106,6 @@ const logger = console;
|
|
|
106
106
|
import {
|
|
107
107
|
AdtOnPremConnector,
|
|
108
108
|
OnPremHttpTransport,
|
|
109
|
-
getTimeout,
|
|
110
109
|
} from '@mcp-abap-adt/connection';
|
|
111
110
|
import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
112
111
|
|
|
@@ -125,7 +124,7 @@ await connection.connect(); // required before any request
|
|
|
125
124
|
connection.setSessionType('stateful');
|
|
126
125
|
|
|
127
126
|
// Following requests use the stateful context until the mode is changed
|
|
128
|
-
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery' , timeout:
|
|
127
|
+
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery' , timeout: 0 });
|
|
129
128
|
|
|
130
129
|
// Switch back to stateless
|
|
131
130
|
connection.setSessionType('stateless');
|
|
@@ -280,16 +279,18 @@ server's own timeout releases them together.
|
|
|
280
279
|
This is what makes an aborted request expensive, and it is not what it looks
|
|
281
280
|
like. Aborting costs you **knowledge**, not a session: whether the modification
|
|
282
281
|
was applied becomes unknowable, and the handle `unlock` needs is gone, while the
|
|
283
|
-
lock is still very much held.
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
lock is still very much held. And SAP, seeing the socket close, ends the
|
|
283
|
+
synchronous request that was running on it — a write in it is lost. That — not
|
|
284
|
+
any teardown — is why a request inside `beginCriticalSection()` carries no
|
|
285
|
+
deadline at all for the duration of a `lock → modify → unlock` chain.
|
|
286
286
|
|
|
287
287
|
Since 8.0.0 you reach it through the contract rather than the class: it is
|
|
288
288
|
`ICriticalSection` in `@mcp-abap-adt/interfaces-adt-connection`, which this connection declares.
|
|
289
|
-
What it promises is narrow and worth stating exactly — inside a section
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
289
|
+
What it promises is narrow and worth stating exactly — inside a section no
|
|
290
|
+
deadline of this package's applies, and the caller's per-request `timeout` is
|
|
291
|
+
not applied either (17.0.0; before, a ten-minute `SAP_TIMEOUT_CRITICAL` ceiling
|
|
292
|
+
replaced it). Not that no request can be cut short: the network, a proxy or the
|
|
293
|
+
server's own limits end a request whatever a contract says.
|
|
293
294
|
|
|
294
295
|
A section keeps its session through a credential renewal: a mutation refused
|
|
295
296
|
with a 401 inside it is renewed and resent on the same session, never moved to
|
package/docs/USAGE.md
CHANGED
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
import {
|
|
20
20
|
AdtOnPremConnector,
|
|
21
21
|
OnPremHttpTransport,
|
|
22
|
-
getTimeout,
|
|
23
22
|
} from '@mcp-abap-adt/connection';
|
|
24
23
|
import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
25
24
|
import { SapConfig } from '@mcp-abap-adt/connection';
|
|
@@ -61,7 +60,7 @@ await connection.connect();
|
|
|
61
60
|
const response = await connection.makeAdtRequest({
|
|
62
61
|
method: 'GET',
|
|
63
62
|
url: '/sap/bc/adt/repository/nodestructure',
|
|
64
|
-
timeout:
|
|
63
|
+
timeout: 0,
|
|
65
64
|
});
|
|
66
65
|
|
|
67
66
|
console.log(response.data);
|
|
@@ -122,7 +121,6 @@ For SAP BTP ABAP Environment. Token refresh belongs to
|
|
|
122
121
|
import {
|
|
123
122
|
AdtCloudConnector,
|
|
124
123
|
CloudHttpTransport,
|
|
125
|
-
getTimeout,
|
|
126
124
|
} from '@mcp-abap-adt/connection';
|
|
127
125
|
import { TokenAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
128
126
|
|
|
@@ -151,7 +149,7 @@ await connection.connect(); // required: nothing is established implicitly
|
|
|
151
149
|
const response = await connection.makeAdtRequest({
|
|
152
150
|
method: 'GET',
|
|
153
151
|
url: '/sap/bc/adt/repository/nodestructure',
|
|
154
|
-
timeout:
|
|
152
|
+
timeout: 0,
|
|
155
153
|
});
|
|
156
154
|
```
|
|
157
155
|
|
|
@@ -177,6 +175,59 @@ you give them; whatever you leave out takes the constructors' own defaults.
|
|
|
177
175
|
`createConnection(...)`. The constructors still work for anything the
|
|
178
176
|
factory does not name.
|
|
179
177
|
|
|
178
|
+
### An instance on an existing session: `session` and `sessionCookies()`
|
|
179
|
+
|
|
180
|
+
`sessionCookies()` returns the cookies of the instance's SAP session as one
|
|
181
|
+
`Cookie`-header string: `SAP_SESSIONID_*`, `sap-usercontext`, `sap-contextid`
|
|
182
|
+
when a stateful request opened a context, and whatever else the server set to
|
|
183
|
+
keep the session where it lives — everything the wire holds but `sap-XSRF_*`,
|
|
184
|
+
which belongs to the CSRF token and is earned again. It is `null` before a
|
|
185
|
+
session, after the session ended, and over RFC. The string acts as the user
|
|
186
|
+
for as long as the session lives: keep it as a secret. The package never logs
|
|
187
|
+
it.
|
|
188
|
+
|
|
189
|
+
Hand it back as `session` to build an instance on that session instead of a
|
|
190
|
+
new one (HTTP wires only — over RFC, whose session is a conversation, it is
|
|
191
|
+
refused at construction; an empty string is refused too):
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
const resumed = createConnection({
|
|
195
|
+
system: 'onprem',
|
|
196
|
+
transport: 'http',
|
|
197
|
+
config,
|
|
198
|
+
credential: new BasicAuthProvider(config.username, config.password),
|
|
199
|
+
session: keptCookies, // what an earlier instance's sessionCookies() returned
|
|
200
|
+
});
|
|
201
|
+
await resumed.connect();
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
What `connect()` does then:
|
|
205
|
+
|
|
206
|
+
1. It prepares the credential as always, and **logs on nowhere**.
|
|
207
|
+
2. It makes **one request in that session, without the credential**: the CSRF
|
|
208
|
+
fetch (`GET /sap/bc/adt/core/discovery` with `x-csrf-token: fetch`, the
|
|
209
|
+
fallback `/sap/bc/adt/discovery` on a `404`; on cloud with
|
|
210
|
+
`x-sap-security-session: use`, and no preflight), following no redirect.
|
|
211
|
+
Without the credential,
|
|
212
|
+
because a credential on that request would open a NEW session when the old
|
|
213
|
+
one is gone (measured: a dead session cookie with a good password gets a new
|
|
214
|
+
`SAP_SESSIONID`).
|
|
215
|
+
3. **Alive** — a CSRF token, and the `SAP_SESSIONID` that was handed over,
|
|
216
|
+
unchanged: the session is this instance's. A stateful request reaches the
|
|
217
|
+
ABAP context `sap-contextid` names (an `UNLOCK` lands in the old context);
|
|
218
|
+
later requests carry the credential as usual; a session lost later is
|
|
219
|
+
reported as for any instance (`ADT_SESSION_REPLACED`); `disconnect()` logs it
|
|
220
|
+
off as for any instance.
|
|
221
|
+
4. **Gone** — a `401`, a redirect (a `3xx` is not the session answering; it is
|
|
222
|
+
not followed, so its target is never asked and nothing it sets is taken), or
|
|
223
|
+
any answer that is not the session's (another `SAP_SESSIONID`, none, no
|
|
224
|
+
token): `connect()` rejects with SAP's answer as it is (`error.response`,
|
|
225
|
+
with the status and headers SAP gave). Nothing was opened, so nothing is logged off, and the
|
|
226
|
+
instance is spent.
|
|
227
|
+
|
|
228
|
+
The credential's logon moment (`establish`, which brings TLS material) is
|
|
229
|
+
offered only after the session answered, so it never rides on that request.
|
|
230
|
+
|
|
180
231
|
Wrapping the connection with your own HTTP request logging stays with the
|
|
181
232
|
consumer. That is a policy of yours, typically read from your environment, not
|
|
182
233
|
a property of the wire. The factory passes `wireLogger` to the transport,
|
|
@@ -192,7 +243,6 @@ them is refused with `ADT_NOT_CONNECTED`.
|
|
|
192
243
|
### GET Request
|
|
193
244
|
|
|
194
245
|
```typescript
|
|
195
|
-
import { getTimeout } from '@mcp-abap-adt/connection';
|
|
196
246
|
// The body is XML: name its type, or the answer's `data` is `unknown`.
|
|
197
247
|
const packages = await connection.makeAdtRequest<string>({
|
|
198
248
|
method: 'GET',
|
|
@@ -202,14 +252,13 @@ const packages = await connection.makeAdtRequest<string>({
|
|
|
202
252
|
parent_type: 'DEVC/K',
|
|
203
253
|
withShortDescriptions: 'true',
|
|
204
254
|
},
|
|
205
|
-
timeout:
|
|
255
|
+
timeout: 0,
|
|
206
256
|
});
|
|
207
257
|
```
|
|
208
258
|
|
|
209
259
|
### POST Request (Create Object)
|
|
210
260
|
|
|
211
261
|
```typescript
|
|
212
|
-
import { getTimeout } from '@mcp-abap-adt/connection';
|
|
213
262
|
const classXml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
214
263
|
<class:abapClass xmlns:class="http://www.sap.com/adt/oo/classes"
|
|
215
264
|
class:name="ZCL_MY_CLASS">
|
|
@@ -222,7 +271,7 @@ const response = await connection.makeAdtRequest({
|
|
|
222
271
|
headers: { 'Content-Type': 'application/xml' },
|
|
223
272
|
data: classXml,
|
|
224
273
|
params: { package: 'ZTEST' },
|
|
225
|
-
timeout:
|
|
274
|
+
timeout: 0,
|
|
226
275
|
});
|
|
227
276
|
```
|
|
228
277
|
|
|
@@ -231,26 +280,24 @@ const response = await connection.makeAdtRequest({
|
|
|
231
280
|
```typescript
|
|
232
281
|
const classSourceCode = 'CLASS zcl_my_class DEFINITION ...';
|
|
233
282
|
const lockToken = 'the handle the lock call returned';
|
|
234
|
-
import { getTimeout } from '@mcp-abap-adt/connection';
|
|
235
283
|
await connection.makeAdtRequest({
|
|
236
284
|
method: 'PUT',
|
|
237
285
|
url: '/sap/bc/adt/oo/classes/zcl_my_class/source/main',
|
|
238
286
|
headers: { 'Content-Type': 'text/plain' },
|
|
239
287
|
data: classSourceCode, // the new source, as a string
|
|
240
288
|
params: { lockHandle: lockToken }, // from the lock you took first
|
|
241
|
-
timeout:
|
|
289
|
+
timeout: 0,
|
|
242
290
|
});
|
|
243
291
|
```
|
|
244
292
|
|
|
245
293
|
### DELETE Request
|
|
246
294
|
|
|
247
295
|
```typescript
|
|
248
|
-
import { getTimeout } from '@mcp-abap-adt/connection';
|
|
249
296
|
await connection.makeAdtRequest({
|
|
250
297
|
method: 'DELETE',
|
|
251
298
|
url: '/sap/bc/adt/oo/classes/zcl_my_class',
|
|
252
299
|
params: { deleteOption: 'deleteAndLocalVersions' },
|
|
253
|
-
timeout:
|
|
300
|
+
timeout: 0,
|
|
254
301
|
});
|
|
255
302
|
```
|
|
256
303
|
|
|
@@ -261,7 +308,7 @@ await connection.makeAdtRequest({
|
|
|
261
308
|
By default, connections are stateless - each request gets fresh cookies and CSRF tokens:
|
|
262
309
|
|
|
263
310
|
```typescript
|
|
264
|
-
import { AdtOnPremConnector, OnPremHttpTransport
|
|
311
|
+
import { AdtOnPremConnector, OnPremHttpTransport } from '@mcp-abap-adt/connection';
|
|
265
312
|
import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
266
313
|
const connection = new AdtOnPremConnector(
|
|
267
314
|
config,
|
|
@@ -275,7 +322,7 @@ const connection = new AdtOnPremConnector(
|
|
|
275
322
|
await connection.connect();
|
|
276
323
|
|
|
277
324
|
// Each request is independent
|
|
278
|
-
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery' , timeout:
|
|
325
|
+
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery' , timeout: 0 });
|
|
279
326
|
```
|
|
280
327
|
|
|
281
328
|
### Stateful Mode (HTTP Context)
|
|
@@ -287,7 +334,7 @@ writes from running in the lock context and failing with PAK/058 or an invalid
|
|
|
287
334
|
lock handle. See [HTTP context isolation](./STATEFUL_SESSION_GUIDE.md#http-context-isolation-931).
|
|
288
335
|
|
|
289
336
|
```typescript
|
|
290
|
-
import { AdtOnPremConnector, OnPremHttpTransport
|
|
337
|
+
import { AdtOnPremConnector, OnPremHttpTransport } from '@mcp-abap-adt/connection';
|
|
291
338
|
import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
292
339
|
const connection = new AdtOnPremConnector(
|
|
293
340
|
config,
|
|
@@ -304,7 +351,7 @@ await connection.connect();
|
|
|
304
351
|
connection.setSessionType('stateful');
|
|
305
352
|
|
|
306
353
|
// Following requests use the stateful context until the mode is changed
|
|
307
|
-
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery' , timeout:
|
|
354
|
+
await connection.makeAdtRequest({ method: 'GET', url: '/sap/bc/adt/discovery' , timeout: 0 });
|
|
308
355
|
|
|
309
356
|
// Check session mode
|
|
310
357
|
console.log(connection.getSessionMode()); // 'stateful'
|
|
@@ -435,12 +482,11 @@ side instead of a condition that silently stops matching. The codes live in
|
|
|
435
482
|
|
|
436
483
|
```typescript
|
|
437
484
|
import { ADT_SESSION_ERROR } from '@mcp-abap-adt/interfaces-adt-connection';
|
|
438
|
-
import { getTimeout } from '@mcp-abap-adt/connection';
|
|
439
485
|
|
|
440
486
|
const options = {
|
|
441
487
|
method: 'GET',
|
|
442
488
|
url: '/sap/bc/adt/repository/nodestructure',
|
|
443
|
-
timeout:
|
|
489
|
+
timeout: 0,
|
|
444
490
|
};
|
|
445
491
|
|
|
446
492
|
try {
|
|
@@ -555,10 +601,11 @@ The connection does **not** track locks — it does not know one exists, what
|
|
|
555
601
|
object it covers, or what would release it. Pairing every LOCK with its UNLOCK is
|
|
556
602
|
`@mcp-abap-adt/adt-clients`' job, and it does it per object in its lock registry.
|
|
557
603
|
|
|
558
|
-
What this layer owns is
|
|
559
|
-
|
|
560
|
-
leaves an operation whose outcome you cannot
|
|
561
|
-
succeeded server-side, with a handle you
|
|
604
|
+
What this layer owns is that no deadline cuts such a span. A client deadline
|
|
605
|
+
closes the socket, and SAP then ends the synchronous request running on it — a
|
|
606
|
+
write in it lost — and leaves you an operation whose outcome you cannot
|
|
607
|
+
determine: a `LOCK` that may have succeeded server-side, with a handle you
|
|
608
|
+
never received:
|
|
562
609
|
|
|
563
610
|
```typescript
|
|
564
611
|
connection.beginCriticalSection();
|
|
@@ -571,16 +618,21 @@ try {
|
|
|
571
618
|
}
|
|
572
619
|
```
|
|
573
620
|
|
|
574
|
-
While a section is active
|
|
575
|
-
`
|
|
576
|
-
|
|
621
|
+
While a section is active a request carries **no deadline at all** — not the
|
|
622
|
+
`timeout` you passed either, and no ceiling of the package's own (17.0.0
|
|
623
|
+
removed `SAP_TIMEOUT_CRITICAL`). The pair is reference-counted, so nesting is
|
|
577
624
|
safe.
|
|
578
625
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
locked object. Those requests share one ABAP session, and
|
|
582
|
-
session in the same uncertain state during a span someone declared
|
|
583
|
-
precisely to avoid it.
|
|
626
|
+
This is **connection-wide**: while any section is active, every request on that
|
|
627
|
+
connection goes without a deadline, including one that has nothing to do with
|
|
628
|
+
the locked object. Those requests share one ABAP session, and a cut one leaves
|
|
629
|
+
that session in the same uncertain state during a span someone declared
|
|
630
|
+
sensitive precisely to avoid it.
|
|
631
|
+
|
|
632
|
+
Outside a section a request carries the `timeout` you passed, unchanged, and
|
|
633
|
+
nothing else: the CSRF fetch and the cloud preflight carry none either.
|
|
634
|
+
`IAbapRequestOptions.timeout` is still a required field of the contract; `0` is
|
|
635
|
+
none over HTTP, and the RFC wire reads it not at all.
|
|
584
636
|
|
|
585
637
|
### When the session is lost
|
|
586
638
|
|
|
@@ -647,7 +699,7 @@ console.log(connectionWithOwnId.getSessionId()); // 'custom-session-123'
|
|
|
647
699
|
Dynamically switch between stateful and stateless modes:
|
|
648
700
|
|
|
649
701
|
```typescript
|
|
650
|
-
import { AdtOnPremConnector, OnPremHttpTransport
|
|
702
|
+
import { AdtOnPremConnector, OnPremHttpTransport } from '@mcp-abap-adt/connection';
|
|
651
703
|
import { BasicAuthProvider } from '@mcp-abap-adt/auth-providers';
|
|
652
704
|
// Start in stateless mode (default)
|
|
653
705
|
const connection = new AdtOnPremConnector(
|
|
@@ -665,7 +717,7 @@ await connection.connect();
|
|
|
665
717
|
connection.setSessionType('stateful');
|
|
666
718
|
|
|
667
719
|
// Do stateful operations...
|
|
668
|
-
await connection.makeAdtRequest({ method: 'POST', url: '...' , timeout:
|
|
720
|
+
await connection.makeAdtRequest({ method: 'POST', url: '...' , timeout: 0 });
|
|
669
721
|
|
|
670
722
|
// Switch back to stateless
|
|
671
723
|
connection.setSessionType('stateless');
|
|
@@ -746,12 +798,11 @@ const connection = new AdtOnPremConnector(
|
|
|
746
798
|
### Basic Error Handling
|
|
747
799
|
|
|
748
800
|
```typescript
|
|
749
|
-
import { getTimeout } from '@mcp-abap-adt/connection';
|
|
750
801
|
try {
|
|
751
802
|
await connection.makeAdtRequest({
|
|
752
803
|
method: 'GET',
|
|
753
804
|
url: '/sap/bc/adt/invalid/endpoint',
|
|
754
|
-
timeout:
|
|
805
|
+
timeout: 0,
|
|
755
806
|
});
|
|
756
807
|
} catch (error) {
|
|
757
808
|
const failure = error as {
|
|
@@ -784,12 +835,11 @@ When these errors occur, the connection:
|
|
|
784
835
|
3. **Logs the error** with full context for troubleshooting
|
|
785
836
|
|
|
786
837
|
```typescript
|
|
787
|
-
import { getTimeout } from '@mcp-abap-adt/connection';
|
|
788
838
|
try {
|
|
789
839
|
await connection.makeAdtRequest({
|
|
790
840
|
method: 'GET',
|
|
791
841
|
url: '/sap/bc/adt/repository/nodestructure',
|
|
792
|
-
timeout:
|
|
842
|
+
timeout: 0,
|
|
793
843
|
});
|
|
794
844
|
} catch (error) {
|
|
795
845
|
const failure = error as {
|
|
@@ -862,6 +912,7 @@ class AdtOnPremConnector<
|
|
|
862
912
|
transport: TTransport,
|
|
863
913
|
logger?: ILogger | null,
|
|
864
914
|
sessionId?: string,
|
|
915
|
+
session?: string, // an existing session to take over; HTTP wires only
|
|
865
916
|
);
|
|
866
917
|
}
|
|
867
918
|
|
|
@@ -875,6 +926,7 @@ class AdtCloudConnector<
|
|
|
875
926
|
transport: TTransport,
|
|
876
927
|
logger?: ILogger | null,
|
|
877
928
|
sessionId?: string,
|
|
929
|
+
session?: string, // an existing session to take over
|
|
878
930
|
);
|
|
879
931
|
}
|
|
880
932
|
```
|
package/package.json
CHANGED
package/dist/utils/timeouts.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ITimeoutConfig } from '@mcp-abap-adt/interfaces-adt-connection';
|
|
2
|
-
export type TimeoutConfig = ITimeoutConfig;
|
|
3
|
-
export declare function getTimeoutConfig(): ITimeoutConfig;
|
|
4
|
-
export declare function getTimeout(type?: 'default' | 'csrf' | 'long' | number): number;
|
|
5
|
-
/**
|
|
6
|
-
* Large ceiling timeout applied while a connection is inside an uninterruptible
|
|
7
|
-
* critical section (lock → modify → unlock). A short per-request timeout must
|
|
8
|
-
* not abort such a request mid-flight — not because aborting ends anything on
|
|
9
|
-
* the server, but because it ends what the CLIENT knows: the modification may
|
|
10
|
-
* or may not have been applied, and the handle `unlock` needs is gone, while
|
|
11
|
-
* the lock and the ABAP session holding it sit there until that server-side
|
|
12
|
-
* idle timeout, which this side can neither read nor influence.
|
|
13
|
-
* Configurable via SAP_TIMEOUT_CRITICAL (ms).
|
|
14
|
-
* Default 600000 (10 minutes) — a generous ceiling that still guards against a
|
|
15
|
-
* permanently dead socket hanging forever.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getCriticalSectionTimeout(): number;
|
|
18
|
-
//# sourceMappingURL=timeouts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeouts.d.ts","sourceRoot":"","sources":["../../src/utils/timeouts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAG9E,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;AAE3C,wBAAgB,gBAAgB,IAAI,cAAc,CAajD;AAED,wBAAgB,UAAU,CACxB,IAAI,GAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAkB,GACrD,MAAM,CAOR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAElD"}
|
package/dist/utils/timeouts.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTimeoutConfig = getTimeoutConfig;
|
|
4
|
-
exports.getTimeout = getTimeout;
|
|
5
|
-
exports.getCriticalSectionTimeout = getCriticalSectionTimeout;
|
|
6
|
-
function getTimeoutConfig() {
|
|
7
|
-
const defaultTimeout = parseInt(process.env.SAP_TIMEOUT_DEFAULT || '45000', 10);
|
|
8
|
-
const csrfTimeout = parseInt(process.env.SAP_TIMEOUT_CSRF || '15000', 10);
|
|
9
|
-
const longTimeout = parseInt(process.env.SAP_TIMEOUT_LONG || '60000', 10);
|
|
10
|
-
return {
|
|
11
|
-
default: defaultTimeout,
|
|
12
|
-
csrf: csrfTimeout,
|
|
13
|
-
long: longTimeout,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function getTimeout(type = 'default') {
|
|
17
|
-
if (typeof type === 'number') {
|
|
18
|
-
return type;
|
|
19
|
-
}
|
|
20
|
-
const config = getTimeoutConfig();
|
|
21
|
-
return config[type];
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Large ceiling timeout applied while a connection is inside an uninterruptible
|
|
25
|
-
* critical section (lock → modify → unlock). A short per-request timeout must
|
|
26
|
-
* not abort such a request mid-flight — not because aborting ends anything on
|
|
27
|
-
* the server, but because it ends what the CLIENT knows: the modification may
|
|
28
|
-
* or may not have been applied, and the handle `unlock` needs is gone, while
|
|
29
|
-
* the lock and the ABAP session holding it sit there until that server-side
|
|
30
|
-
* idle timeout, which this side can neither read nor influence.
|
|
31
|
-
* Configurable via SAP_TIMEOUT_CRITICAL (ms).
|
|
32
|
-
* Default 600000 (10 minutes) — a generous ceiling that still guards against a
|
|
33
|
-
* permanently dead socket hanging forever.
|
|
34
|
-
*/
|
|
35
|
-
function getCriticalSectionTimeout() {
|
|
36
|
-
return parseInt(process.env.SAP_TIMEOUT_CRITICAL || '600000', 10);
|
|
37
|
-
}
|