AFTE RELEASE feat(customization): typed customization registry via AppTypes.Customizations#6133
AFTE RELEASE feat(customization): typed customization registry via AppTypes.Customizations#6133sedghi wants to merge 1 commit into
Conversation
…stomizations Seeds a declaration-merged AppTypes.Customizations registry so extensions can declare the value type of each customization id they own, and adds typed overloads to getCustomization, getValue, hasCustomization and setCustomizations. Registered ids get autocomplete and precise types; unregistered and dynamic ids keep the existing loose Customization fallback, so nothing breaks. setCustomizations payloads (including immutability-helper command specs and the custom $filter) are checked against the registry through the new CustomizationEntries type, which CustomizationPhaseInput now reuses for phased app-config blocks. Also drops a redundant string 'mode' scope argument in two modes that was mistyped against the CustomizationScope enum (Mode is the default). CUSTOMIZATION_TYPING_PLAN.md documents the design and the follow-up phases for populating the registry across extensions.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
❌ Deploy Preview for ohif-dev failed. Why did it fail? →
|
📝 WalkthroughWalkthroughThe PR adds a declaration-merged customization registry, typed customization update entries, and registry-aware ChangesTyped customization API
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Viewers
|
||||||||||||||||||||||||||||
| Project |
Viewers
|
| Branch Review |
ohifTypeOHIFCustomization
|
| Run status |
|
| Run duration | 01m 40s |
| Commit |
|
| Committer | Alireza |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
28
|
| View all changes introduced in this branch ↗︎ | |
Context
The CustomizationService exposes ~90 customization ids, but
getCustomization(id)returns the looseCustomizationunion for all of them. There is no discoverability of which ids exist or what shape each expects, and consumers compensate with ~20as unknown as X/as anycasts across the repo.setCustomizationspayloads (including$set/$pushcommand specs used by modes and app config) are not checked at all.Changes
This PR adds the typing infrastructure (no per-key population yet, and no runtime changes):
AppTypes.Customizationsregistry — an empty, declaration-merged global interface inplatform/core/src/types/AppTypes.ts, following the exact pattern already used byAppTypes.ServicesandPresentationIds. Each extension (in-tree or third-party) declares the ids it owns:Typed overloads on
getCustomization,getValue, andhasCustomization: registered ids get autocomplete and their declared return type; any other string (dynamic keys, undeclared third-party keys) falls back to the existingCustomization | undefinedsignature, so nothing breaks.Checked
setCustomizationspayloads via the newCustomizationEntriestype: registered ids accept their declared value directly or as an immutability-helper spec ({ $set: ... },{ $push: [...] }, the custom$filter, ...).CustomizationPhaseInputreuses it, so phase-taggedappConfig.customizationServiceblocks written in TypeScript are checked the same way.Two small call-site fixes:
usAnnotationandbasic-test-modepassed the raw string'mode'where theCustomizationScopeenum is expected (Mode is already the default scope, so the argument is dropped; runtime behavior identical).CUSTOMIZATION_TYPING_PLAN.mddocuments the design, the conventions for declaring keys, and the follow-up phases (populating the registry per extension, then optionally generating the docs table and a JSON Schema for JSONC customization files from the registry).Testing
tscdiffed against a pre-change baseline: three pre-existing false positives fixed (valid customization objects rejected by the oldRecord<string, Customization>input type), zero new errors.$pushof wrong element type rejected,$filteraccepted, unknown keys and string module refs still compiling) under both the repo compiler settings and--strict.Summary by CodeRabbit
New Features
Documentation