import type { RefByUnique } from '../instantiation/RefByUnique'; import type { DomainObjectShape, Refable } from './Refable'; /** * creates a reference to a domain object by its unique key * * extracts only the unique key properties from a domain object instance * * note * - you may need to explicitly annotate the type for proper inference * - e.g., `const ref = refByUnique(turtle)` * - automatic resolution of the relationship between instance and class.static properties is not yet possible in TypeScript * - recursively extracts references from nested domain objects * - if a unique key property is itself a domain object, it will recursively call refByUnique on it * * @example * ```ts * const turtle = new SeaTurtle({ uuid: '1', seawaterSecurityNumber: '821', name: 'Crush' }); * const ref = refByUnique(turtle); * // ref = { seawaterSecurityNumber: '821' } * ``` * * @example * ```ts * // with nested domain objects * const turtle = new SeaTurtle({ seawaterSecurityNumber: '821', name: 'Crush' }); * const shell = new SeaTurtleShell({ turtle, algea: 'ALIL' }); * const ref = refByUnique(shell); * // ref = { turtle: { seawaterSecurityNumber: '821' } } * ``` */ export declare const refByUnique: , TShape extends DomainObjectShape = any, TPrimary extends readonly string[] = any, TUnique extends readonly string[] = any>(instance: InstanceType) => RefByUnique;