All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Fixes all 542 ESLint problems in the web package to achieve 0 errors and 0 warnings. Changes: - Fixed 144 issues: nullish coalescing, return types, unused variables - Fixed 118 issues: unnecessary conditions, type safety, template literals - Fixed 79 issues: non-null assertions, unsafe assignments, empty functions - Fixed 67 issues: explicit return types, promise handling, enum comparisons - Fixed 45 final warnings: missing return types, optional chains - Fixed 25 typecheck-related issues: async/await, type assertions, formatting - Fixed JSX.Element namespace errors across 90+ files All Quality Rails violations resolved. Lint and typecheck both pass with 0 problems. Files modified: 118 components, tests, hooks, and utilities Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
93 lines
2.0 KiB
TypeScript
93 lines
2.0 KiB
TypeScript
/**
|
|
* Domain API Client
|
|
* Handles domain-related API requests
|
|
*/
|
|
|
|
import type { Domain, DomainWithCounts } from "@mosaic/shared";
|
|
import { apiGet, apiPost, apiPatch, apiDelete, type ApiResponse } from "./client";
|
|
|
|
/**
|
|
* Create domain DTO
|
|
*/
|
|
export interface CreateDomainDto {
|
|
name: string;
|
|
slug: string;
|
|
description?: string;
|
|
color?: string;
|
|
icon?: string;
|
|
sortOrder?: number;
|
|
metadata?: Record<string, unknown>;
|
|
}
|
|
|
|
/**
|
|
* Update domain DTO
|
|
*/
|
|
export interface UpdateDomainDto {
|
|
name?: string;
|
|
slug?: string;
|
|
description?: string;
|
|
color?: string;
|
|
icon?: string;
|
|
sortOrder?: number;
|
|
metadata?: Record<string, unknown>;
|
|
}
|
|
|
|
/**
|
|
* Domain filters for querying
|
|
*/
|
|
export interface DomainFilters {
|
|
search?: string;
|
|
page?: number;
|
|
limit?: number;
|
|
}
|
|
|
|
/**
|
|
* Fetch all domains
|
|
*/
|
|
export async function fetchDomains(filters?: DomainFilters): Promise<ApiResponse<Domain[]>> {
|
|
const params = new URLSearchParams();
|
|
|
|
if (filters?.search) {
|
|
params.append("search", filters.search);
|
|
}
|
|
if (filters?.page) {
|
|
params.append("page", filters.page.toString());
|
|
}
|
|
if (filters?.limit) {
|
|
params.append("limit", filters.limit.toString());
|
|
}
|
|
|
|
const queryString = params.toString();
|
|
const endpoint = queryString ? `/api/domains?${queryString}` : "/api/domains";
|
|
|
|
return apiGet<ApiResponse<Domain[]>>(endpoint);
|
|
}
|
|
|
|
/**
|
|
* Fetch a single domain by ID
|
|
*/
|
|
export async function fetchDomain(id: string): Promise<DomainWithCounts> {
|
|
return apiGet<DomainWithCounts>(`/api/domains/${id}`);
|
|
}
|
|
|
|
/**
|
|
* Create a new domain
|
|
*/
|
|
export async function createDomain(data: CreateDomainDto): Promise<Domain> {
|
|
return apiPost<Domain>("/api/domains", data);
|
|
}
|
|
|
|
/**
|
|
* Update a domain
|
|
*/
|
|
export async function updateDomain(id: string, data: UpdateDomainDto): Promise<Domain> {
|
|
return apiPatch<Domain>(`/api/domains/${id}`, data);
|
|
}
|
|
|
|
/**
|
|
* Delete a domain
|
|
*/
|
|
export async function deleteDomain(id: string): Promise<Record<string, never>> {
|
|
return apiDelete<Record<string, never>>(`/api/domains/${id}`);
|
|
}
|