Replace the deprecated v3 string-method forms with the top-level
validator helpers zod 4 prefers:
- z.string().url() → z.url() (3 sites)
- z.string().uuid() → z.uuid() (5 sites)
- z.string().datetime() → z.iso.datetime() (9 sites)
Also swap the ZodIssueCode.custom compat-shim reference in
demo-bot.server.ts's superRefine for the bare string literal "custom",
which is v4's idiomatic form. No runtime change.
All 147 tests still pass.
The `parsed.error.issues.map(i => ({field, message}))` pattern in the
five journal API route handlers stays as-is — the fields we read are
unchanged in v4, and zod's new error helpers (z.treeifyError,
z.prettifyError) produce different shapes that would change our
public API error contract.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const TokenExchangeRequestSchema = z.object({
|
|
grant_type: z.enum(["authorization_code", "refresh_token"]),
|
|
code: z.string().optional(),
|
|
code_verifier: z.string().optional(),
|
|
refresh_token: z.string().optional(),
|
|
client_id: z.string(),
|
|
redirect_uri: z.string().optional(),
|
|
device_name: z.string().max(100).optional(),
|
|
});
|
|
|
|
export const TokenResponseSchema = z.object({
|
|
access_token: z.string(),
|
|
refresh_token: z.string(),
|
|
token_type: z.literal("Bearer"),
|
|
expires_in: z.number(),
|
|
});
|
|
|
|
export const DeviceSchema = z.object({
|
|
id: z.string(),
|
|
deviceName: z.string().nullable(),
|
|
lastActiveAt: z.iso.datetime(),
|
|
createdAt: z.iso.datetime(),
|
|
isCurrent: z.boolean(),
|
|
});
|
|
|
|
export const DeviceListResponseSchema = z.object({
|
|
devices: z.array(DeviceSchema),
|
|
});
|
|
|
|
export type TokenExchangeRequest = z.infer<typeof TokenExchangeRequestSchema>;
|
|
export type TokenResponse = z.infer<typeof TokenResponseSchema>;
|
|
export type Device = z.infer<typeof DeviceSchema>;
|
|
export type DeviceListResponse = z.infer<typeof DeviceListResponseSchema>;
|