Skip to content

Commit 46f8405

Browse files
author
iwakitakuma
committed
FIX
1 parent 6e82e7e commit 46f8405

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

customSchemas.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { z } from "zod";
22
import { pino } from 'pino';
3+
const DEFAULT_NULL = process.env.DEFAULT_NULL;
4+
35

46
const logger = pino({
57
level: process.env.LOG_LEVEL || 'info',
@@ -19,3 +21,5 @@ export const flexibleBoolean = z.preprocess((val) => {
1921
}
2022
return val;
2123
}, z.boolean());
24+
25+
export const flexibleBooleanNullable = DEFAULT_NULL ? flexibleBoolean.nullable().default(null) : flexibleBoolean.nullable();

schemas.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { z } from "zod";
2-
import {flexibleBoolean} from "./customSchemas.js"
2+
import {flexibleBoolean,flexibleBooleanNullable} from "./customSchemas.js"
33

44
// Base schemas for common types
55
export const GitLabAuthorSchema = z.object({
@@ -318,7 +318,7 @@ export const GitLabRepositorySchema = z.object({
318318
jobs_enabled: flexibleBoolean.optional(),
319319
snippets_enabled: flexibleBoolean.optional(),
320320
can_create_merge_request_in: flexibleBoolean.optional(),
321-
resolve_outdated_diff_discussions: flexibleBoolean.nullable().default(null).optional(),
321+
resolve_outdated_diff_discussions: flexibleBooleanNullable.optional(),
322322
shared_runners_enabled: flexibleBoolean.optional(),
323323
shared_with_groups: z
324324
.array(
@@ -566,7 +566,7 @@ export const GitLabIssueSchema = z.object({
566566
.optional(),
567567
confidential: flexibleBoolean.optional(),
568568
due_date: z.string().nullable().optional(),
569-
discussion_locked: flexibleBoolean.nullable().default(null).optional(),
569+
discussion_locked: flexibleBooleanNullable.optional(),
570570
weight: z.number().nullable().optional(),
571571
});
572572

@@ -629,8 +629,8 @@ export const GitLabMergeRequestSchema = z.object({
629629
merge_error: z.string().nullable().optional(),
630630
work_in_progress: flexibleBoolean.optional(),
631631
blocking_discussions_resolved: flexibleBoolean.optional(),
632-
should_remove_source_branch: flexibleBoolean.nullable().default(null).optional(),
633-
force_remove_source_branch: flexibleBoolean.nullable().default(null).optional(),
632+
should_remove_source_branch: flexibleBooleanNullable.optional(),
633+
force_remove_source_branch: flexibleBooleanNullable.optional(),
634634
allow_collaboration: flexibleBoolean.optional(),
635635
allow_maintainer_to_push: flexibleBoolean.optional(),
636636
changes_count: z.string().nullable().optional(),
@@ -848,8 +848,8 @@ const MergeRequestOptionsSchema = {
848848
.boolean()
849849
.optional()
850850
.describe("Allow commits from upstream members"),
851-
remove_source_branch: flexibleBoolean.nullable().default(null).optional().describe("Flag indicating if a merge request should remove the source branch when merging."),
852-
squash: flexibleBoolean.nullable().default(null).optional().describe("If true, squash all commits into a single commit on merge."),
851+
remove_source_branch: flexibleBooleanNullable.optional().describe("Flag indicating if a merge request should remove the source branch when merging."),
852+
squash: flexibleBooleanNullable.optional().describe("If true, squash all commits into a single commit on merge."),
853853
}
854854
export const CreateMergeRequestOptionsSchema = z.object(MergeRequestOptionsSchema);
855855
export const CreateMergeRequestSchema = ProjectParamsSchema.extend(MergeRequestOptionsSchema);

0 commit comments

Comments
 (0)