@reqord/shared 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +38 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +2 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/paths.d.ts +13 -0
- package/dist/constants/paths.d.ts.map +1 -0
- package/dist/constants/paths.js +13 -0
- package/dist/constants/paths.js.map +1 -0
- package/dist/constants/paths.test.d.ts +2 -0
- package/dist/constants/paths.test.d.ts.map +1 -0
- package/dist/constants/paths.test.js +11 -0
- package/dist/constants/paths.test.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/rules/consistency.d.ts +12 -0
- package/dist/rules/consistency.d.ts.map +1 -0
- package/dist/rules/consistency.js +34 -0
- package/dist/rules/consistency.js.map +1 -0
- package/dist/rules/consistency.test.d.ts +2 -0
- package/dist/rules/consistency.test.d.ts.map +1 -0
- package/dist/rules/consistency.test.js +97 -0
- package/dist/rules/consistency.test.js.map +1 -0
- package/dist/rules/index.d.ts +3 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +3 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/status-transitions.d.ts +5 -0
- package/dist/rules/status-transitions.d.ts.map +1 -0
- package/dist/rules/status-transitions.js +13 -0
- package/dist/rules/status-transitions.js.map +1 -0
- package/dist/rules/status-transitions.test.d.ts +2 -0
- package/dist/rules/status-transitions.test.d.ts.map +1 -0
- package/dist/rules/status-transitions.test.js +53 -0
- package/dist/rules/status-transitions.test.js.map +1 -0
- package/dist/schemas/common.d.ts +33 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +19 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/schemas/feedback.d.ts +249 -0
- package/dist/schemas/feedback.d.ts.map +1 -0
- package/dist/schemas/feedback.js +39 -0
- package/dist/schemas/feedback.js.map +1 -0
- package/dist/schemas/feedback.test.d.ts +2 -0
- package/dist/schemas/feedback.test.d.ts.map +1 -0
- package/dist/schemas/feedback.test.js +234 -0
- package/dist/schemas/feedback.test.js.map +1 -0
- package/dist/schemas/index.d.ts +8 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +8 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/project-context.d.ts +116 -0
- package/dist/schemas/project-context.d.ts.map +1 -0
- package/dist/schemas/project-context.js +25 -0
- package/dist/schemas/project-context.js.map +1 -0
- package/dist/schemas/requirement.d.ts +242 -0
- package/dist/schemas/requirement.d.ts.map +1 -0
- package/dist/schemas/requirement.js +52 -0
- package/dist/schemas/requirement.js.map +1 -0
- package/dist/schemas/requirement.test.d.ts +2 -0
- package/dist/schemas/requirement.test.d.ts.map +1 -0
- package/dist/schemas/requirement.test.js +38 -0
- package/dist/schemas/requirement.test.js.map +1 -0
- package/dist/schemas/specification.d.ts +217 -0
- package/dist/schemas/specification.d.ts.map +1 -0
- package/dist/schemas/specification.js +32 -0
- package/dist/schemas/specification.js.map +1 -0
- package/dist/schemas/specification.test.d.ts +2 -0
- package/dist/schemas/specification.test.d.ts.map +1 -0
- package/dist/schemas/specification.test.js +89 -0
- package/dist/schemas/specification.test.js.map +1 -0
- package/dist/schemas/task.d.ts +177 -0
- package/dist/schemas/task.d.ts.map +1 -0
- package/dist/schemas/task.js +29 -0
- package/dist/schemas/task.js.map +1 -0
- package/dist/schemas/task.test.d.ts +2 -0
- package/dist/schemas/task.test.d.ts.map +1 -0
- package/dist/schemas/task.test.js +203 -0
- package/dist/schemas/task.test.js.map +1 -0
- package/dist/schemas/validation.d.ts +174 -0
- package/dist/schemas/validation.d.ts.map +1 -0
- package/dist/schemas/validation.js +31 -0
- package/dist/schemas/validation.js.map +1 -0
- package/dist/utils/zod-error-formatter.d.ts +25 -0
- package/dist/utils/zod-error-formatter.d.ts.map +1 -0
- package/dist/utils/zod-error-formatter.js +115 -0
- package/dist/utils/zod-error-formatter.js.map +1 -0
- package/dist/utils/zod-error-formatter.test.d.ts +2 -0
- package/dist/utils/zod-error-formatter.test.d.ts.map +1 -0
- package/dist/utils/zod-error-formatter.test.js +314 -0
- package/dist/utils/zod-error-formatter.test.js.map +1 -0
- package/dist/validation/ambiguous-phrases.d.ts +11 -0
- package/dist/validation/ambiguous-phrases.d.ts.map +1 -0
- package/dist/validation/ambiguous-phrases.js +56 -0
- package/dist/validation/ambiguous-phrases.js.map +1 -0
- package/dist/validation/smart-scoring.d.ts +15 -0
- package/dist/validation/smart-scoring.d.ts.map +1 -0
- package/dist/validation/smart-scoring.js +225 -0
- package/dist/validation/smart-scoring.js.map +1 -0
- package/dist/validation/smart-scoring.test.d.ts +2 -0
- package/dist/validation/smart-scoring.test.d.ts.map +1 -0
- package/dist/validation/smart-scoring.test.js +136 -0
- package/dist/validation/smart-scoring.test.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { TaskDefinitionSchema, TaskDefinitionFileSchema, TaskLinkedToSchema, TaskEntrySchema, TasksIndexSchema, } from "./task.js";
|
|
3
|
+
describe("TaskDefinitionSchema", () => {
|
|
4
|
+
describe("正常系", () => {
|
|
5
|
+
it("全フィールド指定で受け入れる", () => {
|
|
6
|
+
const task = {
|
|
7
|
+
title: "Implement feature X",
|
|
8
|
+
description: "Add new feature X with tests",
|
|
9
|
+
priority: "P1",
|
|
10
|
+
estimatedHours: 5,
|
|
11
|
+
dependencies: ["req-000001"],
|
|
12
|
+
};
|
|
13
|
+
const result = TaskDefinitionSchema.parse(task);
|
|
14
|
+
expect(result).toEqual(task);
|
|
15
|
+
});
|
|
16
|
+
it("priority省略時にP2をデフォルト値として設定する", () => {
|
|
17
|
+
const task = {
|
|
18
|
+
title: "Implement feature Y",
|
|
19
|
+
description: "Add new feature Y",
|
|
20
|
+
estimatedHours: 3,
|
|
21
|
+
dependencies: ["req-000002"],
|
|
22
|
+
};
|
|
23
|
+
const result = TaskDefinitionSchema.parse(task);
|
|
24
|
+
expect(result.priority).toBe("P2");
|
|
25
|
+
expect(result.title).toBe("Implement feature Y");
|
|
26
|
+
});
|
|
27
|
+
it("dependencies省略時に空配列をデフォルト値として設定する", () => {
|
|
28
|
+
const task = {
|
|
29
|
+
title: "Implement feature Z",
|
|
30
|
+
description: "Add new feature Z",
|
|
31
|
+
priority: "P0",
|
|
32
|
+
estimatedHours: 8,
|
|
33
|
+
};
|
|
34
|
+
const result = TaskDefinitionSchema.parse(task);
|
|
35
|
+
expect(result.dependencies).toEqual([]);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe("異常系", () => {
|
|
39
|
+
it("title空文字で拒否する", () => {
|
|
40
|
+
const task = {
|
|
41
|
+
title: "",
|
|
42
|
+
description: "Some description",
|
|
43
|
+
estimatedHours: 5,
|
|
44
|
+
};
|
|
45
|
+
expect(() => TaskDefinitionSchema.parse(task)).toThrow();
|
|
46
|
+
});
|
|
47
|
+
it("description空文字で拒否する", () => {
|
|
48
|
+
const task = {
|
|
49
|
+
title: "Valid title",
|
|
50
|
+
description: "",
|
|
51
|
+
estimatedHours: 5,
|
|
52
|
+
};
|
|
53
|
+
expect(() => TaskDefinitionSchema.parse(task)).toThrow();
|
|
54
|
+
});
|
|
55
|
+
it("estimatedHours 0で拒否する", () => {
|
|
56
|
+
const task = {
|
|
57
|
+
title: "Valid title",
|
|
58
|
+
description: "Valid description",
|
|
59
|
+
estimatedHours: 0,
|
|
60
|
+
};
|
|
61
|
+
expect(() => TaskDefinitionSchema.parse(task)).toThrow();
|
|
62
|
+
});
|
|
63
|
+
it("estimatedHours負数で拒否する", () => {
|
|
64
|
+
const task = {
|
|
65
|
+
title: "Valid title",
|
|
66
|
+
description: "Valid description",
|
|
67
|
+
estimatedHours: -5,
|
|
68
|
+
};
|
|
69
|
+
expect(() => TaskDefinitionSchema.parse(task)).toThrow();
|
|
70
|
+
});
|
|
71
|
+
it("無効なpriorityで拒否する", () => {
|
|
72
|
+
const task = {
|
|
73
|
+
title: "Valid title",
|
|
74
|
+
description: "Valid description",
|
|
75
|
+
priority: "P4",
|
|
76
|
+
estimatedHours: 5,
|
|
77
|
+
};
|
|
78
|
+
expect(() => TaskDefinitionSchema.parse(task)).toThrow();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe("TaskDefinitionFileSchema", () => {
|
|
83
|
+
describe("正常系", () => {
|
|
84
|
+
it("複数タスクを受け入れる", () => {
|
|
85
|
+
const file = {
|
|
86
|
+
tasks: [
|
|
87
|
+
{
|
|
88
|
+
title: "Task 1",
|
|
89
|
+
description: "First task",
|
|
90
|
+
priority: "P0",
|
|
91
|
+
estimatedHours: 3,
|
|
92
|
+
dependencies: [],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
title: "Task 2",
|
|
96
|
+
description: "Second task",
|
|
97
|
+
priority: "P2",
|
|
98
|
+
estimatedHours: 5,
|
|
99
|
+
dependencies: ["req-000001"],
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
};
|
|
103
|
+
const result = TaskDefinitionFileSchema.parse(file);
|
|
104
|
+
expect(result.tasks).toHaveLength(2);
|
|
105
|
+
expect(result.tasks[0].title).toBe("Task 1");
|
|
106
|
+
expect(result.tasks[1].title).toBe("Task 2");
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
describe("異常系", () => {
|
|
110
|
+
it("空配列で拒否する", () => {
|
|
111
|
+
const file = {
|
|
112
|
+
tasks: [],
|
|
113
|
+
};
|
|
114
|
+
expect(() => TaskDefinitionFileSchema.parse(file)).toThrow();
|
|
115
|
+
});
|
|
116
|
+
it("tasksフィールド欠落で拒否する", () => {
|
|
117
|
+
const file = {};
|
|
118
|
+
expect(() => TaskDefinitionFileSchema.parse(file)).toThrow();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
describe("TaskLinkedToSchema", () => {
|
|
123
|
+
it("specifications配列を受け入れる", () => {
|
|
124
|
+
const result = TaskLinkedToSchema.parse({
|
|
125
|
+
specifications: ["spec-000001", "spec-000002"],
|
|
126
|
+
});
|
|
127
|
+
expect(result.specifications).toEqual(["spec-000001", "spec-000002"]);
|
|
128
|
+
});
|
|
129
|
+
it("specifications省略時に空配列をデフォルト値として設定する", () => {
|
|
130
|
+
const result = TaskLinkedToSchema.parse({});
|
|
131
|
+
expect(result.specifications).toEqual([]);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
describe("TaskEntrySchema", () => {
|
|
135
|
+
const baseEntry = {
|
|
136
|
+
number: 101,
|
|
137
|
+
title: "Implement feature X",
|
|
138
|
+
url: "https://github.com/owner/repo/issues/101",
|
|
139
|
+
linkedTo: { specifications: ["spec-000001"] },
|
|
140
|
+
priority: "P1",
|
|
141
|
+
status: "open",
|
|
142
|
+
estimatedHours: 5,
|
|
143
|
+
syncedAt: "2026-02-10T10:00:00Z",
|
|
144
|
+
};
|
|
145
|
+
it("全フィールド指定で受け入れる", () => {
|
|
146
|
+
const result = TaskEntrySchema.parse(baseEntry);
|
|
147
|
+
expect(result.number).toBe(101);
|
|
148
|
+
expect(result.title).toBe("Implement feature X");
|
|
149
|
+
expect(result.linkedTo.specifications).toEqual(["spec-000001"]);
|
|
150
|
+
expect(result.status).toBe("open");
|
|
151
|
+
});
|
|
152
|
+
it("priority・estimatedHoursはオプション", () => {
|
|
153
|
+
const { priority: _priority, estimatedHours: _estimatedHours, ...minimal } = baseEntry;
|
|
154
|
+
const result = TaskEntrySchema.parse(minimal);
|
|
155
|
+
expect(result.priority).toBeUndefined();
|
|
156
|
+
expect(result.estimatedHours).toBeUndefined();
|
|
157
|
+
});
|
|
158
|
+
it("numberが0以下で拒否する", () => {
|
|
159
|
+
expect(() => TaskEntrySchema.parse({ ...baseEntry, number: 0 })).toThrow();
|
|
160
|
+
expect(() => TaskEntrySchema.parse({ ...baseEntry, number: -1 })).toThrow();
|
|
161
|
+
});
|
|
162
|
+
it("不正なURLで拒否する", () => {
|
|
163
|
+
expect(() => TaskEntrySchema.parse({ ...baseEntry, url: "not-a-url" })).toThrow();
|
|
164
|
+
});
|
|
165
|
+
it("不正なstatusで拒否する", () => {
|
|
166
|
+
expect(() => TaskEntrySchema.parse({ ...baseEntry, status: "in_progress" })).toThrow();
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
describe("TasksIndexSchema", () => {
|
|
170
|
+
it("タスク一覧を受け入れる", () => {
|
|
171
|
+
const index = {
|
|
172
|
+
title: "Project Tasks",
|
|
173
|
+
tasks: [
|
|
174
|
+
{
|
|
175
|
+
number: 101,
|
|
176
|
+
title: "Task 1",
|
|
177
|
+
url: "https://github.com/owner/repo/issues/101",
|
|
178
|
+
linkedTo: { specifications: ["spec-000001"] },
|
|
179
|
+
status: "open",
|
|
180
|
+
syncedAt: "2026-02-10T10:00:00Z",
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
};
|
|
184
|
+
const result = TasksIndexSchema.parse(index);
|
|
185
|
+
expect(result.title).toBe("Project Tasks");
|
|
186
|
+
expect(result.tasks).toHaveLength(1);
|
|
187
|
+
});
|
|
188
|
+
it("空のタスク配列を受け入れる", () => {
|
|
189
|
+
const index = {
|
|
190
|
+
title: "Empty Project",
|
|
191
|
+
tasks: [],
|
|
192
|
+
};
|
|
193
|
+
const result = TasksIndexSchema.parse(index);
|
|
194
|
+
expect(result.tasks).toEqual([]);
|
|
195
|
+
});
|
|
196
|
+
it("titleが欠けている場合は拒否する", () => {
|
|
197
|
+
expect(() => TasksIndexSchema.parse({ tasks: [] })).toThrow();
|
|
198
|
+
});
|
|
199
|
+
it("title空文字で拒否する", () => {
|
|
200
|
+
expect(() => TasksIndexSchema.parse({ title: "", tasks: [] })).toThrow();
|
|
201
|
+
});
|
|
202
|
+
});
|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: z.ZodEnum<["error", "warning", "info"]>;
|
|
3
|
+
export type ValidationSeverity = z.infer<typeof ValidationSeveritySchema>;
|
|
4
|
+
export declare const ValidationIssueSchema: z.ZodObject<{
|
|
5
|
+
type: z.ZodString;
|
|
6
|
+
severity: z.ZodEnum<["error", "warning", "info"]>;
|
|
7
|
+
field: z.ZodString;
|
|
8
|
+
message: z.ZodString;
|
|
9
|
+
suggestion: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
type: string;
|
|
12
|
+
message: string;
|
|
13
|
+
severity: "error" | "warning" | "info";
|
|
14
|
+
field: string;
|
|
15
|
+
suggestion?: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
type: string;
|
|
18
|
+
message: string;
|
|
19
|
+
severity: "error" | "warning" | "info";
|
|
20
|
+
field: string;
|
|
21
|
+
suggestion?: string | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
export type ValidationIssue = z.infer<typeof ValidationIssueSchema>;
|
|
24
|
+
export declare const SmartScoreSchema: z.ZodObject<{
|
|
25
|
+
specific: z.ZodNumber;
|
|
26
|
+
measurable: z.ZodNumber;
|
|
27
|
+
achievable: z.ZodNumber;
|
|
28
|
+
relevant: z.ZodNumber;
|
|
29
|
+
timeBound: z.ZodNumber;
|
|
30
|
+
overall: z.ZodNumber;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
specific: number;
|
|
33
|
+
measurable: number;
|
|
34
|
+
achievable: number;
|
|
35
|
+
relevant: number;
|
|
36
|
+
timeBound: number;
|
|
37
|
+
overall: number;
|
|
38
|
+
}, {
|
|
39
|
+
specific: number;
|
|
40
|
+
measurable: number;
|
|
41
|
+
achievable: number;
|
|
42
|
+
relevant: number;
|
|
43
|
+
timeBound: number;
|
|
44
|
+
overall: number;
|
|
45
|
+
}>;
|
|
46
|
+
export type SmartScore = z.infer<typeof SmartScoreSchema>;
|
|
47
|
+
export declare const ValidationMetadataSchema: z.ZodObject<{
|
|
48
|
+
criteriaCount: z.ZodNumber;
|
|
49
|
+
hasDescription: z.ZodBoolean;
|
|
50
|
+
hasDependencyIssues: z.ZodBoolean;
|
|
51
|
+
validatedAt: z.ZodString;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
criteriaCount: number;
|
|
54
|
+
hasDescription: boolean;
|
|
55
|
+
hasDependencyIssues: boolean;
|
|
56
|
+
validatedAt: string;
|
|
57
|
+
}, {
|
|
58
|
+
criteriaCount: number;
|
|
59
|
+
hasDescription: boolean;
|
|
60
|
+
hasDependencyIssues: boolean;
|
|
61
|
+
validatedAt: string;
|
|
62
|
+
}>;
|
|
63
|
+
export type ValidationMetadata = z.infer<typeof ValidationMetadataSchema>;
|
|
64
|
+
export declare const ValidationResultSchema: z.ZodObject<{
|
|
65
|
+
id: z.ZodString;
|
|
66
|
+
valid: z.ZodBoolean;
|
|
67
|
+
issues: z.ZodArray<z.ZodObject<{
|
|
68
|
+
type: z.ZodString;
|
|
69
|
+
severity: z.ZodEnum<["error", "warning", "info"]>;
|
|
70
|
+
field: z.ZodString;
|
|
71
|
+
message: z.ZodString;
|
|
72
|
+
suggestion: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
type: string;
|
|
75
|
+
message: string;
|
|
76
|
+
severity: "error" | "warning" | "info";
|
|
77
|
+
field: string;
|
|
78
|
+
suggestion?: string | undefined;
|
|
79
|
+
}, {
|
|
80
|
+
type: string;
|
|
81
|
+
message: string;
|
|
82
|
+
severity: "error" | "warning" | "info";
|
|
83
|
+
field: string;
|
|
84
|
+
suggestion?: string | undefined;
|
|
85
|
+
}>, "many">;
|
|
86
|
+
smartScore: z.ZodObject<{
|
|
87
|
+
specific: z.ZodNumber;
|
|
88
|
+
measurable: z.ZodNumber;
|
|
89
|
+
achievable: z.ZodNumber;
|
|
90
|
+
relevant: z.ZodNumber;
|
|
91
|
+
timeBound: z.ZodNumber;
|
|
92
|
+
overall: z.ZodNumber;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
specific: number;
|
|
95
|
+
measurable: number;
|
|
96
|
+
achievable: number;
|
|
97
|
+
relevant: number;
|
|
98
|
+
timeBound: number;
|
|
99
|
+
overall: number;
|
|
100
|
+
}, {
|
|
101
|
+
specific: number;
|
|
102
|
+
measurable: number;
|
|
103
|
+
achievable: number;
|
|
104
|
+
relevant: number;
|
|
105
|
+
timeBound: number;
|
|
106
|
+
overall: number;
|
|
107
|
+
}>;
|
|
108
|
+
metadata: z.ZodObject<{
|
|
109
|
+
criteriaCount: z.ZodNumber;
|
|
110
|
+
hasDescription: z.ZodBoolean;
|
|
111
|
+
hasDependencyIssues: z.ZodBoolean;
|
|
112
|
+
validatedAt: z.ZodString;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
criteriaCount: number;
|
|
115
|
+
hasDescription: boolean;
|
|
116
|
+
hasDependencyIssues: boolean;
|
|
117
|
+
validatedAt: string;
|
|
118
|
+
}, {
|
|
119
|
+
criteriaCount: number;
|
|
120
|
+
hasDescription: boolean;
|
|
121
|
+
hasDependencyIssues: boolean;
|
|
122
|
+
validatedAt: string;
|
|
123
|
+
}>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
issues: {
|
|
126
|
+
type: string;
|
|
127
|
+
message: string;
|
|
128
|
+
severity: "error" | "warning" | "info";
|
|
129
|
+
field: string;
|
|
130
|
+
suggestion?: string | undefined;
|
|
131
|
+
}[];
|
|
132
|
+
valid: boolean;
|
|
133
|
+
id: string;
|
|
134
|
+
smartScore: {
|
|
135
|
+
specific: number;
|
|
136
|
+
measurable: number;
|
|
137
|
+
achievable: number;
|
|
138
|
+
relevant: number;
|
|
139
|
+
timeBound: number;
|
|
140
|
+
overall: number;
|
|
141
|
+
};
|
|
142
|
+
metadata: {
|
|
143
|
+
criteriaCount: number;
|
|
144
|
+
hasDescription: boolean;
|
|
145
|
+
hasDependencyIssues: boolean;
|
|
146
|
+
validatedAt: string;
|
|
147
|
+
};
|
|
148
|
+
}, {
|
|
149
|
+
issues: {
|
|
150
|
+
type: string;
|
|
151
|
+
message: string;
|
|
152
|
+
severity: "error" | "warning" | "info";
|
|
153
|
+
field: string;
|
|
154
|
+
suggestion?: string | undefined;
|
|
155
|
+
}[];
|
|
156
|
+
valid: boolean;
|
|
157
|
+
id: string;
|
|
158
|
+
smartScore: {
|
|
159
|
+
specific: number;
|
|
160
|
+
measurable: number;
|
|
161
|
+
achievable: number;
|
|
162
|
+
relevant: number;
|
|
163
|
+
timeBound: number;
|
|
164
|
+
overall: number;
|
|
165
|
+
};
|
|
166
|
+
metadata: {
|
|
167
|
+
criteriaCount: number;
|
|
168
|
+
hasDescription: boolean;
|
|
169
|
+
hasDependencyIssues: boolean;
|
|
170
|
+
validatedAt: string;
|
|
171
|
+
};
|
|
172
|
+
}>;
|
|
173
|
+
export type ValidationResult = z.infer<typeof ValidationResultSchema>;
|
|
174
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/schemas/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,wBAAwB,yCAAuC,CAAC;AAC7E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;EAMhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAO3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;EAKnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const ValidationSeveritySchema = z.enum(["error", "warning", "info"]);
|
|
3
|
+
export const ValidationIssueSchema = z.object({
|
|
4
|
+
type: z.string(),
|
|
5
|
+
severity: ValidationSeveritySchema,
|
|
6
|
+
field: z.string(),
|
|
7
|
+
message: z.string(),
|
|
8
|
+
suggestion: z.string().optional(),
|
|
9
|
+
});
|
|
10
|
+
export const SmartScoreSchema = z.object({
|
|
11
|
+
specific: z.number().min(0).max(1),
|
|
12
|
+
measurable: z.number().min(0).max(1),
|
|
13
|
+
achievable: z.number().min(0).max(1),
|
|
14
|
+
relevant: z.number().min(0).max(1),
|
|
15
|
+
timeBound: z.number().min(0).max(1),
|
|
16
|
+
overall: z.number().min(0).max(1),
|
|
17
|
+
});
|
|
18
|
+
export const ValidationMetadataSchema = z.object({
|
|
19
|
+
criteriaCount: z.number(),
|
|
20
|
+
hasDescription: z.boolean(),
|
|
21
|
+
hasDependencyIssues: z.boolean(),
|
|
22
|
+
validatedAt: z.string(),
|
|
23
|
+
});
|
|
24
|
+
export const ValidationResultSchema = z.object({
|
|
25
|
+
id: z.string(),
|
|
26
|
+
valid: z.boolean(),
|
|
27
|
+
issues: z.array(ValidationIssueSchema),
|
|
28
|
+
smartScore: SmartScoreSchema,
|
|
29
|
+
metadata: ValidationMetadataSchema,
|
|
30
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AG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAClC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE;IAC3B,mBAAmB,EAAE,CAAC,CAAC,OAAO,EAAE;IAChC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE;IAClB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC;IACtC,UAAU,EAAE,gBAAgB;IAC5B,QAAQ,EAAE,wBAAwB;CACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ZodError, type ZodIssue } from "zod";
|
|
2
|
+
export interface FormatOptions {
|
|
3
|
+
prefix?: string;
|
|
4
|
+
separator?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* パスをフォーマットする
|
|
8
|
+
* @param path - パス配列
|
|
9
|
+
* @returns フォーマットされたパス文字列
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatPath(path: (string | number)[]): string;
|
|
12
|
+
/**
|
|
13
|
+
* ZodIssueをフォーマットする
|
|
14
|
+
* @param issue - ZodIssue
|
|
15
|
+
* @returns フォーマットされたエラーメッセージ
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatZodIssue(issue: ZodIssue): string;
|
|
18
|
+
/**
|
|
19
|
+
* ZodErrorをフォーマットする
|
|
20
|
+
* @param error - ZodError
|
|
21
|
+
* @param options - フォーマットオプション
|
|
22
|
+
* @returns フォーマットされたエラーメッセージ
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatZodError(error: ZodError, options?: FormatOptions): string;
|
|
25
|
+
//# sourceMappingURL=zod-error-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod-error-formatter.d.ts","sourceRoot":"","sources":["../../src/utils/zod-error-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM,CAuB5D;AAYD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAwDtD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAc/E"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* パスをフォーマットする
|
|
3
|
+
* @param path - パス配列
|
|
4
|
+
* @returns フォーマットされたパス文字列
|
|
5
|
+
*/
|
|
6
|
+
export function formatPath(path) {
|
|
7
|
+
if (path.length === 0) {
|
|
8
|
+
return "(root)";
|
|
9
|
+
}
|
|
10
|
+
let result = "";
|
|
11
|
+
for (let i = 0; i < path.length; i++) {
|
|
12
|
+
const segment = path[i];
|
|
13
|
+
if (typeof segment === "number") {
|
|
14
|
+
// 配列インデックス
|
|
15
|
+
result += `[${segment}]`;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// プロパティ名
|
|
19
|
+
if (i === 0) {
|
|
20
|
+
result = segment;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
result += `.${segment}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
const TYPE_NAMES_JA = {
|
|
30
|
+
string: "文字列",
|
|
31
|
+
number: "数値",
|
|
32
|
+
boolean: "真偽値",
|
|
33
|
+
object: "オブジェクト",
|
|
34
|
+
array: "配列",
|
|
35
|
+
null: "null",
|
|
36
|
+
undefined: "未定義",
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* ZodIssueをフォーマットする
|
|
40
|
+
* @param issue - ZodIssue
|
|
41
|
+
* @returns フォーマットされたエラーメッセージ
|
|
42
|
+
*/
|
|
43
|
+
export function formatZodIssue(issue) {
|
|
44
|
+
const path = formatPath(issue.path);
|
|
45
|
+
switch (issue.code) {
|
|
46
|
+
case "invalid_type": {
|
|
47
|
+
const expected = TYPE_NAMES_JA[issue.expected] || issue.expected;
|
|
48
|
+
const received = TYPE_NAMES_JA[issue.received] || issue.received;
|
|
49
|
+
return `${path}: ${expected}が必要です(実際の型: ${received})`;
|
|
50
|
+
}
|
|
51
|
+
case "invalid_enum_value": {
|
|
52
|
+
const options = issue.options.map((o) => `'${o}'`).join(", ");
|
|
53
|
+
return `${path}: 不正な値 '${issue.received}'(期待値: ${options})`;
|
|
54
|
+
}
|
|
55
|
+
case "too_small": {
|
|
56
|
+
const minimum = issue.minimum;
|
|
57
|
+
if (issue.type === "string") {
|
|
58
|
+
return `${path}: ${minimum}文字以上の文字列が必要です`;
|
|
59
|
+
}
|
|
60
|
+
else if (issue.type === "number") {
|
|
61
|
+
if (issue.exact === false && minimum === 0 && !issue.inclusive) {
|
|
62
|
+
return `${path}: 正の数値が必要です`;
|
|
63
|
+
}
|
|
64
|
+
return `${path}: ${minimum}以上の数値が必要です`;
|
|
65
|
+
}
|
|
66
|
+
else if (issue.type === "array") {
|
|
67
|
+
return `${path}: ${minimum}個以上の要素が必要です`;
|
|
68
|
+
}
|
|
69
|
+
return `${path}: ${issue.message}`;
|
|
70
|
+
}
|
|
71
|
+
case "too_big": {
|
|
72
|
+
const maximum = issue.maximum;
|
|
73
|
+
if (issue.type === "string") {
|
|
74
|
+
return `${path}: ${maximum}文字以下の文字列が必要です`;
|
|
75
|
+
}
|
|
76
|
+
else if (issue.type === "number") {
|
|
77
|
+
return `${path}: ${maximum}以下の数値が必要です`;
|
|
78
|
+
}
|
|
79
|
+
else if (issue.type === "array") {
|
|
80
|
+
return `${path}: ${maximum}個以下の要素が必要です`;
|
|
81
|
+
}
|
|
82
|
+
return `${path}: ${issue.message}`;
|
|
83
|
+
}
|
|
84
|
+
case "invalid_string": {
|
|
85
|
+
return `${path}: 形式が不正です`;
|
|
86
|
+
}
|
|
87
|
+
case "unrecognized_keys": {
|
|
88
|
+
const keys = issue.keys.join(", ");
|
|
89
|
+
return `${path}: 不明なフィールド '${keys}'`;
|
|
90
|
+
}
|
|
91
|
+
default: {
|
|
92
|
+
// Fallback for other error codes
|
|
93
|
+
return `${path}: ${issue.message}`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* ZodErrorをフォーマットする
|
|
99
|
+
* @param error - ZodError
|
|
100
|
+
* @param options - フォーマットオプション
|
|
101
|
+
* @returns フォーマットされたエラーメッセージ
|
|
102
|
+
*/
|
|
103
|
+
export function formatZodError(error, options) {
|
|
104
|
+
const prefix = options?.prefix ?? "- ";
|
|
105
|
+
const separator = options?.separator ?? "\n";
|
|
106
|
+
if (error.issues.length === 0) {
|
|
107
|
+
return "";
|
|
108
|
+
}
|
|
109
|
+
const formattedIssues = error.issues.map((issue) => {
|
|
110
|
+
const message = formatZodIssue(issue);
|
|
111
|
+
return `${prefix}${message}`;
|
|
112
|
+
});
|
|
113
|
+
return formattedIssues.join(separator);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=zod-error-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod-error-formatter.js","sourceRoot":"","sources":["../../src/utils/zod-error-formatter.ts"],"names":[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