Skip to content

Commit 1131897

Browse files
committed
FIX
1 parent 0affdf9 commit 1131897

File tree

2 files changed

+40
-96
lines changed

2 files changed

+40
-96
lines changed

customSchemas.ts

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -19,59 +19,3 @@ export const flexibleBoolean = z.preprocess((val) => {
1919
}
2020
return val;
2121
}, z.boolean());
22-
23-
24-
export const numericStringSchemaNullable = z.coerce.string().nullable()
25-
// export const numericStringSchemaNullable = z.coerce.string().or(z.number()).transform((val, ctx) => {
26-
// const strValue = String(val);
27-
// const trimmedStrValue = strValue.trim();
28-
29-
// if (trimmedStrValue === '') {
30-
// ctx.addIssue({
31-
// code: z.ZodIssueCode.custom,
32-
// message: `Expected a numeric string or number, but received an empty string or string with only whitespace.`,
33-
// });
34-
// return z.NEVER;
35-
// }
36-
// if (trimmedStrValue.toLowerCase() === 'null') {
37-
// return null;
38-
// }
39-
// if (isNaN(Number(trimmedStrValue))) {
40-
// ctx.addIssue({
41-
// code: z.ZodIssueCode.custom,
42-
// message: `Expected a numeric string or number, but received ${trimmedStrValue}`,
43-
// });
44-
// return z.NEVER;
45-
// }
46-
// return String(trimmedStrValue);
47-
// }).nullable();
48-
49-
50-
export const numericStringSchema = z.coerce.string()
51-
// export const numericStringSchema = z.coerce.string().transform((val, ctx) => {
52-
// const strValue = String(val);
53-
// const trimmedStrValue = strValue.trim();
54-
55-
// if (trimmedStrValue === '') {
56-
// ctx.addIssue({
57-
// code: z.ZodIssueCode.custom,
58-
// message: `Expected a numeric string or number, but received an empty string or string with only whitespace.`,
59-
// });
60-
// return z.NEVER;
61-
// }
62-
// if (trimmedStrValue.toLowerCase() === 'null') {
63-
// ctx.addIssue({
64-
// code: z.ZodIssueCode.custom,
65-
// message: `Expected a numeric string or number, but received an null as string`,
66-
// });
67-
// return z.NEVER;
68-
// }
69-
// if (isNaN(Number(trimmedStrValue))) {
70-
// ctx.addIssue({
71-
// code: z.ZodIssueCode.custom,
72-
// message: `Expected a numeric string or number, but received ${trimmedStrValue}`,
73-
// });
74-
// return z.NEVER;
75-
// }
76-
// return String(trimmedStrValue);
77-
// });

schemas.ts

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

44
// Base schemas for common types
55
export const GitLabAuthorSchema = z.object({
@@ -147,13 +147,13 @@ export const ListPipelinesSchema = z.object({
147147
// Schema for getting a specific pipeline
148148
export const GetPipelineSchema = z.object({
149149
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
150-
pipeline_id: numericStringSchema.describe("The ID of the pipeline"),
150+
pipeline_id: z.coerce.string().describe("The ID of the pipeline"),
151151
});
152152

153153
// Schema for listing jobs in a pipeline
154154
export const ListPipelineJobsSchema = z.object({
155155
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
156-
pipeline_id: numericStringSchema.describe("The ID of the pipeline"),
156+
pipeline_id: z.coerce.string().describe("The ID of the pipeline"),
157157
scope: z
158158
.enum(["created", "pending", "running", "failed", "success", "canceled", "skipped", "manual"])
159159
.optional()
@@ -179,7 +179,7 @@ export const CreatePipelineSchema = z.object({
179179
// Schema for retrying a pipeline
180180
export const RetryPipelineSchema = z.object({
181181
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
182-
pipeline_id: numericStringSchema.describe("The ID of the pipeline to retry"),
182+
pipeline_id: z.coerce.string().describe("The ID of the pipeline to retry"),
183183
});
184184

185185
// Schema for canceling a pipeline
@@ -188,7 +188,7 @@ export const CancelPipelineSchema = RetryPipelineSchema
188188
// Schema for the input parameters for pipeline job operations
189189
export const GetPipelineJobOutputSchema = z.object({
190190
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
191-
job_id: numericStringSchema.describe("The ID of the job"),
191+
job_id: z.coerce.string().describe("The ID of the job"),
192192
limit: z.number().optional().describe("Maximum number of lines to return from the end of the log (default: 1000)"),
193193
offset: z.number().optional().describe("Number of lines to skip from the end of the log (default: 0)"),
194194
});
@@ -432,7 +432,7 @@ export const GitLabReferenceSchema = z.object({
432432
// Milestones rest api output schemas
433433
export const GitLabMilestonesSchema = z.object({
434434
id: z.coerce.string(),
435-
iid: numericStringSchema,
435+
iid: z.coerce.string(),
436436
project_id: z.coerce.string(),
437437
title: z.string(),
438438
description: z.string().nullable(),
@@ -457,7 +457,7 @@ export const CreateIssueOptionsSchema = z.object({
457457
title: z.string(),
458458
description: z.string().optional(), // Changed from body to match GitLab API
459459
assignee_ids: z.array(z.number()).optional(), // Changed from assignees to match GitLab API
460-
milestone_id: numericStringSchema.optional(), // Changed from milestone to match GitLab API
460+
milestone_id: z.coerce.string().optional(), // Changed from milestone to match GitLab API
461461
labels: z.array(z.string()).optional(),
462462
});
463463

@@ -527,7 +527,7 @@ export const GitLabLabelSchema = z.object({
527527

528528
export const GitLabMilestoneSchema = z.object({
529529
id: z.coerce.string(),
530-
iid: numericStringSchema, // Added to match GitLab API
530+
iid: z.coerce.string(), // Added to match GitLab API
531531
title: z.string(),
532532
description: z.string().nullable().default(""),
533533
state: z.string(),
@@ -536,7 +536,7 @@ export const GitLabMilestoneSchema = z.object({
536536

537537
export const GitLabIssueSchema = z.object({
538538
id: z.coerce.string(),
539-
iid: numericStringSchema, // Added to match GitLab API
539+
iid: z.coerce.string(), // Added to match GitLab API
540540
project_id: z.coerce.string(), // Added to match GitLab API
541541
title: z.string(),
542542
description: z.string().nullable().default(""), // Changed from body to match GitLab API
@@ -605,7 +605,7 @@ export const GitLabMergeRequestDiffRefSchema = z.object({
605605

606606
export const GitLabMergeRequestSchema = z.object({
607607
id: z.coerce.string(),
608-
iid: numericStringSchema,
608+
iid: z.coerce.string(),
609609
project_id: z.coerce.string(),
610610
title: z.string(),
611611
description: z.string().nullable(),
@@ -664,10 +664,10 @@ export const GitLabDiscussionNoteSchema = z.object({
664664
created_at: z.string(),
665665
updated_at: z.string(),
666666
system: flexibleBoolean,
667-
noteable_id: numericStringSchema,
667+
noteable_id: z.coerce.string(),
668668
noteable_type: z.enum(["Issue", "MergeRequest", "Snippet", "Commit", "Epic"]),
669669
project_id: z.coerce.string().optional(),
670-
noteable_iid: numericStringSchemaNullable.optional(),
670+
noteable_iid: z.coerce.string().nullable().optional(),
671671
resolvable: flexibleBoolean.optional(),
672672
resolved: flexibleBoolean.optional(),
673673
resolved_by: GitLabUserSchema.nullable().optional(),
@@ -729,19 +729,19 @@ export type PaginatedDiscussionsResponse = z.infer<typeof PaginatedDiscussionsRe
729729

730730
export const ListIssueDiscussionsSchema = z.object({
731731
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
732-
issue_iid: numericStringSchema.describe("The internal ID of the project issue"),
732+
issue_iid: z.coerce.string().describe("The internal ID of the project issue"),
733733
}).merge(PaginationOptionsSchema);
734734

735735
// Input schema for listing merge request discussions
736736
export const ListMergeRequestDiscussionsSchema = ProjectParamsSchema.extend({
737-
merge_request_iid: numericStringSchema.describe("The IID of a merge request"),
737+
merge_request_iid: z.coerce.string().describe("The IID of a merge request"),
738738
}).merge(PaginationOptionsSchema);
739739

740740
// Input schema for updating a merge request discussion note
741741
export const UpdateMergeRequestNoteSchema = ProjectParamsSchema.extend({
742-
merge_request_iid: numericStringSchema.describe("The IID of a merge request"),
743-
discussion_id: numericStringSchema.describe("The ID of a thread"),
744-
note_id: numericStringSchema.describe("The ID of a thread note"),
742+
merge_request_iid: z.coerce.string().describe("The IID of a merge request"),
743+
discussion_id: z.coerce.string().describe("The ID of a thread"),
744+
note_id: z.coerce.string().describe("The ID of a thread note"),
745745
body: z.string().optional().describe("The content of the note or reply"),
746746
resolved: flexibleBoolean.optional().describe("Resolve or unresolve the note"),
747747
})
@@ -754,24 +754,24 @@ export const UpdateMergeRequestNoteSchema = ProjectParamsSchema.extend({
754754

755755
// Input schema for adding a note to an existing merge request discussion
756756
export const CreateMergeRequestNoteSchema = ProjectParamsSchema.extend({
757-
merge_request_iid: numericStringSchema.describe("The IID of a merge request"),
758-
discussion_id: numericStringSchema.describe("The ID of a thread"),
757+
merge_request_iid: z.coerce.string().describe("The IID of a merge request"),
758+
discussion_id: z.coerce.string().describe("The ID of a thread"),
759759
body: z.string().describe("The content of the note or reply"),
760760
created_at: z.string().optional().describe("Date the note was created at (ISO 8601 format)"),
761761
});
762762

763763
// Input schema for updating an issue discussion note
764764
export const UpdateIssueNoteSchema = ProjectParamsSchema.extend({
765-
issue_iid: numericStringSchema.describe("The IID of an issue"),
766-
discussion_id: numericStringSchema.describe("The ID of a thread"),
767-
note_id: numericStringSchema.describe("The ID of a thread note"),
765+
issue_iid: z.coerce.string().describe("The IID of an issue"),
766+
discussion_id: z.coerce.string().describe("The ID of a thread"),
767+
note_id: z.coerce.string().describe("The ID of a thread note"),
768768
body: z.string().describe("The content of the note or reply"),
769769
});
770770

771771
// Input schema for adding a note to an existing issue discussion
772772
export const CreateIssueNoteSchema = ProjectParamsSchema.extend({
773-
issue_iid: numericStringSchema.describe("The IID of an issue"),
774-
discussion_id: numericStringSchema.describe("The ID of a thread"),
773+
issue_iid: z.coerce.string().describe("The IID of an issue"),
774+
discussion_id: z.coerce.string().describe("The ID of a thread"),
775775
body: z.string().describe("The content of the note or reply"),
776776
created_at: z.string().optional().describe("Date the note was created at (ISO 8601 format)"),
777777
});
@@ -825,7 +825,7 @@ export const CreateIssueSchema = ProjectParamsSchema.extend({
825825
description: z.string().optional().describe("Issue description"),
826826
assignee_ids: z.array(z.number()).optional().describe("Array of user IDs to assign"),
827827
labels: z.array(z.string()).optional().describe("Array of label names"),
828-
milestone_id: numericStringSchema.optional().describe("Milestone ID to assign"),
828+
milestone_id: z.coerce.string().optional().describe("Milestone ID to assign"),
829829
});
830830

831831
const MergeRequestOptionsSchema = {
@@ -873,7 +873,7 @@ export const GetBranchDiffsSchema = ProjectParamsSchema.extend({
873873
});
874874

875875
export const GetMergeRequestSchema = ProjectParamsSchema.extend({
876-
merge_request_iid: numericStringSchema.optional().describe("The IID of a merge request"),
876+
merge_request_iid: z.coerce.string().optional().describe("The IID of a merge request"),
877877
source_branch: z.string().optional().describe("Source branch name"),
878878
});
879879

@@ -917,7 +917,7 @@ export const CreateNoteSchema = z.object({
917917
noteable_type: z
918918
.enum(["issue", "merge_request"])
919919
.describe("Type of noteable (issue or merge_request)"),
920-
noteable_iid: numericStringSchema.describe("IID of the issue or merge request"),
920+
noteable_iid: z.coerce.string().describe("IID of the issue or merge request"),
921921
body: z.string().describe("Note content"),
922922
});
923923

@@ -926,7 +926,7 @@ export const ListIssuesSchema = z.object({
926926
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
927927
assignee_id: z.coerce.string().optional().describe("Return issues assigned to the given user ID. user id or none or any"),
928928
assignee_username: z.array(z.string()).optional().describe("Return issues assigned to the given username"),
929-
author_id: numericStringSchema.optional().describe("Return issues created by the given user ID"),
929+
author_id: z.coerce.string().optional().describe("Return issues created by the given user ID"),
930930
author_username: z.string().optional().describe("Return issues created by the given username"),
931931
confidential: flexibleBoolean.optional().describe("Filter confidential or public issues"),
932932
created_after: z.string().optional().describe("Return issues created after the given time"),
@@ -956,7 +956,7 @@ export const ListMergeRequestsSchema = z.object({
956956
.string()
957957
.optional()
958958
.describe("Returns merge requests assigned to the given username"),
959-
author_id: numericStringSchema.optional().describe("Returns merge requests created by the given user ID"),
959+
author_id: z.coerce.string().optional().describe("Returns merge requests created by the given user ID"),
960960
author_username: z
961961
.string()
962962
.optional()
@@ -1017,27 +1017,27 @@ export const ListMergeRequestsSchema = z.object({
10171017

10181018
export const GetIssueSchema = z.object({
10191019
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
1020-
issue_iid: numericStringSchema.describe("The internal ID of the project issue"),
1020+
issue_iid: z.coerce.string().describe("The internal ID of the project issue"),
10211021
});
10221022

10231023
export const UpdateIssueSchema = z.object({
10241024
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
1025-
issue_iid: numericStringSchema.describe("The internal ID of the project issue"),
1025+
issue_iid: z.coerce.string().describe("The internal ID of the project issue"),
10261026
title: z.string().optional().describe("The title of the issue"),
10271027
description: z.string().optional().describe("The description of the issue"),
10281028
assignee_ids: z.array(z.number()).optional().describe("Array of user IDs to assign issue to"),
10291029
confidential: flexibleBoolean.optional().describe("Set the issue to be confidential"),
10301030
discussion_locked: flexibleBoolean.optional().describe("Flag to lock discussions"),
10311031
due_date: z.string().optional().describe("Date the issue is due (YYYY-MM-DD)"),
10321032
labels: z.array(z.string()).optional().describe("Array of label names"),
1033-
milestone_id: numericStringSchema.optional().describe("Milestone ID to assign"),
1033+
milestone_id: z.coerce.string().optional().describe("Milestone ID to assign"),
10341034
state_event: z.enum(["close", "reopen"]).optional().describe("Update issue state (close/reopen)"),
10351035
weight: z.number().optional().describe("Weight of the issue (0-9)"),
10361036
});
10371037

10381038
export const DeleteIssueSchema = z.object({
10391039
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
1040-
issue_iid: numericStringSchema.describe("The internal ID of the project issue"),
1040+
issue_iid: z.coerce.string().describe("The internal ID of the project issue"),
10411041
});
10421042

10431043
// Issue links related schemas
@@ -1049,20 +1049,20 @@ export const GitLabIssueLinkSchema = z.object({
10491049

10501050
export const ListIssueLinksSchema = z.object({
10511051
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
1052-
issue_iid: numericStringSchema.describe("The internal ID of a project's issue"),
1052+
issue_iid: z.coerce.string().describe("The internal ID of a project's issue"),
10531053
});
10541054

10551055
export const GetIssueLinkSchema = z.object({
10561056
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
1057-
issue_iid: numericStringSchema.describe("The internal ID of a project's issue"),
1057+
issue_iid: z.coerce.string().describe("The internal ID of a project's issue"),
10581058
issue_link_id: z.coerce.string().describe("ID of an issue relationship"),
10591059
});
10601060

10611061
export const CreateIssueLinkSchema = z.object({
10621062
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
1063-
issue_iid: numericStringSchema.describe("The internal ID of a project's issue"),
1063+
issue_iid: z.coerce.string().describe("The internal ID of a project's issue"),
10641064
target_project_id: z.coerce.string().describe("The ID or URL-encoded path of a target project"),
1065-
target_issue_iid: numericStringSchema.describe("The internal ID of a target project's issue"),
1065+
target_issue_iid: z.coerce.string().describe("The internal ID of a target project's issue"),
10661066
link_type: z
10671067
.enum(["relates_to", "blocks", "is_blocked_by"])
10681068
.optional()
@@ -1071,7 +1071,7 @@ export const CreateIssueLinkSchema = z.object({
10711071

10721072
export const DeleteIssueLinkSchema = z.object({
10731073
project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
1074-
issue_iid: numericStringSchema.describe("The internal ID of a project's issue"),
1074+
issue_iid: z.coerce.string().describe("The internal ID of a project's issue"),
10751075
issue_link_id: z.coerce.string().describe("The ID of an issue relationship"),
10761076
});
10771077

@@ -1257,7 +1257,7 @@ export const MergeRequestThreadPositionSchema = z.object({
12571257

12581258
// Schema for creating a new merge request thread
12591259
export const CreateMergeRequestThreadSchema = ProjectParamsSchema.extend({
1260-
merge_request_iid: numericStringSchema.describe("The IID of a merge request"),
1260+
merge_request_iid: z.coerce.string().describe("The IID of a merge request"),
12611261
body: z.string().describe("The content of the thread"),
12621262
position: MergeRequestThreadPositionSchema.optional().describe(
12631263
"Position when creating a diff note"
@@ -1294,7 +1294,7 @@ export const ListProjectMilestonesSchema = ProjectParamsSchema.extend({
12941294

12951295
// Schema for getting a single milestone
12961296
export const GetProjectMilestoneSchema = ProjectParamsSchema.extend({
1297-
milestone_id: numericStringSchema.describe("The ID of a project milestone"),
1297+
milestone_id: z.coerce.string().describe("The ID of a project milestone"),
12981298
});
12991299

13001300
// Schema for creating a new milestone

0 commit comments

Comments
 (0)