/** * Graph Relationship Interfaces * * Types for relationship CRUD operations * Based on Ductape Graph API documentation (relationships.md, overview.md) */ import { IGraphWhereClause } from './query.interface'; /** * Generic relationship properties type */ export type RelationshipProperties = Record; /** * Relationship structure * As documented in relationships.md */ export interface IRelationship { /** Database-specific ID */ id: string | number; /** Relationship type */ type: string; /** Source node ID */ startNodeId: string | number; /** Target node ID */ endNodeId: string | number; /** Relationship properties */ properties: T; /** Neo4j 5.x element ID */ elementId?: string; } /** * Options for creating a relationship * As documented in relationships.md */ export interface ICreateRelationshipOptions { /** Relationship type (e.g., 'FRIENDS_WITH', 'MANAGES') */ type: string; /** Source node ID */ startNodeId: string | number; /** Target node ID */ endNodeId: string | number; /** Relationship properties */ properties?: T; } /** * Result of creating a relationship * As documented in relationships.md */ export interface ICreateRelationshipResult { /** The created relationship */ relationship: IRelationship; /** Always true for create */ created: boolean; } /** * Options for finding relationships * As documented in relationships.md */ export interface IFindRelationshipsOptions { /** Relationship type(s) to filter by */ type?: string | string[]; /** Relationship types to filter by (alias for type) */ types?: string[]; /** Filter by source node ID */ startNodeId?: string | number; /** Filter by target node ID */ endNodeId?: string | number; /** Filter conditions on properties */ where?: IGraphWhereClause; /** Maximum number of results */ limit?: number; /** Number of results to skip */ offset?: number; /** Number of results to skip (alias for offset) */ skip?: number; } /** * Result of finding relationships * As documented in relationships.md */ export interface IFindRelationshipsResult { /** Array of matching relationships */ relationships: IRelationship[]; /** Total count (for pagination) */ count?: number; /** Total count (alias for count) */ total?: number; } /** * Options for updating a relationship * As documented in relationships.md */ export interface IUpdateRelationshipOptions { /** Relationship ID to update */ id?: string | number; /** Relationship type to filter by (for batch update) */ type?: string; /** Filter conditions (for batch update) */ where?: IGraphWhereClause; /** Properties to update */ properties: Partial | IRelationshipPropertyUpdate; } /** * Property update operations * As documented in relationships.md */ export interface IRelationshipPropertyUpdate { [key: string]: any | { $INCREMENT: number; } | { $SET: any; } | { $UNSET: boolean; }; } /** * Result of updating a relationship * As documented in relationships.md */ export interface IUpdateRelationshipResult { /** Updated relationship (if single update) */ relationship?: IRelationship; /** Updated relationships (if batch update) */ relationships?: IRelationship[]; /** Number of relationships updated */ updatedCount?: number; /** Whether the relationship was updated */ updated?: boolean; } /** * Options for deleting a relationship * As documented in relationships.md */ export interface IDeleteRelationshipOptions { /** Relationship ID to delete */ id?: string | number; /** Relationship type to filter by (for batch delete) */ type?: string; /** Filter by source node ID */ startNodeId?: string | number; /** Filter by target node ID */ endNodeId?: string | number; /** Filter conditions (for batch delete) */ where?: IGraphWhereClause; } /** * Result of deleting a relationship * As documented in relationships.md */ export interface IDeleteRelationshipResult { /** Whether deletion succeeded */ deleted: boolean; /** Number of relationships deleted */ deletedCount?: number; /** ID of deleted relationship */ id?: string | number; } /** * Options for merge (upsert) relationship operation * As documented in relationships.md */ export interface IMergeRelationshipOptions { /** Relationship type */ type: string; /** Source node ID */ startNodeId: string | number; /** Target node ID */ endNodeId: string | number; /** Properties to match on */ matchProperties?: Partial; /** Properties to set if relationship is created */ onCreate?: Partial; /** Properties to set if relationship already exists */ onMatch?: Partial | IRelationshipPropertyUpdate; } /** * Result of merge relationship operation * As documented in relationships.md */ export interface IMergeRelationshipResult { /** The resulting relationship */ relationship: IRelationship; /** true if created, false if matched */ created: boolean; /** Whether the merge operation completed */ merged?: boolean; } /** * Relationship filter for traversals */ export interface IRelationshipFilter { /** Types to filter by */ types?: string[]; /** Property filter conditions */ where?: IGraphWhereClause; } /** * Options for creating relationship index * As documented in relationships.md */ export interface ICreateRelationshipIndexOptions { /** Index name */ name: string; /** Relationship type */ type: string; /** Properties to index */ properties: string[]; }