summaryrefslogtreecommitdiff
path: root/makima/frontend/src/lib
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-25 03:53:55 +0000
committerGitHub <noreply@github.com>2026-01-25 03:53:55 +0000
commitc908854e7e3571c99cce9f46497ce5337ea0aed1 (patch)
tree3d35137a452c562059ecd8c759393b90937df70c /makima/frontend/src/lib
parent03ab90836707954277597dc21fd8035019d8e221 (diff)
downloadsoryu-c908854e7e3571c99cce9f46497ce5337ea0aed1.tar.gz
soryu-c908854e7e3571c99cce9f46497ce5337ea0aed1.zip
Update create contract page to use dynamic templates (#29)
* feat: Add contract type templates API endpoint Add a new API endpoint to provide contract type templates (workflow definitions) separate from file templates. This enables the create contract page to dynamically show available contract types. Changes: - Add ContractTypeTemplate struct in templates.rs with id, name, description, phases, default_phase, and is_builtin fields - Add built-in contract types: 'simple' (plan/execute) and 'specification' (research/specify/plan/execute/review) - Add GET /api/v1/contract-types endpoint returning all contract types - Add frontend ContractTypeTemplate interface and listContractTypes() API function Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: Update create contract modal to use dynamic templates - Add ContractTypeTemplate interface and listContractTypes API function to frontend api.ts - Add GET /api/v1/contract-types backend endpoint that returns built-in contract types (simple, specification) with their phases and defaults - Update create contract modal to fetch contract types dynamically when opened, with loading state and fallback to hardcoded types on error - Dynamically render contract type selection buttons from fetched types - Update phase dropdown to use phases from selected contract type - Replace static getValidPhases/getDefaultPhase calls with dynamic data Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'makima/frontend/src/lib')
-rw-r--r--makima/frontend/src/lib/api.ts73
1 files changed, 73 insertions, 0 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts
index 76ee4d4..64ce591 100644
--- a/makima/frontend/src/lib/api.ts
+++ b/makima/frontend/src/lib/api.ts
@@ -1507,6 +1507,43 @@ export function getDefaultPhase(contractType: ContractType): ContractPhase {
return "research";
}
+// =============================================================================
+// Contract Type Templates
+// =============================================================================
+
+/** Contract type template returned by the API */
+export interface ContractTypeTemplate {
+ /** Template identifier (e.g., "simple", "specification") */
+ id: string;
+ /** Display name */
+ name: string;
+ /** Description of the contract type workflow */
+ description: string;
+ /** Ordered list of phases for this contract type */
+ phases: ContractPhase[];
+ /** Default starting phase */
+ defaultPhase: ContractPhase;
+ /** Whether this is a built-in type (always available) */
+ isBuiltin: boolean;
+}
+
+/** Response from list contract types endpoint */
+export interface ListContractTypesResponse {
+ types: ContractTypeTemplate[];
+}
+
+/**
+ * List available contract types/templates.
+ * Returns built-in types (simple, specification) and any custom types.
+ */
+export async function listContractTypes(): Promise<ListContractTypesResponse> {
+ const res = await authFetch(`${API_BASE}/api/v1/contract-types`);
+ if (!res.ok) {
+ throw new Error(`Failed to list contract types: ${res.statusText}`);
+ }
+ return res.json();
+}
+
export interface ContractRepository {
id: string;
contractId: string;
@@ -2008,6 +2045,42 @@ export async function getTemplate(id: string): Promise<FileTemplate> {
}
// =============================================================================
+// Contract Type Templates (Workflow Definitions)
+// =============================================================================
+
+/** A contract type template defining a workflow */
+export interface ContractTypeTemplate {
+ /** Unique identifier (e.g., 'simple', 'specification', 'feature-development') */
+ id: string;
+ /** Display name */
+ name: string;
+ /** What this contract type is for */
+ description: string;
+ /** Ordered list of phases in the workflow */
+ phases: string[];
+ /** Starting phase */
+ defaultPhase: string;
+ /** True for built-in types ('simple', 'specification') */
+ isBuiltin: boolean;
+}
+
+export interface ListContractTypesResponse {
+ contractTypes: ContractTypeTemplate[];
+}
+
+/**
+ * List all available contract type templates.
+ * Returns built-in types (simple, specification) and any custom types.
+ */
+export async function listContractTypes(): Promise<ListContractTypesResponse> {
+ const res = await authFetch(`${API_BASE}/api/v1/contract-types`);
+ if (!res.ok) {
+ throw new Error(`Failed to list contract types: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+// =============================================================================
// Supervisor Question Types and Functions
// =============================================================================