Skip to content

Commit 424a529

Browse files
vladjercaseferturan
authored andcommitted
refactor: prefer nullish decorator
1 parent 2025305 commit 424a529

63 files changed

Lines changed: 261 additions & 253 deletions

File tree

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
deno-version: v2.3.0
5454

5555
- name: The Sacred Assembly aka Install Dependencies
56-
run: "deno task install"
56+
run: 'deno task install'
5757

5858
- name: The Scroll's Scrutiny aka Validate OpenAPI
5959
if: ${{

projects/api/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"tasks": {
1919
"test": "deno test --unstable --allow-all"
2020
}
21-
}
21+
}

projects/api/src/contracts/_internal/request/bulkMediaRequestSchema.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from './idsRequestSchema.ts';
88

99
const watchedAtSchema = z.object({
10-
watched_at: z.string().datetime().optional(),
10+
watched_at: z.string().datetime().nullish(),
1111
});
1212

1313
const watchWithTileAndYearSchema = z.object({
@@ -26,7 +26,7 @@ const watchWithSeasonsSchema = z
2626
}).merge(watchedAtSchema),
2727
),
2828
}).merge(watchedAtSchema),
29-
).optional(),
29+
).nullish(),
3030
}).merge(watchedAtSchema);
3131

3232
const addMovieToHistorySchema = z
@@ -63,8 +63,8 @@ const addEpisodeToHistorySchema = z
6363
}).merge(watchedAtSchema);
6464

6565
export const bulkMediaRequestSchema = z.object({
66-
movies: z.array(addMovieToHistorySchema).optional(),
67-
shows: z.array(addShowToHistorySchema).optional(),
68-
seasons: z.array(addSeasonToHistorySchema).optional(),
69-
episodes: z.array(addEpisodeToHistorySchema).optional(),
66+
movies: z.array(addMovieToHistorySchema).nullish(),
67+
shows: z.array(addShowToHistorySchema).nullish(),
68+
seasons: z.array(addSeasonToHistorySchema).nullish(),
69+
episodes: z.array(addEpisodeToHistorySchema).nullish(),
7070
});

projects/api/src/contracts/_internal/request/commentsSortParamsSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export const commentsSortParamsSchema = z.object({
99
'highest',
1010
'lowest',
1111
'plays',
12-
]).optional(),
12+
]).nullish(),
1313
});
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import { extendedQuerySchemaFactory } from './extendedQuerySchemaFactory.ts';
22

3-
export const extendedMediaQuerySchema = extendedQuerySchemaFactory<['full', 'images', 'colors', 'streaming_ids']>()
3+
export const extendedMediaQuerySchema = extendedQuerySchemaFactory<
4+
['full', 'images', 'colors', 'streaming_ids']
5+
>();
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import { extendedQuerySchemaFactory } from './extendedQuerySchemaFactory.ts';
22

3-
export const extendedPeopleQuerySchema = extendedQuerySchemaFactory<['full', 'images']>();
3+
export const extendedPeopleQuerySchema = extendedQuerySchemaFactory<
4+
['full', 'images']
5+
>();
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import { extendedQuerySchemaFactory } from './extendedQuerySchemaFactory.ts';
22

3-
export const extendedProfileQuerySchema = extendedQuerySchemaFactory<['full', 'images', 'vip']>();
3+
export const extendedProfileQuerySchema = extendedQuerySchemaFactory<
4+
['full', 'images', 'vip']
5+
>();

projects/api/src/contracts/_internal/request/extendedQuerySchemaFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const extendedQuerySchemaFactory = <T extends string[]>() =>
55
z.object({
66
extended: z
77
.custom<CombinationsFrom<T>>()
8-
.optional()
8+
.nullish()
99
.openapi({
1010
description: 'Extended information to include in the response.',
1111
}),

projects/api/src/contracts/_internal/request/idsRequestSchema.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { z } from '../z.ts';
22

33
const allMediaIdsSchema = z.object({
4-
trakt: z.number().int().optional().openapi({ description: 'Trakt ID' }),
5-
slug: z.string().optional().openapi({ description: 'Slug' }),
6-
imdb: z.string().optional().openapi({ description: 'IMDb ID' }),
7-
tmdb: z.number().int().optional().openapi({ description: 'TMDb ID' }),
8-
tvdb: z.number().int().optional().openapi({ description: 'TVDb ID' }),
4+
trakt: z.number().int().nullish().openapi({ description: 'Trakt ID' }),
5+
slug: z.string().nullish().openapi({ description: 'Slug' }),
6+
imdb: z.string().nullish().openapi({ description: 'IMDb ID' }),
7+
tmdb: z.number().int().nullish().openapi({ description: 'TMDb ID' }),
8+
tvdb: z.number().int().nullish().openapi({ description: 'TVDb ID' }),
99
});
1010

1111
const showMediaIdsSchema = allMediaIdsSchema;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { z } from '../z.ts';
22

33
export const ignoreQuerySchema = z.object({
4-
ignore_watched: z.boolean().optional().openapi({
4+
ignore_watched: z.boolean().nullish().openapi({
55
description: 'Ignore watched items.',
66
}),
7-
ignore_collected: z.boolean().optional().openapi({
7+
ignore_collected: z.boolean().nullish().openapi({
88
description: 'Ignore collected items.',
99
}),
10-
ignore_watchlisted: z.boolean().optional().openapi({
10+
ignore_watchlisted: z.boolean().nullish().openapi({
1111
description: 'Ignore watchlisted items.',
1212
}),
1313
});

0 commit comments

Comments
 (0)