@fixerorg/schemas 1.0.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +1376 -0
  2. package/dist/index.js +435 -0
  3. package/package.json +37 -0
package/dist/index.js ADDED
@@ -0,0 +1,435 @@
1
+ // src/routes.ts
2
+ var API_BASE = "/api";
3
+ var API_ROUTES = {
4
+ settings: "/api/settings",
5
+ projects: "/api/projects",
6
+ tasks: "/api/tasks",
7
+ github: "/api/github",
8
+ worktree: "/api/worktree",
9
+ issueTemplates: "/api/issue-templates",
10
+ health: "/api/health"
11
+ };
12
+ var SETTINGS = {
13
+ /** 获取/更新设置 */
14
+ base: `${API_BASE}/settings`,
15
+ /** GitHub Token 验证 */
16
+ verifyGithub: `${API_BASE}/settings/github/verify`
17
+ };
18
+ var PROJECTS = {
19
+ /** 项目列表 */
20
+ list: `${API_BASE}/projects`,
21
+ /** 单个项目 */
22
+ detail: (projectId) => `${API_BASE}/projects/${projectId}`,
23
+ /** 同步项目 */
24
+ sync: (projectId) => `${API_BASE}/projects/${projectId}/sync`
25
+ };
26
+ var ISSUES = {
27
+ /** 项目下的 Issue 列表 */
28
+ listByProject: (projectId) => `${API_BASE}/projects/${projectId}/issues`,
29
+ /** 创建 Issue */
30
+ create: (projectId) => `${API_BASE}/projects/${projectId}/issues`,
31
+ /** 单个 Issue */
32
+ detail: (projectId, issueId) => `${API_BASE}/projects/${projectId}/issues/${issueId}`,
33
+ /** 更新 Issue */
34
+ update: (projectId, issueId) => `${API_BASE}/projects/${projectId}/issues/${issueId}`,
35
+ /** 删除 Issue */
36
+ delete: (projectId, issueId) => `${API_BASE}/projects/${projectId}/issues/${issueId}`,
37
+ /** AI 聊天 */
38
+ aiChat: (projectId, issueId) => `${API_BASE}/projects/${projectId}/issues/${issueId}/ai/chat`
39
+ };
40
+ var TASKS = {
41
+ /** Issue 下的 Task 列表 */
42
+ listByIssue: (issueId) => `${API_BASE}/tasks/issue/${issueId}`,
43
+ /** 创建 Task */
44
+ create: (issueId) => `${API_BASE}/tasks/issue/${issueId}`,
45
+ /** 单个 Task */
46
+ detail: (taskId) => `${API_BASE}/tasks/${taskId}`,
47
+ /** 更新 Task */
48
+ update: (taskId) => `${API_BASE}/tasks/${taskId}`,
49
+ /** 取消 Task */
50
+ cancel: (taskId) => `${API_BASE}/tasks/${taskId}/cancel`,
51
+ /** 删除 Task */
52
+ delete: (taskId) => `${API_BASE}/tasks/${taskId}`
53
+ };
54
+ var GITHUB = {
55
+ /** 获取仓库列表 */
56
+ repos: `${API_BASE}/github/repos`,
57
+ /** 获取仓库分支 */
58
+ branches: (owner, repo) => `${API_BASE}/github/repos/${owner}/${repo}/branches`
59
+ };
60
+ var WORKTREE = {
61
+ /** 获取 Worktree 状态 */
62
+ status: (issueId) => `${API_BASE}/worktree/issue/${issueId}`,
63
+ /** 创建 Worktree */
64
+ create: (issueId) => `${API_BASE}/worktree/issue/${issueId}`,
65
+ /** 删除 Worktree */
66
+ delete: (issueId) => `${API_BASE}/worktree/issue/${issueId}`
67
+ };
68
+ var ISSUE_TEMPLATES = {
69
+ /** 模板列表(全局) */
70
+ list: `${API_BASE}/issue-templates`,
71
+ /** 获取项目下的模板列表 */
72
+ byProject: (projectId) => `${API_BASE}/issue-templates/project/${projectId}`,
73
+ /** 获取单个模板 */
74
+ detail: (projectId, name) => `${API_BASE}/issue-templates/project/${projectId}/${name}`
75
+ };
76
+ var AI = {
77
+ /** AI 聊天 (SSE) - 实际端点由 ISSUES.aiChat 提供 */
78
+ chat: (projectId, issueId) => ISSUES.aiChat(projectId, issueId)
79
+ };
80
+ var HEALTH = `${API_BASE}/health`;
81
+
82
+ // src/common.ts
83
+ import { z } from "zod";
84
+ var SyncStatusSchema = z.enum(["syncing", "synced", "error"]);
85
+ var IssueStatusSchema = z.enum(["open", "in_progress", "in_review", "done"]);
86
+ var IssuePrioritySchema = z.enum(["high", "medium", "low"]);
87
+ var TaskStatusSchema = z.enum(["pending", "active", "completed", "cancelled", "error"]);
88
+ var WorktreeStatusSchema = z.enum(["pending", "creating", "ready", "error"]);
89
+ var PaginatedResponseSchema = (itemSchema) => z.object({
90
+ items: z.array(itemSchema),
91
+ total: z.number().int().nonnegative(),
92
+ page: z.number().int().positive(),
93
+ per_page: z.number().int().positive(),
94
+ pages: z.number().int().nonnegative()
95
+ });
96
+ var PaginationQuerySchema = z.object({
97
+ page: z.coerce.number().int().positive().default(1),
98
+ per_page: z.coerce.number().int().positive().max(100).default(20)
99
+ });
100
+
101
+ // src/project.ts
102
+ import { z as z2 } from "zod";
103
+ var IssueStatsSchema = z2.object({
104
+ total: z2.number().int().nonnegative(),
105
+ done: z2.number().int().nonnegative()
106
+ });
107
+ var ProjectResponseSchema = z2.object({
108
+ id: z2.number().int(),
109
+ projectId: z2.string(),
110
+ name: z2.string(),
111
+ description: z2.string().nullable(),
112
+ color: z2.string(),
113
+ githubRepoId: z2.number().int().nullable(),
114
+ defaultBranch: z2.string(),
115
+ selectedBranch: z2.string(),
116
+ cloneUrl: z2.string().nullable(),
117
+ starsCount: z2.number().int().nonnegative(),
118
+ forksCount: z2.number().int().nonnegative(),
119
+ syncStatus: SyncStatusSchema,
120
+ localPath: z2.string().nullable(),
121
+ lastSyncAt: z2.coerce.date().nullable(),
122
+ lastActivity: z2.string().nullable(),
123
+ syncError: z2.string().nullable(),
124
+ createdAt: z2.coerce.date(),
125
+ updatedAt: z2.coerce.date(),
126
+ issueStats: IssueStatsSchema.optional()
127
+ });
128
+ var ProjectCreateSchema = z2.object({
129
+ repo: z2.string().min(1),
130
+ branch: z2.string().default("main")
131
+ });
132
+ var ProjectUpdateSchema = z2.object({
133
+ selectedBranch: z2.string().optional(),
134
+ color: z2.string().optional()
135
+ });
136
+ var ProjectListResponseSchema = PaginatedResponseSchema(ProjectResponseSchema);
137
+
138
+ // src/task.ts
139
+ import { z as z3 } from "zod";
140
+ var TaskResponseSchema = z3.object({
141
+ id: z3.number().int(),
142
+ issueId: z3.string(),
143
+ name: z3.string(),
144
+ status: TaskStatusSchema,
145
+ output: z3.unknown().nullable(),
146
+ startedAt: z3.coerce.date().nullable(),
147
+ completedAt: z3.coerce.date().nullable(),
148
+ createdAt: z3.coerce.date(),
149
+ updatedAt: z3.coerce.date()
150
+ });
151
+ var TaskCreateSchema = z3.object({
152
+ name: z3.string().min(1),
153
+ issueId: z3.string().min(1)
154
+ });
155
+ var TaskUpdateSchema = z3.object({
156
+ status: TaskStatusSchema.optional(),
157
+ output: z3.unknown().optional()
158
+ });
159
+ var TaskListResponseSchema = PaginatedResponseSchema(TaskResponseSchema);
160
+
161
+ // src/issue.ts
162
+ import { z as z4 } from "zod";
163
+ var IssueResponseSchema = z4.object({
164
+ id: z4.number().int(),
165
+ issueId: z4.string(),
166
+ projectId: z4.string(),
167
+ title: z4.string(),
168
+ description: z4.string().nullable(),
169
+ status: IssueStatusSchema,
170
+ priority: IssuePrioritySchema,
171
+ tags: z4.array(z4.string()),
172
+ branchName: z4.string().nullable(),
173
+ worktreePath: z4.string().nullable(),
174
+ worktreeStatus: WorktreeStatusSchema,
175
+ worktreeError: z4.string().nullable(),
176
+ worktreeCreatedAt: z4.coerce.date().nullable(),
177
+ createdAt: z4.coerce.date(),
178
+ updatedAt: z4.coerce.date()
179
+ });
180
+ var IssueCreateSchema = z4.object({
181
+ title: z4.string().min(1),
182
+ description: z4.string().optional(),
183
+ priority: IssuePrioritySchema.optional(),
184
+ tags: z4.array(z4.string()).optional()
185
+ });
186
+ var IssueUpdateSchema = z4.object({
187
+ title: z4.string().min(1).optional(),
188
+ description: z4.string().optional(),
189
+ status: IssueStatusSchema.optional(),
190
+ priority: IssuePrioritySchema.optional(),
191
+ tags: z4.array(z4.string()).optional()
192
+ });
193
+ var IssueListResponseSchema = PaginatedResponseSchema(IssueResponseSchema);
194
+
195
+ // src/settings.ts
196
+ import { z as z5 } from "zod";
197
+ var SettingsResponseSchema = z5.object({
198
+ githubUsername: z5.string().nullable(),
199
+ githubToken: z5.string().nullable(),
200
+ hasGithubToken: z5.boolean(),
201
+ baseModel: z5.string(),
202
+ apiKey: z5.string().nullable(),
203
+ hasApiKey: z5.boolean(),
204
+ apiEndpoint: z5.string(),
205
+ proxyUrl: z5.string().nullable(),
206
+ proxyEnabled: z5.boolean(),
207
+ reposPath: z5.string().nullable()
208
+ });
209
+ var SettingsUpdateSchema = z5.object({
210
+ githubUsername: z5.string().optional(),
211
+ githubToken: z5.string().optional(),
212
+ baseModel: z5.string().optional(),
213
+ apiKey: z5.string().optional(),
214
+ apiEndpoint: z5.string().optional(),
215
+ proxyUrl: z5.string().optional(),
216
+ proxyEnabled: z5.boolean().optional(),
217
+ reposPath: z5.string().optional()
218
+ });
219
+ var GitHubVerifyRequestSchema = z5.object({
220
+ githubToken: z5.string().min(1),
221
+ githubUsername: z5.string().optional()
222
+ });
223
+ var GitHubVerifyResponseSchema = z5.object({
224
+ success: z5.boolean(),
225
+ username: z5.string().optional(),
226
+ reposCount: z5.number().int().nonnegative().optional(),
227
+ error: z5.string().optional()
228
+ });
229
+
230
+ // src/ai-chat.ts
231
+ import { z as z6 } from "zod";
232
+ var AIChatRequestSchema = z6.object({
233
+ message: z6.string().min(1),
234
+ cwd: z6.string().optional(),
235
+ session_id: z6.string().optional()
236
+ });
237
+ var AIMessageSchema = z6.object({
238
+ id: z6.union([z6.string(), z6.number().int()]),
239
+ role: z6.enum(["user", "assistant"]),
240
+ content: z6.string(),
241
+ createdAt: z6.coerce.date()
242
+ });
243
+ var AIChatResponseSchema = z6.object({
244
+ sessionId: z6.string(),
245
+ message: AIMessageSchema
246
+ });
247
+ var AISessionResponseSchema = z6.object({
248
+ sessionId: z6.string(),
249
+ messages: z6.array(AIMessageSchema)
250
+ });
251
+ var ThinkingStartEventSchema = z6.object({
252
+ type: z6.literal("thinking_start")
253
+ });
254
+ var ThinkingDeltaEventSchema = z6.object({
255
+ type: z6.literal("thinking_delta"),
256
+ thinking: z6.string()
257
+ });
258
+ var ThinkingEndEventSchema = z6.object({
259
+ type: z6.literal("thinking_end")
260
+ });
261
+ var ContentDeltaEventSchema = z6.object({
262
+ type: z6.literal("content_delta"),
263
+ content: z6.string()
264
+ });
265
+ var ToolStartEventSchema = z6.object({
266
+ type: z6.literal("tool_start"),
267
+ tool_use_id: z6.string(),
268
+ name: z6.string(),
269
+ input: z6.record(z6.any())
270
+ });
271
+ var ToolResultEventSchema = z6.object({
272
+ type: z6.literal("tool_result"),
273
+ tool_use_id: z6.string(),
274
+ content: z6.string(),
275
+ is_error: z6.boolean().optional()
276
+ });
277
+ var MessageDoneEventSchema = z6.object({
278
+ type: z6.literal("message_done")
279
+ });
280
+ var ErrorEventSchema = z6.object({
281
+ type: z6.literal("error"),
282
+ message: z6.string()
283
+ });
284
+ var SSEEventSchema = z6.union([
285
+ ThinkingStartEventSchema,
286
+ ThinkingDeltaEventSchema,
287
+ ThinkingEndEventSchema,
288
+ ContentDeltaEventSchema,
289
+ ToolStartEventSchema,
290
+ ToolResultEventSchema,
291
+ MessageDoneEventSchema,
292
+ ErrorEventSchema
293
+ ]);
294
+
295
+ // src/github.ts
296
+ import { z as z7 } from "zod";
297
+ var RepositorySchema = z7.object({
298
+ id: z7.number().int().positive(),
299
+ name: z7.string(),
300
+ full_name: z7.string(),
301
+ description: z7.string().nullable(),
302
+ clone_url: z7.string().url(),
303
+ default_branch: z7.string(),
304
+ stargazers_count: z7.number().int().nonnegative(),
305
+ forks_count: z7.number().int().nonnegative(),
306
+ private: z7.boolean()
307
+ });
308
+ var BranchSchema = z7.object({
309
+ name: z7.string()
310
+ });
311
+ var RepoOptionSchema = z7.object({
312
+ value: z7.string(),
313
+ // full_name
314
+ label: z7.string(),
315
+ // full_name
316
+ description: z7.string().nullable()
317
+ });
318
+ var BranchOptionSchema = z7.object({
319
+ value: z7.string(),
320
+ // branch name
321
+ label: z7.string()
322
+ // branch name
323
+ });
324
+ var GitHubReposResponseSchema = z7.object({
325
+ repos: z7.array(RepoOptionSchema)
326
+ });
327
+ var GitHubBranchesResponseSchema = z7.object({
328
+ branches: z7.array(BranchOptionSchema)
329
+ });
330
+
331
+ // src/template.ts
332
+ import { z as z8 } from "zod";
333
+ var IssueTemplateListItemSchema = z8.object({
334
+ id: z8.string(),
335
+ name: z8.string(),
336
+ description: z8.string()
337
+ });
338
+ var IssueTemplateSchema = z8.object({
339
+ id: z8.string(),
340
+ name: z8.string(),
341
+ description: z8.string(),
342
+ body: z8.string()
343
+ });
344
+ var IssueTemplateListResponseSchema = z8.object({
345
+ templates: z8.array(IssueTemplateListItemSchema)
346
+ });
347
+
348
+ // src/utils.ts
349
+ import { z as z9 } from "zod";
350
+ var RetryOptionsSchema = z9.object({
351
+ maxRetries: z9.number().int().nonnegative().default(3),
352
+ delayMs: z9.number().int().positive().default(1e3),
353
+ backoffMultiplier: z9.number().positive().default(2),
354
+ onRetry: z9.function(z9.tuple([z9.instanceof(Error), z9.number().int()]), z9.void()).optional()
355
+ });
356
+
357
+ // src/worktree.ts
358
+ import { z as z10 } from "zod";
359
+ var WorktreeCreateRequestSchema = z10.object({
360
+ branch: z10.string().min(1),
361
+ force: z10.boolean().optional()
362
+ });
363
+ var WorktreeDeleteRequestSchema = z10.object({
364
+ issueId: z10.string().min(1)
365
+ });
366
+ var WorktreeStatusResponseSchema = z10.object({
367
+ issueId: z10.string(),
368
+ status: WorktreeStatusSchema,
369
+ path: z10.string().nullable(),
370
+ branchName: z10.string().nullable(),
371
+ error: z10.string().nullable()
372
+ });
373
+ export {
374
+ AI,
375
+ AIChatRequestSchema,
376
+ AIChatResponseSchema,
377
+ AIMessageSchema,
378
+ AISessionResponseSchema,
379
+ API_BASE,
380
+ API_ROUTES,
381
+ BranchOptionSchema,
382
+ BranchSchema,
383
+ ContentDeltaEventSchema,
384
+ ErrorEventSchema,
385
+ GITHUB,
386
+ GitHubBranchesResponseSchema,
387
+ GitHubReposResponseSchema,
388
+ GitHubVerifyRequestSchema,
389
+ GitHubVerifyResponseSchema,
390
+ HEALTH,
391
+ ISSUES,
392
+ ISSUE_TEMPLATES,
393
+ IssueCreateSchema,
394
+ IssueListResponseSchema,
395
+ IssuePrioritySchema,
396
+ IssueResponseSchema,
397
+ IssueStatsSchema,
398
+ IssueStatusSchema,
399
+ IssueTemplateListItemSchema,
400
+ IssueTemplateListResponseSchema,
401
+ IssueTemplateSchema,
402
+ IssueUpdateSchema,
403
+ MessageDoneEventSchema,
404
+ PROJECTS,
405
+ PaginatedResponseSchema,
406
+ PaginationQuerySchema,
407
+ ProjectCreateSchema,
408
+ ProjectListResponseSchema,
409
+ ProjectResponseSchema,
410
+ ProjectUpdateSchema,
411
+ RepoOptionSchema,
412
+ RepositorySchema,
413
+ RetryOptionsSchema,
414
+ SETTINGS,
415
+ SSEEventSchema,
416
+ SettingsResponseSchema,
417
+ SettingsUpdateSchema,
418
+ SyncStatusSchema,
419
+ TASKS,
420
+ TaskCreateSchema,
421
+ TaskListResponseSchema,
422
+ TaskResponseSchema,
423
+ TaskStatusSchema,
424
+ TaskUpdateSchema,
425
+ ThinkingDeltaEventSchema,
426
+ ThinkingEndEventSchema,
427
+ ThinkingStartEventSchema,
428
+ ToolResultEventSchema,
429
+ ToolStartEventSchema,
430
+ WORKTREE,
431
+ WorktreeCreateRequestSchema,
432
+ WorktreeDeleteRequestSchema,
433
+ WorktreeStatusResponseSchema,
434
+ WorktreeStatusSchema
435
+ };
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@fixerorg/schemas",
3
+ "version": "1.0.0",
4
+ "description": "Shared schemas for Fixer - AI-powered Issue Management System",
5
+ "author": "zhangyingwei",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": ["dist"],
17
+ "scripts": {
18
+ "build": "tsup src/index.ts --format esm --dts",
19
+ "dev": "tsup src/index.ts --format esm --dts --watch",
20
+ "prepublishOnly": "pnpm build"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/zhangyingwei/superdev.git",
28
+ "directory": "packages/schemas"
29
+ },
30
+ "dependencies": {
31
+ "zod": "^3.24.0"
32
+ },
33
+ "devDependencies": {
34
+ "tsup": "^8.0.0",
35
+ "typescript": "^5.7.0"
36
+ }
37
+ }