MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / parseCliServerConnectionStore

Function parseCliServerConnectionStore

apps/cli/src/server-profile.ts:100–125  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

98};
99
100export const parseCliServerConnectionStore = (raw: string): CliServerConnectionStore => {
101 const decoded = decodeStoreJson(raw);
102 if (Option.isNone(decoded)) return emptyCliServerConnectionStore;
103 const record = decoded.value;
104
105 const profiles = record.profiles.flatMap((value): readonly CliServerConnectionProfile[] => {
106 const connection = decodeConnection(value.connection);
107 if (!connection) return [];
108 try {
109 return [{ name: validateCliServerConnectionProfileName(value.name), connection }];
110 } catch {
111 return [];
112 }
113 });
114
115 const defaultProfile =
116 record.defaultProfile && profiles.some((profile) => profile.name === record.defaultProfile)
117 ? record.defaultProfile
118 : null;
119
120 return {
121 version: 1,
122 defaultProfile,
123 profiles,
124 };
125};
126
127const serializeCliServerConnectionStore = (store: CliServerConnectionStore): string =>
128 `${JSON.stringify(store, null, 2)}\n`;

Callers 2

Calls 2

decodeConnectionFunction · 0.85

Tested by

no test coverage detected