Skip to content

Handle different refs on target - #48

Merged
garethj2 merged 1 commit into
masterfrom
feat/FINMMTL-952-improve-relativization
Nov 17, 2026
Merged

garethj2 merged 1 commit into
masterfrom
feat/FINMMTL-952-improve-relativization

Conversation

@garethj2

Copy link
Copy Markdown
Contributor

Relativize filters to other refs on the target

Why

A graphic bound to an equip often needs to reference points that aren't under that equip. For example, an equip with a cooRef to a sibling co-ordinator record needs filters for the co-ordinator's points, written relative to the equip:

equipRef == $cooRef and dis == "Zone Temp" and point

Previously, includeOtherRefs only matched records that carry the same ref as the target (cooRef == $cooRef). Records contained under the referenced record couldn't be relativized, so the call threw.

What changed

makeRelativeHaystackFilterForTarget now tries a priority-ordered list of anchor refs on the target. For each anchor, a record matches if it either:

  • shares the ref with the target, giving cooRef == $cooRef and ... (the existing behaviour), or
  • is contained under the referenced record, giving equipRef == $cooRef and ... or equipRef->equipRef == $cooRef and ....

The first match wins and sets the macro used in the filter ($id, $cooRef, ...).

Anchor selection

  • Automatic (default): id is always tried first, then the other Ref tags on the target. Containment refs (siteRef, equipRef, spaceRef, floorRef) are never used, because they point to ancestors and would match far too broadly. If options.namespace is given, any ref defs it marks with containedBy (HNamespace.getContainmentRefs()) are excluded as well.
  • Explicit: the new targetRefNames?: string | string[] option replaces automatic discovery and is used exactly as given, in order. Include id if you want it. An empty value falls back to automatic discovery.
  • includeOtherRefs: false limits automatic discovery to id only.

Other changes

  • resolveDictPathForId is renamed to resolveContainedPath(anchorRef, ...).
  • The error thrown when nothing matches now lists the anchor refs that were tried.
  • JSDoc is updated for makeRelativeHaystackFilterForTarget, includeOtherRefs and targetRefNames.
  • getParentRefTag is unchanged and still uses its hardcoded order.

Compatibility

  • Existing $id and shared-ref results are unchanged.
  • Cases that used to throw (records contained under a non-containment ref) now resolve.
  • One minor ordering edge case: if one ref on the target gives a contained match and a later ref gives a shared match, the earlier ref now wins.

Tests

A new anchor refs block in spec/filter/relativize.spec.ts covers:

  • $id, contained and nested-contained matches
  • id precedence over other refs
  • containment refs never used automatically
  • namespace-based exclusion
  • non-Ref anchor values skipped
  • includeOtherRefs: false
  • targetRefNames as a string, a list, in priority order, and empty

@garethj2
garethj2 requested review from kianj2 and rracariu November 17, 2026 10:45
@garethj2 garethj2 self-assigned this Nov 17, 2026
@garethj2
garethj2 merged commit aa5bb3c into master Nov 17, 2026
1 check passed
@garethj2
garethj2 deleted the feat/FINMMTL-952-improve-relativization branch November 17, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants