Files
Michael Kriese e144d8dbc1 fix(http): validate the cached response shape in the http cache schema (#46417)
refactor(http): validate the cached response shape in the http cache schema

Co-authored-by: Claude Fable 5.1 <michael.kriese+claude-code@mend.io>
2026-09-23 14:12:16 +00:00

27 lines
669 B
TypeScript

import { z } from 'zod/v4';
const HttpCacheHeaders = z.record(
z.string(),
z.union([z.string(), z.array(z.string())]).optional(),
);
export const HttpCacheResponse = z.object({
statusCode: z.number(),
headers: HttpCacheHeaders,
body: z.unknown(),
authorization: z.boolean().optional(),
cached: z.boolean().optional(),
});
export type HttpCacheResponse = z.infer<typeof HttpCacheResponse>;
export const HttpCache = z
.object({
etag: z.string().optional(),
lastModified: z.string().optional(),
httpResponse: HttpCacheResponse,
timestamp: z.string(),
})
.nullable()
.catch(null);
export type HttpCache = z.infer<typeof HttpCache>;