import type { ExistingLegalEntity, LegalEntityAssociationDto } from './legalEntity.types'; /** * A legal entity reachable from the root through `entityAssociations`, with every * role it holds (merged across parents) and either its fetched data or the fetch error. */ export interface AssociatedLegalEntity { id: string; name?: string; entityType?: string; /** 1 = directly associated with the root, 2 = associated with a level-1 entity, etc. */ depth: number; associations: LegalEntityAssociationDto[]; legalEntity?: ExistingLegalEntity; error?: string; } /** Upper bound on distinct legal entities collected (and therefore fetched) per walk. */ export declare const MAX_ASSOCIATED_LEGAL_ENTITIES = 50; export interface AssociatedLegalEntitiesResult { legalEntities: AssociatedLegalEntity[]; isTruncated: boolean; } /** * Walks a legal entity's associations recursively and returns every associated legal entity. * * Needed because nested association IDs are only known once their parent has been fetched, * so they can't be passed upfront to `useLegalEntities(ids)`. The walk goes breadth-first, * fetching each level in parallel, and: * - fetches each legal entity once, merging all of its roles * - skips the root and already-collected IDs, so cycles terminate * - records fetch failures per entity instead of failing the whole walk * - stops adding new legal entities after `maxLegalEntities`, flagging `isTruncated` * * Kept free of React/TanStack (fetching is injected) so it can be unit-tested in isolation; * `useAssociatedLegalEntities` wires it up to the query cache. */ export declare const collectAssociatedLegalEntities: (rootLegalEntity: ExistingLegalEntity, fetchLegalEntity: (legalEntityId: string) => Promise, maxLegalEntities?: number) => Promise;