import type { EntityRelationDtoSchema } from '../schemas/dto-schemas.js'; /** * Normalized relation data structure. * Derived from EntityRelationDtoSchema with required (but nullable) version/revision fields. */ export type NormalizedRelation = Pick & { /** * Source entity version (may be swapped from original) */ sourceVersion: string | null; /** * Target entity version (may be swapped from original) */ targetVersion: string | null; /** * Source entity revision (may be swapped from original) */ sourceRevision: string | null; /** * Target entity revision (may be swapped from original) */ targetRevision: string | null; }; /** * Input relation data structure. * Core relation fields from EntityRelationDtoSchema. */ export type RelationInput = Pick; /** * Normalizes a relation to its canonical form. * * This function: * 1. Looks up the canonical relation type in the normalization map * 2. If the relation type differs from its canonical form, swaps source and target (including versions and revisions) * 3. Uses the canonical relation type * 4. For unknown relation types, passes through without modification * * @param relation - The relation to normalize * @returns Normalized relation with canonical type and potentially swapped entities * * @example * // Normalize ownedBy -> owns with swapped entities * normalizeRelation({ * type: 'ownedBy', * sourceKey: 'api-1', * targetKey: 'team-1', * sourceVersion: 'v1', * targetVersion: null, * sourceRevision: null, * targetRevision: null, * }) * // Returns: * // { * // type: 'owns', * // sourceKey: 'team-1', // swapped * // targetKey: 'api-1', // swapped * // sourceVersion: null, // swapped * // targetVersion: 'v1', // swapped * // sourceRevision: null, * // targetRevision: null, * // } * * @example * // Canonical type passes through unchanged * normalizeRelation({ * type: 'owns', * sourceKey: 'team-1', * targetKey: 'api-1', * sourceVersion: null, * targetVersion: 'v1', * sourceRevision: null, * targetRevision: null, * }) * // Returns: same as input */ export declare function normalizeRelation(relation: RelationInput): NormalizedRelation; //# sourceMappingURL=normalize-relation.d.ts.map