fix(contract): add .contract.ref(by) — an x-domain-object-ref pragma for cross-service references - #135
Merged
Merged
Conversation
…for cross-service references
- .contract.ref('primary'|'unique'|'ref') returns a zod schema of only the referenced
key fields, stamped with an x-domain-object-ref pragma that survives z.toJSONSchema()
- lets a field REFERENCE another dobj by key (not compose the whole dobj), so a cross-service
consumer can emit a typed RefBy*<typeof X> instead of an anonymous shape
- unique-key recursion mirrors refByUnique (via shared hasDeclaredUniqueKey gate); primary stays
a flat pick; ref degrades a union-of-one; cyclic/polymorphic unique graphs fail fast
- new DomainObjectPragmaRef type + DomainObjectClass structural view, exported from the barrel
- memoized per class+by (WeakMap), mirroring getContract
- covered by unit tests, a full producer->wire->consumer roundtrip acceptance journey
(single ref, array-of-refs, nested recursion, ref-union), and exhaustive snapshots
Co-authored-by: Ulad Kasach <uladkasach@gmail.com>
uladkasach
force-pushed
the
vlad/fix-contract-refs
branch
from
July 23, 2026 02:01
de45f49 to
4835b1c
Compare
Contributor
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.
fix(contract): add .contract.ref(by) — an x-domain-object-ref pragma for cross-service references
key fields, stamped with an x-domain-object-ref pragma that survives z.toJSONSchema()
consumer can emit a typed RefBy* instead of an anonymous shape
a flat pick; ref degrades a union-of-one; cyclic/polymorphic unique graphs fail fast
(single ref, array-of-refs, nested recursion, ref-union), and exhaustive snapshots
🐢🌊 surfed in by seaturtle[bot]