import 'reflect-metadata'; import { AutoMap } from '@cratis/chronicle.contracts'; import { ChildrenFromMetadata } from './childrenFrom.js'; /** The contract-level event type identifier shape used across projection definitions. */ export type ContractEventType = { Id: string; Generation: number; Tombstone: boolean; }; /** Accumulated property mapping for a from clause. */ export interface FromRecord { Key: ContractEventType; Value: { Properties: Record; Key: string; ParentKey: string; }; } /** Plain object shape matching the wire-level `ChildrenDefinition`. */ export interface ChildrenDefinitionLike { IdentifiedBy: string; From: FromRecord[]; Join: unknown[]; Children: Record; All: { Properties: Record; IncludeChildren: boolean; AutoMap: AutoMap; }; RemovedWith: Array<{ Key: ContractEventType; Value: { Key: string; ParentKey: string; }; }>; RemovedWithJoin: Array<{ Key: ContractEventType; Value: { Key: string; }; }>; AutoMap: AutoMap; Nested: Record; NoAutoMapProperties: string[]; } /** * Resolves the contract event type for a decorated event constructor. * @param eventTypeConstructor - The event class constructor. * @returns The contract-level event type identifier. */ export declare function toContractEventType(eventTypeConstructor: Function): ContractEventType; /** * Builds a stable map key for a contract event type. * @param eventType - The contract event type. * @returns A string key unique to the event type/generation/tombstone combination. */ export declare function getEventTypeMapKey(eventType: ContractEventType): string; /** * Gets or creates the `From` entry for an event type within the given map. * @param fromByEventType - The map of event type key to accumulated from entry. * @param eventTypeConstructor - The event constructor to resolve the entry for. * @returns The existing or newly created from entry. */ export declare function ensureFromEntry(fromByEventType: Map, eventTypeConstructor: Function): FromRecord; /** * Applies the property-mapping decorators (`@setFrom`, `@setFromContext`, `@setValue`, * `@addFrom`, `@subtractFrom`, `@increment`, `@decrement`, `@count`) declared on a single * property into the given from-by-event-type map. Shared by the root model-bound processing * loop and by child/nested type processing below, so both honor the same decorators. * @param prototype - The class prototype the property is declared on. * @param property - The property name. * @param fromByEventType - The map of event type key to accumulated from entry to populate. */ export declare function applyPropertyMappings(prototype: object, property: string, fromByEventType: Map): void; /** * Resolves the element type of a `@childrenFrom` collection property. TypeScript erases * generic type arguments at runtime, so the element type must be supplied by @childrenFrom * or `@field(Array, { genericArguments: [ItemType] })` - without it, * the children definition still registers correctly (structural Key/ParentKey wiring plus * AutoMap), it just cannot also translate the child type's own decorators. * @param type - The declaring class constructor. * @param property - The property name. * @returns The child element type constructor, or undefined when it cannot be resolved. */ export declare function resolveChildElementType(type: Function, property: string): Function | undefined; /** * Resolves the type of a `@nested` single-object property, preferring an explicit * `@field(NestedType)` declaration and falling back to `design:type` decorator metadata * (only available when compiled with `tsc`, not esbuild/tsx). * @param type - The declaring class constructor. * @param property - The property name. * @returns The nested type constructor, or undefined when it cannot be resolved. */ export declare function resolveNestedType(type: Function, property: string): Function | undefined; /** * Builds the `ChildrenDefinition` for a `@childrenFrom` collection property. * @param type - The class declaring the property. * @param property - The property name. * @param metadataList - The `@childrenFrom` metadata entries declared on the property (one per creating event type). * @param collectSharedMapping - Collects member mappings into their owning All definition. * @param path - The contract path of this children definition. * @returns The wire-shaped children definition. */ export declare function buildChildrenEntry(type: Function, property: string, metadataList: ChildrenFromMetadata[], collectSharedMapping?: (prototype: object, property: string, all: ChildrenDefinitionLike['All'], path: string) => void, path?: string): ChildrenDefinitionLike; /** * Builds the `ChildrenDefinition` for a `@nested` single-object property. * @param type - The class declaring the property. * @param property - The property name. * @param collectSharedMapping - Collects member mappings into their owning All definition. * @param path - The contract path of this nested definition. * @returns The wire-shaped nested definition. */ export declare function buildNestedEntry(type: Function, property: string, collectSharedMapping?: (prototype: object, property: string, all: ChildrenDefinitionLike['All'], path: string) => void, path?: string): ChildrenDefinitionLike; //# sourceMappingURL=childrenAndNestedBuilder.d.ts.map