Skip to content

Commit 3211d56

Browse files
authored
refactor(zod): rename schema to match our best practices guide (renovatebot#37499)
1 parent c59727f commit 3211d56

File tree

101 files changed

+599
-612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+599
-612
lines changed

lib/modules/datasource/aws-eks-addon/schema.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@ import { z } from 'zod/v4';
22
import { regEx } from '../../../util/regex';
33
import { Json } from '../../../util/schema-utils/v4';
44

5-
export const EksAddonsFilterSchema = z.object({
6-
addonName: z.string().nonempty().regex(regEx('^[a-z0-9][a-z0-9-]*[a-z0-9]$')),
7-
kubernetesVersion: z
8-
.string()
9-
.regex(regEx('^(?<major>\\d+)\\.(?<minor>\\d+)$'))
10-
.optional(),
11-
default: z
12-
.union([z.boolean(), z.string().transform((value) => value === 'true')])
13-
.optional(),
14-
region: z.string().optional(),
15-
profile: z.string().optional(),
16-
});
5+
export const EksAddonsFilter = Json.pipe(
6+
z.object({
7+
addonName: z
8+
.string()
9+
.nonempty()
10+
.regex(regEx('^[a-z0-9][a-z0-9-]*[a-z0-9]$')),
11+
kubernetesVersion: z
12+
.string()
13+
.regex(regEx('^(?<major>\\d+)\\.(?<minor>\\d+)$'))
14+
.optional(),
15+
default: z
16+
.union([z.boolean(), z.string().transform((value) => value === 'true')])
17+
.optional(),
18+
region: z.string().optional(),
19+
profile: z.string().optional(),
20+
}),
21+
);
1722

18-
export type EksAddonsFilter = z.infer<typeof EksAddonsFilterSchema>;
19-
export const EksAddonsFilter = Json.pipe(EksAddonsFilterSchema);
23+
export type EksAddonsFilter = z.infer<typeof EksAddonsFilter>;

lib/modules/datasource/buildpacks-registry/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Result } from '../../../util/result';
66
import { Datasource } from '../datasource';
77
import { ReleasesConfig } from '../schema';
88
import type { GetReleasesConfig, Release, ReleaseResult } from '../types';
9-
import { BuildpacksRegistryResponseSchema } from './schema';
9+
import { BuildpacksRegistryResponse } from './schema';
1010

1111
export class BuildpacksRegistryDatasource extends Datasource {
1212
static readonly id = 'buildpacks-registry';
@@ -42,7 +42,7 @@ export class BuildpacksRegistryDatasource extends Datasource {
4242
packageName,
4343
);
4444

45-
return this.http.getJsonSafe(url, BuildpacksRegistryResponseSchema);
45+
return this.http.getJsonSafe(url, BuildpacksRegistryResponse);
4646
})
4747
.transform(({ versions, latest }): ReleaseResult => {
4848
const releases: Release[] = versions;

lib/modules/datasource/buildpacks-registry/schema.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BuildpacksRegistryResponseSchema } from './schema';
1+
import { BuildpacksRegistryResponse } from './schema';
22

33
describe('modules/datasource/buildpacks-registry/schema', () => {
44
it('parses buildpack-registry schema', () => {
@@ -26,7 +26,7 @@ describe('modules/datasource/buildpacks-registry/schema', () => {
2626
},
2727
],
2828
};
29-
expect(BuildpacksRegistryResponseSchema.parse(response)).toMatchObject({
29+
expect(BuildpacksRegistryResponse.parse(response)).toMatchObject({
3030
latest: {
3131
homepage: 'https://github.com/heroku/buildpacks-python',
3232
},

lib/modules/datasource/buildpacks-registry/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { z } from 'zod';
33
/**
44
* Response from registry.buildpacks.io
55
*/
6-
export const BuildpacksRegistryResponseSchema = z.object({
6+
export const BuildpacksRegistryResponse = z.object({
77
latest: z
88
.object({
99
homepage: z.string().optional(),

lib/modules/datasource/cdnjs/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ import type {
1313
Release,
1414
ReleaseResult,
1515
} from '../types';
16-
import {
17-
CdnjsAPISriResponseSchema,
18-
CdnjsAPIVersionResponseSchema,
19-
} from './schema';
16+
import { CdnjsAPISriResponse, CdnjsAPIVersionResponse } from './schema';
2017

2118
export class CdnjsDatasource extends Datasource {
2219
static readonly id = 'cdnjs';
@@ -50,7 +47,7 @@ export class CdnjsDatasource extends Datasource {
5047
return this.http.getJsonSafe(
5148
url,
5249
{ cacheProvider: memCacheProvider },
53-
CdnjsAPIVersionResponseSchema,
50+
CdnjsAPIVersionResponse,
5451
);
5552
})
5653
.transform(({ versions, homepage, repository }): ReleaseResult => {
@@ -100,7 +97,7 @@ export class CdnjsDatasource extends Datasource {
10097
.transform(({ registryUrl }) => {
10198
const url = `${registryUrl}libraries/${library}/${newValue}?fields=sri`;
10299

103-
return this.http.getJsonSafe(url, CdnjsAPISriResponseSchema);
100+
return this.http.getJsonSafe(url, CdnjsAPISriResponse);
104101
})
105102
.transform(({ sri }): string => {
106103
return sri?.[assetName];

lib/modules/datasource/cdnjs/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ export const Versions = z
1919

2020
export const Sri = z.record(z.string());
2121

22-
export const CdnjsAPIVersionResponseSchema = z.object({
22+
export const CdnjsAPIVersionResponse = z.object({
2323
homepage: Homepage,
2424
repository: Repository,
2525
versions: Versions,
2626
});
2727

28-
export const CdnjsAPISriResponseSchema = z.object({
28+
export const CdnjsAPISriResponse = z.object({
2929
sri: Sri,
3030
});

lib/modules/datasource/conda/prefix-dev.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { isNotNullOrUndefined } from '../../../util/array';
33
import type { Http } from '../../../util/http';
44
import { MaybeTimestamp } from '../../../util/timestamp';
55
import type { Release, ReleaseResult } from '../types';
6-
import { type File, PagedResponseSchema } from './schema/prefix-dev';
6+
import { type File, PagedResponse } from './schema/prefix-dev';
77

88
const MAX_PREFIX_DEV_GRAPHQL_PAGE = 100;
99

@@ -93,7 +93,7 @@ async function getPagedResponse(
9393
},
9494
},
9595
},
96-
PagedResponseSchema,
96+
PagedResponse,
9797
);
9898

9999
const currentPage = res.body.data.package?.variants;

lib/modules/datasource/conda/schema/prefix-dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const File = z.object({
1515

1616
export type File = z.infer<typeof File>;
1717

18-
export const PagedResponseSchema = z.object({
18+
export const PagedResponse = z.object({
1919
data: z.object({
2020
package: z
2121
.object({

lib/modules/datasource/cpan/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { CpanRelease } from './types';
66
/**
77
* https://fastapi.metacpan.org/v1/file/_mapping
88
*/
9-
const MetaCpanApiFileSchema = z
9+
const MetaCpanApiFile = z
1010
.object({
1111
module: LooseArray(
1212
z.object({
@@ -52,7 +52,7 @@ export const MetaCpanApiFileSearchResponse = z
5252
hits: z.object({
5353
hits: LooseArray(
5454
z.object({
55-
_source: MetaCpanApiFileSchema,
55+
_source: MetaCpanApiFile,
5656
}),
5757
),
5858
}),

lib/modules/datasource/crate/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type {
2020
Release,
2121
ReleaseResult,
2222
} from '../types';
23-
import { ReleaseTimestampSchema } from './schema';
23+
import { ReleaseTimestamp } from './schema';
2424
import type {
2525
CrateMetadata,
2626
CrateRecord,
@@ -442,7 +442,7 @@ export class CrateDatasource extends Datasource {
442442
const { body: releaseTimestamp } = await this.http.getJson(
443443
url,
444444
{ cacheProvider: memCacheProvider },
445-
ReleaseTimestampSchema,
445+
ReleaseTimestamp,
446446
);
447447
release.releaseTimestamp = releaseTimestamp;
448448
return release;

0 commit comments

Comments
 (0)