Files
Sebastian Poxhofer 3ed45d1efd refactor(misc): remove getJsonUnchecked usages (#43696)
* fix(datasource): replace getJsonUnchecked with validated getJson in misc+merge-confidence group

Replaces all getJsonUnchecked calls with Zod-validated getJson calls in:
- crate: adds CrateMetadataSchema to existing schema.ts
- conan: uses existing ConanJSON schema directly
- puppet-forge: new schema.ts with PuppetModuleSchema
- conda: new schema.ts with CondaPackageSchema
- repology: new schema.ts with RepologyPackagesSchema
- jenkins-plugins: new schema.ts, parameterizes helper with ZodType<T>
- custom/formats/json: uses z.unknown() for user-defined responses
- merge-confidence: adds inline MergeConfidenceResponseSchema

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: correct nullable/optional schema fields for crate, jenkins-plugins, puppet-forge

- crate: remove .optional() from all CrateMetadata fields to match string|null type
- jenkins-plugins: use .default({}) instead of .optional() for plugins fields so schemas match required Record types; widen ZodType input to unknown; update JenkinsPluginVersion.releaseTimestamp to Timestamp|null to match MaybeTimestamp output
- puppet-forge: change releases from .optional() to .default([]) to match Release[] type

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: migrate zod/v3 imports to zod/v4 in misc datasources and merge-confidence

Update remaining zod/v3 imports in files added/modified by the getJsonUnchecked
migration to use zod/v4 as required after the upstream migration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore minor improvements

* remove unnecessary types and reintroduce nullable where necessary

* refactor: move logic into transform

* test: add tests to improve coverage

* chore removed some unused types

* remove type declaration

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-03 15:58:20 +00:00

33 lines
957 B
TypeScript

import { z } from 'zod/v4';
import { MaybeTimestamp } from '../../../util/timestamp.ts';
export const JenkinsPluginInfo = z.object({
name: z.string(),
scm: z.string().optional(),
});
export const JenkinsPluginsInfoResponse = z.object({
plugins: z.record(z.string(), JenkinsPluginInfo).default({}),
});
export type JenkinsPluginsInfoResponse = z.infer<
typeof JenkinsPluginsInfoResponse
>;
export const JenkinsPluginVersion = z.object({
version: z.string(),
buildDate: z.string().optional(),
url: z.string().optional(),
requiredCore: z.string().optional(),
releaseTimestamp: MaybeTimestamp.optional(),
});
export type JenkinsPluginVersion = z.infer<typeof JenkinsPluginVersion>;
export const JenkinsPluginsVersionsResponse = z.object({
plugins: z
.record(z.string(), z.record(z.string(), JenkinsPluginVersion))
.default({}),
});
export type JenkinsPluginsVersionsResponse = z.infer<
typeof JenkinsPluginsVersionsResponse
>;