@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.
- package/README.md +78 -79
- package/dist/bowser-D72SKZAH.js +2820 -0
- package/dist/bowser-D72SKZAH.js.map +1 -0
- package/dist/chunk-27S56UPF.js +4754 -0
- package/dist/chunk-27S56UPF.js.map +1 -0
- package/dist/chunk-4UP2SG3N.js +2095 -0
- package/dist/chunk-4UP2SG3N.js.map +1 -0
- package/dist/chunk-6DEJAFBY.js +125 -0
- package/dist/chunk-6DEJAFBY.js.map +1 -0
- package/dist/chunk-7UD62TQI.js +3317 -0
- package/dist/chunk-7UD62TQI.js.map +1 -0
- package/dist/chunk-B2W57CWL.js +47 -0
- package/dist/chunk-B2W57CWL.js.map +1 -0
- package/dist/chunk-DCLCNCC5.js +1051 -0
- package/dist/chunk-DCLCNCC5.js.map +1 -0
- package/dist/chunk-KE4TRQI4.js +576 -0
- package/dist/chunk-KE4TRQI4.js.map +1 -0
- package/dist/chunk-MWZWSKZD.js +1166 -0
- package/dist/chunk-MWZWSKZD.js.map +1 -0
- package/dist/chunk-V4VXQDJC.js +436 -0
- package/dist/chunk-V4VXQDJC.js.map +1 -0
- package/dist/dist-es-2CKOZ7UJ.js +69 -0
- package/dist/dist-es-2CKOZ7UJ.js.map +1 -0
- package/dist/dist-es-CUJAAJXF.js +6632 -0
- package/dist/dist-es-CUJAAJXF.js.map +1 -0
- package/dist/dist-es-LM7J2FUI.js +87 -0
- package/dist/dist-es-LM7J2FUI.js.map +1 -0
- package/dist/dist-es-QTXLRLLM.js +169 -0
- package/dist/dist-es-QTXLRLLM.js.map +1 -0
- package/dist/dist-es-R223S2WP.js +484 -0
- package/dist/dist-es-R223S2WP.js.map +1 -0
- package/dist/dist-es-SI3C7IEH.js +22 -0
- package/dist/dist-es-SI3C7IEH.js.map +1 -0
- package/dist/dist-es-XNPYIYQW.js +314 -0
- package/dist/dist-es-XNPYIYQW.js.map +1 -0
- package/dist/dist-es-ZYIOCGDF.js +376 -0
- package/dist/dist-es-ZYIOCGDF.js.map +1 -0
- package/dist/event-streams-AI5RIQ2F.js +1376 -0
- package/dist/event-streams-AI5RIQ2F.js.map +1 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/loadSso-6PVX5KA7.js +576 -0
- package/dist/loadSso-6PVX5KA7.js.map +1 -0
- package/dist/signin-GV4P4PGF.js +662 -0
- package/dist/signin-GV4P4PGF.js.map +1 -0
- package/dist/sso-oidc-WFVKSVW6.js +829 -0
- package/dist/sso-oidc-WFVKSVW6.js.map +1 -0
- package/dist/sts-7N7QMJRQ.js +1244 -0
- package/dist/sts-7N7QMJRQ.js.map +1 -0
- 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
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
57
|
-
await
|
|
55
|
+
// Singleton factory — connects automatically
|
|
56
|
+
const graph = await getGraphDatabase(graphConfig);
|
|
58
57
|
|
|
59
|
-
// Create a
|
|
60
|
-
const
|
|
61
|
-
|
|
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
|
-
|
|
66
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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.
|
|
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
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
//
|
|
175
|
-
await graph.
|
|
176
|
-
await graph.
|
|
177
|
-
await graph.
|
|
178
|
-
await graph.
|
|
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(
|
|
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
|
-
//
|
|
187
|
-
await graph.
|
|
188
|
-
await graph.
|
|
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**:
|