@semiont/graph 0.2.28 → 0.2.29-build.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +112 -18
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # @semiont/graph
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@semiont/graph)](https://www.npmjs.com/package/@semiont/graph)
3
4
  [![Tests](https://github.com/The-AI-Alliance/semiont/actions/workflows/package-tests.yml/badge.svg)](https://github.com/The-AI-Alliance/semiont/actions/workflows/package-tests.yml?query=branch%3Amain+is%3Asuccess+job%3A%22Test+graph%22)
4
5
 
5
6
  Graph database abstraction with Neo4j, Neptune, JanusGraph, and in-memory implementations.
@@ -44,32 +45,56 @@ const envConfig: EnvironmentConfig = {
44
45
  };
45
46
 
46
47
  const graph = await getGraphDatabase(envConfig);
47
-
48
- // Create a resource
49
- const resource = await graph.createResource({
50
- id: 'res_123',
51
- type: 'Document',
52
- title: 'My Document'
48
+ await graph.connect();
49
+
50
+ // Create a document
51
+ const document = await graph.createDocument({
52
+ id: 'doc-123',
53
+ name: 'My Document',
54
+ format: 'text/plain',
55
+ entityTypes: ['Person', 'Organization'],
56
+ archived: false,
57
+ createdAt: new Date().toISOString(),
58
+ updatedAt: new Date().toISOString()
53
59
  });
54
60
 
55
61
  // Create an annotation
56
62
  const annotation = await graph.createAnnotation({
57
- target: { source: 'res_123' },
58
- body: { value: 'A note' },
59
- motivation: 'commenting'
63
+ id: 'anno-456',
64
+ target: { source: 'doc-123' },
65
+ body: [{ value: 'Important note' }],
66
+ creator: 'user-123',
67
+ created: new Date().toISOString()
60
68
  });
69
+
70
+ // Query relationships
71
+ const annotations = await graph.getAnnotationsForDocument('doc-123');
61
72
  ```
62
73
 
63
- ## Supported Implementations
74
+ ## Features
75
+
76
+ - 🔌 **Multiple Providers** - Neo4j, AWS Neptune, JanusGraph, In-memory
77
+ - 🎯 **Unified Interface** - Same API across all providers
78
+ - 📊 **W3C Compliant** - Full Web Annotation Data Model support
79
+ - 🔄 **Event-Driven Updates** - Sync from Event Store projections
80
+ - 🚀 **Optional Projection** - Graph is optional, core features work without it
81
+ - 🔍 **Rich Queries** - Cross-document relationships and entity searches
64
82
 
65
- - **Neo4j** - Cypher-based graph database
66
- - **Neptune** - AWS managed Gremlin-based graph database
67
- - **JanusGraph** - Open-source Gremlin-based graph database
68
- - **MemoryGraph** - In-memory implementation for testing
83
+ ## Documentation
69
84
 
70
- ## Configuration
85
+ - [API Reference](./docs/API.md) - Complete API documentation
86
+ - [Architecture](./docs/ARCHITECTURE.md) - System design and principles
87
+ - [Provider Guide](./docs/PROVIDERS.md) - Provider-specific details
88
+
89
+ ## Examples
90
+
91
+ - [Basic Example](./examples/basic.ts) - Simple graph operations
92
+ - [Multi-Provider](./examples/multi-provider.ts) - Switching between providers
93
+
94
+ ## Supported Implementations
71
95
 
72
96
  ### Neo4j
97
+ Native graph database with Cypher query language.
73
98
 
74
99
  ```typescript
75
100
  const envConfig = {
@@ -85,7 +110,8 @@ const envConfig = {
85
110
  };
86
111
  ```
87
112
 
88
- ### Neptune
113
+ ### AWS Neptune
114
+ Managed graph database supporting Gremlin.
89
115
 
90
116
  ```typescript
91
117
  const envConfig = {
@@ -101,6 +127,7 @@ const envConfig = {
101
127
  ```
102
128
 
103
129
  ### JanusGraph
130
+ Open-source distributed graph database.
104
131
 
105
132
  ```typescript
106
133
  const envConfig = {
@@ -117,6 +144,7 @@ const envConfig = {
117
144
  ```
118
145
 
119
146
  ### MemoryGraph
147
+ In-memory implementation for development and testing.
120
148
 
121
149
  ```typescript
122
150
  const envConfig = {
@@ -130,8 +158,74 @@ const envConfig = {
130
158
 
131
159
  ## API Overview
132
160
 
133
- See [docs/GraphInterface.md](docs/GraphInterface.md) for complete API documentation.
161
+ ### Core Operations
162
+
163
+ ```typescript
164
+ // Document operations
165
+ await graph.createDocument(document);
166
+ await graph.getDocument(id);
167
+ await graph.updateDocument(id, updates);
168
+ await graph.deleteDocument(id);
169
+
170
+ // Annotation operations
171
+ await graph.createAnnotation(annotation);
172
+ await graph.getAnnotation(id);
173
+ await graph.updateAnnotation(id, updates);
174
+ await graph.deleteAnnotation(id);
175
+
176
+ // Query operations
177
+ await graph.getAnnotationsForDocument(documentId);
178
+ await graph.findDocumentsByEntityTypes(['Person']);
179
+ await graph.findAnnotationsByTarget(targetId);
180
+
181
+ // Tag collections
182
+ await graph.getEntityTypes();
183
+ await graph.addEntityType('NewType');
184
+ ```
185
+
186
+ ## Graph as Optional Projection
187
+
188
+ The graph database is designed as an **optional read-only projection**:
189
+
190
+ ### Works WITHOUT Graph
191
+ ✅ Viewing resources and annotations
192
+ ✅ Creating/updating/deleting annotations
193
+ ✅ Single-document workflows
194
+ ✅ Real-time SSE updates
195
+
196
+ ### Requires Graph
197
+ ❌ Cross-document relationship queries
198
+ ❌ Entity-based search across resources
199
+ ❌ Graph visualization
200
+ ❌ Network analysis
201
+
202
+ See [Architecture Documentation](./docs/ARCHITECTURE.md) for details.
203
+
204
+ ## Performance
205
+
206
+ | Provider | Setup | Speed | Scalability | Persistence |
207
+ |----------|-------|-------|-------------|-------------|
208
+ | Neo4j | Medium | Fast | High | Yes |
209
+ | Neptune | Complex | Medium | Very High | Yes |
210
+ | JanusGraph | Complex | Medium | Very High | Yes |
211
+ | Memory | None | Very Fast | Low | No |
212
+
213
+ ## Development
214
+
215
+ ```bash
216
+ # Install dependencies
217
+ npm install
218
+
219
+ # Build package
220
+ npm run build
221
+
222
+ # Run tests
223
+ npm test
224
+
225
+ # Type checking
226
+ npm run typecheck
227
+ ```
134
228
 
135
229
  ## License
136
230
 
137
- Apache-2.0
231
+ Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semiont/graph",
3
- "version": "0.2.28",
3
+ "version": "0.2.29-build.42",
4
4
  "type": "module",
5
5
  "description": "Graph database abstraction with Neo4j, Neptune, JanusGraph, and in-memory implementations",
6
6
  "main": "./dist/index.js",