API: migrate package-defect handling to CM patches (Phase 1, #128)#176
Open
ryukzak wants to merge 14 commits into
Open
API: migrate package-defect handling to CM patches (Phase 1, #128)#176ryukzak wants to merge 14 commits into
ryukzak wants to merge 14 commits into
Conversation
Adds an optional `patches?: Partial<Patches>` constructor option, passed to the CanonicalManager config; warns if set alongside an injected manager/register (which owns its own patch wiring). No example changes yet.
…on (P1.1) New src/api/patches/ helper module with injectDependency(match, deps) — a PackagePatch that adds missing FHIR package dependencies to a matching manifest. Migrates the dependency-injection blocks of the kbv-r4 and norge-r4 examples off preprocessPackage onto CM's patches config (kbv's preprocessPackage is fully removed; norge keeps its rename + resource fixes for P1.2/P1.3). Generated code typechecks and example tests pass.
Switches @atomic-ehr/fhir-canonical-manager from 0.0.24 to the canary build that ships the composable patches runtime, so the Phase-1 patch helpers resolve against a published version (not a local link). To be repinned to the proper release once CM #14 ships.
renamePackage(renames) — a PackagePatch that fixes manifest-name typos via an old→new map. Migrates norge-r4's packageNameFixes off preprocessPackage onto patches; norge's preprocessPackage now only handles the gd-RelatedPerson resource fix (P1.3 next). Generated code typechecks.
Adds scoped resource-phase URL-rewrite helpers (shared blanket replace + a ResourceScope of package/url). Migrates norge's gd-RelatedPerson Person->Patient fix (renameReferenceTarget) — norge's preprocessPackage is now fully gone — and ccda's IVL_TS->IVL-TS canonical typo (renameCanonical) onto its manual CM's patches config. Both examples regenerate successfully; norge generated code typechecks. ccda keeps preprocessPackage for CarePlanAct + bundle-type (P1.4/P1.5).
…1.5) swapBinding(swaps, scope?) — swap a binding's ValueSet URL for an available one (scoped URL replace). patchCodeSystem(url, codes) — add missing codes to a CodeSystem. Migrates ccda's CarePlanAct ValueSet swap and bundle-type missing codes; ccda's preprocessPackage is now fully removed. All three examples (kbv/norge/ccda) regenerate successfully and their generated code typechecks.
…P1.6)
Adds nesting scope combinators forPackage(match, handlers) and forResource(url,
handlers); the transform helpers (injectDependency/renameCanonical/
renameReferenceTarget/swapBinding) drop their scope args and are scoped by the
combinators instead. APIBuilder.patches now accepts a single handler or a list
per phase (PatchesInput), normalized to CM's array form. Restyles all three
examples to the grouped/nested form, e.g.
patches: { package: forPackage("de.basisprofil.r4", [injectDependency({ "hl7.fhir.r4.core": "4.0.1" })]) }
All three examples regenerate (Status: Success) and tests pass (kbv 5/0,
norge 3/0, ccda 24/0).
… to packageJson/indexEntry/fhirResource
…pe + Package{Name,Version} aliases)
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.
Phase 1 of the #128 migration (see
docs/design/defect-handling-migration.md, PR #173): move the examplepreprocessPackagedefect workarounds onto CanonicalManager's composablepatchesruntime (shipped in CM #14). Codegen-only; no CM changes.Helpers + combinators —
src/api/patches/Unscoped transform helpers, scoped by nesting combinators:
forPackage(match, handlers)andforResource(url, handlers)— scope a list of handlers (nest freely).injectDependency(deps),renameCanonical(renames),renameReferenceTarget(renames),swapBinding(swaps)(scoped via combinators);renamePackage(renames)andpatchCodeSystem(url, codes)(self-matching).APIBuilder
patches?: PatchesInputconstructor option — each phase accepts a single handler or a list — normalized to CM'sPartial<Patches>(arrays). Warns if combined with an injectedmanager/register(which owns its own patch wiring).Examples migrated off
preprocessPackagekbv,norge, andccdahave nopreprocessPackageleft.Notes
0.0.24-canary…(the published build with the patches API) — interim; repin to the proper release once CM minor fixes for Type Schema Writing #14 ships.manager.report()inprettyReport.Verification
cda9/0;local-package17/0.test-on-the-fly-example(kbv 5/0, norge 3/0) andtest-typescript-ccda-example(24/0) green — all three examples regenerate (Status: Success) and their generated code typechecks.make allis green up to the pre-existingsql-on-fhir"Library not found" failure (fixed separately in PR API: fix SQL-on-FHIR generation by adding the missing hl7.fhir.r5.core dependency #175; unrelated to Phase 1) — it aborts there, so the example targets above were run directly to validate.