@luolapeikko/graph-entity-types
v0.2.0
Published
Typess for Graph Entity module
Readme
@luolapeikko/graph-entity-types
TypeScript type definitions for the Graph Entity ecosystem. Provides core interfaces and types for graph nodes, edges, and graph management, designed for use with the @luolapeikko/graph-entity package or similar graph-based systems.
Installation
npm install @luolapeikko/graph-entity-typesor with pnpm:
pnpm add @luolapeikko/graph-entity-typesOverview
This package contains reusable TypeScript types and interfaces for building strongly-typed graph data structures and event-driven graph managers.
Exports
IGraphBaseEntityNode– Base interface for a graph nodeIGraphEventEntityNode– Node interface with event supportGraphNodeEventMapping– Node event mapping typeGraphEdge– Type for graph edgesGraphManagerEventMapping– Event mapping for graph managersGraphStructure– Recursive type for graph structureGraphEdgeStructure– Recursive type for edge structureIGraphManager– Interface for a graph manager
Example Usage
import type { IGraphBaseEntityNode, GraphEdge } from '@luolapeikko/graph-entity-types';
// Define a node type
type MyNode = IGraphBaseEntityNode<1, { label: string }>;
const nodeA: MyNode = {
nodeType: 1,
nodeId: 'cf9cda0d-b479-4e07-b2bd-695c161d71db',
getNodeProps: () => ({ label: 'Node A' }),
};
const nodeB: MyNode = {
nodeType: 1,
nodeId: 'b4794e07-b2bd-695c-161d71dbcf9cda0d',
getNodeProps: () => ({ label: 'Node B' }),
};
const edge: GraphEdge<MyNode> = { source: nodeA, target: nodeB };See more features on Package documentation
