mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 06:51:11 +00:00
e144d8dbc1
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>
27 lines
669 B
TypeScript
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>;
|