test: cache provider contract entries · openclaw/openclaw@3915089
steipete
·
2026-05-06
·
via Recent Commits to openclaw:main
File tree
src/plugin-sdk/test-helpers
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,15 +26,21 @@ function resolveProviderContractProvidersFromPublicArtifact(
|
26 | 26 | } |
27 | 27 | |
28 | 28 | export function describeProviderContracts(pluginId: string) { |
| 29 | +let providerEntries: ProviderContractEntry[] | undefined; |
29 | 30 | const resolveProviderEntries = (): ProviderContractEntry[] => { |
| 31 | +if (providerEntries) { |
| 32 | +return providerEntries; |
| 33 | +} |
30 | 34 | const publicArtifactProviders = resolveProviderContractProvidersFromPublicArtifact(pluginId); |
31 | 35 | if (publicArtifactProviders) { |
32 | | -return publicArtifactProviders; |
| 36 | +providerEntries = publicArtifactProviders; |
| 37 | +return providerEntries; |
33 | 38 | } |
34 | | -return resolveProviderContractProvidersForPluginIds([pluginId]).map((provider) => ({ |
| 39 | +providerEntries = resolveProviderContractProvidersForPluginIds([pluginId]).map((provider) => ({ |
35 | 40 | pluginId, |
36 | 41 | provider, |
37 | 42 | })); |
| 43 | +return providerEntries; |
38 | 44 | }; |
39 | 45 | const resolveProviderIds = (): string[] => |
40 | 46 | resolveProviderEntries().map((entry) => entry.provider.id); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -33,18 +33,24 @@ export function describeWebSearchProviderContracts(pluginId: string) {
|
33 | 33 | pluginRegistrationContractRegistry.find((entry) => entry.pluginId === pluginId) |
34 | 34 | ?.webSearchProviderIds ?? []; |
35 | 35 | |
| 36 | +let providerEntries: WebSearchContractEntry[] | undefined; |
36 | 37 | const resolveProviders = (): WebSearchContractEntry[] => { |
| 38 | +if (providerEntries) { |
| 39 | +return providerEntries; |
| 40 | +} |
37 | 41 | const publicArtifactProviders = resolveBundledExplicitWebSearchProvidersFromPublicArtifacts({ |
38 | 42 | onlyPluginIds: [pluginId], |
39 | 43 | }); |
40 | 44 | if (publicArtifactProviders) { |
41 | | -return publicArtifactProviders.map((provider) => ({ |
| 45 | +providerEntries = publicArtifactProviders.map((provider) => ({ |
42 | 46 | pluginId: provider.pluginId, |
43 | 47 | provider, |
44 | 48 | credentialValue: resolveWebSearchCredentialValue(provider), |
45 | 49 | })); |
| 50 | +return providerEntries; |
46 | 51 | } |
47 | | -return resolveWebSearchProviderContractEntriesForPluginId(pluginId); |
| 52 | +providerEntries = resolveWebSearchProviderContractEntriesForPluginId(pluginId); |
| 53 | +return providerEntries; |
48 | 54 | }; |
49 | 55 | |
50 | 56 | describe(`${pluginId} web search provider contract registry load`, () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。