TypeSchema: collect referenced nested types into SnapshotProfileTypeSchema - #162
Closed
ryukzak wants to merge 1 commit into
Closed
TypeSchema: collect referenced nested types into SnapshotProfileTypeSchema#162ryukzak wants to merge 1 commit into
ryukzak wants to merge 1 commit into
Conversation
…chema Builds snapshot.nested by closure rather than just the profile's own nested array. Walks: - Profile-local nested types (seeded first — they take precedence by URL over inherited copies when constraints exist). - Each nested type's fields (transitive nested-in-nested closure). - The profile's own constrained fields. - The base resource's fields — inherited types referenced by base fields matter to consumers that read inherited slots, and flatProfile only carries profile-level constraints. Identities are preserved (same URLs); nested schemas are shared by reference, not re-rooted to the profile. Currently sets up data with no immediate consumer — the TS writer still imports nested types via tsIndex.resolveType — but future code reading methods/types from the snapshot directly no longer needs to round-trip through the index for nested lookups.
Collaborator
Author
|
Closing — not required. The nested-collection groundwork wasn't unlocking anything concrete yet; we'll revisit if and when consumers actually need self-contained snapshots. |
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.
Stacks on #158.
Makes
snapshot.nesteda closure of every nested type a consumer might reach when reading the snapshot, rather than just the profile's own nested array.What the walk includes
Patient#contact→ `Patient#contact.communication` if referenced).Identities are preserved — same URLs, nested schemas shared by reference, not re-rooted to the profile.
Why now, what it unlocks
No immediate behavior change in the writer — the TS writer still imports nested types via `tsIndex.resolveType` and `tsModulePath`. But future code that reads methods/types from the snapshot directly (the larger plan) no longer needs to round-trip through the index for nested lookups. Snapshots become self-contained.
Tests
Two new tests in `test/unit/typeschema/utils.test.ts`:
Verification