Diffo.Provider.Extension.Transformers.TransformInheritedJason (Diffo v0.5.1)

Copy Markdown View Source

Surfaces inherited and reverse-inherited results into the TMF JSON view.

TransformInheritedRefs injects the Ash calculations for inherited_place, inherited_party, inherited_characteristic, and reverse_inherited_characteristic so they are loadable via Ash.load/2. That alone keeps the brought-up values off the consumer-visible TMF surface — the calc result never reaches the place / relatedParty / serviceCharacteristic / resourceCharacteristic arrays on encode.

This transformer closes that gap. It appends one focused jason.customize step per TMF array — but only for the inherited kinds the resource actually declares:

  • inherited_placeDiffo.Provider.Instance.Util.surface_inherited_places/2 (the place array)
  • inherited_partyDiffo.Provider.Instance.Util.surface_inherited_parties/2 (the relatedParty array)
  • inherited_characteristic / reverse_inherited_characteristicDiffo.Provider.Instance.Util.surface_inherited_characteristics/2 (the serviceCharacteristic / resourceCharacteristic array)

Each step — at encode time — reads its inherited calc(s) off the record, drops %Diffo.Unknown{} sentinels (X-state is the Diffo diagnostic surface, not the TMF wire), and appends the concrete structs to its array. Each surfaced struct encodes via its own Jason.Encoder, so subtype fidelity is preserved without hand-building any TMF object here. See the Diffo.Provider.Instance.Util functions for the runtime logic and the ordering convention.

Single responsibility by design: calc injection stays in TransformInheritedRefs (an API concern), wire surfacing lives here (a TMF concern). The two evolve independently.

Runs after TransformInheritedRefs (the calcs must exist) and before AshJason.Resource.Transformer (which compiles the jason do steps into the Jason.Encoder implementation).

Summary

Functions

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.