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

Function readConfigSnapshot

graph-ui/src/settings/config-model.ts:33–51  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

31const nullableString = (value: unknown): value is string | null => value === null || typeof value === 'string';
32
33export function readConfigSnapshot(value: unknown): ConfigSnapshot {
34 if (!record(value) || typeof value.revision !== 'string' || !Array.isArray(value.settings)) throw new Error('The daemon returned an invalid configuration snapshot.');
35 const keys = new Set<string>();
36 for (const item of value.settings) {
37 if (!record(item) || typeof item.key !== 'string' || !item.key || ['__proto__', 'constructor', 'prototype'].includes(item.key) || keys.has(item.key)
38 || ['label', 'description', 'category', 'source', 'applyMode'].some(key => typeof item[key] !== 'string')
39 || !['boolean', 'integer', 'number', 'enum', 'string'].includes(String(item.type))
40 || ['value', 'override', 'effective', 'defaultValue'].some(key => !nullableString(item[key]))
41 || typeof item.editable !== 'boolean' || typeof item.pendingRestart !== 'boolean'
42 || (item.effectiveKnown !== undefined && typeof item.effectiveKnown !== 'boolean')
43 || (item.options !== undefined && (!Array.isArray(item.options) || item.options.some(option => typeof option !== 'string')))
44 || (item.type === 'enum' && (!Array.isArray(item.options) || !item.options.length))
45 || ['minimum', 'maximum'].some(key => item[key] !== undefined && (typeof item[key] !== 'number' || !Number.isFinite(item[key])))) {
46 throw new Error('The daemon returned an invalid setting. Configuration was not changed.');
47 }
48 keys.add(item.key);
49 }
50 return value as unknown as ConfigSnapshot;
51}
52
53export function configValueError(setting: ConfigSetting, value: string | null): string | undefined {
54 if (value === null) return;

Callers 3

configurationMethod · 0.90
saveConfigurationMethod · 0.90

Calls 2

nullableStringFunction · 0.85
recordFunction · 0.70

Tested by

no test coverage detected