@ddd-ts-kit/http 0.12.0 → 0.13.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.md +56 -4
- package/dist/hono/edge-problem.d.ts +11 -0
- package/dist/hono/edge-problem.d.ts.map +1 -0
- package/dist/hono/edge-problem.js +15 -0
- package/dist/hono/edge-problem.js.map +1 -0
- package/dist/hono/hono-mount-options.d.ts +10 -0
- package/dist/hono/hono-mount-options.d.ts.map +1 -0
- package/dist/hono/hono-mount-options.js +2 -0
- package/dist/hono/hono-mount-options.js.map +1 -0
- package/dist/hono/hono-raw.d.ts +11 -0
- package/dist/hono/hono-raw.d.ts.map +1 -0
- package/dist/hono/hono-raw.js +2 -0
- package/dist/hono/hono-raw.js.map +1 -0
- package/dist/hono/mount-hono.d.ts +11 -0
- package/dist/hono/mount-hono.d.ts.map +1 -0
- package/dist/hono/mount-hono.js +65 -0
- package/dist/hono/mount-hono.js.map +1 -0
- package/dist/hono/read-body.d.ts +15 -0
- package/dist/hono/read-body.d.ts.map +1 -0
- package/dist/hono/read-body.js +58 -0
- package/dist/hono/read-body.js.map +1 -0
- package/dist/hono.d.ts +4 -0
- package/dist/hono.d.ts.map +1 -0
- package/dist/hono.js +2 -0
- package/dist/hono.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/openapi/definitions.d.ts +6 -1
- package/dist/openapi/definitions.d.ts.map +1 -1
- package/dist/openapi/definitions.js +12 -1
- package/dist/openapi/definitions.js.map +1 -1
- package/dist/openapi/schema-parameters.js +1 -1
- package/dist/openapi/schema-parameters.js.map +1 -1
- package/dist/pagination/page-schema-of.d.ts +2 -1
- package/dist/pagination/page-schema-of.d.ts.map +1 -1
- package/dist/pagination/page-schema-of.js +7 -3
- package/dist/pagination/page-schema-of.js.map +1 -1
- package/dist/schemas/accepted-schema.d.ts +8 -0
- package/dist/schemas/accepted-schema.d.ts.map +1 -0
- package/dist/schemas/accepted-schema.js +20 -0
- package/dist/schemas/accepted-schema.js.map +1 -0
- package/dist/schemas/accepted.d.ts +5 -0
- package/dist/schemas/accepted.d.ts.map +1 -0
- package/dist/schemas/accepted.js +2 -0
- package/dist/schemas/accepted.js.map +1 -0
- package/package.json +15 -5
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @ddd-ts-kit/http
|
|
2
2
|
|
|
3
|
-
Declare a route once, without a framework. Mount it on Express 5, Fastify 5
|
|
4
|
-
generate the OpenAPI 3.1 contract from the same declaration.
|
|
3
|
+
Declare a route once, without a framework. Mount it on Express 5, Fastify 5, Hono 4 (on Node)
|
|
4
|
+
or NestJS, and generate the OpenAPI 3.1 contract from the same declaration.
|
|
5
5
|
|
|
6
6
|
Every adapter goes through one pipeline (`executeRoute`): validation, handler, error mapping.
|
|
7
|
-
The behaviour is therefore the same on the
|
|
7
|
+
The behaviour is therefore the same on the four frameworks, and one test suite proves it.
|
|
8
8
|
|
|
9
9
|
## Declare
|
|
10
10
|
|
|
@@ -527,7 +527,7 @@ const searchOrders = defineRoute(
|
|
|
527
527
|
| `pageQuerySchema(options?)` | the same reading as a `Schema`, for a route whose whole query is the page |
|
|
528
528
|
| `pageResponse(page, map)` | the JSON body `{ items, total?, nextCursor? }`, each item through `map` |
|
|
529
529
|
| `pageRequestParameters(options?)` | the JSON Schema of the query (one OpenAPI parameter per property); `properties` merges into a wider schema |
|
|
530
|
-
| `pageSchemaOf(itemSchema)` | the `Schema` of a page of items: validates the envelope and each item, describes both in the contract |
|
|
530
|
+
| `pageSchemaOf(itemSchema)` | the `Schema` of a page of items: validates the envelope and each item, describes both in the contract; shared as `<Item>Page` when the item is shared ([shared schemas](#shared-schemas)) |
|
|
531
531
|
|
|
532
532
|
`options` are the `PageLimits` of the kernel (`defaultSize` 20, `maxSize` 100) plus `sortable`,
|
|
533
533
|
the closed list of fields a client may sort by, and `kind`, the variant of a query that names
|
|
@@ -632,6 +632,28 @@ mountFastify(app, orderRoutes(orders), options);
|
|
|
632
632
|
await app.register(fastifyRoutes(orderRoutes(orders), options), { prefix: '/api' });
|
|
633
633
|
```
|
|
634
634
|
|
|
635
|
+
## Hono 4
|
|
636
|
+
|
|
637
|
+
```ts
|
|
638
|
+
import { serve } from '@hono/node-server';
|
|
639
|
+
import { Hono } from 'hono';
|
|
640
|
+
import { mountHono } from '@ddd-ts-kit/http/hono';
|
|
641
|
+
|
|
642
|
+
const app = new Hono();
|
|
643
|
+
mountHono(app, orderRoutes(orders), options);
|
|
644
|
+
serve({ fetch: app.fetch, port: 3000 });
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
The adapter reads the JSON body itself, chunk by chunk and up to `bodyLimit` bytes (1 MiB by
|
|
648
|
+
default, as Fastify; Express stops at 100 kB): a larger body is answered 413 as a problem
|
|
649
|
+
(`BODY_TOO_LARGE`), a body that is not JSON 400 (`MALFORMED_BODY`), both before the pipeline and
|
|
650
|
+
without holding the body whole. An upload and a raw body are read from the request stream, with
|
|
651
|
+
the limits their route declares, and a stream answer is streamed. A request carries `HonoRaw` as
|
|
652
|
+
its raw request (its headers as a record, which the authenticators of the kit read, and the
|
|
653
|
+
`Context` of Hono), and a repeated query parameter is a list, as on Express and Fastify. The
|
|
654
|
+
adapter imports nothing of Hono at run time and `node:stream` for the streams: the kit proves
|
|
655
|
+
Node with `@hono/node-server`, not Bun, Deno or an edge runtime.
|
|
656
|
+
|
|
635
657
|
## NestJS
|
|
636
658
|
|
|
637
659
|
No decorator per route: a module mounts the routes on the underlying HTTP server at module
|
|
@@ -691,6 +713,36 @@ whenever the route validates input, a shared `Problem` schema. Local `$defs` of
|
|
|
691
713
|
moved to `components.schemas`. Paths, statuses and component keys are sorted: the output does
|
|
692
714
|
not depend on the order of the routes, so the committed file diffs cleanly.
|
|
693
715
|
|
|
716
|
+
### Shared schemas
|
|
717
|
+
|
|
718
|
+
A schema several routes use is declared once and lands once in `components.schemas`; each route
|
|
719
|
+
points at it with `$ref`, whether it uses it whole or inside another schema. A schema is shared
|
|
720
|
+
when its JSON Schema is a reference to one of its own definitions, which every adapter of
|
|
721
|
+
`@ddd-ts-kit/validation` can produce:
|
|
722
|
+
|
|
723
|
+
| Library | Shared by |
|
|
724
|
+
|---|---|
|
|
725
|
+
| zod | `.meta({ id: 'Slot' })` on the zod schema, used whole or nested |
|
|
726
|
+
| class-validator | `classSchema(SlotDto, { shared: true })`; a nested class is always a component |
|
|
727
|
+
| TypeBox | `{ $id: 'Slot' }` in the options of the schema, used whole or nested |
|
|
728
|
+
| Standard Schema | the library's own ids through Standard JSON Schema, or `sharedSchema('Slot', schema)` |
|
|
729
|
+
| any `Schema` | `sharedSchema(name, schema)` of `@ddd-ts-kit/validation` |
|
|
730
|
+
|
|
731
|
+
A part of a shared schema (`slot.pick(...)`, `pickClass(SlotDto, [...])`) is a new shape: it is
|
|
732
|
+
written where it is used unless it is shared under a name of its own. Two different shapes under
|
|
733
|
+
one name get distinct components (`Slot`, `Slot_2`): for zod, the input and the output side of a
|
|
734
|
+
schema with defaults are two shapes, so a response gets an id of its own.
|
|
735
|
+
|
|
736
|
+
The platform shares three schemas of its own:
|
|
737
|
+
|
|
738
|
+
| Schema | Component | For |
|
|
739
|
+
|---|---|---|
|
|
740
|
+
| `acceptedSchema` | `Accepted`, `{ id }` | the answer of every command route that returns the identifier of what it created or changed |
|
|
741
|
+
| `pageSchemaOf(item)` | `<Item>Page` when the item is shared | the envelope of a search answer (`items`, `total`, `nextCursor`) |
|
|
742
|
+
| the problem document | `Problem` | every refusal, RFC 9457 with the stable `code` |
|
|
743
|
+
|
|
744
|
+
A shared request part (`params`, `query`, `headers`) still gives one parameter per property.
|
|
745
|
+
|
|
694
746
|
## Serving the contract and its page
|
|
695
747
|
|
|
696
748
|
```ts
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RawHeaders } from '../route/raw-headers.js';
|
|
2
|
+
/** A request the adapter refuses before the pipeline runs: its status, its code and what is wrong. */
|
|
3
|
+
export interface EdgeRefusal {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly title: string;
|
|
6
|
+
readonly code: string;
|
|
7
|
+
readonly detail: string;
|
|
8
|
+
}
|
|
9
|
+
/** The answer to a request refused at the edge: a problem document, as every other refusal. */
|
|
10
|
+
export declare function edgeProblem(headers: RawHeaders, refusal: EdgeRefusal): Response;
|
|
11
|
+
//# sourceMappingURL=edge-problem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-problem.d.ts","sourceRoot":"","sources":["../../src/hono/edge-problem.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,sGAAsG;AACtG,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,GAAG,QAAQ,CAW/E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CORRELATION_HEADER } from '../pipeline/correlation-header.js';
|
|
2
|
+
import { wellFormedIdentifier } from '../pipeline/well-formed-identifier.js';
|
|
3
|
+
/** The answer to a request refused at the edge: a problem document, as every other refusal. */
|
|
4
|
+
export function edgeProblem(headers, refusal) {
|
|
5
|
+
const requestId = wellFormedIdentifier(headers['x-request-id']) ?? globalThis.crypto.randomUUID();
|
|
6
|
+
const problem = { type: 'about:blank', ...refusal, requestId };
|
|
7
|
+
return new Response(JSON.stringify(problem), {
|
|
8
|
+
status: refusal.status,
|
|
9
|
+
headers: {
|
|
10
|
+
'content-type': 'application/problem+json',
|
|
11
|
+
[CORRELATION_HEADER]: wellFormedIdentifier(headers[CORRELATION_HEADER]) ?? requestId,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=edge-problem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-problem.js","sourceRoot":"","sources":["../../src/hono/edge-problem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAW7E,+FAA+F;AAC/F,MAAM,UAAU,WAAW,CAAC,OAAmB,EAAE,OAAoB;IACnE,MAAM,SAAS,GAAG,oBAAoB,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAClG,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,CAAC;IAE/D,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QAC3C,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE;YACP,cAAc,EAAE,0BAA0B;YAC1C,CAAC,kBAAkB,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,SAAS;SACrF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExecuteOptions } from '../pipeline/execute-options.js';
|
|
2
|
+
export interface HonoMountOptions extends ExecuteOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The largest JSON body read, in bytes: a larger one is answered 413 as a problem
|
|
5
|
+
* (`BODY_TOO_LARGE`) before the pipeline runs, without being held in memory. 1 MiB by default,
|
|
6
|
+
* the limit of Fastify; Express answers beyond 100 kB. An upload has the limit its route declares.
|
|
7
|
+
*/
|
|
8
|
+
readonly bodyLimit?: number;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=hono-mount-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-mount-options.d.ts","sourceRoot":"","sources":["../../src/hono/hono-mount-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-mount-options.js","sourceRoot":"","sources":["../../src/hono/hono-mount-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { RawHeaders } from '../route/raw-headers.js';
|
|
3
|
+
/**
|
|
4
|
+
* What `resolvePrincipal` and the hooks receive as the request on Hono: the headers as a plain
|
|
5
|
+
* record, which the authenticators of the kit read, and the context of Hono for the rest.
|
|
6
|
+
*/
|
|
7
|
+
export interface HonoRaw {
|
|
8
|
+
readonly headers: RawHeaders;
|
|
9
|
+
readonly context: Context;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=hono-raw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-raw.d.ts","sourceRoot":"","sources":["../../src/hono/hono-raw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono-raw.js","sourceRoot":"","sources":["../../src/hono/hono-raw.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
import type { Route } from '../route/route.js';
|
|
3
|
+
import type { HonoMountOptions } from './hono-mount-options.js';
|
|
4
|
+
/**
|
|
5
|
+
* Registers the routes on a Hono application. The adapter reads the JSON body itself, up to
|
|
6
|
+
* `bodyLimit` (1 MiB by default): a larger body is answered 413 and a body that is not JSON 400,
|
|
7
|
+
* both as problems, before the pipeline runs. An upload and a raw body are read from the
|
|
8
|
+
* request stream; a body that is a stream is streamed to the response.
|
|
9
|
+
*/
|
|
10
|
+
export declare function mountHono(app: Pick<Hono, 'on'>, routes: readonly Route[], options?: HonoMountOptions): void;
|
|
11
|
+
//# sourceMappingURL=mount-hono.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-hono.d.ts","sourceRoot":"","sources":["../../src/hono/mount-hono.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAM1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAShE;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,OAAO,GAAE,gBAAqB,GAAG,IAAI,CAM/G"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { executeRoute } from '../pipeline/execute-route.js';
|
|
3
|
+
import { serializeBody } from '../pipeline/serialize-body.js';
|
|
4
|
+
import { assertUniqueRoutes } from '../route/assert-unique-routes.js';
|
|
5
|
+
import { edgeProblem } from './edge-problem.js';
|
|
6
|
+
import { readBody } from './read-body.js';
|
|
7
|
+
/** What Fastify reads at most by default: the same bound on every adapter that sets its own. */
|
|
8
|
+
const ONE_MEBIBYTE = 1_048_576;
|
|
9
|
+
/**
|
|
10
|
+
* Registers the routes on a Hono application. The adapter reads the JSON body itself, up to
|
|
11
|
+
* `bodyLimit` (1 MiB by default): a larger body is answered 413 and a body that is not JSON 400,
|
|
12
|
+
* both as problems, before the pipeline runs. An upload and a raw body are read from the
|
|
13
|
+
* request stream; a body that is a stream is streamed to the response.
|
|
14
|
+
*/
|
|
15
|
+
export function mountHono(app, routes, options = {}) {
|
|
16
|
+
assertUniqueRoutes(routes);
|
|
17
|
+
for (const route of routes) {
|
|
18
|
+
app.on(route.method, route.path, handlerOf(route, options));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function handlerOf(route, options) {
|
|
22
|
+
const { bodyLimit = ONE_MEBIBYTE, ...execute } = options;
|
|
23
|
+
return async (context) => {
|
|
24
|
+
const request = streamed(route) ? streamRequest(context) : await jsonRequest(context, bodyLimit);
|
|
25
|
+
if (request instanceof Response) {
|
|
26
|
+
return request;
|
|
27
|
+
}
|
|
28
|
+
return responseOf(await executeRoute(route, request, execute));
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function streamed(route) {
|
|
32
|
+
return route.upload !== undefined || route.rawBody === true;
|
|
33
|
+
}
|
|
34
|
+
function streamRequest(context) {
|
|
35
|
+
const { body } = context.req.raw;
|
|
36
|
+
return {
|
|
37
|
+
...common(context),
|
|
38
|
+
body: undefined,
|
|
39
|
+
...(body === null ? {} : { stream: Readable.fromWeb(body) }),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async function jsonRequest(context, limit) {
|
|
43
|
+
const body = await readBody(context, limit);
|
|
44
|
+
if (!body.read) {
|
|
45
|
+
return edgeProblem(context.req.header(), body.refusal);
|
|
46
|
+
}
|
|
47
|
+
return { ...common(context), body: body.value };
|
|
48
|
+
}
|
|
49
|
+
function common(context) {
|
|
50
|
+
const headers = context.req.header();
|
|
51
|
+
const raw = { headers, context };
|
|
52
|
+
return { params: context.req.param(), query: queryOf(context), headers, raw };
|
|
53
|
+
}
|
|
54
|
+
function responseOf(result) {
|
|
55
|
+
const body = result.body instanceof Readable ? Readable.toWeb(result.body) : (serializeBody(result) ?? null);
|
|
56
|
+
return new Response(body, { status: result.status, headers: result.headers });
|
|
57
|
+
}
|
|
58
|
+
/** A repeated key keeps its values as a list, a single one is a string: what Express and Fastify answer. */
|
|
59
|
+
function queryOf(context) {
|
|
60
|
+
return Object.fromEntries(Object.entries(context.req.queries()).map(([name, values]) => [
|
|
61
|
+
name,
|
|
62
|
+
values.length === 1 ? (values[0] ?? '') : values,
|
|
63
|
+
]));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=mount-hono.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-hono.js","sourceRoot":"","sources":["../../src/hono/mount-hono.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,gGAAgG;AAChG,MAAM,YAAY,GAAG,SAAS,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAqB,EAAE,MAAwB,EAAE,OAAO,GAAqB,EAAE;IACvG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAE3B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,SAAS,CA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C,CAAC,CAAC,CAAC,MAAM;KACjD,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { EdgeRefusal } from './edge-problem.js';
|
|
3
|
+
export type ReadBody = {
|
|
4
|
+
readonly read: true;
|
|
5
|
+
readonly value: unknown;
|
|
6
|
+
} | {
|
|
7
|
+
readonly read: false;
|
|
8
|
+
readonly refusal: EdgeRefusal;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The JSON body of the request, `undefined` when there is none; not read when it is not JSON.
|
|
12
|
+
* Read chunk by chunk and given up beyond `limit` bytes, so that no body is held whole past it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readBody(context: Context, limit: number): Promise<ReadBody>;
|
|
15
|
+
//# sourceMappingURL=read-body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-body.d.ts","sourceRoot":"","sources":["../../src/hono/read-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAW5D;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAYjF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const JSON_MEDIA = /[/+]json\b/;
|
|
2
|
+
const MALFORMED = {
|
|
3
|
+
status: 400,
|
|
4
|
+
title: 'Bad Request',
|
|
5
|
+
code: 'MALFORMED_BODY',
|
|
6
|
+
detail: 'The body is not valid JSON.',
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The JSON body of the request, `undefined` when there is none; not read when it is not JSON.
|
|
10
|
+
* Read chunk by chunk and given up beyond `limit` bytes, so that no body is held whole past it.
|
|
11
|
+
*/
|
|
12
|
+
export async function readBody(context, limit) {
|
|
13
|
+
if (!JSON_MEDIA.test(context.req.header('content-type') ?? '')) {
|
|
14
|
+
return { read: true, value: undefined };
|
|
15
|
+
}
|
|
16
|
+
const text = await boundedText(context.req.raw, limit);
|
|
17
|
+
if (text === undefined) {
|
|
18
|
+
return { read: false, refusal: tooLarge(limit) };
|
|
19
|
+
}
|
|
20
|
+
return text === '' ? { read: true, value: undefined } : parsed(text);
|
|
21
|
+
}
|
|
22
|
+
async function boundedText(request, limit) {
|
|
23
|
+
if (Number(request.headers.get('content-length') ?? 0) > limit) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return request.body === null ? '' : decodedUpTo(request.body, limit);
|
|
27
|
+
}
|
|
28
|
+
async function decodedUpTo(body, limit) {
|
|
29
|
+
const decoder = new TextDecoder();
|
|
30
|
+
let size = 0;
|
|
31
|
+
let text = '';
|
|
32
|
+
for await (const chunk of body) {
|
|
33
|
+
size += chunk.byteLength;
|
|
34
|
+
if (size > limit) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
text += decoder.decode(chunk, { stream: true });
|
|
38
|
+
}
|
|
39
|
+
return text + decoder.decode();
|
|
40
|
+
}
|
|
41
|
+
function parsed(text) {
|
|
42
|
+
try {
|
|
43
|
+
const value = JSON.parse(text);
|
|
44
|
+
return { read: true, value };
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return { read: false, refusal: MALFORMED };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function tooLarge(limit) {
|
|
51
|
+
return {
|
|
52
|
+
status: 413,
|
|
53
|
+
title: 'Payload Too Large',
|
|
54
|
+
code: 'BODY_TOO_LARGE',
|
|
55
|
+
detail: `The body is larger than ${String(limit)} bytes.`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=read-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-body.js","sourceRoot":"","sources":["../../src/hono/read-body.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,GAAG,YAAY,CAAC;AAEhC,MAAM,SAAS,GAAgB;IAC7B,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,aAAa;IACpB,IAAI,EAAE,gBAAgB;IACtB,MAAM,EAAE,6BAA6B;CACtC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAgB,EAAE,KAAa;IAC5D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAC/D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAC1C,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAEvD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACvE,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,OAAgB,EAAE,KAAa;IACxD,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAA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AAC,SAAS;KAC1D,CAAC;AACJ,CAAC"}
|
package/dist/hono.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../src/hono.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/hono.js
ADDED
package/dist/hono.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hono.js","sourceRoot":"","sources":["../src/hono.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -86,6 +86,8 @@ export type { RouteInput } from './route/route-input.js';
|
|
|
86
86
|
export type { RouteOutput } from './route/route-output.js';
|
|
87
87
|
export type { RouteSpec } from './route/route-spec.js';
|
|
88
88
|
export type { Route } from './route/route.js';
|
|
89
|
+
export type { Accepted } from './schemas/accepted.js';
|
|
90
|
+
export { acceptedSchema } from './schemas/accepted-schema.js';
|
|
89
91
|
export type { UploadSpec } from './route/upload-spec.js';
|
|
90
92
|
export { firstTenantOf } from './tenancy/first-tenant-of.js';
|
|
91
93
|
export { tenantFromClaim } from './tenancy/tenant-from-claim.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,YAAY,EAA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C/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,7 @@ export { defineRoute } from './route/define-route.js';
|
|
|
41
41
|
export { defineRoutes } from './route/define-routes.js';
|
|
42
42
|
export { DuplicateRouteError } from './route/duplicate-route-error.js';
|
|
43
43
|
export { prefixRoutes } from './route/prefix-routes.js';
|
|
44
|
+
export { acceptedSchema } from './schemas/accepted-schema.js';
|
|
44
45
|
export { firstTenantOf } from './tenancy/first-tenant-of.js';
|
|
45
46
|
export { tenantFromClaim } from './tenancy/tenant-from-claim.js';
|
|
46
47
|
export { tenantFromHeader } from './tenancy/tenant-from-header.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAK9C,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAKxD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,MAA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AE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAItE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAK3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAKvE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAYxD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import type { JsonSchema, Schema } from '@ddd-ts-kit/validation';
|
|
2
2
|
/**
|
|
3
3
|
* Local definitions (`$defs`) of the embedded JSON Schemas are moved to `components.schemas`,
|
|
4
|
-
* because a `#/$defs/...` pointer means nothing once the schema sits inside a document.
|
|
4
|
+
* because a `#/$defs/...` pointer means nothing once the schema sits inside a document. A shared
|
|
5
|
+
* schema (`sharedSchema`, a class schema with `shared`, a zod schema with `.meta({ id })`) is a
|
|
6
|
+
* reference to one of its definitions: it lands once among the components and every route that
|
|
7
|
+
* uses it points at it.
|
|
5
8
|
*/
|
|
6
9
|
export declare class Definitions {
|
|
7
10
|
private readonly schemas;
|
|
8
11
|
private readonly sources;
|
|
9
12
|
embed(schema: Schema<unknown>): JsonSchema;
|
|
10
13
|
all(): Record<string, JsonSchema>;
|
|
14
|
+
/** The schema itself when it is a reference to a component: the parameters of a request part are its properties. */
|
|
15
|
+
resolve(schema: JsonSchema): JsonSchema;
|
|
11
16
|
/** Two different definitions sharing a name get distinct component names. */
|
|
12
17
|
private reserve;
|
|
13
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/openapi/definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/openapi/definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAMjE;;;;;;GAMG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IAEzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IAErD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,UAAU,CAgBzC;IAED,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAEhC;IAED,oHAAoH;IACpH,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAMtC;IAED,6EAA6E;IAC7E,OAAO,CAAC,OAAO;CAgBhB"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { isRecord } from '../support/is-record.js';
|
|
2
2
|
import { compare } from './compare.js';
|
|
3
|
+
const COMPONENT = /^#\/components\/schemas\/(.+)$/;
|
|
3
4
|
/**
|
|
4
5
|
* Local definitions (`$defs`) of the embedded JSON Schemas are moved to `components.schemas`,
|
|
5
|
-
* because a `#/$defs/...` pointer means nothing once the schema sits inside a document.
|
|
6
|
+
* because a `#/$defs/...` pointer means nothing once the schema sits inside a document. A shared
|
|
7
|
+
* schema (`sharedSchema`, a class schema with `shared`, a zod schema with `.meta({ id })`) is a
|
|
8
|
+
* reference to one of its definitions: it lands once among the components and every route that
|
|
9
|
+
* uses it points at it.
|
|
6
10
|
*/
|
|
7
11
|
export class Definitions {
|
|
8
12
|
schemas = new Map();
|
|
@@ -24,6 +28,13 @@ export class Definitions {
|
|
|
24
28
|
all() {
|
|
25
29
|
return Object.fromEntries(this.schemas);
|
|
26
30
|
}
|
|
31
|
+
/** The schema itself when it is a reference to a component: the parameters of a request part are its properties. */
|
|
32
|
+
resolve(schema) {
|
|
33
|
+
const reference = schema['$ref'];
|
|
34
|
+
const component = typeof reference === 'string' ? COMPONENT.exec(reference)?.[1] : undefined;
|
|
35
|
+
const target = component === undefined ? undefined : this.schemas.get(component);
|
|
36
|
+
return target === undefined ? schema : this.resolve(target);
|
|
37
|
+
}
|
|
27
38
|
/** Two different definitions sharing a name get distinct component names. */
|
|
28
39
|
reserve(name, source) {
|
|
29
40
|
for (let attempt = 1;; attempt += 1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/openapi/definitions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/openapi/definitions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,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,CAAC,CAAC,CAAC,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -4,7 +4,7 @@ export function schemaParameters(location, schema, definitions) {
|
|
|
4
4
|
if (schema === undefined) {
|
|
5
5
|
return [];
|
|
6
6
|
}
|
|
7
|
-
const embedded = definitions.embed(schema);
|
|
7
|
+
const embedded = definitions.resolve(definitions.embed(schema));
|
|
8
8
|
const properties = embedded['properties'];
|
|
9
9
|
if (!isRecord(properties)) {
|
|
10
10
|
return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-parameters.js","sourceRoot":"","sources":["../../src/openapi/schema-parameters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGnD,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAC9B,QAAqC,EACrC,MAAmC,EACnC,WAAwB;IAExB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"schema-parameters.js","sourceRoot":"","sources":["../../src/openapi/schema-parameters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGnD,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAC9B,QAAqC,EACrC,MAAmC,EACnC,WAAwB;IAExB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IAE1C,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEjF,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE;QACzD,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE7E,OAAO;YACL,IAAI;YACJ,EAAE,EAAE,QAAQ;YACZ,GAAG,CAAC,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3D,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;YACjC,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -3,7 +3,8 @@ import type { PageBody } from './page-body.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* The schema of a page of items, from the schema of one item: validates the envelope and each
|
|
5
5
|
* item, and describes both in the contract. Local `$defs` of the item schema move to the top,
|
|
6
|
-
* where the OpenAPI generator collects them.
|
|
6
|
+
* where the OpenAPI generator collects them. The page of a shared item is shared too, as
|
|
7
|
+
* `<Item>Page`: every search that answers pages of it points at one component.
|
|
7
8
|
*/
|
|
8
9
|
export declare function pageSchemaOf<T>(item: Schema<T>): Schema<PageBody<T>>;
|
|
9
10
|
//# sourceMappingURL=page-schema-of.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-schema-of.d.ts","sourceRoot":"","sources":["../../src/pagination/page-schema-of.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"page-schema-of.d.ts","sourceRoot":"","sources":["../../src/pagination/page-schema-of.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,MAAM,EAEZ,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAMpE"}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { err, ok } from '@ddd-ts-kit/kernel';
|
|
2
|
-
import { customSchema } from '@ddd-ts-kit/validation';
|
|
2
|
+
import { customSchema, sharedNameOf, sharedSchema, } from '@ddd-ts-kit/validation';
|
|
3
3
|
import { isRecord } from '../support/is-record.js';
|
|
4
4
|
import { issue } from './issue.js';
|
|
5
5
|
/**
|
|
6
6
|
* The schema of a page of items, from the schema of one item: validates the envelope and each
|
|
7
7
|
* item, and describes both in the contract. Local `$defs` of the item schema move to the top,
|
|
8
|
-
* where the OpenAPI generator collects them.
|
|
8
|
+
* where the OpenAPI generator collects them. The page of a shared item is shared too, as
|
|
9
|
+
* `<Item>Page`: every search that answers pages of it points at one component.
|
|
9
10
|
*/
|
|
10
11
|
export function pageSchemaOf(item) {
|
|
11
|
-
|
|
12
|
+
const itemJsonSchema = item.toJsonSchema();
|
|
13
|
+
const page = customSchema((input) => parsePageBody(input, item), pageJsonSchema(itemJsonSchema));
|
|
14
|
+
const shared = sharedNameOf(itemJsonSchema);
|
|
15
|
+
return shared === undefined ? page : sharedSchema(`${shared}Page`, page);
|
|
12
16
|
}
|
|
13
17
|
function parsePageBody(input, item) {
|
|
14
18
|
if (!isRecord(input) || !Array.isArray(input['items'])) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-schema-of.js","sourceRoot":"","sources":["../../src/pagination/page-schema-of.ts"],"names":[],"mappings":"AAAA,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C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Schema } from '@ddd-ts-kit/validation';
|
|
2
|
+
import type { Accepted } from './accepted.js';
|
|
3
|
+
/**
|
|
4
|
+
* The body every command route answers with, shared by the platform: one `Accepted` component in
|
|
5
|
+
* the contract, referenced by each route instead of a copy of `{ id }` per route.
|
|
6
|
+
*/
|
|
7
|
+
export declare const acceptedSchema: Schema<Accepted>;
|
|
8
|
+
//# sourceMappingURL=accepted-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accepted-schema.d.ts","sourceRoot":"","sources":["../../src/schemas/accepted-schema.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,MAAM,EAAwB,MAAM,wBAAwB,CAAC;AAEvG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,QAAQ,CAQ3C,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { err, ok } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { customSchema, sharedSchema } from '@ddd-ts-kit/validation';
|
|
3
|
+
import { isRecord } from '../support/is-record.js';
|
|
4
|
+
/**
|
|
5
|
+
* The body every command route answers with, shared by the platform: one `Accepted` component in
|
|
6
|
+
* the contract, referenced by each route instead of a copy of `{ id }` per route.
|
|
7
|
+
*/
|
|
8
|
+
export const acceptedSchema = sharedSchema('Accepted', customSchema(parseAccepted, {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['id'],
|
|
11
|
+
properties: { id: { type: 'string', description: 'The identifier of what the command created or changed.' } },
|
|
12
|
+
additionalProperties: false,
|
|
13
|
+
}));
|
|
14
|
+
function parseAccepted(input) {
|
|
15
|
+
if (isRecord(input) && typeof input['id'] === 'string') {
|
|
16
|
+
return ok({ id: input['id'] });
|
|
17
|
+
}
|
|
18
|
+
return err([{ path: 'id', code: 'invalid_type', message: 'An identifier is expected.' }]);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=accepted-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accepted-schema.js","sourceRoot":"","sources":["../../src/schemas/accepted-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAqC,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGnD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAqB,YAAY,CAC1D,UAAU,EACV,YAAY,CAAC,aAAa,EAAE;IAC1B,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,IAAI,CAAC;IAChB,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,wDAAwD,EAAE,EAAE;IAC7G,oBAAoB,EAAE,KAAK;CAC5B,CAAC,CACH,CAAC;AAEF,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;QACvD,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accepted.d.ts","sourceRoot":"","sources":["../../src/schemas/accepted.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accepted.js","sourceRoot":"","sources":["../../src/schemas/accepted.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts-kit/http",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Framework-agnostic route definitions with Express, Fastify and NestJS adapters and OpenAPI 3.1 generation.",
|
|
3
|
+
"version": "0.13.0",
|
|
4
|
+
"description": "Framework-agnostic route definitions with Express, Fastify, Hono and NestJS adapters and OpenAPI 3.1 generation.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
"types": "./dist/fastify.d.ts",
|
|
30
30
|
"default": "./dist/fastify.js"
|
|
31
31
|
},
|
|
32
|
+
"./hono": {
|
|
33
|
+
"types": "./dist/hono.d.ts",
|
|
34
|
+
"default": "./dist/hono.js"
|
|
35
|
+
},
|
|
32
36
|
"./nest": {
|
|
33
37
|
"types": "./dist/nest.d.ts",
|
|
34
38
|
"default": "./dist/nest.js"
|
|
@@ -54,14 +58,15 @@
|
|
|
54
58
|
"dist"
|
|
55
59
|
],
|
|
56
60
|
"dependencies": {
|
|
57
|
-
"@ddd-ts-kit/kernel": "0.
|
|
58
|
-
"@ddd-ts-kit/validation": "0.
|
|
61
|
+
"@ddd-ts-kit/kernel": "0.13.0",
|
|
62
|
+
"@ddd-ts-kit/validation": "0.13.0"
|
|
59
63
|
},
|
|
60
64
|
"peerDependencies": {
|
|
61
65
|
"@nestjs/common": ">=11.0.0",
|
|
62
66
|
"@nestjs/core": ">=11.0.0",
|
|
63
67
|
"express": "^5.0.0",
|
|
64
68
|
"fastify": "^5.0.0",
|
|
69
|
+
"hono": "^4.0.0",
|
|
65
70
|
"busboy": "^1.6.0"
|
|
66
71
|
},
|
|
67
72
|
"peerDependenciesMeta": {
|
|
@@ -77,12 +82,16 @@
|
|
|
77
82
|
"@nestjs/core": {
|
|
78
83
|
"optional": true
|
|
79
84
|
},
|
|
85
|
+
"hono": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
80
88
|
"busboy": {
|
|
81
89
|
"optional": true
|
|
82
90
|
}
|
|
83
91
|
},
|
|
84
92
|
"devDependencies": {
|
|
85
|
-
"@ddd-ts-kit/testing": "0.
|
|
93
|
+
"@ddd-ts-kit/testing": "0.13.0",
|
|
94
|
+
"@hono/node-server": "^2.1.4",
|
|
86
95
|
"@nestjs/common": "^12.1.2",
|
|
87
96
|
"@nestjs/core": "^12.1.2",
|
|
88
97
|
"@nestjs/platform-express": "^12.1.2",
|
|
@@ -92,6 +101,7 @@
|
|
|
92
101
|
"busboy": "^1.6.0",
|
|
93
102
|
"express": "^5.3.0",
|
|
94
103
|
"fastify": "^5.12.5",
|
|
104
|
+
"hono": "^4.13.13",
|
|
95
105
|
"reflect-metadata": "^0.2.2",
|
|
96
106
|
"rxjs": "^7.8.0",
|
|
97
107
|
"zod": "^4.6.5"
|