@mcp-abap-adt/connection 19.1.0 → 20.1.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 +83 -1
- package/README.md +110 -26
- 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/RfcTransport.d.ts +64 -9
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +174 -31
- 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 +31 -26
- package/dist/connection/rfcConversation.d.ts.map +1 -1
- package/dist/connection/rfcConversation.js +32 -46
- package/dist/index.d.ts +3 -3
- 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 +37 -13
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpTransport.d.ts","sourceRoot":"","sources":["../../src/connection/HttpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;A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) ? mod : { "default": mod };
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.HttpTransport = exports.isStatefulRequest = void 0;
|
|
27
|
+
exports.HttpTransport = exports.nodeHttpClient = exports.isStatefulRequest = void 0;
|
|
28
28
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
29
29
|
const node_crypto_1 = require("node:crypto");
|
|
30
30
|
const node_http_1 = require("node:http");
|
|
@@ -257,6 +257,13 @@ function sameMaterial(a, b) {
|
|
|
257
257
|
return Buffer.from(left).equals(Buffer.from(right));
|
|
258
258
|
});
|
|
259
259
|
}
|
|
260
|
+
/** axios over the wire's agents, and node's own `http` / `https` for a logoff. */
|
|
261
|
+
exports.nodeHttpClient = {
|
|
262
|
+
create: (agents) => axios_1.default.create(agents),
|
|
263
|
+
logoffRequest: (options, onResponse) => options.protocol === 'https:'
|
|
264
|
+
? (0, node_https_1.request)(options, onResponse)
|
|
265
|
+
: (0, node_http_1.request)(options, onResponse),
|
|
266
|
+
};
|
|
260
267
|
/**
|
|
261
268
|
* Whether the server certificate is verified: yes, as Node does, unless told
|
|
262
269
|
* otherwise in so many words.
|
|
@@ -318,16 +325,38 @@ class HttpTransport {
|
|
|
318
325
|
token = null;
|
|
319
326
|
constructor(agentOptions = () => ({}), logger = null,
|
|
320
327
|
/**
|
|
321
|
-
*
|
|
322
|
-
* first one on: the establishing call is where the
|
|
323
|
-
* token are issued, so a client applied any later is
|
|
324
|
-
* that already lives in another one. See
|
|
328
|
+
* `client`: the SAP client (mandant) every request on this wire
|
|
329
|
+
* addresses, from the first one on: the establishing call is where the
|
|
330
|
+
* session and its CSRF token are issued, so a client applied any later is
|
|
331
|
+
* applied to a session that already lives in another one. See
|
|
332
|
+
* `clientHeaders()`.
|
|
333
|
+
*
|
|
334
|
+
* `baseUrl`: the system this wire addresses, required. A path a caller
|
|
335
|
+
* sends is put on it; every request the wire originates itself — the
|
|
336
|
+
* CSRF fetch, the cloud preflight, the logoff — goes to its origin.
|
|
337
|
+
*
|
|
338
|
+
* `httpClient`: how the wire reaches the network. Absent: `nodeHttpClient`.
|
|
325
339
|
*/
|
|
326
|
-
options
|
|
340
|
+
options) {
|
|
327
341
|
this.agentOptions = agentOptions;
|
|
328
342
|
this.logger = logger;
|
|
329
343
|
this.options = options;
|
|
330
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* The system's origin: where the wire's own requests go — the CSRF fetch,
|
|
347
|
+
* the session check, the cloud preflight, the logoff — whatever path the
|
|
348
|
+
* configured URL carries. The same base the connection's `getBaseUrl()`
|
|
349
|
+
* answers.
|
|
350
|
+
*/
|
|
351
|
+
origin() {
|
|
352
|
+
return new URL(this.options.baseUrl).origin;
|
|
353
|
+
}
|
|
354
|
+
/** The base URL without a trailing slash, for a caller's path to be put on. */
|
|
355
|
+
base() {
|
|
356
|
+
return this.options.baseUrl.endsWith('/')
|
|
357
|
+
? this.options.baseUrl.slice(0, -1)
|
|
358
|
+
: this.options.baseUrl;
|
|
359
|
+
}
|
|
331
360
|
/**
|
|
332
361
|
* Fold a response into the wire state.
|
|
333
362
|
*
|
|
@@ -423,9 +452,7 @@ class HttpTransport {
|
|
|
423
452
|
this.forgetSession();
|
|
424
453
|
throw new Error('The session handed over names no SAP_SESSIONID, so there is no session to take over; nothing was sent.');
|
|
425
454
|
}
|
|
426
|
-
const base =
|
|
427
|
-
? context.baseUrl.slice(0, -1)
|
|
428
|
-
: context.baseUrl;
|
|
455
|
+
const base = this.origin();
|
|
429
456
|
const endpoints = [
|
|
430
457
|
`${base}${csrfConfig_js_1.CSRF_CONFIG.ENDPOINT}`,
|
|
431
458
|
`${base}${csrfConfig_js_1.CSRF_CONFIG.FALLBACK_ENDPOINT}`,
|
|
@@ -610,9 +637,7 @@ class HttpTransport {
|
|
|
610
637
|
// move the session out from under a lock taken against the first.
|
|
611
638
|
if (this.token)
|
|
612
639
|
return;
|
|
613
|
-
const base =
|
|
614
|
-
? context.baseUrl.slice(0, -1)
|
|
615
|
-
: context.baseUrl;
|
|
640
|
+
const base = this.origin();
|
|
616
641
|
const endpoints = [
|
|
617
642
|
`${base}${csrfConfig_js_1.CSRF_CONFIG.ENDPOINT}`,
|
|
618
643
|
// BASIS < 7.52 has no /sap/bc/adt/core/discovery.
|
|
@@ -879,12 +904,9 @@ class HttpTransport {
|
|
|
879
904
|
}
|
|
880
905
|
/** A path becomes an address; anything already absolute is left alone. */
|
|
881
906
|
address(url) {
|
|
882
|
-
if (!url.startsWith('/')
|
|
907
|
+
if (!url.startsWith('/'))
|
|
883
908
|
return url;
|
|
884
|
-
|
|
885
|
-
? this.options.baseUrl.slice(0, -1)
|
|
886
|
-
: this.options.baseUrl;
|
|
887
|
-
return `${base}${url}`;
|
|
909
|
+
return `${this.base()}${url}`;
|
|
888
910
|
}
|
|
889
911
|
/**
|
|
890
912
|
* What this wire says to a provider at a logon.
|
|
@@ -926,7 +948,7 @@ class HttpTransport {
|
|
|
926
948
|
// caller's `agentOptions` and the TLS material win over the pool's
|
|
927
949
|
// options — `keepAlive: false` there turns the pool off for `https:`.
|
|
928
950
|
const tls = { ...options, rejectUnauthorized, ...this.material };
|
|
929
|
-
this.instance =
|
|
951
|
+
this.instance = (this.options.httpClient ?? exports.nodeHttpClient).create({
|
|
930
952
|
httpAgent: new PooledHttpAgent(POOLED),
|
|
931
953
|
httpsAgent: new PooledHttpsAgent({ ...POOLED, ...tls }),
|
|
932
954
|
});
|
|
@@ -966,7 +988,7 @@ class HttpTransport {
|
|
|
966
988
|
* cookies were refused with 401 right after it, accepted before).
|
|
967
989
|
*/
|
|
968
990
|
async sendIcfLogoff(context, snapshot, written) {
|
|
969
|
-
await this.sendLogoff(context, `${
|
|
991
|
+
await this.sendLogoff(context, `${this.origin()}${ICF_LOGOFF_PATH}`, { ...snapshot, session: {} }, written);
|
|
970
992
|
}
|
|
971
993
|
/**
|
|
972
994
|
* The logoff, sent as Eclipse ADT 3.60.3 sends it when a project is closed.
|
|
@@ -1073,16 +1095,13 @@ class HttpTransport {
|
|
|
1073
1095
|
return this.dispatch(request, { ...request.headers }, written);
|
|
1074
1096
|
}
|
|
1075
1097
|
/**
|
|
1076
|
-
* The node request a logoff goes out on — the seam where its write is seen
|
|
1077
|
-
*
|
|
1078
|
-
*
|
|
1079
|
-
*
|
|
1080
|
-
* answer is not read, so not following a redirect changes nothing.
|
|
1098
|
+
* The node request a logoff goes out on — the seam where its write is seen:
|
|
1099
|
+
* the `httpClient`'s, node's own `http` / `https` by default, as axios would
|
|
1100
|
+
* use with redirects off. The logoff's answer is not read, so not following a
|
|
1101
|
+
* redirect changes nothing.
|
|
1081
1102
|
*/
|
|
1082
1103
|
logoffRequest(options, onResponse) {
|
|
1083
|
-
return options.
|
|
1084
|
-
? (0, node_https_1.request)(options, onResponse)
|
|
1085
|
-
: (0, node_http_1.request)(options, onResponse);
|
|
1104
|
+
return (this.options.httpClient ?? exports.nodeHttpClient).logoffRequest(options, onResponse);
|
|
1086
1105
|
}
|
|
1087
1106
|
/** The agent a logoff goes out on: never a pooled one. */
|
|
1088
1107
|
goodbyeAgent(options) {
|
|
@@ -76,10 +76,11 @@ export interface IAdtTransportResponse {
|
|
|
76
76
|
* session is one request, and one that is retried is one the caller cannot
|
|
77
77
|
* reason about — a second session may already be open by the time the first
|
|
78
78
|
* answer arrives.
|
|
79
|
+
*
|
|
80
|
+
* No address: a wire that addresses a server (HTTP) was handed its base URL
|
|
81
|
+
* at construction, and one that does not (RFC) has none to be handed.
|
|
79
82
|
*/
|
|
80
83
|
export interface IAdtSessionContext {
|
|
81
|
-
/** The server, for a wire that addresses one. */
|
|
82
|
-
baseUrl: string;
|
|
83
84
|
/**
|
|
84
85
|
* Fill the credential into a request the wire itself originates — the CSRF
|
|
85
86
|
* fetch, the cloud preflight. Not the logoff: it carries the session's cookie
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IAdtTransport.d.ts","sourceRoot":"","sources":["../../src/connection/IAdtTransport.ts"],"names":[],"mappings":"AAAA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;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;CAC3B;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,GAAG,IAAI,CAQtE"}
|
|
@@ -39,6 +39,18 @@
|
|
|
39
39
|
* Eclipse's JCo trace carries no session header either. A transport that
|
|
40
40
|
* also captured cookies would be doing that work twice, and the two copies
|
|
41
41
|
* would disagree the first time one of them was cleared.
|
|
42
|
+
*
|
|
43
|
+
* **A request's language.** Over HTTP the ICF layer reads `sap-language` — a
|
|
44
|
+
* header or a query parameter — and runs the request in it. This endpoint has
|
|
45
|
+
* no ICF logon: it runs a request in the conversation's logon language and
|
|
46
|
+
* ignores `sap-language` wherever it is written (measured on S/4HANA 2025,
|
|
47
|
+
* 2026-11-09). So a request's `sap-language` is compared with the logon
|
|
48
|
+
* language of the conversation that would carry it — the `lang` its logon
|
|
49
|
+
* carries: the provider's where it wrote one, else the factory's. Another
|
|
50
|
+
* language: a non-stateful request goes on a conversation logged on in it,
|
|
51
|
+
* opened for that call and closed after it, nothing kept; a stateful one is
|
|
52
|
+
* refused before anything is sent, because a session cannot change its
|
|
53
|
+
* language.
|
|
42
54
|
*/
|
|
43
55
|
import type { ILogger } from '../logger.js';
|
|
44
56
|
import type { IAdtEstablishContext, IAdtSessionContext, IAdtTransportRequest, IAdtTransportResponse, IOnPremTransport } from './IAdtTransport.js';
|
|
@@ -56,6 +68,18 @@ export interface IRfcConversation {
|
|
|
56
68
|
*/
|
|
57
69
|
resetServerContext?(): Promise<void>;
|
|
58
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* What `RfcTransport` opens its conversations with: the logon parameters the
|
|
73
|
+
* provider wrote go in, a conversation comes out. `language` is the logon
|
|
74
|
+
* language a conversation opens in when its logon names no `lang`, where the
|
|
75
|
+
* factory states it — `rfcConversationFrom` does, from the config. The
|
|
76
|
+
* effective logon language is the `lang` the logon carried, else this. Where
|
|
77
|
+
* neither states one, the wire cannot know the logon language, and every
|
|
78
|
+
* request that names a `sap-language` is treated as naming another one.
|
|
79
|
+
*/
|
|
80
|
+
export type RfcConversationFactory = ((logon: Readonly<Record<string, string>>) => IRfcConversation) & {
|
|
81
|
+
readonly language?: string;
|
|
82
|
+
};
|
|
59
83
|
/** What this wire does beyond carrying the request. */
|
|
60
84
|
export interface IRfcTransportOptions {
|
|
61
85
|
/**
|
|
@@ -102,6 +126,15 @@ export declare class RfcTransport implements IOnPremTransport {
|
|
|
102
126
|
private canReset;
|
|
103
127
|
/** Names the conversation, and so the ABAP session it carries. */
|
|
104
128
|
private conversationId;
|
|
129
|
+
/**
|
|
130
|
+
* The language the stateful conversation logged on in: the `lang` its logon
|
|
131
|
+
* carried — the provider's where it wrote one, else the factory's. What a
|
|
132
|
+
* request's `sap-language` is compared with. `undefined` when neither
|
|
133
|
+
* states one.
|
|
134
|
+
*/
|
|
135
|
+
private logonLanguage;
|
|
136
|
+
/** The language the kept stateless conversation logged on in, the same way. */
|
|
137
|
+
private statelessLanguage;
|
|
105
138
|
/**
|
|
106
139
|
* Where each logon asks the provider what to open with. Kept from `open()`;
|
|
107
140
|
* `null` when the wire is driven without a lifecycle, and then a conversation
|
|
@@ -160,7 +193,7 @@ export declare class RfcTransport implements IOnPremTransport {
|
|
|
160
193
|
* that reached for it in its constructor could not be built at all on a
|
|
161
194
|
* machine without it.
|
|
162
195
|
*/
|
|
163
|
-
constructor(connect:
|
|
196
|
+
constructor(connect: RfcConversationFactory, logger?: ILogger | null, options?: IRfcTransportOptions);
|
|
164
197
|
/** Cut a body down to what a log line may carry. */
|
|
165
198
|
private clipped;
|
|
166
199
|
open(context?: IAdtSessionContext): Promise<void>;
|
|
@@ -180,15 +213,23 @@ export declare class RfcTransport implements IOnPremTransport {
|
|
|
180
213
|
* before the first one's reset would run in the first one's context — a
|
|
181
214
|
* package the first one saved would refuse the second one's write (PAK/058).
|
|
182
215
|
* So a concurrent call takes a conversation of its own instead of waiting.
|
|
216
|
+
*
|
|
217
|
+
* A request that names a `sap-language` runs on a conversation logged on in
|
|
218
|
+
* it: the kept one when that one's logon language is the same, else one of
|
|
219
|
+
* its own logged on with that `lang`, closed after the call.
|
|
183
220
|
*/
|
|
184
221
|
private carryOnItsOwn;
|
|
185
222
|
private carryOnKept;
|
|
186
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* A conversation opened for this one call with `parameters`, closed when it
|
|
225
|
+
* answers, whatever the answer.
|
|
226
|
+
*/
|
|
187
227
|
private carryOnThrowaway;
|
|
188
228
|
/**
|
|
189
|
-
* A new conversation, logged on
|
|
190
|
-
* wire was closed meanwhile, the conversation is
|
|
191
|
-
* sent — not a PUT, not a DELETE — on a wire
|
|
229
|
+
* A new conversation, logged on with `parameters`. The logon takes time
|
|
230
|
+
* (~0.5 s on E19); if the wire was closed meanwhile, the conversation is
|
|
231
|
+
* closed again and nothing is sent — not a PUT, not a DELETE — on a wire
|
|
232
|
+
* already given back.
|
|
192
233
|
*/
|
|
193
234
|
private openOwn;
|
|
194
235
|
/**
|
|
@@ -199,12 +240,26 @@ export declare class RfcTransport implements IOnPremTransport {
|
|
|
199
240
|
* and whether that matters is the provider's call.
|
|
200
241
|
*/
|
|
201
242
|
private logonTarget;
|
|
243
|
+
/** What the provider writes for one logon: asked every time. */
|
|
244
|
+
private logonParameters;
|
|
245
|
+
/**
|
|
246
|
+
* The language a logon with `parameters` logs on in: its `lang` — the
|
|
247
|
+
* provider's, or the one a call in another language put over it — else the
|
|
248
|
+
* factory's.
|
|
249
|
+
*/
|
|
250
|
+
private languageOf;
|
|
251
|
+
/**
|
|
252
|
+
* A new conversation, logged on with `parameters`; a failed open is a
|
|
253
|
+
* refused logon whose cause is the SDK's own error, untouched — a provider
|
|
254
|
+
* reads its `key` and message.
|
|
255
|
+
*/
|
|
256
|
+
private openedWith;
|
|
202
257
|
/**
|
|
203
|
-
* A
|
|
204
|
-
*
|
|
205
|
-
*
|
|
258
|
+
* A debug line that cannot throw: the line is built and written inside the
|
|
259
|
+
* guard, so neither a value that will not stringify nor a logger that throws
|
|
260
|
+
* stops what logs it — a close above all.
|
|
206
261
|
*/
|
|
207
|
-
private
|
|
262
|
+
private logQuietly;
|
|
208
263
|
private closeQuietly;
|
|
209
264
|
private carry;
|
|
210
265
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RfcTransport.d.ts","sourceRoot":"","sources":["../../src/connection/RfcTransport.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"RfcTransport.d.ts","sourceRoot":"","sources":["../../src/connection/RfcTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAa5B,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,CACF,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;;;;OAKG;IACH,kBAAkB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CACpC,K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,+BAA+B;IAC/B,SAAS,IAAI,IAAI;IAIjB;;;OAGG;IACH,cAAc,IAAI,IAAI;IAEtB;;;OAGG;IACH,6EAA6E;IAC7E,kBAAkB,IAAI,OAAO;IAI7B,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAQzC,2EAA2E;IAC3E,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIzC;;;;OAIG;IACH,aAAa,IAAI,IAAI;IAErB;;;;;OAKG;gBAEgB,OAAO,EAAE,sBAAsB,EAC/B,MAAM,GAAE,OAAO,GAAG,IAAW,EAC7B,OAAO,GAAE,oBAAyB;IAGrD,oDAAoD;IACpD,OAAO,CAAC,OAAO;IAcT,IAAI,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBvD,0DAA0D;IACpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BtB,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAuBzE;;;;;;;;;;;;;;;;;OAiBG;YACW,aAAa;YAeb,WAAW;IA+EzB;;;OAGG;YACW,gBAAgB;IAc9B;;;;;OAKG;YACW,OAAO;IAcrB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAgBnB,gEAAgE;YAClD,eAAe;IAM7B;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAMlB;;;;OAIG;YACW,UAAU;IAYxB;;;;OAIG;IACH,OAAO,CAAC,UAAU;YAQJ,YAAY;YAQZ,KAAK;CA+KpB"}
|
|
@@ -40,6 +40,18 @@
|
|
|
40
40
|
* Eclipse's JCo trace carries no session header either. A transport that
|
|
41
41
|
* also captured cookies would be doing that work twice, and the two copies
|
|
42
42
|
* would disagree the first time one of them was cleared.
|
|
43
|
+
*
|
|
44
|
+
* **A request's language.** Over HTTP the ICF layer reads `sap-language` — a
|
|
45
|
+
* header or a query parameter — and runs the request in it. This endpoint has
|
|
46
|
+
* no ICF logon: it runs a request in the conversation's logon language and
|
|
47
|
+
* ignores `sap-language` wherever it is written (measured on S/4HANA 2025,
|
|
48
|
+
* 2026-11-09). So a request's `sap-language` is compared with the logon
|
|
49
|
+
* language of the conversation that would carry it — the `lang` its logon
|
|
50
|
+
* carries: the provider's where it wrote one, else the factory's. Another
|
|
51
|
+
* language: a non-stateful request goes on a conversation logged on in it,
|
|
52
|
+
* opened for that call and closed after it, nothing kept; a stateful one is
|
|
53
|
+
* refused before anything is sent, because a session cannot change its
|
|
54
|
+
* language.
|
|
43
55
|
*/
|
|
44
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
57
|
exports.RfcTransport = void 0;
|
|
@@ -56,6 +68,71 @@ function record(value) {
|
|
|
56
68
|
? value
|
|
57
69
|
: undefined;
|
|
58
70
|
}
|
|
71
|
+
/** The header and query parameter that name the language a request runs in. */
|
|
72
|
+
const LANGUAGE_FIELD = 'sap-language';
|
|
73
|
+
/**
|
|
74
|
+
* The language a request names in `sap-language` — a header, a query
|
|
75
|
+
* parameter in `params`, or one written into the URL — or `undefined` when it
|
|
76
|
+
* names none. Names are read without case, as HTTP reads them; an empty value
|
|
77
|
+
* names no language. A request that names two different languages is refused:
|
|
78
|
+
* which of them a system would take is not something this wire decides.
|
|
79
|
+
*/
|
|
80
|
+
function requestedLanguage(request) {
|
|
81
|
+
const named = [];
|
|
82
|
+
for (const [name, value] of Object.entries(request.headers ?? {})) {
|
|
83
|
+
if (name.toLowerCase() === LANGUAGE_FIELD)
|
|
84
|
+
named.push(String(value));
|
|
85
|
+
}
|
|
86
|
+
for (const [name, value] of Object.entries(request.params ?? {})) {
|
|
87
|
+
if (name.toLowerCase() === LANGUAGE_FIELD &&
|
|
88
|
+
value !== undefined &&
|
|
89
|
+
value !== null) {
|
|
90
|
+
named.push(String(value));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const queryStart = request.url.indexOf('?');
|
|
94
|
+
if (queryStart >= 0) {
|
|
95
|
+
const query = new URLSearchParams(request.url.slice(queryStart + 1));
|
|
96
|
+
for (const [name, value] of query) {
|
|
97
|
+
if (name.toLowerCase() === LANGUAGE_FIELD)
|
|
98
|
+
named.push(value);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
let language;
|
|
102
|
+
for (const value of named) {
|
|
103
|
+
if (value === '')
|
|
104
|
+
continue;
|
|
105
|
+
if (language === undefined) {
|
|
106
|
+
language = value;
|
|
107
|
+
}
|
|
108
|
+
else if (!sameLanguage(language, value)) {
|
|
109
|
+
throw new Error(`The request names two languages in ${LANGUAGE_FIELD}, ${language} and ${value}; nothing was sent.`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return language;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* `language` when a request names it and the conversation's logon language is
|
|
116
|
+
* another (or unknown); `undefined` when it names none or the same one.
|
|
117
|
+
*/
|
|
118
|
+
function otherLanguage(language, logonLanguage) {
|
|
119
|
+
return language !== undefined && !sameLanguage(language, logonLanguage)
|
|
120
|
+
? language
|
|
121
|
+
: undefined;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The provider's logon parameters, with the request's language as `lang` over
|
|
125
|
+
* any `lang` the provider wrote — or as they are when the request names none.
|
|
126
|
+
*/
|
|
127
|
+
function inLanguage(parameters, language) {
|
|
128
|
+
return language === undefined
|
|
129
|
+
? parameters
|
|
130
|
+
: { ...parameters, lang: language };
|
|
131
|
+
}
|
|
132
|
+
/** SAP language keys are read without case: `ru` and `RU` are one language. */
|
|
133
|
+
function sameLanguage(a, b) {
|
|
134
|
+
return b !== undefined && a.toUpperCase() === b.toUpperCase();
|
|
135
|
+
}
|
|
59
136
|
/**
|
|
60
137
|
* ADT exception types, mapped to what they would have been over HTTP. Standard
|
|
61
138
|
* types, returned in `<exc:exception>` XML.
|
|
@@ -152,6 +229,15 @@ class RfcTransport {
|
|
|
152
229
|
canReset;
|
|
153
230
|
/** Names the conversation, and so the ABAP session it carries. */
|
|
154
231
|
conversationId = '';
|
|
232
|
+
/**
|
|
233
|
+
* The language the stateful conversation logged on in: the `lang` its logon
|
|
234
|
+
* carried — the provider's where it wrote one, else the factory's. What a
|
|
235
|
+
* request's `sap-language` is compared with. `undefined` when neither
|
|
236
|
+
* states one.
|
|
237
|
+
*/
|
|
238
|
+
logonLanguage;
|
|
239
|
+
/** The language the kept stateless conversation logged on in, the same way. */
|
|
240
|
+
statelessLanguage;
|
|
155
241
|
/**
|
|
156
242
|
* Where each logon asks the provider what to open with. Kept from `open()`;
|
|
157
243
|
* `null` when the wire is driven without a lifecycle, and then a conversation
|
|
@@ -251,7 +337,8 @@ class RfcTransport {
|
|
|
251
337
|
if (this.conversation?.alive)
|
|
252
338
|
return;
|
|
253
339
|
const generation = this.generation;
|
|
254
|
-
const
|
|
340
|
+
const parameters = await this.logonParameters();
|
|
341
|
+
const conversation = await this.openedWith(parameters);
|
|
255
342
|
// close() ran while this logged on: the session it would have handed out
|
|
256
343
|
// belongs to a wire already given back, so it is closed, not kept.
|
|
257
344
|
if (generation !== this.generation) {
|
|
@@ -259,6 +346,7 @@ class RfcTransport {
|
|
|
259
346
|
throw new Error('RFC transport was closed while it was being opened.');
|
|
260
347
|
}
|
|
261
348
|
this.conversation = conversation;
|
|
349
|
+
this.logonLanguage = this.languageOf(parameters);
|
|
262
350
|
// Minted here, where the session begins. A conversation opened after an
|
|
263
351
|
// earlier one closed is a DIFFERENT ABAP session, and the fingerprint has
|
|
264
352
|
// to say so — a constant would report `unchanged` across a reconnect and
|
|
@@ -281,17 +369,20 @@ class RfcTransport {
|
|
|
281
369
|
this.stateless = null;
|
|
282
370
|
this.conversation = null;
|
|
283
371
|
this.conversationId = '';
|
|
372
|
+
this.logonLanguage = undefined;
|
|
373
|
+
this.statelessLanguage = undefined;
|
|
284
374
|
if (stateless)
|
|
285
375
|
await this.closeQuietly(stateless);
|
|
286
376
|
if (!conversation)
|
|
287
377
|
return;
|
|
288
378
|
try {
|
|
289
379
|
await conversation.close();
|
|
290
|
-
this.logger?.debug('RFC conversation closed');
|
|
291
380
|
}
|
|
292
381
|
catch (e) {
|
|
293
|
-
this.
|
|
382
|
+
this.logQuietly(() => `RFC close error: ${message(e)}`);
|
|
383
|
+
return;
|
|
294
384
|
}
|
|
385
|
+
this.logQuietly(() => 'RFC conversation closed');
|
|
295
386
|
}
|
|
296
387
|
async send(request) {
|
|
297
388
|
if (!this.conversation?.alive) {
|
|
@@ -303,9 +394,15 @@ class RfcTransport {
|
|
|
303
394
|
// Taken once, here: every await below compares against it, and a call
|
|
304
395
|
// that finds the wire closed since it began sends nothing.
|
|
305
396
|
const generation = this.generation;
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
397
|
+
const language = requestedLanguage(request);
|
|
398
|
+
if ((0, statefulRequest_js_1.isStatefulRequest)(request)) {
|
|
399
|
+
const other = otherLanguage(language, this.logonLanguage);
|
|
400
|
+
if (other !== undefined) {
|
|
401
|
+
throw new Error(`The request asks for ${LANGUAGE_FIELD} ${other}, but the stateful RFC session is logged on in ${this.logonLanguage ?? 'a language neither the RFC conversation factory nor the provider states'}: a session cannot change its language, so the request was not sent.`);
|
|
402
|
+
}
|
|
403
|
+
return this.carry(request, this.conversation, generation);
|
|
404
|
+
}
|
|
405
|
+
return this.carryOnItsOwn(request, language, generation);
|
|
309
406
|
}
|
|
310
407
|
/**
|
|
311
408
|
* A request that is not stateful, in a fresh ABAP session.
|
|
@@ -320,18 +417,29 @@ class RfcTransport {
|
|
|
320
417
|
* before the first one's reset would run in the first one's context — a
|
|
321
418
|
* package the first one saved would refuse the second one's write (PAK/058).
|
|
322
419
|
* So a concurrent call takes a conversation of its own instead of waiting.
|
|
420
|
+
*
|
|
421
|
+
* A request that names a `sap-language` runs on a conversation logged on in
|
|
422
|
+
* it: the kept one when that one's logon language is the same, else one of
|
|
423
|
+
* its own logged on with that `lang`, closed after the call.
|
|
323
424
|
*/
|
|
324
|
-
async carryOnItsOwn(request, generation) {
|
|
425
|
+
async carryOnItsOwn(request, language, generation) {
|
|
325
426
|
if (this.canReset !== false && !this.statelessBusy) {
|
|
326
|
-
return this.carryOnKept(request, generation);
|
|
427
|
+
return this.carryOnKept(request, language, generation);
|
|
327
428
|
}
|
|
328
|
-
return this.carryOnThrowaway(request, generation);
|
|
429
|
+
return this.carryOnThrowaway(request, inLanguage(await this.logonParameters(), language), generation);
|
|
329
430
|
}
|
|
330
|
-
async carryOnKept(request, generation) {
|
|
431
|
+
async carryOnKept(request, language, generation) {
|
|
331
432
|
this.statelessBusy = true;
|
|
332
433
|
try {
|
|
333
|
-
|
|
334
|
-
|
|
434
|
+
let kept = this.stateless;
|
|
435
|
+
if (!kept?.alive) {
|
|
436
|
+
// The provider is asked first: what it writes says which language the
|
|
437
|
+
// kept conversation would log on in, before any logon is made.
|
|
438
|
+
const parameters = await this.logonParameters();
|
|
439
|
+
if (otherLanguage(language, this.languageOf(parameters)) !== undefined) {
|
|
440
|
+
return await this.carryOnThrowaway(request, inLanguage(parameters, language), generation);
|
|
441
|
+
}
|
|
442
|
+
const opened = await this.openOwn(parameters, generation);
|
|
335
443
|
// Checked again after the await: close() may have run since openOwn()
|
|
336
444
|
// checked, and a conversation of a closed wire must not become the
|
|
337
445
|
// kept one of the next.
|
|
@@ -352,9 +460,13 @@ class RfcTransport {
|
|
|
352
460
|
}
|
|
353
461
|
this.canReset = true;
|
|
354
462
|
this.stateless = opened;
|
|
463
|
+
this.statelessLanguage = this.languageOf(parameters);
|
|
464
|
+
kept = opened;
|
|
355
465
|
this.logger?.debug('RFC stateless conversation opened (reset per call)');
|
|
356
466
|
}
|
|
357
|
-
|
|
467
|
+
else if (otherLanguage(language, this.statelessLanguage) !== undefined) {
|
|
468
|
+
return await this.carryOnThrowaway(request, inLanguage(await this.logonParameters(), language), generation);
|
|
469
|
+
}
|
|
358
470
|
try {
|
|
359
471
|
return await this.carry(request, kept, generation);
|
|
360
472
|
}
|
|
@@ -364,9 +476,11 @@ class RfcTransport {
|
|
|
364
476
|
}
|
|
365
477
|
catch (e) {
|
|
366
478
|
// A context that could not be reset must not serve the next call.
|
|
367
|
-
this.
|
|
368
|
-
if (this.stateless === kept)
|
|
479
|
+
this.logQuietly(() => `RFC reset failed, dropping the conversation: ${message(e)}`);
|
|
480
|
+
if (this.stateless === kept) {
|
|
369
481
|
this.stateless = null;
|
|
482
|
+
this.statelessLanguage = undefined;
|
|
483
|
+
}
|
|
370
484
|
await this.closeQuietly(kept);
|
|
371
485
|
}
|
|
372
486
|
}
|
|
@@ -375,11 +489,14 @@ class RfcTransport {
|
|
|
375
489
|
this.statelessBusy = false;
|
|
376
490
|
}
|
|
377
491
|
}
|
|
378
|
-
/**
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
492
|
+
/**
|
|
493
|
+
* A conversation opened for this one call with `parameters`, closed when it
|
|
494
|
+
* answers, whatever the answer.
|
|
495
|
+
*/
|
|
496
|
+
async carryOnThrowaway(request, parameters, generation) {
|
|
497
|
+
const own = await this.openOwn(parameters, generation);
|
|
382
498
|
try {
|
|
499
|
+
this.logger?.debug('RFC conversation opened for one stateless call');
|
|
383
500
|
return await this.carry(request, own, generation);
|
|
384
501
|
}
|
|
385
502
|
finally {
|
|
@@ -387,12 +504,13 @@ class RfcTransport {
|
|
|
387
504
|
}
|
|
388
505
|
}
|
|
389
506
|
/**
|
|
390
|
-
* A new conversation, logged on
|
|
391
|
-
* wire was closed meanwhile, the conversation is
|
|
392
|
-
* sent — not a PUT, not a DELETE — on a wire
|
|
507
|
+
* A new conversation, logged on with `parameters`. The logon takes time
|
|
508
|
+
* (~0.5 s on E19); if the wire was closed meanwhile, the conversation is
|
|
509
|
+
* closed again and nothing is sent — not a PUT, not a DELETE — on a wire
|
|
510
|
+
* already given back.
|
|
393
511
|
*/
|
|
394
|
-
async openOwn(generation) {
|
|
395
|
-
const own = await this.
|
|
512
|
+
async openOwn(parameters, generation) {
|
|
513
|
+
const own = await this.openedWith(parameters);
|
|
396
514
|
if (generation !== this.generation || !this.conversation?.alive) {
|
|
397
515
|
await this.closeQuietly(own);
|
|
398
516
|
throw new Error('RFC transport was closed while the call was being opened; nothing was sent.');
|
|
@@ -421,14 +539,26 @@ class RfcTransport {
|
|
|
421
539
|
},
|
|
422
540
|
};
|
|
423
541
|
}
|
|
424
|
-
/**
|
|
425
|
-
|
|
426
|
-
* every time, and a failed open is a refused logon whose cause is the SDK's
|
|
427
|
-
* own error, untouched — a provider reads its `key` and message.
|
|
428
|
-
*/
|
|
429
|
-
async loggedOn() {
|
|
542
|
+
/** What the provider writes for one logon: asked every time. */
|
|
543
|
+
async logonParameters() {
|
|
430
544
|
const parameters = {};
|
|
431
545
|
await this.context?.logon(this.logonTarget(parameters));
|
|
546
|
+
return parameters;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* The language a logon with `parameters` logs on in: its `lang` — the
|
|
550
|
+
* provider's, or the one a call in another language put over it — else the
|
|
551
|
+
* factory's.
|
|
552
|
+
*/
|
|
553
|
+
languageOf(parameters) {
|
|
554
|
+
return parameters.lang ?? this.connect.language;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* A new conversation, logged on with `parameters`; a failed open is a
|
|
558
|
+
* refused logon whose cause is the SDK's own error, untouched — a provider
|
|
559
|
+
* reads its `key` and message.
|
|
560
|
+
*/
|
|
561
|
+
async openedWith(parameters) {
|
|
432
562
|
const conversation = this.connect(parameters);
|
|
433
563
|
try {
|
|
434
564
|
await conversation.open();
|
|
@@ -438,12 +568,25 @@ class RfcTransport {
|
|
|
438
568
|
}
|
|
439
569
|
return conversation;
|
|
440
570
|
}
|
|
571
|
+
/**
|
|
572
|
+
* A debug line that cannot throw: the line is built and written inside the
|
|
573
|
+
* guard, so neither a value that will not stringify nor a logger that throws
|
|
574
|
+
* stops what logs it — a close above all.
|
|
575
|
+
*/
|
|
576
|
+
logQuietly(line) {
|
|
577
|
+
try {
|
|
578
|
+
this.logger?.debug(line());
|
|
579
|
+
}
|
|
580
|
+
catch {
|
|
581
|
+
// A broken logger must not stop a close; there is nowhere left to say so.
|
|
582
|
+
}
|
|
583
|
+
}
|
|
441
584
|
async closeQuietly(conversation) {
|
|
442
585
|
try {
|
|
443
586
|
await conversation.close();
|
|
444
587
|
}
|
|
445
588
|
catch (e) {
|
|
446
|
-
this.
|
|
589
|
+
this.logQuietly(() => `RFC close error: ${message(e)}`);
|
|
447
590
|
}
|
|
448
591
|
}
|
|
449
592
|
async carry(request, conversation, generation) {
|