mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:40:44 +00:00
test: cache provider contract entries
This commit is contained in:
@@ -26,15 +26,21 @@ function resolveProviderContractProvidersFromPublicArtifact(
|
||||
}
|
||||
|
||||
export function describeProviderContracts(pluginId: string) {
|
||||
let providerEntries: ProviderContractEntry[] | undefined;
|
||||
const resolveProviderEntries = (): ProviderContractEntry[] => {
|
||||
if (providerEntries) {
|
||||
return providerEntries;
|
||||
}
|
||||
const publicArtifactProviders = resolveProviderContractProvidersFromPublicArtifact(pluginId);
|
||||
if (publicArtifactProviders) {
|
||||
return publicArtifactProviders;
|
||||
providerEntries = publicArtifactProviders;
|
||||
return providerEntries;
|
||||
}
|
||||
return resolveProviderContractProvidersForPluginIds([pluginId]).map((provider) => ({
|
||||
providerEntries = resolveProviderContractProvidersForPluginIds([pluginId]).map((provider) => ({
|
||||
pluginId,
|
||||
provider,
|
||||
}));
|
||||
return providerEntries;
|
||||
};
|
||||
const resolveProviderIds = (): string[] =>
|
||||
resolveProviderEntries().map((entry) => entry.provider.id);
|
||||
|
||||
@@ -33,18 +33,24 @@ export function describeWebSearchProviderContracts(pluginId: string) {
|
||||
pluginRegistrationContractRegistry.find((entry) => entry.pluginId === pluginId)
|
||||
?.webSearchProviderIds ?? [];
|
||||
|
||||
let providerEntries: WebSearchContractEntry[] | undefined;
|
||||
const resolveProviders = (): WebSearchContractEntry[] => {
|
||||
if (providerEntries) {
|
||||
return providerEntries;
|
||||
}
|
||||
const publicArtifactProviders = resolveBundledExplicitWebSearchProvidersFromPublicArtifacts({
|
||||
onlyPluginIds: [pluginId],
|
||||
});
|
||||
if (publicArtifactProviders) {
|
||||
return publicArtifactProviders.map((provider) => ({
|
||||
providerEntries = publicArtifactProviders.map((provider) => ({
|
||||
pluginId: provider.pluginId,
|
||||
provider,
|
||||
credentialValue: resolveWebSearchCredentialValue(provider),
|
||||
}));
|
||||
return providerEntries;
|
||||
}
|
||||
return resolveWebSearchProviderContractEntriesForPluginId(pluginId);
|
||||
providerEntries = resolveWebSearchProviderContractEntriesForPluginId(pluginId);
|
||||
return providerEntries;
|
||||
};
|
||||
|
||||
describe(`${pluginId} web search provider contract registry load`, () => {
|
||||
|
||||
Reference in New Issue
Block a user