mirror of
https://github.com/morluto/rea.git
synced 2026-11-11 17:28:08 +00:00
fix(setup): report the effective ZCode fallback registration
Resolve native-versus-fallback precedence once at the parsed configuration owner. Status and maintenance consume the selected dialect and path, including invalid and disabled fallback registrations. Validation: 28 ZCode boundary and 26 maintenance tests pass. No configuration writes introduced. Based on #3123. Co-authored-by: IvenKooLab <276572622@qq.com>
This commit is contained in:
1 parent
03ffb2c13d
commit
583166785f
4 files changed
+202
-19
No files matched your search
@@ -172,3 +172,47 @@ export const effectiveClientConfiguration = (
|
||||
}
|
||||
return { ...last, servers, legacyServers: {} };
|
||||
};
|
||||
|
||||
/** Read the configuration ZCode will load, preserving its same-scope fallback rule. */
|
||||
export const readEffectiveClientRegistrationConfiguration = async (
|
||||
client: SetupClient,
|
||||
resources?: ArtifactResourceScope,
|
||||
): Promise<
|
||||
Result<
|
||||
{
|
||||
readonly document: ClientConfigurationDocument | undefined;
|
||||
readonly configPath: string;
|
||||
},
|
||||
ClientConfigurationFileError
|
||||
>
|
||||
> => {
|
||||
const nativeSources = await readClientConfigurationFiles(client, resources);
|
||||
if (!nativeSources.ok) return nativeSources;
|
||||
const nativeDocument = effectiveClientConfiguration(nativeSources.value);
|
||||
const fallbackPath =
|
||||
client.format === "zcode" ? client.zcodeFallbackPath : undefined;
|
||||
if (
|
||||
fallbackPath === undefined ||
|
||||
(nativeDocument !== undefined &&
|
||||
Object.keys(nativeDocument.servers).length > 0)
|
||||
)
|
||||
return ok({ document: nativeDocument, configPath: client.configPath });
|
||||
|
||||
const fallbackClient: SetupClient = {
|
||||
...client,
|
||||
configPath: fallbackPath,
|
||||
configPaths: [fallbackPath],
|
||||
format: "zcode_fallback",
|
||||
};
|
||||
const fallbackSources = await readClientConfigurationFiles(
|
||||
fallbackClient,
|
||||
resources,
|
||||
);
|
||||
if (!fallbackSources.ok) return fallbackSources;
|
||||
const fallbackDocument = effectiveClientConfiguration(fallbackSources.value);
|
||||
return ok(
|
||||
fallbackDocument === undefined
|
||||
? { document: nativeDocument, configPath: client.configPath }
|
||||
: { document: fallbackDocument, configPath: fallbackPath },
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user