mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-01 18:19:51 +00:00
15f4bd8eff
* chore: migrate from zod/v3 to zod/v4 This commit contains the logic changes * chore: migrate imports from zod/v3 to zod/v4 This contains import updates and adds explicit record keys as zod/v4 requires these now * ci: enforce usage of zod/v4
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { z } from 'zod/v4';
|
|
import { getSourceUrl as getGithubSourceUrl } from '../../../util/github/url.ts';
|
|
import { LooseArray } from '../../../util/schema-utils/index.ts';
|
|
import { MaybeTimestamp } from '../../../util/timestamp.ts';
|
|
import type { Release } from '../types.ts';
|
|
|
|
export const DenoApiTag = z.object({
|
|
kind: z.string(),
|
|
value: z.string(),
|
|
});
|
|
|
|
export const DenoAPIModuleResponse = z.object({
|
|
tags: LooseArray(DenoApiTag)
|
|
.transform((tags) => {
|
|
const record: Record<string, string> = {};
|
|
for (const { kind, value } of tags) {
|
|
record[kind] = value;
|
|
}
|
|
return record;
|
|
})
|
|
.catch({}),
|
|
versions: z.array(z.string()),
|
|
});
|
|
|
|
export const DenoAPIUploadOptions = z.object({
|
|
ref: z.string(),
|
|
type: z.union([z.literal('github'), z.unknown()]),
|
|
repository: z.string(),
|
|
subdir: z.string().optional(),
|
|
});
|
|
|
|
export const DenoAPIModuleVersionResponse = z
|
|
.object({
|
|
upload_options: DenoAPIUploadOptions,
|
|
uploaded_at: MaybeTimestamp,
|
|
version: z.string(),
|
|
})
|
|
.transform(
|
|
({ version, uploaded_at: releaseTimestamp, upload_options }): Release => {
|
|
let sourceUrl: string | undefined = undefined;
|
|
const { type, repository, ref: gitRef } = upload_options;
|
|
if (type === 'github') {
|
|
sourceUrl = getGithubSourceUrl(repository);
|
|
}
|
|
return {
|
|
version,
|
|
gitRef,
|
|
releaseTimestamp,
|
|
sourceUrl,
|
|
};
|
|
},
|
|
);
|