/** * Graph Node Interfaces * * Types for node CRUD operations * Based on Ductape Graph API documentation (nodes.md, overview.md) */ import { IGraphWhereClause } from './query.interface'; /** * Generic node properties type */ export type NodeProperties = Record; /** * Node structure * As documented in nodes.md */ export interface INode { /** Database-specific ID */ id: string | number; /** Node labels/types */ labels: string[]; /** Node properties */ properties: T; /** Neo4j 5.x element ID */ elementId?: string; /** Distance from start node (for traversals) */ distance?: number; } /** * Options for creating a node * As documented in nodes.md */ export interface ICreateNodeOptions { /** Node labels (e.g., ['Person', 'User']) */ labels: string[]; /** Node properties */ properties: T; } /** * Result of creating a node * As documented in nodes.md */ export interface ICreateNodeResult { /** The created node */ node: INode; /** Always true for create */ created: boolean; } /** * Options for finding nodes * As documented in nodes.md */ export interface IFindNodesOptions { /** Node labels to filter by */ labels?: string[]; /** Filter conditions */ 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; /** Order by properties */ orderBy?: IGraphOrderBy[]; /** Properties to return (projection) */ select?: string[]; /** Cache tag for result caching */ cache?: string; } /** * Order by specification */ export interface IGraphOrderBy { /** Property name */ property: string; /** Sort direction */ direction: 'asc' | 'desc' | 'ASC' | 'DESC'; } /** * Result of finding nodes * As documented in nodes.md */ export interface IFindNodesResult { /** Array of matching nodes */ nodes: INode[]; /** Total count (for pagination) */ count?: number; /** Total count (alias for count) */ total?: number; } /** * Options for updating a node * As documented in nodes.md */ export interface IUpdateNodeOptions { /** Node ID to update */ id?: string | number; /** Node labels to filter by (for batch update) */ labels?: string[]; /** Filter conditions (for batch update) */ where?: IGraphWhereClause; /** Properties to update */ properties: Partial | INodePropertyUpdate; } /** * Property update operations * As documented in nodes.md */ export interface INodePropertyUpdate { [key: string]: any | { $INCREMENT: number; } | { $SET: any; } | { $UNSET: boolean; }; } /** * Result of updating a node * As documented in nodes.md */ export interface IUpdateNodeResult { /** Updated node (if single update) */ node?: INode; /** Updated nodes (if batch update) */ nodes?: INode[]; /** Number of nodes updated */ updatedCount?: number; /** Whether the node was updated */ updated?: boolean; } /** * Options for deleting a node * As documented in nodes.md */ export interface IDeleteNodeOptions { /** Node ID to delete */ id?: string | number; /** Node labels to filter by (for batch delete) */ labels?: string[]; /** Filter conditions (for batch delete) */ where?: IGraphWhereClause; /** Also delete connected relationships */ detach?: boolean; } /** * Result of deleting a node * As documented in nodes.md */ export interface IDeleteNodeResult { /** Whether deletion succeeded */ deleted: boolean; /** Number of nodes deleted */ deletedCount?: number; /** ID of deleted node */ id?: string | number; } /** * Options for merge (upsert) operation * As documented in nodes.md */ export interface IMergeNodeOptions { /** Node labels */ labels: string[]; /** Properties to match on */ matchProperties: Partial; /** Properties to set if node is created */ onCreate?: Partial; /** Properties to set if node already exists */ onMatch?: Partial | INodePropertyUpdate; } /** * Result of merge operation * As documented in nodes.md */ export interface IMergeNodeResult { /** The resulting node */ node: INode; /** true if created, false if matched */ created: boolean; /** Whether the merge operation completed */ merged?: boolean; } /** * Node filter for traversals */ export interface INodeFilter { /** Labels to filter by */ labels?: string[]; /** Property filter conditions */ where?: IGraphWhereClause; } /** * Options for adding labels to a node */ export interface IAddLabelsOptions { /** Node ID */ id: string | number; /** Labels to add */ labels: string[]; } /** * Result of adding labels */ export interface IAddLabelsResult { /** Updated node with new labels */ node: INode; /** Labels that were added */ addedLabels: string[]; } /** * Options for removing labels from a node */ export interface IRemoveLabelsOptions { /** Node ID */ id: string | number; /** Labels to remove */ labels: string[]; } /** * Result of removing labels */ export interface IRemoveLabelsResult { /** Updated node without removed labels */ node: INode; /** Labels that were removed */ removedLabels: string[]; } /** * Options for setting labels on a node (replaces all existing labels) */ export interface ISetLabelsOptions { /** Node ID */ id: string | number; /** New labels to set (replaces existing) */ labels: string[]; } /** * Result of setting labels */ export interface ISetLabelsResult { /** Updated node with new labels */ node: INode; /** Previous labels */ previousLabels: string[]; /** New labels */ newLabels: string[]; }