Files
renovate/lib/util/github/graphql/query-adapters/branches-query-adapter.ts
Sebastian Poxhofer 15f4bd8eff chore: migrate from zod/v3 to zod/v4 (#43691)
* 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
2026-05-30 16:01:58 +00:00

59 lines
1.3 KiB
TypeScript

import { z } from 'zod/v4';
import { Timestamp } from '../../../timestamp.ts';
import type {
GithubBranchItem,
GithubGraphqlDatasourceAdapter,
} from '../types.ts';
import { prepareQuery } from '../util.ts';
const key = 'github-branches-datasource-v1';
const GithubGraphqlBranch = z.object({
version: z.string(),
target: z.object({
type: z.literal('Commit'),
oid: z.string(),
releaseTimestamp: Timestamp,
}),
});
export type GithubGraphqlBranch = z.infer<typeof GithubGraphqlBranch>;
const query = prepareQuery(`
refs(
first: $count
after: $cursor
refPrefix: "refs/heads/"
) {
pageInfo {
hasNextPage
endCursor
}
nodes {
version: name
target {
type: __typename
... on Commit {
oid
releaseTimestamp: committedDate
}
}
}
}`);
function transform(item: GithubGraphqlBranch): GithubBranchItem | null {
const res = GithubGraphqlBranch.safeParse(item);
if (!res.success) {
return null;
}
const { version, target } = item;
const releaseTimestamp = target.releaseTimestamp;
const hash = target.oid;
return { version, gitRef: version, hash, releaseTimestamp };
}
export const adapter: GithubGraphqlDatasourceAdapter<
GithubGraphqlBranch,
GithubBranchItem
> = { key, query, transform, maxItems: 300 };