-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat: add visualization card in customized parser #16
feat: add visualization card in customized parser #16
Conversation
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good place to add some unit tests for the parser :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, added cases accordingly.
async parserProvider(interaction: Interaction) { | ||
const additionalInfo = interaction.additional_info as { | ||
'VisualizationTool.output': string[]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type doesn't seem right, on line 21, additionalInfo
is nullable, but additional_info
in Interaction
is Record<string, unknown>
. Is additional_info
actually optional field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think assertion should happen after field check
return lines | ||
.map((line) => line.split(',').at(column)) | ||
.filter(<T>(v: T | null | undefined): v is T => v !== null && v !== undefined); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add the TODO comment
// TODO use a more robust CSV parsing library | |
const extractNthColumn = (csv: string, column: number) => { |
theoretically id can contain any character, i haven't tested whether "
in ids would be encoded or left as is, but current logic is not enough either way
also should output_builders/saved_objects.ts
be removed? and could there be some tests similar to
dashboards-assistant/server/olly/utils/output_builders/__tests__/saved_objects.test.ts
Line 11 in a74ff7f
describe('build saved objects', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using csv-parser
package, which is a popular and robust package to handle with csv format.
And sure, I migrate the test cases in save_objects.test.ts and add some edge cases.
}; | ||
|
||
export const VisualizationCardParser = { | ||
id: 'core_visualization', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should there be an order
explicitly? and i remember parsers should use the MessageParser
interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If order is not specified, default order value will be 999.
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
* feat: add implement visualization in customized parser Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: add csv-parser lib Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: add csv-parser lib Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: add test cases Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: optimize Signed-off-by: SuZhou-Joe <suzhou@amazon.com> --------- Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
* feat: add implement visualization in customized parser Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: add csv-parser lib Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: add csv-parser lib Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: add test cases Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: optimize Signed-off-by: SuZhou-Joe <suzhou@amazon.com> --------- Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Description
Parse out visualization message if the final response is generated by visualization tool.
Issues Resolved
List any issues this PR will resolve, e.g. Closes [...].
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.