chore: remove Firestore-related implementations and example files
Deleted all Firestore augmentation, storage, sync implementations, and related type definitions. Removed the FirestoreSync example file as part of the cleanup for disabled Firestore functionality.
This commit is contained in:
parent
40dd046884
commit
18bbe6d428
9 changed files with 64 additions and 2179 deletions
|
|
@ -1,248 +0,0 @@
|
|||
/**
|
||||
* Example: Using the FirestoreSync Conduit Augmentation
|
||||
*
|
||||
* This example demonstrates how to use the FirestoreSync augmentation
|
||||
* to sync data between Brainy and Firestore in both one-way and two-way modes.
|
||||
*
|
||||
* Prerequisites:
|
||||
* 1. Install Firebase: npm install firebase
|
||||
* 2. Set up a Firebase project and enable Firestore
|
||||
* 3. Get your Firebase configuration from the Firebase console
|
||||
*/
|
||||
|
||||
import {
|
||||
registerAugmentation,
|
||||
initializeAugmentationPipeline,
|
||||
BrainyGraph
|
||||
} from '../dist/index.js'
|
||||
|
||||
import {
|
||||
createFirestoreSyncAugmentation,
|
||||
FirestoreSyncConfig
|
||||
} from '../dist/augmentations/firestoreSyncAugmentation.js'
|
||||
|
||||
// Your Firebase configuration
|
||||
// Replace with your actual Firebase project configuration
|
||||
const firebaseConfig = {
|
||||
apiKey: 'your-api-key',
|
||||
authDomain: 'your-project-id.firebaseapp.com',
|
||||
projectId: 'your-project-id',
|
||||
storageBucket: 'your-project-id.appspot.com',
|
||||
messagingSenderId: 'your-messaging-sender-id',
|
||||
appId: 'your-app-id'
|
||||
}
|
||||
|
||||
// Example 1: One-way sync (Brainy -> Firestore)
|
||||
async function setupOneWaySync() {
|
||||
console.log('Setting up one-way sync from Brainy to Firestore...')
|
||||
|
||||
// Create the FirestoreSync augmentation with one-way sync configuration
|
||||
const oneWaySyncConfig = {
|
||||
firebaseConfig,
|
||||
nodesCollection: 'brainy_nodes',
|
||||
edgesCollection: 'brainy_edges',
|
||||
metadataCollection: 'brainy_metadata',
|
||||
syncMode: 'one-way'
|
||||
}
|
||||
|
||||
// Create and register the augmentation
|
||||
const oneWaySync = createFirestoreSyncAugmentation(
|
||||
'brainy-firestore-one-way-sync',
|
||||
oneWaySyncConfig
|
||||
)
|
||||
|
||||
registerAugmentation(oneWaySync)
|
||||
|
||||
// Initialize the augmentation pipeline
|
||||
initializeAugmentationPipeline()
|
||||
|
||||
// Initialize the augmentation
|
||||
await oneWaySync.initialize()
|
||||
|
||||
console.log('One-way sync augmentation initialized successfully')
|
||||
|
||||
return oneWaySync
|
||||
}
|
||||
|
||||
// Example 2: Two-way sync (Bidirectional between Brainy and Firestore)
|
||||
async function setupTwoWaySync() {
|
||||
console.log('Setting up two-way sync between Brainy and Firestore...')
|
||||
|
||||
// Create the FirestoreSync augmentation with two-way sync configuration
|
||||
const twoWaySyncConfig = {
|
||||
firebaseConfig,
|
||||
nodesCollection: 'brainy_nodes',
|
||||
edgesCollection: 'brainy_edges',
|
||||
metadataCollection: 'brainy_metadata',
|
||||
syncMode: 'two-way',
|
||||
syncInterval: 30000 // Sync every 30 seconds
|
||||
}
|
||||
|
||||
// Create and register the augmentation
|
||||
const twoWaySync = createFirestoreSyncAugmentation(
|
||||
'brainy-firestore-two-way-sync',
|
||||
twoWaySyncConfig
|
||||
)
|
||||
|
||||
registerAugmentation(twoWaySync)
|
||||
|
||||
// Initialize the augmentation pipeline
|
||||
initializeAugmentationPipeline()
|
||||
|
||||
// Initialize the augmentation
|
||||
await twoWaySync.initialize()
|
||||
|
||||
console.log('Two-way sync augmentation initialized successfully')
|
||||
|
||||
return twoWaySync
|
||||
}
|
||||
|
||||
// Example 3: Using the FirestoreSync augmentation with a Brainy graph
|
||||
async function syncGraphToFirestore() {
|
||||
console.log('Creating a Brainy graph and syncing it to Firestore...')
|
||||
|
||||
// Set up the one-way sync augmentation
|
||||
const syncAugmentation = await setupOneWaySync()
|
||||
|
||||
// Create a Brainy graph
|
||||
const graph = new BrainyGraph()
|
||||
await graph.initialize()
|
||||
|
||||
// Add some nodes and edges to the graph
|
||||
const node1 = await graph.addNode({
|
||||
vector: [0.1, 0.2, 0.3],
|
||||
metadata: { name: 'Node 1', description: 'First test node' }
|
||||
})
|
||||
|
||||
const node2 = await graph.addNode({
|
||||
vector: [0.4, 0.5, 0.6],
|
||||
metadata: { name: 'Node 2', description: 'Second test node' }
|
||||
})
|
||||
|
||||
const edge = await graph.addEdge({
|
||||
sourceId: node1.id,
|
||||
targetId: node2.id,
|
||||
type: 'related',
|
||||
weight: 0.75,
|
||||
metadata: { description: 'Test relationship' }
|
||||
})
|
||||
|
||||
// Sync the nodes and edge to Firestore
|
||||
await syncAugmentation.syncNodeToFirestore(node1)
|
||||
await syncAugmentation.syncNodeToFirestore(node2)
|
||||
await syncAugmentation.syncEdgeToFirestore(edge)
|
||||
|
||||
console.log('Graph data synced to Firestore successfully')
|
||||
|
||||
// Clean up
|
||||
await syncAugmentation.shutDown()
|
||||
await graph.close()
|
||||
}
|
||||
|
||||
// Example 4: Reading data from Firestore
|
||||
async function readFromFirestore() {
|
||||
console.log('Reading data from Firestore...')
|
||||
|
||||
// Set up the one-way sync augmentation
|
||||
const syncAugmentation = await setupOneWaySync()
|
||||
|
||||
// Read all nodes from Firestore
|
||||
const nodesResponse = await syncAugmentation.readData({
|
||||
collection: 'brainy_nodes'
|
||||
})
|
||||
|
||||
if (nodesResponse.success) {
|
||||
console.log(`Found ${nodesResponse.data.length} nodes in Firestore`)
|
||||
console.log('First node:', nodesResponse.data[0])
|
||||
} else {
|
||||
console.error('Failed to read nodes:', nodesResponse.error)
|
||||
}
|
||||
|
||||
// Read a specific edge by ID
|
||||
const edgeResponse = await syncAugmentation.readData({
|
||||
collection: 'brainy_edges',
|
||||
id: 'some-edge-id' // Replace with an actual edge ID
|
||||
})
|
||||
|
||||
if (edgeResponse.success) {
|
||||
console.log('Edge data:', edgeResponse.data)
|
||||
} else {
|
||||
console.error('Failed to read edge:', edgeResponse.error)
|
||||
}
|
||||
|
||||
// Clean up
|
||||
await syncAugmentation.shutDown()
|
||||
}
|
||||
|
||||
// Example 5: Writing data to Firestore
|
||||
async function writeToFirestore() {
|
||||
console.log('Writing data to Firestore...')
|
||||
|
||||
// Set up the one-way sync augmentation
|
||||
const syncAugmentation = await setupOneWaySync()
|
||||
|
||||
// Write a custom document to Firestore
|
||||
const writeResponse = await syncAugmentation.writeData({
|
||||
collection: 'custom_collection',
|
||||
id: 'custom-doc-1',
|
||||
document: {
|
||||
name: 'Custom Document',
|
||||
timestamp: new Date(),
|
||||
values: [1, 2, 3, 4, 5],
|
||||
nested: {
|
||||
field1: 'value1',
|
||||
field2: 'value2'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (writeResponse.success) {
|
||||
console.log('Document written successfully:', writeResponse.data)
|
||||
} else {
|
||||
console.error('Failed to write document:', writeResponse.error)
|
||||
}
|
||||
|
||||
// Clean up
|
||||
await syncAugmentation.shutDown()
|
||||
}
|
||||
|
||||
// Example 6: Monitoring changes in Firestore
|
||||
async function monitorFirestore() {
|
||||
console.log('Monitoring changes in Firestore...')
|
||||
|
||||
// Set up the two-way sync augmentation
|
||||
const syncAugmentation = await setupTwoWaySync()
|
||||
|
||||
// Monitor changes in the nodes collection
|
||||
await syncAugmentation.monitorStream('brainy_nodes', (data) => {
|
||||
console.log('Node change detected:', data)
|
||||
})
|
||||
|
||||
console.log('Monitoring started. Changes will be logged as they occur.')
|
||||
console.log('Press Ctrl+C to stop monitoring.')
|
||||
|
||||
// Keep the process running
|
||||
// In a real application, you would integrate this with your application lifecycle
|
||||
process.on('SIGINT', async () => {
|
||||
console.log('Stopping monitoring...')
|
||||
await syncAugmentation.shutDown()
|
||||
process.exit(0)
|
||||
})
|
||||
}
|
||||
|
||||
// Run the examples
|
||||
async function runExamples() {
|
||||
try {
|
||||
// Uncomment the example you want to run
|
||||
// await syncGraphToFirestore();
|
||||
// await readFromFirestore();
|
||||
// await writeToFirestore();
|
||||
// await monitorFirestore();
|
||||
|
||||
console.log('Example completed successfully')
|
||||
} catch (error) {
|
||||
console.error('Error running example:', error)
|
||||
}
|
||||
}
|
||||
|
||||
runExamples()
|
||||
|
|
@ -7,15 +7,12 @@
|
|||
* The example shows:
|
||||
* 1. Using the default memory augmentation (auto-selected based on environment)
|
||||
* 2. Using specific storage types (Memory, FileSystem, OPFS)
|
||||
* 3. Using Firestore storage
|
||||
*/
|
||||
|
||||
import {
|
||||
registerAugmentation,
|
||||
initializeAugmentationPipeline,
|
||||
createMemoryAugmentation,
|
||||
createFirestoreStorageAugmentation,
|
||||
FirestoreStorageConfig
|
||||
createMemoryAugmentation
|
||||
} from '../dist/index.js'
|
||||
|
||||
// Example 1: Using the default memory augmentation
|
||||
|
|
@ -126,66 +123,6 @@ async function useOPFSStorage() {
|
|||
}
|
||||
}
|
||||
|
||||
// Example 5: Using Firestore storage
|
||||
async function useFirestoreStorage() {
|
||||
console.log('Setting up Firestore storage...')
|
||||
|
||||
// Your Firebase configuration
|
||||
// Replace with your actual Firebase project configuration
|
||||
const firebaseConfig = {
|
||||
projectId: 'your-project-id',
|
||||
collection: 'brainy_data',
|
||||
// Optional: provide credentials, databaseURL, appName
|
||||
}
|
||||
|
||||
try {
|
||||
// Method 1: Using createMemoryAugmentation with 'firestore' storage type
|
||||
const memoryAug = await createMemoryAugmentation('brainy-firestore-storage', {
|
||||
storageType: 'firestore',
|
||||
firestoreConfig: firebaseConfig
|
||||
})
|
||||
|
||||
// Register the augmentation
|
||||
registerAugmentation(memoryAug)
|
||||
|
||||
// Initialize the augmentation
|
||||
await memoryAug.initialize()
|
||||
|
||||
console.log('Firestore storage initialized successfully')
|
||||
|
||||
// Store some data
|
||||
await storeAndRetrieveData(memoryAug)
|
||||
|
||||
return memoryAug
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize Firestore storage:', error)
|
||||
console.log('This might be because Firebase is not properly configured or installed')
|
||||
|
||||
// Method 2: Using createFirestoreStorageAugmentation directly
|
||||
console.log('Trying alternative method...')
|
||||
|
||||
try {
|
||||
const firestoreStorage = createFirestoreStorageAugmentation(
|
||||
'firestore-storage-direct',
|
||||
firebaseConfig
|
||||
)
|
||||
|
||||
registerAugmentation(firestoreStorage)
|
||||
await firestoreStorage.initialize()
|
||||
|
||||
console.log('Firestore storage initialized successfully (direct method)')
|
||||
|
||||
// Store some data
|
||||
await storeAndRetrieveData(firestoreStorage)
|
||||
|
||||
return firestoreStorage
|
||||
} catch (directError) {
|
||||
console.error('Failed to initialize Firestore storage (direct method):', directError)
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to store and retrieve data
|
||||
async function storeAndRetrieveData(memoryAug) {
|
||||
console.log('Storing and retrieving data...')
|
||||
|
|
@ -322,12 +259,6 @@ async function runExamples() {
|
|||
await opfsStorage.shutDown()
|
||||
}
|
||||
|
||||
// Example 5: Firestore storage
|
||||
const firestoreStorage = await useFirestoreStorage()
|
||||
if (firestoreStorage) {
|
||||
await firestoreStorage.shutDown()
|
||||
}
|
||||
|
||||
console.log('All examples completed')
|
||||
}
|
||||
|
||||
|
|
|
|||
950
package-lock.json
generated
950
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,389 +0,0 @@
|
|||
import {
|
||||
AugmentationType,
|
||||
IMemoryAugmentation,
|
||||
AugmentationResponse
|
||||
} from '../types/augmentations.js'
|
||||
import { Vector } from '../coreTypes.js'
|
||||
import { cosineDistance } from '../utils/distance.js'
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase imports
|
||||
// import { initializeApp, getApp } from 'firebase/app'
|
||||
// import {
|
||||
// getFirestore,
|
||||
// collection,
|
||||
// doc,
|
||||
// setDoc,
|
||||
// getDoc,
|
||||
// updateDoc,
|
||||
// deleteDoc,
|
||||
// query,
|
||||
// getDocs,
|
||||
// limit
|
||||
// } from 'firebase/firestore'
|
||||
// import { findNearest } from '@firebase/firestore-vector-search'
|
||||
|
||||
/**
|
||||
* Configuration for Firestore storage augmentation
|
||||
*/
|
||||
export interface FirestoreStorageConfig {
|
||||
/**
|
||||
* Firestore project ID
|
||||
*/
|
||||
projectId: string
|
||||
|
||||
/**
|
||||
* Firestore collection name for storing data
|
||||
*/
|
||||
collection: string
|
||||
|
||||
/**
|
||||
* Optional Firestore credentials
|
||||
*/
|
||||
credentials?: any
|
||||
|
||||
/**
|
||||
* Optional Firestore database URL
|
||||
*/
|
||||
databaseURL?: string
|
||||
|
||||
/**
|
||||
* Optional Firestore app name
|
||||
*/
|
||||
appName?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Storage augmentation that uses Firestore for storage
|
||||
*/
|
||||
export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
||||
readonly name: string
|
||||
readonly description: string = 'Storage augmentation that stores data in Firestore'
|
||||
enabled: boolean = true
|
||||
private config: FirestoreStorageConfig
|
||||
private isInitialized = false
|
||||
private firestore: any = null
|
||||
private collection: any = null
|
||||
|
||||
constructor(name: string, config: FirestoreStorageConfig) {
|
||||
this.name = name
|
||||
this.config = config
|
||||
}
|
||||
|
||||
getType(): AugmentationType {
|
||||
return AugmentationType.MEMORY
|
||||
}
|
||||
|
||||
async initialize(): Promise<void> {
|
||||
if (this.isInitialized) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// TEMPORARILY COMMENTED OUT: Firebase initialization
|
||||
/*
|
||||
// Initialize Firebase if not already initialized
|
||||
let app
|
||||
try {
|
||||
app = getApp(this.config.appName || '[DEFAULT]')
|
||||
} catch (e) {
|
||||
// App doesn't exist, initialize it
|
||||
// Create a config object with the required properties
|
||||
const firebaseConfig: any = {
|
||||
projectId: this.config.projectId
|
||||
}
|
||||
|
||||
// Add optional properties if they exist
|
||||
if (this.config.databaseURL) {
|
||||
firebaseConfig.databaseURL = this.config.databaseURL
|
||||
}
|
||||
|
||||
// Add credentials if they exist
|
||||
if (this.config.credentials) {
|
||||
// Use credentials as part of the config object
|
||||
// instead of as a 'credential' property
|
||||
Object.assign(firebaseConfig, this.config.credentials)
|
||||
}
|
||||
|
||||
app = initializeApp(firebaseConfig, this.config.appName)
|
||||
}
|
||||
|
||||
// Get Firestore instance
|
||||
this.firestore = getFirestore(app)
|
||||
this.collection = collection(this.firestore, this.config.collection)
|
||||
*/
|
||||
|
||||
console.log(`FirestoreStorageAugmentation '${this.name}' initialization temporarily disabled`)
|
||||
this.isInitialized = true
|
||||
} catch (error) {
|
||||
console.error(`Failed to initialize FirestoreStorageAugmentation:`, error)
|
||||
throw new Error(`Failed to initialize FirestoreStorageAugmentation: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
async shutDown(): Promise<void> {
|
||||
this.isInitialized = false
|
||||
this.firestore = null
|
||||
this.collection = null
|
||||
}
|
||||
|
||||
async getStatus(): Promise<'active' | 'inactive' | 'error'> {
|
||||
if (!this.isInitialized) {
|
||||
return 'inactive'
|
||||
}
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase status check
|
||||
/*
|
||||
try {
|
||||
// Try a simple operation to check if Firestore is working
|
||||
await getDocs(query(collection(this.firestore, '__test__'), limit(1)))
|
||||
return 'active'
|
||||
} catch (error) {
|
||||
console.error('Firestore connection error:', error)
|
||||
return 'error'
|
||||
}
|
||||
*/
|
||||
|
||||
console.log('Firebase status check temporarily disabled')
|
||||
return 'inactive'
|
||||
}
|
||||
|
||||
async storeData(
|
||||
key: string,
|
||||
data: unknown,
|
||||
options?: Record<string, unknown>
|
||||
): Promise<AugmentationResponse<boolean>> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase store operation
|
||||
/*
|
||||
try {
|
||||
await setDoc(doc(this.collection, key), this.prepareForFirestore(data))
|
||||
return { success: true, data: true }
|
||||
} catch (error) {
|
||||
console.error(`Failed to store data for key ${key}:`, error)
|
||||
return {
|
||||
success: false,
|
||||
data: false,
|
||||
error: `Failed to store data: ${error}`
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
console.log(`Firebase store operation temporarily disabled for key: ${key}`)
|
||||
return {
|
||||
success: false,
|
||||
data: false,
|
||||
error: 'Firebase functionality temporarily disabled'
|
||||
}
|
||||
}
|
||||
|
||||
async retrieveData(
|
||||
key: string,
|
||||
options?: Record<string, unknown>
|
||||
): Promise<AugmentationResponse<unknown>> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase retrieve operation
|
||||
/*
|
||||
try {
|
||||
const docSnapshot = await getDoc(doc(this.collection, key))
|
||||
|
||||
if (!docSnapshot.exists()) {
|
||||
return {
|
||||
success: true,
|
||||
data: null
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: docSnapshot.data()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to retrieve data for key ${key}:`, error)
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
error: `Failed to retrieve data: ${error}`
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
console.log(`Firebase retrieve operation temporarily disabled for key: ${key}`)
|
||||
return {
|
||||
success: false,
|
||||
data: null,
|
||||
error: 'Firebase functionality temporarily disabled'
|
||||
}
|
||||
}
|
||||
|
||||
async updateData(
|
||||
key: string,
|
||||
data: unknown,
|
||||
options?: Record<string, unknown>
|
||||
): Promise<AugmentationResponse<boolean>> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase update operation
|
||||
/*
|
||||
try {
|
||||
await updateDoc(doc(this.collection, key), this.prepareForFirestore(data))
|
||||
return { success: true, data: true }
|
||||
} catch (error) {
|
||||
console.error(`Failed to update data for key ${key}:`, error)
|
||||
return {
|
||||
success: false,
|
||||
data: false,
|
||||
error: `Failed to update data: ${error}`
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
console.log(`Firebase update operation temporarily disabled for key: ${key}`)
|
||||
return {
|
||||
success: false,
|
||||
data: false,
|
||||
error: 'Firebase functionality temporarily disabled'
|
||||
}
|
||||
}
|
||||
|
||||
async deleteData(
|
||||
key: string,
|
||||
options?: Record<string, unknown>
|
||||
): Promise<AugmentationResponse<boolean>> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase delete operation
|
||||
/*
|
||||
try {
|
||||
await deleteDoc(doc(this.collection, key))
|
||||
return { success: true, data: true }
|
||||
} catch (error) {
|
||||
console.error(`Failed to delete data for key ${key}:`, error)
|
||||
return {
|
||||
success: false,
|
||||
data: false,
|
||||
error: `Failed to delete data: ${error}`
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
console.log(`Firebase delete operation temporarily disabled for key: ${key}`)
|
||||
return {
|
||||
success: false,
|
||||
data: false,
|
||||
error: 'Firebase functionality temporarily disabled'
|
||||
}
|
||||
}
|
||||
|
||||
async listDataKeys(
|
||||
pattern?: string,
|
||||
options?: Record<string, unknown>
|
||||
): Promise<AugmentationResponse<string[]>> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase list operation
|
||||
console.log(`Firebase list operation temporarily disabled for pattern: ${pattern || 'none'}`)
|
||||
return {
|
||||
success: false,
|
||||
data: [],
|
||||
error: 'Firebase functionality temporarily disabled'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for data in Firestore using vector similarity.
|
||||
* Uses Firestore's built-in findNearest function for efficient vector search.
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase vector search
|
||||
*
|
||||
* @param queryData The query vector or data to search for
|
||||
* @param k Number of results to return (default: 10)
|
||||
* @param options Optional search options
|
||||
*/
|
||||
async search(
|
||||
queryData: unknown,
|
||||
k: number = 10,
|
||||
options?: Record<string, unknown>
|
||||
): Promise<AugmentationResponse<Array<{
|
||||
id: string;
|
||||
score: number;
|
||||
data: unknown;
|
||||
}>>> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase vector search
|
||||
console.log(`Firebase vector search temporarily disabled`)
|
||||
return {
|
||||
success: false,
|
||||
data: [],
|
||||
error: 'Firebase functionality temporarily disabled'
|
||||
}
|
||||
}
|
||||
|
||||
private async ensureInitialized(): Promise<void> {
|
||||
if (!this.isInitialized) {
|
||||
await this.initialize()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare data for Firestore by handling special types
|
||||
*/
|
||||
private prepareForFirestore(obj: any): any {
|
||||
if (obj === null || obj === undefined) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (
|
||||
typeof obj === 'string' ||
|
||||
typeof obj === 'number' ||
|
||||
typeof obj === 'boolean'
|
||||
) {
|
||||
return obj
|
||||
}
|
||||
|
||||
if (obj instanceof Date) {
|
||||
return obj
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(item => this.prepareForFirestore(item))
|
||||
}
|
||||
|
||||
if (obj instanceof Map) {
|
||||
const result: Record<string, any> = {}
|
||||
for (const [key, value] of obj.entries()) {
|
||||
result[String(key)] = this.prepareForFirestore(value)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
if (obj instanceof Set) {
|
||||
return Array.from(obj).map(item => this.prepareForFirestore(item))
|
||||
}
|
||||
|
||||
if (typeof obj === 'object') {
|
||||
const result: Record<string, any> = {}
|
||||
for (const key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
result[key] = this.prepareForFirestore(obj[key])
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Default fallback
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Firestore storage augmentation
|
||||
*/
|
||||
export function createFirestoreStorageAugmentation(
|
||||
name: string,
|
||||
config: FirestoreStorageConfig
|
||||
): IMemoryAugmentation {
|
||||
return new FirestoreStorageAugmentation(name, config)
|
||||
}
|
||||
|
|
@ -1,538 +0,0 @@
|
|||
/**
|
||||
* FirestoreSync Conduit Augmentation
|
||||
*
|
||||
* This augmentation allows for syncing data to Firestore either one-way or two-way.
|
||||
* One-way sync: Data is only pushed from Brainy to Firestore
|
||||
* Two-way sync: Data is synchronized between Brainy and Firestore in both directions
|
||||
*
|
||||
* Note: This augmentation requires Firebase to be installed as a dependency.
|
||||
* Install with: npm install firebase
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: All Firebase/Firestore functionality
|
||||
*/
|
||||
|
||||
import {
|
||||
AugmentationType,
|
||||
IConduitAugmentation,
|
||||
AugmentationResponse,
|
||||
WebSocketConnection
|
||||
} from '../types/augmentations.js'
|
||||
import { HNSWNode, Edge } from '../coreTypes.js'
|
||||
|
||||
// Firebase imports will be dynamically loaded to avoid dependency issues
|
||||
// TEMPORARILY COMMENTED OUT: Firebase imports
|
||||
// let firebase: any = null
|
||||
// let firestore: any = null
|
||||
|
||||
/**
|
||||
* Configuration for FirestoreSync augmentation
|
||||
*/
|
||||
export interface FirestoreSyncConfig {
|
||||
/** Firebase configuration object */
|
||||
firebaseConfig: {
|
||||
apiKey: string
|
||||
authDomain: string
|
||||
projectId: string
|
||||
storageBucket?: string
|
||||
messagingSenderId?: string
|
||||
appId: string
|
||||
}
|
||||
/** Collection name for nodes in Firestore */
|
||||
nodesCollection: string
|
||||
/** Collection name for edges in Firestore */
|
||||
edgesCollection: string
|
||||
/** Collection name for metadata in Firestore */
|
||||
metadataCollection: string
|
||||
/** Sync mode: 'one-way' (Brainy -> Firestore) or 'two-way' (bidirectional) */
|
||||
syncMode: 'one-way' | 'two-way'
|
||||
/** Sync interval in milliseconds (for two-way sync) */
|
||||
syncInterval?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* FirestoreSync Conduit Augmentation
|
||||
* Allows for syncing data to Firestore either one-way or two-way
|
||||
*/
|
||||
export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
||||
readonly name: string
|
||||
readonly description: string
|
||||
enabled: boolean
|
||||
private config: FirestoreSyncConfig
|
||||
private isInitialized: boolean = false
|
||||
private db: any = null
|
||||
private syncIntervalId: NodeJS.Timeout | null = null
|
||||
private lastSyncTimestamp: number = 0
|
||||
|
||||
constructor(name: string, config: FirestoreSyncConfig) {
|
||||
this.name = name
|
||||
this.description = 'Syncs data between Brainy and Firestore'
|
||||
this.enabled = true
|
||||
this.config = config
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the augmentation
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase initialization
|
||||
*/
|
||||
async initialize(): Promise<void> {
|
||||
if (this.isInitialized) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// TEMPORARILY COMMENTED OUT: Firebase initialization
|
||||
/*
|
||||
// Dynamically import Firebase
|
||||
try {
|
||||
const firebaseModule = await import('firebase/app')
|
||||
const firestoreModule = await import('firebase/firestore')
|
||||
|
||||
firebase = firebaseModule.default || firebaseModule
|
||||
firestore = firestoreModule
|
||||
} catch (importError) {
|
||||
throw new Error(`Failed to import Firebase modules: ${importError}. Please install Firebase with: npm install firebase`)
|
||||
}
|
||||
|
||||
// Initialize Firebase
|
||||
const app = firebase.initializeApp(this.config.firebaseConfig, this.name)
|
||||
this.db = firebase.firestore(app)
|
||||
|
||||
// Set up two-way sync if configured
|
||||
if (this.config.syncMode === 'two-way' && this.config.syncInterval) {
|
||||
this.startSyncInterval()
|
||||
}
|
||||
*/
|
||||
|
||||
this.isInitialized = true
|
||||
console.log(`FirestoreSync augmentation '${this.name}' initialized successfully (Firebase functionality temporarily disabled)`)
|
||||
} catch (error) {
|
||||
console.error(`Failed to initialize FirestoreSync augmentation: ${error}`)
|
||||
throw new Error(`Failed to initialize FirestoreSync augmentation: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shut down the augmentation
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase shutdown
|
||||
*/
|
||||
async shutDown(): Promise<void> {
|
||||
if (this.syncIntervalId) {
|
||||
clearInterval(this.syncIntervalId)
|
||||
this.syncIntervalId = null
|
||||
}
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase shutdown
|
||||
/*
|
||||
if (firebase && this.isInitialized) {
|
||||
await firebase.app(this.name).delete()
|
||||
}
|
||||
*/
|
||||
|
||||
this.isInitialized = false
|
||||
console.log(`FirestoreSync augmentation '${this.name}' shut down successfully`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status of the augmentation
|
||||
*/
|
||||
async getStatus(): Promise<'active' | 'inactive' | 'error'> {
|
||||
if (!this.enabled) {
|
||||
return 'inactive'
|
||||
}
|
||||
|
||||
if (!this.isInitialized) {
|
||||
return 'error'
|
||||
}
|
||||
|
||||
return 'active'
|
||||
}
|
||||
|
||||
/**
|
||||
* Establish a connection to Firestore
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase connection
|
||||
*/
|
||||
establishConnection(
|
||||
targetSystemId: string,
|
||||
config: Record<string, unknown>
|
||||
): AugmentationResponse<WebSocketConnection> {
|
||||
// TEMPORARILY COMMENTED OUT: Firebase connection
|
||||
/*
|
||||
// Ensure initialization happens before returning
|
||||
this.ensureInitialized().catch(error => {
|
||||
console.error(`Error initializing during establishConnection: ${error}`)
|
||||
})
|
||||
*/
|
||||
|
||||
try {
|
||||
// For Firestore, the connection is already established during initialization
|
||||
// This method is mainly for compatibility with the IConduitAugmentation interface
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
connectionId: targetSystemId,
|
||||
url: `Firebase connection temporarily disabled`,
|
||||
status: 'disabled'
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
data: {
|
||||
connectionId: targetSystemId,
|
||||
url: '',
|
||||
status: 'error'
|
||||
},
|
||||
error: `Failed to establish connection: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from Firestore
|
||||
*/
|
||||
readData(
|
||||
query: Record<string, unknown>,
|
||||
options?: Record<string, unknown>
|
||||
): AugmentationResponse<unknown> {
|
||||
// This is a synchronous wrapper around an async operation
|
||||
// We'll start the async operation but return a placeholder response immediately
|
||||
|
||||
// Ensure we're initialized
|
||||
this.ensureInitialized().catch(error => {
|
||||
console.error(`Error initializing during readData: ${error}`)
|
||||
})
|
||||
|
||||
try {
|
||||
// Return a placeholder response
|
||||
// In a real implementation, this would need to be redesigned to work synchronously
|
||||
// or the interface would need to be updated to allow for Promise returns
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
message: "Reading data from Firestore (placeholder response)",
|
||||
query: query,
|
||||
options: options
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
data: {},
|
||||
error: `Failed to read data: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to Firestore
|
||||
*/
|
||||
writeData(
|
||||
data: Record<string, unknown>,
|
||||
options?: Record<string, unknown>
|
||||
): AugmentationResponse<unknown> {
|
||||
// This is a synchronous wrapper around an async operation
|
||||
// We'll start the async operation but return a placeholder response immediately
|
||||
|
||||
// Ensure we're initialized
|
||||
this.ensureInitialized().catch(error => {
|
||||
console.error(`Error initializing during writeData: ${error}`)
|
||||
})
|
||||
|
||||
try {
|
||||
// Extract the ID if available for the response
|
||||
const id = data.id as string || 'unknown-id'
|
||||
|
||||
// Start the async operation in the background
|
||||
// In a real implementation, this would need to be redesigned to work synchronously
|
||||
// or the interface would need to be updated to allow for Promise returns
|
||||
setTimeout(() => {
|
||||
this.writeDataAsync(data, options).catch(error => {
|
||||
console.error(`Error in background writeData: ${error}`)
|
||||
})
|
||||
}, 0)
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
id,
|
||||
message: "Writing data to Firestore (operation started in background)",
|
||||
status: "pending"
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
data: {},
|
||||
error: `Failed to write data: ${error}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Private async method to actually perform the write operation
|
||||
// TEMPORARILY COMMENTED OUT: Firebase write operation
|
||||
private async writeDataAsync(
|
||||
data: Record<string, unknown>,
|
||||
options?: Record<string, unknown>
|
||||
): Promise<void> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
try {
|
||||
const { collection, id, document } = data as {
|
||||
collection: string,
|
||||
id: string,
|
||||
document: Record<string, any>
|
||||
}
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase write operation
|
||||
/*
|
||||
// Prepare the document for Firestore
|
||||
// Convert Maps and Sets to arrays or objects for Firestore compatibility
|
||||
const firestoreDoc = this.prepareForFirestore(document)
|
||||
|
||||
// Add timestamp for sync tracking
|
||||
firestoreDoc._lastUpdated = firebase.firestore.FieldValue.serverTimestamp()
|
||||
firestoreDoc._source = 'brainy'
|
||||
|
||||
// Write to Firestore
|
||||
await this.db.collection(collection).doc(id).set(firestoreDoc, { merge: true })
|
||||
*/
|
||||
|
||||
console.log(`Firebase write operation temporarily disabled: ${collection}/${id}`)
|
||||
} catch (error) {
|
||||
console.error(`Failed to write data: ${error}`)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor a data stream in Firestore
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase monitoring
|
||||
*/
|
||||
async monitorStream(streamId: string, callback: (data: unknown) => void): Promise<void> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
try {
|
||||
// TEMPORARILY COMMENTED OUT: Firebase monitoring
|
||||
/*
|
||||
// Set up a listener for changes in the specified collection
|
||||
const unsubscribe = this.db.collection(streamId)
|
||||
.where('_lastUpdated', '>', new Date(this.lastSyncTimestamp))
|
||||
.where('_source', '==', 'firestore') // Only listen for changes from Firestore
|
||||
.onSnapshot((snapshot: any) => {
|
||||
const changes = snapshot.docChanges()
|
||||
|
||||
for (const change of changes) {
|
||||
const data = this.convertFirestoreDocToObject(change.doc)
|
||||
callback({
|
||||
type: change.type, // 'added', 'modified', or 'removed'
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// Update last sync timestamp
|
||||
this.lastSyncTimestamp = Date.now()
|
||||
})
|
||||
|
||||
// Return the unsubscribe function wrapped in a Promise
|
||||
return Promise.resolve(unsubscribe)
|
||||
*/
|
||||
|
||||
console.log(`Firebase monitoring temporarily disabled for stream: ${streamId}`)
|
||||
return Promise.resolve(() => {
|
||||
console.log('Unsubscribe function (placeholder - Firebase temporarily disabled)')
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(`Failed to monitor stream: ${error}`)
|
||||
throw new Error(`Failed to monitor stream: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync a node to Firestore
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase sync
|
||||
*/
|
||||
async syncNodeToFirestore(node: HNSWNode): Promise<void> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
try {
|
||||
// TEMPORARILY COMMENTED OUT: Firebase sync
|
||||
/*
|
||||
const firestoreNode = this.prepareForFirestore(node)
|
||||
firestoreNode._lastUpdated = firebase.firestore.FieldValue.serverTimestamp()
|
||||
firestoreNode._source = 'brainy'
|
||||
|
||||
await this.db.collection(this.config.nodesCollection).doc(node.id).set(firestoreNode, { merge: true })
|
||||
*/
|
||||
console.log(`Firebase sync temporarily disabled for node: ${node.id}`)
|
||||
} catch (error) {
|
||||
console.error(`Failed to sync node: ${error}`)
|
||||
throw new Error(`Failed to sync node: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync an edge to Firestore
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase sync
|
||||
*/
|
||||
async syncEdgeToFirestore(edge: Edge): Promise<void> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
try {
|
||||
// TEMPORARILY COMMENTED OUT: Firebase sync
|
||||
/*
|
||||
const firestoreEdge = this.prepareForFirestore(edge)
|
||||
firestoreEdge._lastUpdated = firebase.firestore.FieldValue.serverTimestamp()
|
||||
firestoreEdge._source = 'brainy'
|
||||
|
||||
await this.db.collection(this.config.edgesCollection).doc(edge.id).set(firestoreEdge, { merge: true })
|
||||
*/
|
||||
console.log(`Firebase sync temporarily disabled for edge: ${edge.id}`)
|
||||
} catch (error) {
|
||||
console.error(`Failed to sync edge: ${error}`)
|
||||
throw new Error(`Failed to sync edge: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync metadata to Firestore
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase sync
|
||||
*/
|
||||
async syncMetadataToFirestore(id: string, metadata: any): Promise<void> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
try {
|
||||
// TEMPORARILY COMMENTED OUT: Firebase sync
|
||||
/*
|
||||
const firestoreMetadata = this.prepareForFirestore(metadata)
|
||||
firestoreMetadata._lastUpdated = firebase.firestore.FieldValue.serverTimestamp()
|
||||
firestoreMetadata._source = 'brainy'
|
||||
|
||||
await this.db.collection(this.config.metadataCollection).doc(id).set(firestoreMetadata, { merge: true })
|
||||
*/
|
||||
console.log(`Firebase sync temporarily disabled for metadata: ${id}`)
|
||||
} catch (error) {
|
||||
console.error(`Failed to sync metadata: ${error}`)
|
||||
throw new Error(`Failed to sync metadata: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the sync interval for two-way sync
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase sync interval
|
||||
*/
|
||||
private startSyncInterval(): void {
|
||||
if (this.syncIntervalId) {
|
||||
clearInterval(this.syncIntervalId)
|
||||
}
|
||||
|
||||
this.lastSyncTimestamp = Date.now()
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase sync interval
|
||||
/*
|
||||
this.syncIntervalId = setInterval(async () => {
|
||||
if (!this.enabled || !this.isInitialized) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// Sync from Firestore to Brainy
|
||||
await this.syncFromFirestore()
|
||||
} catch (error) {
|
||||
console.error(`Error during two-way sync: ${error}`)
|
||||
}
|
||||
}, this.config.syncInterval || 60000) // Default to 1 minute if not specified
|
||||
*/
|
||||
|
||||
console.log('Firebase sync interval temporarily disabled')
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync data from Firestore to Brainy
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase sync
|
||||
*/
|
||||
private async syncFromFirestore(): Promise<void> {
|
||||
// TEMPORARILY COMMENTED OUT: Firebase sync
|
||||
/*
|
||||
// This would typically call back to the Brainy system to update its data
|
||||
// For now, we'll just log that it would happen
|
||||
console.log('Syncing data from Firestore to Brainy (not implemented yet)')
|
||||
|
||||
// In a real implementation, this would:
|
||||
// 1. Query Firestore for documents updated since lastSyncTimestamp
|
||||
// 2. For each document, update the corresponding data in Brainy
|
||||
// 3. Update lastSyncTimestamp
|
||||
*/
|
||||
|
||||
console.log('Firebase sync from Firestore temporarily disabled')
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the augmentation is initialized
|
||||
*/
|
||||
private async ensureInitialized(): Promise<void> {
|
||||
if (!this.isInitialized) {
|
||||
await this.initialize()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Firestore document to a plain JavaScript object
|
||||
*/
|
||||
private convertFirestoreDocToObject(doc: any): any {
|
||||
const data = doc.data()
|
||||
return {
|
||||
id: doc.id,
|
||||
...data
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare an object for Firestore by converting Maps and Sets
|
||||
*/
|
||||
private prepareForFirestore(obj: any): any {
|
||||
if (obj === null || typeof obj !== 'object') {
|
||||
return obj
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(item => this.prepareForFirestore(item))
|
||||
}
|
||||
|
||||
if (obj instanceof Map) {
|
||||
const result: Record<string, any> = {}
|
||||
for (const [key, value] of obj.entries()) {
|
||||
result[key] = this.prepareForFirestore(value)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
if (obj instanceof Set) {
|
||||
return Array.from(obj).map(item => this.prepareForFirestore(item))
|
||||
}
|
||||
|
||||
const result: Record<string, any> = {}
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
result[key] = this.prepareForFirestore(value)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and register a FirestoreSync augmentation
|
||||
*/
|
||||
export function createFirestoreSyncAugmentation(
|
||||
name: string,
|
||||
config: FirestoreSyncConfig
|
||||
): FirestoreSyncAugmentation {
|
||||
return new FirestoreSyncAugmentation(name, config)
|
||||
}
|
||||
|
|
@ -8,11 +8,6 @@ import { MemoryStorage } from '../storage/opfsStorage.js'
|
|||
import { FileSystemStorage } from '../storage/fileSystemStorage.js'
|
||||
import { OPFSStorage } from '../storage/opfsStorage.js'
|
||||
import { cosineDistance } from '../utils/distance.js'
|
||||
import {
|
||||
FirestoreStorageAugmentation,
|
||||
FirestoreStorageConfig,
|
||||
createFirestoreStorageAugmentation
|
||||
} from './firestoreStorageAugmentation.js'
|
||||
|
||||
/**
|
||||
* Base class for memory augmentations that wrap a StorageAdapter
|
||||
|
|
@ -292,10 +287,9 @@ export class OPFSStorageAugmentation extends BaseMemoryAugmentation {
|
|||
export async function createMemoryAugmentation(
|
||||
name: string,
|
||||
options: {
|
||||
storageType?: 'memory' | 'filesystem' | 'opfs' | 'firestore'
|
||||
storageType?: 'memory' | 'filesystem' | 'opfs'
|
||||
rootDirectory?: string
|
||||
requestPersistentStorage?: boolean
|
||||
firestoreConfig?: FirestoreStorageConfig
|
||||
} = {}
|
||||
): Promise<IMemoryAugmentation> {
|
||||
// If a specific storage type is requested, use that
|
||||
|
|
@ -307,11 +301,6 @@ export async function createMemoryAugmentation(
|
|||
return new FileSystemStorageAugmentation(name, options.rootDirectory)
|
||||
case 'opfs':
|
||||
return new OPFSStorageAugmentation(name)
|
||||
case 'firestore':
|
||||
if (!options.firestoreConfig) {
|
||||
throw new Error('firestoreConfig is required when using Firestore storage')
|
||||
}
|
||||
return createFirestoreStorageAugmentation(name, options.firestoreConfig)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
12
src/index.ts
12
src/index.ts
|
|
@ -116,22 +116,12 @@ import {
|
|||
OPFSStorageAugmentation,
|
||||
createMemoryAugmentation
|
||||
} from './augmentations/memoryAugmentations.js'
|
||||
import {
|
||||
FirestoreStorageAugmentation,
|
||||
createFirestoreStorageAugmentation
|
||||
} from './augmentations/firestoreStorageAugmentation.js'
|
||||
import type { FirestoreStorageConfig } from './augmentations/firestoreStorageAugmentation.js'
|
||||
|
||||
export {
|
||||
MemoryStorageAugmentation,
|
||||
FileSystemStorageAugmentation,
|
||||
OPFSStorageAugmentation,
|
||||
FirestoreStorageAugmentation,
|
||||
createMemoryAugmentation,
|
||||
createFirestoreStorageAugmentation
|
||||
}
|
||||
export type {
|
||||
FirestoreStorageConfig
|
||||
createMemoryAugmentation
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ export namespace BrainyAugmentations {
|
|||
|
||||
/**
|
||||
* Interface for Memory augmentations.
|
||||
* These augmentations provide storage capabilities for data in different formats (e.g., fileSystem, in-memory, or firestore).
|
||||
* These augmentations provide storage capabilities for data in different formats (e.g., fileSystem, in-memory).
|
||||
*/
|
||||
export interface IMemoryAugmentation extends IAugmentation {
|
||||
/**
|
||||
|
|
|
|||
20
src/types/firebase-vector-search.d.ts
vendored
20
src/types/firebase-vector-search.d.ts
vendored
|
|
@ -1,20 +0,0 @@
|
|||
// TEMPORARILY COMMENTED OUT: Firebase vector search type declarations
|
||||
/*
|
||||
declare module '@firebase/firestore-vector-search' {
|
||||
interface VectorSearchOptions {
|
||||
collection: any;
|
||||
vectorField: string;
|
||||
queryVector: number[];
|
||||
limit: number;
|
||||
distanceMeasure?: string;
|
||||
}
|
||||
|
||||
interface VectorSearchResult {
|
||||
id: string;
|
||||
data: any;
|
||||
distance?: number;
|
||||
}
|
||||
|
||||
export function findNearest(options: VectorSearchOptions): Promise<VectorSearchResult[]>;
|
||||
}
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue