feat: update import statements to use TypeScript file extensions

This commit is contained in:
David Snelling 2025-05-29 08:27:59 -07:00
parent 61d86c98a7
commit 7d2b695ea0
10 changed files with 35 additions and 35 deletions

View file

@ -4,19 +4,19 @@
*/
import { v4 as uuidv4 } from 'uuid'
import { HNSWIndex } from './hnsw/hnswIndex.js'
import { createStorage } from './storage/opfsStorage.js'
import { HNSWIndex } from './hnsw/hnswIndex.ts'
import { createStorage } from './storage/opfsStorage.ts'
import {
DistanceFunction,
Edge,
EmbeddingFunction,
HNSWConfig,
HNSWConfig, HNSWNode,
SearchResult,
StorageAdapter,
Vector,
VectorDocument
} from './coreTypes.js'
import { cosineDistance, defaultEmbeddingFunction, euclideanDistance } from './utils/index.js'
} from './coreTypes.ts'
import { cosineDistance, defaultEmbeddingFunction, euclideanDistance } from './utils/index.ts'
export interface BrainyDataConfig {
/**
@ -94,7 +94,7 @@ export class BrainyData<T = any> {
await this.storage!.init()
// 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
this.index.clear()
@ -631,12 +631,12 @@ export class BrainyData<T = any> {
// Check if the storage adapter has a getStorageStatus method
if (typeof this.storage.getStorageStatus !== 'function') {
// 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 {
type: storageType || 'unknown',
used: 0,
quota: null,
details: {
details: {
error: 'Storage adapter does not implement getStorageStatus method',
storageAdapter: this.storage.constructor.name,
indexSize: this.size()
@ -666,13 +666,13 @@ export class BrainyData<T = any> {
console.error('Failed to get storage status:', error)
// 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 {
type: storageType || 'unknown',
used: 0,
quota: null,
details: {
details: {
error: String(error),
storageAdapter: this.storage.constructor.name,
indexSize: this.size()

View file

@ -2,7 +2,7 @@
* Basic usage example for the Soulcraft Brainy database
*/
import { BrainyData } from '../brainyData.js'
import { BrainyData } from '../brainyData.ts'
// Example data - word embeddings
const wordEmbeddings = {

View file

@ -3,8 +3,8 @@
* 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 { euclideanDistance } from '../utils/index.js'
import { DistanceFunction, HNSWConfig, HNSWNode, Vector, VectorDocument } from '../coreTypes.ts'
import { euclideanDistance } from '../utils/index.ts'
// Default HNSW parameters
const DEFAULT_CONFIG: HNSWConfig = {

View file

@ -4,7 +4,7 @@
*/
// Export main BrainyData class and related types
import { BrainyData, BrainyDataConfig } from './brainyData.js'
import { BrainyData, BrainyDataConfig } from './brainyData.ts'
export { BrainyData }
export type { BrainyDataConfig }
@ -14,7 +14,7 @@ import {
cosineDistance,
manhattanDistance,
dotProductDistance
} from './utils/index.js'
} from './utils/index.ts'
export {
euclideanDistance,
cosineDistance,
@ -30,7 +30,7 @@ import {
createTensorFlowEmbeddingFunction,
createSimpleEmbeddingFunction,
defaultEmbeddingFunction
} from './utils/embedding.js'
} from './utils/embedding.ts'
export {
SimpleEmbedding,
UniversalSentenceEncoder,
@ -45,7 +45,7 @@ import {
OPFSStorage,
MemoryStorage,
createStorage
} from './storage/opfsStorage.js'
} from './storage/opfsStorage.ts'
export {
OPFSStorage,
MemoryStorage,
@ -58,7 +58,7 @@ import {
augmentationPipeline,
ExecutionMode,
PipelineOptions
} from './augmentationPipeline.js'
} from './augmentationPipeline.ts'
export {
AugmentationPipeline,
augmentationPipeline,
@ -72,12 +72,12 @@ import {
configureAndStartPipeline,
createSensePluginConfig,
createConduitPluginConfig
} from './pluginLoader.js'
} from './pluginLoader.ts'
import type {
PluginLoaderOptions,
PluginConfig,
PluginLoadResult
} from './pluginLoader.js'
} from './pluginLoader.ts'
export {
loadPlugins,
configureAndStartPipeline,
@ -102,7 +102,7 @@ import type {
Edge,
HNSWConfig,
StorageAdapter
} from './coreTypes.js'
} from './coreTypes.ts'
export type {
Vector,
VectorDocument,
@ -128,8 +128,8 @@ import type {
IPerceptionAugmentation,
IDialogAugmentation,
IActivationAugmentation
} from './types/augmentations.js'
import { AugmentationType, BrainyAugmentations } from './types/augmentations.js'
} from './types/augmentations.ts'
import { AugmentationType, BrainyAugmentations } from './types/augmentations.ts'
export type {
IAugmentation,
AugmentationResponse,
@ -156,7 +156,7 @@ export type {
IWebSocketDialogAugmentation,
IWebSocketConduitAugmentation,
IWebSocketMemoryAugmentation
} from './types/augmentations.js'
} from './types/augmentations.ts'
// Export graph types
import type {
@ -169,8 +169,8 @@ import type {
Event,
Concept,
Content
} from './types/graphTypes.js'
import { NounType, VerbType } from './types/graphTypes.js'
} from './types/graphTypes.ts'
import { NounType, VerbType } from './types/graphTypes.ts'
export type {
GraphNoun,
GraphVerb,

View file

@ -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
let fs: any

View file

@ -3,7 +3,7 @@
* 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
const ROOT_DIR = 'opfs-vector-db'
@ -902,7 +902,7 @@ export async function createStorage(options: {
if (isNode) {
// In Node.js, use FileSystemStorage first, then fall back to memory
try {
const fileSystemModule = await import('./fileSystemStorage.js')
const fileSystemModule = await import('./fileSystemStorage.ts')
return new fileSystemModule.FileSystemStorage()
} catch (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 to load FileSystemStorage for browser environments
// 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()
} catch (error) {
console.warn('FileSystem storage is not available, falling back to in-memory storage')

View file

@ -2,7 +2,7 @@
* 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

View file

@ -2,7 +2,7 @@
* 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

View file

@ -1,2 +1,2 @@
export * from './distance.js'
export * from './embedding.js'
export * from './distance.ts'
export * from './embedding.ts'

View file

@ -14,7 +14,7 @@
],
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"allowImportingTsExtensions": false,
"allowImportingTsExtensions": true,
"noEmit": false,
"preserveConstEnums": true,
"sourceMap": true