@semiont/graph 0.5.2 → 0.5.4
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/dist/factory.d.ts +21 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/implementations/janusgraph.d.ts +72 -0
- package/dist/implementations/janusgraph.d.ts.map +1 -0
- package/dist/implementations/memorygraph.d.ts +70 -0
- package/dist/implementations/memorygraph.d.ts.map +1 -0
- package/dist/implementations/neo4j.d.ts +80 -0
- package/dist/implementations/neo4j.d.ts.map +1 -0
- package/dist/implementations/neptune.d.ts +78 -0
- package/dist/implementations/neptune.d.ts.map +1 -0
- package/dist/index.d.ts +17 -358
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -15
- package/dist/index.js.map +1 -1
- package/dist/interface.d.ts +57 -0
- package/dist/interface.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,358 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
updateAnnotation(id: AnnotationId, updates: Partial<Annotation>): Promise<Annotation>;
|
|
19
|
-
deleteAnnotation(id: AnnotationId): Promise<void>;
|
|
20
|
-
listAnnotations(filter: {
|
|
21
|
-
resourceId?: ResourceId;
|
|
22
|
-
type?: AnnotationCategory;
|
|
23
|
-
}): Promise<{
|
|
24
|
-
annotations: Annotation[];
|
|
25
|
-
total: number;
|
|
26
|
-
}>;
|
|
27
|
-
getHighlights(resourceId: ResourceId): Promise<Annotation[]>;
|
|
28
|
-
resolveReference(annotationId: AnnotationId, source: ResourceId): Promise<Annotation>;
|
|
29
|
-
getReferences(resourceId: ResourceId): Promise<Annotation[]>;
|
|
30
|
-
getEntityReferences(resourceId: ResourceId, entityTypes?: string[]): Promise<Annotation[]>;
|
|
31
|
-
getResourceAnnotations(resourceId: ResourceId): Promise<Annotation[]>;
|
|
32
|
-
getResourceReferencedBy(resourceId: ResourceId, motivation?: string): Promise<Annotation[]>;
|
|
33
|
-
getResourceConnections(resourceId: ResourceId): Promise<GraphConnection[]>;
|
|
34
|
-
findPath(fromResourceId: ResourceId, toResourceId: ResourceId, maxDepth?: number): Promise<GraphPath[]>;
|
|
35
|
-
getEntityTypeStats(): Promise<EntityTypeStats[]>;
|
|
36
|
-
getStats(): Promise<{
|
|
37
|
-
resourceCount: number;
|
|
38
|
-
annotationCount: number;
|
|
39
|
-
highlightCount: number;
|
|
40
|
-
referenceCount: number;
|
|
41
|
-
entityReferenceCount: number;
|
|
42
|
-
entityTypes: Record<string, number>;
|
|
43
|
-
contentTypes: Record<string, number>;
|
|
44
|
-
}>;
|
|
45
|
-
batchCreateResources(resources: ResourceDescriptor[]): Promise<ResourceDescriptor[]>;
|
|
46
|
-
createAnnotations(inputs: CreateAnnotationInternal[]): Promise<Annotation[]>;
|
|
47
|
-
resolveReferences(inputs: {
|
|
48
|
-
annotationId: AnnotationId;
|
|
49
|
-
source: ResourceId;
|
|
50
|
-
}[]): Promise<Annotation[]>;
|
|
51
|
-
detectAnnotations(resourceId: ResourceId): Promise<Annotation[]>;
|
|
52
|
-
getEntityTypes(): Promise<string[]>;
|
|
53
|
-
addEntityType(tag: string): Promise<void>;
|
|
54
|
-
addEntityTypes(tags: string[]): Promise<void>;
|
|
55
|
-
generateId(): string;
|
|
56
|
-
clearDatabase(): Promise<void>;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
type GraphDatabaseType = 'neptune' | 'neo4j' | 'janusgraph' | 'memory';
|
|
60
|
-
interface GraphDatabaseConfig {
|
|
61
|
-
type: GraphDatabaseType;
|
|
62
|
-
neptuneEndpoint?: string;
|
|
63
|
-
neptunePort?: number;
|
|
64
|
-
neptuneRegion?: string;
|
|
65
|
-
neo4jUri?: string;
|
|
66
|
-
neo4jUsername?: string;
|
|
67
|
-
neo4jPassword?: string;
|
|
68
|
-
neo4jDatabase?: string;
|
|
69
|
-
janusHost?: string;
|
|
70
|
-
janusPort?: number;
|
|
71
|
-
janusStorageBackend?: 'cassandra' | 'hbase' | 'berkeleydb';
|
|
72
|
-
janusIndexBackend?: 'elasticsearch' | 'solr' | 'lucene';
|
|
73
|
-
}
|
|
74
|
-
declare function createGraphDatabase(config: GraphDatabaseConfig): GraphDatabase;
|
|
75
|
-
declare function getGraphDatabase(graphConfig: GraphServiceConfig): Promise<GraphDatabase>;
|
|
76
|
-
declare function closeGraphDatabase(): Promise<void>;
|
|
77
|
-
|
|
78
|
-
declare class Neo4jGraphDatabase implements GraphDatabase {
|
|
79
|
-
private driver;
|
|
80
|
-
private neo4j;
|
|
81
|
-
private connected;
|
|
82
|
-
private logger?;
|
|
83
|
-
private config;
|
|
84
|
-
private entityTypesCollection;
|
|
85
|
-
constructor(config?: {
|
|
86
|
-
uri?: string;
|
|
87
|
-
username?: string;
|
|
88
|
-
password?: string;
|
|
89
|
-
database?: string;
|
|
90
|
-
logger?: Logger;
|
|
91
|
-
});
|
|
92
|
-
connect(): Promise<void>;
|
|
93
|
-
disconnect(): Promise<void>;
|
|
94
|
-
isConnected(): boolean;
|
|
95
|
-
private getSession;
|
|
96
|
-
private ensureSchemaExists;
|
|
97
|
-
createResource(resource: ResourceDescriptor): Promise<ResourceDescriptor>;
|
|
98
|
-
getResource(id: ResourceId): Promise<ResourceDescriptor | null>;
|
|
99
|
-
updateResource(id: ResourceId, input: UpdateResourceInput): Promise<ResourceDescriptor>;
|
|
100
|
-
deleteResource(id: ResourceId): Promise<void>;
|
|
101
|
-
listResources(filter: ResourceFilter): Promise<{
|
|
102
|
-
resources: ResourceDescriptor[];
|
|
103
|
-
total: number;
|
|
104
|
-
}>;
|
|
105
|
-
searchResources(query: string, limit?: number): Promise<ResourceDescriptor[]>;
|
|
106
|
-
createAnnotation(input: CreateAnnotationInternal): Promise<Annotation>;
|
|
107
|
-
getAnnotation(id: AnnotationId): Promise<Annotation | null>;
|
|
108
|
-
updateAnnotation(id: AnnotationId, updates: Partial<Annotation>): Promise<Annotation>;
|
|
109
|
-
deleteAnnotation(id: AnnotationId): Promise<void>;
|
|
110
|
-
listAnnotations(filter: {
|
|
111
|
-
resourceId?: ResourceId;
|
|
112
|
-
type?: AnnotationCategory;
|
|
113
|
-
}): Promise<{
|
|
114
|
-
annotations: Annotation[];
|
|
115
|
-
total: number;
|
|
116
|
-
}>;
|
|
117
|
-
getHighlights(resourceId: ResourceId): Promise<Annotation[]>;
|
|
118
|
-
resolveReference(annotationId: AnnotationId, source: ResourceId): Promise<Annotation>;
|
|
119
|
-
getReferences(resourceId: ResourceId): Promise<Annotation[]>;
|
|
120
|
-
getEntityReferences(resourceId: ResourceId, entityTypes?: string[]): Promise<Annotation[]>;
|
|
121
|
-
getResourceAnnotations(resourceId: ResourceId): Promise<Annotation[]>;
|
|
122
|
-
getResourceReferencedBy(resourceId: ResourceId, motivation?: string): Promise<Annotation[]>;
|
|
123
|
-
getResourceConnections(resourceId: ResourceId): Promise<GraphConnection[]>;
|
|
124
|
-
findPath(fromResourceId: string, toResourceId: string, maxDepth?: number): Promise<GraphPath[]>;
|
|
125
|
-
getEntityTypeStats(): Promise<EntityTypeStats[]>;
|
|
126
|
-
getStats(): Promise<{
|
|
127
|
-
resourceCount: number;
|
|
128
|
-
annotationCount: number;
|
|
129
|
-
highlightCount: number;
|
|
130
|
-
referenceCount: number;
|
|
131
|
-
entityReferenceCount: number;
|
|
132
|
-
entityTypes: Record<string, number>;
|
|
133
|
-
contentTypes: Record<string, number>;
|
|
134
|
-
}>;
|
|
135
|
-
batchCreateResources(resources: ResourceDescriptor[]): Promise<ResourceDescriptor[]>;
|
|
136
|
-
createAnnotations(inputs: CreateAnnotationInternal[]): Promise<Annotation[]>;
|
|
137
|
-
resolveReferences(inputs: {
|
|
138
|
-
annotationId: AnnotationId;
|
|
139
|
-
source: ResourceId;
|
|
140
|
-
}[]): Promise<Annotation[]>;
|
|
141
|
-
detectAnnotations(_resourceId: ResourceId): Promise<Annotation[]>;
|
|
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
|
-
declare class NeptuneGraphDatabase implements GraphDatabase {
|
|
154
|
-
private connected;
|
|
155
|
-
private neptuneEndpoint?;
|
|
156
|
-
private neptunePort;
|
|
157
|
-
private region?;
|
|
158
|
-
private logger?;
|
|
159
|
-
private g;
|
|
160
|
-
private connection;
|
|
161
|
-
private fetchAnnotationsWithEntityTypes;
|
|
162
|
-
constructor(config?: {
|
|
163
|
-
endpoint?: string;
|
|
164
|
-
port?: number;
|
|
165
|
-
region?: string;
|
|
166
|
-
logger?: Logger;
|
|
167
|
-
});
|
|
168
|
-
private discoverNeptuneEndpoint;
|
|
169
|
-
connect(): Promise<void>;
|
|
170
|
-
disconnect(): Promise<void>;
|
|
171
|
-
isConnected(): boolean;
|
|
172
|
-
createResource(resource: ResourceDescriptor): Promise<ResourceDescriptor>;
|
|
173
|
-
getResource(id: ResourceId): Promise<ResourceDescriptor | null>;
|
|
174
|
-
updateResource(id: ResourceId, input: UpdateResourceInput): Promise<ResourceDescriptor>;
|
|
175
|
-
deleteResource(id: ResourceId): Promise<void>;
|
|
176
|
-
listResources(filter: ResourceFilter): Promise<{
|
|
177
|
-
resources: ResourceDescriptor[];
|
|
178
|
-
total: number;
|
|
179
|
-
}>;
|
|
180
|
-
searchResources(query: string, limit?: number): Promise<ResourceDescriptor[]>;
|
|
181
|
-
createAnnotation(input: CreateAnnotationInternal): Promise<Annotation>;
|
|
182
|
-
getAnnotation(id: AnnotationId): Promise<Annotation | null>;
|
|
183
|
-
updateAnnotation(id: AnnotationId, updates: Partial<Annotation>): Promise<Annotation>;
|
|
184
|
-
deleteAnnotation(id: AnnotationId): Promise<void>;
|
|
185
|
-
listAnnotations(filter: {
|
|
186
|
-
resourceId?: ResourceId;
|
|
187
|
-
type?: AnnotationCategory;
|
|
188
|
-
}): Promise<{
|
|
189
|
-
annotations: Annotation[];
|
|
190
|
-
total: number;
|
|
191
|
-
}>;
|
|
192
|
-
getHighlights(resourceId: ResourceId): Promise<Annotation[]>;
|
|
193
|
-
resolveReference(annotationId: AnnotationId, source: ResourceId): Promise<Annotation>;
|
|
194
|
-
getReferences(resourceId: ResourceId): Promise<Annotation[]>;
|
|
195
|
-
getEntityReferences(resourceId: ResourceId, entityTypes?: string[]): Promise<Annotation[]>;
|
|
196
|
-
getResourceAnnotations(resourceId: ResourceId): Promise<Annotation[]>;
|
|
197
|
-
getResourceReferencedBy(resourceId: ResourceId, _motivation?: string): Promise<Annotation[]>;
|
|
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
|
-
batchCreateResources(resources: ResourceDescriptor[]): Promise<ResourceDescriptor[]>;
|
|
211
|
-
createAnnotations(inputs: CreateAnnotationInternal[]): Promise<Annotation[]>;
|
|
212
|
-
resolveReferences(inputs: {
|
|
213
|
-
annotationId: AnnotationId;
|
|
214
|
-
source: ResourceId;
|
|
215
|
-
}[]): Promise<Annotation[]>;
|
|
216
|
-
detectAnnotations(_resourceId: ResourceId): Promise<Annotation[]>;
|
|
217
|
-
private entityTypesCollection;
|
|
218
|
-
getEntityTypes(): Promise<string[]>;
|
|
219
|
-
addEntityType(tag: string): Promise<void>;
|
|
220
|
-
addEntityTypes(tags: string[]): Promise<void>;
|
|
221
|
-
private initializeTagCollections;
|
|
222
|
-
generateId(): string;
|
|
223
|
-
clearDatabase(): Promise<void>;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
declare class JanusGraphDatabase implements GraphDatabase {
|
|
227
|
-
private graphConfig;
|
|
228
|
-
private connected;
|
|
229
|
-
private connection;
|
|
230
|
-
private g;
|
|
231
|
-
private logger?;
|
|
232
|
-
private entityTypesCollection;
|
|
233
|
-
constructor(graphConfig: {
|
|
234
|
-
host?: string;
|
|
235
|
-
port?: number;
|
|
236
|
-
storageBackend?: 'cassandra' | 'hbase' | 'berkeleydb';
|
|
237
|
-
indexBackend?: 'elasticsearch' | 'solr' | 'lucene';
|
|
238
|
-
logger?: Logger;
|
|
239
|
-
});
|
|
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): Promise<ResourceDescriptor>;
|
|
249
|
-
getResource(id: ResourceId): Promise<ResourceDescriptor | null>;
|
|
250
|
-
updateResource(id: ResourceId, input: UpdateResourceInput): Promise<ResourceDescriptor>;
|
|
251
|
-
deleteResource(id: ResourceId): Promise<void>;
|
|
252
|
-
listResources(filter: ResourceFilter): Promise<{
|
|
253
|
-
resources: ResourceDescriptor[];
|
|
254
|
-
total: number;
|
|
255
|
-
}>;
|
|
256
|
-
searchResources(query: string, limit?: number): Promise<ResourceDescriptor[]>;
|
|
257
|
-
createAnnotation(input: CreateAnnotationInternal): Promise<Annotation>;
|
|
258
|
-
getAnnotation(id: AnnotationId): Promise<Annotation | null>;
|
|
259
|
-
updateAnnotation(id: AnnotationId, updates: Partial<Annotation>): Promise<Annotation>;
|
|
260
|
-
deleteAnnotation(id: AnnotationId): Promise<void>;
|
|
261
|
-
listAnnotations(filter: {
|
|
262
|
-
resourceId?: ResourceId;
|
|
263
|
-
type?: AnnotationCategory;
|
|
264
|
-
}): Promise<{
|
|
265
|
-
annotations: Annotation[];
|
|
266
|
-
total: number;
|
|
267
|
-
}>;
|
|
268
|
-
getHighlights(resourceId: ResourceId): Promise<Annotation[]>;
|
|
269
|
-
resolveReference(annotationId: AnnotationId, source: ResourceId): Promise<Annotation>;
|
|
270
|
-
getReferences(resourceId: ResourceId): Promise<Annotation[]>;
|
|
271
|
-
getEntityReferences(resourceId: ResourceId, entityTypes?: string[]): Promise<Annotation[]>;
|
|
272
|
-
getResourceAnnotations(resourceId: ResourceId): Promise<Annotation[]>;
|
|
273
|
-
getResourceReferencedBy(resourceId: ResourceId, _motivation?: string): Promise<Annotation[]>;
|
|
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
|
-
batchCreateResources(resources: ResourceDescriptor[]): Promise<ResourceDescriptor[]>;
|
|
279
|
-
createAnnotations(inputs: CreateAnnotationInternal[]): Promise<Annotation[]>;
|
|
280
|
-
resolveReferences(inputs: Array<{
|
|
281
|
-
annotationId: AnnotationId;
|
|
282
|
-
source: ResourceId;
|
|
283
|
-
}>): Promise<Annotation[]>;
|
|
284
|
-
detectAnnotations(_resourceId: ResourceId): Promise<Annotation[]>;
|
|
285
|
-
getEntityTypes(): Promise<string[]>;
|
|
286
|
-
addEntityType(tag: string): Promise<void>;
|
|
287
|
-
addEntityTypes(tags: string[]): Promise<void>;
|
|
288
|
-
private initializeTagCollections;
|
|
289
|
-
generateId(): string;
|
|
290
|
-
clearDatabase(): Promise<void>;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
declare class MemoryGraphDatabase implements GraphDatabase {
|
|
294
|
-
private connected;
|
|
295
|
-
private logger?;
|
|
296
|
-
private resources;
|
|
297
|
-
private annotations;
|
|
298
|
-
constructor(config?: {
|
|
299
|
-
logger?: Logger;
|
|
300
|
-
});
|
|
301
|
-
connect(): Promise<void>;
|
|
302
|
-
disconnect(): Promise<void>;
|
|
303
|
-
isConnected(): boolean;
|
|
304
|
-
createResource(resource: ResourceDescriptor): Promise<ResourceDescriptor>;
|
|
305
|
-
getResource(id: ResourceId): Promise<ResourceDescriptor | null>;
|
|
306
|
-
updateResource(id: ResourceId, input: UpdateResourceInput): Promise<ResourceDescriptor>;
|
|
307
|
-
deleteResource(id: ResourceId): Promise<void>;
|
|
308
|
-
listResources(filter: ResourceFilter): Promise<{
|
|
309
|
-
resources: ResourceDescriptor[];
|
|
310
|
-
total: number;
|
|
311
|
-
}>;
|
|
312
|
-
searchResources(query: string, limit?: number): Promise<ResourceDescriptor[]>;
|
|
313
|
-
createAnnotation(input: CreateAnnotationInternal): Promise<Annotation>;
|
|
314
|
-
getAnnotation(id: AnnotationId): Promise<Annotation | null>;
|
|
315
|
-
updateAnnotation(id: AnnotationId, updates: Partial<Annotation>): Promise<Annotation>;
|
|
316
|
-
deleteAnnotation(id: AnnotationId): Promise<void>;
|
|
317
|
-
listAnnotations(filter: {
|
|
318
|
-
resourceId?: ResourceId;
|
|
319
|
-
type?: AnnotationCategory;
|
|
320
|
-
}): Promise<{
|
|
321
|
-
annotations: Annotation[];
|
|
322
|
-
total: number;
|
|
323
|
-
}>;
|
|
324
|
-
getHighlights(resourceId: ResourceId): Promise<Annotation[]>;
|
|
325
|
-
resolveReference(annotationId: AnnotationId, source: ResourceId): Promise<Annotation>;
|
|
326
|
-
getReferences(resourceId: ResourceId): Promise<Annotation[]>;
|
|
327
|
-
getEntityReferences(resourceId: ResourceId, entityTypes?: string[]): Promise<Annotation[]>;
|
|
328
|
-
getResourceAnnotations(resourceId: ResourceId): Promise<Annotation[]>;
|
|
329
|
-
getResourceReferencedBy(resourceId: ResourceId, _motivation?: string): Promise<Annotation[]>;
|
|
330
|
-
getResourceConnections(resourceId: ResourceId): Promise<GraphConnection[]>;
|
|
331
|
-
findPath(fromResourceId: string, toResourceId: string, maxDepth?: number): Promise<GraphPath[]>;
|
|
332
|
-
getEntityTypeStats(): Promise<EntityTypeStats[]>;
|
|
333
|
-
getStats(): Promise<{
|
|
334
|
-
resourceCount: number;
|
|
335
|
-
annotationCount: number;
|
|
336
|
-
highlightCount: number;
|
|
337
|
-
referenceCount: number;
|
|
338
|
-
entityReferenceCount: number;
|
|
339
|
-
entityTypes: Record<string, number>;
|
|
340
|
-
contentTypes: Record<string, number>;
|
|
341
|
-
}>;
|
|
342
|
-
batchCreateResources(resources: ResourceDescriptor[]): Promise<ResourceDescriptor[]>;
|
|
343
|
-
createAnnotations(inputs: CreateAnnotationInternal[]): Promise<Annotation[]>;
|
|
344
|
-
resolveReferences(inputs: {
|
|
345
|
-
annotationId: AnnotationId;
|
|
346
|
-
source: ResourceId;
|
|
347
|
-
}[]): Promise<Annotation[]>;
|
|
348
|
-
detectAnnotations(_resourceId: ResourceId): Promise<Annotation[]>;
|
|
349
|
-
private entityTypesCollection;
|
|
350
|
-
getEntityTypes(): Promise<string[]>;
|
|
351
|
-
addEntityType(tag: string): Promise<void>;
|
|
352
|
-
addEntityTypes(tags: string[]): Promise<void>;
|
|
353
|
-
private initializeTagCollections;
|
|
354
|
-
generateId(): string;
|
|
355
|
-
clearDatabase(): Promise<void>;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
export { type GraphDatabase, JanusGraphDatabase, MemoryGraphDatabase, Neo4jGraphDatabase, NeptuneGraphDatabase, closeGraphDatabase, createGraphDatabase, getGraphDatabase };
|
|
1
|
+
/**
|
|
2
|
+
* @semiont/graph
|
|
3
|
+
*
|
|
4
|
+
* Graph database abstraction with multiple implementations
|
|
5
|
+
*
|
|
6
|
+
* Provides:
|
|
7
|
+
* - GraphDatabase interface with 28 methods
|
|
8
|
+
* - Singleton factory pattern for runtime selection
|
|
9
|
+
* - 4 implementations: Neo4j, Neptune, JanusGraph, MemoryGraph
|
|
10
|
+
*/
|
|
11
|
+
export type { GraphDatabase } from './interface';
|
|
12
|
+
export { getGraphDatabase, createGraphDatabase, closeGraphDatabase } from './factory';
|
|
13
|
+
export { Neo4jGraphDatabase } from './implementations/neo4j';
|
|
14
|
+
export { NeptuneGraphDatabase } from './implementations/neptune';
|
|
15
|
+
export { JanusGraphDatabase } from './implementations/janusgraph';
|
|
16
|
+
export { MemoryGraphDatabase } from './implementations/memorygraph';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -61,8 +61,7 @@ function vertexToResource(vertex) {
|
|
|
61
61
|
}],
|
|
62
62
|
archived: archived === "true" || archived === true,
|
|
63
63
|
dateCreated,
|
|
64
|
-
wasAttributedTo: typeof creatorRaw === "string" ? JSON.parse(creatorRaw) : creatorRaw
|
|
65
|
-
creationMethod: getValue("creationMethod", true)
|
|
64
|
+
wasAttributedTo: typeof creatorRaw === "string" ? JSON.parse(creatorRaw) : creatorRaw
|
|
66
65
|
};
|
|
67
66
|
const sourceResourceId = getValue("sourceResourceId");
|
|
68
67
|
if (sourceResourceId) resource.sourceResourceId = sourceResourceId;
|
|
@@ -247,7 +246,7 @@ var NeptuneGraphDatabase = class {
|
|
|
247
246
|
throw new Error("Resource must have at least one representation");
|
|
248
247
|
}
|
|
249
248
|
try {
|
|
250
|
-
const vertex = this.g.addV("Resource").property("id", id).property("name", resource.name).property("mediaType", primaryRep.mediaType).property("archived", resource.archived || false).property("dateCreated", resource.dateCreated).property("creator", JSON.stringify(resource.wasAttributedTo)).property("
|
|
249
|
+
const vertex = this.g.addV("Resource").property("id", id).property("name", resource.name).property("mediaType", primaryRep.mediaType).property("archived", resource.archived || false).property("dateCreated", resource.dateCreated).property("creator", JSON.stringify(resource.wasAttributedTo)).property("checksum", primaryRep.checksum).property("entityTypes", JSON.stringify(resource.entityTypes));
|
|
251
250
|
if (resource.sourceResourceId) {
|
|
252
251
|
vertex.property("sourceResourceId", resource.sourceResourceId);
|
|
253
252
|
}
|
|
@@ -911,7 +910,6 @@ var Neo4jGraphDatabase = class {
|
|
|
911
910
|
d.archived = $archived,
|
|
912
911
|
d.created = datetime($created),
|
|
913
912
|
d.creator = $creator,
|
|
914
|
-
d.creationMethod = $creationMethod,
|
|
915
913
|
d.contentChecksum = $contentChecksum,
|
|
916
914
|
d.sourceAnnotationId = $sourceAnnotationId,
|
|
917
915
|
d.sourceResourceId = $sourceResourceId,
|
|
@@ -926,7 +924,6 @@ var Neo4jGraphDatabase = class {
|
|
|
926
924
|
archived: resource.archived || false,
|
|
927
925
|
created: resource.dateCreated,
|
|
928
926
|
creator: JSON.stringify(resource.wasAttributedTo),
|
|
929
|
-
creationMethod: resource.creationMethod,
|
|
930
927
|
contentChecksum: primaryRep.checksum,
|
|
931
928
|
sourceAnnotationId: resource.sourceAnnotationId ?? null,
|
|
932
929
|
sourceResourceId: resource.sourceResourceId ?? null,
|
|
@@ -1590,7 +1587,6 @@ var Neo4jGraphDatabase = class {
|
|
|
1590
1587
|
archived: resource.archived || false,
|
|
1591
1588
|
created: resource.dateCreated,
|
|
1592
1589
|
creator: JSON.stringify(resource.wasAttributedTo),
|
|
1593
|
-
creationMethod: resource.creationMethod,
|
|
1594
1590
|
contentChecksum: primaryRep.checksum,
|
|
1595
1591
|
sourceAnnotationId: resource.sourceAnnotationId ?? null,
|
|
1596
1592
|
sourceResourceId: resource.sourceResourceId ?? null,
|
|
@@ -1606,7 +1602,6 @@ var Neo4jGraphDatabase = class {
|
|
|
1606
1602
|
d.archived = r.archived,
|
|
1607
1603
|
d.created = datetime(r.created),
|
|
1608
1604
|
d.creator = r.creator,
|
|
1609
|
-
d.creationMethod = r.creationMethod,
|
|
1610
1605
|
d.contentChecksum = r.contentChecksum,
|
|
1611
1606
|
d.sourceAnnotationId = r.sourceAnnotationId,
|
|
1612
1607
|
d.sourceResourceId = r.sourceResourceId,
|
|
@@ -1713,7 +1708,6 @@ var Neo4jGraphDatabase = class {
|
|
|
1713
1708
|
if (props.archived === void 0 || props.archived === null) throw new Error(`Resource ${props.id} missing required field: archived`);
|
|
1714
1709
|
if (!props.created) throw new Error(`Resource ${props.id} missing required field: created`);
|
|
1715
1710
|
if (!props.creator) throw new Error(`Resource ${props.id} missing required field: creator`);
|
|
1716
|
-
if (!props.creationMethod) throw new Error(`Resource ${props.id} missing required field: creationMethod`);
|
|
1717
1711
|
if (!props.contentChecksum) throw new Error(`Resource ${props.id} missing required field: contentChecksum`);
|
|
1718
1712
|
const resource = {
|
|
1719
1713
|
"@context": "https://schema.org/",
|
|
@@ -1727,8 +1721,7 @@ var Neo4jGraphDatabase = class {
|
|
|
1727
1721
|
}],
|
|
1728
1722
|
archived: props.archived,
|
|
1729
1723
|
dateCreated: props.created.toString(),
|
|
1730
|
-
wasAttributedTo: typeof props.creator === "string" ? JSON.parse(props.creator) : props.creator
|
|
1731
|
-
creationMethod: props.creationMethod
|
|
1724
|
+
wasAttributedTo: typeof props.creator === "string" ? JSON.parse(props.creator) : props.creator
|
|
1732
1725
|
};
|
|
1733
1726
|
if (props.sourceResourceId) resource.sourceResourceId = props.sourceResourceId;
|
|
1734
1727
|
if (props.storageUri) resource.storageUri = props.storageUri;
|
|
@@ -1841,11 +1834,9 @@ var JanusGraphDatabase = class {
|
|
|
1841
1834
|
const props = vertex.properties || {};
|
|
1842
1835
|
const id = this.getPropertyValue(props, "id");
|
|
1843
1836
|
const creatorRaw = this.getPropertyValue(props, "creator");
|
|
1844
|
-
const creationMethod = this.getPropertyValue(props, "creationMethod");
|
|
1845
1837
|
const contentChecksum = this.getPropertyValue(props, "contentChecksum");
|
|
1846
1838
|
const mediaType = this.getPropertyValue(props, "contentType");
|
|
1847
1839
|
if (!creatorRaw) throw new Error(`Resource ${id} missing required field: creator`);
|
|
1848
|
-
if (!creationMethod) throw new Error(`Resource ${id} missing required field: creationMethod`);
|
|
1849
1840
|
if (!contentChecksum) throw new Error(`Resource ${id} missing required field: contentChecksum`);
|
|
1850
1841
|
if (!mediaType) throw new Error(`Resource ${id} missing required field: contentType`);
|
|
1851
1842
|
const creator = typeof creatorRaw === "string" ? JSON.parse(creatorRaw) : creatorRaw;
|
|
@@ -1861,8 +1852,7 @@ var JanusGraphDatabase = class {
|
|
|
1861
1852
|
}],
|
|
1862
1853
|
archived: this.getPropertyValue(props, "archived") === "true",
|
|
1863
1854
|
dateCreated: this.getPropertyValue(props, "created"),
|
|
1864
|
-
wasAttributedTo: creator
|
|
1865
|
-
creationMethod
|
|
1855
|
+
wasAttributedTo: creator
|
|
1866
1856
|
};
|
|
1867
1857
|
const sourceAnnotationId = this.getPropertyValue(props, "sourceAnnotationId");
|
|
1868
1858
|
const sourceResourceId = this.getPropertyValue(props, "sourceResourceId");
|
|
@@ -1948,7 +1938,7 @@ var JanusGraphDatabase = class {
|
|
|
1948
1938
|
if (!primaryRep) {
|
|
1949
1939
|
throw new Error("Resource must have at least one representation");
|
|
1950
1940
|
}
|
|
1951
|
-
const vertex = this.g.addV("Resource").property("id", id).property("name", resource.name).property("entityTypes", JSON.stringify(resource.entityTypes)).property("contentType", primaryRep.mediaType).property("archived", resource.archived || false).property("created", resource.dateCreated).property("creator", JSON.stringify(resource.wasAttributedTo)).property("
|
|
1941
|
+
const vertex = this.g.addV("Resource").property("id", id).property("name", resource.name).property("entityTypes", JSON.stringify(resource.entityTypes)).property("contentType", primaryRep.mediaType).property("archived", resource.archived || false).property("created", resource.dateCreated).property("creator", JSON.stringify(resource.wasAttributedTo)).property("contentChecksum", primaryRep.checksum);
|
|
1952
1942
|
if (resource.sourceAnnotationId) {
|
|
1953
1943
|
vertex.property("sourceAnnotationId", resource.sourceAnnotationId);
|
|
1954
1944
|
}
|