Some checks failed
ci/woodpecker/push/web Pipeline failed
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
81 lines
1.9 KiB
TypeScript
81 lines
1.9 KiB
TypeScript
/**
|
|
* Personality API Client
|
|
* Handles personality-related API requests
|
|
*/
|
|
|
|
import type { Personality, FormalityLevel } from "@mosaic/shared";
|
|
import { apiGet, apiPost, apiPatch, apiDelete, type ApiResponse } from "./client";
|
|
|
|
/**
|
|
* Create personality DTO
|
|
*/
|
|
export interface CreatePersonalityDto {
|
|
name: string;
|
|
description?: string;
|
|
tone: string;
|
|
formalityLevel: FormalityLevel;
|
|
systemPromptTemplate: string;
|
|
isDefault?: boolean;
|
|
isActive?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Update personality DTO
|
|
*/
|
|
export interface UpdatePersonalityDto {
|
|
name?: string;
|
|
description?: string;
|
|
tone?: string;
|
|
formalityLevel?: FormalityLevel;
|
|
systemPromptTemplate?: string;
|
|
isDefault?: boolean;
|
|
isActive?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Fetch all personalities
|
|
*/
|
|
export async function fetchPersonalities(isActive = true): Promise<ApiResponse<Personality[]>> {
|
|
const endpoint = `/api/personalities?isActive=${isActive.toString()}`;
|
|
return apiGet<ApiResponse<Personality[]>>(endpoint);
|
|
}
|
|
|
|
/**
|
|
* Fetch the default personality
|
|
*/
|
|
export async function fetchDefaultPersonality(): Promise<Personality> {
|
|
return apiGet<Personality>("/api/personalities/default");
|
|
}
|
|
|
|
/**
|
|
* Fetch a single personality by ID
|
|
*/
|
|
export async function fetchPersonality(id: string): Promise<Personality> {
|
|
return apiGet<Personality>(`/api/personalities/${id}`);
|
|
}
|
|
|
|
/**
|
|
* Create a new personality
|
|
*/
|
|
export async function createPersonality(data: CreatePersonalityDto): Promise<Personality> {
|
|
return apiPost<Personality>("/api/personalities", data);
|
|
}
|
|
|
|
/**
|
|
* Update a personality
|
|
*/
|
|
export async function updatePersonality(
|
|
id: string,
|
|
data: UpdatePersonalityDto
|
|
): Promise<Personality> {
|
|
return apiPatch<Personality>(`/api/personalities/${id}`, data);
|
|
}
|
|
|
|
/**
|
|
* Delete a personality
|
|
* The DELETE endpoint returns 204 No Content on success.
|
|
*/
|
|
export async function deletePersonality(id: string): Promise<void> {
|
|
await apiDelete<undefined>(`/api/personalities/${id}`);
|
|
}
|