domain-objects
Version:
A simple, convenient way to represent domain objects, leverage domain knowledge, and add runtime validation in your code base.
9 lines (8 loc) • 691 B
TypeScript
import { DomainObjectShape, Refable } from './DomainReferenceable';
import { DomainUniqueKeys } from './DomainUniqueKeys';
/**
* a generic which extracts the unique key shape of a domain object
*/
export type DomainUniqueKeyShape<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> = Pick<InstanceType<TDobj>, DomainUniqueKeys<TDobj>[number]>;
export { DomainUniqueKeyShape as DomainReferenceByUniqueKey, DomainUniqueKeyShape as RefByUnique, };