///
import { ApsorcRelationship, Relationship, RelationshipMap, RelationshipForTemplate } from "../../types";
/**
* Parses a OneToMany relationship definition.
* These are treated as bidirectional from the .apsorc definition.
* Only generates the configuration for the 'from' side.
* @param relationship The .apsorc relationship definition.
* @returns A RelationshipMap containing only the entry for the 'from' side.
*/
export declare const parseOneToMany: (relationship: ApsorcRelationship) => RelationshipMap;
/**
* Parses a ManyToOne relationship definition.
* Bidirectional by default, mirroring parseOneToMany with from/to swapped:
* the target entity gets the inverse OneToMany collection (and with it the
* controller join allowlist), so `Authors?join=books` works no matter which
* direction the .apsorc declared the relationship in.
* Set `bi_directional: false` to keep the old FK-only unidirectional shape.
* Self-referencing relationships stay unidirectional (both sides would
* collide on the same RelationshipMap key).
* @param relationship The .apsorc relationship definition.
* @returns A RelationshipMap with entries for both sides (or just 'from' when unidirectional).
*/
export declare const parseManytoOne: (relationship: ApsorcRelationship) => RelationshipMap;
/**
* Parses a ManyToMany relationship definition.
* Determines bidirectionality based on flags and inverse definitions.
* Determines the owning side (which gets the @JoinTable decorator).
* Calculates reference names (property names), defaulting if 'to_name' is missing.
* If bidirectional, generates configuration for both 'from' and 'to' sides.
* @param relationship The .apsorc relationship definition.
* @param allRelationships The full list of relationship definitions for finding inverses.
* @returns A RelationshipMap containing entries for one or both sides.
*/
export declare const parseManyToMany: (relationship: ApsorcRelationship, allRelationships: ApsorcRelationship[]) => RelationshipMap;
/**
* Parses a single relationship definition from .apsorc.
* Dispatches to the appropriate type-specific parser (parseManyToMany, parseOneToMany, etc.).
* For bidirectional relationships, the type-specific parsers handle generating data for both sides.
* @param relationship The single .apsorc relationship definition to parse.
* @param allRelationships The full list of relationship definitions (needed for context, e.g., finding inverses).
* @returns A RelationshipMap, potentially containing entries for both entities involved in the relationship.
*/
export declare const parseRelationship: (relationship: ApsorcRelationship, allRelationships: ApsorcRelationship[]) => RelationshipMap;
/**
* Parses the entire array of relationship definitions from the .apsorc file.
* Iterates through each definition, calls parseRelationship, and merges the results.
* @param relationships The array of relationship definitions from .apsorc.
* @returns A comprehensive RelationshipMap mapping entity names to their Relationship objects.
*/
export declare const parseRelationships: (relationships: ApsorcRelationship[]) => RelationshipMap;
export declare const getRelationshipIdField: (relationship: Relationship) => string;
/**
* Transforms the parsed Relationship data into the final format needed by the entity/controller templates.
* Calculates additional helper properties like pluralized names and inverse property names.
* @param entityName The name of the entity for which to generate template data.
* @param relationships An array of Relationship objects for the given entity.
* @param entities Optional array of all entities, used to determine referenced entity's primary key type.
* @returns An array of RelationshipForTemplate objects with extra properties for the template.
*/
export declare const getRelationshipForTemplate: (entityName: string, relationships: Relationship[], entities?: any[]) => RelationshipForTemplate[];
/**
* Generates all valid nested join paths for an entity, avoiding cycles and redundant paths.
*
* Requirements enforced:
* 1. No cycles by tracking visited (entity, reference) pairs in the current path
* 2. Allow the same entity with different references (proper name vs alias)
* 3. Allow different aliases to the same entity in different branches
* 4. Respect max depth limit
*
* @param entityName - Current entity to generate relationships from
* @param relationshipMap - Map of all entity relationships
* @param maxDepth - Maximum depth of nested joins (default: 6)
* @param path - Current join path being built (internal use)
* @param visitedPairs - Set of (entity, reference) pairs visited in current path (internal use)
* @param baseEntity - The root entity we started from (internal use)
* @returns Generator yielding valid join path strings
*/
export declare function generateNestedRelationships(entityName: string, relationshipMap: RelationshipMap, maxDepth?: number, path?: string[], visitedPairs?: Set, baseEntity?: string): Generator;
export declare function getNestedRelationships(entityName: string, relationshipMap: RelationshipMap, maxDepth?: number): string[];
export declare function streamNestedRelationships(entityName: string, relationshipMap: RelationshipMap, writable: NodeJS.WritableStream, maxDepth?: number): Promise;
export declare const getRelationshipsForImport: (entityName: string, relationships?: Relationship[]) => string[];