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 { z } from "zod";
|
|
|
|
|
import { COMPANY_STATUSES } from "../constants.js";
|
|
|
|
|
|
2026-03-16 09:25:39 -05:00
|
|
|
const logoAssetIdSchema = z.string().uuid().nullable().optional();
|
2026-03-18 21:03:41 -05:00
|
|
|
const brandColorSchema = z.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional();
|
2026-03-06 16:39:35 -05:00
|
|
|
|
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
|
|
|
export const createCompanySchema = z.object({
|
|
|
|
|
name: z.string().min(1),
|
|
|
|
|
description: z.string().optional().nullable(),
|
|
|
|
|
budgetMonthlyCents: z.number().int().nonnegative().optional().default(0),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type CreateCompany = z.infer<typeof createCompanySchema>;
|
|
|
|
|
|
|
|
|
|
export const updateCompanySchema = createCompanySchema
|
|
|
|
|
.partial()
|
|
|
|
|
.extend({
|
|
|
|
|
status: z.enum(COMPANY_STATUSES).optional(),
|
|
|
|
|
spentMonthlyCents: z.number().int().nonnegative().optional(),
|
2026-02-19 09:10:38 -06:00
|
|
|
requireBoardApprovalForNewAgents: z.boolean().optional(),
|
2026-03-18 21:03:41 -05:00
|
|
|
brandColor: brandColorSchema,
|
2026-03-16 09:25:39 -05:00
|
|
|
logoAssetId: logoAssetIdSchema,
|
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
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type UpdateCompany = z.infer<typeof updateCompanySchema>;
|
2026-03-18 21:03:41 -05:00
|
|
|
|
|
|
|
|
export const updateCompanyBrandingSchema = z
|
|
|
|
|
.object({
|
2026-03-20 06:25:24 -05:00
|
|
|
name: z.string().min(1).optional(),
|
|
|
|
|
description: z.string().nullable().optional(),
|
2026-03-18 21:03:41 -05:00
|
|
|
brandColor: brandColorSchema,
|
|
|
|
|
logoAssetId: logoAssetIdSchema,
|
|
|
|
|
})
|
|
|
|
|
.strict()
|
|
|
|
|
.refine(
|
2026-03-20 06:25:24 -05:00
|
|
|
(value) =>
|
|
|
|
|
value.name !== undefined
|
|
|
|
|
|| value.description !== undefined
|
|
|
|
|
|| value.brandColor !== undefined
|
|
|
|
|
|| value.logoAssetId !== undefined,
|
2026-03-18 21:03:41 -05:00
|
|
|
"At least one branding field must be provided",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export type UpdateCompanyBranding = z.infer<typeof updateCompanyBrandingSchema>;
|