MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / normalizeDataConfig

Function normalizeDataConfig

src/runtime/config.ts:146–189  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

144 };
145}
146
147function normalizeDataConfig(value: unknown): DataConfig {
148 if (!value || typeof value !== "object") {
149 return {};
150 }
151
152 const raw = value as Record<string, unknown>;
153 const normalized: DataConfig = {};
154
155 if (typeof raw.apiKey === "string") {
156 normalized.apiKey = raw.apiKey;
157 }
158 if (typeof raw.provider === "string") {
159 normalized.provider = raw.provider;
160 }
161 if (typeof raw.baseUrl === "string") {
162 normalized.baseUrl = raw.baseUrl;
163 }
164 if (typeof raw.modelId === "string") {
165 normalized.modelId = raw.modelId;
166 }
167 if (
168 raw.apiProtocol === "openai-responses" ||
169 raw.apiProtocol === "openai-completions"
170 ) {
171 normalized.apiProtocol = raw.apiProtocol;
172 }
173 if (typeof raw.reasoning === "boolean") {
174 normalized.reasoning = raw.reasoning;
175 }
176 if (raw.adapters && typeof raw.adapters === "object" && !Array.isArray(raw.adapters)) {
177 const rawAdapters = raw.adapters as Record<string, unknown>;
178 const adapters = { ...rawAdapters } as NonNullable<DataConfig["adapters"]>;
179 const feishu = normalizeFeishuAdapterConfig(rawAdapters.feishu);
180 if (feishu) {
181 adapters.feishu = feishu;
182 }
183 normalized.adapters = adapters;
184 }
185 if (raw._auth && typeof raw._auth === "object" && !Array.isArray(raw._auth)) {
186 normalized._auth = raw._auth as Record<string, unknown>;
187 }
188
189 return normalized;
190}
191
192export function resolveRuntimeConfig(

Callers 3

resolveRuntimeConfigFunction · 0.85
loadMethod · 0.85
saveMethod · 0.85

Calls 1

Tested by

no test coverage detected