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:
David Snelling 2025-06-02 17:03:53 -07:00
parent 40dd046884
commit 18bbe6d428
9 changed files with 64 additions and 2179 deletions

View file

@ -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()

View file

@ -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')
}