Skip to content

Feature/com UI 4514#327

Draft
daragh-king-genesys wants to merge 3 commits intomainfrom
feature/COMUI-4514
Draft

Feature/com UI 4514#327
daragh-king-genesys wants to merge 3 commits intomainfrom
feature/COMUI-4514

Conversation

@daragh-king-genesys
Copy link
Collaborator

Upgrade decoders dependency from v1 to v2

Summary

This PR upgrades the decoders library 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 + guardtaggedUnion + verify: Simplified tagged union validation in ClientToHost.ts and HostToClient.ts
  • objectexact: All object decoders now use exact (v2's renamed equivalent of v1's object). This maintains the existing strict validation behavior that rejects unknown properties, ensuring protocol integrity and catching malformed messages early.
  • mixedunknown: Updated type-safe handling of arbitrary data
  • hardcodedoptional + transform: Replaced deprecated hardcoded with optional fields and default value transformation
  • maptransform: Updated functional transformations to use the new transform method

2. Affected Files

  • ClientToHost.ts - Updated message validation
  • HostToClient.ts - Updated message validation
  • LabeledMsg.ts - Refactored to use exact, optional, and transform for protocol/version defaults
  • Lifecycle.ts - Replaced mixed with unknown, object with exact
  • ModalRequest.ts - Updated decoder and made modalData optional
  • Notification.ts - Simplified toast type conversion using transform
  • PageMetadata.ts - Updated to use exact and unknown
  • Publication.ts - Made payload optional, updated decoder
  • PromptOnLeave.ts - Minor formatting update

3. Type Safety Improvements

  • Maintains strict object validation (rejects unknown properties) to catch protocol errors
  • Better type inference with unknown instead of mixed
  • Cleaner API with verify() method instead of guard() wrapper

Why exact instead of object?

In decoders v2, the old object decoder was renamed to exact. The new object decoder is permissive (allows extra properties). We use exact to 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.

ran prettier formatting on all files

COMUI-4513
update all dependencies to wanted

COMUI-4512
update decoders to v2

COMUI-4514
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.

1 participant