feat(tree): add alpha Component utilities for open-polymorphic schema#27628
feat(tree): add alpha Component utilities for open-polymorphic schema#27628CraigMacomber wants to merge 10 commits into
Conversation
Promote the Component composition namespace from the openPolymorphism integration test into @fluidframework/tree as an @Alpha API, re-exported from fluid-framework. Adds unit tests, documentation, API report updates, and a changeset.
|
Hi! Thank you for opening this PR. Want me to review it? Based on the diff (1346 lines, 8 files), I've queued these reviewers:
How this works
|
|
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output |
| type MyAppComponent = Component.Factory<Composed, MyAppComponentContent>; | ||
|
|
||
| // A simple item type, with the required statics. | ||
| class MyItem extends sf.object("MyItem", {}) { |
There was a problem hiding this comment.
Should this implement MyStatics?
Bundle size comparisonBase commit: Notable changesNo bundles changed by ≥ 500 bytes parsed. Per-bundle deltas
|
| @@ -0,0 +1,316 @@ | |||
| /*! | |||
There was a problem hiding this comment.
Obviously not for this PR, but I wonder how easy it would be to expose a more restrictive, but easier to understand model on top of this that is explicitly Tree schema focused for the common use cases. We're trying to offer a lot of flexibility below, but I imagine the vast majority of users who would want to leverage a pattern like this for SharedTree would:
a) not need a lot of the flexibility
b) find leveraging them complex / potentially confusing.
If we offered a TreeComponent API layer above this that was more prescriptive, it might give the average user an easier onboarding experience, and then they could move to the lower level alternatives as needed to address complex scenarios.
Just a thought.
Josmithr
left a comment
There was a problem hiding this comment.
This seems reasonable to expose as alpha. I think we'd really want to get a lot of user feedback before promoting further though.
Long term, this also doesn't seem like it really belongs in SharedTree. Maybe a SharedTree-specific wrapper (like I suggested here) would want to live in this package long term, but this seems general enough to live somewhere else.
Description
Promotes the
Componentcomposition namespace out of theopenPolymorphism.integration.tstest file and into@fluidframework/treeas a new@alphaAPI (also re-exported fromfluid-framework). This pattern was previously validated only by the open-polymorphism examples; it's now a supported (alpha) part of the package because an app depends on it.Componentprovides utilities for composing independently authored application "components" that contribute to a shared configuration — useful for "open polymorphism" schema patterns where the set of allowed types for a field or collection can be extended by separate libraries. Each component is aComponent.Factorythat receives a lazy reference to the composed configuration and returns the content it contributes;Component.composeComponentscombines them into aComponent.ComposedComponents.Changes:
packages/dds/tree/src/simple-tree/api/componentApi.tswith the@alpha-tagged, fully documentedComponentnamespace, exporting only what's needed (Factory,LazyArray,Configurable,composeComponents,ComposedComponents); theConfigimplementation class stays internal.@fluidframework/treeand (via the alpha entrypoint)fluid-framework; API reports updated.Componentinstead of defining it locally.componentApi.spec.tssupplementing the existing example/integration tests.getConfigured(it previously ranconfigureon every call; now cached viagetOrCreate).Reviewer Guidance
The review process is outlined on this wiki page.
Componentnamespace is generic (not tied to tree types) but lives undersimple-tree/apialongside other schema-composition utilities. Feedback welcome on placement and on the genericComponentname for a top-level@alphaexport.Configurable/getConfiguredare part of the proposed API but aren't exercised by the integration examples (they're now covered by unit tests). Let me know if they should be trimmed to keep the surface minimal.