Add shared types package
Shared TypeScript types, Zod validators, API contract definitions, and constants used by both server and UI. Covers agents, goals, issues, projects, and activity entities. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
20
packages/shared/src/validators/agent.ts
Normal file
20
packages/shared/src/validators/agent.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { z } from "zod";
|
||||
import { AGENT_ROLES, AGENT_STATUSES } from "../constants.js";
|
||||
|
||||
export const createAgentSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
role: z.enum(AGENT_ROLES),
|
||||
budgetCents: z.number().int().nonnegative().optional().default(0),
|
||||
reportsTo: z.string().uuid().optional().nullable(),
|
||||
metadata: z.record(z.unknown()).optional().nullable(),
|
||||
});
|
||||
|
||||
export type CreateAgent = z.infer<typeof createAgentSchema>;
|
||||
|
||||
export const updateAgentSchema = createAgentSchema
|
||||
.partial()
|
||||
.extend({
|
||||
status: z.enum(AGENT_STATUSES).optional(),
|
||||
});
|
||||
|
||||
export type UpdateAgent = z.infer<typeof updateAgentSchema>;
|
||||
16
packages/shared/src/validators/goal.ts
Normal file
16
packages/shared/src/validators/goal.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { z } from "zod";
|
||||
import { GOAL_LEVELS } from "../constants.js";
|
||||
|
||||
export const createGoalSchema = z.object({
|
||||
title: z.string().min(1),
|
||||
description: z.string().optional().nullable(),
|
||||
level: z.enum(GOAL_LEVELS),
|
||||
parentId: z.string().uuid().optional().nullable(),
|
||||
ownerId: z.string().uuid().optional().nullable(),
|
||||
});
|
||||
|
||||
export type CreateGoal = z.infer<typeof createGoalSchema>;
|
||||
|
||||
export const updateGoalSchema = createGoalSchema.partial();
|
||||
|
||||
export type UpdateGoal = z.infer<typeof updateGoalSchema>;
|
||||
27
packages/shared/src/validators/index.ts
Normal file
27
packages/shared/src/validators/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export {
|
||||
createAgentSchema,
|
||||
updateAgentSchema,
|
||||
type CreateAgent,
|
||||
type UpdateAgent,
|
||||
} from "./agent.js";
|
||||
|
||||
export {
|
||||
createProjectSchema,
|
||||
updateProjectSchema,
|
||||
type CreateProject,
|
||||
type UpdateProject,
|
||||
} from "./project.js";
|
||||
|
||||
export {
|
||||
createIssueSchema,
|
||||
updateIssueSchema,
|
||||
type CreateIssue,
|
||||
type UpdateIssue,
|
||||
} from "./issue.js";
|
||||
|
||||
export {
|
||||
createGoalSchema,
|
||||
updateGoalSchema,
|
||||
type CreateGoal,
|
||||
type UpdateGoal,
|
||||
} from "./goal.js";
|
||||
18
packages/shared/src/validators/issue.ts
Normal file
18
packages/shared/src/validators/issue.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { z } from "zod";
|
||||
import { ISSUE_PRIORITIES, ISSUE_STATUSES } from "../constants.js";
|
||||
|
||||
export const createIssueSchema = z.object({
|
||||
title: z.string().min(1),
|
||||
description: z.string().optional().nullable(),
|
||||
status: z.enum(ISSUE_STATUSES).optional().default("backlog"),
|
||||
priority: z.enum(ISSUE_PRIORITIES).optional().default("medium"),
|
||||
projectId: z.string().uuid().optional().nullable(),
|
||||
assigneeId: z.string().uuid().optional().nullable(),
|
||||
goalId: z.string().uuid().optional().nullable(),
|
||||
});
|
||||
|
||||
export type CreateIssue = z.infer<typeof createIssueSchema>;
|
||||
|
||||
export const updateIssueSchema = createIssueSchema.partial();
|
||||
|
||||
export type UpdateIssue = z.infer<typeof updateIssueSchema>;
|
||||
12
packages/shared/src/validators/project.ts
Normal file
12
packages/shared/src/validators/project.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const createProjectSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
description: z.string().optional().nullable(),
|
||||
});
|
||||
|
||||
export type CreateProject = z.infer<typeof createProjectSchema>;
|
||||
|
||||
export const updateProjectSchema = createProjectSchema.partial();
|
||||
|
||||
export type UpdateProject = z.infer<typeof updateProjectSchema>;
|
||||
Reference in New Issue
Block a user