Files
fusion/packages/dashboard/app/api/settings/settings.ts
gsxdsm cb57093d03 refactor: domain folder layout (types, API, core, engine) (#2398)
## Summary

Wave 17 organizes Fusion into **domain folders** (stacks on #2397).

### Layout
- **core/types/** — board, task, agents, settings, merge, workflow,
mesh, …
- **core/src/** — agents, ai, async-stores, workflows, tasks, config,
db, …
- **dashboard/app/api/** — client, tasks, agents, git, missions,
planning, …
- **engine/src/** — agents, auth, execution, merge, missions, overseer,
worktree, …

Root keepers retained for large entrypoints (`store.ts`, `executor.ts`,
`merger.ts`, …).

Public barrels (`@fusion/core`, `@fusion/engine`, `app/api.ts` → legacy)
stay stable.

## Test plan
- [x] `@fusion/core` typecheck
- [x] `@fusion/engine` typecheck (pre-existing playwright-core noise
only)
- [ ] CI merge gate

**Stack:** #2394 → #2397 → **this PR**
2026-08-03 00:20:53 -07:00

57 lines
2.0 KiB
TypeScript

/**
* FNXC:CodeOrganization 2026-07-16-14:00:
* Settings/config/update client API peeled from legacy.ts.
*/
import type { Settings } from "@fusion/core";
import { api } from "../client/client.js";
import type { FetchOptions } from "../client/client.js";
import { withProjectId } from "../client/health.js";
import type { UpdateCheckResponse } from "../client/health.js";
import { dedupe } from "../client/dedupe.js";
export function fetchConfig(projectId?: string): Promise<{ maxConcurrent: number; rootDir: string }> {
const path = withProjectId("/config", projectId);
return dedupe(path, () => api<{ maxConcurrent: number; rootDir: string }>(path));
}
export function fetchSettings(projectId?: string, options?: FetchOptions): Promise<Settings> {
const path = withProjectId("/settings", projectId);
return dedupe(path, () => api<Settings>(path), options);
}
export function fetchTaskEffectiveSettings(taskId: string, projectId?: string, options?: FetchOptions): Promise<Settings> {
const path = withProjectId(`/tasks/${taskId}/effective-settings`, projectId);
return dedupe(path, () => api<Settings>(path), options);
}
export function updateSettings(settings: Partial<Settings>, projectId?: string): Promise<Settings> {
return api<Settings>(withProjectId("/settings", projectId), {
method: "PUT",
body: JSON.stringify(settings),
});
}
export function checkForUpdate(projectId?: string): Promise<UpdateCheckResponse> {
return api<UpdateCheckResponse>(withProjectId("/update-check", projectId));
}
export function refreshUpdateCheck(projectId?: string): Promise<UpdateCheckResponse> {
return api<UpdateCheckResponse>(withProjectId("/update-check/refresh", projectId), {
method: "POST",
});
}
export interface UpdateInstallResponse {
currentVersion: string;
latestVersion: string | null;
updated: boolean;
error?: string;
}
export function installUpdate(projectId?: string): Promise<UpdateInstallResponse> {
return api<UpdateInstallResponse>(withProjectId("/update-check/install", projectId), {
method: "POST",
});
}