MCPcopy Create free account
hub / github.com/anus-dev/ANUS / flattenSchema

Function flattenSchema

packages/cli/src/utils/settingsUtils.ts:19–33  ·  view source on GitHub ↗
(
  schema: SettingsSchema,
  prefix = '',
)

Source from the content-addressed store, hash-verified

17// schema into a map for easier lookups.
18
19function flattenSchema(
20 schema: SettingsSchema,
21 prefix = '',
22): Record<string, SettingDefinition & { key: string }> {
23 let result: Record<string, SettingDefinition & { key: string }> = {};
24 for (const key in schema) {
25 const newKey = prefix ? `${prefix}.${key}` : key;
26 const definition = schema[key];
27 result[newKey] = { ...definition, key: newKey };
28 if (definition.properties) {
29 result = { ...result, ...flattenSchema(definition.properties, newKey) };
30 }
31 }
32 return result;
33}
34
35const FLATTENED_SCHEMA = flattenSchema(SETTINGS_SCHEMA);
36

Callers 1

settingsUtils.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected