Skip to content

Commit ea2ba36

Browse files
committed
feat: narrow generated types and validators to the real data contract
Three schema cases previously emitted types wider than the data they describe, weakening consumer type-safety and runtime validation: - RFC 3339 string formats (date, date-time, time, duration) now emit template-literal types plus matching regex validators. Previously only date-time was handled, and as the opaque Jsonify<Date>. - integer/int64 now maps to bigint, since its range exceeds Number.MAX_SAFE_INTEGER and number would silently lose precision. - enums short-circuit all type-specific constraints and emit a bare picklist/literal/union, including null and non-string members. Layering string()/minLength() on an enum produced misleading "expected string" errors when the contract is simply "one of [...]". BREAKING: emitted types change for the single consumer. DateTime is now a template-literal string instead of Jsonify<Date>, and int64 fields are bigint instead of number; both require consumer updates.
1 parent 9a3315d commit ea2ba36

31 files changed

Lines changed: 934 additions & 623 deletions

__tests__/__snapshots__/nullables.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ exports[`header parameters 1`] = `
2828
export type UploadStatus = "pending" | "complete";
2929
export type UploadDataCommandHeader = {
3030
"content-type": "application/json" | "text/csv" | "application/xml";
31-
"content-length": \`\${number}\`;
31+
"content-length": \`\${bigint}\`;
3232
"x-idempotency-key"?: string;
3333
};
3434
export type UploadDataCommandParams = {
@@ -144,9 +144,9 @@ exports[`query and header integer params coerce strings to numbers 1`] = `
144144
"import type { UndefinedOnPartialDeep } from "type-fest";
145145
146146
export type Dummy = string;
147-
export type ExpireTime = number;
147+
export type ExpireTime = bigint;
148148
export type ListFilesCommandQuery = {
149-
exp: \`\${number}\`;
149+
exp: \`\${bigint}\`;
150150
limit?: \`\${number}\`;
151151
};
152152
export type ListFilesCommandHeader = {

__tests__/fixtures/docker/commands-validated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* WARN: Do not edit directly.
55
*
6-
* Generated on 2026-06-08T01:23:59.032Z
6+
* Generated on 2026-06-09T09:18:39.851Z
77
*
88
*/
99
/** eslint-disable max-classes */

__tests__/fixtures/docker/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* WARN: Do not edit directly.
55
*
6-
* Generated on 2026-06-08T01:23:59.032Z
6+
* Generated on 2026-06-09T09:18:39.851Z
77
*
88
*/
99
/** eslint-disable max-classes */

__tests__/fixtures/docker/enums.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* WARN: Do not edit directly.
55
*
6-
* Generated on 2026-06-08T01:23:59.032Z
6+
* Generated on 2026-06-09T09:18:39.851Z
77
*
88
*/
99
/**

__tests__/fixtures/docker/hono-valibot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { PublicValibotHonoError } from "@block65/rest-client";
44
*
55
* WARN: Do not edit directly.
66
*
7-
* Generated on 2026-06-08T01:23:59.032Z
7+
* Generated on 2026-06-09T09:18:39.851Z
88
*
99
*/
1010
import { validator } from "hono/validator";

__tests__/fixtures/docker/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* WARN: Do not edit directly.
55
*
6-
* Generated on 2026-06-08T01:23:59.032Z
6+
* Generated on 2026-06-09T09:18:39.851Z
77
*
88
*/
99
import {

0 commit comments

Comments
 (0)