chore: temporarily disable Firestore functionality and remove Firebase dependencies
Commented out all Firestore-related code across the project, including sync, storage, and vector search features. Removed Firebase dependencies (`firebase`, `firebase-admin`) from `package.json`. Updated `README.md` to reflect the temporary unavailability of Firestore features.
This commit is contained in:
parent
7e31719b2a
commit
3659b0069b
5 changed files with 166 additions and 237 deletions
51
README.md
51
README.md
|
|
@ -16,7 +16,7 @@ for storage, with HNSW (Hierarchical Navigable Small World) for efficient vector
|
|||
- **TypeScript support**: Fully typed API with generics for metadata types
|
||||
- **Multiple distance functions**: Supports cosine, Euclidean, Manhattan, and dot product distance metrics
|
||||
- **Augmentation system**: Extensible architecture for adding specialized capabilities
|
||||
- **Memory augmentation**: Store and retrieve data in different formats (fileSystem, in-memory, firestore)
|
||||
- **Memory augmentation**: Store and retrieve data in different formats (fileSystem, in-memory)
|
||||
- **Full graph database capabilities**: Structured representation of entities and relationships with support for nodes (
|
||||
nouns) and edges (verbs)
|
||||
|
||||
|
|
@ -394,14 +394,6 @@ interface IConduitAugmentation extends IAugmentation {
|
|||
}
|
||||
```
|
||||
|
||||
##### FirestoreSync Conduit Augmentation
|
||||
|
||||
Brainy includes a FirestoreSync conduit augmentation that 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
|
||||
|
||||
**Prerequisites:**
|
||||
|
||||
Brainy provides several memory augmentation implementations for different storage types:
|
||||
|
|
@ -409,8 +401,6 @@ Brainy provides several memory augmentation implementations for different storag
|
|||
1. **MemoryStorageAugmentation**: In-memory storage (volatile)
|
||||
2. **FileSystemStorageAugmentation**: File system storage (for Node.js environments)
|
||||
3. **OPFSStorageAugmentation**: Origin Private File System storage (for browser environments)
|
||||
4. **FirestoreStorageAugmentation**: Firestore database storage (requires Firebase)
|
||||
- Note: The FirestoreStorageAugmentation includes vector search functionality that will automatically fall back to client-side search if the Firebase Extensions for Firestore Vector Search is not available.
|
||||
|
||||
You can use the `createMemoryAugmentation` factory function to automatically select the appropriate storage type based on the environment, or you can specify a particular storage type.
|
||||
|
||||
|
|
@ -481,41 +471,6 @@ const opfsStorage = await createMemoryAugmentation('opfs-storage', {
|
|||
});
|
||||
```
|
||||
|
||||
**Using Firestore Storage:**
|
||||
|
||||
If you want to use Firestore as your storage backend:
|
||||
|
||||
1. Install Firebase: `npm install firebase`
|
||||
2. Set up a Firebase project and enable Firestore
|
||||
3. Get your Firebase configuration from the Firebase console
|
||||
|
||||
```typescript
|
||||
import {
|
||||
createMemoryAugmentation,
|
||||
FirestoreStorageConfig
|
||||
} from '@soulcraft/brainy';
|
||||
|
||||
// Your Firebase configuration
|
||||
const firestoreConfig: FirestoreStorageConfig = {
|
||||
projectId: 'your-project-id',
|
||||
collection: 'brainy_data',
|
||||
// Optional: provide credentials, databaseURL, appName
|
||||
};
|
||||
|
||||
// Create a memory augmentation with Firestore storage
|
||||
const firestoreStorage = await createMemoryAugmentation('firestore-storage', {
|
||||
storageType: 'firestore',
|
||||
firestoreConfig
|
||||
});
|
||||
|
||||
// Or use the direct factory function
|
||||
import { createFirestoreStorageAugmentation } from '@soulcraft/brainy';
|
||||
|
||||
const firestoreStorage = createFirestoreStorageAugmentation(
|
||||
'firestore-storage',
|
||||
firestoreConfig
|
||||
);
|
||||
```
|
||||
|
||||
The memory augmentation will automatically select the appropriate storage based on the environment:
|
||||
- In Node.js: FileSystemStorage
|
||||
|
|
@ -543,7 +498,7 @@ interface ICognitionAugmentation extends IAugmentation {
|
|||
|
||||
#### Memory Augmentations
|
||||
|
||||
For storing data in different formats (e.g., fileSystem, in-memory, or firestore):
|
||||
For storing data in different formats (e.g., fileSystem, in-memory):
|
||||
|
||||
```typescript
|
||||
interface IMemoryAugmentation extends IAugmentation {
|
||||
|
|
@ -956,7 +911,7 @@ The repository also includes TypeScript examples for Node.js:
|
|||
- `src/examples/customStorage.ts`: Shows how to use a custom storage adapter
|
||||
- `src/examples/augmentationPipeline.ts`: Demonstrates the augmentation pipeline
|
||||
- `src/examples/webSocketAugmentation.ts`: Shows how to create WebSocket-supporting augmentations
|
||||
- `examples/memoryAugmentationExample.js`: Demonstrates memory augmentations for different storage types (Memory, FileSystem, OPFS, Firestore)
|
||||
- `examples/memoryAugmentationExample.js`: Demonstrates memory augmentations for different storage types (Memory, FileSystem, OPFS)
|
||||
|
||||
## How It Works
|
||||
|
||||
|
|
|
|||
|
|
@ -65,9 +65,7 @@
|
|||
"@tensorflow/tfjs": "^4.22.0",
|
||||
"@tensorflow/tfjs-backend-cpu": "^4.22.0",
|
||||
"@tensorflow/tfjs-core": "^4.22.0",
|
||||
"@tensorflow/tfjs-layers": "^4.22.0",
|
||||
"firebase": "^10.8.0",
|
||||
"firebase-admin": "^12.0.0"
|
||||
"@tensorflow/tfjs-layers": "^4.22.0"
|
||||
},
|
||||
"prettier": {
|
||||
"arrowParens": "always",
|
||||
|
|
|
|||
|
|
@ -5,20 +5,22 @@ import {
|
|||
} from '../types/augmentations.js'
|
||||
import { Vector } from '../coreTypes.js'
|
||||
import { cosineDistance } from '../utils/distance.js'
|
||||
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'
|
||||
|
||||
// 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
|
||||
|
|
@ -77,6 +79,8 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
}
|
||||
|
||||
try {
|
||||
// TEMPORARILY COMMENTED OUT: Firebase initialization
|
||||
/*
|
||||
// Initialize Firebase if not already initialized
|
||||
let app
|
||||
try {
|
||||
|
|
@ -106,6 +110,9 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
// 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)
|
||||
|
|
@ -124,6 +131,8 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
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)))
|
||||
|
|
@ -132,6 +141,10 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
console.error('Firestore connection error:', error)
|
||||
return 'error'
|
||||
}
|
||||
*/
|
||||
|
||||
console.log('Firebase status check temporarily disabled')
|
||||
return 'inactive'
|
||||
}
|
||||
|
||||
async storeData(
|
||||
|
|
@ -141,6 +154,8 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
): 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 }
|
||||
|
|
@ -152,6 +167,14 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
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(
|
||||
|
|
@ -160,6 +183,8 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
): Promise<AugmentationResponse<unknown>> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase retrieve operation
|
||||
/*
|
||||
try {
|
||||
const docSnapshot = await getDoc(doc(this.collection, key))
|
||||
|
||||
|
|
@ -182,6 +207,14 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
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(
|
||||
|
|
@ -191,6 +224,8 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
): 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 }
|
||||
|
|
@ -202,6 +237,14 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
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(
|
||||
|
|
@ -210,6 +253,8 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
): Promise<AugmentationResponse<boolean>> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase delete operation
|
||||
/*
|
||||
try {
|
||||
await deleteDoc(doc(this.collection, key))
|
||||
return { success: true, data: true }
|
||||
|
|
@ -221,6 +266,14 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
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(
|
||||
|
|
@ -229,43 +282,21 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
): Promise<AugmentationResponse<string[]>> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
try {
|
||||
// Create a query from the collection
|
||||
const q = query(this.collection)
|
||||
|
||||
// If pattern is provided, use it to filter keys
|
||||
// Note: Firestore doesn't support wildcard queries directly,
|
||||
// so we'll need to do some client-side filtering
|
||||
const snapshot = await getDocs(q)
|
||||
|
||||
let keys = snapshot.docs.map((docSnapshot: any) => docSnapshot.id)
|
||||
|
||||
// Apply pattern filtering if provided
|
||||
if (pattern) {
|
||||
// Convert wildcard pattern to regex
|
||||
const regexPattern = new RegExp(
|
||||
'^' + pattern.replace(/\*/g, '.*') + '$'
|
||||
)
|
||||
keys = keys.filter((key: string) => regexPattern.test(key))
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: keys
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to list data keys:`, error)
|
||||
return {
|
||||
success: false,
|
||||
data: [],
|
||||
error: `Failed to list data keys: ${error}`
|
||||
}
|
||||
// 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
|
||||
|
|
@ -281,134 +312,12 @@ export class FirestoreStorageAugmentation implements IMemoryAugmentation {
|
|||
}>>> {
|
||||
await this.ensureInitialized()
|
||||
|
||||
try {
|
||||
// Check if queryData is a vector
|
||||
let queryVector: Vector
|
||||
|
||||
if (Array.isArray(queryData) && queryData.every(item => typeof item === 'number')) {
|
||||
queryVector = queryData as Vector
|
||||
} else {
|
||||
// If queryData is not a vector, we can't perform vector search
|
||||
return {
|
||||
success: false,
|
||||
data: [],
|
||||
error: 'Query must be a vector (array of numbers) for vector search'
|
||||
}
|
||||
}
|
||||
|
||||
// Get vector field name from options or use default 'vector'
|
||||
const vectorField = options?.vectorField as string || 'vector'
|
||||
|
||||
// Get distance measure from options or use default 'COSINE'
|
||||
// Firestore supports 'COSINE', 'EUCLIDEAN', and 'DOT_PRODUCT'
|
||||
const distanceMeasure = options?.distanceMeasure as string || 'COSINE'
|
||||
|
||||
try {
|
||||
// Note: In Firebase v9+, vector search requires the Firebase Extensions for Firestore Vector Search
|
||||
// This code attempts to use it if available, but will fall back to client-side search
|
||||
|
||||
// Use the vector search extension imported at the top of the file
|
||||
try {
|
||||
const vectorSearchOptions = {
|
||||
collection: this.collection,
|
||||
vectorField: vectorField,
|
||||
queryVector: queryVector,
|
||||
limit: k,
|
||||
distanceMeasure: distanceMeasure
|
||||
}
|
||||
|
||||
const searchResults = await findNearest(vectorSearchOptions)
|
||||
|
||||
// Process results
|
||||
const results: Array<{
|
||||
id: string;
|
||||
score: number;
|
||||
data: unknown;
|
||||
}> = searchResults.map((result: any) => {
|
||||
// Calculate the similarity score based on the distance measure
|
||||
let score: number
|
||||
|
||||
if (distanceMeasure === 'DOT_PRODUCT') {
|
||||
// For dot product, higher is already better
|
||||
score = result.distance || 0
|
||||
} else {
|
||||
// For COSINE and EUCLIDEAN, convert to similarity score
|
||||
// where 1 is perfect match and 0 is completely dissimilar
|
||||
score = 1 / (1 + (result.distance || 0))
|
||||
}
|
||||
|
||||
return {
|
||||
id: result.id,
|
||||
score,
|
||||
data: result.data
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: results
|
||||
}
|
||||
} catch (vectorSearchError) {
|
||||
// Vector search extension not available, fall back to client-side search
|
||||
console.warn('Firestore vector search extension not available, falling back to client-side search:', vectorSearchError)
|
||||
throw vectorSearchError
|
||||
}
|
||||
} catch (vectorSearchError) {
|
||||
console.warn('Firestore vector search failed, falling back to client-side search:', vectorSearchError)
|
||||
|
||||
// Fallback to client-side search if findNearest is not available
|
||||
// This can happen if the Firestore instance doesn't support vector search
|
||||
// or if the collection isn't configured for vector search
|
||||
|
||||
// Get all documents from Firestore using the modern API
|
||||
const q = query(this.collection)
|
||||
const snapshot = await getDocs(q)
|
||||
|
||||
// Calculate distances and prepare results
|
||||
const results: Array<{
|
||||
id: string;
|
||||
score: number;
|
||||
data: unknown;
|
||||
}> = []
|
||||
|
||||
for (const docSnapshot of snapshot.docs) {
|
||||
const data = docSnapshot.data() as Record<string, any>
|
||||
|
||||
// Skip documents that don't have a vector field
|
||||
if (!data[vectorField] || !Array.isArray(data[vectorField])) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Calculate distance between query vector and document vector
|
||||
const distance = cosineDistance(queryVector, data[vectorField] as number[])
|
||||
|
||||
// Convert distance to similarity score (1 - distance for cosine)
|
||||
// This way higher scores are better (more similar)
|
||||
const score = 1 - distance
|
||||
|
||||
results.push({
|
||||
id: docSnapshot.id,
|
||||
score,
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// Sort results by score (descending) and take top k
|
||||
results.sort((a, b) => b.score - a.score)
|
||||
const topResults = results.slice(0, k)
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: topResults
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to search in Firestore:`, error)
|
||||
return {
|
||||
success: false,
|
||||
data: [],
|
||||
error: `Failed to search in Firestore: ${error}`
|
||||
}
|
||||
// TEMPORARILY COMMENTED OUT: Firebase vector search
|
||||
console.log(`Firebase vector search temporarily disabled`)
|
||||
return {
|
||||
success: false,
|
||||
data: [],
|
||||
error: 'Firebase functionality temporarily disabled'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
*
|
||||
* Note: This augmentation requires Firebase to be installed as a dependency.
|
||||
* Install with: npm install firebase
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: All Firebase/Firestore functionality
|
||||
*/
|
||||
|
||||
import {
|
||||
|
|
@ -18,8 +20,9 @@ import {
|
|||
import { HNSWNode, Edge } from '../coreTypes.js'
|
||||
|
||||
// Firebase imports will be dynamically loaded to avoid dependency issues
|
||||
let firebase: any = null
|
||||
let firestore: any = null
|
||||
// TEMPORARILY COMMENTED OUT: Firebase imports
|
||||
// let firebase: any = null
|
||||
// let firestore: any = null
|
||||
|
||||
/**
|
||||
* Configuration for FirestoreSync augmentation
|
||||
|
|
@ -69,6 +72,8 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
|
||||
/**
|
||||
* Initialize the augmentation
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase initialization
|
||||
*/
|
||||
async initialize(): Promise<void> {
|
||||
if (this.isInitialized) {
|
||||
|
|
@ -76,6 +81,8 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
}
|
||||
|
||||
try {
|
||||
// TEMPORARILY COMMENTED OUT: Firebase initialization
|
||||
/*
|
||||
// Dynamically import Firebase
|
||||
try {
|
||||
const firebaseModule = await import('firebase/app')
|
||||
|
|
@ -95,9 +102,10 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
if (this.config.syncMode === 'two-way' && this.config.syncInterval) {
|
||||
this.startSyncInterval()
|
||||
}
|
||||
*/
|
||||
|
||||
this.isInitialized = true
|
||||
console.log(`FirestoreSync augmentation '${this.name}' initialized successfully`)
|
||||
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}`)
|
||||
|
|
@ -106,6 +114,8 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
|
||||
/**
|
||||
* Shut down the augmentation
|
||||
*
|
||||
* TEMPORARILY COMMENTED OUT: Firebase shutdown
|
||||
*/
|
||||
async shutDown(): Promise<void> {
|
||||
if (this.syncIntervalId) {
|
||||
|
|
@ -113,9 +123,12 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
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`)
|
||||
|
|
@ -138,15 +151,20 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
|
||||
/**
|
||||
* 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
|
||||
|
|
@ -155,8 +173,8 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
success: true,
|
||||
data: {
|
||||
connectionId: targetSystemId,
|
||||
url: `https://firestore.googleapis.com/v1/projects/${this.config.firebaseConfig.projectId}/databases/(default)/documents`,
|
||||
status: 'connected'
|
||||
url: `Firebase connection temporarily disabled`,
|
||||
status: 'disabled'
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -254,6 +272,7 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
}
|
||||
|
||||
// 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>
|
||||
|
|
@ -267,6 +286,8 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
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)
|
||||
|
|
@ -277,21 +298,26 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
|
||||
// Write to Firestore
|
||||
await this.db.collection(collection).doc(id).set(firestoreDoc, { merge: true })
|
||||
*/
|
||||
|
||||
console.log(`Successfully wrote data to Firestore: ${collection}/${id}`)
|
||||
console.log(`Firebase write operation temporarily disabled: ${collection}/${id}`)
|
||||
} catch (error) {
|
||||
console.error(`Failed to write data to Firestore: ${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))
|
||||
|
|
@ -313,6 +339,12 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
|
||||
// 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}`)
|
||||
|
|
@ -321,60 +353,80 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
|
||||
/**
|
||||
* 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 to Firestore: ${error}`)
|
||||
throw new Error(`Failed to sync node to Firestore: ${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 to Firestore: ${error}`)
|
||||
throw new Error(`Failed to sync edge to Firestore: ${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 to Firestore: ${error}`)
|
||||
throw new Error(`Failed to sync metadata to Firestore: ${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) {
|
||||
|
|
@ -383,6 +435,8 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
|
||||
this.lastSyncTimestamp = Date.now()
|
||||
|
||||
// TEMPORARILY COMMENTED OUT: Firebase sync interval
|
||||
/*
|
||||
this.syncIntervalId = setInterval(async () => {
|
||||
if (!this.enabled || !this.isInitialized) {
|
||||
return
|
||||
|
|
@ -395,12 +449,19 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
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)')
|
||||
|
|
@ -409,6 +470,9 @@ export class FirestoreSyncAugmentation implements IConduitAugmentation {
|
|||
// 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')
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
3
src/types/firebase-vector-search.d.ts
vendored
3
src/types/firebase-vector-search.d.ts
vendored
|
|
@ -1,3 +1,5 @@
|
|||
// TEMPORARILY COMMENTED OUT: Firebase vector search type declarations
|
||||
/*
|
||||
declare module '@firebase/firestore-vector-search' {
|
||||
interface VectorSearchOptions {
|
||||
collection: any;
|
||||
|
|
@ -15,3 +17,4 @@ declare module '@firebase/firestore-vector-search' {
|
|||
|
||||
export function findNearest(options: VectorSearchOptions): Promise<VectorSearchResult[]>;
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue