Unified · Split
| @@ -878,11 +878,12 @@ export const openApiPlugin = definePlugin< · 877 unmodified lines | |||
| 878 | }, | 878 | }, |
| 879 | httpClientLayer, | 879 | httpClientLayer, |
| 880 | ); | 880 | ); |
| 881 | const compiled = yield* compileOpenApiSpec(resolved.specText); | 881 | const compiled = resolved.keepPathItem |
| 882 | ? undefined | ||
| 883 | : yield* compileOpenApiSpec(resolved.specText); | ||
| 882 | 884 | ||
| 883 | const previousOperations = yield* ctx.storage.listOperations(rawSlug); | 885 | const previousOperations = yield* ctx.storage.listOperations(rawSlug); |
| 884 | const previousNames = new Set(previousOperations.map((op) => op.toolName)); | 886 | const previousNames = new Set(previousOperations.map((op) => op.toolName)); |
| 885 | const nextNames = new Set(compiled.definitions.map((def) => def.toolPath)); | ||
| 886 | 887 | ||
| 887 | // The resolved spec text lives in the plugin blob store keyed by its | 888 | // The resolved spec text lives in the plugin blob store keyed by its |
| 888 | // content hash (`spec/<hash>`); the config carries only the hash. Put | 889 | // content hash (`spec/<hash>`); the config carries only the hash. Put |
| @@ -890,7 +891,9 @@ export const openApiPlugin = definePlugin< · 1 unmodified line | |||
| 890 | // aborted config update just leaves an unreferenced blob. | 891 | // aborted config update just leaves an unreferenced blob. |
| 891 | const specHash = yield* sha256Hex(resolved.specText); | 892 | const specHash = yield* sha256Hex(resolved.specText); |
| 892 | yield* ctx.storage.putSpec(specHash, resolved.specText); | 893 | yield* ctx.storage.putSpec(specHash, resolved.specText); |
| 893 | yield* ctx.storage.putDefs(specHash, JSON.stringify(compiled.hoistedDefs)); | 894 | if (compiled) { |
| 895 | yield* ctx.storage.putDefs(specHash, JSON.stringify(compiled.hoistedDefs)); | ||
| 896 | } | ||
| 894 | 897 | ||
| 895 | const nextConfig: OpenApiIntegrationConfig = { | 898 | const nextConfig: OpenApiIntegrationConfig = { |
| 896 | ...current, | 899 | ...current, |
| @@ -905,13 +908,28 @@ export const openApiPlugin = definePlugin< · 8 unmodified lines | |||
| 905 | yield* ctx.core.integrations.update(slug, { | 908 | yield* ctx.core.integrations.update(slug, { |
| 906 | config: nextConfig satisfies OpenApiIntegrationConfig as IntegrationConfig, | 909 | config: nextConfig satisfies OpenApiIntegrationConfig as IntegrationConfig, |
| 907 | }); | 910 | }); |
| 908 | yield* ctx.storage.putOperations( | 911 | if (compiled) { |
| 909 | rawSlug, | 912 | yield* ctx.storage.putOperations( |
| 910 | openApiStoredOperationsFromCompiled(rawSlug, compiled), | 913 | rawSlug, |
| 911 | ); | 914 | openApiStoredOperationsFromCompiled(rawSlug, compiled), |
| 915 | ); | ||
| 916 | } else { | ||
| 917 | yield* compileAndPersistOpenApiSpecStreaming({ | ||
| 918 | specText: resolved.specText, | ||
| 919 | integration: rawSlug, | ||
| 920 | storage: ctx.storage, | ||
| 921 | specHash, | ||
| 922 | keepPathItem: resolved.keepPathItem, | ||
| 923 | }); | ||
| 924 | } | ||
| 912 | }), | 925 | }), |
| 913 | ); | 926 | ); |
| 914 | 927 | ||
| 928 | const nextOperations = compiled | ||
| 929 | ? openApiStoredOperationsFromCompiled(rawSlug, compiled) | ||
| 930 | : yield* ctx.storage.listOperations(rawSlug); | ||
| 931 | const nextNames = new Set(nextOperations.map((op) => op.toolName)); | ||
| 932 | |||
| 915 | // Rebuild each connection's tool rows from the new spec. Outside the | 933 | // Rebuild each connection's tool rows from the new spec. Outside the |
| 916 | // transaction: refresh opens its own, and a half-refreshed catalog | 934 | // transaction: refresh opens its own, and a half-refreshed catalog |
| 917 | // self-heals on the next refresh anyway. | 935 | // self-heals on the next refresh anyway. |
| @@ -936,7 +954,7 @@ export const openApiPlugin = definePlugin< · 18 unmodified lines | |||
| 936 | 954 | ||
| 937 | return { | 955 | return { |
| 938 | slug, | 956 | slug, |
| 939 | toolCount: compiled.definitions.length, | 957 | toolCount: nextNames.size, |
| 940 | addedTools: [...nextNames].filter((name) => !previousNames.has(name)).sort(), | 958 | addedTools: [...nextNames].filter((name) => !previousNames.has(name)).sort(), |
| 941 | removedTools: [...previousNames].filter((name) => !nextNames.has(name)).sort(), | 959 | removedTools: [...previousNames].filter((name) => !nextNames.has(name)).sort(), |
| 942 | } satisfies UpdateSpecResult; | 960 | } satisfies UpdateSpecResult; |