2026-02-16 13:31:47 -06:00
|
|
|
import { z } from "zod";
|
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events,
heartbeat_runs, issue_comments. Add corresponding shared types and
validators. Update existing schemas (agents, goals, issues, projects)
with new fields for company association, budgets, and richer metadata.
Generate initial Drizzle migration. Update seed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:22 -06:00
|
|
|
import { PROJECT_STATUSES } from "../constants.js";
|
2026-02-16 13:31:47 -06:00
|
|
|
|
|
|
|
|
export const createProjectSchema = z.object({
|
2026-02-20 13:43:25 -06:00
|
|
|
/** @deprecated Use goalIds instead */
|
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events,
heartbeat_runs, issue_comments. Add corresponding shared types and
validators. Update existing schemas (agents, goals, issues, projects)
with new fields for company association, budgets, and richer metadata.
Generate initial Drizzle migration. Update seed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:22 -06:00
|
|
|
goalId: z.string().uuid().optional().nullable(),
|
2026-02-20 13:43:25 -06:00
|
|
|
goalIds: z.array(z.string().uuid()).optional(),
|
2026-02-16 13:31:47 -06:00
|
|
|
name: z.string().min(1),
|
|
|
|
|
description: z.string().optional().nullable(),
|
Expand data model with companies, approvals, costs, and heartbeats
Add new DB schemas: companies, agent_api_keys, approvals, cost_events,
heartbeat_runs, issue_comments. Add corresponding shared types and
validators. Update existing schemas (agents, goals, issues, projects)
with new fields for company association, budgets, and richer metadata.
Generate initial Drizzle migration. Update seed data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:22 -06:00
|
|
|
status: z.enum(PROJECT_STATUSES).optional().default("backlog"),
|
|
|
|
|
leadAgentId: z.string().uuid().optional().nullable(),
|
|
|
|
|
targetDate: z.string().optional().nullable(),
|
2026-02-23 09:14:08 -06:00
|
|
|
color: z.string().optional().nullable(),
|
|
|
|
|
archivedAt: z.string().datetime().optional().nullable(),
|
2026-02-16 13:31:47 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type CreateProject = z.infer<typeof createProjectSchema>;
|
|
|
|
|
|
|
|
|
|
export const updateProjectSchema = createProjectSchema.partial();
|
|
|
|
|
|
|
|
|
|
export type UpdateProject = z.infer<typeof updateProjectSchema>;
|
2026-02-25 08:38:46 -06:00
|
|
|
|
2026-02-25 21:35:33 -06:00
|
|
|
const projectWorkspaceFields = {
|
|
|
|
|
name: z.string().min(1).optional(),
|
|
|
|
|
cwd: z.string().min(1).optional().nullable(),
|
2026-02-25 08:38:46 -06:00
|
|
|
repoUrl: z.string().url().optional().nullable(),
|
|
|
|
|
repoRef: z.string().optional().nullable(),
|
|
|
|
|
metadata: z.record(z.unknown()).optional().nullable(),
|
2026-02-25 21:35:33 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createProjectWorkspaceSchema = z.object({
|
|
|
|
|
...projectWorkspaceFields,
|
2026-02-25 08:38:46 -06:00
|
|
|
isPrimary: z.boolean().optional().default(false),
|
2026-02-25 21:35:33 -06:00
|
|
|
}).superRefine((value, ctx) => {
|
|
|
|
|
const hasCwd = typeof value.cwd === "string" && value.cwd.trim().length > 0;
|
|
|
|
|
const hasRepo = typeof value.repoUrl === "string" && value.repoUrl.trim().length > 0;
|
|
|
|
|
if (!hasCwd && !hasRepo) {
|
|
|
|
|
ctx.addIssue({
|
|
|
|
|
code: z.ZodIssueCode.custom,
|
|
|
|
|
message: "Workspace requires at least one of cwd or repoUrl.",
|
|
|
|
|
path: ["cwd"],
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-02-25 08:38:46 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type CreateProjectWorkspace = z.infer<typeof createProjectWorkspaceSchema>;
|
|
|
|
|
|
2026-02-25 21:35:33 -06:00
|
|
|
export const updateProjectWorkspaceSchema = z.object({
|
|
|
|
|
...projectWorkspaceFields,
|
|
|
|
|
isPrimary: z.boolean().optional(),
|
|
|
|
|
}).partial();
|
2026-02-25 08:38:46 -06:00
|
|
|
|
|
|
|
|
export type UpdateProjectWorkspace = z.infer<typeof updateProjectWorkspaceSchema>;
|