@semiont/graph 0.5.5 → 0.5.7

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 (50) hide show
  1. package/README.md +78 -79
  2. package/dist/bowser-D72SKZAH.js +2820 -0
  3. package/dist/bowser-D72SKZAH.js.map +1 -0
  4. package/dist/chunk-27S56UPF.js +4754 -0
  5. package/dist/chunk-27S56UPF.js.map +1 -0
  6. package/dist/chunk-4UP2SG3N.js +2095 -0
  7. package/dist/chunk-4UP2SG3N.js.map +1 -0
  8. package/dist/chunk-6DEJAFBY.js +125 -0
  9. package/dist/chunk-6DEJAFBY.js.map +1 -0
  10. package/dist/chunk-7UD62TQI.js +3317 -0
  11. package/dist/chunk-7UD62TQI.js.map +1 -0
  12. package/dist/chunk-B2W57CWL.js +47 -0
  13. package/dist/chunk-B2W57CWL.js.map +1 -0
  14. package/dist/chunk-DCLCNCC5.js +1051 -0
  15. package/dist/chunk-DCLCNCC5.js.map +1 -0
  16. package/dist/chunk-KE4TRQI4.js +576 -0
  17. package/dist/chunk-KE4TRQI4.js.map +1 -0
  18. package/dist/chunk-MWZWSKZD.js +1166 -0
  19. package/dist/chunk-MWZWSKZD.js.map +1 -0
  20. package/dist/chunk-V4VXQDJC.js +436 -0
  21. package/dist/chunk-V4VXQDJC.js.map +1 -0
  22. package/dist/dist-es-2CKOZ7UJ.js +69 -0
  23. package/dist/dist-es-2CKOZ7UJ.js.map +1 -0
  24. package/dist/dist-es-CUJAAJXF.js +6632 -0
  25. package/dist/dist-es-CUJAAJXF.js.map +1 -0
  26. package/dist/dist-es-LM7J2FUI.js +87 -0
  27. package/dist/dist-es-LM7J2FUI.js.map +1 -0
  28. package/dist/dist-es-QTXLRLLM.js +169 -0
  29. package/dist/dist-es-QTXLRLLM.js.map +1 -0
  30. package/dist/dist-es-R223S2WP.js +484 -0
  31. package/dist/dist-es-R223S2WP.js.map +1 -0
  32. package/dist/dist-es-SI3C7IEH.js +22 -0
  33. package/dist/dist-es-SI3C7IEH.js.map +1 -0
  34. package/dist/dist-es-XNPYIYQW.js +314 -0
  35. package/dist/dist-es-XNPYIYQW.js.map +1 -0
  36. package/dist/dist-es-ZYIOCGDF.js +376 -0
  37. package/dist/dist-es-ZYIOCGDF.js.map +1 -0
  38. package/dist/event-streams-AI5RIQ2F.js +1376 -0
  39. package/dist/event-streams-AI5RIQ2F.js.map +1 -0
  40. package/dist/index.js +2 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/loadSso-6PVX5KA7.js +576 -0
  43. package/dist/loadSso-6PVX5KA7.js.map +1 -0
  44. package/dist/signin-GV4P4PGF.js +662 -0
  45. package/dist/signin-GV4P4PGF.js.map +1 -0
  46. package/dist/sso-oidc-WFVKSVW6.js +829 -0
  47. package/dist/sso-oidc-WFVKSVW6.js.map +1 -0
  48. package/dist/sts-7N7QMJRQ.js +1244 -0
  49. package/dist/sts-7N7QMJRQ.js.map +1 -0
  50. package/package.json +13 -8
package/README.md CHANGED
@@ -39,45 +39,45 @@ The examples below show direct usage for **testing, CLI tools, or standalone app
39
39
 
40
40
  ```typescript
41
41
  import { getGraphDatabase } from '@semiont/graph';
42
- import type { EnvironmentConfig } from '@semiont/core';
43
-
44
- const envConfig: EnvironmentConfig = {
45
- services: {
46
- graph: {
47
- type: 'neo4j',
48
- uri: 'bolt://localhost:7687',
49
- username: 'neo4j',
50
- password: 'password',
51
- database: 'neo4j'
52
- }
53
- }
42
+ import { resourceId, annotationId } from '@semiont/core';
43
+ import type { GraphServiceConfig } from '@semiont/core';
44
+
45
+ // The `services.graph` block of an environment config
46
+ const graphConfig: GraphServiceConfig = {
47
+ platform: { type: 'container' },
48
+ type: 'neo4j',
49
+ uri: 'bolt://localhost:7687',
50
+ username: 'neo4j',
51
+ password: 'password',
52
+ database: 'neo4j'
54
53
  };
55
54
 
56
- const graph = await getGraphDatabase(envConfig);
57
- await graph.connect();
55
+ // Singleton factory connects automatically
56
+ const graph = await getGraphDatabase(graphConfig);
58
57
 
59
- // Create a document
60
- const document = await graph.createDocument({
61
- id: 'doc-123',
58
+ // Create a resource (W3C ResourceDescriptor)
59
+ const resource = await graph.createResource({
60
+ '@context': 'https://www.w3.org/ns/ldp',
61
+ '@id': resourceId('doc-123'),
62
62
  name: 'My Document',
63
- format: 'text/plain',
64
63
  entityTypes: ['Person', 'Organization'],
65
- archived: false,
66
- createdAt: new Date().toISOString(),
67
- updatedAt: new Date().toISOString()
64
+ representations: [{ mediaType: 'text/plain' }],
65
+ dateCreated: new Date().toISOString()
68
66
  });
69
67
 
70
- // Create an annotation
68
+ // Create an annotation (W3C Web Annotation; highlights carry no body)
71
69
  const annotation = await graph.createAnnotation({
72
- id: 'anno-456',
73
- target: { source: 'doc-123' },
74
- body: [{ value: 'Important note' }],
75
- creator: 'user-123',
76
- created: new Date().toISOString()
70
+ id: annotationId('anno-456'),
71
+ motivation: 'highlighting',
72
+ target: {
73
+ source: 'doc-123',
74
+ selector: { type: 'TextQuoteSelector', exact: 'Important phrase', prefix: '', suffix: '' }
75
+ },
76
+ creator: { '@type': 'Person', name: 'user-123' }
77
77
  });
78
78
 
79
79
  // Query relationships
80
- const annotations = await graph.getAnnotationsForDocument('doc-123');
80
+ const annotations = await graph.getResourceAnnotations(resourceId('doc-123'));
81
81
  ```
82
82
 
83
83
  ## Features
@@ -92,64 +92,56 @@ const annotations = await graph.getAnnotationsForDocument('doc-123');
92
92
  ## Documentation
93
93
 
94
94
  - [API Reference](./docs/API.md) - Complete API documentation
95
+ - [GraphDatabase Interface](./docs/GraphInterface.md) - The full interface contract
95
96
  - [Architecture](./docs/ARCHITECTURE.md) - System design and principles
96
97
  - [Eventual Consistency](./docs/EVENTUAL-CONSISTENCY.md) - Order-independent projections and race condition handling
97
- - [Provider Guide](./docs/PROVIDERS.md) - Provider-specific details
98
-
99
- ## Examples
100
-
101
- - [Basic Example](./examples/basic.ts) - Simple graph operations
102
- - [Multi-Provider](./examples/multi-provider.ts) - Switching between providers
103
98
 
104
99
  ## Supported Implementations
105
100
 
101
+ Each example below is the `services.graph` block of an environment config — pass it directly to `getGraphDatabase()`. (`platform` is required by the config schema but not used by this package.)
102
+
106
103
  ### Neo4j
107
104
  Native graph database with Cypher query language.
108
105
 
109
106
  ```typescript
110
- const envConfig = {
111
- services: {
112
- graph: {
113
- type: 'neo4j',
114
- uri: 'bolt://localhost:7687',
115
- username: 'neo4j',
116
- password: 'password',
117
- database: 'neo4j'
118
- }
119
- }
107
+ const graphConfig: GraphServiceConfig = {
108
+ platform: { type: 'container' },
109
+ type: 'neo4j',
110
+ uri: 'bolt://localhost:7687',
111
+ username: 'neo4j',
112
+ password: 'password',
113
+ database: 'neo4j'
120
114
  };
121
115
  ```
122
116
 
117
+ `uri`, `username`, `password`, and `database` support `${ENV_VAR}` placeholders, evaluated at startup.
118
+
123
119
  ### AWS Neptune
124
120
  Managed graph database supporting Gremlin.
125
121
 
126
122
  ```typescript
127
- const envConfig = {
128
- services: {
129
- graph: {
130
- type: 'neptune',
131
- endpoint: 'wss://your-cluster.neptune.amazonaws.com:8182/gremlin',
132
- port: 8182,
133
- region: 'us-east-1'
134
- }
135
- }
123
+ const graphConfig: GraphServiceConfig = {
124
+ platform: { type: 'aws' },
125
+ type: 'neptune',
126
+ endpoint: 'wss://your-cluster.neptune.amazonaws.com:8182/gremlin',
127
+ port: 8182,
128
+ region: 'us-east-1'
136
129
  };
137
130
  ```
138
131
 
132
+ If `endpoint` is omitted, the cluster endpoint is discovered via the AWS SDK using `region`.
133
+
139
134
  ### JanusGraph
140
135
  Open-source distributed graph database.
141
136
 
142
137
  ```typescript
143
- const envConfig = {
144
- services: {
145
- graph: {
146
- type: 'janusgraph',
147
- host: 'localhost',
148
- port: 8182,
149
- storage: 'cassandra',
150
- index: 'elasticsearch'
151
- }
152
- }
138
+ const graphConfig: GraphServiceConfig = {
139
+ platform: { type: 'container' },
140
+ type: 'janusgraph',
141
+ host: 'localhost',
142
+ port: 8182,
143
+ storage: 'cassandra',
144
+ index: 'elasticsearch'
153
145
  };
154
146
  ```
155
147
 
@@ -157,12 +149,9 @@ const envConfig = {
157
149
  In-memory implementation for development and testing.
158
150
 
159
151
  ```typescript
160
- const envConfig = {
161
- services: {
162
- graph: {
163
- type: 'memory'
164
- }
165
- }
152
+ const graphConfig: GraphServiceConfig = {
153
+ platform: { type: 'posix' },
154
+ type: 'memory'
166
155
  };
167
156
  ```
168
157
 
@@ -171,28 +160,38 @@ const envConfig = {
171
160
  ### Core Operations
172
161
 
173
162
  ```typescript
174
- // Document operations
175
- await graph.createDocument(document);
176
- await graph.getDocument(id);
177
- await graph.updateDocument(id, updates);
178
- await graph.deleteDocument(id);
163
+ // Resource operations
164
+ await graph.createResource(resource);
165
+ await graph.getResource(id);
166
+ await graph.updateResource(id, updates);
167
+ await graph.deleteResource(id);
168
+ await graph.listResources({ entityTypes: ['Person'] });
169
+ await graph.searchResources('query');
179
170
 
180
171
  // Annotation operations
181
- await graph.createAnnotation(annotation);
172
+ await graph.createAnnotation(input);
182
173
  await graph.getAnnotation(id);
183
174
  await graph.updateAnnotation(id, updates);
184
175
  await graph.deleteAnnotation(id);
176
+ await graph.listAnnotations({ resourceId });
177
+
178
+ // Relationship queries
179
+ await graph.getResourceAnnotations(resourceId);
180
+ await graph.getHighlights(resourceId);
181
+ await graph.getReferences(resourceId);
182
+ await graph.getResourceReferencedBy(resourceId);
185
183
 
186
- // Query operations
187
- await graph.getAnnotationsForDocument(documentId);
188
- await graph.findDocumentsByEntityTypes(['Person']);
189
- await graph.findAnnotationsByTarget(targetId);
184
+ // Graph traversal
185
+ await graph.getResourceConnections(resourceId);
186
+ await graph.findPath(fromResourceId, toResourceId);
190
187
 
191
188
  // Tag collections
192
189
  await graph.getEntityTypes();
193
190
  await graph.addEntityType('NewType');
194
191
  ```
195
192
 
193
+ See [GraphInterface.md](./docs/GraphInterface.md) for the full contract.
194
+
196
195
  ## Graph as Optional Projection
197
196
 
198
197
  The graph database is designed as an **optional read-only projection**: