domain-objects
Version:
A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.
18 lines (17 loc) • 965 B
TypeScript
import { DomainPrimaryKeyShape } from './DomainPrimaryKeyShape';
import { DomainObjectShape, Refable } from './DomainReferenceable';
import { DomainUniqueKeyShape } from './DomainUniqueKeyShape';
/**
* declares a reference to a domain.entity or a domain.event
*/
export type DomainReference<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<DomainPrimaryKeyShape<TDobj, TShape, TPrimary, TUnique>> & {}) | (DomainUniqueKeyShape<TDobj, TShape, TPrimary, TUnique> & {}));
export { DomainReference as Ref, };