Repository navigation
feat: add the @dcmjs/schemas package with the naturalized-rules catalog generator - #522
Merged
Merged
Conversation
…og generator Co-Authored-By: Claude Fable 5 <[email protected]>
…og header Co-Authored-By: Claude Fable 5 <[email protected]>
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.
This PR starts the
@dcmjs/schemaspackage. It's step 3 of section 6 in RELEASE_PLAN.md, and it covers the naturalized-rules half of the schema work. Quick context for anyone who hasn't been following the branch: the "naturalized" representation is the plain-JavaScript view of a DICOM dataset —dataset.PatientNameinstead of raw tag numbers. This package builds a machine-readable catalog that says, for every standard DICOM attribute, what its keyword is, what type it holds (its VR, or value representation), and how many values it can carry (its VM, or value multiplicity).Three pieces land here, all under
packages/schemas/generate/:buildCatalog.mjs— the catalog builder. It's deliberately pure (no file I/O, noimport.meta) so jest can import it directly, which the CI reproducibility gates in the next PR rely on. It reads the packed data dictionary already insrc/viagetAllStandardTagEntries()and fails loudly on anything it can't classify.schemaRules.mjs— the rule tables:parseVm()for VM patterns like1-nand3-3n, the VR-to-JS-type maps (VR_SCALAR,MULTI_VR), the Part 5 value-format constraints (VR_FORMATS), and the excluded structural tags (EXCLUDED_TAGS).generate-schema.mjs— the CLI shell that owns the filesystem writes. It emits three artifacts: the rules catalog (src/schema/naturalizedRules.js), a JSON Schema (schema/naturalized.schema.json), and TypeScript typings (types/dcmjs-schema.d.ts).Here's the shape of it — the builder returns the whole catalog as one object, and the CLI just serializes it three ways:
Two things worth flagging. First, this PR does not commit the generated artifacts — I verified the generator's output is byte-identical to the artifacts on the rewrite branch, and those committed artifacts arrive in the next PR together with a CI check that regeneration reproduces them exactly. Second, getting jest to transform files under
packages/needed a rootbabel.config.jswithbabelrcRoots, so that's included; each package keeps its own presets in its.babelrc.The rule tables are covered by a new suite,
test/schema/schemaRules.test.js, which pins the VM parsing and the VR maps. The IOD catalog half of the schema work is deferred — it'll land with the validation package that consumes it.🤖 Generated with Claude Code