davsclaus opened a new pull request, #30676: URL: https://github.com/apache/camel/pull/30676
_Claude Code on behalf of Claus Ibsen (davsclaus)_ [CAMEL-27475](https://issues.apache.org/jira/browse/CAMEL-27475). **Stacked on #30675 (CAMEL-27468)**: the base is its branch, so this PR shows only its own commit. Retarget it to `main` once #30675 is merged. ### Why The sample of the Kamelets 4.24 blog post, `file-watch-source -> csv-deserialize-action -> split -> postgresql-sink`, shows `File`, `ArrayList`, `LinkedHashMap`, `LinkedHashMap` in the TUI. That reads as if a `Map` goes into a sink that takes JSON, and yet the sink works: its default `in` data type is `json` (`application-json`), and Camel turns the body into it before the Kamelet sees it. Camel developers don't know what a Kamelet takes. They may also wonder why a SQL sink takes JSON at all: Kamelets come from event-driven and serverless integration (Knative, CloudEvents), where the data between steps was JSON. So the tools now show the conversion at the step that calls the Kamelet: ```text 8: to[kamelet:csv-deserialize-action] body: File → text 13: to[kamelet:postgresql-sink] body: LinkedHashMap → json ``` Before a message has reached the step, it shows only what the Kamelet takes (`→ json`). A body the transformer does not take, according to the catalog, is marked: `⚠ ArrayList → text (text-plain does not take it)`. ### Where the facts come from - **The data type:** the Kamelet's default `in` data type (`spec.dataTypes`). This is the same one `KameletRoutesBuilderLoader` sets as the `inputType` of the Kamelet's route. The Kamelet is looked up in the project's own Kamelet files, then in the Kamelet catalog. - **What the transformer takes:** the catalog transformer's `bodyTypes.transformerIn` carriers. `application-json` takes text, bytes, a stream, a Map, a List, a POJO or no body. The YAML validator already joins these two (`CatalogBodyTypes.transformerIn`). - **Whether the body fits:** the runtime class names are mapped to carriers with `BodyTypeModel.carrierOf`. Camel's stream caches count as streams. A class the catalog has no name for is "not known", and **only a definite "does not take" gives a warning**. ### Changes - `KameletInput` (camel-jbang-core) resolves the data type and decides whether the transformer takes the body. - `camel cmd route-structure` adds it to each step as `kameletInput`, both in `--json` and in the text output. - So do the AI tool and the MCP `camel_runtime_route_structure` tool (descriptions updated). It also works for the kamelet EIP (`kamelet[name]`). - **TUI** - Kamelets are looked up on a background thread, so the screen never waits for the Kamelet catalog to load. A lookup is kept for 30 seconds, then refreshed. - The integration's own Kamelets version is used (`camel.jbang.kameletsVersion`, set by `camel run --kamelets-version`). It can differ from the CLI's. - **Source view:** `LinkedHashMap → json` at the end of the line. A new "Kamelet data type" quick doc says what the Kamelet takes and that a Map, a List or a POJO is written as JSON for you. - **Routes view:** the processor table's BODY TYPES column shows the same. - **Diagram:** the label on the arrow into the step. The Info panel says what the Kamelet takes. The box gets a ⚠ when the body is not taken. - `KameletDefinitions.find`/`catalog` take a Kamelets version. - `KameletInputInfo` is added to camel-diagram's `NodeInfo`, parsed from a step's `kameletInput`. - Docs: TUI source editor, TUI diagram, CLI diagnostics and MCP pages, and the TUI help. ### Note Camel main pins `camel-kamelets-catalog-version` to 4.23.0, whose `postgresql-sink` declares no `in` data type. Until that pin is bumped: - the CLI resolves catalog Kamelets against 4.23.0, and shows nothing for them; - an integration run with `--kamelets-version=4.24.0-SNAPSHOT` gets the right data types in the TUI, because the TUI uses the integration's version. I checked against the real 4.24.0-SNAPSHOT Kamelet catalog: `postgresql-sink → json` (takes a Map), `csv-deserialize-action → text` (takes a File, not a List), and `file-watch-source` has no `in` type, so nothing is shown. Not in this PR: the PNG route diagram (`camel cmd route-diagram`) does not draw the arrow yet. ### Tests - `KameletInputTest`: name parsing, the resolved data type, whether the body fits, and the route-structure enrichment, including the kamelet EIP. - `CamelRouteStructureActionTest` (text output), `RouteDiagramHelperTest`. - TUI: `KameletInputsTest` (labels, quick doc, source line, source view rendering, diagram via topology and Info panel, the integration's Kamelets version, background lookup) and `BodyTypesOnArrowsTest` (arrow label). - Tests of every affected module ran green locally, including `SourceSizeTest` and the MCP runtime tools tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
