@alxia/core 0.1.0 → 0.2.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 (59) hide show
  1. package/README.md +103 -3
  2. package/dist/app/alxia.d.ts +53 -5
  3. package/dist/app/alxia.d.ts.map +1 -1
  4. package/dist/app/chain.d.ts +5 -8
  5. package/dist/app/chain.d.ts.map +1 -1
  6. package/dist/app/context.d.ts +12 -0
  7. package/dist/app/context.d.ts.map +1 -0
  8. package/dist/app/definition.d.ts +22 -1
  9. package/dist/app/definition.d.ts.map +1 -1
  10. package/dist/app/refusal.d.ts +15 -0
  11. package/dist/app/refusal.d.ts.map +1 -0
  12. package/dist/app/send.d.ts +8 -1
  13. package/dist/app/send.d.ts.map +1 -1
  14. package/dist/app/socket.d.ts +1 -1
  15. package/dist/app/socket.d.ts.map +1 -1
  16. package/dist/app/types/index.d.ts +1 -0
  17. package/dist/app/types/index.d.ts.map +1 -1
  18. package/dist/app/types/refusal.d.ts +94 -0
  19. package/dist/app/types/refusal.d.ts.map +1 -0
  20. package/dist/app/types/route-table.d.ts +3 -2
  21. package/dist/app/types/route-table.d.ts.map +1 -1
  22. package/dist/app/types/schema.d.ts +7 -0
  23. package/dist/app/types/schema.d.ts.map +1 -1
  24. package/dist/app/types/valid-schema.d.ts +1 -1
  25. package/dist/app/types/valid-schema.d.ts.map +1 -1
  26. package/dist/errors/errors.d.ts +47 -1
  27. package/dist/errors/errors.d.ts.map +1 -1
  28. package/dist/index.d.ts +5 -3
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +395 -97
  31. package/dist/index.js.map +20 -13
  32. package/dist/reply/problem.d.ts +33 -0
  33. package/dist/reply/problem.d.ts.map +1 -0
  34. package/dist/reply/reply.d.ts.map +1 -1
  35. package/dist/request/limit.d.ts +13 -0
  36. package/dist/request/limit.d.ts.map +1 -0
  37. package/dist/request/read.d.ts +3 -2
  38. package/dist/request/read.d.ts.map +1 -1
  39. package/dist/sse/async-iterable.d.ts +6 -0
  40. package/dist/sse/async-iterable.d.ts.map +1 -0
  41. package/dist/sse/event-stream.d.ts +29 -6
  42. package/dist/sse/event-stream.d.ts.map +1 -1
  43. package/dist/sse/frame.d.ts +35 -0
  44. package/dist/sse/frame.d.ts.map +1 -0
  45. package/dist/sse/named-events.d.ts +70 -0
  46. package/dist/sse/named-events.d.ts.map +1 -0
  47. package/docs/README.md +3 -3
  48. package/docs/guide/groups-and-plugins.md +8 -1
  49. package/docs/guide/hooks.md +128 -3
  50. package/docs/guide/replies.md +40 -0
  51. package/docs/guide/routes.md +115 -1
  52. package/docs/guide/server-sent-events.md +177 -5
  53. package/docs/guide/serving.md +1 -1
  54. package/docs/guide/types.md +3 -1
  55. package/docs/guide/websockets.md +1 -1
  56. package/docs/guide/writing-a-plugin.md +1 -1
  57. package/docs/roadmap.md +35 -2
  58. package/docs/troubleshooting.md +303 -6
  59. package/package.json +1 -1
package/README.md CHANGED
@@ -88,6 +88,40 @@ whatever part it is in:
88
88
  { "error": "validation", "issues": [{ "target": "params", "path": ["id"], "code": "invalid_type", "message": "…" }] }
89
89
  ```
90
90
 
91
+ `onRefusal(hook)` answers it in your format instead, for the routes declared
92
+ after it: the hook reads the refusal's `kind` — for a `validation`, the
93
+ `part` that failed and the `issues` — and returns a reply with a 4xx
94
+ status, or nothing, for the default.
95
+ `problem(details)` builds an RFC 9457 problem, sent as
96
+ `application/problem+json`, its extension members typed:
97
+
98
+ ```ts
99
+ import { alxia, problem } from '@alxia/core';
100
+ import { z } from 'zod';
101
+
102
+ const JmapRequest = z.object({ using: z.array(z.string()), methodCalls: z.array(z.unknown()) });
103
+
104
+ const app = alxia()
105
+ .onRefusal((refusal) =>
106
+ refusal.kind === 'body_limit'
107
+ ? problem({ type: 'urn:ietf:params:jmap:error:limit', status: 413, limit: 'maxSizeRequest' })
108
+ : problem({
109
+ type: refusal.issues.some((issue) => issue.code === 'invalid_json')
110
+ ? 'urn:ietf:params:jmap:error:notJSON'
111
+ : 'urn:ietf:params:jmap:error:notRequest',
112
+ status: 400,
113
+ detail: `the ${refusal.part} is invalid`,
114
+ }),
115
+ )
116
+ .post('/jmap', { body: JmapRequest }, ({ reply }) => reply(200, { methodResponses: [] }));
117
+ ```
118
+
119
+ Its reply replaces the 400 in the type of every route after it that
120
+ validates, so the client reads the problem. Given schemas first —
121
+ `onRefusal({ response: { 400: Problem }, contentType: 'application/problem+json' }, hook)`
122
+ — its `reply` is typed by them, its body checked and sent as their output,
123
+ and `@alxia/openapi` documents it.
124
+
91
125
  `ip` is the client's address — the `ip` option reads it behind a proxy —
92
126
  and `server` the Bun server, when there is one. `HEAD` runs the `GET` route.
93
127
 
@@ -119,6 +153,39 @@ const getUser = {
119
153
  app.route(getUser, async ({ params, reply }) => reply.ok(await findUser(params.id)));
120
154
  ```
121
155
 
156
+ ### Body size
157
+
158
+ `bodyLimit`, in bytes, caps a route's request body below the server's
159
+ `maxRequestBodySize`. Set it on a route, or call `bodyLimit(bytes)` for
160
+ every route declared after the call: on the app, for every later route; in a
161
+ group, for the group's routes alone. A route's own limit wins.
162
+
163
+ ```ts
164
+ const app = alxia()
165
+ .bodyLimit(64 * 1024)
166
+ .post('/notes', { body: z.object({ text: z.string() }) }, ({ body, reply }) => reply.created(body))
167
+ .post('/upload', { bodyLimit: 25 * 1024 * 1024 }, async ({ request, reply }) => {
168
+ await Bun.write('upload.bin', new Response(request.body));
169
+ return reply.noContent();
170
+ });
171
+ ```
172
+
173
+ A `Content-Length` over the limit is refused without reading the body.
174
+ Without one, the bytes are counted as they arrive, and reading stops once
175
+ they pass the limit, so a chunked upload is never buffered whole. The
176
+ limit applies to JSON, forms, text, an app's own parsers, and a handler
177
+ reading `request.body` as a stream. Either way the answer is a 413, which
178
+ the route's type and its OpenAPI document include:
179
+
180
+ ```json
181
+ { "error": "content_too_large", "limit": 65536 }
182
+ ```
183
+
184
+ It is a refusal, as a 400 is: the `onRefusal` hook above reads it as `{ kind: 'body_limit', limit }` and may answer it in its
185
+ own format, JMAP's `limit` problem there, sent with 413 by that app's
186
+ choice. A route with no limit reads its
187
+ body as before.
188
+
122
189
  ## Replies
123
190
 
124
191
  A handler returns `reply(status, body, init?)`. With `response` schemas,
@@ -219,6 +286,27 @@ Each value is checked by the event's schema and sent as one `data:` line of
219
286
  JSON; a comment keeps an idle stream open, and the generator is closed when
220
287
  the client leaves. The client reads `data` as an `AsyncIterable` of events.
221
288
 
289
+ Name the events, each with its schema, and each is sent with its `event:`
290
+ line, plus `id:` and `retry:` when given:
291
+
292
+ ```ts
293
+ const Push = eventStream({ state: StateChange, ping: Ping });
294
+
295
+ app.get('/push', { response: { 200: Push } }, ({ reply }) =>
296
+ reply(200, (async function* () {
297
+ yield Push.event('ping', { interval: 30 });
298
+ yield Push.event('state', change, { id: 's42' });
299
+ })()),
300
+ );
301
+ // event: ping
302
+ // data: {"interval":30}
303
+ ```
304
+
305
+ `Push.event(name, data, fields?)` types each by its name's schema. The
306
+ client reads `{ event, data, id? }`, a union discriminated by `event`. A
307
+ line break in an `id`, or a `retry` that is not a whole number, ends the
308
+ stream before it is written.
309
+
222
310
  ## WebSockets
223
311
 
224
312
  ```ts
@@ -267,7 +355,10 @@ response, which the hook returns — or a reply of its own, typed like a
267
355
  Hooks run before validation: `pathParams` holds the path's parameters as
268
356
  they arrived. `onError` turns a thrown
269
357
  error into a reply the same way; an `HttpError` is answered as it says, and
270
- anything else is a 500 that leaks nothing.
358
+ anything else is a 500 that leaks nothing. `onRefusal` answers a request
359
+ the route's schemas refuse, or whose body passes its `bodyLimit`
360
+ ([Requests](#requests)); the last one declared
361
+ before a route is the one it uses.
271
362
 
272
363
  Global hooks apply to the whole app, wherever they are declared:
273
364
 
@@ -350,12 +441,16 @@ covers all three kinds.
350
441
  | export | |
351
442
  | --- | --- |
352
443
  | `alxia(options?)`, `AlxiaOptions` | a new app: `prefix`, `validateResponses`, `ip` |
353
- | `Alxia` | `get` `post` `put` `patch` `delete` `options` `head` `query` `route` `ws`, `static` `file` `page`, `decorate` `derive` `wrap` `onError`, `around` `onRequest` `onResponse` `onStart` `onStop` `parser`, `group` `use`, `fetch` `websocket` `request` `listen` `stop`, `routes` `sockets` `server` |
444
+ | `Alxia` | `get` `post` `put` `patch` `delete` `options` `head` `query` `route` `ws`, `static` `file` `page`, `decorate` `derive` `wrap` `onError` `onRefusal` `bodyLimit`, `around` `onRequest` `onResponse` `onStart` `onStop` `parser`, `group` `use`, `fetch` `websocket` `request` `listen` `stop`, `routes` `sockets` `server` |
354
445
  | `eventStream(schema)`, `EventStreamSchema` | the response schema of a stream of events |
355
- | `isEventStreamSchema(schema)` | whether a schema is one `eventStream` made |
446
+ | `isEventStreamSchema(schema)` | whether a schema is one `eventStream(schema)` made |
447
+ | `eventStream({ name: schema })`, `NamedEventStreamSchema`, `EventSchemas` | the response schema of a stream of named events, its `event(name, data, fields?)` builder, its schemas by name under `~events` |
448
+ | `EventInput<Of>`, `EventOutput<Of>`, `EventFields` | what a handler yields on a named stream, what the client reads of it, and an event's `id` and `retry` |
449
+ | `isNamedEventStreamSchema(schema)` | whether a schema is one `eventStream({ … })` made |
356
450
  | `FileSource`, `StaticOptions`, `FileOptions`, `StaticReply`, `parseRange` | static files |
357
451
  | `Precompressed`, `FileNotFoundBody`, `RangeNotSatisfiableBody` | a coding stored beside a file, the bodies of the 404 and 416 |
358
452
  | `Reply`, `HttpError`, `ResponseValidationError` | what a handler returns or throws |
453
+ | `ContentTooLargeError`, `ContentTooLargeBody` | what reading a body past its route's `bodyLimit` throws — answered as a `body_limit` refusal — and the body of its default 413: `{ error: 'content_too_large', limit }` |
359
454
  | `ReplyInit` | a reply's options: `headers` |
360
455
  | `AnyReply`, `FreeReplyFunction`, `TypedReplyFunction`, `DeclaredReply`, `RedirectFunction` | any reply, `reply` without and with schemas, every reply a route with schemas may return, `redirect` |
361
456
  | `FreeShortcuts`, `TypedShortcuts`, `SHORTCUTS`, `Shortcuts` | `reply`'s shortcuts without and with schemas, and the status of each |
@@ -379,6 +474,11 @@ covers all three kinds.
379
474
  | `StandardSchemaV1`, `StandardResult`, `StandardIssue`, `InferInput`, `InferOutput` | the Standard Schema types |
380
475
  | `ValidationErrorBody`, `InternalErrorBody`, `RoutingErrorBody` | the bodies of the 400, 500, 404, 405 and 426 |
381
476
  | `ValidationIssue`, `ValidationTarget` | one issue of a 400, and where the refused value was read from |
477
+ | `Refusal`, `ValidationRefusal`, `BodyLimitRefusal`, `RequestPart` | what an `onRefusal` hook reads: the refusal by `kind` — `validation`, with the `part` that failed first and its `issues`, or `body_limit`, with the route's `limit` |
478
+ | `RefusalSchema`, `RefusalResponses` | what an `onRefusal` hook may declare: the schema of each 4xx it answers, and its `contentType` |
479
+ | `RefusalHook`, `RefusalHandler` | an `onRefusal` hook, and the one in force for a route: `RouteDefinition['refusal']`, what `@alxia/openapi` documents |
480
+ | `Refusing`, `FallsBack`, `DefaultRefusalOutcome`, `DefaultLimitOutcome`, `RefusalOutcome`, `ThenShortcuts`, `BehindShortcuts`, `BodyLimited`, `BodyLimitShortcut`, `IsLimited` | how an app's type carries its `onRefusal` hook and its `bodyLimit()`: the mark of the hook's replies, of the default it falls back to, the default 400 and 413 a plugin's route keeps, how a later scope's and a using app's hooks replace them, the mark of a `bodyLimit()` in force and the shortcut it adds, and whether a route is under a limit. Exported so an app's type can be named in a declaration file |
481
+ | `problem(details, init?)`, `ProblemDetails` | a reply whose body is an RFC 9457 problem — `type`, `title`, `status`, `detail`, `instance` and typed extension members — sent with its `status` as `application/problem+json` |
382
482
  | `RoutePath`, `JoinPath`, `PathParams`, `PathParamName` | paths: an absolute path, a prefix joined to a path, the parameters a path declares |
383
483
  | `StatusCode`, `InformationalStatus`, `SuccessStatus`, `RedirectStatus`, `ClientErrorStatus`, `ServerErrorStatus` | every status a route may declare, and each class of them |
384
484
  | `Method`, `Empty`, `MaybePromise`, `Simplify` | an HTTP method, no properties, a value or its promise, an object type with its intersections flattened |
@@ -1,12 +1,14 @@
1
- import type { AnyReply } from '../reply/reply';
1
+ import type { Refusal } from '../errors/errors';
2
+ import type { AnyReply, Reply } from '../reply/reply';
2
3
  import type { BodyParser } from '../request/read';
3
4
  import type { FileOptions, FileSource, StaticOptions, StaticReply } from '../static/types';
4
5
  import type { JoinPath, RoutePath } from '../types/path';
6
+ import type { ClientErrorStatus } from '../types/status';
5
7
  import type { SocketContext, SocketEntryOf, SocketHandlers, SocketMessage, SocketSchema, SocketSend } from '../ws/types';
6
8
  import type { AroundHook, RequestHook, ResponseHook, RouteDefinition, SocketDefinition, StartHook, StopHook } from './definition';
7
9
  import type { OperationMethod } from './route-operation';
8
10
  import { type SocketData } from './socket';
9
- import type { BaseContext, Context, Empty, HandlerResult, MaybePromise, Method, Outcome, OutcomeOf, ProvidedBy, RouteEntryOf, RouteRecord, RouteSchema, ValidSchema } from './types';
11
+ import type { BaseContext, BehindShortcuts, BodyLimitShortcut, Context, DeclaredRefusal, DeclaredReply, Empty, HandlerResult, MaybePromise, Method, Outcome, ProvidedBy, RefusalResponses, RefusalSchema, RefusalsOf, Refusing, RouteEntryOf, RouteRecord, RouteSchema, ThenShortcuts, TypedReplyFunction, ValidSchema } from './types';
10
12
  /** The route a static directory is served at: its path, then a wildcard. */
11
13
  type StaticPath<Path extends string> = Path extends '/' ? '/*' : `${Path}/*`;
12
14
  export interface AlxiaOptions<Prefix extends string> {
@@ -41,7 +43,7 @@ export interface RouteMethod<M extends Method, Ctx extends object, Routes extend
41
43
  /** The routes of a plugin, under the prefix of the app it is used by. */
42
44
  type Prefixed<Prefix extends string, Routes, Shortcuts> = {
43
45
  readonly [Path in keyof Routes as Path extends string ? JoinPath<Prefix, Path> : never]: {
44
- readonly [M in keyof Routes[Path]]: Routes[Path][M] extends RouteRecord<infer Input, infer Output> ? RouteRecord<Input, Output | OutcomeOf<Shortcuts>> : Routes[Path][M];
46
+ readonly [M in keyof Routes[Path]]: Routes[Path][M] extends RouteRecord<infer Input, infer Output> ? RouteRecord<Input, BehindShortcuts<Output, Shortcuts>> : Routes[Path][M];
45
47
  };
46
48
  };
47
49
  /** Any app, whatever it holds. */
@@ -65,7 +67,7 @@ export type Plugin = <App extends AnyAlxia>(app: App) => App;
65
67
  * export type App = typeof app;
66
68
  * ```
67
69
  *
68
- * A route hook (`derive`, `decorate`, `onError`) applies to the routes
70
+ * A route hook (`derive`, `decorate`, `onError`, `onRefusal`) applies to the routes
69
71
  * declared after it, never before: the order of the chain is the order of
70
72
  * the request. A global hook (`onRequest`, `onResponse`, `onStart`,
71
73
  * `onStop`, `parser`) applies to the whole app, wherever it is declared.
@@ -168,12 +170,58 @@ export declare class Alxia<Ctx extends object = Empty, Routes extends object = E
168
170
  * ```
169
171
  */
170
172
  wrap<Result extends AnyReply | Response>(hook: (ctx: BaseContext & Ctx, next: () => Promise<Response>) => MaybePromise<Result>): Alxia<Ctx, Routes, Prefix, Shortcuts | Extract<Result, AnyReply>>;
173
+ /**
174
+ * The most bytes the request body of every route declared after it may
175
+ * hold, unless the route's own `bodyLimit` says otherwise. Inside a
176
+ * group, only the group's routes. A body past it is refused with a 413
177
+ * as soon as its `Content-Length` or the bytes counted pass the limit,
178
+ * which is added to the type of every such route.
179
+ *
180
+ * ```ts
181
+ * alxia()
182
+ * .bodyLimit(64 * 1024) // every route below: 64 KiB
183
+ * .post('/notes', { body: Note }, handler)
184
+ * .post('/upload', { bodyLimit: 25 * 1024 * 1024 }, handler); // its own
185
+ * ```
186
+ */
187
+ bodyLimit(bytes: number): Alxia<Ctx, Routes, Prefix, Shortcuts | BodyLimitShortcut>;
171
188
  /**
172
189
  * A hook that turns an error thrown by a route declared after it into a
173
190
  * reply. Returning nothing lets the next one try; past the last, an
174
191
  * `HttpError` is answered as it says and anything else as a 500.
175
192
  */
176
193
  onError<Result extends AnyReply | undefined | void>(hook: (error: unknown, ctx: BaseContext & Partial<Ctx>) => MaybePromise<Result>): Alxia<Ctx, Routes, Prefix, Shortcuts | Extract<Result, AnyReply>>;
194
+ /**
195
+ * A hook that answers a request a route declared after it refuses
196
+ * before its handler runs: one its schemas refuse, the default of which
197
+ * is `400 { error: 'validation', issues }`, or one whose body passes its
198
+ * `bodyLimit`, the default of which is
199
+ * `413 { error: 'content_too_large', limit }`. The hook reads
200
+ * the refusal — its `kind`: `validation`, with the `part` that failed
201
+ * and the `issues`, or `body_limit`, with the route's `limit` — and
202
+ * returns a reply with a 4xx status, or nothing for that kind's default.
203
+ * The last one declared before a route is the one in force; a group's
204
+ * stays inside it. Its reply replaces the default 400 in the type of
205
+ * every such route that validates, so the client reads it:
206
+ *
207
+ * ```ts
208
+ * .onRefusal((refusal) => refusal.kind === 'validation'
209
+ * ? problem({ type: 'urn:example:invalid', status: 400, detail: `the ${refusal.part} is invalid` })
210
+ * : problem({ type: 'urn:example:limit', status: 413, limit: refusal.limit }))
211
+ * ```
212
+ *
213
+ * Given schemas first, its `reply` is typed by them, its reply is
214
+ * checked and sent as their output, and `@alxia/openapi` documents it:
215
+ *
216
+ * ```ts
217
+ * .onRefusal({ response: { 400: Problem }, contentType: 'application/problem+json' },
218
+ * (refusal, { reply }) => reply(400, { type: 'urn:example:invalid', status: 400, detail: refusal.kind }))
219
+ * ```
220
+ */
221
+ onRefusal<Result extends Reply<ClientErrorStatus, any> | undefined | void>(hook: (refusal: Refusal, ctx: BaseContext & Ctx) => MaybePromise<Result>): Alxia<Ctx, Routes, Prefix, Exclude<Shortcuts, Refusing> | RefusalsOf<Extract<Result, AnyReply>, Result>>;
222
+ onRefusal<Responses extends RefusalResponses, Result extends DeclaredReply<Responses> | undefined | void>(schema: RefusalSchema<Responses>, hook: (refusal: Refusal, ctx: Omit<BaseContext, 'reply'> & Ctx & {
223
+ readonly reply: TypedReplyFunction<Responses>;
224
+ }) => MaybePromise<Result>): Alxia<Ctx, Routes, Prefix, Exclude<Shortcuts, Refusing> | RefusalsOf<DeclaredRefusal<Responses>, Result>>;
177
225
  /**
178
226
  * A global hook run on every request, before routing: a 404 included. A
179
227
  * `Response` it returns is sent as it is, and is no part of any route's
@@ -237,7 +285,7 @@ export declare class Alxia<Ctx extends object = Empty, Routes extends object = E
237
285
  use<Result extends AnyAlxia>(plugin: (app: this) => Result): Result;
238
286
  use<PluginCtx extends object, PluginRoutes extends object, PluginPrefix extends string, PluginShortcuts extends AnyReply, PluginRequires = Empty>(plugin: Alxia<PluginCtx, PluginRoutes, PluginPrefix, PluginShortcuts> & {
239
287
  readonly '~requires'?: PluginRequires;
240
- } & ProvidedBy<Ctx, PluginRequires>): Alxia<Ctx & PluginCtx, Routes & Prefixed<Prefix, PluginRoutes, Shortcuts>, Prefix, Shortcuts | PluginShortcuts>;
288
+ } & ProvidedBy<Ctx, PluginRequires>): Alxia<Ctx & PluginCtx, Routes & Prefixed<Prefix, PluginRoutes, Shortcuts>, Prefix, ThenShortcuts<Shortcuts, PluginShortcuts>>;
241
289
  /** Every route, in the order declared: what `@alxia/openapi` documents. */
242
290
  get routes(): readonly RouteDefinition[];
243
291
  /** Every socket route, in the order declared. */
@@ -1 +1 @@
1
- {"version":3,"file":"alxia.d.ts","sourceRoot":"","sources":["../../src/app/alxia.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,OAAO,KAAK,EACX,WAAW,EACX,UAAU,EACV,aAAa,EACb,WAAW,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACZ,UAAU,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACX,UAAU,EAIV,WAAW,EACX,YAAY,EACZ,eAAe,EAEf,gBAAgB,EAChB,SAAS,EACT,QAAQ,EAER,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAC;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O,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI5D;;;;;;;;;;OAUG;IACH,MAAM,CAAC,OAAO,GAAE,aAAa,GAAG,MAAW,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC;IA+BjE,wEAAwE;IAClE,IAAI,CAAC,sBAAsB,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAqEzD;AAED,iBAAiB;AACjB,wBAAgB,KAAK,CAAC,KAAK,CAAC,MAAM,SAAS,EAAE,GAAG,SAAS,GAAG,EAAE,EAC7D,OAAO,GAAE,YAAY,CAAC,MAAM,CAAM,GAChC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAEpC;AAED,yDAAyD;AACzD,MAAM,MAAM,QAAQ,CAAC,GAAG,IAAI,GAAG,SAAS;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,MAAM,CAAA;CAAE,GACzE,MAAM,GACN,KAAK,CAAC;AAET;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,CAAA;CAAE,GACxE,WAAW,GAAG,GAAG,GACjB,KAAK,CAAC;AAET,YAAY,EAAE,OAAO,EAAE,CAAC"}
@@ -1,23 +1,20 @@
1
1
  import { type BodyParser } from '../request/read';
2
2
  import type { RouteDefinition, SocketDefinition } from './definition';
3
3
  import type { BaseContext, RequestContext, ResponseSettings } from './types';
4
- /** The context a route's hooks and handler read, and what they set on its response. */
5
- export declare function routeContext(definition: RouteDefinition | SocketDefinition, request: RequestContext, pathParams: Record<string, string>): {
6
- ctx: Record<string, unknown> & BaseContext;
7
- set: ResponseSettings;
8
- };
9
4
  /**
10
5
  * Runs the hooks of a route in order — a `derive` adds to the context or
11
6
  * ends the request, a `wrap` runs the rest inside it — then validates the
12
7
  * request, then `last`. A socket's upgrade skips the `wrap` hooks: it has
13
8
  * no response to wrap.
14
9
  */
15
- export declare function chain<Last>(definition: RouteDefinition | SocketDefinition, request: RequestContext, rawParams: Record<string, string>, set: ResponseSettings, ctx: Record<string, unknown> & BaseContext, parsers: readonly BodyParser[], last: () => Promise<Response | Last>): Promise<Response | Last>;
10
+ export declare function chain<Last>(definition: RouteDefinition | SocketDefinition, request: RequestContext, rawParams: Record<string, string>, set: ResponseSettings, ctx: Record<string, unknown> & BaseContext, parsers: readonly BodyParser[], validateResponses: boolean, last: () => Promise<Response | Last>): Promise<Response | Last>;
16
11
  /** A route's request, from its hooks to its handler's reply, sent. */
17
12
  export declare function handle(route: RouteDefinition, request: RequestContext, rawParams: Record<string, string>, parsers: readonly BodyParser[], validateResponses: boolean): Promise<Response>;
18
13
  /**
19
14
  * An error a route threw, answered by its `onError` hooks in order; past
20
- * the last, an `HttpError` as it says and anything else as a 500.
15
+ * the last, an `HttpError` as it says and anything else as a 500. A body
16
+ * past the route's `bodyLimit` is a refusal instead, answered as
17
+ * `refuse` answers one: by the `onRefusal` hook in force, or its 413.
21
18
  */
22
- export declare function fail(definition: RouteDefinition | SocketDefinition, error: unknown, ctx: BaseContext): Promise<Response>;
19
+ export declare function fail(definition: RouteDefinition | SocketDefinition, error: unknown, ctx: BaseContext, validateResponses?: boolean): Promise<Response>;
23
20
  //# sourceMappingURL=chain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../src/app/chain.ts"],"names":[],"mappings":"AAWA,OAAO,EACN,KAAK,UAAU,EAKf,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,KAAK,EACX,WAAW,EAEX,cAAc,EACd,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAOjB,uFAAuF;AACvF,wBAAgB,YAAY,CAC3B,UAAU,EAAE,eAAe,GAAG,gBAAgB,EAC9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,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE7E;;;;;GAKG;AACH,wBAAsB,KAAK,CAAC,IAAI,EAC/B,UAAU,EAAE,eAAe,GAAG,gBAAgB,EAC9C,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,EAC1C,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,iBAAiB,EAAE,OAAO,EAC1B,IAAI,EAAE,MAAM,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,GAClC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAiC1B;AA4DD,sEAAsE;AACtE,wBAAsB,MAAM,CAC3B,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,iBAAiB,EAAE,OAAO,GACxB,OAAO,CAAC,QAAQ,CAAC,CAiCnB;AAED;;;;;GAKG;AACH,wBAAsB,IAAI,CACzB,UAAU,EAAE,eAAe,GAAG,gBAAgB,EAC9C,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,WAAW,EAChB,iBAAiB,UAAO,GACtB,OAAO,CAAC,QAAQ,CAAC,CA0BnB"}
@@ -0,0 +1,12 @@
1
+ import type { RouteDefinition, SocketDefinition } from './definition';
2
+ import type { BaseContext, RequestContext, ResponseSettings } from './types';
3
+ /**
4
+ * The context a route's hooks and handler read, and what they set on its
5
+ * response. Under a `bodyLimit`, its `request` is the one whose body is
6
+ * bounded: every reader of the body, core's or the handler's, counts.
7
+ */
8
+ export declare function routeContext(definition: RouteDefinition | SocketDefinition, request: RequestContext, pathParams: Record<string, string>): {
9
+ ctx: Record<string, unknown> & BaseContext;
10
+ set: ResponseSettings;
11
+ };
12
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/app/context.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EACX,WAAW,EAEX,cAAc,EACd,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAOjB;;;;GAIG;AACH,wBAAgB,YAAY,CAC3B,UAAU,EAAE,eAAe,GAAG,gBAAgB,EAC9C,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC;IAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC;IAAC,GAAG,EAAE,gBAAgB,CAAA;CAAE,CAuBvE"}
@@ -2,11 +2,12 @@
2
2
  * An app as it runs: its hooks, and the definition of each route and socket
3
3
  * route it holds, with the hooks declared before it.
4
4
  */
5
+ import type { Refusal } from '../errors/errors';
5
6
  import type { AnyReply } from '../reply/reply';
6
7
  import type { BodyParser } from '../request/read';
7
8
  import type { Router } from '../router/router';
8
9
  import type { SocketHandlers, SocketSchema } from '../ws/types';
9
- import type { BaseContext, MaybePromise, Method, RequestContext, RouteSchema } from './types';
10
+ import type { BaseContext, MaybePromise, Method, RequestContext, ResponseSchemas, RouteSchema } from './types';
10
11
  /** A hook that runs before validation, and may add to the context or end the request. */
11
12
  export type DeriveHook = (ctx: Record<string, unknown>) => unknown;
12
13
  /** A hook around the rest of a route: the hooks after it, validation, the handler. */
@@ -21,6 +22,16 @@ export type ChainHook = {
21
22
  };
22
23
  /** A hook that turns an error into a reply, or lets the next one try. */
23
24
  export type ErrorHook = (error: unknown, ctx: BaseContext) => MaybePromise<AnyReply | undefined | void>;
25
+ /** A hook that answers a request the app refused: a reply, or nothing for the default. */
26
+ export type RefusalHook = (refusal: Refusal, ctx: BaseContext) => MaybePromise<AnyReply | undefined | void>;
27
+ /** The `onRefusal` hook in force for a route, and the schemas it declares. */
28
+ export interface RefusalHandler {
29
+ readonly hook: RefusalHook;
30
+ /** The schema of each status the hook may answer: its reply is checked by it, and documented. */
31
+ readonly response?: ResponseSchemas;
32
+ /** The `content-type` of its reply, unless the reply sets one; documented too. */
33
+ readonly contentType?: string;
34
+ }
24
35
  /** Runs on every request, before routing; a `Response` it returns is sent as it is. */
25
36
  export type RequestHook = (ctx: RequestContext) => MaybePromise<Response | undefined | void>;
26
37
  /** Runs on every response, routed or not; a `Response` it returns replaces it. */
@@ -39,9 +50,17 @@ export interface RouteDefinition {
39
50
  readonly method: Method;
40
51
  readonly path: string;
41
52
  readonly schema: RouteSchema;
53
+ /**
54
+ * The most bytes its request body may hold: its schema's `bodyLimit`,
55
+ * else the `bodyLimit` in effect where it was declared. None, no limit
56
+ * beyond the server's `maxRequestBodySize`.
57
+ */
58
+ readonly bodyLimit?: number;
42
59
  readonly handler: (ctx: never) => MaybePromise<AnyReply>;
43
60
  readonly derive: readonly ChainHook[];
44
61
  readonly onError: readonly ErrorHook[];
62
+ /** The `onRefusal` hook declared last before it; none, and a refused request is the default 400. */
63
+ readonly refusal?: RefusalHandler | undefined;
45
64
  }
46
65
  /** A socket route as the app runs it. */
47
66
  export interface SocketDefinition {
@@ -50,6 +69,8 @@ export interface SocketDefinition {
50
69
  readonly handlers: SocketHandlers<never, never, never>;
51
70
  readonly derive: readonly ChainHook[];
52
71
  readonly onError: readonly ErrorHook[];
72
+ /** Answers a refused upgrade request, as a route's. */
73
+ readonly refusal?: RefusalHandler | undefined;
53
74
  }
54
75
  export type Definition = ({
55
76
  readonly kind: 'http';
@@ -1 +1 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/app/definition.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,K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,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,KACnC,MAAM,GAAG,SAAS,CAAC;CACxB"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A request the app refused before its handler ran, answered: by the
3
+ * route's `onRefusal` hook, or by the default.
4
+ */
5
+ import type { Refusal } from '../errors/errors';
6
+ import type { RouteDefinition, SocketDefinition } from './definition';
7
+ import type { BaseContext, ResponseSettings } from './types';
8
+ /**
9
+ * A refused request, answered by the route's `onRefusal` hook — its reply
10
+ * checked by the schemas the hook declares — or, when it has none or
11
+ * returns nothing, by the default of its kind: a 400 with the issues of a
12
+ * `validation`, the 413 of a `body_limit`.
13
+ */
14
+ export declare function refuse(definition: RouteDefinition | SocketDefinition, refusal: Refusal, set: ResponseSettings, ctx: BaseContext, validateResponses: boolean): Promise<Response>;
15
+ //# sourceMappingURL=refusal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../../src/app/refusal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAEX,OAAO,EAEP,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE7D;;;;;GAKG;AACH,wBAAsB,MAAM,CAC3B,UAAU,EAAE,eAAe,GAAG,gBAAgB,EAC9C,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,WAAW,EAChB,iBAAiB,EAAE,OAAO,GACxB,OAAO,CAAC,QAAQ,CAAC,CAyBnB"}
@@ -6,7 +6,7 @@
6
6
  import { type RoutingErrorBody } from '../errors/errors';
7
7
  import { type AnyReply } from '../reply/reply';
8
8
  import type { RouteDefinition } from './definition';
9
- import type { ResponseSettings } from './types';
9
+ import type { ResponseSchemas, ResponseSettings } from './types';
10
10
  /** The 500 of a request that failed: its body says no more than `internal`. */
11
11
  export declare function internalError(): Response;
12
12
  /** A reply as it is, with what the route set on its response. */
@@ -17,6 +17,13 @@ export declare function send(reply: AnyReply, set: ResponseSettings, signal?: Ab
17
17
  * declare, or a body its schema refuses, throws a `ResponseValidationError`.
18
18
  */
19
19
  export declare function sendDeclared(route: RouteDefinition, reply: AnyReply, set: ResponseSettings, signal: AbortSignal, validateResponses: boolean): Promise<Response>;
20
+ /**
21
+ * `reply` checked against the schema `responses` declares for its status,
22
+ * as that schema's output: what a handler's reply and an `onRefusal`
23
+ * hook's go through. A status with no schema, or a body its schema
24
+ * refuses, throws a `ResponseValidationError`.
25
+ */
26
+ export declare function checkReply(method: string, path: string, responses: ResponseSchemas, reply: AnyReply, validateResponses: boolean): Promise<AnyReply>;
20
27
  /** What the router answers when no route takes the request. */
21
28
  export declare function routingError(status: 404 | 405 | 426, error: RoutingErrorBody['error'], allowed?: readonly string[]): Response;
22
29
  //# sourceMappingURL=send.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/app/send.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,gBAAgB,CAAC;AAElE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIhD,+EAA+E;AAC/E,wBAAgB,aAAa,IAAI,QAAQ,CAExC;AAED,iEAAiE;AACjE,wBAAgB,IAAI,CACnB,KAAK,EAAE,QAAQ,EACf,GAAG,EAAE,gBAAgB,EACrB,MAAM,CAAC,EAAE,WAAW,GAClB,QAAQ,CAmBV;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CACjC,KAAK,EA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,QAAQ,CAAC,CAkBnB;AAED,+DAA+D;AAC/D,wBAAgB,YAAY,CAC3B,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EACvB,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAChC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GACzB,QAAQ,CAKV"}
@@ -11,7 +11,7 @@ export interface SocketData {
11
11
  socket?: Socket<unknown, unknown>;
12
12
  }
13
13
  /** The upgrade request of a socket route: its hooks, its validation, then the upgrade. */
14
- export declare function upgradeSocket(definition: SocketDefinition, request: RequestContext, rawParams: Record<string, string>, parsers: readonly BodyParser[]): Promise<Response | typeof UPGRADED>;
14
+ export declare function upgradeSocket(definition: SocketDefinition, request: RequestContext, rawParams: Record<string, string>, parsers: readonly BodyParser[], validateResponses: boolean): Promise<Response | typeof UPGRADED>;
15
15
  /** The `websocket` handler `Bun.serve` runs every open socket through. */
16
16
  export declare function websocketHandler(validate: boolean): Bun.WebSocketHandler<SocketData>;
17
17
  //# sourceMappingURL=socket.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../../src/app/socket.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D,mFAAmF;AACnF,eAAO,MAAM,QAAQ,eAAqB,CAAC;AAE3C,+FAA+F;AAC/F,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,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AC1E,wBAAgB,gBAAgB,CAC/B,QAAQ,EAAE,OAAO,GACf,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,CA4DlC"}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  export type { Empty, MaybePromise, Method } from './common';
7
7
  export type { BaseContext, Context, RequestContext, ResponseSettings, } from './context';
8
+ export type { BehindShortcuts, BodyLimited, BodyLimitShortcut, DeclaredRefusal, DefaultLimitOutcome, DefaultRefusalOutcome, FallsBack, IsLimited, RefusalOutcome, RefusalResponses, RefusalSchema, RefusalsOf, Refusing, ThenShortcuts, } from './refusal';
8
9
  export type { ProvidedBy, RequiresOf, Requiring } from './requires';
9
10
  export type { Outcome, OutcomeOf, RouteEntryOf, RouteInput, RouteOutput, RouteRecord, RouteTable, } from './route-table';
10
11
  export type { ResponseSchemas, RouteDetail, RouteSchema } from './schema';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC5D,YAAY,EACX,WAAW,EACX,OAAO,EACP,cAAc,EACd,gBAAgB,GAChB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACpE,YAAY,EACX,OAAO,EACP,SAAS,EACT,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,EACX,UAAU,GACV,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1E,YAAY,EACX,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACd,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC5D,YAAY,EACX,WAAW,EACX,OAAO,EACP,cAAc,EACd,gBAAgB,GAChB,MAAM,WAAW,CAAC;AACnB,YAAY,EACX,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,QAAQ,EACR,aAAa,GACb,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACpE,YAAY,EACX,OAAO,EACP,SAAS,EACT,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,EACX,UAAU,GACV,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1E,YAAY,EACX,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACd,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * How an app's type carries its `onRefusal` hook: what the hook may
3
+ * declare, and the marked replies that take the place of the default 400
4
+ * in the type of each route after it that validates, and of the default
5
+ * 413 in the type of each route under a `bodyLimit`.
6
+ */
7
+ import type { ContentTooLargeBody, ValidationErrorBody } from '../../errors/errors';
8
+ import type { Reply } from '../../reply/reply';
9
+ import type { InferOutput, StandardSchemaV1 } from '../../schema/standard-schema';
10
+ import type { Jsonify } from '../../types/json';
11
+ import type { ClientErrorStatus } from '../../types/status';
12
+ import type { Outcome, OutcomeOf } from './route-table';
13
+ /** The schema of each status an `onRefusal` hook may answer, client errors only. */
14
+ export type RefusalResponses = {
15
+ readonly [Status in ClientErrorStatus]?: StandardSchemaV1;
16
+ };
17
+ /**
18
+ * What an `onRefusal` hook declares: the schema of each status it may
19
+ * answer — its reply is checked by it, typed and documented — and the
20
+ * `content-type` its reply is sent with unless it sets one.
21
+ */
22
+ export interface RefusalSchema<Responses extends RefusalResponses = RefusalResponses> {
23
+ readonly response: Responses;
24
+ readonly contentType?: string;
25
+ }
26
+ /** The replies an `onRefusal` hook answers with, marked; the default 400 when it may return nothing. */
27
+ export type RefusalsOf<Replies, Result> = (Replies & Refusing) | (undefined extends Result ? Reply<400, ValidationErrorBody> & FallsBack : never);
28
+ /** Every reply a hook declaring `Responses` may answer, as its schemas give it back. */
29
+ export type DeclaredRefusal<Responses> = {
30
+ [Status in keyof Responses & ClientErrorStatus]: Reply<Status, Responses[Status] extends StandardSchemaV1 ? InferOutput<Responses[Status]> : never>;
31
+ }[keyof Responses & ClientErrorStatus];
32
+ /**
33
+ * The mark, among an app's shortcuts, of each reply its `onRefusal` hook
34
+ * answers a refused request with: they replace the default 400 of a route
35
+ * that validates, and are no part of a route that does not.
36
+ */
37
+ export interface Refusing {
38
+ readonly '~refusal': true;
39
+ }
40
+ /**
41
+ * The default 400 in a route's type, marked: the `onRefusal` hook of an
42
+ * app a plugin is used by replaces it on the plugin's routes, as it does
43
+ * at runtime. The client reads it as `Outcome<400, ValidationErrorBody>`.
44
+ */
45
+ export interface DefaultRefusalOutcome extends Outcome<400, ValidationErrorBody> {
46
+ readonly '~default': true;
47
+ }
48
+ /**
49
+ * The mark of the default 400 among a hook's refusals: the hook may return
50
+ * nothing, and the default answers then.
51
+ */
52
+ export interface FallsBack extends Refusing {
53
+ readonly '~fallback': true;
54
+ }
55
+ /**
56
+ * The default 413 in a route's type, marked as the default 400 is: the
57
+ * `onRefusal` hook of an app a plugin is used by replaces it.
58
+ */
59
+ export interface DefaultLimitOutcome extends Outcome<413, Jsonify<ContentTooLargeBody>> {
60
+ readonly '~default': true;
61
+ }
62
+ /**
63
+ * The mark, among an app's shortcuts, of a `bodyLimit()` in force: every
64
+ * route after it may refuse its body with a `body_limit` refusal.
65
+ */
66
+ export interface BodyLimited {
67
+ readonly '~bodyLimit': true;
68
+ }
69
+ /** What `bodyLimit()` adds to the shortcuts of the routes after it. */
70
+ export type BodyLimitShortcut = Reply<413, ContentTooLargeBody> & BodyLimited;
71
+ /** Whether a route is under a `bodyLimit`: its own, or one in force before it. */
72
+ export type IsLimited<Schema, Shortcuts> = Schema extends {
73
+ readonly bodyLimit: number;
74
+ } ? true : [Extract<Shortcuts, BodyLimited>] extends [never] ? false : true;
75
+ /**
76
+ * The outcomes a refused request may get: every reply of the hook in force,
77
+ * on every route it may refuse — one that `Validates` or is `Limited`,
78
+ * since its reply does not depend on the kind in its type — or the default
79
+ * of each kind the route may refuse with: the 400 of a route that
80
+ * `Validates`, the 413 of one that is `Limited`.
81
+ */
82
+ export type RefusalOutcome<Shortcuts, Validates extends boolean = true, Limited extends boolean = false> = [Extract<Shortcuts, Refusing>] extends [never] ? (Validates extends true ? DefaultRefusalOutcome : never) | (Limited extends true ? DefaultLimitOutcome : never) : [Validates | Limited] extends [false] ? never : OutcomeOf<Exclude<Extract<Shortcuts, Refusing>, FallsBack>> | ([Extract<Shortcuts, FallsBack>] extends [never] ? never : (Validates extends true ? Outcome<400, ValidationErrorBody> : never) | (Limited extends true ? Outcome<413, Jsonify<ContentTooLargeBody>> : never));
83
+ /** `Shortcuts`, then the shortcuts of a later scope: its refusals, if any, replace these. */
84
+ export type ThenShortcuts<Shortcuts, Later> = [
85
+ Extract<Later, Refusing>
86
+ ] extends [never] ? Shortcuts | Later : Exclude<Shortcuts, Refusing> | Later;
87
+ /**
88
+ * `Output`, a route of a plugin, behind the hooks of the app using it: its
89
+ * default 400 and 413 replaced by the app's refusals, and the app's other
90
+ * replies added. The app's `bodyLimit()` does not reach it: a plugin's
91
+ * route keeps the limit it was declared with.
92
+ */
93
+ export type BehindShortcuts<Output, Shortcuts> = ([Extract<Shortcuts, Refusing>] extends [never] ? Output : Exclude<Output, DefaultRefusalOutcome | DefaultLimitOutcome> | ([Extract<Output, DefaultRefusalOutcome>] extends [never] ? never : RefusalOutcome<Shortcuts, true, false>) | ([Extract<Output, DefaultLimitOutcome>] extends [never] ? never : RefusalOutcome<Shortcuts, false, true>)) | OutcomeOf<Exclude<Shortcuts, Refusing | BodyLimited>>;
94
+ //# sourceMappingURL=refusal.d.ts.map