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