Skip to content

Feature/adding query md experimental support #923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

davidporter-id-au
Copy link
Member

@davidporter-id-au davidporter-id-au commented Jun 5, 2025

This is an experimental feature which allows a query to return preformatted data (in this instance markdown, though if it's useful, presumably other types as well).

This is still being tested, so it's not going to be super discoverable (and I have no idea what I'm doing on the frontend, so also will try and wall off these changes for a bit until we're more certain they'll be of use).

The idea is that a query should be able return a response struct like this:

  "cadenceResponseType": "formattedData",
  "format": "<mime-type format>",
  "data" <formatted data specific to the format>
}

for example:

{
  "cadenceResponseType": "formattedData",
  "format": "text/markdown",
  "data" "### heading 123 \n[lorem ipsum](https://link) **dolor** sit amet, consectetur adipiscing elit. In id auctor dolor, in condimentum diam. Integer non dignissim odio, eget vehicula orci. Morbi id volutpat augue. Cras vel dui et mauris interdum ultricies. Nam euismod"
}

where cadenceResponseType is expected to always be the fixed string formattedData and format refers to the mime-type classification.

If it works, and if the format returned is supported, this can be rendered in the query UI. The react-md package in this instance takes care to sanitize the inputs since this would otherwise be an obvious XSS vector.

Testing:

  • tested locally, seems like I didn't completely break the existing JSON format (hopefully).

screenshot

@@ -33,3 +40,13 @@ export default function WorkflowQueriesResultJson(props: Props) {
</styled.ViewContainer>
);
}

const isContentMarkdown = (content: any): content is Markdown => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't write typescrypt, so feel free to let me know if you want me to learn how to use the type system more properly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, but with above type updates we wont need it any more

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If we still need this helper, it should be moved to a separate file

@@ -1,7 +1,7 @@
import {
type QueryJsonContent,
type Props,
} from '../workflow-queries-result-json.types';
} from '../workflow-queries-result.types';

export default function getQueryJsonContent(props: Props): QueryJsonContent {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Json can be removed from this name also since it is now returning multiple types of contents.

@@ -33,3 +40,13 @@ export default function WorkflowQueriesResultJson(props: Props) {
</styled.ViewContainer>
);
}

const isContentMarkdown = (content: any): content is Markdown => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, but with above type updates we wont need it any more

alignSelf: 'stretch',
flexDirection: 'row',
alignItems: 'flex-start',
padding: '30px',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this markdown is in the components directory which is intended for highly reusable components, we usually differ layout styles to the Usage (Pages). This allows components to be placed in different pages with different Styles (padding, background colors etc.).

In this case we can follow the how PrettyJSON component is done. So style for text is done here and surrounding styles are added to WorkflowQueriesResult

@@ -55,6 +59,6 @@ function setup({
loading?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can update the tests to check if type is markdown we show the Markdown Mock and in case of JSON we show PrettyJson Mock

@@ -33,3 +40,13 @@ export default function WorkflowQueriesResultJson(props: Props) {
</styled.ViewContainer>
);
}

const isContentMarkdown = (content: any): content is Markdown => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If we still need this helper, it should be moved to a separate file

@@ -8,7 +8,12 @@ export type Props = {
loading?: boolean;
};

export type Markdown = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding new types of content on a case-by-case basis, we can have a generic "custom content" type and add a configuration that parses it based on what the "type" field is.

@Assem-Uber
Copy link
Contributor

Assem-Uber commented Jun 11, 2025

Added styles for different use cases and added support to (autolink literals, footnotes, strikethrough, tables, tasklists)
Screenshot 2025-06-11 at 21 21 41

Handled responsiveness
Screenshot 2025-06-11 at 18 29 30
Screenshot 2025-06-11 at 18 29 15
Screenshot 2025-06-11 at 18 25 57

@davidporter-id-au davidporter-id-au merged commit 26e508a into cadence-workflow:master Jun 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants