@semiont/graph 0.2.28-build.40
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 +231 -0
- package/dist/index.d.ts +355 -0
- package/dist/index.js +2708 -0
- package/dist/index.js.map +1 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# @semiont/graph
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@semiont/graph)
|
|
4
|
+
[](https://github.com/The-AI-Alliance/semiont/actions/workflows/package-tests.yml?query=branch%3Amain+is%3Asuccess+job%3A%22Test+graph%22)
|
|
5
|
+
|
|
6
|
+
Graph database abstraction with Neo4j, Neptune, JanusGraph, and in-memory implementations.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @semiont/graph
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Then install the peer dependency for your chosen graph database:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# For Neo4j
|
|
18
|
+
npm install neo4j-driver
|
|
19
|
+
|
|
20
|
+
# For Neptune or JanusGraph
|
|
21
|
+
npm install gremlin
|
|
22
|
+
|
|
23
|
+
# For Neptune with AWS SDK
|
|
24
|
+
npm install @aws-sdk/client-neptune
|
|
25
|
+
|
|
26
|
+
# MemoryGraph has no dependencies
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { getGraphDatabase } from '@semiont/graph';
|
|
33
|
+
import type { EnvironmentConfig } from '@semiont/core';
|
|
34
|
+
|
|
35
|
+
const envConfig: EnvironmentConfig = {
|
|
36
|
+
services: {
|
|
37
|
+
graph: {
|
|
38
|
+
type: 'neo4j',
|
|
39
|
+
uri: 'bolt://localhost:7687',
|
|
40
|
+
username: 'neo4j',
|
|
41
|
+
password: 'password',
|
|
42
|
+
database: 'neo4j'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const graph = await getGraphDatabase(envConfig);
|
|
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()
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Create an annotation
|
|
62
|
+
const annotation = await graph.createAnnotation({
|
|
63
|
+
id: 'anno-456',
|
|
64
|
+
target: { source: 'doc-123' },
|
|
65
|
+
body: [{ value: 'Important note' }],
|
|
66
|
+
creator: 'user-123',
|
|
67
|
+
created: new Date().toISOString()
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Query relationships
|
|
71
|
+
const annotations = await graph.getAnnotationsForDocument('doc-123');
|
|
72
|
+
```
|
|
73
|
+
|
|
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
|
|
82
|
+
|
|
83
|
+
## Documentation
|
|
84
|
+
|
|
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
|
|
95
|
+
|
|
96
|
+
### Neo4j
|
|
97
|
+
Native graph database with Cypher query language.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const envConfig = {
|
|
101
|
+
services: {
|
|
102
|
+
graph: {
|
|
103
|
+
type: 'neo4j',
|
|
104
|
+
uri: 'bolt://localhost:7687',
|
|
105
|
+
username: 'neo4j',
|
|
106
|
+
password: 'password',
|
|
107
|
+
database: 'neo4j'
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### AWS Neptune
|
|
114
|
+
Managed graph database supporting Gremlin.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
const envConfig = {
|
|
118
|
+
services: {
|
|
119
|
+
graph: {
|
|
120
|
+
type: 'neptune',
|
|
121
|
+
endpoint: 'wss://your-cluster.neptune.amazonaws.com:8182/gremlin',
|
|
122
|
+
port: 8182,
|
|
123
|
+
region: 'us-east-1'
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### JanusGraph
|
|
130
|
+
Open-source distributed graph database.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
const envConfig = {
|
|
134
|
+
services: {
|
|
135
|
+
graph: {
|
|
136
|
+
type: 'janusgraph',
|
|
137
|
+
host: 'localhost',
|
|
138
|
+
port: 8182,
|
|
139
|
+
storage: 'cassandra',
|
|
140
|
+
index: 'elasticsearch'
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### MemoryGraph
|
|
147
|
+
In-memory implementation for development and testing.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const envConfig = {
|
|
151
|
+
services: {
|
|
152
|
+
graph: {
|
|
153
|
+
type: 'memory'
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## API Overview
|
|
160
|
+
|
|
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
|
+
```
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
Apache-2.0
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { components, ResourceUri, AnnotationUri } from '@semiont/api-client';
|
|
2
|
+
import { UpdateResourceInput, ResourceFilter, CreateAnnotationInternal, ResourceId, AnnotationCategory, AnnotationId, GraphConnection, GraphPath, EntityTypeStats, EnvironmentConfig } from '@semiont/core';
|
|
3
|
+
|
|
4
|
+
type ResourceDescriptor$4 = components['schemas']['ResourceDescriptor'];
|
|
5
|
+
type Annotation$4 = components['schemas']['Annotation'];
|
|
6
|
+
interface GraphDatabase {
|
|
7
|
+
connect(): Promise<void>;
|
|
8
|
+
disconnect(): Promise<void>;
|
|
9
|
+
isConnected(): boolean;
|
|
10
|
+
createResource(resource: ResourceDescriptor$4): Promise<ResourceDescriptor$4>;
|
|
11
|
+
getResource(id: ResourceUri): Promise<ResourceDescriptor$4 | null>;
|
|
12
|
+
updateResource(id: ResourceUri, input: UpdateResourceInput): Promise<ResourceDescriptor$4>;
|
|
13
|
+
deleteResource(id: ResourceUri): Promise<void>;
|
|
14
|
+
listResources(filter: ResourceFilter): Promise<{
|
|
15
|
+
resources: ResourceDescriptor$4[];
|
|
16
|
+
total: number;
|
|
17
|
+
}>;
|
|
18
|
+
searchResources(query: string, limit?: number): Promise<ResourceDescriptor$4[]>;
|
|
19
|
+
createAnnotation(input: CreateAnnotationInternal): Promise<Annotation$4>;
|
|
20
|
+
getAnnotation(id: AnnotationUri): Promise<Annotation$4 | null>;
|
|
21
|
+
updateAnnotation(id: AnnotationUri, updates: Partial<Annotation$4>): Promise<Annotation$4>;
|
|
22
|
+
deleteAnnotation(id: AnnotationUri): Promise<void>;
|
|
23
|
+
listAnnotations(filter: {
|
|
24
|
+
resourceId?: ResourceId;
|
|
25
|
+
type?: AnnotationCategory;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
annotations: Annotation$4[];
|
|
28
|
+
total: number;
|
|
29
|
+
}>;
|
|
30
|
+
getHighlights(resourceId: ResourceId): Promise<Annotation$4[]>;
|
|
31
|
+
resolveReference(annotationId: AnnotationId, source: ResourceId): Promise<Annotation$4>;
|
|
32
|
+
getReferences(resourceId: ResourceId): Promise<Annotation$4[]>;
|
|
33
|
+
getEntityReferences(resourceId: ResourceId, entityTypes?: string[]): Promise<Annotation$4[]>;
|
|
34
|
+
getResourceAnnotations(resourceId: ResourceId): Promise<Annotation$4[]>;
|
|
35
|
+
getResourceReferencedBy(resourceUri: ResourceUri, motivation?: string): Promise<Annotation$4[]>;
|
|
36
|
+
getResourceConnections(resourceId: ResourceId): Promise<GraphConnection[]>;
|
|
37
|
+
findPath(fromResourceId: ResourceId, toResourceId: ResourceId, maxDepth?: number): Promise<GraphPath[]>;
|
|
38
|
+
getEntityTypeStats(): Promise<EntityTypeStats[]>;
|
|
39
|
+
getStats(): Promise<{
|
|
40
|
+
resourceCount: number;
|
|
41
|
+
annotationCount: number;
|
|
42
|
+
highlightCount: number;
|
|
43
|
+
referenceCount: number;
|
|
44
|
+
entityReferenceCount: number;
|
|
45
|
+
entityTypes: Record<string, number>;
|
|
46
|
+
contentTypes: Record<string, number>;
|
|
47
|
+
}>;
|
|
48
|
+
createAnnotations(inputs: CreateAnnotationInternal[]): Promise<Annotation$4[]>;
|
|
49
|
+
resolveReferences(inputs: {
|
|
50
|
+
annotationId: AnnotationId;
|
|
51
|
+
source: ResourceId;
|
|
52
|
+
}[]): Promise<Annotation$4[]>;
|
|
53
|
+
detectAnnotations(resourceId: ResourceId): Promise<Annotation$4[]>;
|
|
54
|
+
getEntityTypes(): Promise<string[]>;
|
|
55
|
+
addEntityType(tag: string): Promise<void>;
|
|
56
|
+
addEntityTypes(tags: string[]): Promise<void>;
|
|
57
|
+
generateId(): string;
|
|
58
|
+
clearDatabase(): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type GraphDatabaseType = 'neptune' | 'neo4j' | 'janusgraph' | 'memory';
|
|
62
|
+
interface GraphDatabaseConfig {
|
|
63
|
+
type: GraphDatabaseType;
|
|
64
|
+
neptuneEndpoint?: string;
|
|
65
|
+
neptunePort?: number;
|
|
66
|
+
neptuneRegion?: string;
|
|
67
|
+
neo4jUri?: string;
|
|
68
|
+
neo4jUsername?: string;
|
|
69
|
+
neo4jPassword?: string;
|
|
70
|
+
neo4jDatabase?: string;
|
|
71
|
+
janusHost?: string;
|
|
72
|
+
janusPort?: number;
|
|
73
|
+
janusStorageBackend?: 'cassandra' | 'hbase' | 'berkeleydb';
|
|
74
|
+
janusIndexBackend?: 'elasticsearch' | 'solr' | 'lucene';
|
|
75
|
+
}
|
|
76
|
+
declare function createGraphDatabase(config: GraphDatabaseConfig, envConfig: EnvironmentConfig): GraphDatabase;
|
|
77
|
+
declare function getGraphDatabase(envConfig: EnvironmentConfig): Promise<GraphDatabase>;
|
|
78
|
+
declare function closeGraphDatabase(): Promise<void>;
|
|
79
|
+
|
|
80
|
+
type ResourceDescriptor$3 = components['schemas']['ResourceDescriptor'];
|
|
81
|
+
type Annotation$3 = components['schemas']['Annotation'];
|
|
82
|
+
declare class Neo4jGraphDatabase implements GraphDatabase {
|
|
83
|
+
private driver;
|
|
84
|
+
private connected;
|
|
85
|
+
private config;
|
|
86
|
+
private entityTypesCollection;
|
|
87
|
+
constructor(config?: {
|
|
88
|
+
uri?: string;
|
|
89
|
+
username?: string;
|
|
90
|
+
password?: string;
|
|
91
|
+
database?: string;
|
|
92
|
+
});
|
|
93
|
+
connect(): Promise<void>;
|
|
94
|
+
disconnect(): Promise<void>;
|
|
95
|
+
isConnected(): boolean;
|
|
96
|
+
private getSession;
|
|
97
|
+
private ensureSchemaExists;
|
|
98
|
+
createResource(resource: ResourceDescriptor$3): Promise<ResourceDescriptor$3>;
|
|
99
|
+
getResource(id: ResourceUri): Promise<ResourceDescriptor$3 | null>;
|
|
100
|
+
updateResource(id: ResourceUri, input: UpdateResourceInput): Promise<ResourceDescriptor$3>;
|
|
101
|
+
deleteResource(id: ResourceUri): Promise<void>;
|
|
102
|
+
listResources(filter: ResourceFilter): Promise<{
|
|
103
|
+
resources: ResourceDescriptor$3[];
|
|
104
|
+
total: number;
|
|
105
|
+
}>;
|
|
106
|
+
searchResources(query: string, limit?: number): Promise<ResourceDescriptor$3[]>;
|
|
107
|
+
createAnnotation(input: CreateAnnotationInternal): Promise<Annotation$3>;
|
|
108
|
+
getAnnotation(id: AnnotationUri): Promise<Annotation$3 | null>;
|
|
109
|
+
updateAnnotation(id: AnnotationUri, updates: Partial<Annotation$3>): Promise<Annotation$3>;
|
|
110
|
+
deleteAnnotation(id: AnnotationUri): Promise<void>;
|
|
111
|
+
listAnnotations(filter: {
|
|
112
|
+
resourceId?: ResourceId;
|
|
113
|
+
type?: AnnotationCategory;
|
|
114
|
+
}): Promise<{
|
|
115
|
+
annotations: Annotation$3[];
|
|
116
|
+
total: number;
|
|
117
|
+
}>;
|
|
118
|
+
getHighlights(resourceId: ResourceId): Promise<Annotation$3[]>;
|
|
119
|
+
resolveReference(annotationId: AnnotationId, source: ResourceId): Promise<Annotation$3>;
|
|
120
|
+
getReferences(resourceId: ResourceId): Promise<Annotation$3[]>;
|
|
121
|
+
getEntityReferences(resourceId: ResourceId, entityTypes?: string[]): Promise<Annotation$3[]>;
|
|
122
|
+
getResourceAnnotations(resourceId: ResourceId): Promise<Annotation$3[]>;
|
|
123
|
+
getResourceReferencedBy(resourceUri: ResourceUri, motivation?: string): Promise<Annotation$3[]>;
|
|
124
|
+
getResourceConnections(resourceId: ResourceId): Promise<GraphConnection[]>;
|
|
125
|
+
findPath(fromResourceId: string, toResourceId: string, maxDepth?: number): Promise<GraphPath[]>;
|
|
126
|
+
getEntityTypeStats(): Promise<EntityTypeStats[]>;
|
|
127
|
+
getStats(): Promise<{
|
|
128
|
+
resourceCount: number;
|
|
129
|
+
annotationCount: number;
|
|
130
|
+
highlightCount: number;
|
|
131
|
+
referenceCount: number;
|
|
132
|
+
entityReferenceCount: number;
|
|
133
|
+
entityTypes: Record<string, number>;
|
|
134
|
+
contentTypes: Record<string, number>;
|
|
135
|
+
}>;
|
|
136
|
+
createAnnotations(inputs: CreateAnnotationInternal[]): Promise<Annotation$3[]>;
|
|
137
|
+
resolveReferences(inputs: {
|
|
138
|
+
annotationId: AnnotationId;
|
|
139
|
+
source: ResourceId;
|
|
140
|
+
}[]): Promise<Annotation$3[]>;
|
|
141
|
+
detectAnnotations(_resourceId: ResourceId): Promise<Annotation$3[]>;
|
|
142
|
+
getEntityTypes(): Promise<string[]>;
|
|
143
|
+
addEntityType(tag: string): Promise<void>;
|
|
144
|
+
addEntityTypes(tags: string[]): Promise<void>;
|
|
145
|
+
private initializeTagCollections;
|
|
146
|
+
private persistTagCollection;
|
|
147
|
+
generateId(): string;
|
|
148
|
+
clearDatabase(): Promise<void>;
|
|
149
|
+
private parseResourceNode;
|
|
150
|
+
private parseAnnotationNode;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
type ResourceDescriptor$2 = components['schemas']['ResourceDescriptor'];
|
|
154
|
+
type Annotation$2 = components['schemas']['Annotation'];
|
|
155
|
+
declare class NeptuneGraphDatabase implements GraphDatabase {
|
|
156
|
+
private connected;
|
|
157
|
+
private neptuneEndpoint?;
|
|
158
|
+
private neptunePort;
|
|
159
|
+
private region?;
|
|
160
|
+
private g;
|
|
161
|
+
private connection;
|
|
162
|
+
private fetchAnnotationsWithEntityTypes;
|
|
163
|
+
constructor(config?: {
|
|
164
|
+
endpoint?: string;
|
|
165
|
+
port?: number;
|
|
166
|
+
region?: string;
|
|
167
|
+
});
|
|
168
|
+
private discoverNeptuneEndpoint;
|
|
169
|
+
connect(): Promise<void>;
|
|
170
|
+
disconnect(): Promise<void>;
|
|
171
|
+
isConnected(): boolean;
|
|
172
|
+
createResource(resource: ResourceDescriptor$2): Promise<ResourceDescriptor$2>;
|
|
173
|
+
getResource(id: ResourceUri): Promise<ResourceDescriptor$2 | null>;
|
|
174
|
+
updateResource(id: ResourceUri, input: UpdateResourceInput): Promise<ResourceDescriptor$2>;
|
|
175
|
+
deleteResource(id: ResourceUri): Promise<void>;
|
|
176
|
+
listResources(filter: ResourceFilter): Promise<{
|
|
177
|
+
resources: ResourceDescriptor$2[];
|
|
178
|
+
total: number;
|
|
179
|
+
}>;
|
|
180
|
+
searchResources(query: string, limit?: number): Promise<ResourceDescriptor$2[]>;
|
|
181
|
+
createAnnotation(input: CreateAnnotationInternal): Promise<Annotation$2>;
|
|
182
|
+
getAnnotation(id: AnnotationUri): Promise<Annotation$2 | null>;
|
|
183
|
+
updateAnnotation(id: AnnotationUri, updates: Partial<Annotation$2>): Promise<Annotation$2>;
|
|
184
|
+
deleteAnnotation(id: AnnotationUri): Promise<void>;
|
|
185
|
+
listAnnotations(filter: {
|
|
186
|
+
resourceId?: ResourceId;
|
|
187
|
+
type?: AnnotationCategory;
|
|
188
|
+
}): Promise<{
|
|
189
|
+
annotations: Annotation$2[];
|
|
190
|
+
total: number;
|
|
191
|
+
}>;
|
|
192
|
+
getHighlights(resourceId: ResourceId): Promise<Annotation$2[]>;
|
|
193
|
+
resolveReference(annotationId: AnnotationId, source: ResourceId): Promise<Annotation$2>;
|
|
194
|
+
getReferences(resourceId: ResourceId): Promise<Annotation$2[]>;
|
|
195
|
+
getEntityReferences(resourceId: ResourceId, entityTypes?: string[]): Promise<Annotation$2[]>;
|
|
196
|
+
getResourceAnnotations(resourceId: ResourceId): Promise<Annotation$2[]>;
|
|
197
|
+
getResourceReferencedBy(resourceUri: ResourceUri, _motivation?: string): Promise<Annotation$2[]>;
|
|
198
|
+
getResourceConnections(resourceId: ResourceId): Promise<GraphConnection[]>;
|
|
199
|
+
findPath(fromResourceId: string, toResourceId: string, maxDepth?: number): Promise<GraphPath[]>;
|
|
200
|
+
getEntityTypeStats(): Promise<EntityTypeStats[]>;
|
|
201
|
+
getStats(): Promise<{
|
|
202
|
+
resourceCount: number;
|
|
203
|
+
annotationCount: number;
|
|
204
|
+
highlightCount: number;
|
|
205
|
+
referenceCount: number;
|
|
206
|
+
entityReferenceCount: number;
|
|
207
|
+
entityTypes: Record<string, number>;
|
|
208
|
+
contentTypes: Record<string, number>;
|
|
209
|
+
}>;
|
|
210
|
+
createAnnotations(inputs: CreateAnnotationInternal[]): Promise<Annotation$2[]>;
|
|
211
|
+
resolveReferences(inputs: {
|
|
212
|
+
annotationId: AnnotationId;
|
|
213
|
+
source: ResourceId;
|
|
214
|
+
}[]): Promise<Annotation$2[]>;
|
|
215
|
+
detectAnnotations(_resourceId: ResourceId): Promise<Annotation$2[]>;
|
|
216
|
+
private entityTypesCollection;
|
|
217
|
+
getEntityTypes(): Promise<string[]>;
|
|
218
|
+
addEntityType(tag: string): Promise<void>;
|
|
219
|
+
addEntityTypes(tags: string[]): Promise<void>;
|
|
220
|
+
private initializeTagCollections;
|
|
221
|
+
generateId(): string;
|
|
222
|
+
clearDatabase(): Promise<void>;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
type ResourceDescriptor$1 = components['schemas']['ResourceDescriptor'];
|
|
226
|
+
type Annotation$1 = components['schemas']['Annotation'];
|
|
227
|
+
declare class JanusGraphDatabase implements GraphDatabase {
|
|
228
|
+
private graphConfig;
|
|
229
|
+
private envConfig;
|
|
230
|
+
private connected;
|
|
231
|
+
private connection;
|
|
232
|
+
private g;
|
|
233
|
+
private entityTypesCollection;
|
|
234
|
+
constructor(graphConfig: {
|
|
235
|
+
host?: string;
|
|
236
|
+
port?: number;
|
|
237
|
+
storageBackend?: 'cassandra' | 'hbase' | 'berkeleydb';
|
|
238
|
+
indexBackend?: 'elasticsearch' | 'solr' | 'lucene';
|
|
239
|
+
}, envConfig: EnvironmentConfig);
|
|
240
|
+
connect(): Promise<void>;
|
|
241
|
+
disconnect(): Promise<void>;
|
|
242
|
+
isConnected(): boolean;
|
|
243
|
+
private initializeSchema;
|
|
244
|
+
private vertexToResource;
|
|
245
|
+
private getPropertyValue;
|
|
246
|
+
private fetchAnnotationsWithEntityTypes;
|
|
247
|
+
private vertexToAnnotation;
|
|
248
|
+
createResource(resource: ResourceDescriptor$1): Promise<ResourceDescriptor$1>;
|
|
249
|
+
getResource(id: ResourceUri): Promise<ResourceDescriptor$1 | null>;
|
|
250
|
+
updateResource(id: ResourceUri, input: UpdateResourceInput): Promise<ResourceDescriptor$1>;
|
|
251
|
+
deleteResource(id: ResourceUri): Promise<void>;
|
|
252
|
+
listResources(filter: ResourceFilter): Promise<{
|
|
253
|
+
resources: ResourceDescriptor$1[];
|
|
254
|
+
total: number;
|
|
255
|
+
}>;
|
|
256
|
+
searchResources(query: string, limit?: number): Promise<ResourceDescriptor$1[]>;
|
|
257
|
+
createAnnotation(input: CreateAnnotationInternal): Promise<Annotation$1>;
|
|
258
|
+
getAnnotation(id: AnnotationUri): Promise<Annotation$1 | null>;
|
|
259
|
+
updateAnnotation(id: AnnotationUri, updates: Partial<Annotation$1>): Promise<Annotation$1>;
|
|
260
|
+
deleteAnnotation(id: AnnotationUri): Promise<void>;
|
|
261
|
+
listAnnotations(filter: {
|
|
262
|
+
resourceId?: ResourceId;
|
|
263
|
+
type?: AnnotationCategory;
|
|
264
|
+
}): Promise<{
|
|
265
|
+
annotations: Annotation$1[];
|
|
266
|
+
total: number;
|
|
267
|
+
}>;
|
|
268
|
+
getHighlights(resourceId: ResourceId): Promise<Annotation$1[]>;
|
|
269
|
+
resolveReference(annotationId: AnnotationId, source: ResourceId): Promise<Annotation$1>;
|
|
270
|
+
getReferences(resourceId: ResourceId): Promise<Annotation$1[]>;
|
|
271
|
+
getEntityReferences(resourceId: ResourceId, entityTypes?: string[]): Promise<Annotation$1[]>;
|
|
272
|
+
getResourceAnnotations(resourceId: ResourceId): Promise<Annotation$1[]>;
|
|
273
|
+
getResourceReferencedBy(resourceUri: ResourceUri, _motivation?: string): Promise<Annotation$1[]>;
|
|
274
|
+
getResourceConnections(resourceId: ResourceId): Promise<GraphConnection[]>;
|
|
275
|
+
findPath(_fromResourceId: string, _toResourceId: string, _maxDepth?: number): Promise<GraphPath[]>;
|
|
276
|
+
getEntityTypeStats(): Promise<EntityTypeStats[]>;
|
|
277
|
+
getStats(): Promise<any>;
|
|
278
|
+
createAnnotations(inputs: CreateAnnotationInternal[]): Promise<Annotation$1[]>;
|
|
279
|
+
resolveReferences(inputs: Array<{
|
|
280
|
+
annotationId: AnnotationId;
|
|
281
|
+
source: ResourceId;
|
|
282
|
+
}>): Promise<Annotation$1[]>;
|
|
283
|
+
detectAnnotations(_resourceId: ResourceId): Promise<Annotation$1[]>;
|
|
284
|
+
getEntityTypes(): Promise<string[]>;
|
|
285
|
+
addEntityType(tag: string): Promise<void>;
|
|
286
|
+
addEntityTypes(tags: string[]): Promise<void>;
|
|
287
|
+
private initializeTagCollections;
|
|
288
|
+
generateId(): string;
|
|
289
|
+
clearDatabase(): Promise<void>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
type ResourceDescriptor = components['schemas']['ResourceDescriptor'];
|
|
293
|
+
type Annotation = components['schemas']['Annotation'];
|
|
294
|
+
declare class MemoryGraphDatabase implements GraphDatabase {
|
|
295
|
+
private connected;
|
|
296
|
+
private resources;
|
|
297
|
+
private annotations;
|
|
298
|
+
constructor(config?: any);
|
|
299
|
+
connect(): Promise<void>;
|
|
300
|
+
disconnect(): Promise<void>;
|
|
301
|
+
isConnected(): boolean;
|
|
302
|
+
createResource(resource: ResourceDescriptor): Promise<ResourceDescriptor>;
|
|
303
|
+
getResource(id: ResourceUri): Promise<ResourceDescriptor | null>;
|
|
304
|
+
updateResource(id: ResourceUri, input: UpdateResourceInput): Promise<ResourceDescriptor>;
|
|
305
|
+
deleteResource(id: ResourceUri): Promise<void>;
|
|
306
|
+
listResources(filter: ResourceFilter): Promise<{
|
|
307
|
+
resources: ResourceDescriptor[];
|
|
308
|
+
total: number;
|
|
309
|
+
}>;
|
|
310
|
+
searchResources(query: string, limit?: number): Promise<ResourceDescriptor[]>;
|
|
311
|
+
createAnnotation(input: CreateAnnotationInternal): Promise<Annotation>;
|
|
312
|
+
getAnnotation(id: AnnotationUri): Promise<Annotation | null>;
|
|
313
|
+
updateAnnotation(id: AnnotationUri, updates: Partial<Annotation>): Promise<Annotation>;
|
|
314
|
+
deleteAnnotation(id: AnnotationUri): Promise<void>;
|
|
315
|
+
listAnnotations(filter: {
|
|
316
|
+
resourceId?: ResourceId;
|
|
317
|
+
type?: AnnotationCategory;
|
|
318
|
+
}): Promise<{
|
|
319
|
+
annotations: Annotation[];
|
|
320
|
+
total: number;
|
|
321
|
+
}>;
|
|
322
|
+
getHighlights(resourceId: ResourceId): Promise<Annotation[]>;
|
|
323
|
+
resolveReference(annotationId: AnnotationId, source: ResourceId): Promise<Annotation>;
|
|
324
|
+
getReferences(resourceId: ResourceId): Promise<Annotation[]>;
|
|
325
|
+
getEntityReferences(resourceId: ResourceId, entityTypes?: string[]): Promise<Annotation[]>;
|
|
326
|
+
getResourceAnnotations(resourceId: ResourceId): Promise<Annotation[]>;
|
|
327
|
+
getResourceReferencedBy(resourceUri: ResourceUri, _motivation?: string): Promise<Annotation[]>;
|
|
328
|
+
getResourceConnections(resourceId: ResourceId): Promise<GraphConnection[]>;
|
|
329
|
+
findPath(fromResourceId: string, toResourceId: string, maxDepth?: number): Promise<GraphPath[]>;
|
|
330
|
+
getEntityTypeStats(): Promise<EntityTypeStats[]>;
|
|
331
|
+
getStats(): Promise<{
|
|
332
|
+
resourceCount: number;
|
|
333
|
+
annotationCount: number;
|
|
334
|
+
highlightCount: number;
|
|
335
|
+
referenceCount: number;
|
|
336
|
+
entityReferenceCount: number;
|
|
337
|
+
entityTypes: Record<string, number>;
|
|
338
|
+
contentTypes: Record<string, number>;
|
|
339
|
+
}>;
|
|
340
|
+
createAnnotations(inputs: CreateAnnotationInternal[]): Promise<Annotation[]>;
|
|
341
|
+
resolveReferences(inputs: {
|
|
342
|
+
annotationId: AnnotationId;
|
|
343
|
+
source: ResourceId;
|
|
344
|
+
}[]): Promise<Annotation[]>;
|
|
345
|
+
detectAnnotations(_resourceId: ResourceId): Promise<Annotation[]>;
|
|
346
|
+
private entityTypesCollection;
|
|
347
|
+
getEntityTypes(): Promise<string[]>;
|
|
348
|
+
addEntityType(tag: string): Promise<void>;
|
|
349
|
+
addEntityTypes(tags: string[]): Promise<void>;
|
|
350
|
+
private initializeTagCollections;
|
|
351
|
+
generateId(): string;
|
|
352
|
+
clearDatabase(): Promise<void>;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export { type GraphDatabase, JanusGraphDatabase, MemoryGraphDatabase, Neo4jGraphDatabase, NeptuneGraphDatabase, closeGraphDatabase, createGraphDatabase, getGraphDatabase };
|