TypeSchema: store slicing separately from fields#203
Merged
Conversation
ryukzak
force-pushed
the
typeschema-slicing-refactor
branch
from
July 24, 2026 13:27
be5f1be to
095dde1
Compare
ryukzak
marked this pull request as ready for review
July 24, 2026 13:33
Slicing moves from RegularField/ChoiceFieldInstance into a schema-level 'slicing: Record<fieldName, FieldSlicing>' on specializations, profiles, snapshots and nested types. Fields describe the data shape; slicing is an independent constraint layer keyed by element name, so choice declarations, choice instances and regular fields are covered uniformly. flatProfile merges slicing maps leaf-wins per field (mirroring the field merge) and tree shaking prunes slicing entries for removed fields. Also redefine the slicing vocabulary locally instead of borrowing fhirschema types: SliceDiscriminator and inline rules union replace FS.FHIRSchemaDiscriminator and FS.SlicingRules, and the repeated 'discriminator.some(type === "type")' checks collapse into the isTypeDiscriminated predicate. Generated TS/Python output is byte-identical.
ryukzak
force-pushed
the
typeschema-slicing-refactor
branch
from
July 24, 2026 13:56
095dde1 to
8940186
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.
First of a two-PR sequence restructuring how TypeSchema stores and processes slice information.
slicing: Record<fieldName, FieldSlicing>at schema level (specializations, profiles, snapshots, nested types); fields describe the data shape, slicing is an independent constraint layer. Keyed by element name, so choice declarations/instances and regular fields are covered uniformly.flatProfilemerges slicing maps leaf-wins per field (mirroring the field merge); tree shaking prunes slicing entries for removed fields.SliceDiscriminator+ inline rules union replaceFS.FHIRSchemaDiscriminator/FS.SlicingRules; the repeated type-discriminator checks collapse into theisTypeDiscriminatedpredicate.Generated TS/Python output is byte-identical; only the serialized TypeSchema shape changes:
Follow-up PR (branch
typeschema-slice-derived-facts, stacked on this one): precomputed derived slice facts onFieldSlice(effectiveRequired,constrainedChoice,autoStub,resourceType), deduplicating the TS/Python writer collectors and fixing the divergences that duplication produced.