@ddd-ts-kit/http 0.113.2 → 0.115.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/README.fr.md +40 -16
- package/README.md +36 -16
- package/dist/error/answered-edge-error.d.ts +10 -2
- package/dist/error/answered-edge-error.d.ts.map +1 -1
- package/dist/error/answered-edge-error.js +17 -5
- package/dist/error/answered-edge-error.js.map +1 -1
- package/dist/error/create-error-mapper.d.ts.map +1 -1
- package/dist/error/create-error-mapper.js +2 -1
- package/dist/error/create-error-mapper.js.map +1 -1
- package/dist/error/default-error-mapping.d.ts.map +1 -1
- package/dist/error/default-error-mapping.js +2 -0
- package/dist/error/default-error-mapping.js.map +1 -1
- package/dist/error/edge-refusal.d.ts +5 -7
- package/dist/error/edge-refusal.d.ts.map +1 -1
- package/dist/error/edge-refusal.js.map +1 -1
- package/dist/error/mapped-status.d.ts +8 -0
- package/dist/error/mapped-status.d.ts.map +1 -0
- package/dist/error/mapped-status.js +9 -0
- package/dist/error/mapped-status.js.map +1 -0
- package/dist/error/to-problem.d.ts.map +1 -1
- package/dist/error/to-problem.js +2 -1
- package/dist/error/to-problem.js.map +1 -1
- package/dist/express/express-mount-options.d.ts +11 -0
- package/dist/express/express-mount-options.d.ts.map +1 -0
- package/dist/express/express-mount-options.js +2 -0
- package/dist/express/express-mount-options.js.map +1 -0
- package/dist/express/mount-express.d.ts +11 -9
- package/dist/express/mount-express.d.ts.map +1 -1
- package/dist/express/mount-express.js +33 -23
- package/dist/express/mount-express.js.map +1 -1
- package/dist/express.d.ts +2 -1
- package/dist/express.d.ts.map +1 -1
- package/dist/express.js.map +1 -1
- package/dist/fastify/mount-fastify.d.ts +2 -2
- package/dist/fastify/mount-fastify.d.ts.map +1 -1
- package/dist/fastify/mount-fastify.js +14 -20
- package/dist/fastify/mount-fastify.js.map +1 -1
- package/dist/hono/hono-mount-options.d.ts +1 -1
- package/dist/hono/mount-hono.d.ts.map +1 -1
- package/dist/hono/mount-hono.js +6 -14
- package/dist/hono/mount-hono.js.map +1 -1
- package/dist/hono/read-body.d.ts.map +1 -1
- package/dist/hono/read-body.js +3 -3
- package/dist/hono/read-body.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/nest/is-unread-json-body.d.ts.map +1 -1
- package/dist/nest/is-unread-json-body.js +2 -2
- package/dist/nest/is-unread-json-body.js.map +1 -1
- package/dist/orpc/orpc-router.js +1 -1
- package/dist/orpc/orpc-router.js.map +1 -1
- package/dist/pipeline/admitted-caller.d.ts +3 -5
- package/dist/pipeline/admitted-caller.d.ts.map +1 -1
- package/dist/pipeline/admitted-caller.js +2 -2
- package/dist/pipeline/admitted-caller.js.map +1 -1
- package/dist/pipeline/closing-with.d.ts +7 -0
- package/dist/pipeline/closing-with.d.ts.map +1 -0
- package/dist/pipeline/closing-with.js +21 -0
- package/dist/pipeline/closing-with.js.map +1 -0
- package/dist/pipeline/conditional-answer.d.ts +1 -1
- package/dist/pipeline/conditional-answer.d.ts.map +1 -1
- package/dist/pipeline/conditional-answer.js +12 -3
- package/dist/pipeline/conditional-answer.js.map +1 -1
- package/dist/pipeline/entity-tag-of.d.ts +4 -3
- package/dist/pipeline/entity-tag-of.d.ts.map +1 -1
- package/dist/pipeline/entity-tag-of.js +5 -4
- package/dist/pipeline/entity-tag-of.js.map +1 -1
- package/dist/pipeline/execute-route.d.ts.map +1 -1
- package/dist/pipeline/execute-route.js +44 -58
- package/dist/pipeline/execute-route.js.map +1 -1
- package/dist/pipeline/is-listed.d.ts +3 -0
- package/dist/pipeline/is-listed.d.ts.map +1 -0
- package/dist/pipeline/is-listed.js +7 -0
- package/dist/pipeline/is-listed.js.map +1 -0
- package/dist/pipeline/payload.d.ts +22 -0
- package/dist/pipeline/payload.d.ts.map +1 -0
- package/dist/pipeline/payload.js +2 -0
- package/dist/pipeline/payload.js.map +1 -0
- package/dist/pipeline/progress.d.ts +16 -0
- package/dist/pipeline/progress.d.ts.map +1 -0
- package/dist/pipeline/progress.js +24 -0
- package/dist/pipeline/progress.js.map +1 -0
- package/dist/pipeline/reported-stream.d.ts.map +1 -1
- package/dist/pipeline/reported-stream.js +18 -8
- package/dist/pipeline/reported-stream.js.map +1 -1
- package/dist/pipeline/represented-answer.d.ts +3 -3
- package/dist/pipeline/represented-answer.d.ts.map +1 -1
- package/dist/pipeline/represented.d.ts +8 -3
- package/dist/pipeline/represented.d.ts.map +1 -1
- package/dist/pipeline/represented.js +35 -9
- package/dist/pipeline/represented.js.map +1 -1
- package/dist/pipeline/route-response.d.ts +10 -3
- package/dist/pipeline/route-response.d.ts.map +1 -1
- package/dist/pipeline/whole-of.d.ts +9 -0
- package/dist/pipeline/whole-of.d.ts.map +1 -0
- package/dist/pipeline/whole-of.js +8 -0
- package/dist/pipeline/whole-of.js.map +1 -0
- package/dist/pipeline/writing.d.ts +11 -0
- package/dist/pipeline/writing.d.ts.map +1 -0
- package/dist/pipeline/writing.js +2 -0
- package/dist/pipeline/writing.js.map +1 -0
- package/dist/pipeline/written-in.d.ts +10 -4
- package/dist/pipeline/written-in.d.ts.map +1 -1
- package/dist/pipeline/written-in.js +12 -10
- package/dist/pipeline/written-in.js.map +1 -1
- package/dist/representation/is-json-content-type.d.ts +3 -0
- package/dist/representation/is-json-content-type.d.ts.map +1 -0
- package/dist/representation/is-json-content-type.js +7 -0
- package/dist/representation/is-json-content-type.js.map +1 -0
- package/dist/representation/json-representation.js +9 -1
- package/dist/representation/json-representation.js.map +1 -1
- package/dist/route/reads-its-stream.d.ts +4 -0
- package/dist/route/reads-its-stream.d.ts.map +1 -0
- package/dist/route/reads-its-stream.js +5 -0
- package/dist/route/reads-its-stream.js.map +1 -0
- package/dist/rpc/rpc-answer.d.ts.map +1 -1
- package/dist/rpc/rpc-answer.js +18 -17
- package/dist/rpc/rpc-answer.js.map +1 -1
- package/dist/testing/written-text.d.ts +10 -0
- package/dist/testing/written-text.d.ts.map +1 -0
- package/dist/testing/written-text.js +17 -0
- package/dist/testing/written-text.js.map +1 -0
- package/dist/testing.d.ts +1 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +1 -0
- package/dist/testing.js.map +1 -1
- package/dist/trpc/trpc-router.js +1 -1
- package/dist/trpc/trpc-router.js.map +1 -1
- package/package.json +15 -15
- package/dist/pipeline/serialize-body.d.ts +0 -7
- package/dist/pipeline/serialize-body.d.ts.map +0 -1
- package/dist/pipeline/serialize-body.js +0 -16
- package/dist/pipeline/serialize-body.js.map +0 -1
- package/dist/pipeline/write-stream.d.ts +0 -8
- package/dist/pipeline/write-stream.d.ts.map +0 -1
- package/dist/pipeline/write-stream.js +0 -23
- package/dist/pipeline/write-stream.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"represented.d.ts","sourceRoot":"","sources":["../../src/pipeline/represented.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"represented.d.ts","sourceRoot":"","sources":["../../src/pipeline/represented.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAK5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuBjH"}
|
|
@@ -1,19 +1,45 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
+
import { isJsonContentType } from '../representation/is-json-content-type.js';
|
|
3
|
+
import { JsonRepresentation } from '../representation/json-representation.js';
|
|
2
4
|
import { jsonSchemaOf } from '../schema/json-schema-of.js';
|
|
3
|
-
import {
|
|
5
|
+
import { isListed } from './is-listed.js';
|
|
6
|
+
import { NOTHING } from './payload.js';
|
|
4
7
|
import { primed } from './primed.js';
|
|
5
8
|
import { writtenIn } from './written-in.js';
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
const KIT_JSON = { mediaType: 'application/json', representation: new JsonRepresentation() };
|
|
10
|
+
const OCTETS = { 'content-type': 'application/octet-stream' };
|
|
11
|
+
/**
|
|
12
|
+
* What the answer of a route is written as: in the media type the request negotiated, in JSON
|
|
13
|
+
* when nothing was. Bytes, a file and a text under a content type the handler set itself are the
|
|
14
|
+
* handler's own, and are left as they are. A list read as it comes has its first item read here,
|
|
15
|
+
* while the request can still be answered with a problem.
|
|
16
|
+
*/
|
|
17
|
+
export async function represented(route, result, writing) {
|
|
8
18
|
const { body } = result;
|
|
19
|
+
const { chosen = KIT_JSON, interrupted } = writing;
|
|
9
20
|
if (body === undefined) {
|
|
10
|
-
return { headers: {} };
|
|
21
|
+
return { headers: {}, payload: NOTHING };
|
|
11
22
|
}
|
|
12
|
-
if (body instanceof Uint8Array
|
|
13
|
-
return { headers: {
|
|
23
|
+
if (body instanceof Uint8Array) {
|
|
24
|
+
return { headers: OCTETS, payload: { kind: 'bytes', bytes: body } };
|
|
14
25
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
if (body instanceof Readable) {
|
|
27
|
+
return { headers: OCTETS, payload: { kind: 'stream', stream: body } };
|
|
28
|
+
}
|
|
29
|
+
if (typeof body === 'string' && isOwnText(writing.ownContentType)) {
|
|
30
|
+
return { headers: {}, payload: { kind: 'text', text: body } };
|
|
31
|
+
}
|
|
32
|
+
const shape = chosen === KIT_JSON ? NO_SHAPE : shapeOf(route, result.status);
|
|
33
|
+
return writtenIn(isListed(body) ? await primed(body) : body, { chosen, shape, interrupted });
|
|
34
|
+
}
|
|
35
|
+
/** JSON writes a value as it is: it reads no schema. */
|
|
36
|
+
const NO_SHAPE = { schema: {}, name: '' };
|
|
37
|
+
function shapeOf(route, status) {
|
|
38
|
+
const schema = route.responses[status]?.body;
|
|
39
|
+
return { schema: schema === undefined ? {} : jsonSchemaOf(schema), name: route.operationId };
|
|
40
|
+
}
|
|
41
|
+
/** A text is the handler's own under a content type it chose that is not JSON; under JSON it is a JSON string. */
|
|
42
|
+
function isOwnText(contentType) {
|
|
43
|
+
return contentType !== undefined && !isJsonContentType(contentType);
|
|
18
44
|
}
|
|
19
45
|
//# sourceMappingURL=represented.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"represented.js","sourceRoot":"","sources":["../../src/pipeline/represented.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"represented.js","sourceRoot":"","sources":["../../src/pipeline/represented.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAI3E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,QAAQ,GAAW,EAAE,SAAS,EAAE,kBAAkB,EAAE,cAAc,EAAE,IAAI,kBAAkB,EAAE,EAAE,CAAC;AACrG,MAAM,MAAM,GAAG,EAAE,cAAc,EAAE,0BAA0B,EAAE,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAY,EAAE,MAAmB,EAAE,OAAgB;IACnF,MAAM,EAAE,IAAI,EAAE,G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,SAAS,OAAO,CAAC,KAAY,EAAE,MAA6B;IAC1D,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;IAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC;AAC/F,CAAC;AAED,kHAAkH;AAClH,SAAS,SAAS,CAAC,WAA+B;IAChD,OAAO,WAAW,KAAK,SAAS,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import type { Payload } from './payload.js';
|
|
1
2
|
export interface RouteResponse {
|
|
2
3
|
readonly status: number;
|
|
3
|
-
/** Lower-case names. `content-type` is set whenever there is
|
|
4
|
+
/** Lower-case names. `content-type` is set whenever there is something to write. */
|
|
4
5
|
readonly headers: Readonly<Record<string, string>>;
|
|
6
|
+
/** What an adapter writes, as it is. */
|
|
7
|
+
readonly payload: Payload;
|
|
8
|
+
/**
|
|
9
|
+
* The value answered, before anything wrote it: what the handler returned, without the fields
|
|
10
|
+
* the caller is not shown, or the problem document of a refusal. What a spec calling
|
|
11
|
+
* `executeRoute` reads and what an RPC procedure returns. Absent for a list read as it comes,
|
|
12
|
+
* which is its chunks only.
|
|
13
|
+
*/
|
|
5
14
|
readonly body?: unknown;
|
|
6
|
-
/** The chunks of a body written as it is read, a streamed list: an adapter writes them in order, and `body` is then absent. */
|
|
7
|
-
readonly stream?: AsyncIterable<string>;
|
|
8
15
|
}
|
|
9
16
|
//# sourceMappingURL=route-response.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-response.d.ts","sourceRoot":"","sources":["../../src/pipeline/route-response.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,
|
|
1
|
+
{"version":3,"file":"route-response.d.ts","sourceRoot":"","sources":["../../src/pipeline/route-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Payload } from './payload.js';
|
|
2
|
+
/** A payload a framework is handed whole: every one but a stream, which it pipes. */
|
|
3
|
+
type WholePayload = Exclude<Payload, {
|
|
4
|
+
kind: 'stream';
|
|
5
|
+
}>;
|
|
6
|
+
/** The whole of a payload, as every framework sends it: its text, its bytes, or nothing. */
|
|
7
|
+
export declare function wholeOf(payload: WholePayload): string | Uint8Array | undefined;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=whole-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whole-of.d.ts","sourceRoot":"","sources":["../../src/pipeline/whole-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,qFAAqF;AACrF,KAAK,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAEzD,4FAA4F;AAC5F,wBAAgB,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAM9E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The whole of a payload, as every framework sends it: its text, its bytes, or nothing. */
|
|
2
|
+
export function wholeOf(payload) {
|
|
3
|
+
if (payload.kind === 'none') {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
return payload.kind === 'text' ? payload.text : payload.bytes;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=whole-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whole-of.js","sourceRoot":"","sources":["../../src/pipeline/whole-of.ts"],"names":[],"mappings":"AAKA,4FAA4F;AAC5F,MAAM,UAAU,OAAO,CAAC,OAAqB;IAC3C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Chosen } from '../representation/representations.js';
|
|
2
|
+
/** How the answer of a request is written. */
|
|
3
|
+
export interface Writing {
|
|
4
|
+
/** The representation the request negotiated; `undefined` when nothing was, and the answer is JSON. */
|
|
5
|
+
readonly chosen: Chosen | undefined;
|
|
6
|
+
/** The content type the handler set itself, if it did. */
|
|
7
|
+
readonly ownContentType: string | undefined;
|
|
8
|
+
/** Told of a list that fails once its status is sent. */
|
|
9
|
+
readonly interrupted: (error: unknown) => void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=writing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writing.d.ts","sourceRoot":"","sources":["../../src/pipeline/writing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEhE,8CAA8C;AAC9C,MAAM,WAAW,OAAO;IACtB,uGAAuG;IACvG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,0DAA0D;IAC1D,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,yDAAyD;IACzD,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writing.js","sourceRoot":"","sources":["../../src/pipeline/writing.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import type { BodyShape } from '../representation/body-shape.js';
|
|
2
2
|
import type { Chosen } from '../representation/representations.js';
|
|
3
3
|
import type { RepresentedAnswer } from './represented-answer.js';
|
|
4
|
+
interface Written {
|
|
5
|
+
readonly chosen: Chosen;
|
|
6
|
+
readonly shape: BodyShape;
|
|
7
|
+
/** Told of a list that fails while its chunks are read. */
|
|
8
|
+
readonly interrupted?: (error: unknown) => void;
|
|
9
|
+
}
|
|
4
10
|
/**
|
|
5
|
-
* A value in the representation chosen for it:
|
|
6
|
-
*
|
|
7
|
-
* always did, and which a spec calling `executeRoute` reads as it is.
|
|
11
|
+
* A value in the representation chosen for it: its text at once, or a stream of its chunks for a
|
|
12
|
+
* list read as it comes. A value the representation cannot write fails here, inside the pipeline.
|
|
8
13
|
*/
|
|
9
|
-
export declare function writtenIn(value: unknown, chosen
|
|
14
|
+
export declare function writtenIn(value: unknown, { chosen, shape, interrupted }: Written): RepresentedAnswer;
|
|
15
|
+
export {};
|
|
10
16
|
//# sourceMappingURL=written-in.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"written-in.d.ts","sourceRoot":"","sources":["../../src/pipeline/written-in.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"written-in.d.ts","sourceRoot":"","sources":["../../src/pipeline/written-in.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAIhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,UAAU,OAAO;IACf,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,OAAO,GAAG,iBAAiB,CAYpG"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
2
|
import { isAsyncIterable } from '../support/is-async-iterable.js';
|
|
3
|
-
|
|
3
|
+
import { closingWith } from './closing-with.js';
|
|
4
|
+
import { reportedStream } from './reported-stream.js';
|
|
4
5
|
/**
|
|
5
|
-
* A value in the representation chosen for it:
|
|
6
|
-
*
|
|
7
|
-
* always did, and which a spec calling `executeRoute` reads as it is.
|
|
6
|
+
* A value in the representation chosen for it: its text at once, or a stream of its chunks for a
|
|
7
|
+
* list read as it comes. A value the representation cannot write fails here, inside the pipeline.
|
|
8
8
|
*/
|
|
9
|
-
export function writtenIn(value, chosen, shape) {
|
|
9
|
+
export function writtenIn(value, { chosen, shape, interrupted }) {
|
|
10
10
|
const headers = { 'content-type': `${chosen.mediaType}; charset=utf-8` };
|
|
11
|
-
if (chosen.representation instanceof JsonRepresentation && !isAsyncIterable(value)) {
|
|
12
|
-
return { headers, body: value };
|
|
13
|
-
}
|
|
14
11
|
const written = chosen.representation.write(value, shape);
|
|
15
|
-
|
|
12
|
+
if (typeof written === 'string') {
|
|
13
|
+
return { headers, payload: { kind: 'text', text: written } };
|
|
14
|
+
}
|
|
15
|
+
const chunks = isAsyncIterable(value) ? closingWith(written, value) : written;
|
|
16
|
+
const reported = interrupted === undefined ? chunks : reportedStream(chunks, interrupted);
|
|
17
|
+
return { headers, payload: { kind: 'stream', stream: Readable.from(reported) } };
|
|
16
18
|
}
|
|
17
19
|
//# sourceMappingURL=written-in.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"written-in.js","sourceRoot":"","sources":["../../src/pipeline/written-in.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"written-in.js","sourceRoot":"","sources":["../../src/pipeline/written-in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAUnD;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAW;IAC/E,MAAM,OAAO,GAAG,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,SAAS,iBAAiB,EAAE,CAAC;IACzE,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAE1D,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC;IAC/D,CAAC;IAED,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9E,MAAM,QAAQ,GAAG,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAE1F,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Whether a `Content-Type` header names JSON, whatever its parameters: the one reading of it for a body read and a body written. */
|
|
2
|
+
export declare function isJsonContentType(header: string | string[] | undefined): boolean;
|
|
3
|
+
//# sourceMappingURL=is-json-content-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-json-content-type.d.ts","sourceRoot":"","sources":["../../src/representation/is-json-content-type.ts"],"names":[],"mappings":"AAGA,qIAAqI;AACrI,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,OAAO,CAEhF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { isJsonMediaType } from './is-json-media-type.js';
|
|
2
|
+
import { mediaTypeOf } from './media-type-of.js';
|
|
3
|
+
/** Whether a `Content-Type` header names JSON, whatever its parameters: the one reading of it for a body read and a body written. */
|
|
4
|
+
export function isJsonContentType(header) {
|
|
5
|
+
return isJsonMediaType(mediaTypeOf(header) ?? '');
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=is-json-content-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-json-content-type.js","sourceRoot":"","sources":["../../src/representation/is-json-content-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,qIAAqI;AACrI,MAAM,UAAU,iBAAiB,CAAC,MAAqC;IACrE,OAAO,eAAe,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -35,6 +35,14 @@ function stringified(value) {
|
|
|
35
35
|
if (value === undefined) {
|
|
36
36
|
return 'null';
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
// A function, a symbol: `JSON.stringify` answers nothing for them, which its declaration does not say.
|
|
39
|
+
const text = JSON.stringify(value, bigIntegersAsText);
|
|
40
|
+
if (typeof text !== 'string') {
|
|
41
|
+
throw new TypeError('The answer is a value JSON does not write.');
|
|
42
|
+
}
|
|
43
|
+
return text;
|
|
44
|
+
}
|
|
45
|
+
function bigIntegersAsText(_key, part) {
|
|
46
|
+
return typeof part === 'bigint' ? part.toString() : part;
|
|
39
47
|
}
|
|
40
48
|
//# sourceMappingURL=json-representation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-representation.js","sourceRoot":"","sources":["../../src/representation/json-representation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAEtC;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IACpB,SAAS,GAAG,UAAU,CAAC;IAEvB,gBAAgB,GAAG,0BAA0B,CAAC;IAEvD,KAAK,CAAC,IAAa;QACjB,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,CAAC,IAAY;QACf,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,aAAa,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CACF;AAED,KAAK,SAAS,CAAC,CAAC,SAAS,CAAC,KAA6B;IACrD,IAAI,SAAS,GAAG,EAAE,CAAC;IAEnB,MAAM,GAAG,CAAC;IAEV,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC/B,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,SAAS,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,MAAM,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,wGAAwG;IACxG,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,
|
|
1
|
+
{"version":3,"file":"json-representation.js","sourceRoot":"","sources":["../../src/representation/json-representation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAEtC;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IACpB,SAAS,GAAG,UAAU,CAAC;IAEvB,gBAAgB,GAAG,0BAA0B,CAAC;IAEvD,KAAK,CAAC,IAAa;QACjB,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,CAAC,IAAY;QACf,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,aAAa,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CACF;AAED,KAAK,SAAS,CAAC,CAAC,SAAS,CAAC,KAA6B;IACrD,IAAI,SAAS,GAAG,EAAE,CAAC;IAEnB,MAAM,GAAG,CAAC;IAEV,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC/B,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,SAAS,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,MAAM,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,wGAAwG;IACxG,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,uGAAuG;IACvG,MAAM,IAAI,GAAY,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IAE/D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY,EAAE,IAAa;IACpD,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Route } from './route.js';
|
|
2
|
+
/** Whether the route reads its body as it arrives, an upload or a raw body: no parser may read it first. */
|
|
3
|
+
export declare function readsItsStream(route: Pick<Route, 'upload' | 'rawBody'>): boolean;
|
|
4
|
+
//# sourceMappingURL=reads-its-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads-its-stream.d.ts","sourceRoot":"","sources":["../../src/route/reads-its-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,4GAA4G;AAC5G,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC,GAAG,OAAO,CAEhF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads-its-stream.js","sourceRoot":"","sources":["../../src/route/reads-its-stream.ts"],"names":[],"mappings":"AAEA,4GAA4G;AAC5G,MAAM,UAAU,cAAc,CAAC,KAAwC;IACrE,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC;AAC9D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-answer.d.ts","sourceRoot":"","sources":["../../src/rpc/rpc-answer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rpc-answer.d.ts","sourceRoot":"","sources":["../../src/rpc/rpc-answer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,KAAK,CAAC;IAChD,wHAAwH;IACxH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAuBrH"}
|
package/dist/rpc/rpc-answer.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
+
import { finished } from 'node:stream/promises';
|
|
2
3
|
import { toProblem } from '../error/to-problem.js';
|
|
4
|
+
import { isJsonContentType } from '../representation/is-json-content-type.js';
|
|
3
5
|
import { NotAcceptableError } from '../representation/not-acceptable-error.js';
|
|
4
|
-
import { isAsyncIterable } from '../support/is-async-iterable.js';
|
|
5
6
|
import { isRecord } from '../support/is-record.js';
|
|
6
7
|
const FIRST_REFUSAL_STATUS = 400;
|
|
7
8
|
/**
|
|
@@ -14,31 +15,31 @@ export async function rpcAnswer(response, protocol, mapper) {
|
|
|
14
15
|
if (response.status >= FIRST_REFUSAL_STATUS) {
|
|
15
16
|
throw protocol.refuse(refusalOf(response));
|
|
16
17
|
}
|
|
17
|
-
const {
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
throw
|
|
18
|
+
const { payload } = response;
|
|
19
|
+
const onlyOverHttp = (what) => protocol.refuse(streamedRefusal(what, response, mapper));
|
|
20
|
+
if (payload.kind === 'stream') {
|
|
21
|
+
await closed(payload.stream);
|
|
22
|
+
throw onlyOverHttp(response.body instanceof Readable ? 'a file' : 'a list read as it comes');
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
if (isAsyncIterable(body)) {
|
|
25
|
-
await body[Symbol.asyncIterator]().return?.();
|
|
26
|
-
throw streamed('a list read as it comes');
|
|
27
|
-
}
|
|
28
|
-
if (body instanceof Uint8Array) {
|
|
24
|
+
if (payload.kind === 'bytes') {
|
|
29
25
|
if (!protocol.carriesBinary) {
|
|
30
|
-
throw
|
|
26
|
+
throw onlyOverHttp('a binary body');
|
|
31
27
|
}
|
|
32
|
-
return new Blob([
|
|
28
|
+
return new Blob([payload.bytes], { type: response.headers['content-type'] });
|
|
33
29
|
}
|
|
34
|
-
return
|
|
30
|
+
return payload.kind === 'text' ? returned(payload.text, response) : undefined;
|
|
31
|
+
}
|
|
32
|
+
/** A file is closed, and so is the cursor of a list, whether anything was read from it or not. */
|
|
33
|
+
async function closed(stream) {
|
|
34
|
+
stream.destroy();
|
|
35
|
+
await finished(stream).catch(() => undefined);
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* A JSON body is returned as the HTTP route writes it, a date as its text: what the contract, and
|
|
38
39
|
* the client generated from it, say it is, which the serializer of a protocol would otherwise keep a `Date`.
|
|
39
40
|
*/
|
|
40
|
-
function
|
|
41
|
-
return
|
|
41
|
+
function returned(text, response) {
|
|
42
|
+
return isJsonContentType(response.headers['content-type']) ? JSON.parse(text) : text;
|
|
42
43
|
}
|
|
43
44
|
/** A refusal the route answers itself, without a problem document, keeps its status and its body under the code `HTTP_<status>`. */
|
|
44
45
|
function refusalOf(response) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-answer.js","sourceRoot":"","sources":["../../src/rpc/rpc-answer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc-answer.js","sourceRoot":"","sources":["../../src/rpc/rpc-answer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAUjC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAuB,EAAE,QAAqB,EAAE,MAAmB;IACjG,IAAI,QAAQ,CAAC,MAAM,IAAI,oBAAoB,EAAE,CAAC;QAC5C,MAAM,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC7B,MAAM,YAAY,GAAG,CAAC,IAAY,EAAS,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,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I,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;IAElC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,QAAQ,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAEtC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACnE,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC9F,CAAC;AAED,SAAS,SAAS,CAAC,IAAa;IAC9B,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;AACjG,CAAC;AAED,+GAA+G;AAC/G,SAAS,eAAe,CAAC,IAAY,EAAE,QAAuB,EAAE,MAAmB;IACjF,MAAM,OAAO,GAAG,0BAA0B,IAAI,sCAAsC,CAAC;IACrF,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;IAE3G,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RouteResponse } from '../pipeline/route-response.js';
|
|
2
|
+
/**
|
|
3
|
+
* The text an adapter writes for an answer, read to its end: what a spec checks a representation
|
|
4
|
+
* with (XML, CSV), or a list read as it comes, where `response.body` is the value before it was
|
|
5
|
+
* written.
|
|
6
|
+
*
|
|
7
|
+
* expect(await writtenText(await send({ headers: { accept: 'text/csv' } }))).toBe('id\r\n1\r\n');
|
|
8
|
+
*/
|
|
9
|
+
export declare function writtenText({ payload }: RouteResponse): Promise<string>;
|
|
10
|
+
//# sourceMappingURL=written-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"written-text.d.ts","sourceRoot":"","sources":["../../src/testing/written-text.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ7E"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { text } from 'node:stream/consumers';
|
|
2
|
+
import { wholeOf } from '../pipeline/whole-of.js';
|
|
3
|
+
/**
|
|
4
|
+
* The text an adapter writes for an answer, read to its end: what a spec checks a representation
|
|
5
|
+
* with (XML, CSV), or a list read as it comes, where `response.body` is the value before it was
|
|
6
|
+
* written.
|
|
7
|
+
*
|
|
8
|
+
* expect(await writtenText(await send({ headers: { accept: 'text/csv' } }))).toBe('id\r\n1\r\n');
|
|
9
|
+
*/
|
|
10
|
+
export async function writtenText({ payload }) {
|
|
11
|
+
if (payload.kind === 'stream') {
|
|
12
|
+
return text(payload.stream);
|
|
13
|
+
}
|
|
14
|
+
const whole = wholeOf(payload) ?? '';
|
|
15
|
+
return typeof whole === 'string' ? whole : new TextDecoder().decode(whole);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=written-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"written-text.js","sourceRoot":"","sources":["../../src/testing/written-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAAE,OAAO,EAAiB;IAC1D,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAErC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC"}
|
package/dist/testing.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { routeOf } from './testing/route-of.js';
|
|
|
2
2
|
export type { RouteOfOptions } from './testing/route-of-options.js';
|
|
3
3
|
export type { RouteUnderTest } from './testing/route-under-test.js';
|
|
4
4
|
export type { SentRequest } from './testing/sent-request.js';
|
|
5
|
+
export { writtenText } from './testing/written-text.js';
|
|
5
6
|
//# sourceMappingURL=testing.d.ts.map
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/testing.js
CHANGED
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/trpc/trpc-router.js
CHANGED
|
@@ -26,7 +26,7 @@ export function trpcRouter(routes, options = {}) {
|
|
|
26
26
|
const execute = withoutRepresentations(options);
|
|
27
27
|
return trpc.router(Object.fromEntries(served.map((route) => [route.operationId, procedureOf(route, execute, mapper)])));
|
|
28
28
|
}
|
|
29
|
-
/** tRPC writes the answer: no representation is negotiated, and a list read as it comes
|
|
29
|
+
/** tRPC writes the answer: no representation is negotiated, and a list read as it comes is written as JSON, closed when refused. */
|
|
30
30
|
function withoutRepresentations({ representations, ...options }) {
|
|
31
31
|
return options;
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trpc-router.js","sourceRoot":"","sources":["../../src/trpc/trpc-router.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,GAMT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,SAAS,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KAAK,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAuC,EAAoB,EAAE,CAC9F,SAAS,CAAC,MAAM,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;IAE/F,OAAO,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACzF,CAAC;AAED,wHAAwH;AACxH,SAAS,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAsD;IACvF,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC;IACtC,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,YAAY,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3F,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC;AAClD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts-kit/http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.115.0",
|
|
4
4
|
"description": "Framework-agnostic route definitions with Express, Fastify, Hono and NestJS adapters, oRPC and tRPC procedures and OpenAPI 3.1 generation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ddd",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/
|
|
23
|
+
"url": "git+https://github.com/ddd-ts-kit/ddd-ts-kit.git",
|
|
24
24
|
"directory": "packages/http"
|
|
25
25
|
},
|
|
26
|
-
"homepage": "https://
|
|
27
|
-
"bugs": "https://github.com/
|
|
26
|
+
"homepage": "https://ddd-ts-kit.github.io/ddd-ts-kit/packages/http/",
|
|
27
|
+
"bugs": "https://github.com/ddd-ts-kit/ddd-ts-kit/issues",
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public",
|
|
30
30
|
"provenance": true
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"dist"
|
|
89
89
|
],
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@ddd-ts-kit/kernel": "0.
|
|
92
|
-
"@ddd-ts-kit/validation": "0.
|
|
91
|
+
"@ddd-ts-kit/kernel": "0.115.0",
|
|
92
|
+
"@ddd-ts-kit/validation": "0.115.0"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
95
|
"@nestjs/common": ">=11.0.0",
|
|
@@ -128,23 +128,23 @@
|
|
|
128
128
|
}
|
|
129
129
|
},
|
|
130
130
|
"devDependencies": {
|
|
131
|
-
"@ddd-ts-kit/testing": "0.
|
|
132
|
-
"@hono/node-server": "^2.1.
|
|
133
|
-
"@nestjs/common": "^12.
|
|
134
|
-
"@nestjs/core": "^12.
|
|
135
|
-
"@nestjs/platform-express": "^12.
|
|
136
|
-
"@nestjs/platform-fastify": "^12.
|
|
131
|
+
"@ddd-ts-kit/testing": "0.115.0",
|
|
132
|
+
"@hono/node-server": "^2.1.8",
|
|
133
|
+
"@nestjs/common": "^12.5.0",
|
|
134
|
+
"@nestjs/core": "^12.5.0",
|
|
135
|
+
"@nestjs/platform-express": "^12.5.0",
|
|
136
|
+
"@nestjs/platform-fastify": "^12.5.0",
|
|
137
137
|
"@orpc/client": "^1.16.2",
|
|
138
138
|
"@orpc/contract": "^1.16.2",
|
|
139
139
|
"@orpc/server": "^1.16.2",
|
|
140
|
-
"@trpc/client": "^11.
|
|
141
|
-
"@trpc/server": "^11.
|
|
140
|
+
"@trpc/client": "^11.28.3",
|
|
141
|
+
"@trpc/server": "^11.28.3",
|
|
142
142
|
"@types/busboy": "^1.5.5",
|
|
143
143
|
"@types/express": "^5.0.0",
|
|
144
144
|
"busboy": "^1.6.0",
|
|
145
145
|
"express": "^5.3.0",
|
|
146
146
|
"fastify": "^5.12.7",
|
|
147
|
-
"hono": "^4.13.
|
|
147
|
+
"hono": "^4.13.18",
|
|
148
148
|
"reflect-metadata": "^0.2.2",
|
|
149
149
|
"rxjs": "^7.8.0",
|
|
150
150
|
"zod": "^4.6.5"
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { RouteResponse } from './route-response.js';
|
|
2
|
-
/**
|
|
3
|
-
* The bytes every adapter writes, so the three frameworks answer identically. A string or
|
|
4
|
-
* binary body is sent as is when the handler chose its own content type; anything else is JSON.
|
|
5
|
-
*/
|
|
6
|
-
export declare function serializeBody(response: RouteResponse): string | Uint8Array | undefined;
|
|
7
|
-
//# sourceMappingURL=serialize-body.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialize-body.d.ts","sourceRoot":"","sources":["../../src/pipeline/serialize-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CActF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The bytes every adapter writes, so the three frameworks answer identically. A string or
|
|
3
|
-
* binary body is sent as is when the handler chose its own content type; anything else is JSON.
|
|
4
|
-
*/
|
|
5
|
-
export function serializeBody(response) {
|
|
6
|
-
const { body } = response;
|
|
7
|
-
if (body === undefined) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
if (body instanceof Uint8Array) {
|
|
11
|
-
return body;
|
|
12
|
-
}
|
|
13
|
-
const isJson = /[/+]json\b/.test(response.headers['content-type'] ?? '');
|
|
14
|
-
return typeof body === 'string' && !isJson ? body : JSON.stringify(body);
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=serialize-body.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialize-body.js","sourceRoot":"","sources":["../../src/pipeline/serialize-body.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,QAAuB;IACnD,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;IAE1B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,IAAI,YAAY,UAAU,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;IAEzE,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Writable } from 'node:stream';
|
|
2
|
-
/**
|
|
3
|
-
* Writes the chunks of a streamed list to a response, waiting for the client when it reads slower
|
|
4
|
-
* than the list is produced, and stops reading the list when the client leaves. A failure once
|
|
5
|
-
* the status is sent can only cut the response short: the connection is closed.
|
|
6
|
-
*/
|
|
7
|
-
export declare function writeStream(target: Writable, chunks: AsyncIterable<string>): Promise<void>;
|
|
8
|
-
//# sourceMappingURL=write-stream.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"write-stream.d.ts","sourceRoot":"","sources":["../../src/pipeline/write-stream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBhG"}
|