canvas/dist/db/index.mjs.map

1 line
71 KiB
Text
Raw Permalink Normal View History

2026-03-11 18:42:08 -07:00
{"version":3,"sources":["../../src/db/adapter.ts","../../src/db/supabase-adapter.ts","../../src/db/provider.tsx","../../src/utils/debug.ts","../../src/db/queries/nodes.ts","../../src/db/queries/edges.ts","../../src/db/hooks/keys.ts","../../src/db/hooks/useGraphNodes.ts","../../src/db/hooks/useGraphEdges.ts","../../src/db/hooks/useUpdateNode.ts","../../src/core/sync-store.ts","../../src/db/hooks/useCreateNode.ts","../../src/db/hooks/useDeleteNode.ts","../../src/db/hooks/useUpdateEdge.ts","../../src/db/hooks/useCreateEdge.ts","../../src/db/hooks/useDeleteEdge.ts"],"sourcesContent":["/**\n * Canvas Storage Adapter\n *\n * Backend-agnostic interface for persisting canvas data.\n * The default Supabase implementation lives in `./supabase-adapter.ts`.\n * Users can implement this interface for any backend (REST, GraphQL, localStorage, etc.).\n *\n * Note: The core canvas works WITHOUT any adapter —\n * use `onNodePersist` / `onEdgeCreate` callback props for simple cases.\n * The adapter is for users who want the full `CanvasDbProvider` experience\n * with a non-Supabase backend.\n */\n\nimport { atom } from 'jotai';\n\n// =============================================================================\n// Adapter Types\n// =============================================================================\n\n/** Type aliases for backend-agnostic naming */\n\n/** Change event for realtime subscriptions */\n\n// =============================================================================\n// Adapter Interface\n// =============================================================================\n\n/**\n * Storage adapter for canvas persistence.\n *\n * Implement this interface to use any backend with `CanvasDbProvider`.\n * All methods return Promises for async-first design.\n */\n\n// =============================================================================\n// In-Memory Adapter (for testing / local-only use)\n// =============================================================================\n\n/**\n * Simple in-memory adapter for testing and local-only canvases.\n * Data is lost on page reload.\n */\nexport class InMemoryStorageAdapter {\n nodes = new Map();\n edges = new Map();\n async fetchNodes(graphId) {\n return Array.from(this.nodes.values()).filter(n => n.graph_id === graphId);\n }\n async createNode(graphId, node) {\n const now = new Date().toISOString();\n const fullNode = {\n id: node.id ?? crypto.randomUUID(),\n graph_id: graphId,\n label: node.label ?? null,\n node_type: node.node_type ?? null,\n configuration: node.configuration ?? null,\n ui_properties: node.ui_properties ?? null,\n data: node.data ?? null,\n created_at: now,\n updated_at: now\n };\n this.nodes.set(fullNode.id, fullNode);\n return fullNode;\n }\n async updateNode(nodeId, updates) {\n const existing = this.nodes.get(nodeId);\n if (!existing) throw new Error(`Node ${nodeId} not found`);\n const updated = {\n ...existing,\n ...updates,\n updated_at: new Date().toISOString()\n };\n this.nodes.set(nodeId, updated);\n return updated;\n }\n async deleteNode(nodeId) {\n this.nodes.delete(nodeId);\n // Also delete connected edges\n for (const [edgeId, edge] of this.edges) {\n if (edge.source_node_id === nodeId || edge.target_node_id === nodeId) {\n this.edges.delete(edgeId);\n }\n }\n }\n async fetchEdges(graphId) {\n return Array.from(this.edges.values()).filter(e => e.graph_id === graphId);\n }\n async createEdge(graphId, edge) {\n const now = new Date().toISOString();\n const fullEdge = {\n id: edge.id ?? crypto.randomUUID(),\n graph_id: graphId,\n source_node_id: edge.source_node_id ?? '',\n target_node_id: edge.target_node_id ?? '',\n edge_type: edge.edge_type ?? null,\n filter_condition: edge.filter_condition ?? null,\n ui_properties: edge.ui_properties ?? null,\n data: edge.data ?? null,\n created_at: now,\n updated_at: now\n };\n this.edges.set(fullEdge.id