MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / validated

Function validated

graph-ui/src/settings/view-preferences.ts:27–40  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

25export const viewPreferencesKey = (project: string): string => `cbm-view-preferences-v1:${encodeURIComponent(project)}`;
26
27function validated(value: unknown): Readonly<ViewPreferences> {
28 const row = typeof value === 'object' && value !== null ? value as Record<string, unknown> : {};
29 const oneOf = <T extends string | number>(candidate: unknown, choices: readonly T[], fallback: T): T =>
30 choices.includes(candidate as T) ? candidate as T : fallback;
31 return Object.freeze({
32 galaxyNodes: oneOf(row.galaxyNodes, GALAXY_NODE_LIMITS, DEFAULT_VIEW_PREFERENCES.galaxyNodes),
33 galaxyEdges: oneOf(row.galaxyEdges, GALAXY_EDGE_LIMITS, DEFAULT_VIEW_PREFERENCES.galaxyEdges),
34 coverageShadow: typeof row.coverageShadow === 'boolean' ? row.coverageShadow : DEFAULT_VIEW_PREFERENCES.coverageShadow,
35 brickHeight: oneOf(row.brickHeight, ['lines', 'uniform'] as const, DEFAULT_VIEW_PREFERENCES.brickHeight),
36 brickColor: oneOf(row.brickColor, ['language', 'kind'] as const, DEFAULT_VIEW_PREFERENCES.brickColor),
37 hotspotGravity: typeof row.hotspotGravity === 'boolean' ? row.hotspotGravity : DEFAULT_VIEW_PREFERENCES.hotspotGravity,
38 fileVisibility: oneOf(row.fileVisibility, ['all', 'connected', 'unconnected'] as const, DEFAULT_VIEW_PREFERENCES.fileVisibility),
39 });
40}
41
42function decode(raw: string | null): Readonly<ViewPreferences> {
43 try {

Callers 2

decodeFunction · 0.70
setViewPreferencesFunction · 0.70

Calls 1

oneOfFunction · 0.85

Tested by

no test coverage detected