@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.
Files changed (34) hide show
  1. package/CHANGELOG.md +83 -1
  2. package/README.md +110 -26
  3. package/dist/config/sapConfig.d.ts +6 -1
  4. package/dist/config/sapConfig.d.ts.map +1 -1
  5. package/dist/config/sapConfig.js +11 -0
  6. package/dist/connection/AbstractAbapConnection.d.ts +8 -2
  7. package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
  8. package/dist/connection/AbstractAbapConnection.js +17 -8
  9. package/dist/connection/CloudHttpTransport.js +2 -2
  10. package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
  11. package/dist/connection/CredentialAbapConnection.js +0 -1
  12. package/dist/connection/HttpTransport.d.ts +60 -18
  13. package/dist/connection/HttpTransport.d.ts.map +1 -1
  14. package/dist/connection/HttpTransport.js +46 -27
  15. package/dist/connection/IAdtTransport.d.ts +3 -2
  16. package/dist/connection/IAdtTransport.d.ts.map +1 -1
  17. package/dist/connection/RfcTransport.d.ts +64 -9
  18. package/dist/connection/RfcTransport.d.ts.map +1 -1
  19. package/dist/connection/RfcTransport.js +174 -31
  20. package/dist/connection/createConnection.d.ts +20 -4
  21. package/dist/connection/createConnection.d.ts.map +1 -1
  22. package/dist/connection/createConnection.js +45 -28
  23. package/dist/connection/rfcConversation.d.ts +31 -26
  24. package/dist/connection/rfcConversation.d.ts.map +1 -1
  25. package/dist/connection/rfcConversation.js +32 -46
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +2 -1
  29. package/docs/INDEX.md +2 -0
  30. package/docs/MIGRATION-18.0.md +2 -0
  31. package/docs/MIGRATION-20.0.md +121 -0
  32. package/docs/MIGRATION-6.0.md +2 -0
  33. package/docs/USAGE.md +37 -13
  34. package/package.json +3 -3
@@ -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,OA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AC;IACjB;;;OAGG;IACH,MAAM,EAAE,aAAa,CAAC;IACtB,oEAAoE;IACpE,GAAG,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACvC;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,CAAC,WAAW,SAAS,aAAa,GAAG,aAAa,IACxE,aAAa,CAAC,WAAW,CAAC,GAC1B,cAAc,CAAC,WAAW,CAAC,GAC3B,aAAa,CAAC,WAAW,CAAC,CAAC;AAa/B;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAC3B,WAAW,SAAS,aAAa,GAAG,aAAa,IAE/C,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,14 +6,13 @@
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';
16
- import type { IRfcConversation } from './RfcTransport.js';
14
+ import type { ISapRfcConfig } from '@mcp-abap-adt/interfaces-auth-sap';
15
+ import type { RfcConversationFactory } from './RfcTransport.js';
17
16
  /**
18
17
  * Where the native client dials: one application server. What it logs on with
19
18
  * is not here: the provider writes that at each logon (`user`/`passwd`, or the
@@ -29,45 +28,51 @@ 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
+ *
67
+ * It states its logon language (`language`, the config's), so `RfcTransport`
68
+ * can tell a request that names another `sap-language` apart.
66
69
  *
67
70
  * The SDK is loaded when a conversation is opened, not when this is called, so
68
71
  * a consumer can build the transport on a machine that has no SDK and find out
69
72
  * at `connect()` rather than at construction — with a message that says what to
70
73
  * install.
71
74
  */
72
- export declare function rfcConversationFrom(config: SapConfig): (logon: Readonly<Record<string, string>>) => IRfcConversation;
75
+ export declare function rfcConversationFrom(config: ISapRfcConfig): RfcConversationFactory & {
76
+ readonly language: string;
77
+ };
73
78
  //# 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,GAAG,UAAU,CAsC3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,GAChB,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAK,gBAAgB,CAoB/D"}
1
+ {"version":3,"file":"rfcConversation.d.ts","sourceRoot":"","sources":["../../src/connection/rfcConversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAE3B;;;;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,MAAM,sBAAsB,GAAG;IACnC,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,GAAG,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE9E,qEAAqE;AACrE,MAAM,MAAM,UAAU,GAAG,mBAAmB,GAAG,sBAAsB,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAiB/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,GACpB,sBAAsB,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAwBxD"}
@@ -7,66 +7,48 @@
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
- };
52
- }
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');
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 };
55
36
  }
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.
49
+ *
50
+ * It states its logon language (`language`, the config's), so `RfcTransport`
51
+ * can tell a request that names another `sap-language` apart.
70
52
  *
71
53
  * The SDK is loaded when a conversation is opened, not when this is called, so
72
54
  * a consumer can build the transport on a machine that has no SDK and find out
@@ -75,7 +57,7 @@ function rfcParamsFrom(config) {
75
57
  */
76
58
  function rfcConversationFrom(config) {
77
59
  const params = rfcParamsFrom(config);
78
- return (logon) => {
60
+ const open = (logon) => {
79
61
  let Client;
80
62
  try {
81
63
  // Dynamic, because the SDK is an optional peer: it needs the SAP NW RFC
@@ -89,4 +71,8 @@ function rfcConversationFrom(config) {
89
71
  }
90
72
  return new Client({ ...params, ...logon });
91
73
  };
74
+ // The language every conversation it opens logs on in, unless the logon
75
+ // names another: what `RfcTransport` tells a request's `sap-language` apart
76
+ // from.
77
+ return Object.assign(open, { language: params.lang });
92
78
  }
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,11 +9,11 @@ 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';
16
- export { type IRfcConversation, type IRfcTransportOptions, RfcTransport, } from './connection/RfcTransport.js';
16
+ export { type IRfcConversation, type IRfcTransportOptions, type RfcConversationFactory, RfcTransport, } from './connection/RfcTransport.js';
17
17
  export { type RfcAddress, type RfcConnectionParams, type RfcMessageServerParams, rfcConversationFrom, rfcParamsFrom, } from './connection/rfcConversation.js';
18
18
  export type { ILogger } from './logger.js';
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -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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AC;AAGtC,OAAO,EACL,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,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.
@@ -0,0 +1,121 @@
1
+ # Migration to 20.0
2
+
3
+ 20.0.0 takes an RFC destination's address as the config states it. An RFC
4
+ config has no URL: it names the server it dials — one application server, or a
5
+ message server and a logon group — and its client and logon language, and the
6
+ SAP NW RFC SDK gets exactly that. Nothing of the address is derived from a URL,
7
+ nothing is defaulted, nothing is read from the environment.
8
+
9
+ It rests on `@mcp-abap-adt/interfaces-auth-sap` 4.0.0, where `ISapConfig` is a
10
+ union by connection type, and `@mcp-abap-adt/interfaces-adt-connection` 4.0.0,
11
+ where `getBaseUrl()` may answer `undefined`. Both are required (`^4.0.0`).
12
+
13
+ ## What changed
14
+
15
+ - **An RFC config is an `ISapRfcConfig`** (exported here as `SapRfcConfig`):
16
+ `connectionType: 'rfc'`, `client`, `language`, and one address:
17
+ - an application server: `ashost` and `sysnr`;
18
+ - a message server: `mshost`, its service as `msserv`, `sysid` or both, and
19
+ `group`.
20
+
21
+ `saprouter` goes with either. An RFC config takes no `url`; an HTTP config
22
+ (`ISapHttpConfig`, exported as `SapHttpConfig`: `connectionType` `'http'` or
23
+ absent, and `url`) takes none of the RFC keys, `saprouter` and `language`
24
+ included. The compiler refuses a config that states two addresses, an
25
+ incomplete one, or a key of the other shape.
26
+ - **`rfcParamsFrom(config)` and `rfcConversationFrom(config)` take an
27
+ `ISapRfcConfig` and read it as stated.** Gone:
28
+ - the host taken from `url` and the system number from its port (`80NN` →
29
+ `NN`);
30
+ - `SAP_SYSNR` read from `process.env`;
31
+ - the defaults `client` `'000'`, `lang` `'EN'` and `group` `'PUBLIC'`;
32
+ - the two throws (no `url`; `mshost` without `msserv` or `sysid`): the type
33
+ proves the address complete.
34
+
35
+ `language` reaches the SDK as `lang`; `msserv`, `sysid` and `saprouter` are
36
+ there exactly when the config states them; no value is trimmed. The
37
+ provider's logon parameters are still spread over the address at each open:
38
+ where they name a key of the address, the logon's value is the one sent.
39
+ - **`RfcMessageServerParams`** is the "`msserv`, `sysid` or both" shape: a
40
+ union in which at least one of the two is a `string`.
41
+ - **`createConnection`: each spec takes its own config shape.** `CloudHttpSpec`
42
+ and `OnPremHttpSpec` take an `ISapHttpConfig`, `OnPremRfcSpec` an
43
+ `ISapRfcConfig`; the other shape does not compile. A combination of `system`
44
+ and `transport` that does not exist does not compile either; built past the
45
+ types, it is still refused with the fixed `TypeError`, as is any other value
46
+ passed as the spec. Only a `null` or `undefined` spec now fails with the
47
+ runtime's own `TypeError` rather than those fixed words.
48
+ - **`getBaseUrl(): Promise<string | undefined>`.** An HTTP connection answers
49
+ the origin of its `url`, as before. An RFC connection answers `undefined`: it
50
+ has no HTTP origin, and none is invented. Construction no longer parses a URL
51
+ for an RFC config.
52
+ - **The HTTP transports own their base URL.** `HttpTransport`,
53
+ `OnPremHttpTransport`, `LegacyOnPremHttpTransport` and `CloudHttpTransport`
54
+ take `baseUrl` as a required option (`{ client?, baseUrl }`). A path a caller
55
+ sends is put on it; the requests the wire makes on its own — the CSRF fetch,
56
+ the cloud preflight, the logoff — go to its origin, as they did.
57
+ - **Added: `httpClient`, an optional HTTP-transport option** (`{ client?, baseUrl,
58
+ httpClient? }`): an `HttpClientFactory` that builds the axios instance the
59
+ wire sends through from its agents and opens the Node request a logoff goes
60
+ out on. Left out, it is `nodeHttpClient`, what the wire used before — nothing
61
+ to do unless you want something of your own under the wire, such as a test
62
+ double. `createConnection` takes it too, beside `agentOptions`, for its
63
+ three HTTP combinations.
64
+ - **`IAdtSessionContext` has no `baseUrl`.** The connection hands a wire no
65
+ address; `establishSession` no longer reads `getBaseUrl()`.
66
+ - **`sapConfigSignature`** also carries `connectionType`, the RFC address
67
+ fields and `language`: two configs that dial different servers never share a
68
+ signature.
69
+
70
+ ## What to do
71
+
72
+ **An RFC config states its address, client and language.** Remove `url`; add
73
+ what was derived or defaulted:
74
+
75
+ ```diff
76
+ const config = {
77
+ - url: 'http://saphost:8042',
78
+ + connectionType: 'rfc',
79
+ + ashost: 'saphost', // the host the URL named
80
+ + sysnr: '42', // the two digits of its 80NN port, or the SAP_SYSNR you set
81
+ + client: '000', // if you relied on the default
82
+ + language: 'EN', // if you relied on the default
83
+ authType: 'basic',
84
+ };
85
+ ```
86
+
87
+ A message-server config adds `connectionType: 'rfc'`, `client`, `language`, and
88
+ `group: 'PUBLIC'` if it relied on that default; it removes `url`. `SAP_SYSNR`
89
+ in the environment is no longer read: put its value in `sysnr`.
90
+
91
+ Type the config you build for RFC as `SapRfcConfig` (or `ISapRfcConfig`) and
92
+ the one for HTTP as `SapHttpConfig`; a value of the whole union narrows on
93
+ `connectionType === 'rfc'` before it is handed to `rfcConversationFrom` or an
94
+ RFC spec. Data you read from outside the type system — an env file, the
95
+ environment, YAML — is yours to check before you build the config: this package
96
+ refuses nothing about a typed config.
97
+
98
+ **`getBaseUrl()` may answer `undefined`.** Narrow before you use it:
99
+
100
+ ```typescript
101
+ const origin = await connection.getBaseUrl();
102
+ if (origin !== undefined) {
103
+ // an HTTP connection: its origin
104
+ }
105
+ ```
106
+
107
+ **A hand-built HTTP transport takes `baseUrl`:**
108
+
109
+ ```diff
110
+ -new OnPremHttpTransport(() => ({}), logger, { client: config.client })
111
+ +new OnPremHttpTransport(() => ({}), logger, {
112
+ + client: config.client,
113
+ + baseUrl: config.url,
114
+ +})
115
+ ```
116
+
117
+ **A custom wire or test double reading `context.baseUrl`** takes its address
118
+ from its own construction instead: the session context no longer carries one.
119
+
120
+ If you only pass an HTTP config to `createConnection` or the connectors, there
121
+ is nothing to do.
@@ -153,6 +153,8 @@ about the certificate.
153
153
 
154
154
  ## Taking the RFC wire
155
155
 
156
+ > Superseded by 20.0.0: the address is stated, see [MIGRATION-20.0](./MIGRATION-20.0.md).
157
+
156
158
  `connectionType: 'rfc'` is gone. The wire is an argument now, which is what it
157
159
  always was in fact:
158
160