-
Notifications
You must be signed in to change notification settings - Fork 2
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 ODP Schema validation example for FileTypes to publish checks #3373
Conversation
Removed vultr server and associated DNS entries |
const sortedValidationChecks = failingChecks | ||
.concat(warningChecks) | ||
.concat(passingChecks) | ||
.concat(notApplicableChecks); |
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.
Anyone have a more clever suggestion for how to sort in a custom order by "status" ? This is explicit and easy-to-read, but a bit lengthy and I feel like there's probably some cool one-liner I'm missing?
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.
Yeah I can think of a few ways!
Map.groupBy
is pretty new but seems to have decent coverage https://caniuse.com/?search=map.groupby
I think it would then just be Map.groupBy(passingChecks, (check) => check.status))
.
If we hit browser compatibility issues here we could import groupBy
from lodash, or use a reduce()
.
Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/groupBy
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.
Ah just realised we're in the API here on Node 18 - I don't think Map.groupBy()
would be available.
Lodash or reduce()
would be the way to go here 👍
…ss/validate-files-against-schema
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.
All looking very good, a few small comments / suggestions here and there 👍
Link to exact node(s) with unsupported variables
Nice idea! Yep let's pick this up once we have this function ready for search.
Link to ODP Schema definitions (could even be Issue template?)
Another great idea 💡
const sortedValidationChecks = failingChecks | ||
.concat(warningChecks) | ||
.concat(passingChecks) | ||
.concat(notApplicableChecks); |
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.
Yeah I can think of a few ways!
Map.groupBy
is pretty new but seems to have decent coverage https://caniuse.com/?search=map.groupby
I think it would then just be Map.groupBy(passingChecks, (check) => check.status))
.
If we hit browser compatibility issues here we could import groupBy
from lodash, or use a reduce()
.
Docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/groupBy
const sortedValidationChecks = failingChecks | ||
.concat(warningChecks) | ||
.concat(passingChecks) | ||
.concat(notApplicableChecks); |
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.
Ah just realised we're in the API here on Node 18 - I don't think Map.groupBy()
would be available.
Lodash or reduce()
would be the way to go here 👍
|
||
const getFileUploadNodeFns = (flowGraph: FlowGraph): string[] => { | ||
const fileUploadNodes = Object.entries(flowGraph).filter( | ||
(entry): entry is [string, Node] => |
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.
So, as of TS 5.5 I think we can lose the entry is [string, Node]
here and it should be inferred from isComponentType()
.
Docs: https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#inferred-type-predicates
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.
Yep, you're correct this is just properly inferred from isComponentType()
- removed unnecessary verbose-ness!
@@ -23,7 +25,7 @@ type AlteredNode = { | |||
|
|||
type ValidationResponse = { | |||
title: string; | |||
status: "Pass" | "Fail" | "Not applicable"; | |||
status: "Pass" | "Fail" | "Warn" | "Not applicable"; |
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 was expecting to see this change also picked up in docs.yaml
, but it looks like we've missed adding in the validationChecks
property.
Happy for this to be picked up here, or in a follow up PR 👍
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.
Relies on theopensystemslab/planx-core#436
Changes:
FileUpload
and/orFileUploadAndLabel
nodes to the ODP Schema'sFileType
enum valuesFileUploadAndLabel
component is used in info-only mode with a hidden dropzoneWhat this doesn't do yet / future design scope: