Refactors ContextTypes&Intent to union type instead of enum#1139
Refactors ContextTypes&Intent to union type instead of enum#1139kriswest merged 9 commits intofinos:mainfrom
Conversation
✅ Deploy Preview for fdc3 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
e884964 to
991c549
Compare
Signed-off-by: Andrei Floricel <andrei.floricel@gmail.com>
991c549 to
6c0128f
Compare
kriswest
left a comment
There was a problem hiding this comment.
This change LGTM - although I think we should consider whether to add an array or use an array instead to simplify implementation of a runtime check as to whether a context is a standard type.
|
Sorry, this PR has slipped under my radar over the last few weeks. |
@kriswest Do you have a use case in mind where you would need to know if it is a standard type? |
|
@andreifloricel could outline the use case for this type and confirm or deny whether you see a use case for a util function to check if a context is a standard type at runtime? If we can confirm that I can probably document it and add in a util fn to do it (which may need an array or the type names). Without a use case, one of the other maintainers suggested dropping the enum/union entirely... I sort of see a use case - but I'd much rather confirmation from someone using it for real! |
Signed-off-by: Andrei Floricel <andrei.floricel@gmail.com>
…nums Signed-off-by: Andrei Floricel <andrei.floricel@gmail.com>
b379e4c to
a19a633
Compare
Signed-off-by: Andrei Floricel <andrei.floricel@gmail.com>
I think it all comes down to a type-safe API and implicitly to a superior DX. @kriswest I updated the PR:
Note:
L.E. I thought I managed to circumvent the TS problem when I finally managed to commit the changes but it was a false positive, in the end I had to comment out that part (see my comment in |
Signed-off-by: Andrei Floricel <andrei.floricel@gmail.com>
| ViewProfile: ['fdc3.contact', 'fdc3.organization', 'fdc3.nothing'], | ||
| ViewQuote: ['fdc3.instrument', 'fdc3.nothing'], | ||
| ViewResearch: ['fdc3.contact', 'fdc3.instrument', 'fdc3.organization', 'fdc3.nothing'], | ||
| }; |
There was a problem hiding this comment.
I tried to "trick" TypeScript to compile this, to no avail.
And TSDX seems to be more or less dead...
|
Isn't this a semver major breaking api change to anyone using the old style constants like below? |
I don't understand the use case for these. Do you have a local implementation dependent on these?
Isn't this opinionated? |
No, all changes in this PR are backward compatible:
|
A real use case for us is that we need to dynamically build UI controls for our users (e.g., right-click a grid cell and generate an intent for the context referenced in that specific cell). When we do this, it's very useful to know if that specific intent and/or context is a standard FDC3 one, because in that case we can make a lot of educated guesses. Such as, for example, deriving possible contexts for a standard intention (see the next section of the commentary).
Well, it is, but it's FDC3's opinion :) |
Signed-off-by: Andrei Floricel <andrei.floricel@gmail.com>
I agree with the change and type guard, but it is a breaking change on the caller side as ContextTypes and Intents is no longer exported. Put the above in a new file in the project and it is fine. Switch to this branch and it has errors for missing exports. |
Signed-off-by: Andrei Floricel <andrei.floricel@gmail.com>
Good spot! I reintroduced the deprecated enum types but marked them as deprecated. |
|
Shall we pick this up briefly at tomorrow's Standards Working Group meeting? Happy to add it to the agenda - I haven't yet caught up on the conversation. |
|
Hi @kriswest, since I can't attend today's Standards Working Group meeting, I'll try to to summarize all the changes in this task:
Note:
|
|
I removed the |
Signed-off-by: Andrei Floricel <andrei.floricel@gmail.com>
bingenito
left a comment
There was a problem hiding this comment.
Confirmed backcompat issue I raised is fixed. Looks good.
|
This PR when in without a changelog entry, which we will need to add before the next version of FDC3 is adopted |

closes #1138