import { EntityClass } from "./EntityClass"; export interface Relation { type: RelationType; to: () => EntityClass; inversedBy?: string; optional?: boolean; } export interface ManyToMany extends Relation { type: RelationType.ManyToMany; owner?: boolean; } export interface ManyToOne extends Relation { type: RelationType.ManyToOne; foreignKey?: string; } export interface OneToOne extends Relation { type: RelationType.OneToOne; foreignKey?: string; owner?: boolean; } export interface OneToMany extends Relation { type: RelationType.OneToMany; inversedBy: string; } export declare enum RelationType { OneToOne = "ONE_TO_ONE", OneToMany = "ONE_TO_MANY", ManyToOne = "MANY_TO_ONE", ManyToMany = "MANY_TO_MANY" } export declare type RelatedEntityClass = ReturnType; export declare type RelatedEntityType = RelatedEntityClass["prototype"]; export declare type RelatedRelationsType = RelatedEntityClass["relations"]; export declare type OneOrManyFromRelation = HasManyRelatedEntities extends true ? T[] : T; export declare type HasManyRelatedEntities = IsOneToMany extends true ? true : IsManyToMany extends true ? true : false; export declare type RequiresForeignKey = IsManyToOne extends true ? true : IsOneToOne extends true ? R extends OneToOne ? R["owner"] extends true ? true : false : false : false; export declare type IsOneToOne = IsRelationOfType; export declare type IsOneToMany = IsRelationOfType; export declare type IsManyToOne = IsRelationOfType; export declare type IsManyToMany = IsRelationOfType; export declare type IsRelationOfType = R["type"] extends T ? true : false; export declare type OptionalSingularRelations = { [K in keyof OptionalRelations as HasManyRelatedEntities[K]> extends true ? never : K]: TRelations[K]; }; export declare type OptionalRelations = { [K in keyof TRelations as IsOptional extends true ? K : never]: TRelations[K]; }; export declare type IsOptional = R["optional"] extends true ? true : false; //# sourceMappingURL=Relation.d.ts.map