@mcp-abap-adt/connection 19.1.0 → 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  return (mod && mod.__esModule) ? 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
- * The SAP client (mandant) every request on this wire addresses, from the
322
- * first one on: the establishing call is where the session and its CSRF
323
- * token are issued, so a client applied any later is applied to a session
324
- * that already lives in another one. See `clientHeaders()`.
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 = context.baseUrl.endsWith('/')
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 = context.baseUrl.endsWith('/')
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('/') || !this.options.baseUrl)
907
+ if (!url.startsWith('/'))
883
908
  return url;
884
- const base = this.options.baseUrl.endsWith('/')
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 = axios_1.default.create({
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, `${context.baseUrl}${ICF_LOGOFF_PATH}`, { ...snapshot, session: {} }, written);
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
- * A test replaces it to hold a request's socket shut; the wire uses node's
1079
- * own `http` / `https`, as axios would with redirects off. The logoff's
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.protocol === 'https:'
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;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,4DAA4D;AAC5D,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7C;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf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CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C;;;;;;;;;;;;OAYG;IACH,kBAAkB,IAAI,OAAO,CAAC;IAE9B,4EAA4E;IAC5E,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD,0EAA0E;IAC1E,SAAS,IAAI,MAAM,GAAG,IAAI,CAAC;IAE3B;;;;;;OAMG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAE3C,oDAAoD;IACpD,aAAa,IAAI,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;;;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"}
@@ -8,6 +8,10 @@
8
8
  * system and a transport is the caller stating which system it is dialling
9
9
  * and what it travels over — the rule the connectors themselves follow.
10
10
  *
11
+ * **Each wire takes its own config shape.** The HTTP wires take an
12
+ * `ISapHttpConfig` (its URL is their base URL), RFC an `ISapRfcConfig` (its
13
+ * stated address, no URL); the compiler refuses the other one.
14
+ *
11
15
  * **A new instance on every call.** One connection instance is one SAP
12
16
  * session: after its `disconnect()` (or a logoff of its own) it is spent, and
13
17
  * a new session is a new call to this.
@@ -22,18 +26,17 @@
22
26
  */
23
27
  import type { AgentOptions } from 'node:https';
24
28
  import type { IAuthProvider } from '@mcp-abap-adt/interfaces-auth';
25
- import type { SapConfig } from '../config/sapConfig.js';
29
+ import type { ISapHttpConfig, ISapRfcConfig } from '@mcp-abap-adt/interfaces-auth-sap';
26
30
  import type { ILogger } from '../logger.js';
27
31
  import { AdtCloudConnector } from './AdtCloudConnector.js';
28
32
  import { AdtOnPremConnector } from './AdtOnPremConnector.js';
29
33
  import { CloudHttpTransport } from './CloudHttpTransport.js';
34
+ import type { HttpClientFactory } from './HttpTransport.js';
30
35
  import { LegacyOnPremHttpTransport } from './LegacyOnPremHttpTransport.js';
31
36
  import { OnPremHttpTransport } from './OnPremHttpTransport.js';
32
37
  import { type IRfcTransportOptions, RfcTransport } from './RfcTransport.js';
33
- /** What every combination takes. */
38
+ /** What every combination takes; each states the shape of its `config`. */
34
39
  interface ConnectionSpecBase<TCredential extends IAuthProvider> {
35
- /** The system: its URL, client and, over RFC, what the conversation needs. */
36
- config: SapConfig;
37
40
  /** The credential, handed to the connector as it is. */
38
41
  credential: TCredential;
39
42
  /** The connection's logger. Absent: none. */
@@ -49,11 +52,19 @@ interface ConnectionSpecBase<TCredential extends IAuthProvider> {
49
52
  }
50
53
  /** What the HTTP wires take besides. */
51
54
  interface HttpWireOptions {
55
+ /** The system: its URL and client. An HTTP config, never an RFC one. */
56
+ config: ISapHttpConfig;
52
57
  /**
53
58
  * The HTTPS agent's options — `ca`, `rejectUnauthorized` and the like, not
54
59
  * the credential (its TLS material arrives at logon). Absent: none.
55
60
  */
56
61
  agentOptions?: (() => AgentOptions) | undefined;
62
+ /**
63
+ * How the wire reaches the network: the factory of its axios instance and
64
+ * of the node request a logoff goes out on. Absent: `nodeHttpClient`, as
65
+ * the transport constructors default.
66
+ */
67
+ httpClient?: HttpClientFactory | undefined;
57
68
  /**
58
69
  * An existing session to build the instance on, instead of logging on: the
59
70
  * string an instance's `sessionCookies()` returned. `connect()` then sends
@@ -75,6 +86,11 @@ export interface OnPremHttpSpec<TCredential extends IAuthProvider = IAuthProvide
75
86
  export interface OnPremRfcSpec<TCredential extends IAuthProvider = IAuthProvider> extends ConnectionSpecBase<TCredential> {
76
87
  system: 'onprem';
77
88
  transport: 'rfc';
89
+ /**
90
+ * The system: its stated RFC address, client and language. An RFC config,
91
+ * which has no URL.
92
+ */
93
+ config: ISapRfcConfig;
78
94
  /** The RFC wire's own options (`logWire`, `maxLoggedBodyChars`). */
79
95
  rfc?: IRfcTransportOptions | undefined;
80
96
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"createConnection.d.ts","sourceRoot":"","sources":["../../src/connection/createConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,oBAAoB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG5E,oCAAoC;AACpC,UAAU,kBAAkB,CAAC,WAAW,SAAS,aAAa;IAC5D,8EAA8E;IAC9E,MAAM,EAAE,SAAS,CAAC;IAClB,wDAAwD;IACxD,UAAU,EAAE,WAAW,CAAC;IACxB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,G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,iBAAiB,CAAC,WAAW,EAAE,kBAAkB,CAAC,GAClD,kBAAkB,CAChB,WAAW,EACX,mBAAmB,GAAG,yBAAyB,GAAG,YAAY,CAC/D,CAAC;AAkBN,wBAAgB,gBAAgB,CAAC,WAAW,SAAS,aAAa,EAChE,IAAI,EAAE,cAAc,CAAC,WAAW,CAAC,GAChC,iBAAiB,CAAC,WAAW,CAAC,CA6EhC"}
@@ -8,37 +8,54 @@ const LegacyOnPremHttpTransport_js_1 = require("./LegacyOnPremHttpTransport.js")
8
8
  const OnPremHttpTransport_js_1 = require("./OnPremHttpTransport.js");
9
9
  const RfcTransport_js_1 = require("./RfcTransport.js");
10
10
  const rfcConversation_js_1 = require("./rfcConversation.js");
11
- /** Whatever a caller passed, read as the two words that pick the wire. */
12
- function stated(spec) {
13
- const record = (spec ?? {});
14
- return { system: record.system, transport: record.transport };
11
+ /**
12
+ * Fixed words: nothing the caller passed is echoed back. Typed `never`: the
13
+ * compiler proves every combination of the spec type is handled before it,
14
+ * so only a caller that broke the types reaches it.
15
+ */
16
+ function noSuchCombination(_spec) {
17
+ throw new TypeError("createConnection: no such combination of system and transport. ABAP Cloud has one wire, 'http'; on-prem takes 'http', 'legacy-http' or 'rfc'. Both are stated by the caller, never inferred.");
18
+ }
19
+ /**
20
+ * What an HTTP wire is told: the config's client and its URL as its address,
21
+ * and the caller's `httpClient` when one is given.
22
+ */
23
+ function httpAddress(spec) {
24
+ return {
25
+ client: spec.config.client,
26
+ baseUrl: spec.config.url,
27
+ ...(spec.httpClient !== undefined ? { httpClient: spec.httpClient } : {}),
28
+ };
15
29
  }
16
30
  function createConnection(spec) {
17
- const { system, transport } = stated(spec);
18
- // Fixed words, before anything is built.
19
- if (transport === 'rfc' &&
20
- spec.session !== undefined) {
21
- throw new TypeError("createConnection: an RFC session cannot be taken over — it is a conversation, not something a cookie names. 'session' is for the HTTP wires; over RFC, connect() opens a new session.");
22
- }
23
31
  const logger = spec.logger ?? null;
24
32
  const wireLogger = spec.wireLogger ?? null;
25
- const address = { client: spec.config.client, baseUrl: spec.config.url };
26
- if (system === 'cloud' && transport === 'http') {
27
- const http = spec;
28
- return new AdtCloudConnector_js_1.AdtCloudConnector(spec.config, spec.credential, new CloudHttpTransport_js_1.CloudHttpTransport(http.agentOptions, wireLogger, address), logger, spec.sessionId, http.session);
29
- }
30
- if (system === 'onprem' && transport === 'http') {
31
- const http = spec;
32
- return new AdtOnPremConnector_js_1.AdtOnPremConnector(spec.config, spec.credential, new OnPremHttpTransport_js_1.OnPremHttpTransport(http.agentOptions, wireLogger, address), logger, spec.sessionId, http.session);
33
+ // The spec is a union discriminated by `transport` and `system`: each branch
34
+ // narrows it to one spec, so its config is that spec's shape.
35
+ switch (spec.transport) {
36
+ case 'http':
37
+ if (spec.system === 'cloud') {
38
+ return new AdtCloudConnector_js_1.AdtCloudConnector(spec.config, spec.credential, new CloudHttpTransport_js_1.CloudHttpTransport(spec.agentOptions, wireLogger, httpAddress(spec)), logger, spec.sessionId, spec.session);
39
+ }
40
+ if (spec.system === 'onprem') {
41
+ return new AdtOnPremConnector_js_1.AdtOnPremConnector(spec.config, spec.credential, new OnPremHttpTransport_js_1.OnPremHttpTransport(spec.agentOptions, wireLogger, httpAddress(spec)), logger, spec.sessionId, spec.session);
42
+ }
43
+ return noSuchCombination(spec);
44
+ case 'legacy-http':
45
+ if (spec.system === 'onprem') {
46
+ return new AdtOnPremConnector_js_1.AdtOnPremConnector(spec.config, spec.credential, new LegacyOnPremHttpTransport_js_1.LegacyOnPremHttpTransport(spec.agentOptions, wireLogger, httpAddress(spec)), logger, spec.sessionId, spec.session);
47
+ }
48
+ return noSuchCombination(spec);
49
+ case 'rfc':
50
+ // Fixed words, before anything is built.
51
+ if (spec.session !== undefined) {
52
+ throw new TypeError("createConnection: an RFC session cannot be taken over — it is a conversation, not something a cookie names. 'session' is for the HTTP wires; over RFC, connect() opens a new session.");
53
+ }
54
+ if (spec.system === 'onprem') {
55
+ return new AdtOnPremConnector_js_1.AdtOnPremConnector(spec.config, spec.credential, new RfcTransport_js_1.RfcTransport((0, rfcConversation_js_1.rfcConversationFrom)(spec.config), wireLogger, spec.rfc), logger, spec.sessionId);
56
+ }
57
+ return noSuchCombination(spec);
58
+ default:
59
+ return noSuchCombination(spec);
33
60
  }
34
- if (system === 'onprem' && transport === 'legacy-http') {
35
- const http = spec;
36
- return new AdtOnPremConnector_js_1.AdtOnPremConnector(spec.config, spec.credential, new LegacyOnPremHttpTransport_js_1.LegacyOnPremHttpTransport(http.agentOptions, wireLogger, address), logger, spec.sessionId, http.session);
37
- }
38
- if (system === 'onprem' && transport === 'rfc') {
39
- const rfc = spec;
40
- return new AdtOnPremConnector_js_1.AdtOnPremConnector(spec.config, spec.credential, new RfcTransport_js_1.RfcTransport((0, rfcConversation_js_1.rfcConversationFrom)(spec.config), wireLogger, rfc.rfc), logger, spec.sessionId);
41
- }
42
- // Fixed words: nothing the caller passed is echoed back.
43
- throw new TypeError("createConnection: no such combination of system and transport. ABAP Cloud has one wire, 'http'; on-prem takes 'http', 'legacy-http' or 'rfc'. Both are stated by the caller, never inferred.");
44
61
  }
@@ -6,13 +6,12 @@
6
6
  * machine, and a transport that reached for it in its constructor could not be
7
7
  * built at all where it is absent. But a factory is a poor front door — without
8
8
  * this, reaching the RFC wire means every consumer writing the `require` and
9
- * deriving `ashost` and `sysnr` for themselves, which is the derivation the
10
- * per-transport connection class used to do for them.
9
+ * mapping the config to the SDK's parameters for themselves.
11
10
  *
12
- * So the derivation lives here, once, and the SDK is still only touched when a
11
+ * So the mapping lives here, once, and the SDK is still only touched when a
13
12
  * conversation is actually opened.
14
13
  */
15
- import type { SapConfig } from '../config/sapConfig.js';
14
+ import type { ISapRfcConfig } from '@mcp-abap-adt/interfaces-auth-sap';
16
15
  import type { IRfcConversation } from './RfcTransport.js';
17
16
  /**
18
17
  * Where the native client dials: one application server. What it logs on with
@@ -29,45 +28,46 @@ export interface RfcConnectionParams {
29
28
  /**
30
29
  * Where the native client dials: a message server, which picks an application
31
30
  * server of the logon group (load-balanced logon). The keys are the SAP NW RFC
32
- * SDK's own; one of `msserv` and `sysid` names the message server's service.
31
+ * SDK's own; `msserv`, `sysid` or both name the message server's service.
33
32
  */
34
- export interface RfcMessageServerParams {
33
+ export type RfcMessageServerParams = {
35
34
  mshost: string;
36
- msserv?: string;
37
- sysid?: string;
38
35
  group: string;
39
36
  client: string;
40
37
  lang: string;
41
38
  saprouter?: string;
42
- }
39
+ } & ({
40
+ msserv: string;
41
+ sysid?: string;
42
+ } | {
43
+ msserv?: string;
44
+ sysid: string;
45
+ });
43
46
  /** One application server, or a message server and a logon group. */
44
47
  export type RfcAddress = RfcConnectionParams | RfcMessageServerParams;
45
48
  /**
46
- * Read out of the config, never asked of the server.
47
- *
48
- * **A message server**, when the config states `mshost`: the SDK needs the
49
- * message server's service, so `msserv` or `sysid` must be there too, and the
50
- * logon group is `group` or SAP's default `PUBLIC`. `url` then gives no host
51
- * and no system number — the message server chooses the application server.
49
+ * The address the config states, in the SDK's terms — read as given, never
50
+ * asked of the server.
52
51
  *
53
- * **One application server** otherwise: the host comes off `url`, and the
54
- * system number off the HTTP port by the SAP convention that 80XX is the ICM
55
- * port for system XX — the convention the port itself follows, not a guess
56
- * about the deployment. `SAP_SYSNR` overrides it for a port that follows no
57
- * convention, which is the case on a system reached through 50400.
52
+ * Nothing is derived and nothing is added: no default client, language or
53
+ * logon group, no host or system number taken from a URL, nothing read from
54
+ * the environment, no value trimmed. `language` is the SDK's `lang`;
55
+ * `msserv`, `sysid` and `saprouter` are there exactly when the config states
56
+ * them. It refuses nothing: the config's type proves the address complete,
57
+ * and data from outside the type system is checked where it is read.
58
58
  *
59
- * `saprouter` goes with either. The address only: no username or password is
60
- * read from the config.
59
+ * The address only: no username or password is read from the config.
61
60
  */
62
- export declare function rfcParamsFrom(config: SapConfig): RfcAddress;
61
+ export declare function rfcParamsFrom(config: ISapRfcConfig): RfcAddress;
63
62
  /**
64
63
  * The factory `RfcTransport` asks for: the logon parameters the provider wrote
65
- * for this open go in, spread over the address from the config.
64
+ * for this open go in, spread over the address the config states; nothing
65
+ * else is added.
66
66
  *
67
67
  * The SDK is loaded when a conversation is opened, not when this is called, so
68
68
  * a consumer can build the transport on a machine that has no SDK and find out
69
69
  * at `connect()` rather than at construction — with a message that says what to
70
70
  * install.
71
71
  */
72
- export declare function rfcConversationFrom(config: SapConfig): (logon: Readonly<Record<string, string>>) => IRfcConversation;
72
+ export declare function rfcConversationFrom(config: ISapRfcConfig): (logon: Readonly<Record<string, string>>) => IRfcConversation;
73
73
  //# sourceMappingURL=rfcConversation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rfcConversation.d.ts","sourceRoot":"","sources":["../../src/connection/rfcConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qEAAqE;AACrE,MAAM,MAAM,UAAU,GAAG,mBAAmB,GAAG,sBAAsB,CAAC;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAA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K,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,gBAAgB,CAoB/D"}
@@ -7,66 +7,45 @@
7
7
  * machine, and a transport that reached for it in its constructor could not be
8
8
  * built at all where it is absent. But a factory is a poor front door — without
9
9
  * this, reaching the RFC wire means every consumer writing the `require` and
10
- * deriving `ashost` and `sysnr` for themselves, which is the derivation the
11
- * per-transport connection class used to do for them.
10
+ * mapping the config to the SDK's parameters for themselves.
12
11
  *
13
- * So the derivation lives here, once, and the SDK is still only touched when a
12
+ * So the mapping lives here, once, and the SDK is still only touched when a
14
13
  * conversation is actually opened.
15
14
  */
16
15
  Object.defineProperty(exports, "__esModule", { value: true });
17
16
  exports.rfcParamsFrom = rfcParamsFrom;
18
17
  exports.rfcConversationFrom = rfcConversationFrom;
19
18
  /**
20
- * Read out of the config, never asked of the server.
19
+ * The address the config states, in the SDK's terms — read as given, never
20
+ * asked of the server.
21
21
  *
22
- * **A message server**, when the config states `mshost`: the SDK needs the
23
- * message server's service, so `msserv` or `sysid` must be there too, and the
24
- * logon group is `group` or SAP's default `PUBLIC`. `url` then gives no host
25
- * and no system number — the message server chooses the application server.
22
+ * Nothing is derived and nothing is added: no default client, language or
23
+ * logon group, no host or system number taken from a URL, nothing read from
24
+ * the environment, no value trimmed. `language` is the SDK's `lang`;
25
+ * `msserv`, `sysid` and `saprouter` are there exactly when the config states
26
+ * them. It refuses nothing: the config's type proves the address complete,
27
+ * and data from outside the type system is checked where it is read.
26
28
  *
27
- * **One application server** otherwise: the host comes off `url`, and the
28
- * system number off the HTTP port by the SAP convention that 80XX is the ICM
29
- * port for system XX — the convention the port itself follows, not a guess
30
- * about the deployment. `SAP_SYSNR` overrides it for a port that follows no
31
- * convention, which is the case on a system reached through 50400.
32
- *
33
- * `saprouter` goes with either. The address only: no username or password is
34
- * read from the config.
29
+ * The address only: no username or password is read from the config.
35
30
  */
36
31
  function rfcParamsFrom(config) {
37
- const client = config.client || '000';
38
- const router = config.saprouter ? { saprouter: config.saprouter } : {};
39
- if (config.mshost) {
40
- if (!config.msserv && !config.sysid) {
41
- throw new Error('An RFC conversation through a message server needs msserv or sysid beside mshost');
42
- }
43
- return {
44
- mshost: config.mshost,
45
- ...(config.msserv ? { msserv: config.msserv } : {}),
46
- ...(config.sysid ? { sysid: config.sysid } : {}),
47
- group: config.group || 'PUBLIC',
48
- client,
49
- lang: 'EN',
50
- ...router,
51
- };
32
+ const router = config.saprouter === undefined ? {} : { saprouter: config.saprouter };
33
+ const logon = { client: config.client, lang: config.language, ...router };
34
+ if (config.mshost === undefined) {
35
+ return { ashost: config.ashost, sysnr: config.sysnr, ...logon };
52
36
  }
53
- if (!config.url) {
54
- throw new Error('An RFC conversation needs a url to take its host from, or mshost for a message server');
55
- }
56
- const parsed = new URL(config.url);
57
- const port = Number.parseInt(parsed.port || '8000', 10);
58
- const derived = String(port - 8000).padStart(2, '0');
59
- return {
60
- ashost: parsed.hostname,
61
- sysnr: process.env.SAP_SYSNR?.trim() || derived,
62
- client,
63
- lang: 'EN',
64
- ...router,
65
- };
37
+ const service = config.msserv === undefined
38
+ ? { sysid: config.sysid }
39
+ : {
40
+ msserv: config.msserv,
41
+ ...(config.sysid === undefined ? {} : { sysid: config.sysid }),
42
+ };
43
+ return { mshost: config.mshost, group: config.group, ...service, ...logon };
66
44
  }
67
45
  /**
68
46
  * The factory `RfcTransport` asks for: the logon parameters the provider wrote
69
- * for this open go in, spread over the address from the config.
47
+ * for this open go in, spread over the address the config states; nothing
48
+ * else is added.
70
49
  *
71
50
  * The SDK is loaded when a conversation is opened, not when this is called, so
72
51
  * a consumer can build the transport on a machine that has no SDK and find out
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { IWebSocketCloseInfo, IWebSocketConnectOptions, IWebSocketMessageEnvelope, IWebSocketMessageHandler, IWebSocketTransport, } from '@mcp-abap-adt/interfaces-network';
2
- export type { SapAuthType, SapConfig, SapConnectionType, } from './config/sapConfig.js';
2
+ export type { SapAuthType, SapConfig, SapConnectionType, SapHttpConfig, SapRfcConfig, } from './config/sapConfig.js';
3
3
  export { sapConfigSignature } from './config/sapConfig.js';
4
4
  export type { AbapConnection, AbapRequestOptions, } from './connection/AbapConnection.js';
5
5
  export { AdtCloudConnector } from './connection/AdtCloudConnector.js';
@@ -9,7 +9,7 @@ export { CloudHttpTransport } from './connection/CloudHttpTransport.js';
9
9
  export { type CloudHttpSpec, type ConnectionSpec, type CreatedConnection, createConnection, type OnPremHttpSpec, type OnPremRfcSpec, } from './connection/createConnection.js';
10
10
  export { CSRF_CONFIG, CSRF_ERROR_MESSAGES } from './connection/csrfConfig.js';
11
11
  export { GenericWebSocketTransport, type IWebSocketFactory, type IWebSocketLike, } from './connection/GenericWebSocketTransport.js';
12
- export { HttpTransport } from './connection/HttpTransport.js';
12
+ export { type HttpClientAgents, type HttpClientFactory, HttpTransport, nodeHttpClient, } from './connection/HttpTransport.js';
13
13
  export type { IAdtEstablishContext, IAdtSessionContext, IAdtTransport, IAdtTransportRequest, IAdtTransportResponse, ICloudTransport, IOnPremTransport, } from './connection/IAdtTransport.js';
14
14
  export { LegacyOnPremHttpTransport } from './connection/LegacyOnPremHttpTransport.js';
15
15
  export { OnPremHttpTransport } from './connection/OnPremHttpTransport.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,kCAAkC,CAAC;AAK1C,YAAY,EACV,WAAW,EACX,SAAS,EACT,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,YAAY,EACV,cAAc,EACd,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;A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KAAK,sBAAsB,EAC3B,mBAAmB,EACnB,aAAa,GACd,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Types - re-exported from the contract packages, under the names this
3
3
  // package has always published them by.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.rfcParamsFrom = exports.rfcConversationFrom = exports.RfcTransport = exports.OnPremHttpTransport = exports.LegacyOnPremHttpTransport = exports.HttpTransport = exports.GenericWebSocketTransport = exports.CSRF_ERROR_MESSAGES = exports.CSRF_CONFIG = exports.createConnection = exports.CloudHttpTransport = exports.WireLogonError = exports.AuthRefusedError = exports.AdtOnPremConnector = exports.AdtCloudConnector = exports.sapConfigSignature = void 0;
5
+ exports.rfcParamsFrom = exports.rfcConversationFrom = exports.RfcTransport = exports.OnPremHttpTransport = exports.LegacyOnPremHttpTransport = exports.nodeHttpClient = exports.HttpTransport = exports.GenericWebSocketTransport = exports.CSRF_ERROR_MESSAGES = exports.CSRF_CONFIG = exports.createConnection = exports.CloudHttpTransport = exports.WireLogonError = exports.AuthRefusedError = exports.AdtOnPremConnector = exports.AdtCloudConnector = exports.sapConfigSignature = void 0;
6
6
  // Config utilities
7
7
  var sapConfig_js_1 = require("./config/sapConfig.js");
8
8
  Object.defineProperty(exports, "sapConfigSignature", { enumerable: true, get: function () { return sapConfig_js_1.sapConfigSignature; } });
@@ -34,6 +34,7 @@ Object.defineProperty(exports, "GenericWebSocketTransport", { enumerable: true,
34
34
  // The transport axis. Both ends are objects, so a caller can name either.
35
35
  var HttpTransport_js_1 = require("./connection/HttpTransport.js");
36
36
  Object.defineProperty(exports, "HttpTransport", { enumerable: true, get: function () { return HttpTransport_js_1.HttpTransport; } });
37
+ Object.defineProperty(exports, "nodeHttpClient", { enumerable: true, get: function () { return HttpTransport_js_1.nodeHttpClient; } });
37
38
  var LegacyOnPremHttpTransport_js_1 = require("./connection/LegacyOnPremHttpTransport.js");
38
39
  Object.defineProperty(exports, "LegacyOnPremHttpTransport", { enumerable: true, get: function () { return LegacyOnPremHttpTransport_js_1.LegacyOnPremHttpTransport; } });
39
40
  var OnPremHttpTransport_js_1 = require("./connection/OnPremHttpTransport.js");
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-20.0.md # an RFC config states its address, client and language; no URL over RFC
18
19
  │ ├── MIGRATION-18.0.md # rfcParamsFrom returns RfcAddress; RFC through a message server
19
20
  │ ├── MIGRATION-17.0.md # no deadline of the package's own; an instance on an existing session
20
21
  │ ├── MIGRATION-16.0.md # the request signal removed; disconnect() resolves once the logoff is written
@@ -49,6 +50,7 @@ mcp-abap-connection/
49
50
  - 🧭 [Scope](./SCOPE.md) - What this package answers for, and only that
50
51
 
51
52
  ### Upgrading
53
+ - 🚚 [Migrating to 20.0.0](./MIGRATION-20.0.md) - an RFC config is an `ISapRfcConfig` stating its address, `client` and `language`: no URL, no defaults, no `SAP_SYSNR`; `getBaseUrl()` may answer `undefined`; HTTP transports take `baseUrl`
52
54
  - 🚚 [Migrating to 18.0.0](./MIGRATION-18.0.md) - `rfcParamsFrom` returns `RfcAddress`; RFC through a message server and a logon group
53
55
  - 🚚 [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()`
54
56
  - 🚚 [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
@@ -1,5 +1,7 @@
1
1
  # Migration to 18.0
2
2
 
3
+ > Superseded by 20.0.0: the address is stated, see [MIGRATION-20.0](./MIGRATION-20.0.md).
4
+
3
5
  18.0.0 adds RFC logon through a message server and a logon group
4
6
  (load-balanced logon). For a consumer on 17.x, the change is confined to the
5
7
  types of one function.