Shared TypeScript type definitions for the CodeGraph monorepo. This package contains all entity, edge, graph, plugin, document, and NLP types used across packages. It has no runtime dependencies -- pure TypeScript declarations and constants.
pnpm add @codegraph/types
pnpm build
Entity types representing code constructs in the graph:
FileEntity-- source file with path, LOC, hash, and optional embeddingFunctionEntity-- function/method with params, return type, complexity metrics, body snippetClassEntity-- class with export status, abstract flag, extends/implementsInterfaceEntity-- interface with export status and extendsVariableEntity-- variable with kind (const/let/var) and type annotationTypeEntity-- type alias or enum declarationComponentEntity-- React component with propsImportEntity-- import statement with specifiers and resolved pathCommitEntity-- git commit with hash, message, author, dateProjectEntity-- parsed project metadata
Base types: BaseEntity, RangeEntity, ProvenanceFields
Helper types: FunctionParam, ComponentProp, ImportSpecifier, VariableKind, TypeKind
Union types: Entity (all entity types), NodeLabel (all graph node labels)
Relationship types connecting nodes in the graph:
- Structural:
ContainsEdge(file contains entity) - Import/Export:
ImportsEdge,ImportsSymbolEdge,ExportsEdge - Call graph:
CallsEdge,InstantiatesEdge - Inheritance:
ExtendsEdge,ImplementsEdge - Type usage:
UsesTypeEdge,ReturnsEdge,HasParamEdge - Class members:
HasMethodEdge,HasPropertyEdge(withVisibility) - React:
RendersEdge,UsesHookEdge - Git temporal:
IntroducedInEdge,ModifiedInEdge,DeletedInEdge - Dataflow:
ReadsEdge,WritesEdge,FlowsToEdge - Document:
HasSectionEdge,ParentSectionEdge,ContainsCodeEdge,LinksToEdge - Bridge:
AboutEdge(knowledge entity to code node, with confidence and method)
Union types: Edge (all edge types), EdgeLabel (all edge labels)
Types for graph operations and visualization:
- Graph nodes:
GraphNodeand typed variants (FileGraphNode,FunctionGraphNode, etc.) - Graph edges:
GraphEdgewith source, target, label, and data - Graph data:
GraphData,SubgraphData - Statistics:
GraphStats(node/edge counts by type, largest files, most connected) - Search:
SearchResult(id, name, type, filePath, score) - Parse results:
ParseResult,ParseStats,ParsedFileEntities,FileError
Interfaces for language-specific parsing plugins:
LanguagePlugin-- main plugin interface (id, extensions, grammar, extractors)EntityExtractors-- combinesCoreExtractorsandOptionalExtractorsCoreExtractors-- required:extractFunctions,extractClasses,extractVariables,extractImportsOptionalExtractors-- optional:extractInterfaces,extractTypes,extractComponents,extractCalls,extractRenders,extractInheritanceSyntaxNode-- generic tree-sitter node interface- References:
CallReference,RenderReference,InheritanceReference - Registry:
PluginRegistration,RegisteredPlugin
Types for markdown/documentation indexing:
MarkdownDocumentEntity-- document with frontmatter, title, hashSectionEntity-- heading with level and line rangeCodeBlockEntity-- fenced code block with language and contentLinkEntity-- link with target, internal/external flag, anchorExtractedDocumentEntities-- all entities from a single document
Knowledge graph entity and relationship types with a guided open taxonomy:
- Type system:
EntityType,RelationshipType(open strings, not closed unions) - Preferred types:
CORE_ENTITY_TYPES,SE_ENTITY_TYPES,CORE_RELATIONSHIP_TYPES,SE_RELATIONSHIP_TYPES - Normalization:
normalizeEntityType(),normalizeRelationshipType()with synonym maps - Domain presets:
getPreferredEntityTypes(domain),getPreferredRelationshipTypes(domain) - Annotations:
EntityAnnotation,RelationshipAnnotation,Sample,AnnotatedSample