[ 
https://issues.apache.org/jira/browse/CAMEL-27475?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149882#comment-18149882
 ] 

Claus Ibsen commented on CAMEL-27475:
-------------------------------------

Also from Claus: Camel developers often do not know what a Kamelet takes in, 
and may not understand why a SQL sink such as {{postgresql-sink}} takes JSON. 
The reason is where Kamelets come from: they were designed for event-driven and 
serverless use (Knative, CloudEvents), where the data between steps was mostly 
JSON. So the TUI should answer "what does this Kamelet take" before any message 
has run, and say why a Map is fine:

* Show the declared data types of the Kamelet at the step that calls it, from 
the Kamelet YAML ({{spec.dataTypes}}), also before a message has reached it: 
{{postgresql-sink <- json}}. The AI tools ({{CatalogDocs}}, 
{{KameletDefinitions}}) and the MCP {{KameletTools}} already read 
{{dataTypes}}; the TUI reads none today.
* The quick documentation of the step gives the description of the data type 
("One JSON object, or with batch a JSON array of objects, as JSON text in 
bytes.") and what its transformer takes from the catalog, in words a Camel 
developer knows: "a Map, a List or a POJO is written as JSON for you, so no 
marshal step is needed".
* With messages, the runtime facts are added as proposed above: {{LinkedHashMap 
-> json}}, with a warning only when the transformer does not take the body.

_Claude Code on behalf of Claus Ibsen_

> camel-jbang - show the data type a Kamelet turns the body into, at the step 
> that calls it (LinkedHashMap -> json)
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27475
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27475
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jbang
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 4.24.0
>
>
> Follow-up of CAMEL-27468.
> The body types of each step (CAMEL-25892) and their formats (CAMEL-27468) are 
> what a step was reached with. At a step that calls a Kamelet, the body is 
> then turned into the in data type of the Kamelet, by a data type transformer, 
> before the template of the Kamelet sees it. That conversion is not shown 
> anywhere.
> h3. Example
> The sample of the Kamelets 4.24 blog post: {{file-watch-source -> 
> csv-deserialize-action -> split -> postgresql-sink}}. The TUI shows {{File}}, 
> {{ArrayList}}, {{LinkedHashMap}}, {{LinkedHashMap}}, so it looks as if a 
> {{Map}} goes into a sink that takes JSON, and yet the sink works: its 
> {{dataTypes.in}} is {{json}} ({{format: application-json}}), and the 
> {{application-json}} transformer writes the {{Map}} as JSON bytes.
> h3. Where this is known
> * The Kamelet: {{spec.dataTypes.in/out}}, the default type, its {{format}} 
> (the transformer) and {{mediaType}}. At runtime 
> {{KameletRoutesBuilderLoader}} sets the {{in}} type as the {{inputType}} of 
> the route, and the {{out}} type as the {{kameletOutputType}} route property, 
> which {{KameletProducer}} applies.
> * The catalog: {{transformers/<name>.json}}, {{bodyTypes.transformerIn}} (the 
> carriers it takes: {{application-json}} takes text, bytes, stream, map, list, 
> pojo, null) and {{transformerOut}} (carriers, javaType, format).
> * The YAML validator already combines the two ({{ValidatorFacts}} -> 
> {{ProjectFacts.KameletDataTypes}}, 
> {{CatalogBodyTypes.transformerIn/transformerOut}} in {{TextBodyFlow}}).
> h3. Proposal
> * The route-structure console gives, for a route with one, its input data 
> type and the output data type of a Kamelet (from the route, so placeholders 
> are resolved).
> * The TUI (Source, Routes, Diagram), {{camel cmd route-structure}} and the 
> MCP tools join it with the catalog transformer, and show the conversion at 
> the step that calls the Kamelet: {{LinkedHashMap -> json}}, {{File -> text}}.
> * No warning when the transformer takes the body; a warning when it does not, 
> such as an {{ArrayList}} into {{text-plain}}, which takes text, bytes, a 
> stream, a file or a value.
> h3. Also
> * The catalog transformer {{text-plain}} has no {{format}} in 
> {{transformerOut}}, where {{application-json}} has {{json}}: it should say 
> {{text}}.
> _Claude Code on behalf of Claus Ibsen_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to