@xfcfam/xf-server-http 0.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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +240 -0
  3. package/dist/index.d.ts +63 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +55 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/src/api/A.d.ts +18 -0
  8. package/dist/src/api/A.d.ts.map +1 -0
  9. package/dist/src/api/A.js +18 -0
  10. package/dist/src/api/A.js.map +1 -0
  11. package/dist/src/api/general/GraphQLService.d.ts +48 -0
  12. package/dist/src/api/general/GraphQLService.d.ts.map +1 -0
  13. package/dist/src/api/general/GraphQLService.js +43 -0
  14. package/dist/src/api/general/GraphQLService.js.map +1 -0
  15. package/dist/src/api/general/ObjectRestService.d.ts +196 -0
  16. package/dist/src/api/general/ObjectRestService.d.ts.map +1 -0
  17. package/dist/src/api/general/ObjectRestService.js +289 -0
  18. package/dist/src/api/general/ObjectRestService.js.map +1 -0
  19. package/dist/src/api/general/RestService.d.ts +62 -0
  20. package/dist/src/api/general/RestService.d.ts.map +1 -0
  21. package/dist/src/api/general/RestService.js +75 -0
  22. package/dist/src/api/general/RestService.js.map +1 -0
  23. package/dist/src/api/general/WebSocketService.d.ts +42 -0
  24. package/dist/src/api/general/WebSocketService.d.ts.map +1 -0
  25. package/dist/src/api/general/WebSocketService.js +45 -0
  26. package/dist/src/api/general/WebSocketService.js.map +1 -0
  27. package/dist/src/api/utils/FileResponseUtils.d.ts +66 -0
  28. package/dist/src/api/utils/FileResponseUtils.d.ts.map +1 -0
  29. package/dist/src/api/utils/FileResponseUtils.js +82 -0
  30. package/dist/src/api/utils/FileResponseUtils.js.map +1 -0
  31. package/dist/src/api/utils/HttpStatusUtils.d.ts +36 -0
  32. package/dist/src/api/utils/HttpStatusUtils.d.ts.map +1 -0
  33. package/dist/src/api/utils/HttpStatusUtils.js +40 -0
  34. package/dist/src/api/utils/HttpStatusUtils.js.map +1 -0
  35. package/dist/src/api/utils/ResponseUtils.d.ts +61 -0
  36. package/dist/src/api/utils/ResponseUtils.d.ts.map +1 -0
  37. package/dist/src/api/utils/ResponseUtils.js +81 -0
  38. package/dist/src/api/utils/ResponseUtils.js.map +1 -0
  39. package/dist/src/api/utils/SchemaValidatorUtils.d.ts +48 -0
  40. package/dist/src/api/utils/SchemaValidatorUtils.d.ts.map +1 -0
  41. package/dist/src/api/utils/SchemaValidatorUtils.js +52 -0
  42. package/dist/src/api/utils/SchemaValidatorUtils.js.map +1 -0
  43. package/dist/src/api/utils/SseUtils.d.ts +57 -0
  44. package/dist/src/api/utils/SseUtils.d.ts.map +1 -0
  45. package/dist/src/api/utils/SseUtils.js +78 -0
  46. package/dist/src/api/utils/SseUtils.js.map +1 -0
  47. package/dist/src/business/B.d.ts +18 -0
  48. package/dist/src/business/B.d.ts.map +1 -0
  49. package/dist/src/business/B.js +18 -0
  50. package/dist/src/business/B.js.map +1 -0
  51. package/dist/src/business/general/HttpServerBusiness.d.ts +190 -0
  52. package/dist/src/business/general/HttpServerBusiness.d.ts.map +1 -0
  53. package/dist/src/business/general/HttpServerBusiness.js +364 -0
  54. package/dist/src/business/general/HttpServerBusiness.js.map +1 -0
  55. package/dist/src/business/transfers/BadRequestException.d.ts +13 -0
  56. package/dist/src/business/transfers/BadRequestException.d.ts.map +1 -0
  57. package/dist/src/business/transfers/BadRequestException.js +16 -0
  58. package/dist/src/business/transfers/BadRequestException.js.map +1 -0
  59. package/dist/src/business/transfers/ForbiddenException.d.ts +13 -0
  60. package/dist/src/business/transfers/ForbiddenException.d.ts.map +1 -0
  61. package/dist/src/business/transfers/ForbiddenException.js +16 -0
  62. package/dist/src/business/transfers/ForbiddenException.js.map +1 -0
  63. package/dist/src/business/transfers/GraphQLConfig.d.ts +25 -0
  64. package/dist/src/business/transfers/GraphQLConfig.d.ts.map +1 -0
  65. package/dist/src/business/transfers/GraphQLConfig.js +2 -0
  66. package/dist/src/business/transfers/GraphQLConfig.js.map +1 -0
  67. package/dist/src/business/transfers/HttpException.d.ts +23 -0
  68. package/dist/src/business/transfers/HttpException.d.ts.map +1 -0
  69. package/dist/src/business/transfers/HttpException.js +27 -0
  70. package/dist/src/business/transfers/HttpException.js.map +1 -0
  71. package/dist/src/business/transfers/HttpMethod.d.ts +7 -0
  72. package/dist/src/business/transfers/HttpMethod.d.ts.map +1 -0
  73. package/dist/src/business/transfers/HttpMethod.js +2 -0
  74. package/dist/src/business/transfers/HttpMethod.js.map +1 -0
  75. package/dist/src/business/transfers/HttpRequest.d.ts +35 -0
  76. package/dist/src/business/transfers/HttpRequest.d.ts.map +1 -0
  77. package/dist/src/business/transfers/HttpRequest.js +2 -0
  78. package/dist/src/business/transfers/HttpRequest.js.map +1 -0
  79. package/dist/src/business/transfers/HttpResponse.d.ts +28 -0
  80. package/dist/src/business/transfers/HttpResponse.d.ts.map +1 -0
  81. package/dist/src/business/transfers/HttpResponse.js +2 -0
  82. package/dist/src/business/transfers/HttpResponse.js.map +1 -0
  83. package/dist/src/business/transfers/InternalServerException.d.ts +13 -0
  84. package/dist/src/business/transfers/InternalServerException.d.ts.map +1 -0
  85. package/dist/src/business/transfers/InternalServerException.js +16 -0
  86. package/dist/src/business/transfers/InternalServerException.js.map +1 -0
  87. package/dist/src/business/transfers/MultipartPart.d.ts +38 -0
  88. package/dist/src/business/transfers/MultipartPart.d.ts.map +1 -0
  89. package/dist/src/business/transfers/MultipartPart.js +2 -0
  90. package/dist/src/business/transfers/MultipartPart.js.map +1 -0
  91. package/dist/src/business/transfers/NotFoundException.d.ts +13 -0
  92. package/dist/src/business/transfers/NotFoundException.d.ts.map +1 -0
  93. package/dist/src/business/transfers/NotFoundException.js +16 -0
  94. package/dist/src/business/transfers/NotFoundException.js.map +1 -0
  95. package/dist/src/business/transfers/Route.d.ts +25 -0
  96. package/dist/src/business/transfers/Route.d.ts.map +1 -0
  97. package/dist/src/business/transfers/Route.js +2 -0
  98. package/dist/src/business/transfers/Route.js.map +1 -0
  99. package/dist/src/business/transfers/UnauthorizedException.d.ts +13 -0
  100. package/dist/src/business/transfers/UnauthorizedException.d.ts.map +1 -0
  101. package/dist/src/business/transfers/UnauthorizedException.js +16 -0
  102. package/dist/src/business/transfers/UnauthorizedException.js.map +1 -0
  103. package/dist/src/business/transfers/WebSocketConnection.d.ts +40 -0
  104. package/dist/src/business/transfers/WebSocketConnection.d.ts.map +1 -0
  105. package/dist/src/business/transfers/WebSocketConnection.js +2 -0
  106. package/dist/src/business/transfers/WebSocketConnection.js.map +1 -0
  107. package/dist/src/repository/R.d.ts +18 -0
  108. package/dist/src/repository/R.d.ts.map +1 -0
  109. package/dist/src/repository/R.js +18 -0
  110. package/dist/src/repository/R.js.map +1 -0
  111. package/package.json +62 -0
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Interaction-layer Transfer — the response a `RestService` handler
3
+ * returns to the server pipeline.
4
+ *
5
+ * `body` is unified: it may be any of —
6
+ *
7
+ * - a JS value (object, array, primitive) → serialised according to
8
+ * the response's `Content-Type` (or to JSON by default, when
9
+ * `ObjectRestService` is in use);
10
+ * - a `Uint8Array` → written verbatim to the response body;
11
+ * - a `ReadableStream<Uint8Array>` → streamed to the client in
12
+ * chunks (file downloads, server-sent events, large exports);
13
+ * - a `string` → sent as text;
14
+ * - `null` / `undefined` → empty body.
15
+ *
16
+ * No separate `pipe` field: streaming is just a body whose type is a
17
+ * `ReadableStream`. Keeps the surface area minimal and treats
18
+ * streaming as a first-class case rather than an afterthought.
19
+ */
20
+ export interface HttpResponse<TBody = unknown> {
21
+ /** HTTP status code. */
22
+ readonly status: number;
23
+ /** Response headers. Lowercased name → value. */
24
+ readonly headers?: Readonly<Record<string, string>>;
25
+ /** Response body. See class docstring for the supported shapes. */
26
+ readonly body?: TBody;
27
+ }
28
+ //# sourceMappingURL=HttpResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpResponse.d.ts","sourceRoot":"","sources":["../../../../src/business/transfers/HttpResponse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,YAAY,CAAC,KAAK,GAAG,OAAO;IAC3C,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,iDAAiD;IACjD,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACnD,mEAAmE;IACnE,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CACtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=HttpResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpResponse.js","sourceRoot":"","sources":["../../../../src/business/transfers/HttpResponse.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { HttpException } from './HttpException.js';
2
+ /**
3
+ * Interaction-layer Exception — HTTP 500.
4
+ *
5
+ * An unexpected condition prevented the server from fulfilling the request.
6
+ *
7
+ * Use `throw new InternalServerException('message')` inside a handler; the
8
+ * server pipeline translates it into a 500 response automatically.
9
+ */
10
+ export declare class InternalServerException extends HttpException {
11
+ constructor(message: string, body?: unknown);
12
+ }
13
+ //# sourceMappingURL=InternalServerException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InternalServerException.d.ts","sourceRoot":"","sources":["../../../../src/business/transfers/InternalServerException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;GAOG;AACH,qBAAa,uBAAwB,SAAQ,aAAa;gBAC5C,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;CAI5C"}
@@ -0,0 +1,16 @@
1
+ import { HttpException } from './HttpException.js';
2
+ /**
3
+ * Interaction-layer Exception — HTTP 500.
4
+ *
5
+ * An unexpected condition prevented the server from fulfilling the request.
6
+ *
7
+ * Use `throw new InternalServerException('message')` inside a handler; the
8
+ * server pipeline translates it into a 500 response automatically.
9
+ */
10
+ export class InternalServerException extends HttpException {
11
+ constructor(message, body) {
12
+ super(500, message, body);
13
+ this.name = 'InternalServerException';
14
+ }
15
+ }
16
+ //# sourceMappingURL=InternalServerException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InternalServerException.js","sourceRoot":"","sources":["../../../../src/business/transfers/InternalServerException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAwB,SAAQ,aAAa;IACxD,YAAY,OAAe,EAAE,IAAc;QACzC,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QACzB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;IACvC,CAAC;CACF"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Interaction-layer Transfer — a single part of a
3
+ * `multipart/form-data` request body.
4
+ *
5
+ * Each form-data section becomes one `MultipartPart`: text fields,
6
+ * file uploads, attached blobs. The same shape covers all of them —
7
+ * `filename` distinguishes a file (where it carries the original
8
+ * client-side filename) from a plain field (where it is undefined).
9
+ *
10
+ * Body is streaming-friendly: small parts arrive as `Uint8Array`,
11
+ * large ones as `ReadableStream<Uint8Array>`. The handler decides
12
+ * whether to buffer or pipe.
13
+ *
14
+ * `MultipartPart[]` is what an `ObjectRestService` produces in
15
+ * `req.body` for any request whose `Content-Type` is
16
+ * `multipart/form-data`, when the host `HttpServerBusiness` enables
17
+ * the multipart option.
18
+ */
19
+ export interface MultipartPart {
20
+ /** Name of the form field (the `name=` attribute on the client side). */
21
+ readonly field: string;
22
+ /**
23
+ * Original client-side filename if the part is a file upload;
24
+ * undefined for plain text fields.
25
+ */
26
+ readonly filename?: string;
27
+ /** MIME type sent by the client, e.g. `image/jpeg` or `text/plain`. */
28
+ readonly mimeType: string;
29
+ /**
30
+ * Part body. `Uint8Array` for small/buffered content,
31
+ * `ReadableStream<Uint8Array>` for streaming uploads when the
32
+ * underlying library supports it.
33
+ */
34
+ readonly body: Uint8Array | ReadableStream<Uint8Array>;
35
+ /** Byte size of the part if known upfront. */
36
+ readonly size?: number;
37
+ }
38
+ //# sourceMappingURL=MultipartPart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultipartPart.d.ts","sourceRoot":"","sources":["../../../../src/business/transfers/MultipartPart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAA;IACtD,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MultipartPart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultipartPart.js","sourceRoot":"","sources":["../../../../src/business/transfers/MultipartPart.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { HttpException } from './HttpException.js';
2
+ /**
3
+ * Interaction-layer Exception — HTTP 404.
4
+ *
5
+ * The requested resource does not exist.
6
+ *
7
+ * Use `throw new NotFoundException('message')` inside a handler; the
8
+ * server pipeline translates it into a 404 response automatically.
9
+ */
10
+ export declare class NotFoundException extends HttpException {
11
+ constructor(message: string, body?: unknown);
12
+ }
13
+ //# sourceMappingURL=NotFoundException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotFoundException.d.ts","sourceRoot":"","sources":["../../../../src/business/transfers/NotFoundException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,aAAa;gBACtC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;CAI5C"}
@@ -0,0 +1,16 @@
1
+ import { HttpException } from './HttpException.js';
2
+ /**
3
+ * Interaction-layer Exception — HTTP 404.
4
+ *
5
+ * The requested resource does not exist.
6
+ *
7
+ * Use `throw new NotFoundException('message')` inside a handler; the
8
+ * server pipeline translates it into a 404 response automatically.
9
+ */
10
+ export class NotFoundException extends HttpException {
11
+ constructor(message, body) {
12
+ super(404, message, body);
13
+ this.name = 'NotFoundException';
14
+ }
15
+ }
16
+ //# sourceMappingURL=NotFoundException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotFoundException.js","sourceRoot":"","sources":["../../../../src/business/transfers/NotFoundException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;GAOG;AACH,MAAM,OAAO,iBAAkB,SAAQ,aAAa;IAClD,YAAY,OAAe,EAAE,IAAc;QACzC,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QACzB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,CAAC;CACF"}
@@ -0,0 +1,25 @@
1
+ import type { HttpMethod } from './HttpMethod.js';
2
+ import type { HttpRequest } from './HttpRequest.js';
3
+ import type { HttpResponse } from './HttpResponse.js';
4
+ /**
5
+ * Business-layer Transfer — the HTTP address a route answers to: the
6
+ * `{ method, path }` pair. This is the concrete `TAddr` the HTTP server
7
+ * supplies to the generic `Route<TAddr, …>` of `@xfcfam/xf-server`.
8
+ */
9
+ export interface HttpAddress {
10
+ /** HTTP method (`GET`, `POST`, …). */
11
+ readonly method: HttpMethod;
12
+ /** URL path pattern (Fastify syntax: `/users/:id`). */
13
+ readonly path: string;
14
+ }
15
+ /**
16
+ * Function signature of every HTTP handler registered on a
17
+ * `RestService`. The handler receives a fully decoded `HttpRequest`
18
+ * and returns the `HttpResponse` to send back. May be async — the
19
+ * server `await`s it.
20
+ *
21
+ * Structurally a `Handler<HttpRequest, HttpResponse>` from
22
+ * `@xfcfam/xf-server`, with optional per-handler body typing.
23
+ */
24
+ export type HttpHandler<TReqBody = unknown, TResBody = unknown> = (request: HttpRequest<TReqBody>) => Promise<HttpResponse<TResBody>> | HttpResponse<TResBody>;
25
+ //# sourceMappingURL=Route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../../../../src/business/transfers/Route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,sCAAsC;IACtC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,GAAG,OAAO,IAAI,CAChE,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,KAC3B,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../../src/business/transfers/Route.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { HttpException } from './HttpException.js';
2
+ /**
3
+ * Interaction-layer Exception — HTTP 401.
4
+ *
5
+ * Authentication failed or not provided. The client must authenticate to retry.
6
+ *
7
+ * Use `throw new UnauthorizedException('message')` inside a handler; the
8
+ * server pipeline translates it into a 401 response automatically.
9
+ */
10
+ export declare class UnauthorizedException extends HttpException {
11
+ constructor(message: string, body?: unknown);
12
+ }
13
+ //# sourceMappingURL=UnauthorizedException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnauthorizedException.d.ts","sourceRoot":"","sources":["../../../../src/business/transfers/UnauthorizedException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;GAOG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;CAI5C"}
@@ -0,0 +1,16 @@
1
+ import { HttpException } from './HttpException.js';
2
+ /**
3
+ * Interaction-layer Exception — HTTP 401.
4
+ *
5
+ * Authentication failed or not provided. The client must authenticate to retry.
6
+ *
7
+ * Use `throw new UnauthorizedException('message')` inside a handler; the
8
+ * server pipeline translates it into a 401 response automatically.
9
+ */
10
+ export class UnauthorizedException extends HttpException {
11
+ constructor(message, body) {
12
+ super(401, message, body);
13
+ this.name = 'UnauthorizedException';
14
+ }
15
+ }
16
+ //# sourceMappingURL=UnauthorizedException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnauthorizedException.js","sourceRoot":"","sources":["../../../../src/business/transfers/UnauthorizedException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;;;;GAOG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD,YAAY,OAAe,EAAE,IAAc;QACzC,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QACzB,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAA;IACrC,CAAC;CACF"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Business-layer Transfer — a live WebSocket connection handed to a
3
+ * WebSocket handler.
4
+ *
5
+ * A transport-neutral surface over the underlying socket: send frames,
6
+ * listen for inbound frames and lifecycle events, close. The HTTP
7
+ * server adapts the Fastify / `ws` socket to this shape so handlers
8
+ * never touch the engine directly.
9
+ *
10
+ * Unlike `HttpRequest` / `HttpResponse` (a single request → response),
11
+ * a WebSocket is a long-lived bidirectional channel — hence the
12
+ * event-listener shape rather than a return value.
13
+ */
14
+ export interface WebSocketConnection {
15
+ /** Resolved path the client connected to. */
16
+ readonly path: string;
17
+ /** Route parameters extracted from the path. */
18
+ readonly params: Readonly<Record<string, string>>;
19
+ /** Query-string parameters of the upgrade request. */
20
+ readonly query: Readonly<Record<string, string | readonly string[]>>;
21
+ /** Lowercased headers of the upgrade request. */
22
+ readonly headers: Readonly<Record<string, string | readonly string[]>>;
23
+ /** Send a text or binary frame to the client. */
24
+ send(data: string | Uint8Array): void;
25
+ /** Close the connection, optionally with a code and reason. */
26
+ close(code?: number, reason?: string): void;
27
+ /** Register a listener for inbound frames. */
28
+ onMessage(listener: (data: string | Uint8Array) => void): void;
29
+ /** Register a listener for connection close. */
30
+ onClose(listener: (code: number, reason: string) => void): void;
31
+ /** Register a listener for socket errors. */
32
+ onError(listener: (error: Error) => void): void;
33
+ }
34
+ /**
35
+ * Function signature of a WebSocket endpoint handler. Receives the
36
+ * connection once the upgrade completes; wires its own message / close
37
+ * listeners. May be async.
38
+ */
39
+ export type WebSocketHandler = (connection: WebSocketConnection) => void | Promise<void>;
40
+ //# sourceMappingURL=WebSocketConnection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebSocketConnection.d.ts","sourceRoot":"","sources":["../../../../src/business/transfers/WebSocketConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,mBAAmB;IAClC,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACjD,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC,CAAA;IACpE,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC,CAAC,CAAA;IAEtE,iDAAiD;IACjD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAA;IACrC,+DAA+D;IAC/D,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE3C,8CAA8C;IAC9C,SAAS,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,KAAK,IAAI,GAAG,IAAI,CAAA;IAC9D,gDAAgD;IAChD,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAA;IAC/D,6CAA6C;IAC7C,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAA;CAChD;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=WebSocketConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebSocketConnection.js","sourceRoot":"","sources":["../../../../src/business/transfers/WebSocketConnection.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Access Layer Injection — placeholder.
3
+ *
4
+ * `R` is the canonical injection of the Access Layer. `@xfcfam/xf-server`
5
+ * is a library that contributes Generalizations and Transfer objects to
6
+ * the Interaction Layer ( `ObjectRestService`,
7
+ * `HttpServerBusiness`); it does not own any Logical of this layer, so
8
+ * its own `R` declares no static slots. The class is kept structurally
9
+ * complete (private constructor + empty `init` / `terminate`) so the
10
+ * artefact passes XF validation. It is NOT exported from the package —
11
+ * consumers import `R` from their own artefact.
12
+ */
13
+ export declare class R {
14
+ private constructor();
15
+ static init(): Promise<void>;
16
+ static terminate(): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=R.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"R.d.ts","sourceRoot":"","sources":["../../../src/repository/R.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,qBAAa,CAAC;IACZ,OAAO;WACM,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;WACrB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CACxC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Access Layer Injection — placeholder.
3
+ *
4
+ * `R` is the canonical injection of the Access Layer. `@xfcfam/xf-server`
5
+ * is a library that contributes Generalizations and Transfer objects to
6
+ * the Interaction Layer ( `ObjectRestService`,
7
+ * `HttpServerBusiness`); it does not own any Logical of this layer, so
8
+ * its own `R` declares no static slots. The class is kept structurally
9
+ * complete (private constructor + empty `init` / `terminate`) so the
10
+ * artefact passes XF validation. It is NOT exported from the package —
11
+ * consumers import `R` from their own artefact.
12
+ */
13
+ export class R {
14
+ constructor() { }
15
+ static async init() { }
16
+ static async terminate() { }
17
+ }
18
+ //# sourceMappingURL=R.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"R.js","sourceRoot":"","sources":["../../../src/repository/R.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,CAAC;IACZ,gBAAuB,CAAC;IACxB,MAAM,CAAC,KAAK,CAAC,IAAI,KAAmB,CAAC;IACrC,MAAM,CAAC,KAAK,CAAC,SAAS,KAAmB,CAAC;CAC3C"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@xfcfam/xf-server-http",
3
+ "version": "0.1.0",
4
+ "description": "HTTP transport for the XF Architecture Model — REST / WebSocket / SSE / GraphQL over Fastify. Implements the @xfcfam/xf-server contract with canonical HttpServerBusiness / RestService / ObjectRestService bases.",
5
+ "author": "XF Contributors",
6
+ "license": "MIT",
7
+ "homepage": "https://xfcfam.org",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/xfcfam/lib-npm",
11
+ "directory": "packages/xf-server-http"
12
+ },
13
+ "keywords": [
14
+ "xf",
15
+ "cfam",
16
+ "server",
17
+ "http",
18
+ "rest",
19
+ "websocket",
20
+ "sse",
21
+ "graphql",
22
+ "fastify"
23
+ ],
24
+ "type": "module",
25
+ "main": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "import": "./dist/index.js",
30
+ "types": "./dist/index.d.ts"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "peerDependencies": {
40
+ "@xfcfam/xf": "^0.2.0",
41
+ "@xfcfam/xf-server": "^0.1.0"
42
+ },
43
+ "dependencies": {
44
+ "fastify": "^5.0.0",
45
+ "@fastify/multipart": "^9.0.0",
46
+ "@fastify/websocket": "^11.0.0",
47
+ "mercurius": "^16.0.0",
48
+ "graphql": "^16.9.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^20.0.0",
52
+ "typescript": "^5.4.0",
53
+ "vitest": "^2.0.0"
54
+ },
55
+ "scripts": {
56
+ "build": "tsc",
57
+ "typecheck": "tsc --noEmit",
58
+ "clean": "rm -rf dist",
59
+ "test": "vitest run --passWithNoTests",
60
+ "test:watch": "vitest"
61
+ }
62
+ }