/** * Graph Schema Interfaces * * Types for schema management (indexes, constraints) * Based on Ductape Graph API documentation (overview.md) */ import { NodeConstraintType, NodeIndexType } from './enums'; /** * Options for creating a node index * As documented in overview.md */ export interface ICreateNodeIndexOptions { /** Index name */ name: string; /** Node label to index */ label: string; /** Properties to include in the index */ properties: string[]; /** Whether the index should enforce uniqueness */ unique?: boolean; /** Index type */ type?: NodeIndexType | string; /** Additional index options */ options?: { sparse?: boolean; unique?: boolean; }; } /** * Options for creating a node constraint * As documented in overview.md */ export interface ICreateNodeConstraintOptions { /** Constraint name */ name: string; /** Node label */ label: string; /** Property to constrain */ property?: string; /** Properties to constrain (for multi-property constraints) */ properties?: string[]; /** Constraint type: UNIQUE, EXISTS, NODE_KEY */ type: NodeConstraintType | 'UNIQUE' | 'EXISTS' | 'NODE_KEY'; } /** * Index information */ export interface IGraphIndex { /** Index name */ name: string; /** Label (for node indexes) or type (for relationship indexes) */ labelOrType: string; /** Indexed properties */ properties: string[]; /** Whether unique */ unique: boolean; /** Index type */ type: string; /** Index state */ state?: string; } /** * Constraint information */ export interface IGraphConstraint { /** Constraint name */ name: string; /** Label */ label: string; /** Constrained property */ property: string; /** Constraint type */ type: string; } /** * Result of listing indexes */ export interface IListIndexesResult { /** All indexes */ indexes: IGraphIndex[]; } /** * Result of listing constraints */ export interface IListConstraintsResult { /** All constraints */ constraints: IGraphConstraint[]; } /** * Result of creating an index */ export interface ICreateIndexResult { /** Whether index was created */ created: boolean; /** Index name */ name: string; } /** * Result of creating a constraint */ export interface ICreateConstraintResult { /** Whether constraint was created */ created: boolean; /** Constraint name */ name: string; } /** * Result of dropping an index */ export interface IDropIndexResult { /** Whether index was dropped */ dropped: boolean; } /** * Result of dropping a constraint */ export interface IDropConstraintResult { /** Whether constraint was dropped */ dropped: boolean; } /** * Property type for schema introspection */ export type GraphPropertyType = 'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'array' | 'point' | 'object' | 'unknown'; /** * Property definition for a label */ export interface IGraphLabelProperty { /** Property name */ name: string; /** Property type */ type: GraphPropertyType; /** Whether property exists on all nodes with this label */ required?: boolean; } /** * Label definition with schema information */ export interface IGraphLabel { /** Label name */ name: string; /** Number of nodes with this label */ count: number; /** Properties found on nodes with this label */ properties: IGraphLabelProperty[]; /** Display color (optional, for UI purposes) */ color?: string; } /** * Result of listing labels */ export interface IListLabelsResult { /** All node labels */ labels: IGraphLabel[]; } /** * Relationship type definition with schema information */ export interface IGraphRelationshipType { /** Relationship type name */ type: string; /** Number of relationships of this type */ count: number; /** Source node label(s) commonly used */ fromLabels?: string[]; /** Target node label(s) commonly used */ toLabels?: string[]; /** Properties found on relationships of this type */ properties?: IGraphLabelProperty[]; } /** * Result of listing relationship types */ export interface IListRelationshipTypesResult { /** All relationship types */ types: IGraphRelationshipType[]; } /** * Parameter types for graph actions */ export type GraphActionParameterType = 'string' | 'number' | 'boolean' | 'array' | 'object'; /** * Parameter definition for a graph action */ export interface IGraphActionParameter { /** Parameter name (used as placeholder {{name}}) */ name: string; /** JSON path to the value in the query object */ path: string; /** Default value for the parameter */ defaultValue: any; /** Parameter type */ type: GraphActionParameterType; /** Optional description */ description?: string; /** Whether the parameter is required */ required?: boolean; } /** * Graph action definition * Represents a saved parameterized query that can be executed with different parameter values */ export interface IGraphAction { /** Unique identifier */ id: string; /** Unique tag (URL-safe slug) */ tag: string; /** Display name */ name: string; /** Optional description */ description?: string; /** Operation type (e.g., findNodes, traverse, executeRaw) */ operation: string; /** Query object with parameter placeholders */ query: Record; /** Parameter definitions */ parameters: IGraphActionParameter[]; /** ISO timestamp when action was created */ createdAt: string; /** ISO timestamp when action was last updated */ updatedAt?: string; /** Graph tag this action belongs to */ graphTag?: string; } /** * Options for creating a graph action */ export interface ICreateGraphActionOptions { /** Display name */ name: string; /** Optional description */ description?: string; /** Operation type */ operation: string; /** Query object with parameter placeholders */ query: Record; /** Parameter definitions */ parameters: IGraphActionParameter[]; /** Graph tag (optional, defaults to current connected graph) */ graphTag?: string; } /** * Options for updating a graph action */ export interface IUpdateGraphActionOptions { /** Display name */ name?: string; /** Optional description */ description?: string; /** Query object with parameter placeholders */ query?: Record; /** Parameter definitions */ parameters?: IGraphActionParameter[]; } /** * Options for executing a graph action */ export interface IExecuteGraphActionOptions { /** Product tag */ product: string; /** Environment slug */ env: string; /** Graph tag */ graph: string; /** Action tag */ action: string; /** Parameter values to substitute */ input?: Record; /** Session token in format: session_tag:jwt_token */ session?: string; /** Cache tag for result caching */ cache?: string; } /** * Result of executing a graph action */ export interface IExecuteGraphActionResult { /** Whether execution was successful */ success: boolean; /** Execution time in milliseconds */ executionTime: number; /** Result data */ data: T[]; /** Row count */ count: number; /** Error message if failed */ error?: string; } /** * Result of listing graph actions */ export interface IListGraphActionsResult { /** All actions for the graph */ actions: IGraphAction[]; }