@mcp-abap-adt/interfaces-adt-connection 1.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/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # @mcp-abap-adt/interfaces-adt-connection
2
+
3
+ The ABAP connection contract: what an ADT request is sent through, and what
4
+ comes back off the wire. Types and one constant; no implementation.
5
+
6
+ ```bash
7
+ npm install @mcp-abap-adt/interfaces-adt-connection
8
+ ```
9
+
10
+ | symbol | what it is |
11
+ |---|---|
12
+ | `IAbapConnection` | a connection an ADT request is made through: `makeAdtRequest`, connect/disconnect, the session type |
13
+ | `IAbapRequestOptions` | what one request carries |
14
+ | `IAdtWireResponse` | the answer as it came off the wire — extends `IHttpWireResponse` from `interfaces-network` with the headers ADT sends |
15
+ | `ISessionLifecycleAware`, `ICriticalSection`, `IRequestProfiling`, `IDeferredResponseConnection` | the connection's capability atoms — a connection honours the ones it can |
16
+ | `ADT_SESSION_ERROR` / `AdtSessionErrorCode` | what a session failure is called |
17
+ | `ITimeoutConfig` | the deadlines a caller gives a connection: `default`, `csrf`, `long` |
18
+
19
+ ## Why this package exists
20
+
21
+ **It moves on its own schedule.** These four files were
22
+ `interfaces-adt/src/connection/` until `interfaces-adt` 11.0.0. The object
23
+ contracts beside them had three majors in one day — 9, 10 and 11 — and none
24
+ touched the connection; yet every one of them made the connector
25
+ (`@mcp-abap-adt/connection`) either release to follow or install a second copy
26
+ of the contract beside `adt-clients`. Two copies of one interface do not compare
27
+ equal in TypeScript, so that shows up as errors that read as impossible.
28
+
29
+ The subject is still ADT — `makeAdtRequest`, the stateful session, CSRF — so it
30
+ does not belong in `interfaces-network`, whose rule is that nothing there is
31
+ ADT-specific (decision 35). What separated it is the release rate (decision 38
32
+ in the repository's `docs/architecture/DECISIONS.md`).
33
+
34
+ ## Who depends on it
35
+
36
+ - **A connector** — the implementation of `IAbapConnection` — depends on this
37
+ alone, and no longer on the object contracts.
38
+ - **`@mcp-abap-adt/interfaces-adt`** stands on it: its strategies are handed an
39
+ `IAdtWireResponse`. It does **not** re-export these names; import them from
40
+ here (decision 34).
41
+
42
+ Depends on `@mcp-abap-adt/interfaces-network`, and nothing else.
43
+
44
+ ## Licence
45
+
46
+ `LGPL-3.0-only`.
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Minimal response type for ADT requests.
3
+ */
4
+ import type { IHttpHeaderValue, IHttpWireResponse } from '@mcp-abap-adt/interfaces-network';
5
+ import type { IAbapRequestOptions } from './IAbapRequestOptions';
6
+ export type IAdtHeaderValue = IHttpHeaderValue;
7
+ export interface IAdtWireResponse<T = any, D = any> extends Omit<IHttpWireResponse<T, D>, 'headers'> {
8
+ /**
9
+ * **The generic shape, narrowed by the headers ADT actually sends.** The
10
+ * frame itself — `data`, `status`, `statusText`, `config`, `request` — is
11
+ * `IHttpWireResponse` in `@mcp-abap-adt/interfaces-network`, because nothing
12
+ * about it is ABAP. What stays here is this list: `sap-adt-location` and the
13
+ * two spellings of `content-location` are where ADT puts the URI of what it
14
+ * just created, and a caller reads them by name.
15
+ */
16
+ headers: Record<string, IAdtHeaderValue> & {
17
+ location?: string;
18
+ Location?: string;
19
+ 'content-location'?: IAdtHeaderValue;
20
+ 'Content-Location'?: IAdtHeaderValue;
21
+ 'sap-adt-location'?: IAdtHeaderValue;
22
+ };
23
+ }
24
+ /**
25
+ * ABAP Connection interface
26
+ *
27
+ * Minimal interface for consumers to interact with SAP ADT.
28
+ * Implementation details (auth, token refresh, CSRF, cookies) are encapsulated.
29
+ *
30
+ * For JWT connections, token refresh is handled internally via ITokenRefresher.
31
+ * For Basic connections, no token refresh is needed.
32
+ */
33
+ export interface IAbapConnection {
34
+ /**
35
+ * Initialize connection: fetch CSRF token and establish session cookies.
36
+ * Must be called before making any ADT requests.
37
+ */
38
+ connect(): Promise<void>;
39
+ /**
40
+ * Get base URL of SAP system
41
+ */
42
+ getBaseUrl(): Promise<string>;
43
+ /**
44
+ * Get current session ID (for stateful connections)
45
+ */
46
+ getSessionId(): string | null;
47
+ /**
48
+ * Set session type for subsequent requests
49
+ * @param type - "stateful" for persistent session, "stateless" for independent requests
50
+ */
51
+ setSessionType(type: 'stateful' | 'stateless'): void;
52
+ /**
53
+ * Make ADT request to SAP system
54
+ *
55
+ * Handles all auth concerns internally:
56
+ * - Adds authorization header (Basic or Bearer)
57
+ * - Manages CSRF token
58
+ * - Retries on 401/403 with token refresh (JWT only)
59
+ *
60
+ * @param options - Request options (url, method, data, etc.)
61
+ * @returns Promise with Axios response
62
+ */
63
+ makeAdtRequest<T = any, D = any>(options: IAbapRequestOptions): Promise<IAdtWireResponse<T, D>>;
64
+ }
65
+ //# sourceMappingURL=IAbapConnection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAbapConnection.d.ts","sourceRoot":"","sources":["../src/IAbapConnection.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAE/C,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,CAChD,SAAQ,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC;IAChD;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG;QACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,kBAAkB,CAAC,EAAE,eAAe,CAAC;QACrC,kBAAkB,CAAC,EAAE,eAAe,CAAC;QACrC,kBAAkB,CAAC,EAAE,eAAe,CAAC;KACtC,CAAC;CACH;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAE9B;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,IAAI,CAAC;IAE9B;;;OAGG;IACH,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CAAC;IAErD;;;;;;;;;;OAUG;IACH,cAAc,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAC7B,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CACpC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ export interface IAbapRequestOptions {
2
+ url: string;
3
+ method: string;
4
+ timeout: number;
5
+ data?: unknown;
6
+ params?: unknown;
7
+ headers?: Record<string, string>;
8
+ }
9
+ //# sourceMappingURL=IAbapRequestOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAbapRequestOptions.d.ts","sourceRoot":"","sources":["../src/IAbapRequestOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Capability atoms for the connection.
3
+ *
4
+ * The same shape as the ADT capability atoms, for the same reason:
5
+ * `IAbapConnection` is the minimum every transport can honour, and this is a
6
+ * thing only some can. An RFC connection, a batch recorder and a test stub are
7
+ * all legitimate `IAbapConnection`s that own no HTTP session; making these
8
+ * methods mandatory would force each of them to implement a lie.
9
+ *
10
+ * ADDITIVE to `IAbapConnection`, which is unchanged — an implementation adds the
11
+ * atom when it genuinely supports it, and a consumer narrows to it.
12
+ */
13
+ /** Error codes a session-aware connection raises. Match on these, not on messages. */
14
+ export declare const ADT_SESSION_ERROR: {
15
+ /** No usable session: never connected, or torn down since. */
16
+ readonly NOT_CONNECTED: "ADT_NOT_CONNECTED";
17
+ /**
18
+ * The server put us on a DIFFERENT session than the one we were using.
19
+ *
20
+ * Anything locked over the old session is orphaned: the lock handle refers to
21
+ * a session that no longer exists, so it can be neither used nor released.
22
+ */
23
+ readonly SESSION_REPLACED: "ADT_SESSION_REPLACED";
24
+ /** A transport release is still pending; the session cannot yet be reused. */
25
+ readonly RELEASE_PENDING: "ADT_RELEASE_PENDING";
26
+ };
27
+ export type AdtSessionErrorCode = (typeof ADT_SESSION_ERROR)[keyof typeof ADT_SESSION_ERROR];
28
+ /**
29
+ * A connection whose session is owned, observable and explicitly torn down.
30
+ *
31
+ * Without this, "is my session still the one I locked over?" is unanswerable
32
+ * from the consumer's side: a connection can be handed a new server session
33
+ * silently, and a caller holding a lock has no way to notice.
34
+ */
35
+ export interface ISessionLifecycleAware {
36
+ /**
37
+ * Tells the server this session is finished.
38
+ *
39
+ * **It notifies; it does not confirm.** Whether and when the session is
40
+ * actually freed is the server's affair, and nothing here checks afterwards.
41
+ * That is why there is no deadline to pass: waiting for the answer to a
42
+ * message whose answer is not acted on buys the caller nothing, and a
43
+ * goodbye carries no request timeout by design — so waiting is the one thing
44
+ * that could make a teardown unbounded.
45
+ *
46
+ * Resolves rather than throws, and **always settles**: whatever it could not
47
+ * finish is the connection's own state, not the caller's problem. A repeat
48
+ * call performs whatever is still owed.
49
+ *
50
+ * **Calling it again does not wait for the goodbye either**, which is what
51
+ * {@link flushGoodbye} is for. A caller about to reconnect wants both, in
52
+ * this order:
53
+ *
54
+ * ```typescript
55
+ * await conn.disconnect();
56
+ * await conn.flushGoodbye();
57
+ * await conn.connect();
58
+ * ```
59
+ *
60
+ * Without the middle line the next session opens while the previous one's
61
+ * goodbye is still being assembled, and the server keeps both. With it, the
62
+ * goodbye is given up to the budget to finish first.
63
+ *
64
+ * In-flight requests are NOT waited for. They continue as their caller
65
+ * arranged and nothing is aborted; their results can no longer affect this
66
+ * connection.
67
+ */
68
+ disconnect(): Promise<void>;
69
+ /**
70
+ * Wait for the goodbye {@link disconnect} sent, within a budget.
71
+ *
72
+ * `disconnect()` dispatches the logoff and does not await it, deliberately: a
73
+ * goodbye carries no request timeout, and a server that never answers must
74
+ * not hold a teardown open. That is right for teardown and wrong for the one
75
+ * caller who reconnects — `disconnect()` then `connect()` opens the next
76
+ * session while the previous one's goodbye is still being assembled, and the
77
+ * server keeps both.
78
+ *
79
+ * Measured on E19 through `@mcp-abap-adt/adt-clients`, whose harness recycled
80
+ * the session after each test: a new ABAP session every one to two seconds
81
+ * for the length of a run, none released, each living to its own thirty
82
+ * minute idle timeout. Turning the recycling off left one session for the
83
+ * whole run, which is what the harness intended all along.
84
+ *
85
+ * **Bounded, and it resolves rather than throws.** The reason not to await
86
+ * inside `disconnect()` applies here too, so the wait has a budget and gives
87
+ * up quietly: "the goodbye has not arrived yet" is not a failure of whatever
88
+ * the caller does next. A goodbye that failed is likewise not the caller's
89
+ * problem — it is absorbed, not rethrown.
90
+ *
91
+ * **So a return is not a confirmation, and not even of dispatch.** Waiting out
92
+ * the budget resolves the same way as the goodbye finishing, and at that
93
+ * point the request may not have reached the wire at all — the promise it
94
+ * waits on covers assembling and sending, not just answering.
95
+ *
96
+ * The guarantee is exactly this: **the caller gives the goodbye up to the
97
+ * budget to finish before carrying on.** If it finishes in time there is no
98
+ * overlap with the next `connect()`. If it does not, the caller proceeds and
99
+ * the goodbye stays outstanding for as long as it takes — the budget bounds
100
+ * the waiting, not the overlap. Whether the server then releases the session
101
+ * is the server's affair, exactly as it is for `disconnect()`.
102
+ *
103
+ * Returns immediately when nothing was dispatched.
104
+ *
105
+ * @param timeoutMs how long to wait; an implementation chooses its default.
106
+ */
107
+ flushGoodbye(timeoutMs?: number): Promise<void>;
108
+ /** Whether a caller may start work. False throughout a pending teardown. */
109
+ isConnected(): boolean;
110
+ /**
111
+ * Which server session the connection is on — or `null`, which says nothing
112
+ * about whether the connection is usable. **Use {@link isConnected} for that.**
113
+ *
114
+ * `null` means only that no identity is known, and there are two ways to get
115
+ * there: no session exists, or the connection is live over a server that
116
+ * issued no session cookie — some do not. So a live, working connection can
117
+ * return `null` here, and a consumer that reads `null` as "session lost"
118
+ * would tear down a connection that was fine.
119
+ *
120
+ * What it does identify is the SESSION, not the conversation: a stable
121
+ * client-side conversation id says nothing about whether the server replaced
122
+ * the session underneath it, which is precisely the failure this exists to
123
+ * expose. Compare two readings across an operation to detect a replacement.
124
+ *
125
+ * Only a CHANGED value is a replacement. `null` → non-null is an identity
126
+ * being learned, not a new session: the LOCK response is often the first to
127
+ * carry a session cookie, and reading that as a replacement would condemn the
128
+ * operation it just covered.
129
+ */
130
+ getSessionIdentity(): string | null;
131
+ }
132
+ /**
133
+ * A connection whose responses resolve only after a later flush.
134
+ *
135
+ * A batch recorder collects requests and settles their promises when the batch
136
+ * executes. Awaiting one of those promises mid-recording deadlocks: the caller
137
+ * is blocked inside the very code that would have reached `execute()`.
138
+ *
139
+ * Deferral belongs to the connection, not to how a client was configured —
140
+ * which is why it is declared here rather than passed as an option. A consumer
141
+ * that wraps a recorder itself, without going through the batch client, still
142
+ * gets the guard.
143
+ */
144
+ export interface IDeferredResponseConnection {
145
+ /** Always `true`. "Sometimes deferred" is not a state a caller could act on. */
146
+ readonly responsesAreDeferred: true;
147
+ }
148
+ /**
149
+ * A connection whose ordinary per-request deadline can be suspended.
150
+ *
151
+ * A `lock` → write → `unlock` sequence wants to run to completion. Aborting one
152
+ * of its requests part way ends nothing on the server — the server ends an ABAP
153
+ * session on its own idle timeout, which this side cannot see — it ends what
154
+ * this side *knows*: whether the write was applied becomes unanswerable, and
155
+ * the handle `unlock` needs is lost while the lock lives on in that session.
156
+ *
157
+ * Measured on a BTP trial: a `POST /sap/bc/adt/deletion/delete` abandoned at
158
+ * 45 s was followed by `400 … Session Timed Out or Not Found` carrying a *new*
159
+ * session cookie. Over HTTP a session is two layers — the ICF one the cookie
160
+ * addresses and the ABAP one beneath it holding the enqueue locks — and the
161
+ * abort replaces the first while stranding the second.
162
+ *
163
+ * **What this promises, exactly.** Inside a section the connection's ordinary
164
+ * per-request deadline does not apply. It does **not** promise that no request
165
+ * can ever be cut short: an implementation is free to keep a far larger ceiling
166
+ * — `@mcp-abap-adt/connection` raises it to `SAP_TIMEOUT_CRITICAL`, ten minutes
167
+ * by default — and a socket, a proxy or the process itself ends a request
168
+ * whatever a contract says. The guarantee is that the short deadline is out of
169
+ * the way, not that time is.
170
+ *
171
+ * Sections nest: the ceiling lifts on the outermost `begin` and ordinary
172
+ * deadlines resume after the matching `end`.
173
+ *
174
+ * Separate from {@link ISessionLifecycleAware} because it answers a different
175
+ * question: that one is *whose session is this*, this one is *may this request
176
+ * be cut short*. A batch recorder honours the first and has nothing to protect.
177
+ */
178
+ export interface ICriticalSection {
179
+ /**
180
+ * Enter a section in which the ordinary per-request deadline is suspended.
181
+ *
182
+ * Nests. Every call needs its own {@link endCriticalSection}, and the usual
183
+ * shape is a `try`/`finally` so a throw inside the window still ends it.
184
+ */
185
+ beginCriticalSection(): void;
186
+ /** Leave it. Ordinary deadlines resume when the outermost section ends. */
187
+ endCriticalSection(): void;
188
+ }
189
+ /**
190
+ * A connection that can be told what to ask the server to report about itself.
191
+ *
192
+ * `X-sap-adt-profiling` asks the server for its own processing time, and
193
+ * Eclipse sends it on every request. It is a per-connection default: a single
194
+ * request overrides it through `headers` on the request options, which every
195
+ * connection already accepts, so this atom exists for the *default* and not for
196
+ * the one-off.
197
+ *
198
+ * `null` asks for nothing. The value is a string rather than an enum because
199
+ * what a server accepts there is the server's business and grows without this
200
+ * package: `'server-time'` is what Eclipse asks for and is the sensible
201
+ * default.
202
+ *
203
+ * Worth stating: an implementation is not expected to read the answer back.
204
+ * The measurement is for whoever is looking at the wire, and being able to turn
205
+ * it off matters more than being able to consume it.
206
+ */
207
+ export interface IRequestProfiling {
208
+ /**
209
+ * What to ask for on every request from now on, or `null` to ask nothing.
210
+ *
211
+ * @param what the `X-sap-adt-profiling` value; `'server-time'` is Eclipse's.
212
+ */
213
+ setProfilingRequest(what: string | null): void;
214
+ /** What this connection is currently asking for. */
215
+ getProfilingRequest(): string | null;
216
+ }
217
+ //# sourceMappingURL=IConnectionCapabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IConnectionCapabilities.d.ts","sourceRoot":"","sources":["../src/IConnectionCapabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,sFAAsF;AACtF,eAAO,MAAM,iBAAiB;IAC5B,8DAA8D;;IAE9D;;;;;OAKG;;IAEH,8EAA8E;;CAEtE,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAC7B,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD,4EAA4E;IAC5E,WAAW,IAAI,OAAO,CAAC;IAEvB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAAC;CACrC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,2BAA2B;IAC1C,gFAAgF;IAChF,QAAQ,CAAC,oBAAoB,EAAE,IAAI,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,oBAAoB,IAAI,IAAI,CAAC;IAE7B,2EAA2E;IAC3E,kBAAkB,IAAI,IAAI,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAE/C,oDAAoD;IACpD,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAAC;CACtC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * Capability atoms for the connection.
4
+ *
5
+ * The same shape as the ADT capability atoms, for the same reason:
6
+ * `IAbapConnection` is the minimum every transport can honour, and this is a
7
+ * thing only some can. An RFC connection, a batch recorder and a test stub are
8
+ * all legitimate `IAbapConnection`s that own no HTTP session; making these
9
+ * methods mandatory would force each of them to implement a lie.
10
+ *
11
+ * ADDITIVE to `IAbapConnection`, which is unchanged — an implementation adds the
12
+ * atom when it genuinely supports it, and a consumer narrows to it.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ADT_SESSION_ERROR = void 0;
16
+ /** Error codes a session-aware connection raises. Match on these, not on messages. */
17
+ exports.ADT_SESSION_ERROR = {
18
+ /** No usable session: never connected, or torn down since. */
19
+ NOT_CONNECTED: 'ADT_NOT_CONNECTED',
20
+ /**
21
+ * The server put us on a DIFFERENT session than the one we were using.
22
+ *
23
+ * Anything locked over the old session is orphaned: the lock handle refers to
24
+ * a session that no longer exists, so it can be neither used nor released.
25
+ */
26
+ SESSION_REPLACED: 'ADT_SESSION_REPLACED',
27
+ /** A transport release is still pending; the session cannot yet be reused. */
28
+ RELEASE_PENDING: 'ADT_RELEASE_PENDING',
29
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The deadlines a caller gives an ADT connection.
3
+ *
4
+ * **`csrf` is why this is not in `@mcp-abap-adt/interfaces-network`.** Fetching
5
+ * a CSRF token is an SAP operation, not a transport primitive, and `long` is a
6
+ * client's policy for a long-polling read rather than anything the network
7
+ * layer knows. It was in that package until `interfaces-adt` 9.0.0, against its
8
+ * own README's claim that it holds nothing SAP-specific.
9
+ */
10
+ export interface ITimeoutConfig {
11
+ default: number;
12
+ csrf: number;
13
+ long: number;
14
+ }
15
+ //# sourceMappingURL=ITimeoutConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITimeoutConfig.d.ts","sourceRoot":"","sources":["../src/ITimeoutConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @mcp-abap-adt/interfaces-adt-connection
3
+ *
4
+ * The ABAP connection: what an ADT request is sent through, and what comes
5
+ * back off the wire.
6
+ *
7
+ * **Its own package because it moves on its own schedule.** These four files
8
+ * were `interfaces-adt/src/connection/` until 11.0.0, and every release of the
9
+ * object contracts — 9, 10 and 11 in one day, none touching them — made the
10
+ * connector either follow or install a second copy. The subject is still ADT
11
+ * (decision 35); what separated it is the release rate (decision 38).
12
+ */
13
+ export type { IAbapConnection, IAdtWireResponse } from './IAbapConnection';
14
+ export type { IAbapRequestOptions } from './IAbapRequestOptions';
15
+ export type { AdtSessionErrorCode, ICriticalSection, IDeferredResponseConnection, IRequestProfiling, ISessionLifecycleAware, } from './IConnectionCapabilities';
16
+ export { ADT_SESSION_ERROR } from './IConnectionCapabilities';
17
+ export type { ITimeoutConfig } from './ITimeoutConfig';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,2BAA2B,EAC3B,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ADT_SESSION_ERROR = void 0;
4
+ var IConnectionCapabilities_1 = require("./IConnectionCapabilities");
5
+ Object.defineProperty(exports, "ADT_SESSION_ERROR", { enumerable: true, get: function () { return IConnectionCapabilities_1.ADT_SESSION_ERROR; } });
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@mcp-abap-adt/interfaces-adt-connection",
3
+ "version": "1.0.0",
4
+ "description": "The ABAP connection contract: IAbapConnection, its capability atoms, the wire response and the session error codes",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md",
10
+ "CHANGELOG.md",
11
+ "LICENSE",
12
+ "COPYING"
13
+ ],
14
+ "sideEffects": false,
15
+ "author": "Oleksii Kyslytsia <oleksij.kyslytsja@gmail.com>",
16
+ "license": "LGPL-3.0-only",
17
+ "homepage": "https://github.com/fr0ster/mcp-abap-adt-interfaces/tree/master/packages/interfaces-adt-connection#readme",
18
+ "bugs": {
19
+ "url": "https://github.com/fr0ster/mcp-abap-adt-interfaces/issues"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/fr0ster/mcp-abap-adt-interfaces.git",
24
+ "directory": "packages/interfaces-adt-connection"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "clean": "rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
31
+ "build": "tsc -b tsconfig.build.json",
32
+ "test:check": "tsc -p tsconfig.json --noEmit",
33
+ "prepublishOnly": "npm run --prefix ../.. check"
34
+ },
35
+ "engines": {
36
+ "node": ">=18.0.0"
37
+ },
38
+ "dependencies": {
39
+ "@mcp-abap-adt/interfaces-network": "^2.0.0"
40
+ }
41
+ }