@xfcfam/xf-client 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/src/repository/R.d.ts +17 -0
- package/dist/src/repository/R.d.ts.map +1 -0
- package/dist/src/repository/R.js +17 -0
- package/dist/src/repository/R.js.map +1 -0
- package/dist/src/repository/general/ClientRepository.d.ts +59 -0
- package/dist/src/repository/general/ClientRepository.d.ts.map +1 -0
- package/dist/src/repository/general/ClientRepository.js +74 -0
- package/dist/src/repository/general/ClientRepository.js.map +1 -0
- package/dist/src/repository/transfers/ClientException.d.ts +22 -0
- package/dist/src/repository/transfers/ClientException.d.ts.map +1 -0
- package/dist/src/repository/transfers/ClientException.js +26 -0
- package/dist/src/repository/transfers/ClientException.js.map +1 -0
- package/dist/src/repository/transfers/ConnectionException.d.ts +21 -0
- package/dist/src/repository/transfers/ConnectionException.d.ts.map +1 -0
- package/dist/src/repository/transfers/ConnectionException.js +28 -0
- package/dist/src/repository/transfers/ConnectionException.js.map +1 -0
- package/package.json +39 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Israel Sanjurjo and the XF contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@xfcfam/xf-client` — transport-agnostic **outbound client contract**
|
|
3
|
+
* for the XF Architecture Model (CFAM). The Access-layer counterpart of
|
|
4
|
+
* `@xfcfam/xf-server`.
|
|
5
|
+
*
|
|
6
|
+
* Holds no transport of its own. It defines the abstract contract every
|
|
7
|
+
* concrete `@xfcfam/xf-client-*` package implements, so they all share
|
|
8
|
+
* one lifecycle and one request pipeline regardless of protocol:
|
|
9
|
+
*
|
|
10
|
+
* - **{@link ClientRepository}** — Access-Layer Generalization. Owns the
|
|
11
|
+
* `onRequest → send → onResponse` pipeline (`call`); leaves `send` and
|
|
12
|
+
* the wire types abstract for the protocol package.
|
|
13
|
+
* - **Exceptions**: {@link ClientException} (protocol failure — the
|
|
14
|
+
* remote answered with an error) and {@link ConnectionException}
|
|
15
|
+
* (transport failure — no response at all).
|
|
16
|
+
*
|
|
17
|
+
* Concrete implementations:
|
|
18
|
+
*
|
|
19
|
+
* - `@xfcfam/xf-client-http` — REST over `ky`.
|
|
20
|
+
* - `@xfcfam/xf-client-grpc` — gRPC over `@grpc/grpc-js` (sketch).
|
|
21
|
+
* - `@xfcfam/xf-client-tcp` / `-udp` — raw sockets (sketch).
|
|
22
|
+
*
|
|
23
|
+
* You typically install a concrete package, not this one directly.
|
|
24
|
+
*
|
|
25
|
+
* See https://xfcfam.org for the full XF specification.
|
|
26
|
+
*/
|
|
27
|
+
export { ClientRepository } from './src/repository/general/ClientRepository.js';
|
|
28
|
+
export { ClientException } from './src/repository/transfers/ClientException.js';
|
|
29
|
+
export { ConnectionException } from './src/repository/transfers/ConnectionException.js';
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAG/E,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAA;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@xfcfam/xf-client` — transport-agnostic **outbound client contract**
|
|
3
|
+
* for the XF Architecture Model (CFAM). The Access-layer counterpart of
|
|
4
|
+
* `@xfcfam/xf-server`.
|
|
5
|
+
*
|
|
6
|
+
* Holds no transport of its own. It defines the abstract contract every
|
|
7
|
+
* concrete `@xfcfam/xf-client-*` package implements, so they all share
|
|
8
|
+
* one lifecycle and one request pipeline regardless of protocol:
|
|
9
|
+
*
|
|
10
|
+
* - **{@link ClientRepository}** — Access-Layer Generalization. Owns the
|
|
11
|
+
* `onRequest → send → onResponse` pipeline (`call`); leaves `send` and
|
|
12
|
+
* the wire types abstract for the protocol package.
|
|
13
|
+
* - **Exceptions**: {@link ClientException} (protocol failure — the
|
|
14
|
+
* remote answered with an error) and {@link ConnectionException}
|
|
15
|
+
* (transport failure — no response at all).
|
|
16
|
+
*
|
|
17
|
+
* Concrete implementations:
|
|
18
|
+
*
|
|
19
|
+
* - `@xfcfam/xf-client-http` — REST over `ky`.
|
|
20
|
+
* - `@xfcfam/xf-client-grpc` — gRPC over `@grpc/grpc-js` (sketch).
|
|
21
|
+
* - `@xfcfam/xf-client-tcp` / `-udp` — raw sockets (sketch).
|
|
22
|
+
*
|
|
23
|
+
* You typically install a concrete package, not this one directly.
|
|
24
|
+
*
|
|
25
|
+
* See https://xfcfam.org for the full XF specification.
|
|
26
|
+
*/
|
|
27
|
+
// ── Access Generalization ─────────────────────────────────
|
|
28
|
+
export { ClientRepository } from './src/repository/general/ClientRepository.js';
|
|
29
|
+
// ── Exceptions ────────────────────────────────────────────
|
|
30
|
+
export { ClientException } from './src/repository/transfers/ClientException.js';
|
|
31
|
+
export { ConnectionException } from './src/repository/transfers/ConnectionException.js';
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,6DAA6D;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAE/E,6DAA6D;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAA;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access Layer Injection — placeholder.
|
|
3
|
+
*
|
|
4
|
+
* `R` is the canonical injection of the Access Layer. `@xfcfam/xf-client`
|
|
5
|
+
* is a contract library that contributes the abstract Generalization
|
|
6
|
+
* `ClientRepository` and Transfer objects; it owns no Logical of its
|
|
7
|
+
* own, so its `R` declares no static slots. Kept structurally complete
|
|
8
|
+
* (private constructor + empty `init` / `terminate`) so the artefact
|
|
9
|
+
* passes XF validation. NOT exported — consumers import `R` from their
|
|
10
|
+
* own artefact.
|
|
11
|
+
*/
|
|
12
|
+
export declare class R {
|
|
13
|
+
private constructor();
|
|
14
|
+
static init(): Promise<void>;
|
|
15
|
+
static terminate(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=R.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"R.d.ts","sourceRoot":"","sources":["../../../src/repository/R.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,qBAAa,CAAC;IACZ,OAAO;WACM,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;WACrB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CACxC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access Layer Injection — placeholder.
|
|
3
|
+
*
|
|
4
|
+
* `R` is the canonical injection of the Access Layer. `@xfcfam/xf-client`
|
|
5
|
+
* is a contract library that contributes the abstract Generalization
|
|
6
|
+
* `ClientRepository` and Transfer objects; it owns no Logical of its
|
|
7
|
+
* own, so its `R` declares no static slots. Kept structurally complete
|
|
8
|
+
* (private constructor + empty `init` / `terminate`) so the artefact
|
|
9
|
+
* passes XF validation. NOT exported — consumers import `R` from their
|
|
10
|
+
* own artefact.
|
|
11
|
+
*/
|
|
12
|
+
export class R {
|
|
13
|
+
constructor() { }
|
|
14
|
+
static async init() { }
|
|
15
|
+
static async terminate() { }
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=R.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"R.js","sourceRoot":"","sources":["../../../src/repository/R.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,CAAC;IACZ,gBAAuB,CAAC;IACxB,MAAM,CAAC,KAAK,CAAC,IAAI,KAAmB,CAAC;IACrC,MAAM,CAAC,KAAK,CAAC,SAAS,KAAmB,CAAC;CAC3C"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Repository } from '@xfcfam/xf';
|
|
2
|
+
/**
|
|
3
|
+
* Access-Layer Generalization for the artefact-level **outbound client**
|
|
4
|
+
* — the transport-agnostic contract shared by every `@xfcfam/xf-client-*`
|
|
5
|
+
* package, and the symmetric counterpart of `@xfcfam/xf-server`'s
|
|
6
|
+
* `ServerBusiness`.
|
|
7
|
+
*
|
|
8
|
+
* Where `ServerBusiness` owns the *inbound* pipeline
|
|
9
|
+
* (`onRequest → handler → onResponse`, `onError` in the catch),
|
|
10
|
+
* `ClientRepository` owns the *outbound* pipeline:
|
|
11
|
+
*
|
|
12
|
+
* `onRequest → send → onResponse`, with `onError` in the catch.
|
|
13
|
+
*
|
|
14
|
+
* What it deliberately does **not** know is the transport: dispatching
|
|
15
|
+
* one request over the wire ({@link send}) and the request/response
|
|
16
|
+
* shapes (`TReq` / `TRes`) are left abstract. Each protocol package
|
|
17
|
+
* provides them — HTTP via `ky` in `@xfcfam/xf-client-http`, gRPC via
|
|
18
|
+
* `@grpc/grpc-js`, raw sockets via `node:net` / `node:dgram` — and
|
|
19
|
+
* exposes ergonomic helpers (`get`, `post`, `unary`, …) on top of the
|
|
20
|
+
* shared {@link call}.
|
|
21
|
+
*
|
|
22
|
+
* It lives in the **Access Layer** because making outbound calls is
|
|
23
|
+
* communication with an external system, not domain logic. Concrete
|
|
24
|
+
* subclasses are declared on `R` (e.g. `R.users`); Business components
|
|
25
|
+
* call them through the layer injection.
|
|
26
|
+
*
|
|
27
|
+
* Lifecycle (`init` / `terminate`) is inherited from {@link Repository};
|
|
28
|
+
* protocol packages open/close their client there.
|
|
29
|
+
*
|
|
30
|
+
* @typeParam TReq Protocol-specific request type (e.g. xf-client-http's `Request`).
|
|
31
|
+
* @typeParam TRes Protocol-specific response type (e.g. xf-client-http's `HttpResponse`).
|
|
32
|
+
*/
|
|
33
|
+
export declare abstract class ClientRepository<TReq, TRes> extends Repository<null> {
|
|
34
|
+
constructor();
|
|
35
|
+
/** Open the transport client. No-op by default; protocol packages override. */
|
|
36
|
+
init(): Promise<void>;
|
|
37
|
+
/** Release the transport client. No-op by default; protocol packages override. */
|
|
38
|
+
terminate(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Dispatch a single request over the transport and return the
|
|
41
|
+
* response. Implemented by the protocol package; never called
|
|
42
|
+
* directly by consumers — {@link call} wraps it in the pipeline.
|
|
43
|
+
*/
|
|
44
|
+
protected abstract send(request: TReq): Promise<TRes>;
|
|
45
|
+
/**
|
|
46
|
+
* Run one outbound request through the global pipeline:
|
|
47
|
+
* `onRequest → send → onResponse`, with `onError` in the catch.
|
|
48
|
+
* Returns the response, or whatever `onError` resolves to; if
|
|
49
|
+
* `onError` returns `undefined` the original error is rethrown.
|
|
50
|
+
*/
|
|
51
|
+
call(request: TReq): Promise<TRes>;
|
|
52
|
+
/** Before dispatch. Return value replaces the request (auth headers, signing, …). */
|
|
53
|
+
onRequest(request: TReq): Promise<TReq>;
|
|
54
|
+
/** After a successful dispatch. Return value replaces the response. */
|
|
55
|
+
onResponse(_request: TReq, response: TRes): Promise<TRes>;
|
|
56
|
+
/** When `send` (or a hook) throws. Return a `TRes` to recover, or `undefined` to rethrow. */
|
|
57
|
+
onError(_request: TReq, _error: unknown): Promise<TRes | undefined>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ClientRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientRepository.d.ts","sourceRoot":"","sources":["../../../../src/repository/general/ClientRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,8BAAsB,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAE,SAAQ,UAAU,CAAC,IAAI,CAAC;;IAKzE,+EAA+E;IACzE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAE3B,kFAAkF;IAC5E,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAEhC;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAErD;;;;;OAKG;IACG,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAcxC,qFAAqF;IAC/E,SAAS,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,uEAAuE;IACjE,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/D,6FAA6F;IACvF,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;CAG1E"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Repository } from '@xfcfam/xf';
|
|
2
|
+
/**
|
|
3
|
+
* Access-Layer Generalization for the artefact-level **outbound client**
|
|
4
|
+
* — the transport-agnostic contract shared by every `@xfcfam/xf-client-*`
|
|
5
|
+
* package, and the symmetric counterpart of `@xfcfam/xf-server`'s
|
|
6
|
+
* `ServerBusiness`.
|
|
7
|
+
*
|
|
8
|
+
* Where `ServerBusiness` owns the *inbound* pipeline
|
|
9
|
+
* (`onRequest → handler → onResponse`, `onError` in the catch),
|
|
10
|
+
* `ClientRepository` owns the *outbound* pipeline:
|
|
11
|
+
*
|
|
12
|
+
* `onRequest → send → onResponse`, with `onError` in the catch.
|
|
13
|
+
*
|
|
14
|
+
* What it deliberately does **not** know is the transport: dispatching
|
|
15
|
+
* one request over the wire ({@link send}) and the request/response
|
|
16
|
+
* shapes (`TReq` / `TRes`) are left abstract. Each protocol package
|
|
17
|
+
* provides them — HTTP via `ky` in `@xfcfam/xf-client-http`, gRPC via
|
|
18
|
+
* `@grpc/grpc-js`, raw sockets via `node:net` / `node:dgram` — and
|
|
19
|
+
* exposes ergonomic helpers (`get`, `post`, `unary`, …) on top of the
|
|
20
|
+
* shared {@link call}.
|
|
21
|
+
*
|
|
22
|
+
* It lives in the **Access Layer** because making outbound calls is
|
|
23
|
+
* communication with an external system, not domain logic. Concrete
|
|
24
|
+
* subclasses are declared on `R` (e.g. `R.users`); Business components
|
|
25
|
+
* call them through the layer injection.
|
|
26
|
+
*
|
|
27
|
+
* Lifecycle (`init` / `terminate`) is inherited from {@link Repository};
|
|
28
|
+
* protocol packages open/close their client there.
|
|
29
|
+
*
|
|
30
|
+
* @typeParam TReq Protocol-specific request type (e.g. xf-client-http's `Request`).
|
|
31
|
+
* @typeParam TRes Protocol-specific response type (e.g. xf-client-http's `HttpResponse`).
|
|
32
|
+
*/
|
|
33
|
+
export class ClientRepository extends Repository {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(null);
|
|
36
|
+
}
|
|
37
|
+
/** Open the transport client. No-op by default; protocol packages override. */
|
|
38
|
+
async init() { }
|
|
39
|
+
/** Release the transport client. No-op by default; protocol packages override. */
|
|
40
|
+
async terminate() { }
|
|
41
|
+
/**
|
|
42
|
+
* Run one outbound request through the global pipeline:
|
|
43
|
+
* `onRequest → send → onResponse`, with `onError` in the catch.
|
|
44
|
+
* Returns the response, or whatever `onError` resolves to; if
|
|
45
|
+
* `onError` returns `undefined` the original error is rethrown.
|
|
46
|
+
*/
|
|
47
|
+
async call(request) {
|
|
48
|
+
const req = await this.onRequest(request);
|
|
49
|
+
try {
|
|
50
|
+
const res = await this.send(req);
|
|
51
|
+
return await this.onResponse(req, res);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
const resolved = await this.onError(req, err);
|
|
55
|
+
if (resolved !== undefined)
|
|
56
|
+
return resolved;
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// ─── Overridable global hooks (mirror ServerBusiness) ──────
|
|
61
|
+
/** Before dispatch. Return value replaces the request (auth headers, signing, …). */
|
|
62
|
+
async onRequest(request) {
|
|
63
|
+
return request;
|
|
64
|
+
}
|
|
65
|
+
/** After a successful dispatch. Return value replaces the response. */
|
|
66
|
+
async onResponse(_request, response) {
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
/** When `send` (or a hook) throws. Return a `TRes` to recover, or `undefined` to rethrow. */
|
|
70
|
+
async onError(_request, _error) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=ClientRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientRepository.js","sourceRoot":"","sources":["../../../../src/repository/general/ClientRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAgB,gBAA6B,SAAQ,UAAgB;IACzE;QACE,KAAK,CAAC,IAAI,CAAC,CAAA;IACb,CAAC;IAED,+EAA+E;IAC/E,KAAK,CAAC,IAAI,KAAmB,CAAC;IAE9B,kFAAkF;IAClF,KAAK,CAAC,SAAS,KAAmB,CAAC;IASnC;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,OAAa;QACtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QACzC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAChC,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QACxC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;YAC7C,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,QAAQ,CAAA;YAC3C,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IAED,8DAA8D;IAE9D,qFAAqF;IACrF,KAAK,CAAC,SAAS,CAAC,OAAa;QAC3B,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,uEAAuE;IACvE,KAAK,CAAC,UAAU,CAAC,QAAc,EAAE,QAAc;QAC7C,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,6FAA6F;IAC7F,KAAK,CAAC,OAAO,CAAC,QAAc,EAAE,MAAe;QAC3C,OAAO,SAAS,CAAA;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access-layer Exception — base class for a typed error a client raises
|
|
3
|
+
* after the remote answered with a *protocol* failure (a non-success
|
|
4
|
+
* status, a gRPC error code, a framed error packet).
|
|
5
|
+
*
|
|
6
|
+
* The mirror of `@xfcfam/xf-server`'s `ServerException`: the contract
|
|
7
|
+
* fixes only that the error carries the remote's machine-readable `body`
|
|
8
|
+
* (whatever the server actually returned — possibly `undefined` for an
|
|
9
|
+
* empty error body). How the wire status maps onto the exception is the
|
|
10
|
+
* protocol package's responsibility; protocol packages subclass this —
|
|
11
|
+
* `@xfcfam/xf-client-http`'s `RestException` adds the HTTP `status`, a
|
|
12
|
+
* gRPC client would add a `code`.
|
|
13
|
+
*
|
|
14
|
+
* A pure transport failure (no response at all) is a
|
|
15
|
+
* `ConnectionException` instead, not a `ClientException`.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ClientException extends Error {
|
|
18
|
+
/** The remote's machine-readable payload, as returned (may be `undefined`). */
|
|
19
|
+
readonly body: unknown;
|
|
20
|
+
constructor(message: string, body?: unknown);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ClientException.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientException.d.ts","sourceRoot":"","sources":["../../../../src/repository/transfers/ClientException.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;gBAEV,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;CAK5C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access-layer Exception — base class for a typed error a client raises
|
|
3
|
+
* after the remote answered with a *protocol* failure (a non-success
|
|
4
|
+
* status, a gRPC error code, a framed error packet).
|
|
5
|
+
*
|
|
6
|
+
* The mirror of `@xfcfam/xf-server`'s `ServerException`: the contract
|
|
7
|
+
* fixes only that the error carries the remote's machine-readable `body`
|
|
8
|
+
* (whatever the server actually returned — possibly `undefined` for an
|
|
9
|
+
* empty error body). How the wire status maps onto the exception is the
|
|
10
|
+
* protocol package's responsibility; protocol packages subclass this —
|
|
11
|
+
* `@xfcfam/xf-client-http`'s `RestException` adds the HTTP `status`, a
|
|
12
|
+
* gRPC client would add a `code`.
|
|
13
|
+
*
|
|
14
|
+
* A pure transport failure (no response at all) is a
|
|
15
|
+
* `ConnectionException` instead, not a `ClientException`.
|
|
16
|
+
*/
|
|
17
|
+
export class ClientException extends Error {
|
|
18
|
+
/** The remote's machine-readable payload, as returned (may be `undefined`). */
|
|
19
|
+
body;
|
|
20
|
+
constructor(message, body) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = 'ClientException';
|
|
23
|
+
this.body = body;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ClientException.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientException.js","sourceRoot":"","sources":["../../../../src/repository/transfers/ClientException.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,+EAA+E;IACtE,IAAI,CAAS;IAEtB,YAAY,OAAe,EAAE,IAAc;QACzC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access-layer Exception — a transport-level failure that prevented a
|
|
3
|
+
* response from ever being received: the remote was unreachable,
|
|
4
|
+
* timed out, or the connection dropped mid-flight.
|
|
5
|
+
*
|
|
6
|
+
* Transport-agnostic: HTTP (DNS / TLS / socket / timeout), gRPC
|
|
7
|
+
* (`UNAVAILABLE`), raw TCP/UDP (connect / send errors) all surface as
|
|
8
|
+
* a `ConnectionException`. Distinct from a *protocol* error where the
|
|
9
|
+
* remote answered with a failing status — that is the protocol
|
|
10
|
+
* package's own exception (e.g. `RestException`).
|
|
11
|
+
*/
|
|
12
|
+
export declare class ConnectionException extends Error {
|
|
13
|
+
/** The originating low-level error. */
|
|
14
|
+
readonly cause: unknown;
|
|
15
|
+
/** Coarse failure kind, useful for retry policies. */
|
|
16
|
+
readonly kind: 'timeout' | 'connect' | 'network';
|
|
17
|
+
/** The originating request (protocol-specific shape), when available. */
|
|
18
|
+
readonly request?: unknown;
|
|
19
|
+
constructor(cause: unknown, kind: 'timeout' | 'connect' | 'network', request?: unknown);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ConnectionException.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionException.d.ts","sourceRoot":"","sources":["../../../../src/repository/transfers/ConnectionException.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,uCAAuC;IACvC,SAAkB,KAAK,EAAE,OAAO,CAAA;IAChC,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;IAChD,yEAAyE;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;gBAEd,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO;CAOvF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access-layer Exception — a transport-level failure that prevented a
|
|
3
|
+
* response from ever being received: the remote was unreachable,
|
|
4
|
+
* timed out, or the connection dropped mid-flight.
|
|
5
|
+
*
|
|
6
|
+
* Transport-agnostic: HTTP (DNS / TLS / socket / timeout), gRPC
|
|
7
|
+
* (`UNAVAILABLE`), raw TCP/UDP (connect / send errors) all surface as
|
|
8
|
+
* a `ConnectionException`. Distinct from a *protocol* error where the
|
|
9
|
+
* remote answered with a failing status — that is the protocol
|
|
10
|
+
* package's own exception (e.g. `RestException`).
|
|
11
|
+
*/
|
|
12
|
+
export class ConnectionException extends Error {
|
|
13
|
+
/** The originating low-level error. */
|
|
14
|
+
cause;
|
|
15
|
+
/** Coarse failure kind, useful for retry policies. */
|
|
16
|
+
kind;
|
|
17
|
+
/** The originating request (protocol-specific shape), when available. */
|
|
18
|
+
request;
|
|
19
|
+
constructor(cause, kind, request) {
|
|
20
|
+
super(`Connection ${kind}`);
|
|
21
|
+
this.name = 'ConnectionException';
|
|
22
|
+
this.cause = cause;
|
|
23
|
+
this.kind = kind;
|
|
24
|
+
if (request !== undefined)
|
|
25
|
+
this.request = request;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ConnectionException.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionException.js","sourceRoot":"","sources":["../../../../src/repository/transfers/ConnectionException.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,uCAAuC;IACrB,KAAK,CAAS;IAChC,sDAAsD;IAC7C,IAAI,CAAmC;IAChD,yEAAyE;IAChE,OAAO,CAAU;IAE1B,YAAY,KAAc,EAAE,IAAuC,EAAE,OAAiB;QACpF,KAAK,CAAC,cAAc,IAAI,EAAE,CAAC,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,OAAO,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACnD,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfcfam/xf-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Transport-agnostic outbound client contract for the XF Architecture Model — the Access-layer counterpart of @xfcfam/xf-server.",
|
|
5
5
|
"author": "XF Contributors",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://xfcfam.org",
|
|
8
|
-
"repository": {
|
|
9
|
-
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/xfcfam/lib-npm",
|
|
11
|
+
"directory": "packages/xf-client"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"xf",
|
|
15
|
+
"cfam",
|
|
16
|
+
"client",
|
|
17
|
+
"access"
|
|
18
|
+
],
|
|
10
19
|
"type": "module",
|
|
11
20
|
"main": "./dist/index.js",
|
|
12
21
|
"types": "./dist/index.d.ts",
|
|
13
|
-
"exports": {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@xfcfam/xf": "^0.3.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"typescript": "^6.0.3",
|
|
39
|
+
"vitest": "^4.1.8"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc",
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"clean": "rm -rf dist",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"test:watch": "vitest"
|
|
47
|
+
}
|
|
48
|
+
}
|