refactor(types): rename AppType to AppId for semantic clarity
Rename `AppType` to `AppId` across the entire frontend codebase to better reflect its purpose as an application identifier rather than a type category. This aligns frontend naming with backend command parameter conventions. Changes: - Rename type `AppType` to `AppId` in src/lib/api/types.ts - Remove `AppType` export from src/lib/api/index.ts - Update all component props from `appType` to `appId` (43 files) - Update all variable names from `appType` to `appId` - Synchronize documentation (CHANGELOG, refactoring plans) - Update test files and MSW mocks BREAKING CHANGE: `AppType` type is no longer exported. Use `AppId` instead. All component props have been renamed from `appType` to `appId`.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { http, HttpResponse } from "msw";
|
||||
import type { AppType } from "@/lib/api/types";
|
||||
import type { AppId } from "@/lib/api/types";
|
||||
import type { McpServer, Provider, Settings } from "@/types";
|
||||
import {
|
||||
addProvider,
|
||||
@@ -37,19 +37,19 @@ const success = <T>(payload: T) => HttpResponse.json(payload as any);
|
||||
|
||||
export const handlers = [
|
||||
http.post(`${TAURI_ENDPOINT}/get_providers`, async ({ request }) => {
|
||||
const { app } = await withJson<{ app: AppType }>(request);
|
||||
const { app } = await withJson<{ app: AppId }>(request);
|
||||
return success(getProviders(app));
|
||||
}),
|
||||
|
||||
http.post(`${TAURI_ENDPOINT}/get_current_provider`, async ({ request }) => {
|
||||
const { app } = await withJson<{ app: AppType }>(request);
|
||||
const { app } = await withJson<{ app: AppId }>(request);
|
||||
return success(getCurrentProviderId(app));
|
||||
}),
|
||||
|
||||
http.post(`${TAURI_ENDPOINT}/update_providers_sort_order`, async ({ request }) => {
|
||||
const { updates = [], app } = await withJson<{
|
||||
updates: { id: string; sortIndex: number }[];
|
||||
app: AppType;
|
||||
app: AppId;
|
||||
}>(request);
|
||||
updateSortOrder(app, updates);
|
||||
return success(true);
|
||||
@@ -58,7 +58,7 @@ export const handlers = [
|
||||
http.post(`${TAURI_ENDPOINT}/update_tray_menu`, () => success(true)),
|
||||
|
||||
http.post(`${TAURI_ENDPOINT}/switch_provider`, async ({ request }) => {
|
||||
const { id, app } = await withJson<{ id: string; app: AppType }>(request);
|
||||
const { id, app } = await withJson<{ id: string; app: AppId }>(request);
|
||||
const providers = listProviders(app);
|
||||
if (!providers[id]) {
|
||||
return HttpResponse.json(false, { status: 404 });
|
||||
@@ -70,7 +70,7 @@ export const handlers = [
|
||||
http.post(`${TAURI_ENDPOINT}/add_provider`, async ({ request }) => {
|
||||
const { provider, app } = await withJson<{
|
||||
provider: Provider & { id?: string };
|
||||
app: AppType;
|
||||
app: AppId;
|
||||
}>(request);
|
||||
|
||||
const newId = provider.id ?? `mock-${Date.now()}`;
|
||||
@@ -81,14 +81,14 @@ export const handlers = [
|
||||
http.post(`${TAURI_ENDPOINT}/update_provider`, async ({ request }) => {
|
||||
const { provider, app } = await withJson<{
|
||||
provider: Provider;
|
||||
app: AppType;
|
||||
app: AppId;
|
||||
}>(request);
|
||||
updateProvider(app, provider);
|
||||
return success(true);
|
||||
}),
|
||||
|
||||
http.post(`${TAURI_ENDPOINT}/delete_provider`, async ({ request }) => {
|
||||
const { id, app } = await withJson<{ id: string; app: AppType }>(request);
|
||||
const { id, app } = await withJson<{ id: string; app: AppId }>(request);
|
||||
deleteProvider(app, id);
|
||||
return success(true);
|
||||
}),
|
||||
@@ -102,7 +102,7 @@ export const handlers = [
|
||||
|
||||
// MCP APIs
|
||||
http.post(`${TAURI_ENDPOINT}/get_mcp_config`, async ({ request }) => {
|
||||
const { app } = await withJson<{ app: AppType }>(request);
|
||||
const { app } = await withJson<{ app: AppId }>(request);
|
||||
return success(getMcpConfig(app));
|
||||
}),
|
||||
|
||||
@@ -111,7 +111,7 @@ export const handlers = [
|
||||
|
||||
http.post(`${TAURI_ENDPOINT}/set_mcp_enabled`, async ({ request }) => {
|
||||
const { app, id, enabled } = await withJson<{
|
||||
app: AppType;
|
||||
app: AppId;
|
||||
id: string;
|
||||
enabled: boolean;
|
||||
}>(request);
|
||||
@@ -121,7 +121,7 @@ export const handlers = [
|
||||
|
||||
http.post(`${TAURI_ENDPOINT}/upsert_mcp_server_in_config`, async ({ request }) => {
|
||||
const { app, id, spec } = await withJson<{
|
||||
app: AppType;
|
||||
app: AppId;
|
||||
id: string;
|
||||
spec: McpServer;
|
||||
}>(request);
|
||||
@@ -130,7 +130,7 @@ export const handlers = [
|
||||
}),
|
||||
|
||||
http.post(`${TAURI_ENDPOINT}/delete_mcp_server_in_config`, async ({ request }) => {
|
||||
const { app, id } = await withJson<{ app: AppType; id: string }>(request);
|
||||
const { app, id } = await withJson<{ app: AppId; id: string }>(request);
|
||||
deleteMcpServer(app, id);
|
||||
return success(true);
|
||||
}),
|
||||
@@ -162,7 +162,7 @@ export const handlers = [
|
||||
}),
|
||||
|
||||
http.post(`${TAURI_ENDPOINT}/get_config_dir`, async ({ request }) => {
|
||||
const { app } = await withJson<{ app: AppType }>(request);
|
||||
const { app } = await withJson<{ app: AppId }>(request);
|
||||
return success(app === "claude" ? "/default/claude" : "/default/codex");
|
||||
}),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user