UNPKG

domain-objects

Version:

A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.

17 lines (16 loc) 876 B
import type { DomainObjectShape, Refable } from './Refable'; import type { RefByPrimary } from './RefByPrimary.type'; import type { RefByUnique } from './RefByUnique.type'; /** * declares a reference to a domain.entity or a domain.event */ export type Ref<TDobj extends Refable<TShape, TPrimary, TUnique>, TShape extends DomainObjectShape = any, // todo: update DomainObjectShape -> DomainReferenceableInstance to enable extraction of primary and unique keys via types TPrimary extends readonly string[] = any, TUnique extends readonly string[] = any> = { /** * the name of the domain object this is a reference to, if provided * * note * - this will be automatically specified if using `getRef` */ _dobj?: string; } & ((Required<RefByPrimary<TDobj, TShape, TPrimary, TUnique>> & {}) | (RefByUnique<TDobj, TShape, TPrimary, TUnique> & {}));