diff options
| author | soryu <soryu@soryu.co> | 2026-01-29 02:56:44 +0000 |
|---|---|---|
| committer | soryu <soryu@soryu.co> | 2026-01-29 02:56:44 +0000 |
| commit | f19acd400cc5bbe1fe51c004c50ee90d704240d8 (patch) | |
| tree | b7dcfd6926efcafd6eac33e713ebd321ec4284d0 /makima/frontend/src/lib | |
| parent | 7af8561677cfdcfd23d099a25783c7fef51d1ba6 (diff) | |
| download | soryu-f19acd400cc5bbe1fe51c004c50ee90d704240d8.tar.gz soryu-f19acd400cc5bbe1fe51c004c50ee90d704240d8.zip | |
Fix contract type selection
Diffstat (limited to 'makima/frontend/src/lib')
| -rw-r--r-- | makima/frontend/src/lib/api.ts | 120 |
1 files changed, 116 insertions, 4 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts index 8838dbd..e8b3d8a 100644 --- a/makima/frontend/src/lib/api.ts +++ b/makima/frontend/src/lib/api.ts @@ -1645,6 +1645,56 @@ export interface ListContractTypesResponse { contractTypes: ContractTypeTemplate[]; } +/** Phase definition for custom templates */ +export interface PhaseDefinition { + id: string; + name: string; + order: number; +} + +/** Deliverable definition for custom templates */ +export interface DeliverableDefinition { + id: string; + name: string; + priority: "required" | "recommended" | "optional"; +} + +/** Request to create a custom contract type template */ +export interface CreateTemplateRequest { + name: string; + description?: string; + phases: PhaseDefinition[]; + defaultPhase: string; + deliverables?: Record<string, DeliverableDefinition[]>; +} + +/** Request to update a custom contract type template */ +export interface UpdateTemplateRequest { + name?: string; + description?: string; + phases?: PhaseDefinition[]; + defaultPhase?: string; + deliverables?: Record<string, DeliverableDefinition[]>; + version?: number; +} + +/** Custom template record from the API */ +export interface ContractTypeTemplateRecord { + id: string; + name: string; + description: string | null; + phases: PhaseDefinition[]; + defaultPhase: string; + isBuiltin: boolean; + version: number; + createdAt: string; +} + +/** Response for single template operations */ +export interface TemplateResponse { + template: ContractTypeTemplateRecord; +} + /** * List available contract types/templates. * Returns built-in types (simple, specification) and any custom types. @@ -1657,6 +1707,66 @@ export async function listContractTypes(): Promise<ListContractTypesResponse> { return res.json(); } +/** + * Create a new custom contract type template. + */ +export async function createContractTemplate( + req: CreateTemplateRequest +): Promise<TemplateResponse> { + const res = await authFetch(`${API_BASE}/api/v1/contract-types`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(req), + }); + if (!res.ok) { + const err = await res.json().catch(() => ({ message: res.statusText })); + throw new Error(err.message || `Failed to create template: ${res.statusText}`); + } + return res.json(); +} + +/** + * Get a custom contract type template by ID. + */ +export async function getContractTemplate(id: string): Promise<TemplateResponse> { + const res = await authFetch(`${API_BASE}/api/v1/contract-types/${id}`); + if (!res.ok) { + throw new Error(`Failed to get template: ${res.statusText}`); + } + return res.json(); +} + +/** + * Update a custom contract type template. + */ +export async function updateContractTemplate( + id: string, + req: UpdateTemplateRequest +): Promise<TemplateResponse> { + const res = await authFetch(`${API_BASE}/api/v1/contract-types/${id}`, { + method: "PUT", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(req), + }); + if (!res.ok) { + const err = await res.json().catch(() => ({ message: res.statusText })); + throw new Error(err.message || `Failed to update template: ${res.statusText}`); + } + return res.json(); +} + +/** + * Delete a custom contract type template. + */ +export async function deleteContractTemplate(id: string): Promise<void> { + const res = await authFetch(`${API_BASE}/api/v1/contract-types/${id}`, { + method: "DELETE", + }); + if (!res.ok) { + throw new Error(`Failed to delete template: ${res.statusText}`); + } +} + export interface ContractRepository { id: string; contractId: string; @@ -1741,10 +1851,12 @@ export interface ContractListResponse { export interface CreateContractRequest { name: string; description?: string; - /** Contract type: "simple" (default) or "specification" */ - contractType?: ContractType; - /** Initial phase to start in (defaults based on contract type) */ - initialPhase?: ContractPhase; + /** Contract type: "simple" (default), "specification", "execute", or custom template name */ + contractType?: ContractType | string; + /** UUID of a custom template to use. If provided, takes precedence over contractType. */ + templateId?: string; + /** Initial phase to start in (defaults based on contract type or template) */ + initialPhase?: ContractPhase | string; /** When true, tasks won't auto-push or create PRs - use patch files instead */ localOnly?: boolean; /** When true, spawn a red team task to monitor work output */ |
