mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-24 22:48:06 +00:00
c0501194c0
* fix(datasource/gitlab-packages): replace getJsonUnchecked with validated getJson Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(datasource/gitlab-packages): use LooseArray and drop types.ts Apply review feedback: tolerate malformed entries via LooseArray, remove the now unused types.ts, use the fetchJson base helper and cover the failed validation paths. * fix(datasource/gitlab-packages): accept null for optional fields Wrap the package schema in DeepNullish so a null conan_package_name validates like an absent one. * refactor(datasource/gitlab-packages): map releases in schema transform --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
27 lines
768 B
TypeScript
27 lines
768 B
TypeScript
import { z } from 'zod/v4';
|
|
import { DeepNullish, LooseArray } from '../../../util/schema-utils/index.ts';
|
|
import { asTimestamp } from '../../../util/timestamp.ts';
|
|
import type { Release } from '../types.ts';
|
|
|
|
export const GitlabPackage = DeepNullish(
|
|
z.object({
|
|
version: z.string(),
|
|
created_at: z.string(),
|
|
name: z.string(),
|
|
conan_package_name: z.string().optional(),
|
|
}),
|
|
).transform(
|
|
({
|
|
version,
|
|
created_at,
|
|
name,
|
|
conan_package_name,
|
|
}): { packageName: string; release: Release } => ({
|
|
packageName: conan_package_name ?? name,
|
|
release: { version, releaseTimestamp: asTimestamp(created_at) },
|
|
}),
|
|
);
|
|
export type GitlabPackage = z.infer<typeof GitlabPackage>;
|
|
|
|
export const GitlabPackages = LooseArray(GitlabPackage);
|