feat(web): add public chat and thread API types and services

This commit is contained in:
CREDO23 2026-01-26 16:11:55 +02:00
parent aeb0deb21e
commit 9d7259aab9
5 changed files with 170 additions and 2 deletions

View file

@ -0,0 +1,33 @@
import {
type TogglePublicShareRequest,
type TogglePublicShareResponse,
togglePublicShareRequest,
togglePublicShareResponse,
} from "@/contracts/types/chat-threads.types";
import { ValidationError } from "../error";
import { baseApiService } from "./base-api.service";
class ChatThreadsApiService {
/**
* Toggle public sharing for a thread.
* Requires authentication.
*/
togglePublicShare = async (
request: TogglePublicShareRequest
): Promise<TogglePublicShareResponse> => {
const parsed = togglePublicShareRequest.safeParse(request);
if (!parsed.success) {
const errorMessage = parsed.error.issues.map((issue) => issue.message).join(", ");
throw new ValidationError(`Invalid request: ${errorMessage}`);
}
return baseApiService.patch(
`/api/v1/threads/${parsed.data.thread_id}/public-share`,
togglePublicShareResponse,
{ body: { enabled: parsed.data.enabled } }
);
};
}
export const chatThreadsApiService = new ChatThreadsApiService();