import type { DomainObjectShape, Refable } from '../reference/Refable'; import type { RefKeysUnique } from '../reference/RefKeysUnique'; /** * In Domain Driven Design, a Reference is a special type of Domain Literal that represents a reference to another Domain Object. * * A Domain Reference: * - contains only the identifying properties of the referenced object * - is immutable (like all Domain Literals) * - is used to refer to Domain Entities or Domain Events without including their full data * * The purpose of a Domain Reference is to enable lightweight references between domain objects without circular dependencies or data duplication. * * For example: * - A `SeaTurtleRefByUnique { seawaterSecurityNumber: string }` is a reference to a SeaTurtle by its unique key * * Note: * - Domain References are typically created automatically via `DomainEntity.RefByUnique` or `DomainEntity.RefByPrimary` * - You rarely need to extend a DomainRef directly */ export type RefByUnique, TShape extends DomainObjectShape = any, // todo: update DomainObjectShape -> DomainReferenceableInstance to enable extraction of primary and unique keys via types, when typescript supports constructor inference from instances TPrimary extends readonly string[] = any, TUnique extends readonly string[] = any> = Pick, RefKeysUnique[number]>; export declare const RefByUnique: { new , TShape extends DomainObjectShape = any, TPrimary extends readonly string[] = any, TUnique extends readonly string[] = any>(props: RefByUnique): RefByUnique; /** * .what = an interface via which to construct instances w/ immute operations * * .why = * - immute operations such as .clone produce more maintainable code by preventing unexpected mutations * - these immute operations provide a safe pit of success for common operations */ build, TShape extends DomainObjectShape = any, TPrimary extends readonly string[] = any, TUnique extends readonly string[] = any>(props: RefByUnique): RefByUnique; /** * .what = an interface via which to construct instances w/ immute operations * * .why = * - immute operations such as .clone produce more maintainable code by preventing unexpected mutations * - these immute operations provide a safe pit of success for common operations */ as, TShape extends DomainObjectShape = any, TPrimary extends readonly string[] = any, TUnique extends readonly string[] = any>(props: RefByUnique): RefByUnique; };