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

Function parseCliServerConnectionStore

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

Source from the content-addressed store, hash-verified

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

Callers 2

Calls 2

decodeConnectionFunction · 0.85

Tested by

no test coverage detected