@sdk-it/hono 0.46.11 → 0.47.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.
@@ -1,3 +1,4 @@
1
- import ts from 'typescript';
2
- export declare function getConstantValue(checker: ts.TypeChecker, expression: ts.Expression): string | number | boolean | undefined;
1
+ import type { Expression } from '@typescript/native/ast';
2
+ import type { Checker } from '@typescript/native/sync';
3
+ export declare function getConstantValue(checker: Checker, expression: Expression): string | number | boolean | undefined;
3
4
  //# sourceMappingURL=constant-value.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constant-value.d.ts","sourceRoot":"","sources":["../../src/lib/constant-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAqC5B,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,UAAU,EAAE,EAAE,CAAC,UAAU,GACxB,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAgDvC"}
1
+ {"version":3,"file":"constant-value.d.ts","sources":["../../src/lib/constant-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAMzD,OAAO,KAAK,EAAE,OAAO,EAAQ,MAAM,yBAAyB,CAAC;AAyB7D,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,GACrB,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CA6BvC"}
@@ -0,0 +1,28 @@
1
+ import type { Node } from '@typescript/native/ast';
2
+ import type { NaunceResponseAnalyzer } from '@sdk-it/core';
3
+ import type { TypeDeriver } from '@sdk-it/core/deriver.js';
4
+ /** What an evlog error catalog entry tells a client about the error a factory throws. */
5
+ export interface CatalogError {
6
+ code: string;
7
+ status: number;
8
+ /** Undefined when the entry builds its message from call-site params. */
9
+ message: string | undefined;
10
+ why: string | undefined;
11
+ fix: string | undefined;
12
+ link: string | undefined;
13
+ }
14
+ /**
15
+ * The catalog entry behind a thrown evlog factory call such as
16
+ * `billingErrors.PAYMENT_DECLINED(...)`, or undefined when the call is not an
17
+ * evlog `DefinedError`. The literals live in the factory's type arguments,
18
+ * because evlog widens the factory's own `status` to `number`.
19
+ */
20
+ export declare function catalogError(deriver: TypeDeriver, node: Node): CatalogError | undefined;
21
+ /**
22
+ * Documents `throw catalog.KEY(...)` from an evlog `defineErrorCatalog` with
23
+ * evlog's own JSON body, for apps whose error handler returns the error as is.
24
+ * Spread it beside `responseAnalyzer`; for another body, write a
25
+ * `throw.call.EvlogError` entry with {@link catalogError}.
26
+ */
27
+ export declare const evlogErrors: NaunceResponseAnalyzer;
28
+ //# sourceMappingURL=evlog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evlog.d.ts","sources":["../../src/lib/evlog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,IAAI,EAAE,MAAM,wBAAwB,CAAC;AASnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAI3D,yFAAyF;AACzF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AA2BD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,IAAI,GACT,YAAY,GAAG,SAAS,CA8B1B;AA+BD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,sBAezB,CAAC"}
@@ -0,0 +1,152 @@
1
+ // packages/hono/src/lib/evlog.ts
2
+ import {
3
+ isCallExpression,
4
+ isObjectLiteralExpression,
5
+ isPropertyAssignment
6
+ } from "@typescript/native/ast/is";
7
+
8
+ // packages/hono/src/lib/constant-value.ts
9
+ import {
10
+ isAsExpression,
11
+ isParenthesizedExpression,
12
+ isTypeAssertion
13
+ } from "@typescript/native/ast/is";
14
+ function unwrapExpression(node) {
15
+ let current = node;
16
+ while (isAsExpression(current) || isTypeAssertion(current) || isParenthesizedExpression(current)) {
17
+ current = current.expression;
18
+ }
19
+ return current;
20
+ }
21
+ function literalValue(type) {
22
+ if (type.isStringLiteralType() || type.isNumberLiteralType() || type.isBooleanLiteralType()) {
23
+ return type.value;
24
+ }
25
+ return void 0;
26
+ }
27
+ function getConstantValue(checker, expression) {
28
+ const unwrapped = unwrapExpression(expression);
29
+ const constant = checker.getConstantValue(unwrapped);
30
+ if (constant !== void 0) {
31
+ return constant;
32
+ }
33
+ const type = checker.getTypeAtLocation(unwrapped);
34
+ const literal2 = literalValue(type);
35
+ if (literal2 !== void 0) {
36
+ return literal2;
37
+ }
38
+ if (type.isUnionType()) {
39
+ let resolved = void 0;
40
+ for (const entry of type.getTypes()) {
41
+ const value = literalValue(entry);
42
+ if (value === void 0) {
43
+ return void 0;
44
+ }
45
+ if (resolved === void 0) {
46
+ resolved = value;
47
+ } else if (resolved !== value) {
48
+ return void 0;
49
+ }
50
+ }
51
+ return resolved;
52
+ }
53
+ return void 0;
54
+ }
55
+
56
+ // packages/hono/src/lib/evlog.ts
57
+ function literal(type) {
58
+ return "value" in type ? type.value : void 0;
59
+ }
60
+ function text(value) {
61
+ return typeof value === "string" ? value : void 0;
62
+ }
63
+ function statusOverride(checker, call) {
64
+ const [options] = call.arguments;
65
+ if (!options || !isObjectLiteralExpression(options)) {
66
+ return void 0;
67
+ }
68
+ for (const property of options.properties) {
69
+ if (isPropertyAssignment(property) && property.name.getText() === "status") {
70
+ const status = getConstantValue(checker, property.initializer);
71
+ return typeof status === "number" ? status : void 0;
72
+ }
73
+ }
74
+ return void 0;
75
+ }
76
+ function catalogError(deriver, node) {
77
+ if (!isCallExpression(node)) {
78
+ return void 0;
79
+ }
80
+ const checker = deriver.checker;
81
+ const factory = checker.getTypeAtLocation(node.expression);
82
+ if (factory.getAliasSymbol()?.name !== "DefinedError") {
83
+ return void 0;
84
+ }
85
+ const [codeType, entry] = factory.getAliasTypeArguments();
86
+ const code = literal(codeType);
87
+ if (typeof code !== "string") {
88
+ return void 0;
89
+ }
90
+ const field = (name) => {
91
+ const property = checker.getPropertyOfType(entry, name);
92
+ return property ? literal(checker.getTypeOfSymbol(property)) : void 0;
93
+ };
94
+ const status = field("status");
95
+ return {
96
+ code,
97
+ // evlog's EvlogError constructor: `this.status = opts.status ?? 500`.
98
+ status: statusOverride(checker, node) ?? (typeof status === "number" ? status : 500),
99
+ message: text(field("message")),
100
+ why: text(field("why")),
101
+ fix: text(field("fix")),
102
+ link: text(field("link"))
103
+ };
104
+ }
105
+ function evlogErrorBody(error) {
106
+ const string = { type: "string" };
107
+ return {
108
+ type: "object",
109
+ required: ["name", "message", "status", "data"],
110
+ properties: {
111
+ name: { type: "string", enum: ["EvlogError"] },
112
+ message: string,
113
+ status: { type: "number", enum: [error.status] },
114
+ data: {
115
+ type: "object",
116
+ required: ["code"],
117
+ properties: {
118
+ code: { type: "string", enum: [error.code] },
119
+ why: string,
120
+ fix: string,
121
+ link: string
122
+ }
123
+ },
124
+ cause: {
125
+ type: "object",
126
+ required: ["name", "message"],
127
+ properties: { name: string, message: string }
128
+ }
129
+ }
130
+ };
131
+ }
132
+ var evlogErrors = {
133
+ "throw.call.EvlogError": (_handler, deriver, node) => {
134
+ const error = catalogError(deriver, node);
135
+ if (!error) {
136
+ return [];
137
+ }
138
+ return [
139
+ {
140
+ statusCode: String(error.status),
141
+ contentType: "application/json",
142
+ headers: [],
143
+ schema: evlogErrorBody(error)
144
+ }
145
+ ];
146
+ }
147
+ };
148
+ export {
149
+ catalogError,
150
+ evlogErrors
151
+ };
152
+ //# sourceMappingURL=evlog.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/evlog.ts", "../../src/lib/constant-value.ts"],
4
+ "sourcesContent": ["import type { CallExpression, Node } from '@typescript/native/ast';\nimport {\n isCallExpression,\n isObjectLiteralExpression,\n isPropertyAssignment,\n} from '@typescript/native/ast/is';\nimport type { Checker, Type } from '@typescript/native/sync';\nimport type { SchemaObject } from 'openapi3-ts/oas31';\n\nimport type { NaunceResponseAnalyzer } from '@sdk-it/core';\nimport type { TypeDeriver } from '@sdk-it/core/deriver.js';\n\nimport { getConstantValue } from './constant-value.js';\n\n/** What an evlog error catalog entry tells a client about the error a factory throws. */\nexport interface CatalogError {\n code: string;\n status: number;\n /** Undefined when the entry builds its message from call-site params. */\n message: string | undefined;\n why: string | undefined;\n fix: string | undefined;\n link: string | undefined;\n}\n\nfunction literal(type: Type): unknown {\n return 'value' in type ? type.value : undefined;\n}\n\nfunction text(value: unknown): string | undefined {\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction statusOverride(checker: Checker, call: CallExpression) {\n const [options] = call.arguments;\n if (!options || !isObjectLiteralExpression(options)) {\n return undefined;\n }\n for (const property of options.properties) {\n if (\n isPropertyAssignment(property) &&\n property.name.getText() === 'status'\n ) {\n const status = getConstantValue(checker, property.initializer);\n return typeof status === 'number' ? status : undefined;\n }\n }\n return undefined;\n}\n\n/**\n * The catalog entry behind a thrown evlog factory call such as\n * `billingErrors.PAYMENT_DECLINED(...)`, or undefined when the call is not an\n * evlog `DefinedError`. The literals live in the factory's type arguments,\n * because evlog widens the factory's own `status` to `number`.\n */\nexport function catalogError(\n deriver: TypeDeriver,\n node: Node,\n): CatalogError | undefined {\n if (!isCallExpression(node)) {\n return undefined;\n }\n const checker = deriver.checker;\n const factory = checker.getTypeAtLocation(node.expression);\n if (factory.getAliasSymbol()?.name !== 'DefinedError') {\n return undefined;\n }\n const [codeType, entry] = factory.getAliasTypeArguments();\n const code = literal(codeType);\n if (typeof code !== 'string') {\n return undefined;\n }\n const field = (name: string) => {\n const property = checker.getPropertyOfType(entry, name);\n return property ? literal(checker.getTypeOfSymbol(property)) : undefined;\n };\n const status = field('status');\n return {\n code,\n // evlog's EvlogError constructor: `this.status = opts.status ?? 500`.\n status:\n statusOverride(checker, node) ??\n (typeof status === 'number' ? status : 500),\n message: text(field('message')),\n why: text(field('why')),\n fix: text(field('fix')),\n link: text(field('link')),\n };\n}\n\n/** The JSON evlog writes for an `EvlogError` (`EvlogError#toJSON`). */\nfunction evlogErrorBody(error: CatalogError): SchemaObject {\n const string: SchemaObject = { type: 'string' };\n return {\n type: 'object',\n required: ['name', 'message', 'status', 'data'],\n properties: {\n name: { type: 'string', enum: ['EvlogError'] },\n message: string,\n status: { type: 'number', enum: [error.status] },\n data: {\n type: 'object',\n required: ['code'],\n properties: {\n code: { type: 'string', enum: [error.code] },\n why: string,\n fix: string,\n link: string,\n },\n },\n cause: {\n type: 'object',\n required: ['name', 'message'],\n properties: { name: string, message: string },\n },\n },\n };\n}\n\n/**\n * Documents `throw catalog.KEY(...)` from an evlog `defineErrorCatalog` with\n * evlog's own JSON body, for apps whose error handler returns the error as is.\n * Spread it beside `responseAnalyzer`; for another body, write a\n * `throw.call.EvlogError` entry with {@link catalogError}.\n */\nexport const evlogErrors: NaunceResponseAnalyzer = {\n 'throw.call.EvlogError': (_handler, deriver, node) => {\n const error = catalogError(deriver, node);\n if (!error) {\n return [];\n }\n return [\n {\n statusCode: String(error.status),\n contentType: 'application/json',\n headers: [],\n schema: evlogErrorBody(error),\n },\n ];\n },\n};\n", "import type { Expression } from '@typescript/native/ast';\nimport {\n isAsExpression,\n isParenthesizedExpression,\n isTypeAssertion,\n} from '@typescript/native/ast/is';\nimport type { Checker, Type } from '@typescript/native/sync';\n\nfunction unwrapExpression(node: Expression): Expression {\n let current = node;\n while (\n isAsExpression(current) ||\n isTypeAssertion(current) ||\n isParenthesizedExpression(current)\n ) {\n current = current.expression;\n }\n return current;\n}\n\nfunction literalValue(type: Type): string | number | boolean | undefined {\n if (\n type.isStringLiteralType() ||\n type.isNumberLiteralType() ||\n type.isBooleanLiteralType()\n ) {\n return type.value;\n }\n return undefined;\n}\n\nexport function getConstantValue(\n checker: Checker,\n expression: Expression,\n): string | number | boolean | undefined {\n const unwrapped = unwrapExpression(expression);\n\n const constant = checker.getConstantValue(unwrapped);\n if (constant !== undefined) {\n return constant;\n }\n\n const type = checker.getTypeAtLocation(unwrapped);\n const literal = literalValue(type);\n if (literal !== undefined) {\n return literal;\n }\n if (type.isUnionType()) {\n let resolved: string | number | boolean | undefined = undefined;\n for (const entry of type.getTypes()) {\n const value = literalValue(entry);\n if (value === undefined) {\n return undefined;\n }\n if (resolved === undefined) {\n resolved = value;\n } else if (resolved !== value) {\n return undefined;\n }\n }\n return resolved;\n }\n return undefined;\n}\n"],
5
+ "mappings": ";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACJP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,iBAAiB,MAA8B;AACtD,MAAI,UAAU;AACd,SACE,eAAe,OAAO,KACtB,gBAAgB,OAAO,KACvB,0BAA0B,OAAO,GACjC;AACA,cAAU,QAAQ;AAAA,EACpB;AACA,SAAO;AACT;AAEA,SAAS,aAAa,MAAmD;AACvE,MACE,KAAK,oBAAoB,KACzB,KAAK,oBAAoB,KACzB,KAAK,qBAAqB,GAC1B;AACA,WAAO,KAAK;AAAA,EACd;AACA,SAAO;AACT;AAEO,SAAS,iBACd,SACA,YACuC;AACvC,QAAM,YAAY,iBAAiB,UAAU;AAE7C,QAAM,WAAW,QAAQ,iBAAiB,SAAS;AACnD,MAAI,aAAa,QAAW;AAC1B,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,QAAQ,kBAAkB,SAAS;AAChD,QAAMA,WAAU,aAAa,IAAI;AACjC,MAAIA,aAAY,QAAW;AACzB,WAAOA;AAAA,EACT;AACA,MAAI,KA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;AACA,WAAO;AAAA,MACL;AAAA,QACE,YAAY,OAAO,MAAM,MAAM;AAAA,QAC/B,aAAa;AAAA,QACb,SAAS,CAAC;AAAA,QACV,QAAQ,eAAe,KAAK;AAAA,MAC9B;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": ["literal"]
7
+ }
@@ -1,10 +1,12 @@
1
- import ts from 'typescript';
2
- import { type NaunceResponseAnalyzerFn, type ResponseItem, type TypeDeriver } from '@sdk-it/core';
1
+ import type { Node } from '@typescript/native/ast';
2
+ import { type FunctionWithBody, type NaunceResponseAnalyzerFn, type ResponseItem } from '@sdk-it/core';
3
+ import type { TypeDeriver } from '@sdk-it/core/deriver.js';
3
4
  export declare const newResponse: NaunceResponseAnalyzerFn;
4
- export declare function defaultResponseAnalyzer(handler: ts.ArrowFunction | ts.FunctionExpression, deriver: TypeDeriver): ResponseItem[];
5
- export declare function streamText(_handler: ts.ArrowFunction | ts.FunctionExpression, _deriver: TypeDeriver): ResponseItem[];
6
- export declare function stream(_handler: ts.ArrowFunction | ts.FunctionExpression, _deriver: TypeDeriver): ResponseItem[];
7
- export declare function streamSSE(_handler: ts.ArrowFunction | ts.FunctionExpression, _deriver: TypeDeriver): ResponseItem[];
5
+ /** The response `returned`, a value the handler returns, sends when it is a call on the handler's context, such as `c.json(body, 201)`. */
6
+ export declare function defaultResponseAnalyzer(handler: FunctionWithBody, deriver: TypeDeriver, returned: Node): ResponseItem[];
7
+ export declare function streamText(_handler: FunctionWithBody, _deriver: TypeDeriver): ResponseItem[];
8
+ export declare function stream(_handler: FunctionWithBody, _deriver: TypeDeriver): ResponseItem[];
9
+ export declare function streamSSE(_handler: FunctionWithBody, _deriver: TypeDeriver): ResponseItem[];
8
10
  export declare const httpException: NaunceResponseAnalyzerFn;
9
11
  export declare const responseAnalyzer: {
10
12
  default: typeof defaultResponseAnalyzer;
@@ -1 +1 @@
1
- {"version":3,"file":"response-analyzer.d.ts","sourceRoot":"","sources":["../../src/lib/response-analyzer.ts"],"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AO,EAAE,WAAW,EACpB,QAAQ,EAAE,IAAI,GACb,YAAY,EAAE,CA+ChB;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,WAAW,GACpB,YAAY,EAAE,CAahB;AAED,wBAAgB,MAAM,CACpB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,WAAW,GACpB,YAAY,EAAE,CAahB;AAED,wBAAgB,SAAS,CACvB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,WAAW,GACpB,YAAY,EAAE,CAahB;AAED,eAAO,MAAM,aAAa,EAAE,wBAiB3B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;CAO5B,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sources":["../../../src/lib/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
@@ -32,10 +32,7 @@ function createOutput(contextFn) {
32
32
  },
33
33
  redirect(uri, statusCode) {
34
34
  const context = contextFn();
35
- return context.redirect(
36
- uri.toString(),
37
- statusCode ?? void 0
38
- );
35
+ return context.redirect(uri.toString(), statusCode);
39
36
  },
40
37
  attachment(buffer, filename, mimeType) {
41
38
  const context = contextFn();
@@ -84,6 +81,28 @@ import { safeParse } from "fast-content-type-parse";
84
81
  import { createMiddleware } from "hono/factory";
85
82
  import { HTTPException } from "hono/http-exception";
86
83
  import z from "zod";
84
+ var fieldSourceNames = [
85
+ "body",
86
+ "query",
87
+ "queries",
88
+ "params",
89
+ "headers"
90
+ ];
91
+ function fieldMarkers(validationTarget) {
92
+ return new Proxy(
93
+ {},
94
+ {
95
+ get: (_target, name) => typeof name === "string" ? { validationTarget, name } : void 0
96
+ }
97
+ );
98
+ }
99
+ var fieldSources = fieldSourceNames;
100
+ function isFieldMarker(value) {
101
+ return typeof value === "object" && value !== null && "validationTarget" in value && typeof value.validationTarget === "string" && fieldSources.includes(value.validationTarget) && "name" in value && typeof value.name === "string";
102
+ }
103
+ function isRecord(value) {
104
+ return typeof value === "object" && value !== null && !Array.isArray(value);
105
+ }
87
106
  function validate(expectedContentTypeOrSelector, selector) {
88
107
  const expectedContentType = typeof expectedContentTypeOrSelector === "string" ? expectedContentTypeOrSelector : void 0;
89
108
  const _selector = typeof expectedContentTypeOrSelector === "function" ? expectedContentTypeOrSelector : selector;
@@ -127,27 +146,36 @@ function validate(expectedContentTypeOrSelector, selector) {
127
146
  default:
128
147
  body = {};
129
148
  }
130
- const selectedBody = body !== null && typeof body === "object" && !Array.isArray(body) ? body : new Proxy(
131
- {},
132
- {
133
- get() {
134
- throw new HTTPException(400, {
135
- message: "Invalid request body",
136
- cause: {
137
- code: "api/invalid-body",
138
- detail: "Request body must be an object when selecting fields."
139
- }
140
- });
141
- }
142
- }
143
- );
144
149
  const payload = {
145
- body: selectedBody,
150
+ body: fieldMarkers("body"),
151
+ query: fieldMarkers("query"),
152
+ queries: fieldMarkers("queries"),
153
+ params: fieldMarkers("params"),
154
+ headers: fieldMarkers("headers")
155
+ };
156
+ const sources = {
146
157
  query: c.req.query(),
147
158
  queries: c.req.queries(),
148
159
  params: c.req.param(),
149
160
  headers: c.req.header()
150
161
  };
162
+ const read = (select) => {
163
+ if (select === payload.body) return body;
164
+ if (!isFieldMarker(select)) return select;
165
+ if (select.validationTarget !== "body") {
166
+ return sources[select.validationTarget][select.name];
167
+ }
168
+ if (!isRecord(body)) {
169
+ throw new HTTPException(400, {
170
+ message: "Invalid request body",
171
+ cause: {
172
+ code: "api/invalid-body",
173
+ detail: "Request body must be an object when selecting fields."
174
+ }
175
+ });
176
+ }
177
+ return body[select.name];
178
+ };
151
179
  const config = _selector(payload);
152
180
  const schema = z.object(
153
181
  Object.fromEntries(
@@ -155,10 +183,7 @@ function validate(expectedContentTypeOrSelector, selector) {
155
183
  )
156
184
  );
157
185
  const input = Object.fromEntries(
158
- Object.entries(config).map(([key, value]) => [
159
- key,
160
- value.select === selectedBody ? body : value.select
161
- ])
186
+ Object.entries(config).map(([key, value]) => [key, read(value.select)])
162
187
  );
163
188
  const parsed = await parse(schema, input);
164
189
  c.set("input", parsed);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/runtime/output.ts", "../../../src/lib/runtime/validator.ts"],
4
- "sourcesContent": ["import type { Context } from 'hono';\nimport { getContext } from 'hono/context-storage';\nimport type {\n ContentfulStatusCode,\n RedirectStatusCode,\n} from 'hono/utils/http-status';\n\ntype Data = any;\nfunction send(\n context: Context,\n value: Data | undefined | null,\n status: ContentfulStatusCode,\n headers?: Readonly<Record<string, string>>,\n) {\n if (value === undefined || value === null) {\n return context.body(null, status, headers);\n }\n const responseHeaders = { ...headers };\n responseHeaders['Content-Type'] ??= 'application/json';\n if (responseHeaders['Content-Type'].includes('application/json')) {\n return context.body(JSON.stringify(value), status, responseHeaders);\n }\n return context.body(value, status, responseHeaders);\n}\n\nexport function createOutput(contextFn: () => Context) {\n return {\n nocontent() {\n const context = contextFn();\n return context.body(null, 204, {});\n },\n ok(value: Data | undefined | null, headers?: Record<string, string>) {\n return send(contextFn(), value, 200, headers);\n },\n created(\n valueOrUri: string | Data,\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n if (typeof valueOrUri === 'string') {\n // If no content is provided, we send null\n return send(contextFn(), value, 201, {\n Location: valueOrUri,\n ...(headers || {}),\n });\n } else {\n // valueOrUri is the data\n return send(contextFn(), valueOrUri, 201, headers);\n }\n },\n redirect(uri: string | URL, statusCode?: unknown) {\n const context = contextFn();\n return context.redirect(\n uri.toString(),\n (statusCode as RedirectStatusCode) ?? undefined,\n );\n },\n attachment(buffer: Buffer, filename: string, mimeType: string) {\n const context = contextFn();\n // https://github.com/honojs/hono/issues/3720\n return context.body(buffer as never, 200, {\n 'Content-Type': mimeType,\n 'Content-Disposition': `attachment; filename=\"${filename}\"`,\n 'Content-Length': buffer.length.toString(),\n });\n },\n badRequest(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 400, headers);\n },\n unauthorized(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 401, headers);\n },\n forbidden(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 403, headers);\n },\n notFound(value: Data | undefined | null, headers?: Record<string, string>) {\n return send(contextFn(), value, 404, headers);\n },\n notImplemented(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 501, headers);\n },\n accepted(value: Data | undefined | null, headers?: Record<string, string>) {\n return send(contextFn(), value, 202, headers);\n },\n conflict(value: Data | undefined | null, headers?: Record<string, string>) {\n return send(contextFn(), value, 409, headers);\n },\n unprocessableEntity(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 422, headers);\n },\n internalServerError(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 500, headers);\n },\n serviceUnavailable(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 503, headers);\n },\n };\n}\n\nexport const output = createOutput(() => getContext());\n", "import { safeParse } from 'fast-content-type-parse';\nimport type { MiddlewareHandler, ValidationTargets } from 'hono';\nimport { createMiddleware } from 'hono/factory';\nimport { HTTPException } from 'hono/http-exception';\nimport z from 'zod';\n\ntype ContentType =\n | 'application/json'\n | 'application/x-www-form-urlencoded'\n | 'multipart/form-data'\n | 'text/plain';\n\n// z.ZodType<any> mirrors zod v3's ZodTypeAny: with the default `unknown`\n// output, concrete middlewares stop being assignable to\n// ValidateMiddleware<ValidatorConfig>.\n\ntype ValidatorConfig = Record<\n string,\n { select: unknown; against: z.ZodType<any> }\n>;\n\ntype ExtractInput<T extends ValidatorConfig> = z.output<\n z.ZodObject<{ [K in keyof T]: T[K]['against'] }>\n>;\n\ntype HasUndefined<T> = undefined extends T ? true : false;\n\ntype InferTarget<\n T extends ValidatorConfig,\n S,\n Target extends keyof ValidationTargets,\n> = {\n [K in keyof T as T[K]['select'] extends S ? K : never]: HasUndefined<\n z.infer<T[K]['against']>\n > extends true\n ? z.infer<T[K]['against']> | undefined\n : z.infer<T[K]['against']> extends ValidationTargets[Target]\n ? z.infer<T[K]['against']>\n : z.infer<T[K]['against']>;\n};\n\ntype InferIn<T extends ValidatorConfig> = (keyof InferTarget<\n T,\n QuerySelect | QueriesSelect,\n 'query'\n> extends never\n ? never\n : { query: InferTarget<T, QuerySelect | QueriesSelect, 'query'> }) &\n (keyof InferTarget<T, BodySelect, 'json'> extends never\n ? never\n : { json: InferTarget<T, BodySelect, 'json'> }) &\n (keyof InferTarget<T, ParamsSelect, 'param'> extends never\n ? never\n : { param: InferTarget<T, ParamsSelect, 'param'> }) &\n (keyof InferTarget<T, HeadersSelect, 'header'> extends never\n ? never\n : { header: InferTarget<T, HeadersSelect, 'header'> }) &\n (keyof InferTarget<T, CookieSelect, 'cookie'> extends never\n ? never\n : { cookie: InferTarget<T, CookieSelect, 'cookie'> });\n\n// Type-only markers distinguish request sources; no marker objects exist at runtime.\ntype Select<Target extends string> = {\n readonly validationTarget: Target;\n};\n\ntype BodySelect = Select<'body'>;\ntype QuerySelect = Select<'query'>;\ntype QueriesSelect = Select<'queries'>;\ntype ParamsSelect = Select<'params'>;\ntype HeadersSelect = Select<'headers'>;\ntype CookieSelect = Select<'cookie'>;\n\ntype SelectorFn<T> = (payload: {\n body: Record<string, BodySelect>;\n query: Record<string, QuerySelect>;\n queries: Record<string, QueriesSelect>;\n params: Record<string, ParamsSelect>;\n headers: Record<string, HeadersSelect>;\n}) => T;\ntype ValidateMiddleware<T extends ValidatorConfig> = MiddlewareHandler<\n {\n Variables: {\n input: ExtractInput<T>;\n };\n },\n string,\n { in: InferIn<T> }\n>;\n\n/** Validate selected request values and expose Zod's parsed output as `c.var.input`. */\nexport function validate<T extends ValidatorConfig>(\n selector: SelectorFn<T>,\n): ValidateMiddleware<T>;\n/** Enforce a content type before validating the selected request values. */\nexport function validate<T extends ValidatorConfig>(\n expectedContentTypeOrSelector: ContentType,\n selector: SelectorFn<T>,\n): ValidateMiddleware<T>;\nexport function validate<T extends ValidatorConfig>(\n expectedContentTypeOrSelector: ContentType | SelectorFn<T>,\n selector?: SelectorFn<T>,\n): ValidateMiddleware<T> {\n const expectedContentType =\n typeof expectedContentTypeOrSelector === 'string'\n ? expectedContentTypeOrSelector\n : undefined;\n const _selector =\n typeof expectedContentTypeOrSelector === 'function'\n ? expectedContentTypeOrSelector\n : selector;\n if (!_selector) {\n throw new Error('Selector function is required');\n }\n\n return createMiddleware(async (c, next) => {\n const ct = c.req.header('content-type');\n if (c.req.method === 'GET' && ct) {\n throw new HTTPException(415, {\n message: 'Unsupported Media Type',\n cause: {\n code: 'api/unsupported-media-type',\n detail: `GET requests cannot have a content type header`,\n },\n });\n }\n if (expectedContentType) {\n verifyContentType(ct, expectedContentType);\n }\n\n const contentType = ct ? parseContentType(ct) : null;\n let body: unknown = null;\n\n switch (contentType?.type) {\n case 'application/json':\n try {\n body = await c.req.json();\n } catch {\n throw new HTTPException(400, {\n message: 'Invalid JSON body',\n cause: {\n code: 'api/invalid-json',\n detail: 'Request body must be valid JSON.',\n },\n });\n }\n break;\n case 'application/x-www-form-urlencoded':\n case 'multipart/form-data':\n body = await c.req.parseBody({ all: true });\n break;\n default:\n body = {};\n }\n\n // Whole-body schemas may accept any JSON value. A field selector, however,\n // requires an object: guard the property read itself rather than catching\n // arbitrary errors thrown by the application's selector.\n const selectedBody =\n body !== null && typeof body === 'object' && !Array.isArray(body)\n ? body\n : new Proxy(\n {},\n {\n get() {\n throw new HTTPException(400, {\n message: 'Invalid request body',\n cause: {\n code: 'api/invalid-body',\n detail:\n 'Request body must be an object when selecting fields.',\n },\n });\n },\n },\n );\n const payload = {\n body: selectedBody,\n query: c.req.query(),\n queries: c.req.queries(),\n params: c.req.param(),\n headers: c.req.header(),\n };\n\n const config = _selector(payload as never);\n const schema = z.object(\n Object.fromEntries(\n Object.entries(config).map(([key, value]) => [key, value.against]),\n ),\n );\n\n const input = Object.fromEntries(\n Object.entries(config).map(([key, value]) => [\n key,\n value.select === selectedBody ? body : value.select,\n ]),\n );\n\n const parsed = await parse(schema, input);\n c.set('input', parsed as ExtractInput<T>);\n await next();\n });\n}\n\n/** Parse any Zod schema asynchronously, throwing a structured HTTP 400 on rejection. */\nexport async function parse<T extends z.ZodType>(\n schema: T,\n input: unknown,\n): Promise<z.output<T>> {\n const result = await schema.safeParseAsync(input);\n if (!result.success) {\n const { fieldErrors, formErrors } = z.flattenError(\n result.error,\n (issue) => ({\n message: issue.message,\n code: issue.code,\n path: issue.path.join('.'),\n }),\n );\n const error = new HTTPException(400, {\n message: 'Validation failed',\n cause: {\n code: 'api/validation-failed',\n detail: 'The input data is invalid',\n errors: fieldErrors,\n formErrors,\n },\n });\n throw error;\n }\n return result.data;\n}\n\nexport const openapi = validate;\n\n/** Enforce a request content type without reading or validating its body. */\nexport const consume = (contentType: ContentType) => {\n return createMiddleware(async (context, next) => {\n verifyContentType(context.req.header('content-type'), contentType);\n await next();\n });\n};\n\nfunction parseContentType(header: string) {\n const contentType = safeParse(header);\n if (!contentType.type) {\n throw new HTTPException(415, {\n message: 'Unsupported Media Type',\n cause: {\n code: 'api/unsupported-media-type',\n detail: 'Invalid content type header',\n },\n });\n }\n return contentType;\n}\n\nexport function verifyContentType(\n actual: string | undefined,\n expected: ContentType,\n): asserts actual is ContentType {\n if (!actual) {\n throw new HTTPException(415, {\n message: 'Unsupported Media Type',\n cause: {\n code: 'api/unsupported-media-type',\n detail: 'Missing content type header',\n },\n });\n }\n const { type: incomingContentType } = parseContentType(actual);\n if (incomingContentType !== expected) {\n throw new HTTPException(415, {\n message: 'Unsupported Media Type',\n cause: {\n code: 'api/unsupported-media-type',\n detail: `Expected content type: ${expected}, but got: ${incomingContentType}`,\n },\n });\n }\n}\n"],
5
- "mappings": ";AACA,SAAS,kBAAkB;AAO3B,SAAS,KACP,SACA,OACA,QACA,SACA;AACA,MAAI,UAAU,UAAa,UAAU,MAAM;AACzC,WAAO,QAAQ,KAAK,MAAM,QAAQ,OAAO;AAAA,EAC3C;AACA,QAAM,kBAAkB,EAAE,GAAG,QAAQ;AACrC,kBAAgB,cAAc,MAAM;AACpC,MAAI,gBAAgB,cAAc,EAAE,SAAS,kBAAkB,GAAG;AAChE,WAAO,QAAQ,KAAK,KAAK,UAAU,KAAK,GAAG,QAAQ,eAAe;AAAA,EACpE;AACA,SAAO,QAAQ,KAAK,OAAO,QAAQ,eAAe;AACpD;AAEO,SAAS,aAAa,WAA0B;AACrD,SAAO;AAAA,IACL,YAAY;AACV,YAAM,UAAU,UAAU;AAC1B,aAAO,QAAQ,KAAK,MAAM,KAAK,CAAC,CAAC;AAAA,IACnC;AAAA,IACA,GAAG,OAAgC,SAAkC;AACnE,aAAO,KAAK,UAAU,GAAG,OAAO,KAAK,OAAO;AAAA,IAC9C;AAAA,IACA,QACE,YACA,OACA,SACA;AACA,UAAI,OAAO,eAAe,UAAU;AAElC,eAAO,KAAK,UAAU,GAAG,OAAO,KAAK;AAAA,UACnC,UAAU;AAAA,UACV,GAAI,WAAW,CAAC;AAAA,QAClB,CAAC;AAAA,MACH,OAAO;AAEL,eAAO,KAAK,UAAU,GAAG,YAAY,KAAK,OAAO;AAAA,MACnD;AAAA,IACF;AAAA,IACA,SAAS,KAAmB,YAAsB;AAChD,YAAM,UAAU,UAAU;AAC1B,aAAO,QAAQ;AAAA,QACb,IAAI,SAAS;AAAA,QACZ,cAAqC;AAAA,MACxC;AAAA,IACF;AAAA,IACA,WAAW,QAAgB,UAAkB,UAAkB;AAC7D,YAAM,UAAU,UAAU;AAE1B,aAAO,QAAQ,KAAK,QAAiB,KAAK;AAAA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C,sBAAkB,QAAQ,IAAI,OAAO,cAAc,GAAG,WAAW;AACjE,UAAM,KAAK;AAAA,EACb,CAAC;AACH;AAEA,SAAS,iBAAiB,QAAgB;AACxC,QAAM,cAAc,UAAU,MAAM;AACpC,MAAI,CAAC,YAAY,MAAM;AACrB,UAAM,IAAI,cAAc,KAAK;AAAA,MAC3B,SAAS;AAAA,MACT,OAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEO,SAAS,kBACd,QACA,UAC+B;AAC/B,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,cAAc,KAAK;AAAA,MAC3B,SAAS;AAAA,MACT,OAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACH;AACA,QAAM,EAAE,MAAM,oBAAoB,IAAI,iBAAiB,MAAM;AAC7D,MAAI,wBAAwB,UAAU;AACpC,UAAM,IAAI,cAAc,KAAK;AAAA,MAC3B,SAAS;AAAA,MACT,OAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ,0BAA0B,QAAQ,cAAc,mBAAmB;AAAA,MAC7E;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
4
+ "sourcesContent": ["import type { Context } from 'hono';\nimport { getContext } from 'hono/context-storage';\nimport type {\n ContentfulStatusCode,\n RedirectStatusCode,\n} from 'hono/utils/http-status';\n\ntype Data = any;\nfunction send(\n context: Context,\n value: Data | undefined | null,\n status: ContentfulStatusCode,\n headers?: Readonly<Record<string, string>>,\n) {\n if (value === undefined || value === null) {\n return context.body(null, status, headers);\n }\n const responseHeaders = { ...headers };\n responseHeaders['Content-Type'] ??= 'application/json';\n if (responseHeaders['Content-Type'].includes('application/json')) {\n return context.body(JSON.stringify(value), status, responseHeaders);\n }\n return context.body(value, status, responseHeaders);\n}\n\nexport function createOutput(contextFn: () => Context) {\n return {\n nocontent() {\n const context = contextFn();\n return context.body(null, 204, {});\n },\n ok(value: Data | undefined | null, headers?: Record<string, string>) {\n return send(contextFn(), value, 200, headers);\n },\n created(\n valueOrUri: string | Data,\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n if (typeof valueOrUri === 'string') {\n // If no content is provided, we send null\n return send(contextFn(), value, 201, {\n Location: valueOrUri,\n ...(headers || {}),\n });\n } else {\n // valueOrUri is the data\n return send(contextFn(), valueOrUri, 201, headers);\n }\n },\n redirect(uri: string | URL, statusCode?: RedirectStatusCode) {\n const context = contextFn();\n return context.redirect(uri.toString(), statusCode);\n },\n attachment(\n buffer: Uint8Array<ArrayBuffer>,\n filename: string,\n mimeType: string,\n ) {\n const context = contextFn();\n return context.body(buffer, 200, {\n 'Content-Type': mimeType,\n 'Content-Disposition': `attachment; filename=\"${filename}\"`,\n 'Content-Length': buffer.length.toString(),\n });\n },\n badRequest(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 400, headers);\n },\n unauthorized(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 401, headers);\n },\n forbidden(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 403, headers);\n },\n notFound(value: Data | undefined | null, headers?: Record<string, string>) {\n return send(contextFn(), value, 404, headers);\n },\n notImplemented(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 501, headers);\n },\n accepted(value: Data | undefined | null, headers?: Record<string, string>) {\n return send(contextFn(), value, 202, headers);\n },\n conflict(value: Data | undefined | null, headers?: Record<string, string>) {\n return send(contextFn(), value, 409, headers);\n },\n unprocessableEntity(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 422, headers);\n },\n internalServerError(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 500, headers);\n },\n serviceUnavailable(\n value: Data | undefined | null,\n headers?: Record<string, string>,\n ) {\n return send(contextFn(), value, 503, headers);\n },\n };\n}\n\nexport const output = createOutput(() => getContext());\n", "import { safeParse } from 'fast-content-type-parse';\nimport type { MiddlewareHandler, ValidationTargets } from 'hono';\nimport { createMiddleware } from 'hono/factory';\nimport { HTTPException } from 'hono/http-exception';\nimport z from 'zod';\n\ntype ContentType =\n | 'application/json'\n | 'application/x-www-form-urlencoded'\n | 'multipart/form-data'\n | 'text/plain';\n\n// z.ZodType<any> mirrors zod v3's ZodTypeAny: with the default `unknown`\n// output, concrete middlewares stop being assignable to\n// ValidateMiddleware<ValidatorConfig>.\n\ntype ValidatorConfig = Record<\n string,\n { select: unknown; against: z.ZodType<any> }\n>;\n\ntype ExtractInput<T extends ValidatorConfig> = z.output<\n z.ZodObject<{ [K in keyof T]: T[K]['against'] }>\n>;\n\ntype HasUndefined<T> = undefined extends T ? true : false;\n\ntype InferTarget<\n T extends ValidatorConfig,\n S,\n Target extends keyof ValidationTargets,\n> = {\n [K in keyof T as T[K]['select'] extends S ? K : never]: HasUndefined<\n z.infer<T[K]['against']>\n > extends true\n ? z.infer<T[K]['against']> | undefined\n : z.infer<T[K]['against']> extends ValidationTargets[Target]\n ? z.infer<T[K]['against']>\n : z.infer<T[K]['against']>;\n};\n\ntype InferIn<T extends ValidatorConfig> = (keyof InferTarget<\n T,\n QuerySelect | QueriesSelect,\n 'query'\n> extends never\n ? never\n : { query: InferTarget<T, QuerySelect | QueriesSelect, 'query'> }) &\n (keyof InferTarget<T, BodySelect, 'json'> extends never\n ? never\n : { json: InferTarget<T, BodySelect, 'json'> }) &\n (keyof InferTarget<T, ParamsSelect, 'param'> extends never\n ? never\n : { param: InferTarget<T, ParamsSelect, 'param'> }) &\n (keyof InferTarget<T, HeadersSelect, 'header'> extends never\n ? never\n : { header: InferTarget<T, HeadersSelect, 'header'> }) &\n (keyof InferTarget<T, CookieSelect, 'cookie'> extends never\n ? never\n : { cookie: InferTarget<T, CookieSelect, 'cookie'> });\n\n// Markers distinguish request sources; `fieldMarkers` builds them at runtime.\ntype Select<Target extends string> = {\n readonly validationTarget: Target;\n};\n\ntype BodySelect = Select<'body'>;\ntype QuerySelect = Select<'query'>;\ntype QueriesSelect = Select<'queries'>;\ntype ParamsSelect = Select<'params'>;\ntype HeadersSelect = Select<'headers'>;\ntype CookieSelect = Select<'cookie'>;\n\nconst fieldSourceNames = [\n 'body',\n 'query',\n 'queries',\n 'params',\n 'headers',\n] as const;\ntype FieldSource = (typeof fieldSourceNames)[number];\ntype FieldMarker = Select<FieldSource> & { readonly name: string };\n\n/** `payload.<source>.<name>` in a selector reads a marker that names the field, not its value. */\nfunction fieldMarkers<Target extends FieldSource>(\n validationTarget: Target,\n): Record<string, Select<Target>> {\n return new Proxy<Record<string, Select<Target>>>(\n {},\n {\n get: (_target, name) =>\n typeof name === 'string' ? { validationTarget, name } : undefined,\n },\n );\n}\n\nconst fieldSources: readonly string[] = fieldSourceNames;\n\nfunction isFieldMarker(value: unknown): value is FieldMarker {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'validationTarget' in value &&\n typeof value.validationTarget === 'string' &&\n fieldSources.includes(value.validationTarget) &&\n 'name' in value &&\n typeof value.name === 'string'\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\ntype SelectorFn<T> = (payload: {\n body: Record<string, BodySelect>;\n query: Record<string, QuerySelect>;\n queries: Record<string, QueriesSelect>;\n params: Record<string, ParamsSelect>;\n headers: Record<string, HeadersSelect>;\n}) => T;\ntype ValidateMiddleware<T extends ValidatorConfig> = MiddlewareHandler<\n {\n Variables: {\n input: ExtractInput<T>;\n };\n },\n string,\n { in: InferIn<T> }\n>;\n\n/** Validate selected request values and expose Zod's parsed output as `c.var.input`. */\nexport function validate<T extends ValidatorConfig>(\n selector: SelectorFn<T>,\n): ValidateMiddleware<T>;\n/** Enforce a content type before validating the selected request values. */\nexport function validate<T extends ValidatorConfig>(\n expectedContentTypeOrSelector: ContentType,\n selector: SelectorFn<T>,\n): ValidateMiddleware<T>;\nexport function validate<T extends ValidatorConfig>(\n expectedContentTypeOrSelector: ContentType | SelectorFn<T>,\n selector?: SelectorFn<T>,\n): ValidateMiddleware<T> {\n const expectedContentType =\n typeof expectedContentTypeOrSelector === 'string'\n ? expectedContentTypeOrSelector\n : undefined;\n const _selector =\n typeof expectedContentTypeOrSelector === 'function'\n ? expectedContentTypeOrSelector\n : selector;\n if (!_selector) {\n throw new Error('Selector function is required');\n }\n\n return createMiddleware(async (c, next) => {\n const ct = c.req.header('content-type');\n if (c.req.method === 'GET' && ct) {\n throw new HTTPException(415, {\n message: 'Unsupported Media Type',\n cause: {\n code: 'api/unsupported-media-type',\n detail: `GET requests cannot have a content type header`,\n },\n });\n }\n if (expectedContentType) {\n verifyContentType(ct, expectedContentType);\n }\n\n const contentType = ct ? parseContentType(ct) : null;\n let body: unknown = null;\n\n switch (contentType?.type) {\n case 'application/json':\n try {\n body = await c.req.json();\n } catch {\n throw new HTTPException(400, {\n message: 'Invalid JSON body',\n cause: {\n code: 'api/invalid-json',\n detail: 'Request body must be valid JSON.',\n },\n });\n }\n break;\n case 'application/x-www-form-urlencoded':\n case 'multipart/form-data':\n body = await c.req.parseBody({ all: true });\n break;\n default:\n body = {};\n }\n\n const payload = {\n body: fieldMarkers('body'),\n query: fieldMarkers('query'),\n queries: fieldMarkers('queries'),\n params: fieldMarkers('params'),\n headers: fieldMarkers('headers'),\n };\n const sources: Record<\n Exclude<FieldSource, 'body'>,\n Record<string, string | string[] | undefined>\n > = {\n query: c.req.query(),\n queries: c.req.queries(),\n params: c.req.param(),\n headers: c.req.header(),\n };\n const read = (select: unknown) => {\n if (select === payload.body) return body;\n if (!isFieldMarker(select)) return select;\n if (select.validationTarget !== 'body') {\n return sources[select.validationTarget][select.name];\n }\n // Whole-body schemas may accept any JSON value; a field selector requires an object.\n if (!isRecord(body)) {\n throw new HTTPException(400, {\n message: 'Invalid request body',\n cause: {\n code: 'api/invalid-body',\n detail: 'Request body must be an object when selecting fields.',\n },\n });\n }\n return body[select.name];\n };\n\n const config = _selector(payload);\n const schema = z.object(\n Object.fromEntries(\n Object.entries(config).map(([key, value]) => [key, value.against]),\n ),\n );\n const input = Object.fromEntries(\n Object.entries(config).map(([key, value]) => [key, read(value.select)]),\n );\n\n const parsed = await parse(schema, input);\n c.set('input', parsed as ExtractInput<T>);\n await next();\n });\n}\n\n/** Parse any Zod schema asynchronously, throwing a structured HTTP 400 on rejection. */\nexport async function parse<T extends z.ZodType>(\n schema: T,\n input: unknown,\n): Promise<z.output<T>> {\n const result = await schema.safeParseAsync(input);\n if (!result.success) {\n const { fieldErrors, formErrors } = z.flattenError(\n result.error,\n (issue) => ({\n message: issue.message,\n code: issue.code,\n path: issue.path.join('.'),\n }),\n );\n const error = new HTTPException(400, {\n message: 'Validation failed',\n cause: {\n code: 'api/validation-failed',\n detail: 'The input data is invalid',\n errors: fieldErrors,\n formErrors,\n },\n });\n throw error;\n }\n return result.data;\n}\n\nexport const openapi = validate;\n\n/** Enforce a request content type without reading or validating its body. */\nexport const consume = (contentType: ContentType) => {\n return createMiddleware(async (context, next) => {\n verifyContentType(context.req.header('content-type'), contentType);\n await next();\n });\n};\n\nfunction parseContentType(header: string) {\n const contentType = safeParse(header);\n if (!contentType.type) {\n throw new HTTPException(415, {\n message: 'Unsupported Media Type',\n cause: {\n code: 'api/unsupported-media-type',\n detail: 'Invalid content type header',\n },\n });\n }\n return contentType;\n}\n\nexport function verifyContentType(\n actual: string | undefined,\n expected: ContentType,\n): asserts actual is ContentType {\n if (!actual) {\n throw new HTTPException(415, {\n message: 'Unsupported Media Type',\n cause: {\n code: 'api/unsupported-media-type',\n detail: 'Missing content type header',\n },\n });\n }\n const { type: incomingContentType } = parseContentType(actual);\n if (incomingContentType !== expected) {\n throw new HTTPException(415, {\n message: 'Unsupported Media Type',\n cause: {\n code: 'api/unsupported-media-type',\n detail: `Expected content type: ${expected}, but got: ${incomingContentType}`,\n },\n });\n }\n}\n"],
5
+ "mapp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,oBAAoB,IAAI,iBAAiB,MAAM;AAC7D,MAAI,wBAAwB,UAAU;AACpC,UAAM,IAAI,cAAc,KAAK;AAAA,MAC3B,SAAS;AAAA,MACT,OAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ,0BAA0B,QAAQ,cAAc,mBAAmB;AAAA,MAC7E;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,11 +1,12 @@
1
1
  import type { Context } from 'hono';
2
+ import type { RedirectStatusCode } from 'hono/utils/http-status';
2
3
  type Data = any;
3
4
  export declare function createOutput(contextFn: () => Context): {
4
5
  nocontent(): Response & import("hono").TypedResponse<null, 204, "body">;
5
6
  ok(value: Data | undefined | null, headers?: Record<string, string>): Response & import("hono").TypedResponse<any, -1 | 100 | 102 | 103 | 200 | 201 | 202 | 203 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511, "body">;
6
7
  created(valueOrUri: string | Data, value: Data | undefined | null, headers?: Record<string, string>): Response & import("hono").TypedResponse<any, -1 | 100 | 102 | 103 | 200 | 201 | 202 | 203 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511, "body">;
7
- redirect(uri: string | URL, statusCode?: unknown): Response & import("hono").TypedResponse<undefined, 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308, "redirect">;
8
- attachment(buffer: Buffer, filename: string, mimeType: string): Response & import("hono").TypedResponse<never, 200, "body">;
8
+ redirect(uri: string | URL, statusCode?: RedirectStatusCode): Response & import("hono").TypedResponse<undefined, 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308, "redirect">;
9
+ attachment(buffer: Uint8Array<ArrayBuffer>, filename: string, mimeType: string): Response & import("hono").TypedResponse<Uint8Array<ArrayBuffer>, 200, "body">;
9
10
  badRequest(value: Data | undefined | null, headers?: Record<string, string>): Response & import("hono").TypedResponse<any, -1 | 100 | 102 | 103 | 200 | 201 | 202 | 203 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511, "body">;
10
11
  unauthorized(value: Data | undefined | null, headers?: Record<string, string>): Response & import("hono").TypedResponse<any, -1 | 100 | 102 | 103 | 200 | 201 | 202 | 203 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511, "body">;
11
12
  forbidden(value: Data | undefined | null, headers?: Record<string, string>): Response & import("hono").TypedResponse<any, -1 | 100 | 102 | 103 | 200 | 201 | 202 | 203 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511, "body">;
@@ -21,8 +22,8 @@ export declare const output: {
21
22
  nocontent(): Response & import("hono").TypedResponse<null, 204, "body">;
22
23
  ok(value: Data | undefined | null, headers?: Record<string, string>): Response & import("hono").TypedResponse<any, -1 | 100 | 102 | 103 | 200 | 201 | 202 | 203 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511, "body">;
23
24
  created(valueOrUri: string | Data, value: Data | undefined | null, headers?: Record<string, string>): Response & import("hono").TypedResponse<any, -1 | 100 | 102 | 103 | 200 | 201 | 202 | 203 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511, "body">;
24
- redirect(uri: string | URL, statusCode?: unknown): Response & import("hono").TypedResponse<undefined, 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308, "redirect">;
25
- attachment(buffer: Buffer, filename: string, mimeType: string): Response & import("hono").TypedResponse<never, 200, "body">;
25
+ redirect(uri: string | URL, statusCode?: RedirectStatusCode): Response & import("hono").TypedResponse<undefined, 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308, "redirect">;
26
+ attachment(buffer: Uint8Array<ArrayBuffer>, filename: string, mimeType: string): Response & import("hono").TypedResponse<Uint8Array<ArrayBuffer>, 200, "body">;
26
27
  badRequest(value: Data | undefined | null, headers?: Record<string, string>): Response & import("hono").TypedResponse<any, -1 | 100 | 102 | 103 | 200 | 201 | 202 | 203 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511, "body">;
27
28
  unauthorized(value: Data | undefined | null, headers?: Record<string, string>): Response & import("hono").TypedResponse<any, -1 | 100 | 102 | 103 | 200 | 201 | 202 | 203 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511, "body">;
28
29
  forbidden(value: Data | undefined | null, headers?: Record<string, string>): Response & import("hono").TypedResponse<any, -1 | 100 | 102 | 103 | 200 | 201 | 202 | 203 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511, "body">;
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EA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e,IAAI,iBAAiB,CACpE;IACE,SAAS,EAAE;QACT,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;KACxB,CAAC;CACH,EACD,MAAM,EACN;IAAE,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;CAAE,CACnB,CAAC;AAEF,wFAAwF;AACxF,wBAAgB,QAAQ,CAAC,CAAC,SAAS,eAAe,EAChD,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,GACtB,kBAAkB,CAAC,CAAC,CAAC,CAAC;AACzB,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,CAAC,SAAS,eAAe,EAChD,6BAA6B,EAAE,WAAW,EAC1C,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,GACtB,kBAAkB,CAAC,CAAC,CAAC,CAAC;AA4GzB,wFAAwF;AACxF,wBAAsB,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAC7C,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAuBtB;AAED,eAAO,MAAM,OAAO,iBAAW,CAAC;AAEhC,6EAA6E;AAC7E,eAAO,MAAM,OAAO,gBAAiB,WAAW,iDAK/C,CAAC;AAgBF,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,IAAI,WAAW,CAoB/B"}
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "name": "@sdk-it/hono",
3
- "version": "0.46.11",
3
+ "version": "0.47.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/JanuaryLabs/sdk-it",
7
+ "directory": "packages/hono"
8
+ },
9
+ "bugs": {
10
+ "url": "https://github.com/JanuaryLabs/sdk-it/issues"
11
+ },
12
+ "homepage": "https://github.com/JanuaryLabs/sdk-it/tree/main/packages/hono#readme",
4
13
  "type": "module",
5
14
  "main": "./dist/index.js",
6
15
  "module": "./dist/index.js",
@@ -22,6 +31,11 @@
22
31
  },
23
32
  "import": "./dist/lib/runtime/index.js",
24
33
  "default": "./dist/lib/runtime/index.js"
34
+ },
35
+ "./evlog": {
36
+ "types": "./dist/lib/evlog.d.ts",
37
+ "import": "./dist/lib/evlog.js",
38
+ "default": "./dist/lib/evlog.js"
25
39
  }
26
40
  },
27
41
  "files": [
@@ -31,20 +45,21 @@
31
45
  "!**/*.test.*"
32
46
  ],
33
47
  "dependencies": {
34
- "@sdk-it/core": "0.46.11",
48
+ "@sdk-it/core": "0.47.0",
35
49
  "hono": "^4.7.4",
36
- "zod": "^4.3.0",
50
+ "zod": "^4.6.7",
37
51
  "fast-content-type-parse": "^3.0.0"
38
52
  },
39
53
  "peerDependencies": {
40
- "typescript": "^6.0.3"
54
+ "@typescript/native": "npm:typescript@7.1.0-beta",
55
+ "openapi3-ts": "^4.6.2"
41
56
  },
42
57
  "peerDependenciesMeta": {
43
- "typescript": {
58
+ "@typescript/native": {
59
+ "optional": true
60
+ },
61
+ "openapi3-ts": {
44
62
  "optional": true
45
63
  }
46
- },
47
- "devDependencies": {
48
- "@types/debug": "^4.1.12"
49
64
  }
50
65
  }
@@ -48,17 +48,17 @@ export function createOutput(contextFn: () => Context) {
48
48
  return send(contextFn(), valueOrUri, 201, headers);
49
49
  }
50
50
  },
51
- redirect(uri: string | URL, statusCode?: unknown) {
51
+ redirect(uri: string | URL, statusCode?: RedirectStatusCode) {
52
52
  const context = contextFn();
53
- return context.redirect(
54
- uri.toString(),
55
- (statusCode as RedirectStatusCode) ?? undefined,
56
- );
53
+ return context.redirect(uri.toString(), statusCode);
57
54
  },
58
- attachment(buffer: Buffer, filename: string, mimeType: string) {
55
+ attachment(
56
+ buffer: Uint8Array<ArrayBuffer>,
57
+ filename: string,
58
+ mimeType: string,
59
+ ) {
59
60
  const context = contextFn();
60
- // https://github.com/honojs/hono/issues/3720
61
- return context.body(buffer as never, 200, {
61
+ return context.body(buffer, 200, {
62
62
  'Content-Type': mimeType,
63
63
  'Content-Disposition': `attachment; filename="${filename}"`,
64
64
  'Content-Length': buffer.length.toString(),