From cdc23848819033fe294bf037dd815d14b5a9ce74 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Thu, 5 Feb 2026 16:17:05 +0100 Subject: [PATCH] fix: inconsistent bigint vs number in zod and schema heyapi is doing something weird with bigints. Using just number for now. --- package-lock.json | 60 +++++++++++++------------- package.json | 4 +- scripts/generate.js | 6 ++- src/schema/types.gen.ts | 22 +++++----- src/schema/zod.gen.ts | 93 +++++------------------------------------ 5 files changed, 59 insertions(+), 126 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7e5a5db..8cd4c95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "0.14.0", "license": "Apache-2.0", "devDependencies": { - "@hey-api/openapi-ts": "^0.91.1", - "@types/node": "^25.2.0", + "@hey-api/openapi-ts": "^0.92.3", + "@types/node": "^25.2.1", "@typescript-eslint/eslint-plugin": "^8.54.0", "@typescript-eslint/parser": "^8.54.0", "concurrently": "^9.2.1", @@ -675,9 +675,9 @@ } }, "node_modules/@hey-api/codegen-core": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/@hey-api/codegen-core/-/codegen-core-0.6.1.tgz", - "integrity": "sha512-khTIpxhKEAqmRmeLUnAFJQs4Sbg9RPokovJk9rRcC8B5MWH1j3/BRSqfpAIiJUBDU1+nbVg2RVCV+eQ174cdvw==", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@hey-api/codegen-core/-/codegen-core-0.7.0.tgz", + "integrity": "sha512-HglL4B4QwpzocE+c8qDU6XK8zMf8W8Pcv0RpFDYxHuYALWLTnpDUuEsglC7NQ4vC1maoXsBpMbmwpco0N4QviA==", "dev": true, "license": "MIT", "dependencies": { @@ -697,16 +697,16 @@ } }, "node_modules/@hey-api/json-schema-ref-parser": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/@hey-api/json-schema-ref-parser/-/json-schema-ref-parser-1.2.3.tgz", - "integrity": "sha512-gRbyyTjzpFVNmbD+Upn3w4dWV+bCXGJbff3A7leDO/tfNxSz1xIb6Ad/5UKtvEW9kDt/2Uyc3XkFZ6rpafvbfQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@hey-api/json-schema-ref-parser/-/json-schema-ref-parser-1.2.4.tgz", + "integrity": "sha512-uuOaZ6tStUgRJFUqnX3Xdbs792++ezxOLI5NMxuikVklpbFWk2wcvIZbeX+qTWDv6kiS1Ik2EVKQgeQFWHML4A==", "dev": true, "license": "MIT", "dependencies": { "@jsdevtools/ono": "^7.1.3", "@types/json-schema": "^7.0.15", "js-yaml": "^4.1.1", - "lodash": "^4.17.21" + "lodash": "^4.17.23" }, "engines": { "node": ">= 16" @@ -716,19 +716,19 @@ } }, "node_modules/@hey-api/openapi-ts": { - "version": "0.91.1", - "resolved": "https://registry.npmjs.org/@hey-api/openapi-ts/-/openapi-ts-0.91.1.tgz", - "integrity": "sha512-d16WR35UtthK/ihAIwJaKxrj/zvb5LbYwtVJCyZFFMin2qzDU8Y3Lpk78ensAykrLoaDLzpd0iIyt9JCP5Qmww==", + "version": "0.92.3", + "resolved": "https://registry.npmjs.org/@hey-api/openapi-ts/-/openapi-ts-0.92.3.tgz", + "integrity": "sha512-D+2ySL+PXvp1iZtS+1gTEeGChwjHT3d/a6o9IwAaNdGJVsI1lPqESZx7vxqjoUtE/DruovGZC2/jPc/kA5IQPg==", "dev": true, "license": "MIT", "dependencies": { - "@hey-api/codegen-core": "0.6.1", - "@hey-api/json-schema-ref-parser": "1.2.3", - "@hey-api/shared": "0.1.1", + "@hey-api/codegen-core": "0.7.0", + "@hey-api/json-schema-ref-parser": "1.2.4", + "@hey-api/shared": "0.1.2", "@hey-api/types": "0.1.3", "ansi-colors": "4.1.3", "color-support": "1.1.3", - "commander": "14.0.2" + "commander": "14.0.3" }, "bin": { "openapi-ts": "bin/run.js" @@ -744,14 +744,14 @@ } }, "node_modules/@hey-api/shared": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@hey-api/shared/-/shared-0.1.1.tgz", - "integrity": "sha512-/irgNGXw9TL5aKB3S7jCLgh07vgDFkYjSjz7vEWO9xEe6MUhx76zSFzkPspk2UrLghYayvmaKPf1ky4XjNI9ZQ==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@hey-api/shared/-/shared-0.1.2.tgz", + "integrity": "sha512-dcldulfNI1xiXl/zhdXKDlNX2bvY0TOBWRRyFXNtcfPddMEFcrlXGmi/wk6LN4fPyDO8lM7FAM9aEpkEdUo92A==", "dev": true, "license": "MIT", "dependencies": { - "@hey-api/codegen-core": "0.6.1", - "@hey-api/json-schema-ref-parser": "1.2.3", + "@hey-api/codegen-core": "0.7.0", + "@hey-api/json-schema-ref-parser": "1.2.4", "@hey-api/types": "0.1.3", "ansi-colors": "4.1.3", "cross-spawn": "7.0.6", @@ -1293,9 +1293,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "25.2.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.2.0.tgz", - "integrity": "sha512-DZ8VwRFUNzuqJ5khrvwMXHmvPe+zGayJhr2CDNiKB1WBE1ST8Djl00D0IC4vvNmHMdj6DlbYRIaFE7WHjlDl5w==", + "version": "25.2.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.2.1.tgz", + "integrity": "sha512-CPrnr8voK8vC6eEtyRzvMpgp3VyVRhgclonE7qYi6P9sXwYb59ucfrnmFBTaP0yUi8Gk4yZg/LlTJULGxvTNsg==", "dev": true, "license": "MIT", "peer": true, @@ -1984,9 +1984,9 @@ } }, "node_modules/commander": { - "version": "14.0.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.2.tgz", - "integrity": "sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ==", + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.3.tgz", + "integrity": "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==", "dev": true, "license": "MIT", "engines": { @@ -2753,9 +2753,9 @@ } }, "node_modules/get-tsconfig": { - "version": "4.13.1", - "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.1.tgz", - "integrity": "sha512-EoY1N2xCn44xU6750Sx7OjOIT59FkmstNc3X6y5xpz7D5cBtZRe/3pSlTkDJgqsOk3WwZPkWfonhhUJfttQo3w==", + "version": "4.13.3", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.3.tgz", + "integrity": "sha512-vp8Cj/+9Q/ibZUrq1rhy8mCTQpCk31A3uu9wc1C50yAb3x2pFHOsGdAZQ7jD86ARayyxZUViYeIztW+GE8dcrg==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index a692101..7b4f361 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,8 @@ "zod": "^3.25.0 || ^4.0.0" }, "devDependencies": { - "@hey-api/openapi-ts": "^0.91.1", - "@types/node": "^25.2.0", + "@hey-api/openapi-ts": "^0.92.3", + "@types/node": "^25.2.1", "@typescript-eslint/eslint-plugin": "^8.54.0", "@typescript-eslint/parser": "^8.54.0", "concurrently": "^9.2.1", diff --git a/scripts/generate.js b/scripts/generate.js index 2667027..efced26 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -35,7 +35,11 @@ async function main() { path: "./src/schema", postProcess: ["prettier"], }, - plugins: ["@hey-api/transformers", "@hey-api/typescript", "zod"], + plugins: [ + "zod", + { bigInt: false, name: "@hey-api/transformers" }, + "@hey-api/typescript", + ], }); const zodPath = "./src/schema/zod.gen.ts"; diff --git a/src/schema/types.gen.ts b/src/schema/types.gen.ts index 0bc9422..b6104f4 100644 --- a/src/schema/types.gen.ts +++ b/src/schema/types.gen.ts @@ -553,7 +553,7 @@ export type CreateTerminalRequest = { * string output, even if this means the retained output is slightly less than the * specified limit. */ - outputByteLimit?: bigint | null; + outputByteLimit?: number | null; /** * The session ID for this request. */ @@ -1781,7 +1781,7 @@ export type ReleaseTerminalResponse = { * * [2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions. */ -export type RequestId = null | bigint | string; +export type RequestId = null | number | string; /** * The outcome of a permission request. @@ -1864,7 +1864,7 @@ export type ResourceLink = { description?: string | null; mimeType?: string | null; name: string; - size?: bigint | null; + size?: number | null; title?: string | null; uri: string; }; @@ -2964,27 +2964,27 @@ export type Usage = { /** * Total cache read tokens. */ - cachedReadTokens?: bigint | null; + cachedReadTokens?: number | null; /** * Total cache write tokens. */ - cachedWriteTokens?: bigint | null; + cachedWriteTokens?: number | null; /** * Total input tokens across all turns. */ - inputTokens: bigint; + inputTokens: number; /** * Total output tokens across all turns. */ - outputTokens: bigint; + outputTokens: number; /** * Total thought/reasoning tokens */ - thoughtTokens?: bigint | null; + thoughtTokens?: number | null; /** * Sum of all token types across session. */ - totalTokens: bigint; + totalTokens: number; }; /** @@ -3014,11 +3014,11 @@ export type UsageUpdate = { /** * Total context window size in tokens. */ - size: bigint; + size: number; /** * Tokens currently in context. */ - used: bigint; + used: number; }; /** diff --git a/src/schema/zod.gen.ts b/src/schema/zod.gen.ts index 935c520..055de7e 100644 --- a/src/schema/zod.gen.ts +++ b/src/schema/zod.gen.ts @@ -476,18 +476,7 @@ export const zReleaseTerminalResponse = z.object({ * * [2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions. */ -export const zRequestId = z.union([ - z.null(), - z.coerce - .bigint() - .min(BigInt("-9223372036854775808"), { - message: "Invalid value: Expected int64 to be >= -9223372036854775808", - }) - .max(BigInt("9223372036854775807"), { - message: "Invalid value: Expected int64 to be <= 9223372036854775807", - }), - z.string(), -]); +export const zRequestId = z.union([z.null(), z.number(), z.string()]); /** * **UNSTABLE** @@ -550,20 +539,7 @@ export const zResourceLink = z.object({ description: z.union([z.string(), z.null()]).optional(), mimeType: z.union([z.string(), z.null()]).optional(), name: z.string(), - size: z - .union([ - z.coerce - .bigint() - .min(BigInt("-9223372036854775808"), { - message: - "Invalid value: Expected int64 to be >= -9223372036854775808", - }) - .max(BigInt("9223372036854775807"), { - message: "Invalid value: Expected int64 to be <= 9223372036854775807", - }), - z.null(), - ]) - .optional(), + size: z.union([z.number(), z.null()]).optional(), title: z.union([z.string(), z.null()]).optional(), uri: z.string(), }); @@ -742,14 +718,7 @@ export const zCreateTerminalRequest = z.object({ command: z.string(), cwd: z.union([z.string(), z.null()]).optional(), env: z.array(zEnvVariable).optional(), - outputByteLimit: z - .union([ - z.coerce.bigint().gte(BigInt(0)).max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - z.null(), - ]) - .optional(), + outputByteLimit: z.union([z.number(), z.null()]).optional(), sessionId: zSessionId, }); @@ -1534,48 +1503,12 @@ export const zAvailableCommandsUpdate = z.object({ * @experimental */ export const zUsage = z.object({ - cachedReadTokens: z - .union([ - z.coerce.bigint().gte(BigInt(0)).max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - z.null(), - ]) - .optional(), - cachedWriteTokens: z - .union([ - z.coerce.bigint().gte(BigInt(0)).max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - z.null(), - ]) - .optional(), - inputTokens: z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - outputTokens: z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - thoughtTokens: z - .union([ - z.coerce.bigint().gte(BigInt(0)).max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - z.null(), - ]) - .optional(), - totalTokens: z.coerce - .bigint() - .gte(BigInt(0)) - .max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), + cachedReadTokens: z.union([z.number(), z.null()]).optional(), + cachedWriteTokens: z.union([z.number(), z.null()]).optional(), + inputTokens: z.number(), + outputTokens: z.number(), + thoughtTokens: z.union([z.number(), z.null()]).optional(), + totalTokens: z.number(), }); /** @@ -1625,12 +1558,8 @@ export const zAgentResponse = z.union([ export const zUsageUpdate = z.object({ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(), cost: z.union([zCost, z.null()]).optional(), - size: z.coerce.bigint().gte(BigInt(0)).max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), - used: z.coerce.bigint().gte(BigInt(0)).max(BigInt("18446744073709551615"), { - message: "Invalid value: Expected uint64 to be <= 18446744073709551615", - }), + size: z.number(), + used: z.number(), }); /**