feat: update import statements to use TypeScript file extensions
This commit is contained in:
parent
61d86c98a7
commit
7d2b695ea0
10 changed files with 35 additions and 35 deletions
|
|
@ -4,19 +4,19 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { HNSWIndex } from './hnsw/hnswIndex.js'
|
import { HNSWIndex } from './hnsw/hnswIndex.ts'
|
||||||
import { createStorage } from './storage/opfsStorage.js'
|
import { createStorage } from './storage/opfsStorage.ts'
|
||||||
import {
|
import {
|
||||||
DistanceFunction,
|
DistanceFunction,
|
||||||
Edge,
|
Edge,
|
||||||
EmbeddingFunction,
|
EmbeddingFunction,
|
||||||
HNSWConfig,
|
HNSWConfig, HNSWNode,
|
||||||
SearchResult,
|
SearchResult,
|
||||||
StorageAdapter,
|
StorageAdapter,
|
||||||
Vector,
|
Vector,
|
||||||
VectorDocument
|
VectorDocument
|
||||||
} from './coreTypes.js'
|
} from './coreTypes.ts'
|
||||||
import { cosineDistance, defaultEmbeddingFunction, euclideanDistance } from './utils/index.js'
|
import { cosineDistance, defaultEmbeddingFunction, euclideanDistance } from './utils/index.ts'
|
||||||
|
|
||||||
export interface BrainyDataConfig {
|
export interface BrainyDataConfig {
|
||||||
/**
|
/**
|
||||||
|
|
@ -94,7 +94,7 @@ export class BrainyData<T = any> {
|
||||||
await this.storage!.init()
|
await this.storage!.init()
|
||||||
|
|
||||||
// Load all nodes from storage
|
// Load all nodes from storage
|
||||||
const nodes = await this.storage!.getAllNodes()
|
const nodes: HNSWNode[] = await this.storage!.getAllNodes()
|
||||||
|
|
||||||
// Clear the index and add all nodes
|
// Clear the index and add all nodes
|
||||||
this.index.clear()
|
this.index.clear()
|
||||||
|
|
@ -631,7 +631,7 @@ export class BrainyData<T = any> {
|
||||||
// Check if the storage adapter has a getStorageStatus method
|
// Check if the storage adapter has a getStorageStatus method
|
||||||
if (typeof this.storage.getStorageStatus !== 'function') {
|
if (typeof this.storage.getStorageStatus !== 'function') {
|
||||||
// If not, determine the storage type based on the constructor name
|
// If not, determine the storage type based on the constructor name
|
||||||
const storageType = this.storage.constructor.name.toLowerCase().replace('storage', '');
|
const storageType = this.storage.constructor.name.toLowerCase().replace('storage', '')
|
||||||
return {
|
return {
|
||||||
type: storageType || 'unknown',
|
type: storageType || 'unknown',
|
||||||
used: 0,
|
used: 0,
|
||||||
|
|
@ -666,7 +666,7 @@ export class BrainyData<T = any> {
|
||||||
console.error('Failed to get storage status:', error)
|
console.error('Failed to get storage status:', error)
|
||||||
|
|
||||||
// Determine the storage type based on the constructor name
|
// Determine the storage type based on the constructor name
|
||||||
const storageType = this.storage.constructor.name.toLowerCase().replace('storage', '');
|
const storageType = this.storage.constructor.name.toLowerCase().replace('storage', '')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: storageType || 'unknown',
|
type: storageType || 'unknown',
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* Basic usage example for the Soulcraft Brainy database
|
* Basic usage example for the Soulcraft Brainy database
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BrainyData } from '../brainyData.js'
|
import { BrainyData } from '../brainyData.ts'
|
||||||
|
|
||||||
// Example data - word embeddings
|
// Example data - word embeddings
|
||||||
const wordEmbeddings = {
|
const wordEmbeddings = {
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* Based on the paper: "Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs"
|
* Based on the paper: "Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DistanceFunction, HNSWConfig, HNSWNode, Vector, VectorDocument } from '../coreTypes.js'
|
import { DistanceFunction, HNSWConfig, HNSWNode, Vector, VectorDocument } from '../coreTypes.ts'
|
||||||
import { euclideanDistance } from '../utils/index.js'
|
import { euclideanDistance } from '../utils/index.ts'
|
||||||
|
|
||||||
// Default HNSW parameters
|
// Default HNSW parameters
|
||||||
const DEFAULT_CONFIG: HNSWConfig = {
|
const DEFAULT_CONFIG: HNSWConfig = {
|
||||||
|
|
|
||||||
26
src/index.ts
26
src/index.ts
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Export main BrainyData class and related types
|
// Export main BrainyData class and related types
|
||||||
import { BrainyData, BrainyDataConfig } from './brainyData.js'
|
import { BrainyData, BrainyDataConfig } from './brainyData.ts'
|
||||||
export { BrainyData }
|
export { BrainyData }
|
||||||
export type { BrainyDataConfig }
|
export type { BrainyDataConfig }
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ import {
|
||||||
cosineDistance,
|
cosineDistance,
|
||||||
manhattanDistance,
|
manhattanDistance,
|
||||||
dotProductDistance
|
dotProductDistance
|
||||||
} from './utils/index.js'
|
} from './utils/index.ts'
|
||||||
export {
|
export {
|
||||||
euclideanDistance,
|
euclideanDistance,
|
||||||
cosineDistance,
|
cosineDistance,
|
||||||
|
|
@ -30,7 +30,7 @@ import {
|
||||||
createTensorFlowEmbeddingFunction,
|
createTensorFlowEmbeddingFunction,
|
||||||
createSimpleEmbeddingFunction,
|
createSimpleEmbeddingFunction,
|
||||||
defaultEmbeddingFunction
|
defaultEmbeddingFunction
|
||||||
} from './utils/embedding.js'
|
} from './utils/embedding.ts'
|
||||||
export {
|
export {
|
||||||
SimpleEmbedding,
|
SimpleEmbedding,
|
||||||
UniversalSentenceEncoder,
|
UniversalSentenceEncoder,
|
||||||
|
|
@ -45,7 +45,7 @@ import {
|
||||||
OPFSStorage,
|
OPFSStorage,
|
||||||
MemoryStorage,
|
MemoryStorage,
|
||||||
createStorage
|
createStorage
|
||||||
} from './storage/opfsStorage.js'
|
} from './storage/opfsStorage.ts'
|
||||||
export {
|
export {
|
||||||
OPFSStorage,
|
OPFSStorage,
|
||||||
MemoryStorage,
|
MemoryStorage,
|
||||||
|
|
@ -58,7 +58,7 @@ import {
|
||||||
augmentationPipeline,
|
augmentationPipeline,
|
||||||
ExecutionMode,
|
ExecutionMode,
|
||||||
PipelineOptions
|
PipelineOptions
|
||||||
} from './augmentationPipeline.js'
|
} from './augmentationPipeline.ts'
|
||||||
export {
|
export {
|
||||||
AugmentationPipeline,
|
AugmentationPipeline,
|
||||||
augmentationPipeline,
|
augmentationPipeline,
|
||||||
|
|
@ -72,12 +72,12 @@ import {
|
||||||
configureAndStartPipeline,
|
configureAndStartPipeline,
|
||||||
createSensePluginConfig,
|
createSensePluginConfig,
|
||||||
createConduitPluginConfig
|
createConduitPluginConfig
|
||||||
} from './pluginLoader.js'
|
} from './pluginLoader.ts'
|
||||||
import type {
|
import type {
|
||||||
PluginLoaderOptions,
|
PluginLoaderOptions,
|
||||||
PluginConfig,
|
PluginConfig,
|
||||||
PluginLoadResult
|
PluginLoadResult
|
||||||
} from './pluginLoader.js'
|
} from './pluginLoader.ts'
|
||||||
export {
|
export {
|
||||||
loadPlugins,
|
loadPlugins,
|
||||||
configureAndStartPipeline,
|
configureAndStartPipeline,
|
||||||
|
|
@ -102,7 +102,7 @@ import type {
|
||||||
Edge,
|
Edge,
|
||||||
HNSWConfig,
|
HNSWConfig,
|
||||||
StorageAdapter
|
StorageAdapter
|
||||||
} from './coreTypes.js'
|
} from './coreTypes.ts'
|
||||||
export type {
|
export type {
|
||||||
Vector,
|
Vector,
|
||||||
VectorDocument,
|
VectorDocument,
|
||||||
|
|
@ -128,8 +128,8 @@ import type {
|
||||||
IPerceptionAugmentation,
|
IPerceptionAugmentation,
|
||||||
IDialogAugmentation,
|
IDialogAugmentation,
|
||||||
IActivationAugmentation
|
IActivationAugmentation
|
||||||
} from './types/augmentations.js'
|
} from './types/augmentations.ts'
|
||||||
import { AugmentationType, BrainyAugmentations } from './types/augmentations.js'
|
import { AugmentationType, BrainyAugmentations } from './types/augmentations.ts'
|
||||||
export type {
|
export type {
|
||||||
IAugmentation,
|
IAugmentation,
|
||||||
AugmentationResponse,
|
AugmentationResponse,
|
||||||
|
|
@ -156,7 +156,7 @@ export type {
|
||||||
IWebSocketDialogAugmentation,
|
IWebSocketDialogAugmentation,
|
||||||
IWebSocketConduitAugmentation,
|
IWebSocketConduitAugmentation,
|
||||||
IWebSocketMemoryAugmentation
|
IWebSocketMemoryAugmentation
|
||||||
} from './types/augmentations.js'
|
} from './types/augmentations.ts'
|
||||||
|
|
||||||
// Export graph types
|
// Export graph types
|
||||||
import type {
|
import type {
|
||||||
|
|
@ -169,8 +169,8 @@ import type {
|
||||||
Event,
|
Event,
|
||||||
Concept,
|
Concept,
|
||||||
Content
|
Content
|
||||||
} from './types/graphTypes.js'
|
} from './types/graphTypes.ts'
|
||||||
import { NounType, VerbType } from './types/graphTypes.js'
|
import { NounType, VerbType } from './types/graphTypes.ts'
|
||||||
export type {
|
export type {
|
||||||
GraphNoun,
|
GraphNoun,
|
||||||
GraphVerb,
|
GraphVerb,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Edge, HNSWNode, StorageAdapter } from '../coreTypes.js'
|
import { Edge, HNSWNode, StorageAdapter } from '../coreTypes.ts'
|
||||||
|
|
||||||
// We'll dynamically import Node.js built-in modules
|
// We'll dynamically import Node.js built-in modules
|
||||||
let fs: any
|
let fs: any
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* Provides persistent storage for the vector database using the Origin Private File System API
|
* Provides persistent storage for the vector database using the Origin Private File System API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Edge, HNSWNode, StorageAdapter } from '../coreTypes.js'
|
import { Edge, HNSWNode, StorageAdapter } from '../coreTypes.ts'
|
||||||
|
|
||||||
// Directory and file names
|
// Directory and file names
|
||||||
const ROOT_DIR = 'opfs-vector-db'
|
const ROOT_DIR = 'opfs-vector-db'
|
||||||
|
|
@ -902,7 +902,7 @@ export async function createStorage(options: {
|
||||||
if (isNode) {
|
if (isNode) {
|
||||||
// In Node.js, use FileSystemStorage first, then fall back to memory
|
// In Node.js, use FileSystemStorage first, then fall back to memory
|
||||||
try {
|
try {
|
||||||
const fileSystemModule = await import('./fileSystemStorage.js')
|
const fileSystemModule = await import('./fileSystemStorage.ts')
|
||||||
return new fileSystemModule.FileSystemStorage()
|
return new fileSystemModule.FileSystemStorage()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Failed to load FileSystemStorage, falling back to in-memory storage:', error)
|
console.warn('Failed to load FileSystemStorage, falling back to in-memory storage:', error)
|
||||||
|
|
@ -928,7 +928,7 @@ export async function createStorage(options: {
|
||||||
try {
|
try {
|
||||||
// Try to load FileSystemStorage for browser environments
|
// Try to load FileSystemStorage for browser environments
|
||||||
// Note: This will likely fail as FileSystemStorage is designed for Node.js
|
// Note: This will likely fail as FileSystemStorage is designed for Node.js
|
||||||
const fileSystemModule = await import('./fileSystemStorage.js')
|
const fileSystemModule = await import('./fileSystemStorage.ts')
|
||||||
return new fileSystemModule.FileSystemStorage()
|
return new fileSystemModule.FileSystemStorage()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('FileSystem storage is not available, falling back to in-memory storage')
|
console.warn('FileSystem storage is not available, falling back to in-memory storage')
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* Distance functions for vector similarity calculations
|
* Distance functions for vector similarity calculations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DistanceFunction, Vector } from '../coreTypes.js'
|
import { DistanceFunction, Vector } from '../coreTypes.ts'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the Euclidean distance between two vectors
|
* Calculates the Euclidean distance between two vectors
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* Embedding functions for converting data to vectors
|
* Embedding functions for converting data to vectors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EmbeddingFunction, EmbeddingModel, Vector } from '../coreTypes.js'
|
import { EmbeddingFunction, EmbeddingModel, Vector } from '../coreTypes.ts'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple character-based embedding function
|
* Simple character-based embedding function
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
export * from './distance.js'
|
export * from './distance.ts'
|
||||||
export * from './embedding.js'
|
export * from './embedding.ts'
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
],
|
],
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"allowImportingTsExtensions": false,
|
"allowImportingTsExtensions": true,
|
||||||
"noEmit": false,
|
"noEmit": false,
|
||||||
"preserveConstEnums": true,
|
"preserveConstEnums": true,
|
||||||
"sourceMap": true
|
"sourceMap": true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue