renovate/lib/modules/datasource/cdnjs/schema.ts

31 lines
635 B
TypeScript

import { z } from 'zod';
import type { Release } from '../types';
export const Homepage = z.string().optional().catch(undefined);
export const Repository = z
.object({
type: z.literal('git'),
url: z.string(),
})
.transform(({ url }) => url)
.optional()
.catch(undefined);
export const Versions = z
.string()
.transform((version): Release => ({ version }))
.array();
export const Sri = z.record(z.string());
export const CdnjsAPIVersionResponseSchema = z.object({
homepage: Homepage,
repository: Repository,
versions: Versions,
});
export const CdnjsAPISriResponseSchema = z.object({
sri: Sri,
});