**refactor: adjust export formatting for consistency and alignment**
- Reformatted export statements across `index.ts` and related modules for consistent style, improving code readability and maintainability. - Updated graph types in `graphTypes.ts` to include additional standardized noun and verb categories, enhancing the flexibility of the type system for graph modeling. - Replaced `Place` with `Location` and merged similar types (e.g., `Group` into `Collection`) to eliminate redundancy in entity definitions. - Expanded verb types in `VerbType` to cover more comprehensive use cases, including social, temporal, and ownership relationships. **Purpose**: Streamline code structure with consistent export formatting, simplify type definitions, and enhance the type system for broader modeling capabilities.
This commit is contained in:
parent
79df44351c
commit
d70d0946cf
2 changed files with 601 additions and 274 deletions
528
src/index.ts
528
src/index.ts
|
|
@ -13,228 +13,228 @@
|
|||
import './setup.js'
|
||||
|
||||
// Export main BrainyData class and related types
|
||||
import {BrainyData, BrainyDataConfig} from './brainyData.js'
|
||||
import { BrainyData, BrainyDataConfig } from './brainyData.js'
|
||||
|
||||
export {BrainyData}
|
||||
export type {BrainyDataConfig}
|
||||
export { BrainyData }
|
||||
export type { BrainyDataConfig }
|
||||
|
||||
// Export distance functions for convenience
|
||||
import {
|
||||
euclideanDistance,
|
||||
cosineDistance,
|
||||
manhattanDistance,
|
||||
dotProductDistance,
|
||||
getStatistics
|
||||
euclideanDistance,
|
||||
cosineDistance,
|
||||
manhattanDistance,
|
||||
dotProductDistance,
|
||||
getStatistics
|
||||
} from './utils/index.js'
|
||||
|
||||
export {
|
||||
euclideanDistance,
|
||||
cosineDistance,
|
||||
manhattanDistance,
|
||||
dotProductDistance,
|
||||
getStatistics
|
||||
euclideanDistance,
|
||||
cosineDistance,
|
||||
manhattanDistance,
|
||||
dotProductDistance,
|
||||
getStatistics
|
||||
}
|
||||
|
||||
// Export embedding functionality
|
||||
import {
|
||||
UniversalSentenceEncoder,
|
||||
createEmbeddingFunction,
|
||||
createTensorFlowEmbeddingFunction,
|
||||
createThreadedEmbeddingFunction,
|
||||
defaultEmbeddingFunction
|
||||
UniversalSentenceEncoder,
|
||||
createEmbeddingFunction,
|
||||
createTensorFlowEmbeddingFunction,
|
||||
createThreadedEmbeddingFunction,
|
||||
defaultEmbeddingFunction
|
||||
} from './utils/embedding.js'
|
||||
|
||||
// Export worker utilities
|
||||
import {executeInThread, cleanupWorkerPools} from './utils/workerUtils.js'
|
||||
import { executeInThread, cleanupWorkerPools } from './utils/workerUtils.js'
|
||||
|
||||
// Export environment utilities
|
||||
import {
|
||||
isBrowser,
|
||||
isNode,
|
||||
isWebWorker,
|
||||
areWebWorkersAvailable,
|
||||
areWorkerThreadsAvailable,
|
||||
areWorkerThreadsAvailableSync,
|
||||
isThreadingAvailable,
|
||||
isThreadingAvailableAsync
|
||||
isBrowser,
|
||||
isNode,
|
||||
isWebWorker,
|
||||
areWebWorkersAvailable,
|
||||
areWorkerThreadsAvailable,
|
||||
areWorkerThreadsAvailableSync,
|
||||
isThreadingAvailable,
|
||||
isThreadingAvailableAsync
|
||||
} from './utils/environment.js'
|
||||
|
||||
export {
|
||||
UniversalSentenceEncoder,
|
||||
createEmbeddingFunction,
|
||||
createTensorFlowEmbeddingFunction,
|
||||
createThreadedEmbeddingFunction,
|
||||
defaultEmbeddingFunction,
|
||||
UniversalSentenceEncoder,
|
||||
createEmbeddingFunction,
|
||||
createTensorFlowEmbeddingFunction,
|
||||
createThreadedEmbeddingFunction,
|
||||
defaultEmbeddingFunction,
|
||||
|
||||
// Worker utilities
|
||||
executeInThread,
|
||||
cleanupWorkerPools,
|
||||
// Worker utilities
|
||||
executeInThread,
|
||||
cleanupWorkerPools,
|
||||
|
||||
// Environment utilities
|
||||
isBrowser,
|
||||
isNode,
|
||||
isWebWorker,
|
||||
areWebWorkersAvailable,
|
||||
areWorkerThreadsAvailable,
|
||||
areWorkerThreadsAvailableSync,
|
||||
isThreadingAvailable,
|
||||
isThreadingAvailableAsync
|
||||
// Environment utilities
|
||||
isBrowser,
|
||||
isNode,
|
||||
isWebWorker,
|
||||
areWebWorkersAvailable,
|
||||
areWorkerThreadsAvailable,
|
||||
areWorkerThreadsAvailableSync,
|
||||
isThreadingAvailable,
|
||||
isThreadingAvailableAsync
|
||||
}
|
||||
|
||||
// Export storage adapters
|
||||
import {
|
||||
OPFSStorage,
|
||||
MemoryStorage,
|
||||
FileSystemStorage,
|
||||
R2Storage,
|
||||
S3CompatibleStorage,
|
||||
createStorage
|
||||
OPFSStorage,
|
||||
MemoryStorage,
|
||||
FileSystemStorage,
|
||||
R2Storage,
|
||||
S3CompatibleStorage,
|
||||
createStorage
|
||||
} from './storage/storageFactory.js'
|
||||
|
||||
export {
|
||||
OPFSStorage,
|
||||
MemoryStorage,
|
||||
FileSystemStorage,
|
||||
R2Storage,
|
||||
S3CompatibleStorage,
|
||||
createStorage
|
||||
OPFSStorage,
|
||||
MemoryStorage,
|
||||
FileSystemStorage,
|
||||
R2Storage,
|
||||
S3CompatibleStorage,
|
||||
createStorage
|
||||
}
|
||||
|
||||
// Export unified pipeline
|
||||
import {
|
||||
Pipeline,
|
||||
pipeline,
|
||||
augmentationPipeline,
|
||||
ExecutionMode,
|
||||
PipelineOptions,
|
||||
PipelineResult,
|
||||
executeStreamlined,
|
||||
executeByType,
|
||||
executeSingle,
|
||||
processStaticData,
|
||||
processStreamingData,
|
||||
createPipeline,
|
||||
createStreamingPipeline,
|
||||
StreamlinedExecutionMode,
|
||||
StreamlinedPipelineOptions,
|
||||
StreamlinedPipelineResult
|
||||
Pipeline,
|
||||
pipeline,
|
||||
augmentationPipeline,
|
||||
ExecutionMode,
|
||||
PipelineOptions,
|
||||
PipelineResult,
|
||||
executeStreamlined,
|
||||
executeByType,
|
||||
executeSingle,
|
||||
processStaticData,
|
||||
processStreamingData,
|
||||
createPipeline,
|
||||
createStreamingPipeline,
|
||||
StreamlinedExecutionMode,
|
||||
StreamlinedPipelineOptions,
|
||||
StreamlinedPipelineResult
|
||||
} from './pipeline.js'
|
||||
|
||||
// Export sequential pipeline (for backward compatibility)
|
||||
import {
|
||||
SequentialPipeline,
|
||||
sequentialPipeline,
|
||||
SequentialPipelineOptions
|
||||
SequentialPipeline,
|
||||
sequentialPipeline,
|
||||
SequentialPipelineOptions
|
||||
} from './sequentialPipeline.js'
|
||||
|
||||
// Export augmentation factory
|
||||
import {
|
||||
createSenseAugmentation,
|
||||
addWebSocketSupport,
|
||||
executeAugmentation,
|
||||
loadAugmentationModule,
|
||||
AugmentationOptions
|
||||
createSenseAugmentation,
|
||||
addWebSocketSupport,
|
||||
executeAugmentation,
|
||||
loadAugmentationModule,
|
||||
AugmentationOptions
|
||||
} from './augmentationFactory.js'
|
||||
|
||||
export {
|
||||
// Unified pipeline exports
|
||||
Pipeline,
|
||||
pipeline,
|
||||
augmentationPipeline,
|
||||
ExecutionMode,
|
||||
SequentialPipeline,
|
||||
sequentialPipeline,
|
||||
// Unified pipeline exports
|
||||
Pipeline,
|
||||
pipeline,
|
||||
augmentationPipeline,
|
||||
ExecutionMode,
|
||||
SequentialPipeline,
|
||||
sequentialPipeline,
|
||||
|
||||
// Streamlined pipeline exports (now part of unified pipeline)
|
||||
executeStreamlined,
|
||||
executeByType,
|
||||
executeSingle,
|
||||
processStaticData,
|
||||
processStreamingData,
|
||||
createPipeline,
|
||||
createStreamingPipeline,
|
||||
StreamlinedExecutionMode,
|
||||
// Streamlined pipeline exports (now part of unified pipeline)
|
||||
executeStreamlined,
|
||||
executeByType,
|
||||
executeSingle,
|
||||
processStaticData,
|
||||
processStreamingData,
|
||||
createPipeline,
|
||||
createStreamingPipeline,
|
||||
StreamlinedExecutionMode,
|
||||
|
||||
// Augmentation factory exports
|
||||
createSenseAugmentation,
|
||||
addWebSocketSupport,
|
||||
executeAugmentation,
|
||||
loadAugmentationModule
|
||||
// Augmentation factory exports
|
||||
createSenseAugmentation,
|
||||
addWebSocketSupport,
|
||||
executeAugmentation,
|
||||
loadAugmentationModule
|
||||
}
|
||||
export type {
|
||||
PipelineOptions,
|
||||
PipelineResult,
|
||||
SequentialPipelineOptions,
|
||||
StreamlinedPipelineOptions,
|
||||
StreamlinedPipelineResult,
|
||||
AugmentationOptions
|
||||
PipelineOptions,
|
||||
PipelineResult,
|
||||
SequentialPipelineOptions,
|
||||
StreamlinedPipelineOptions,
|
||||
StreamlinedPipelineResult,
|
||||
AugmentationOptions
|
||||
}
|
||||
|
||||
// Export augmentation registry for build-time loading
|
||||
import {
|
||||
availableAugmentations,
|
||||
registerAugmentation,
|
||||
initializeAugmentationPipeline,
|
||||
setAugmentationEnabled,
|
||||
getAugmentationsByType
|
||||
availableAugmentations,
|
||||
registerAugmentation,
|
||||
initializeAugmentationPipeline,
|
||||
setAugmentationEnabled,
|
||||
getAugmentationsByType
|
||||
} from './augmentationRegistry.js'
|
||||
|
||||
export {
|
||||
availableAugmentations,
|
||||
registerAugmentation,
|
||||
initializeAugmentationPipeline,
|
||||
setAugmentationEnabled,
|
||||
getAugmentationsByType
|
||||
availableAugmentations,
|
||||
registerAugmentation,
|
||||
initializeAugmentationPipeline,
|
||||
setAugmentationEnabled,
|
||||
getAugmentationsByType
|
||||
}
|
||||
|
||||
// Export augmentation registry loader for build tools
|
||||
import {
|
||||
loadAugmentationsFromModules,
|
||||
createAugmentationRegistryPlugin,
|
||||
createAugmentationRegistryRollupPlugin
|
||||
loadAugmentationsFromModules,
|
||||
createAugmentationRegistryPlugin,
|
||||
createAugmentationRegistryRollupPlugin
|
||||
} from './augmentationRegistryLoader.js'
|
||||
import type {
|
||||
AugmentationRegistryLoaderOptions,
|
||||
AugmentationLoadResult
|
||||
AugmentationRegistryLoaderOptions,
|
||||
AugmentationLoadResult
|
||||
} from './augmentationRegistryLoader.js'
|
||||
|
||||
export {
|
||||
loadAugmentationsFromModules,
|
||||
createAugmentationRegistryPlugin,
|
||||
createAugmentationRegistryRollupPlugin
|
||||
loadAugmentationsFromModules,
|
||||
createAugmentationRegistryPlugin,
|
||||
createAugmentationRegistryRollupPlugin
|
||||
}
|
||||
export type {AugmentationRegistryLoaderOptions, AugmentationLoadResult}
|
||||
export type { AugmentationRegistryLoaderOptions, AugmentationLoadResult }
|
||||
|
||||
// Export augmentation implementations
|
||||
import {
|
||||
MemoryStorageAugmentation,
|
||||
FileSystemStorageAugmentation,
|
||||
OPFSStorageAugmentation,
|
||||
createMemoryAugmentation
|
||||
MemoryStorageAugmentation,
|
||||
FileSystemStorageAugmentation,
|
||||
OPFSStorageAugmentation,
|
||||
createMemoryAugmentation
|
||||
} from './augmentations/memoryAugmentations.js'
|
||||
import {
|
||||
WebSocketConduitAugmentation,
|
||||
WebRTCConduitAugmentation,
|
||||
createConduitAugmentation
|
||||
WebSocketConduitAugmentation,
|
||||
WebRTCConduitAugmentation,
|
||||
createConduitAugmentation
|
||||
} from './augmentations/conduitAugmentations.js'
|
||||
import {
|
||||
ServerSearchConduitAugmentation,
|
||||
ServerSearchActivationAugmentation,
|
||||
createServerSearchAugmentations
|
||||
ServerSearchConduitAugmentation,
|
||||
ServerSearchActivationAugmentation,
|
||||
createServerSearchAugmentations
|
||||
} from './augmentations/serverSearchAugmentations.js'
|
||||
|
||||
// Non-LLM exports
|
||||
export {
|
||||
MemoryStorageAugmentation,
|
||||
FileSystemStorageAugmentation,
|
||||
OPFSStorageAugmentation,
|
||||
createMemoryAugmentation,
|
||||
WebSocketConduitAugmentation,
|
||||
WebRTCConduitAugmentation,
|
||||
createConduitAugmentation,
|
||||
ServerSearchConduitAugmentation,
|
||||
ServerSearchActivationAugmentation,
|
||||
createServerSearchAugmentations
|
||||
MemoryStorageAugmentation,
|
||||
FileSystemStorageAugmentation,
|
||||
OPFSStorageAugmentation,
|
||||
createMemoryAugmentation,
|
||||
WebSocketConduitAugmentation,
|
||||
WebRTCConduitAugmentation,
|
||||
createConduitAugmentation,
|
||||
ServerSearchConduitAugmentation,
|
||||
ServerSearchActivationAugmentation,
|
||||
createServerSearchAugmentations
|
||||
}
|
||||
|
||||
// LLM augmentations are optional and not imported by default
|
||||
|
|
@ -243,142 +243,180 @@ export {
|
|||
|
||||
// Export types
|
||||
import type {
|
||||
Vector,
|
||||
VectorDocument,
|
||||
SearchResult,
|
||||
DistanceFunction,
|
||||
EmbeddingFunction,
|
||||
EmbeddingModel,
|
||||
HNSWNoun,
|
||||
GraphVerb,
|
||||
HNSWConfig,
|
||||
StorageAdapter
|
||||
Vector,
|
||||
VectorDocument,
|
||||
SearchResult,
|
||||
DistanceFunction,
|
||||
EmbeddingFunction,
|
||||
EmbeddingModel,
|
||||
HNSWNoun,
|
||||
HNSWConfig,
|
||||
StorageAdapter
|
||||
} from './coreTypes.js'
|
||||
|
||||
// Export HNSW index and optimized version
|
||||
import {HNSWIndex} from './hnsw/hnswIndex.js'
|
||||
import { HNSWIndex } from './hnsw/hnswIndex.js'
|
||||
import {
|
||||
HNSWIndexOptimized,
|
||||
HNSWOptimizedConfig
|
||||
HNSWIndexOptimized,
|
||||
HNSWOptimizedConfig
|
||||
} from './hnsw/hnswIndexOptimized.js'
|
||||
|
||||
export {HNSWIndex, HNSWIndexOptimized}
|
||||
export { HNSWIndex, HNSWIndexOptimized }
|
||||
|
||||
export type {
|
||||
Vector,
|
||||
VectorDocument,
|
||||
SearchResult,
|
||||
DistanceFunction,
|
||||
EmbeddingFunction,
|
||||
EmbeddingModel,
|
||||
HNSWNoun,
|
||||
GraphVerb,
|
||||
HNSWConfig,
|
||||
HNSWOptimizedConfig,
|
||||
StorageAdapter
|
||||
Vector,
|
||||
VectorDocument,
|
||||
SearchResult,
|
||||
DistanceFunction,
|
||||
EmbeddingFunction,
|
||||
EmbeddingModel,
|
||||
HNSWNoun,
|
||||
HNSWConfig,
|
||||
HNSWOptimizedConfig,
|
||||
StorageAdapter
|
||||
}
|
||||
|
||||
// Export augmentation types
|
||||
import type {
|
||||
IAugmentation,
|
||||
AugmentationResponse,
|
||||
IWebSocketSupport,
|
||||
ISenseAugmentation,
|
||||
IConduitAugmentation,
|
||||
ICognitionAugmentation,
|
||||
IMemoryAugmentation,
|
||||
IPerceptionAugmentation,
|
||||
IDialogAugmentation,
|
||||
IActivationAugmentation
|
||||
IAugmentation,
|
||||
AugmentationResponse,
|
||||
IWebSocketSupport,
|
||||
ISenseAugmentation,
|
||||
IConduitAugmentation,
|
||||
ICognitionAugmentation,
|
||||
IMemoryAugmentation,
|
||||
IPerceptionAugmentation,
|
||||
IDialogAugmentation,
|
||||
IActivationAugmentation
|
||||
} from './types/augmentations.js'
|
||||
import {AugmentationType, BrainyAugmentations} from './types/augmentations.js'
|
||||
import { AugmentationType, BrainyAugmentations } from './types/augmentations.js'
|
||||
|
||||
export type {IAugmentation, AugmentationResponse, IWebSocketSupport}
|
||||
export type { IAugmentation, AugmentationResponse, IWebSocketSupport }
|
||||
export {
|
||||
AugmentationType,
|
||||
BrainyAugmentations,
|
||||
ISenseAugmentation,
|
||||
IConduitAugmentation,
|
||||
ICognitionAugmentation,
|
||||
IMemoryAugmentation,
|
||||
IPerceptionAugmentation,
|
||||
IDialogAugmentation,
|
||||
IActivationAugmentation
|
||||
AugmentationType,
|
||||
BrainyAugmentations,
|
||||
ISenseAugmentation,
|
||||
IConduitAugmentation,
|
||||
ICognitionAugmentation,
|
||||
IMemoryAugmentation,
|
||||
IPerceptionAugmentation,
|
||||
IDialogAugmentation,
|
||||
IActivationAugmentation
|
||||
}
|
||||
|
||||
// Export combined WebSocket augmentation interfaces
|
||||
export type {
|
||||
IWebSocketCognitionAugmentation,
|
||||
IWebSocketSenseAugmentation,
|
||||
IWebSocketPerceptionAugmentation,
|
||||
IWebSocketActivationAugmentation,
|
||||
IWebSocketDialogAugmentation,
|
||||
IWebSocketConduitAugmentation,
|
||||
IWebSocketMemoryAugmentation
|
||||
IWebSocketCognitionAugmentation,
|
||||
IWebSocketSenseAugmentation,
|
||||
IWebSocketPerceptionAugmentation,
|
||||
IWebSocketActivationAugmentation,
|
||||
IWebSocketDialogAugmentation,
|
||||
IWebSocketConduitAugmentation,
|
||||
IWebSocketMemoryAugmentation
|
||||
} from './types/augmentations.js'
|
||||
|
||||
// Export graph types
|
||||
import type {
|
||||
GraphNoun,
|
||||
EmbeddedGraphVerb,
|
||||
Person,
|
||||
Place,
|
||||
Thing,
|
||||
Event,
|
||||
Concept,
|
||||
Content
|
||||
GraphNoun,
|
||||
GraphVerb,
|
||||
EmbeddedGraphVerb,
|
||||
Person,
|
||||
Location,
|
||||
Thing,
|
||||
Event,
|
||||
Concept,
|
||||
Content,
|
||||
Collection,
|
||||
Organization,
|
||||
Document,
|
||||
Media,
|
||||
File,
|
||||
Message,
|
||||
Dataset,
|
||||
Product,
|
||||
Service,
|
||||
User,
|
||||
Task,
|
||||
Project,
|
||||
Process,
|
||||
State,
|
||||
Role,
|
||||
Topic,
|
||||
Language,
|
||||
Currency,
|
||||
Measurement
|
||||
} from './types/graphTypes.js'
|
||||
import {NounType, VerbType} from './types/graphTypes.js'
|
||||
import { NounType, VerbType } from './types/graphTypes.js'
|
||||
|
||||
export type {
|
||||
GraphNoun,
|
||||
EmbeddedGraphVerb,
|
||||
Person,
|
||||
Place,
|
||||
Thing,
|
||||
Event,
|
||||
Concept,
|
||||
Content
|
||||
GraphNoun,
|
||||
GraphVerb,
|
||||
EmbeddedGraphVerb,
|
||||
Person,
|
||||
Location,
|
||||
Thing,
|
||||
Event,
|
||||
Concept,
|
||||
Content,
|
||||
Collection,
|
||||
Organization,
|
||||
Document,
|
||||
Media,
|
||||
File,
|
||||
Message,
|
||||
Dataset,
|
||||
Product,
|
||||
Service,
|
||||
User,
|
||||
Task,
|
||||
Project,
|
||||
Process,
|
||||
State,
|
||||
Role,
|
||||
Topic,
|
||||
Language,
|
||||
Currency,
|
||||
Measurement
|
||||
}
|
||||
export {NounType, VerbType}
|
||||
export { NounType, VerbType }
|
||||
|
||||
// Export MCP (Model Control Protocol) components
|
||||
import {
|
||||
BrainyMCPAdapter,
|
||||
MCPAugmentationToolset,
|
||||
BrainyMCPService
|
||||
BrainyMCPAdapter,
|
||||
MCPAugmentationToolset,
|
||||
BrainyMCPService
|
||||
} from './mcp/index.js' // Import from mcp/index.js
|
||||
import {
|
||||
MCPRequest,
|
||||
MCPResponse,
|
||||
MCPDataAccessRequest,
|
||||
MCPToolExecutionRequest,
|
||||
MCPSystemInfoRequest,
|
||||
MCPAuthenticationRequest,
|
||||
MCPRequestType,
|
||||
MCPServiceOptions,
|
||||
MCPTool,
|
||||
MCP_VERSION
|
||||
MCPRequest,
|
||||
MCPResponse,
|
||||
MCPDataAccessRequest,
|
||||
MCPToolExecutionRequest,
|
||||
MCPSystemInfoRequest,
|
||||
MCPAuthenticationRequest,
|
||||
MCPRequestType,
|
||||
MCPServiceOptions,
|
||||
MCPTool,
|
||||
MCP_VERSION
|
||||
} from './types/mcpTypes.js'
|
||||
|
||||
export {
|
||||
// MCP classes
|
||||
BrainyMCPAdapter,
|
||||
MCPAugmentationToolset,
|
||||
BrainyMCPService,
|
||||
// MCP classes
|
||||
BrainyMCPAdapter,
|
||||
MCPAugmentationToolset,
|
||||
BrainyMCPService,
|
||||
|
||||
// MCP types
|
||||
MCPRequestType,
|
||||
MCP_VERSION
|
||||
// MCP types
|
||||
MCPRequestType,
|
||||
MCP_VERSION
|
||||
}
|
||||
|
||||
export type {
|
||||
MCPRequest,
|
||||
MCPResponse,
|
||||
MCPDataAccessRequest,
|
||||
MCPToolExecutionRequest,
|
||||
MCPSystemInfoRequest,
|
||||
MCPAuthenticationRequest,
|
||||
MCPServiceOptions,
|
||||
MCPTool
|
||||
MCPRequest,
|
||||
MCPResponse,
|
||||
MCPDataAccessRequest,
|
||||
MCPToolExecutionRequest,
|
||||
MCPSystemInfoRequest,
|
||||
MCPAuthenticationRequest,
|
||||
MCPServiceOptions,
|
||||
MCPTool
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,166 @@
|
|||
/**
|
||||
* Graph Types - Standardized Noun and Verb Type System
|
||||
*
|
||||
* This module defines a comprehensive, standardized set of noun and verb types
|
||||
* that can be used to model any kind of graph, semantic network, or data model.
|
||||
*
|
||||
* ## Purpose and Design Philosophy
|
||||
*
|
||||
* The type system is designed to be:
|
||||
* - **Universal**: Capable of representing any domain or use case
|
||||
* - **Hierarchical**: Organized into logical categories for easy navigation
|
||||
* - **Extensible**: Additional metadata can be attached to any entity or relationship
|
||||
* - **Semantic**: Types carry meaning that can be used for reasoning and inference
|
||||
*
|
||||
* ## Noun Types (Entities)
|
||||
*
|
||||
* Noun types represent entities in the graph and are organized into categories:
|
||||
*
|
||||
* ### Core Entity Types
|
||||
* - **Person**: Human entities and individuals
|
||||
* - **Organization**: Formal organizations, companies, institutions
|
||||
* - **Location**: Geographic locations, places, addresses
|
||||
* - **Thing**: Physical objects and tangible items
|
||||
* - **Concept**: Abstract ideas, concepts, and intangible entities
|
||||
* - **Event**: Occurrences with time and place dimensions
|
||||
*
|
||||
* ### Digital/Content Types
|
||||
* - **Document**: Text-based files and documents
|
||||
* - **Media**: Non-text media files (images, videos, audio)
|
||||
* - **File**: Generic digital files
|
||||
* - **Message**: Communication content
|
||||
* - **Content**: Generic content that doesn't fit other categories
|
||||
*
|
||||
* ### Collection Types
|
||||
* - **Collection**: Generic groupings of items
|
||||
* - **Dataset**: Structured collections of data
|
||||
*
|
||||
* ### Business/Application Types
|
||||
* - **Product**: Commercial products and offerings
|
||||
* - **Service**: Services and offerings
|
||||
* - **User**: User accounts and profiles
|
||||
* - **Task**: Actions, todos, and workflow items
|
||||
* - **Project**: Organized initiatives with goals and timelines
|
||||
*
|
||||
* ### Descriptive Types
|
||||
* - **Process**: Workflows, procedures, and sequences
|
||||
* - **State**: States, conditions, or statuses
|
||||
* - **Role**: Roles, positions, or responsibilities
|
||||
* - **Topic**: Subjects or themes
|
||||
* - **Language**: Languages or linguistic entities
|
||||
* - **Currency**: Currencies and monetary units
|
||||
* - **Measurement**: Measurements, metrics, or quantities
|
||||
*
|
||||
* ## Verb Types (Relationships)
|
||||
*
|
||||
* Verb types represent relationships between entities and are organized into categories:
|
||||
*
|
||||
* ### Core Relationship Types
|
||||
* - **RelatedTo**: Generic relationship (default fallback)
|
||||
* - **Contains**: Containment relationship
|
||||
* - **PartOf**: Part-whole relationship
|
||||
* - **LocatedAt**: Spatial relationship
|
||||
* - **References**: Reference or citation relationship
|
||||
*
|
||||
* ### Temporal/Causal Types
|
||||
* - **Precedes/Succeeds**: Temporal sequence relationships
|
||||
* - **Causes**: Causal relationships
|
||||
* - **DependsOn**: Dependency relationships
|
||||
* - **Requires**: Necessity relationships
|
||||
*
|
||||
* ### Creation/Transformation Types
|
||||
* - **Creates**: Creation relationships
|
||||
* - **Transforms**: Transformation relationships
|
||||
* - **Becomes**: State change relationships
|
||||
* - **Modifies**: Modification relationships
|
||||
* - **Consumes**: Consumption relationships
|
||||
*
|
||||
* ### Ownership/Attribution Types
|
||||
* - **Owns**: Ownership relationships
|
||||
* - **AttributedTo**: Attribution or authorship
|
||||
* - **CreatedBy**: Creation attribution
|
||||
* - **BelongsTo**: Belonging relationships
|
||||
*
|
||||
* ### Social/Organizational Types
|
||||
* - **MemberOf**: Membership or affiliation
|
||||
* - **WorksWith**: Professional relationships
|
||||
* - **FriendOf**: Friendship relationships
|
||||
* - **Follows**: Following relationships
|
||||
* - **Likes**: Liking relationships
|
||||
* - **ReportsTo**: Reporting relationships
|
||||
* - **Supervises**: Supervisory relationships
|
||||
* - **Mentors**: Mentorship relationships
|
||||
* - **Communicates**: Communication relationships
|
||||
*
|
||||
* ### Descriptive/Functional Types
|
||||
* - **Describes**: Descriptive relationships
|
||||
* - **Defines**: Definition relationships
|
||||
* - **Categorizes**: Categorization relationships
|
||||
* - **Measures**: Measurement relationships
|
||||
* - **Evaluates**: Evaluation or assessment relationships
|
||||
* - **Uses**: Utilization relationships
|
||||
* - **Implements**: Implementation relationships
|
||||
* - **Extends**: Extension relationships
|
||||
*
|
||||
* ## Usage with Additional Metadata
|
||||
*
|
||||
* While the type system provides a standardized vocabulary, additional metadata
|
||||
* can be attached to any entity or relationship to capture domain-specific
|
||||
* information:
|
||||
*
|
||||
* ```typescript
|
||||
* const person: GraphNoun = {
|
||||
* id: 'person-123',
|
||||
* noun: NounType.Person,
|
||||
* data: {
|
||||
* name: 'John Doe',
|
||||
* age: 30,
|
||||
* profession: 'Engineer'
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const worksFor: GraphVerb = {
|
||||
* id: 'verb-456',
|
||||
* source: 'person-123',
|
||||
* target: 'org-789',
|
||||
* verb: VerbType.MemberOf,
|
||||
* data: {
|
||||
* role: 'Senior Engineer',
|
||||
* startDate: '2020-01-01',
|
||||
* department: 'Engineering'
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* ## Modeling Different Graph Types
|
||||
*
|
||||
* This type system can model various graph structures:
|
||||
*
|
||||
* ### Knowledge Graphs
|
||||
* Use Person, Organization, Location, Concept entities with semantic relationships
|
||||
* like AttributedTo, LocatedAt, RelatedTo
|
||||
*
|
||||
* ### Social Networks
|
||||
* Use Person, User entities with social relationships like FriendOf, Follows,
|
||||
* WorksWith, Communicates
|
||||
*
|
||||
* ### Content Networks
|
||||
* Use Document, Media, Content entities with relationships like References,
|
||||
* CreatedBy, Contains, Categorizes
|
||||
*
|
||||
* ### Business Process Models
|
||||
* Use Task, Process, Role entities with relationships like Precedes, Requires,
|
||||
* DependsOn, Transforms
|
||||
*
|
||||
* ### Organizational Charts
|
||||
* Use Person, Role, Organization entities with relationships like ReportsTo,
|
||||
* Supervises, MemberOf
|
||||
*
|
||||
* The flexibility of this system allows it to represent any domain while
|
||||
* maintaining semantic consistency and enabling powerful graph operations
|
||||
* and reasoning capabilities.
|
||||
*/
|
||||
|
||||
// Common metadata types
|
||||
/**
|
||||
* Represents a high-precision timestamp with seconds and nanoseconds
|
||||
|
|
@ -70,8 +233,8 @@ export interface Person extends GraphNoun {
|
|||
/**
|
||||
* Represents a physical location in the graph
|
||||
*/
|
||||
export interface Place extends GraphNoun {
|
||||
noun: typeof NounType.Place
|
||||
export interface Location extends GraphNoun {
|
||||
noun: typeof NounType.Location
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -95,12 +258,80 @@ export interface Concept extends GraphNoun {
|
|||
noun: typeof NounType.Concept
|
||||
}
|
||||
|
||||
export interface Group extends GraphNoun {
|
||||
noun: typeof NounType.Group
|
||||
export interface Collection extends GraphNoun {
|
||||
noun: typeof NounType.Collection
|
||||
}
|
||||
|
||||
export interface List extends GraphNoun {
|
||||
noun: typeof NounType.List
|
||||
export interface Organization extends GraphNoun {
|
||||
noun: typeof NounType.Organization
|
||||
}
|
||||
|
||||
export interface Document extends GraphNoun {
|
||||
noun: typeof NounType.Document
|
||||
}
|
||||
|
||||
export interface Media extends GraphNoun {
|
||||
noun: typeof NounType.Media
|
||||
}
|
||||
|
||||
export interface File extends GraphNoun {
|
||||
noun: typeof NounType.File
|
||||
}
|
||||
|
||||
export interface Message extends GraphNoun {
|
||||
noun: typeof NounType.Message
|
||||
}
|
||||
|
||||
export interface Dataset extends GraphNoun {
|
||||
noun: typeof NounType.Dataset
|
||||
}
|
||||
|
||||
export interface Product extends GraphNoun {
|
||||
noun: typeof NounType.Product
|
||||
}
|
||||
|
||||
export interface Service extends GraphNoun {
|
||||
noun: typeof NounType.Service
|
||||
}
|
||||
|
||||
export interface User extends GraphNoun {
|
||||
noun: typeof NounType.User
|
||||
}
|
||||
|
||||
export interface Task extends GraphNoun {
|
||||
noun: typeof NounType.Task
|
||||
}
|
||||
|
||||
export interface Project extends GraphNoun {
|
||||
noun: typeof NounType.Project
|
||||
}
|
||||
|
||||
export interface Process extends GraphNoun {
|
||||
noun: typeof NounType.Process
|
||||
}
|
||||
|
||||
export interface State extends GraphNoun {
|
||||
noun: typeof NounType.State
|
||||
}
|
||||
|
||||
export interface Role extends GraphNoun {
|
||||
noun: typeof NounType.Role
|
||||
}
|
||||
|
||||
export interface Topic extends GraphNoun {
|
||||
noun: typeof NounType.Topic
|
||||
}
|
||||
|
||||
export interface Language extends GraphNoun {
|
||||
noun: typeof NounType.Language
|
||||
}
|
||||
|
||||
export interface Currency extends GraphNoun {
|
||||
noun: typeof NounType.Currency
|
||||
}
|
||||
|
||||
export interface Measurement extends GraphNoun {
|
||||
noun: typeof NounType.Measurement
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -116,15 +347,40 @@ export interface Content extends GraphNoun {
|
|||
*/
|
||||
|
||||
export const NounType = {
|
||||
Person: 'person', // Person entities
|
||||
Place: 'place', // Physical locations
|
||||
Thing: 'thing', // Physical or virtual objects
|
||||
Event: 'event', // Events or occurrences
|
||||
Concept: 'concept', // Abstract concepts or ideas
|
||||
Content: 'content', // Content items
|
||||
Group: 'group', // Groups of related entities
|
||||
List: 'list', // Ordered collections of entities
|
||||
Category: 'category' // Categories for content items including tags
|
||||
// Core Entity Types
|
||||
Person: 'person', // Human entities
|
||||
Organization: 'organization', // Formal organizations (companies, institutions, etc.)
|
||||
Location: 'location', // Geographic locations (merges previous Place and Location)
|
||||
Thing: 'thing', // Physical objects
|
||||
Concept: 'concept', // Abstract ideas, concepts, and intangible entities
|
||||
Event: 'event', // Occurrences with time and place
|
||||
|
||||
// Digital/Content Types
|
||||
Document: 'document', // Text-based files and documents (reports, articles, etc.)
|
||||
Media: 'media', // Non-text media files (images, videos, audio)
|
||||
File: 'file', // Generic digital files (merges aspects of Digital with file-specific focus)
|
||||
Message: 'message', // Communication content (emails, chat messages, posts)
|
||||
Content: 'content', // Generic content that doesn't fit other categories
|
||||
|
||||
// Collection Types
|
||||
Collection: 'collection', // Generic grouping of items (merges Group, List, and Category)
|
||||
Dataset: 'dataset', // Structured collections of data
|
||||
|
||||
// Business/Application Types
|
||||
Product: 'product', // Commercial products and offerings
|
||||
Service: 'service', // Services and offerings
|
||||
User: 'user', // User accounts and profiles
|
||||
Task: 'task', // Actions, todos, and workflow items
|
||||
Project: 'project', // Organized initiatives with goals and timelines
|
||||
|
||||
// Descriptive Types
|
||||
Process: 'process', // Workflows, procedures, and sequences
|
||||
State: 'state', // States, conditions, or statuses
|
||||
Role: 'role', // Roles, positions, or responsibilities
|
||||
Topic: 'topic', // Subjects or themes
|
||||
Language: 'language', // Languages or linguistic entities
|
||||
Currency: 'currency', // Currencies and monetary units
|
||||
Measurement: 'measurement' // Measurements, metrics, or quantities
|
||||
} as const
|
||||
export type NounType = (typeof NounType)[keyof typeof NounType]
|
||||
|
||||
|
|
@ -133,19 +389,52 @@ export type NounType = (typeof NounType)[keyof typeof NounType]
|
|||
* Used for categorizing different types of connections
|
||||
*/
|
||||
export const VerbType = {
|
||||
AttributedTo: 'attributedTo', // Indicates attribution or authorship
|
||||
Controls: 'controls', // Indicates control or ownership
|
||||
Created: 'created', // Indicates creation or authorship
|
||||
Earned: 'earned', // Indicates achievement or acquisition
|
||||
Owns: 'owns', // Indicates ownership
|
||||
MemberOf: 'memberOf', // Indicates membership or affiliation
|
||||
RelatedTo: 'relatedTo', // Indicates family relationship
|
||||
WorksWith: 'worksWith', // Indicates professional relationship
|
||||
FriendOf: 'friendOf', // Indicates friendship
|
||||
ReportsTo: 'reportsTo', // Indicates reporting relationship
|
||||
Supervises: 'supervises', // Indicates supervisory relationship
|
||||
Mentors: 'mentors', // Indicates mentorship relationship
|
||||
Follows: 'follows', // Indicates the following relationship
|
||||
Likes: 'likes' // Indicates liking relationship
|
||||
// Core Relationship Types
|
||||
RelatedTo: 'relatedTo', // Generic relationship (default fallback)
|
||||
Contains: 'contains', // Containment relationship (parent contains child)
|
||||
PartOf: 'partOf', // Part-whole relationship (child is part of parent)
|
||||
LocatedAt: 'locatedAt', // Spatial relationship
|
||||
References: 'references', // Reference or citation relationship
|
||||
|
||||
// Temporal/Causal Types
|
||||
Precedes: 'precedes', // Temporal sequence (comes before)
|
||||
Succeeds: 'succeeds', // Temporal sequence (comes after)
|
||||
Causes: 'causes', // Causal relationship (merges Influences and Causes)
|
||||
DependsOn: 'dependsOn', // Dependency relationship
|
||||
Requires: 'requires', // Necessity relationship (new)
|
||||
|
||||
// Creation/Transformation Types
|
||||
Creates: 'creates', // Creation relationship (merges Created and Produces)
|
||||
Transforms: 'transforms', // Transformation relationship
|
||||
Becomes: 'becomes', // State change relationship
|
||||
Modifies: 'modifies', // Modification relationship
|
||||
Consumes: 'consumes', // Consumption relationship
|
||||
|
||||
// Ownership/Attribution Types
|
||||
Owns: 'owns', // Ownership relationship (merges Controls and Owns)
|
||||
AttributedTo: 'attributedTo', // Attribution or authorship
|
||||
CreatedBy: 'createdBy', // Creation attribution (new, distinct from Creates)
|
||||
BelongsTo: 'belongsTo', // Belonging relationship (new)
|
||||
|
||||
// Social/Organizational Types
|
||||
MemberOf: 'memberOf', // Membership or affiliation
|
||||
WorksWith: 'worksWith', // Professional relationship
|
||||
FriendOf: 'friendOf', // Friendship relationship
|
||||
Follows: 'follows', // Following relationship
|
||||
Likes: 'likes', // Liking relationship
|
||||
ReportsTo: 'reportsTo', // Reporting relationship
|
||||
Supervises: 'supervises', // Supervisory relationship
|
||||
Mentors: 'mentors', // Mentorship relationship
|
||||
Communicates: 'communicates', // Communication relationship (merges Communicates and Collaborates)
|
||||
|
||||
// Descriptive/Functional Types
|
||||
Describes: 'describes', // Descriptive relationship
|
||||
Defines: 'defines', // Definition relationship
|
||||
Categorizes: 'categorizes', // Categorization relationship
|
||||
Measures: 'measures', // Measurement relationship
|
||||
Evaluates: 'evaluates', // Evaluation or assessment relationship
|
||||
Uses: 'uses', // Utilization relationship (new)
|
||||
Implements: 'implements', // Implementation relationship
|
||||
Extends: 'extends' // Extension relationship (merges Extends and Inherits)
|
||||
} as const
|
||||
export type VerbType = (typeof VerbType)[keyof typeof VerbType]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue