@mcp-abap-adt/connection 24.0.0 → 25.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +81 -1
- package/README.md +55 -6
- package/dist/connection/AbstractAbapConnection.d.ts +1 -0
- package/dist/connection/AbstractAbapConnection.d.ts.map +1 -1
- package/dist/connection/AbstractAbapConnection.js +26 -9
- package/dist/connection/CloudHttpTransport.d.ts.map +1 -1
- package/dist/connection/CloudHttpTransport.js +2 -1
- package/dist/connection/CredentialAbapConnection.d.ts.map +1 -1
- package/dist/connection/CredentialAbapConnection.js +2 -1
- package/dist/connection/GenericWebSocketTransport.d.ts +6 -0
- package/dist/connection/GenericWebSocketTransport.d.ts.map +1 -1
- package/dist/connection/GenericWebSocketTransport.js +22 -10
- package/dist/connection/HttpTransport.d.ts +4 -4
- package/dist/connection/HttpTransport.d.ts.map +1 -1
- package/dist/connection/HttpTransport.js +22 -9
- package/dist/connection/IAdtTransport.d.ts +4 -3
- package/dist/connection/IAdtTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.d.ts +6 -0
- package/dist/connection/RfcTransport.d.ts.map +1 -1
- package/dist/connection/RfcTransport.js +40 -71
- package/dist/connection/authErrors.d.ts +21 -5
- package/dist/connection/authErrors.d.ts.map +1 -1
- package/dist/connection/authErrors.js +29 -6
- package/dist/connection/failureFacts.d.ts +100 -0
- package/dist/connection/failureFacts.d.ts.map +1 -0
- package/dist/connection/failureFacts.js +280 -0
- package/dist/connection/rfcConversation.d.ts +2 -0
- package/dist/connection/rfcConversation.d.ts.map +1 -1
- package/dist/connection/rfcConversation.js +16 -4
- package/docs/INDEX.md +2 -0
- package/docs/MIGRATION-10.0.md +11 -1
- package/docs/MIGRATION-12.0.md +8 -0
- package/docs/MIGRATION-25.0.md +88 -0
- package/docs/MIGRATION-4.0.md +4 -0
- package/docs/USAGE.md +21 -10
- package/package.json +1 -1
|
@@ -57,8 +57,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
57
57
|
exports.RfcTransport = void 0;
|
|
58
58
|
const node_crypto_1 = require("node:crypto");
|
|
59
59
|
const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
|
|
60
|
-
const interfaces_adt_connection_1 = require("@mcp-abap-adt/interfaces-adt-connection");
|
|
61
60
|
const authErrors_js_1 = require("./authErrors.js");
|
|
61
|
+
const failureFacts_js_1 = require("./failureFacts.js");
|
|
62
|
+
const rfcConversation_js_1 = require("./rfcConversation.js");
|
|
62
63
|
const statefulRequest_js_1 = require("./statefulRequest.js");
|
|
63
64
|
/**
|
|
64
65
|
* The SDK answers with untyped structures: each level is read as a record and
|
|
@@ -190,76 +191,26 @@ function statusFromExceptionXml(body) {
|
|
|
190
191
|
? EXCEPTION_STATUS[type]
|
|
191
192
|
: { code: 500, text: 'Internal Server Error' };
|
|
192
193
|
}
|
|
193
|
-
/** An own data property of `source`, read without running a getter. */
|
|
194
|
-
function ownData(source, name) {
|
|
195
|
-
const descriptor = Object.getOwnPropertyDescriptor(source, name);
|
|
196
|
-
return descriptor !== undefined && 'value' in descriptor
|
|
197
|
-
? descriptor.value
|
|
198
|
-
: undefined;
|
|
199
|
-
}
|
|
200
|
-
function isInteger(value) {
|
|
201
|
-
return typeof value === 'number' && Number.isInteger(value);
|
|
202
|
-
}
|
|
203
194
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* The one place an SDK error enters, so the one place it is checked: `key` and
|
|
207
|
-
* `codeString` own data properties holding strings, `group` and `code` own
|
|
208
|
-
* data properties holding integers, and `codeString` one of the closed list
|
|
209
|
-
* `RFC_RCS`. No getter runs, and an object whose traps throw reads as no
|
|
210
|
-
* shape. `name` and `message` are not read, and nothing is read out of a
|
|
211
|
-
* message.
|
|
212
|
-
*/
|
|
213
|
-
function rfcErrorOf(thrown) {
|
|
214
|
-
if (typeof thrown !== 'object' || thrown === null)
|
|
215
|
-
return undefined;
|
|
216
|
-
try {
|
|
217
|
-
const key = ownData(thrown, 'key');
|
|
218
|
-
const group = ownData(thrown, 'group');
|
|
219
|
-
const code = ownData(thrown, 'code');
|
|
220
|
-
const codeString = ownData(thrown, 'codeString');
|
|
221
|
-
if (typeof key !== 'string' || !isInteger(group) || !isInteger(code)) {
|
|
222
|
-
return undefined;
|
|
223
|
-
}
|
|
224
|
-
// Compared with each listed name, so only a string can match: this is
|
|
225
|
-
// the check of `codeString`, and what is stored is the listed member.
|
|
226
|
-
const listed = interfaces_adt_connection_1.RFC_RCS.find((name) => name === codeString);
|
|
227
|
-
if (listed === undefined)
|
|
228
|
-
return undefined;
|
|
229
|
-
return Object.freeze({ key, group, code, codeString: listed });
|
|
230
|
-
}
|
|
231
|
-
catch {
|
|
232
|
-
return undefined;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* What a failed call throws: an `Error` with today's words, and the SDK's
|
|
237
|
-
* fields as `rfc` when the SDK named the failure. The top-level `code` is not
|
|
195
|
+
* What a failed call throws: an `Error` in fixed words, and the SDK's fields
|
|
196
|
+
* as `rfc` when the SDK named the failure. The top-level `code` is not
|
|
238
197
|
* set: `rfc` does not change what it means.
|
|
239
198
|
*/
|
|
240
199
|
function rfcCallError(text, rfc) {
|
|
241
200
|
const error = new Error(text);
|
|
242
201
|
return rfc === undefined ? error : Object.assign(error, { rfc });
|
|
243
202
|
}
|
|
244
|
-
/**
|
|
245
|
-
const
|
|
203
|
+
/** The words for a failure the SDK did not name with its fields. */
|
|
204
|
+
const UNNAMED = 'the SDK did not name the failure';
|
|
246
205
|
/**
|
|
247
|
-
* A
|
|
248
|
-
* `
|
|
249
|
-
*
|
|
250
|
-
*
|
|
206
|
+
* A failure in fixed words: the return code the SDK named — a member of the
|
|
207
|
+
* closed list `RFC_RCS` — else fixed words. Nothing the thrown value says is
|
|
208
|
+
* read: the SDK's text names the partner it dialled (`host:port`), the time
|
|
209
|
+
* and the kernel's source module, and none of it may reach a message or a log
|
|
210
|
+
* line. What the SDK said reaches a caller as `rfc`, its fields.
|
|
251
211
|
*/
|
|
252
|
-
function
|
|
253
|
-
|
|
254
|
-
if (e instanceof Error)
|
|
255
|
-
return String(e.message);
|
|
256
|
-
if (e && typeof e === 'object')
|
|
257
|
-
return String(JSON.stringify(e));
|
|
258
|
-
return String(e);
|
|
259
|
-
}
|
|
260
|
-
catch {
|
|
261
|
-
return UNDESCRIBABLE;
|
|
262
|
-
}
|
|
212
|
+
function failureWords(thrown) {
|
|
213
|
+
return (0, failureFacts_js_1.rfcErrorOf)(thrown)?.codeString ?? UNNAMED;
|
|
263
214
|
}
|
|
264
215
|
/**
|
|
265
216
|
* Header names whose VALUE must never reach a log.
|
|
@@ -553,7 +504,7 @@ class RfcTransport {
|
|
|
553
504
|
await conversation.close();
|
|
554
505
|
}
|
|
555
506
|
catch (e) {
|
|
556
|
-
this.logQuietly(() => `RFC close error: ${
|
|
507
|
+
this.logQuietly(() => `RFC close error: ${failureWords(e)}`);
|
|
557
508
|
return;
|
|
558
509
|
}
|
|
559
510
|
this.logQuietly(() => 'RFC conversation closed');
|
|
@@ -660,7 +611,7 @@ class RfcTransport {
|
|
|
660
611
|
}
|
|
661
612
|
catch (e) {
|
|
662
613
|
// A context that could not be reset must not serve the next call.
|
|
663
|
-
this.logQuietly(() => `RFC reset failed, dropping the conversation: ${
|
|
614
|
+
this.logQuietly(() => `RFC reset failed, dropping the conversation: ${failureWords(e)}`);
|
|
664
615
|
this.dropStateless(kept);
|
|
665
616
|
await this.closeQuietly(kept);
|
|
666
617
|
}
|
|
@@ -765,9 +716,26 @@ class RfcTransport {
|
|
|
765
716
|
* A new conversation, logged on with `parameters`; a failed open is a
|
|
766
717
|
* refused logon whose cause is the SDK's own error, untouched — a provider
|
|
767
718
|
* reads its `key` and message.
|
|
719
|
+
*
|
|
720
|
+
* A factory that throws while building the conversation — the SDK's client
|
|
721
|
+
* constructor, or a consumer's factory — is not a logon: nothing was sent.
|
|
722
|
+
* It is said in fixed words with the SDK's fields as `rfc`, never the
|
|
723
|
+
* thrown value's text — except the shipped factory's own fixed words, which
|
|
724
|
+
* go as they are.
|
|
768
725
|
*/
|
|
769
726
|
async openedWith(parameters) {
|
|
770
|
-
|
|
727
|
+
let conversation;
|
|
728
|
+
try {
|
|
729
|
+
conversation = this.connect(parameters);
|
|
730
|
+
}
|
|
731
|
+
catch (e) {
|
|
732
|
+
// The shipped factory's own words (sap-rfc-lite missing, and what to
|
|
733
|
+
// install) quote nothing, and say more than these would.
|
|
734
|
+
if ((0, rfcConversation_js_1.isFactoryOwnWords)(e))
|
|
735
|
+
throw e;
|
|
736
|
+
const rfc = (0, failureFacts_js_1.rfcErrorOf)(e);
|
|
737
|
+
throw rfcCallError(`The RFC conversation could not be built: ${rfc?.codeString ?? UNNAMED}`, rfc);
|
|
738
|
+
}
|
|
771
739
|
try {
|
|
772
740
|
await conversation.open();
|
|
773
741
|
}
|
|
@@ -794,7 +762,7 @@ class RfcTransport {
|
|
|
794
762
|
await conversation.close();
|
|
795
763
|
}
|
|
796
764
|
catch (e) {
|
|
797
|
-
this.logQuietly(() => `RFC close error: ${
|
|
765
|
+
this.logQuietly(() => `RFC close error: ${failureWords(e)}`);
|
|
798
766
|
}
|
|
799
767
|
}
|
|
800
768
|
async carry(request, conversation, generation, passport,
|
|
@@ -890,8 +858,9 @@ class RfcTransport {
|
|
|
890
858
|
// An RFC-level failure, not an answer: nothing came back to classify.
|
|
891
859
|
// The verdict comes first — the SDK's fields, read once, and whether the
|
|
892
860
|
// session survived — so nothing that describes the failure afterwards
|
|
893
|
-
// (
|
|
894
|
-
|
|
861
|
+
// (a logger) can stand in for it. The words are the return code's, or
|
|
862
|
+
// fixed: the SDK's text is never read (`failureWords`).
|
|
863
|
+
const rfc = (0, failureFacts_js_1.rfcErrorOf)(e);
|
|
895
864
|
// The library released the stateful conversation after the error
|
|
896
865
|
// (`alive` false), and it was not a close() of ours: the session it
|
|
897
866
|
// carried is gone, with every lock taken in it. Said, not cured — no
|
|
@@ -899,10 +868,10 @@ class RfcTransport {
|
|
|
899
868
|
const lost = carriesSession && !conversation.alive && generation === this.generation;
|
|
900
869
|
if (lost)
|
|
901
870
|
this.dropSession(conversation);
|
|
902
|
-
const
|
|
903
|
-
const text = `RFC call to SADT_REST_RFC_ENDPOINT failed: ${
|
|
871
|
+
const words = rfc?.codeString ?? UNNAMED;
|
|
872
|
+
const text = `RFC call to SADT_REST_RFC_ENDPOINT failed: ${words}`;
|
|
904
873
|
try {
|
|
905
|
-
this.logger?.error(`RFC call failed: ${
|
|
874
|
+
this.logger?.error(`RFC call failed: ${words}`);
|
|
906
875
|
}
|
|
907
876
|
catch {
|
|
908
877
|
// A broken logger must not replace the call's failure.
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { IAbapConnectionError, IRfcErrorInfo } from '@mcp-abap-adt/interfaces-adt-connection';
|
|
6
6
|
import type { AuthOutcome, IAuthRefusal } from '@mcp-abap-adt/interfaces-auth';
|
|
7
|
+
import { type FailureCopy } from './failureFacts.js';
|
|
7
8
|
/** When in the connection's life the credential refused. */
|
|
8
9
|
export type AuthRefusalMoment = 'prepare' | 'logon' | 'request';
|
|
9
10
|
/**
|
|
@@ -14,14 +15,18 @@ export type AuthRefusalMoment = 'prepare' | 'logon' | 'request';
|
|
|
14
15
|
* (or the connection's own), classified on the way in: a refusal that is not
|
|
15
16
|
* this copy's minted error is rebuilt from its kind and facts, or else is
|
|
16
17
|
* `provider-threw` — decide on its `kind` and `facts`; the message is its
|
|
17
|
-
* `reason — hint`. `cause`
|
|
18
|
-
*
|
|
19
|
-
* it
|
|
18
|
+
* `reason — hint`. `cause` says the wire's error — or, when the provider threw
|
|
19
|
+
* instead of answering, that throw — by its facts, so a network failure stays
|
|
20
|
+
* visible even when a provider words it as a credential problem: a copy
|
|
21
|
+
* (`failureCopy`) in fixed words with its `code`, `status` and `rfc`, never
|
|
22
|
+
* the value itself — an RFC SDK's text names the partner's host and port, an
|
|
23
|
+
* axios error holds the request's credential headers. The provider was handed
|
|
24
|
+
* the wire's error as it arrived (`IAuthRejection.error`).
|
|
20
25
|
*/
|
|
21
26
|
export declare class AuthRefusedError extends Error {
|
|
22
27
|
readonly refusal: IAuthRefusal;
|
|
23
28
|
readonly at: AuthRefusalMoment;
|
|
24
|
-
readonly cause
|
|
29
|
+
readonly cause: FailureCopy | undefined;
|
|
25
30
|
constructor(refusal: IAuthRefusal, at: AuthRefusalMoment, cause?: unknown);
|
|
26
31
|
}
|
|
27
32
|
/**
|
|
@@ -29,13 +34,24 @@ export declare class AuthRefusedError extends Error {
|
|
|
29
34
|
* do about it is the provider's answer, not the wire's.
|
|
30
35
|
*
|
|
31
36
|
* Exported so a consumer's own wire can say the same thing. `cause` is the raw
|
|
32
|
-
* error, the same object, never re-wrapped
|
|
37
|
+
* error, the same object, never re-wrapped: the provider reads it
|
|
38
|
+
* (`IAuthRejection.error`). The message is fixed words and the status, never
|
|
39
|
+
* the cause's text — an RFC SDK's names the partner it dialled. It is the
|
|
40
|
+
* wire's mark to the connection: the connection hands a consumer none with a
|
|
41
|
+
* raw cause (`outwardLogonError`).
|
|
33
42
|
*/
|
|
34
43
|
export declare class WireLogonError extends Error {
|
|
35
44
|
readonly status?: number;
|
|
36
45
|
readonly cause: unknown;
|
|
37
46
|
constructor(cause: unknown, status?: number);
|
|
38
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* A `WireLogonError` as it may leave the connection: the same status, its
|
|
50
|
+
* cause a copy in fixed words with its facts (`failureCopy`), never the wire's
|
|
51
|
+
* raw error — which the provider was handed, and which may hold an RFC SDK's
|
|
52
|
+
* text or a request's credential headers. Anything else is returned as it is.
|
|
53
|
+
*/
|
|
54
|
+
export declare function outwardLogonError(error: unknown): unknown;
|
|
39
55
|
/**
|
|
40
56
|
* A wire's mark: the session this wire carries has ended under it — over RFC,
|
|
41
57
|
* an RFC error ended the stateful conversation, and the locks taken in it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authErrors.d.ts","sourceRoot":"","sources":["../../src/connection/authErrors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACd,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"authErrors.d.ts","sourceRoot":"","sources":["../../src/connection/authErrors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACd,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,mBAAmB,CAAC;AAElE,4DAA4D;AAC5D,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,EAAE,EAAE,iBAAiB,CAAC;IAC/B,SAAkB,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;gBAErC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,OAAO;CAU1E;AAmBD;;;;;;;;;;GAUG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,SAAkB,KAAK,EAAE,OAAO,CAAC;gBAErB,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM;CAU5C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAIzD;AAED;;;;;;;;GAQG;AACH,qBAAa,oBACX,SAAQ,KACR,YAAW,oBAAoB;IAE/B,QAAQ,CAAC,GAAG,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;gBAE7B,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,aAAa;CAKjD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAElE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAEhE;AAED,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,EAAE,YAEnC,CAAC;AAEH;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,EAChC,EAAE,EAAE,iBAAiB,GACpB,OAAO,CAAC,aAAa,CAAC,CAOxB"}
|
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.NO_CREDENTIAL_TO_RENEW = exports.WireSessionLostError = exports.WireLogonError = exports.AuthRefusedError = void 0;
|
|
8
|
+
exports.outwardLogonError = outwardLogonError;
|
|
8
9
|
exports.providerFailed = providerFailed;
|
|
9
10
|
exports.refusedAgain = refusedAgain;
|
|
10
11
|
exports.guarded = guarded;
|
|
11
12
|
const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
|
|
13
|
+
const failureFacts_js_1 = require("./failureFacts.js");
|
|
12
14
|
/**
|
|
13
15
|
* The credential said no, or the system refused it and the provider's answer
|
|
14
16
|
* is final.
|
|
@@ -17,9 +19,13 @@ const auth_errors_1 = require("@mcp-abap-adt/auth-errors");
|
|
|
17
19
|
* (or the connection's own), classified on the way in: a refusal that is not
|
|
18
20
|
* this copy's minted error is rebuilt from its kind and facts, or else is
|
|
19
21
|
* `provider-threw` — decide on its `kind` and `facts`; the message is its
|
|
20
|
-
* `reason — hint`. `cause`
|
|
21
|
-
*
|
|
22
|
-
* it
|
|
22
|
+
* `reason — hint`. `cause` says the wire's error — or, when the provider threw
|
|
23
|
+
* instead of answering, that throw — by its facts, so a network failure stays
|
|
24
|
+
* visible even when a provider words it as a credential problem: a copy
|
|
25
|
+
* (`failureCopy`) in fixed words with its `code`, `status` and `rfc`, never
|
|
26
|
+
* the value itself — an RFC SDK's text names the partner's host and port, an
|
|
27
|
+
* axios error holds the request's credential headers. The provider was handed
|
|
28
|
+
* the wire's error as it arrived (`IAuthRejection.error`).
|
|
23
29
|
*/
|
|
24
30
|
class AuthRefusedError extends Error {
|
|
25
31
|
refusal;
|
|
@@ -31,7 +37,7 @@ class AuthRefusedError extends Error {
|
|
|
31
37
|
this.name = 'AuthRefusedError';
|
|
32
38
|
this.refusal = checked;
|
|
33
39
|
this.at = at;
|
|
34
|
-
this.cause = cause;
|
|
40
|
+
this.cause = (0, failureFacts_js_1.failureCopy)(cause);
|
|
35
41
|
}
|
|
36
42
|
}
|
|
37
43
|
exports.AuthRefusedError = AuthRefusedError;
|
|
@@ -53,19 +59,36 @@ function checkedRefusal(refusal, at) {
|
|
|
53
59
|
* do about it is the provider's answer, not the wire's.
|
|
54
60
|
*
|
|
55
61
|
* Exported so a consumer's own wire can say the same thing. `cause` is the raw
|
|
56
|
-
* error, the same object, never re-wrapped
|
|
62
|
+
* error, the same object, never re-wrapped: the provider reads it
|
|
63
|
+
* (`IAuthRejection.error`). The message is fixed words and the status, never
|
|
64
|
+
* the cause's text — an RFC SDK's names the partner it dialled. It is the
|
|
65
|
+
* wire's mark to the connection: the connection hands a consumer none with a
|
|
66
|
+
* raw cause (`outwardLogonError`).
|
|
57
67
|
*/
|
|
58
68
|
class WireLogonError extends Error {
|
|
59
69
|
status;
|
|
60
70
|
cause;
|
|
61
71
|
constructor(cause, status) {
|
|
62
|
-
super(
|
|
72
|
+
super(status === undefined
|
|
73
|
+
? 'The logon failed'
|
|
74
|
+
: `The logon failed (status ${status})`);
|
|
63
75
|
this.name = 'WireLogonError';
|
|
64
76
|
this.cause = cause;
|
|
65
77
|
this.status = status;
|
|
66
78
|
}
|
|
67
79
|
}
|
|
68
80
|
exports.WireLogonError = WireLogonError;
|
|
81
|
+
/**
|
|
82
|
+
* A `WireLogonError` as it may leave the connection: the same status, its
|
|
83
|
+
* cause a copy in fixed words with its facts (`failureCopy`), never the wire's
|
|
84
|
+
* raw error — which the provider was handed, and which may hold an RFC SDK's
|
|
85
|
+
* text or a request's credential headers. Anything else is returned as it is.
|
|
86
|
+
*/
|
|
87
|
+
function outwardLogonError(error) {
|
|
88
|
+
return error instanceof WireLogonError
|
|
89
|
+
? new WireLogonError((0, failureFacts_js_1.failureCopy)(error.cause), error.status)
|
|
90
|
+
: error;
|
|
91
|
+
}
|
|
69
92
|
/**
|
|
70
93
|
* A wire's mark: the session this wire carries has ended under it — over RFC,
|
|
71
94
|
* an RFC error ended the stateful conversation, and the locks taken in it
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a thrown value may say about itself to a caller or a log line: its
|
|
3
|
+
* typed facts, never its text.
|
|
4
|
+
*
|
|
5
|
+
* A thrown value comes from outside the type system — the NW RFC SDK, axios,
|
|
6
|
+
* Node's sockets, a WebSocket library, a consumer's own code — and its message,
|
|
7
|
+
* stack, cause and fields carry whatever its author put there: a gateway's
|
|
8
|
+
* `host:port`, a URL with credentials in it, a request's headers. So nothing
|
|
9
|
+
* of it is quoted. What it says is read as facts, each checked where it is
|
|
10
|
+
* read — the RFC SDK's fields (`rfc`), a Node or axios error code (`code`),
|
|
11
|
+
* an HTTP status (`status`) — and said in fixed words built from those facts.
|
|
12
|
+
*
|
|
13
|
+
* Every read is of an own data property: no getter runs, and an object whose
|
|
14
|
+
* traps throw reads as having no facts.
|
|
15
|
+
*/
|
|
16
|
+
import { type IAbapConnectionError, type IRfcErrorInfo } from '@mcp-abap-adt/interfaces-adt-connection';
|
|
17
|
+
import type { IAdtTransportResponse } from './IAdtTransport.js';
|
|
18
|
+
/** An own data property of `source`, read without running a getter. */
|
|
19
|
+
export declare function ownData(source: object, name: string): unknown;
|
|
20
|
+
/**
|
|
21
|
+
* The SDK's error as fields, or `undefined` when `thrown` is not that shape.
|
|
22
|
+
*
|
|
23
|
+
* The one place an SDK error enters, so the one place it is checked: `key` and
|
|
24
|
+
* `codeString` own data properties holding strings, `group` and `code` own
|
|
25
|
+
* data properties holding integers, and `codeString` one of the closed list
|
|
26
|
+
* `RFC_RCS`. No getter runs, and an object whose traps throw reads as no
|
|
27
|
+
* shape. `name` and `message` are not read, and nothing is read out of a
|
|
28
|
+
* message.
|
|
29
|
+
*/
|
|
30
|
+
export declare function rfcErrorOf(thrown: unknown): IRfcErrorInfo | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* A code as a Node or axios error carries it (`ECONNREFUSED`,
|
|
33
|
+
* `ERR_BAD_REQUEST`, one of `ADT_SESSION_ERROR`): a non-empty string of
|
|
34
|
+
* upper-case ASCII letters, digits and `_` only, at most 64 of them. Anything
|
|
35
|
+
* else is no code — free text is never taken for one.
|
|
36
|
+
*/
|
|
37
|
+
export declare function codeOf(thrown: unknown): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The code a thrown value carries: its own (`codeOf`), else the first one down
|
|
40
|
+
* its `cause` chain (own data properties, at most four deep) — a client that
|
|
41
|
+
* wraps a socket's failure (`fetch failed`, its cause `ECONNREFUSED`) says it
|
|
42
|
+
* there.
|
|
43
|
+
*/
|
|
44
|
+
export declare function failureCode(thrown: unknown): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* The HTTP status a thrown value carries: its own `status`, else its
|
|
47
|
+
* `response`'s — `undefined` when neither is an HTTP status.
|
|
48
|
+
*/
|
|
49
|
+
export declare function statusOf(thrown: unknown): number | undefined;
|
|
50
|
+
/** The facts a thrown value is said by. */
|
|
51
|
+
export interface FailureFacts {
|
|
52
|
+
readonly code?: string;
|
|
53
|
+
readonly status?: number;
|
|
54
|
+
readonly rfc?: IRfcErrorInfo;
|
|
55
|
+
/** SAP's answer, as SAP gave it: status, reason, headers, body. */
|
|
56
|
+
readonly response?: IAdtTransportResponse;
|
|
57
|
+
}
|
|
58
|
+
/** Every fact `thrown` carries, each checked; none of its text. */
|
|
59
|
+
export declare function factsOf(thrown: unknown): FailureFacts;
|
|
60
|
+
/** The words for a value that carries no fact. */
|
|
61
|
+
export declare const NO_FACTS = "no code was given";
|
|
62
|
+
/**
|
|
63
|
+
* A thrown value in fixed words: its facts — the RFC return code, the code,
|
|
64
|
+
* the status — or `no code was given`. For a message and a log line.
|
|
65
|
+
*/
|
|
66
|
+
export declare function factWords(thrown: unknown): string;
|
|
67
|
+
/** A copy of a thrown value: fixed words and its facts, nothing else of it. */
|
|
68
|
+
export type FailureCopy = Error & IAbapConnectionError & FailureFacts;
|
|
69
|
+
/**
|
|
70
|
+
* A copy of `thrown` a consumer may stringify or inspect: an `Error` named
|
|
71
|
+
* `WireFailure`, its message `The failure: <facts>`, and its facts as fields
|
|
72
|
+
* (`code`, `status`, `rfc`, SAP's answer as `response`). No message, stack,
|
|
73
|
+
* cause, config or other field of `thrown` is kept. `undefined` stays
|
|
74
|
+
* `undefined`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function failureCopy(thrown: unknown): FailureCopy | undefined;
|
|
77
|
+
/** What an HTTP request's failure is, as the wire hands it up. */
|
|
78
|
+
export type HttpFailure = Error & IAbapConnectionError & {
|
|
79
|
+
readonly status?: number;
|
|
80
|
+
/** SAP's answer, as SAP gave it: status, reason, headers, body. */
|
|
81
|
+
readonly response?: IAdtTransportResponse;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* What an HTTP client's rejection becomes before it leaves the wire: an
|
|
85
|
+
* `Error` in fixed words with its facts and SAP's answer, and nothing else.
|
|
86
|
+
*
|
|
87
|
+
* axios's error carries the request's config — its `Authorization`, `Cookie`
|
|
88
|
+
* and CSRF headers among it — the Node request, and a message that names the
|
|
89
|
+
* host and port it could not reach. None of that is kept. What is: SAP's
|
|
90
|
+
* answer when there was one (`response`, `status`; the message axios gives it,
|
|
91
|
+
* `Request failed with status code <n>`, built from the status), else the
|
|
92
|
+
* code (`ECONNREFUSED`, `ECONNABORTED`, …) and `The request failed: <code>`.
|
|
93
|
+
*/
|
|
94
|
+
export declare function httpFailure(thrown: unknown): HttpFailure;
|
|
95
|
+
/**
|
|
96
|
+
* The wire's error as it arrived: the value an `httpFailure` was made from,
|
|
97
|
+
* or `value` itself. For `IAuthRejection.error` only — never for a consumer.
|
|
98
|
+
*/
|
|
99
|
+
export declare function asArrived(value: unknown): unknown;
|
|
100
|
+
//# sourceMappingURL=failureFacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failureFacts.d.ts","sourceRoot":"","sources":["../../src/connection/failureFacts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAEnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,uEAAuE;AACvE,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAK7D;AAMD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAkBrE;AAcD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAa1D;AAKD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAa/D;AAsBD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAY5D;AAED,2CAA2C;AAC3C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAC3C;AAED,mEAAmE;AACnE,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAarD;AAED,kDAAkD;AAClD,eAAO,MAAM,QAAQ,sBAAsB,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAOjD;AAED,+EAA+E;AAC/E,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,oBAAoB,GAAG,YAAY,CAAC;AAEtE;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAKpE;AAED,kEAAkE;AAClE,MAAM,MAAM,WAAW,GAAG,KAAK,GAC7B,oBAAoB,GAAG;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAC3C,CAAC;AA0BJ;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,WAAW,CAexD;AASD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAIjD"}
|