Draft
Conversation
ran prettier formatting on all files COMUI-4513
update all dependencies to wanted COMUI-4512
update decoders to v2 COMUI-4514
6968e43 to
77568b3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upgrade decoders dependency from v1 to v2
Summary
This PR upgrades the
decoderslibrary from v1.x to v2.8.0, updating all decoder implementations to use the new v2 API. The migration maintains backward compatibility while adopting the improved API design and stricter validation.Key Changes
1. API Replacements
dispatch+guard→taggedUnion+verify: Simplified tagged union validation inClientToHost.tsandHostToClient.tsobject→exact: All object decoders now useexact(v2's renamed equivalent of v1'sobject). This maintains the existing strict validation behavior that rejects unknown properties, ensuring protocol integrity and catching malformed messages early.mixed→unknown: Updated type-safe handling of arbitrary datahardcoded→optional+transform: Replaced deprecatedhardcodedwith optional fields and default value transformationmap→transform: Updated functional transformations to use the newtransformmethod2. Affected Files
ClientToHost.ts- Updated message validationHostToClient.ts- Updated message validationLabeledMsg.ts- Refactored to useexact,optional, andtransformfor protocol/version defaultsLifecycle.ts- Replacedmixedwithunknown,objectwithexactModalRequest.ts- Updated decoder and mademodalDataoptionalNotification.ts- Simplified toast type conversion usingtransformPageMetadata.ts- Updated to useexactandunknownPublication.ts- Madepayloadoptional, updated decoderPromptOnLeave.ts- Minor formatting update3. Type Safety Improvements
unknowninstead ofmixedverify()method instead ofguard()wrapperWhy
exactinstead ofobject?In decoders v2, the old
objectdecoder was renamed toexact. The newobjectdecoder is permissive (allows extra properties). We useexactto preserve the original strict validation behavior, which is appropriate for a messaging protocol where unexpected fields indicate errors or version mismatches.Migration Reference
Changes follow the official migration guide: https://github.com/nvie/decoders/blob/main/MIGRATING-v2.md
Testing
All existing tests pass with the updated decoders implementation. The changes are API-compatible and maintain the same runtime behavior.