MCPcopy Create free account
hub / github.com/VPSDance/ai-proxy-rules / parseProviderFile

Function parseProviderFile

scripts/data.ts:127–153  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

125export { mergeRuleSets };
126
127async function parseProviderFile(filePath: string): Promise<ProviderSource> {
128 const raw = await readFile(filePath, "utf8");
129 const result = providerSchema.safeParse(parse(raw));
130 if (!result.success) {
131 throw new Error(`Invalid provider data in ${filePath}:\n${z.prettifyError(result.error)}`);
132 }
133 const parsed = result.data;
134 const groups = normalizeRuleGroups(
135 parsed.groups ?? [
136 {
137 name: "Rules",
138 rules: parsed.rules ?? emptyRuleSet()
139 }
140 ]
141 );
142
143 return {
144 provider: parsed.provider,
145 name: parsed.name,
146 description: parsed.description,
147 categories: parsed.categories,
148 aliases: parsed.aliases,
149 allowDangerousDomainSuffix: parsed.allowDangerousDomainSuffix,
150 groups,
151 rules: mergeRuleSets(groups.map((group) => group.rules))
152 };
153}
154
155function categoryName(category: ProviderCategory): string {
156 switch (category) {

Callers 2

loadProviderFunction · 0.85
loadAllProvidersFunction · 0.85

Calls 3

normalizeRuleGroupsFunction · 0.85
emptyRuleSetFunction · 0.85
mergeRuleSetsFunction · 0.85

Tested by

no test coverage detected