@undefineds.co/xpod 0.3.14 → 0.3.15
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/components/context.jsonld +6 -0
- package/dist/storage/rdf/RdfLocalQueryEngine.d.ts +4 -1
- package/dist/storage/rdf/RdfLocalQueryEngine.js +77 -8
- package/dist/storage/rdf/RdfLocalQueryEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfEngine.d.ts +5 -0
- package/dist/storage/rdf/SolidRdfEngine.js +31 -3
- package/dist/storage/rdf/SolidRdfEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfEngine.jsonld +34 -0
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ export interface SolidRdfEngineOptions {
|
|
|
11
11
|
textIndex?: RdfTextIndex | RdfTextIndexOptions;
|
|
12
12
|
vectorIndex?: RdfVectorIndex | RdfVectorIndexOptions;
|
|
13
13
|
rdf3xIndex?: Rdf3xTripleIndex | Rdf3xTripleIndexOptions;
|
|
14
|
+
rdf3xPrimary?: boolean;
|
|
14
15
|
compatibilityStore?: QuintStore;
|
|
15
16
|
autoOpen?: boolean;
|
|
16
17
|
}
|
|
@@ -23,9 +24,11 @@ export declare class SolidRdfEngine {
|
|
|
23
24
|
private readonly ownsTextIndex;
|
|
24
25
|
private readonly ownsVectorIndex;
|
|
25
26
|
private readonly ownsRdf3xIndex;
|
|
27
|
+
private readonly rdf3xPrimary;
|
|
26
28
|
private readonly compatibilityStore?;
|
|
27
29
|
private shadowComparator?;
|
|
28
30
|
private readonly queryEngine;
|
|
31
|
+
private rdf3xDirty;
|
|
29
32
|
constructor(options: SolidRdfEngineOptions);
|
|
30
33
|
open(): void;
|
|
31
34
|
close(): Promise<void>;
|
|
@@ -48,4 +51,6 @@ export declare class SolidRdfEngine {
|
|
|
48
51
|
private requireTextIndex;
|
|
49
52
|
private requireVectorIndex;
|
|
50
53
|
private requireRdf3xIndex;
|
|
54
|
+
private markRdf3xDirty;
|
|
55
|
+
private refreshRdf3xPrimary;
|
|
51
56
|
}
|
|
@@ -11,6 +11,7 @@ const RdfShadowComparator_1 = require("./RdfShadowComparator");
|
|
|
11
11
|
const RdfLocalQueryEngine_1 = require("./RdfLocalQueryEngine");
|
|
12
12
|
class SolidRdfEngine {
|
|
13
13
|
constructor(options) {
|
|
14
|
+
this.rdf3xDirty = true;
|
|
14
15
|
if (options.index instanceof RdfQuadIndex_1.RdfQuadIndex) {
|
|
15
16
|
this.index = options.index;
|
|
16
17
|
this.ownsIndex = false;
|
|
@@ -52,8 +53,12 @@ class SolidRdfEngine {
|
|
|
52
53
|
else {
|
|
53
54
|
this.ownsRdf3xIndex = false;
|
|
54
55
|
}
|
|
56
|
+
if (options.rdf3xPrimary && !this.rdf3xIndex) {
|
|
57
|
+
throw new Error('SolidRdfEngine rdf3xPrimary requires an rdf3xIndex');
|
|
58
|
+
}
|
|
59
|
+
this.rdf3xPrimary = Boolean(options.rdf3xPrimary);
|
|
55
60
|
this.compatibilityStore = options.compatibilityStore;
|
|
56
|
-
this.queryEngine = new RdfLocalQueryEngine_1.RdfLocalQueryEngine(this.index, this.textIndex, this.vectorIndex);
|
|
61
|
+
this.queryEngine = new RdfLocalQueryEngine_1.RdfLocalQueryEngine(this.index, this.textIndex, this.vectorIndex, this.rdf3xPrimary ? this.rdf3xIndex : undefined);
|
|
57
62
|
if (this.compatibilityStore) {
|
|
58
63
|
this.shadowComparator = new RdfShadowComparator_1.RdfShadowComparator(this.index, this.compatibilityStore);
|
|
59
64
|
}
|
|
@@ -86,20 +91,31 @@ class SolidRdfEngine {
|
|
|
86
91
|
}
|
|
87
92
|
put(quads, options) {
|
|
88
93
|
this.index.multiPut(Array.isArray(quads) ? quads : [quads], options);
|
|
94
|
+
this.markRdf3xDirty();
|
|
89
95
|
}
|
|
90
96
|
replaceSource(quads, source) {
|
|
91
97
|
this.index.replaceSource(quads, source);
|
|
98
|
+
this.markRdf3xDirty();
|
|
92
99
|
}
|
|
93
100
|
deleteSource(source) {
|
|
94
|
-
|
|
101
|
+
const changes = this.index.deleteSource(source);
|
|
102
|
+
if (changes > 0) {
|
|
103
|
+
this.markRdf3xDirty();
|
|
104
|
+
}
|
|
105
|
+
return changes;
|
|
95
106
|
}
|
|
96
107
|
delete(pattern) {
|
|
97
|
-
|
|
108
|
+
const changes = this.index.delete(pattern);
|
|
109
|
+
if (changes > 0) {
|
|
110
|
+
this.markRdf3xDirty();
|
|
111
|
+
}
|
|
112
|
+
return changes;
|
|
98
113
|
}
|
|
99
114
|
scan(query) {
|
|
100
115
|
return this.index.scan(query.pattern, query.options);
|
|
101
116
|
}
|
|
102
117
|
query(query) {
|
|
118
|
+
this.refreshRdf3xPrimary();
|
|
103
119
|
return this.queryEngine.query(query);
|
|
104
120
|
}
|
|
105
121
|
indexTextSource(source, text, chunks) {
|
|
@@ -194,6 +210,18 @@ class SolidRdfEngine {
|
|
|
194
210
|
}
|
|
195
211
|
return this.rdf3xIndex;
|
|
196
212
|
}
|
|
213
|
+
markRdf3xDirty() {
|
|
214
|
+
if (this.rdf3xIndex) {
|
|
215
|
+
this.rdf3xDirty = true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
refreshRdf3xPrimary() {
|
|
219
|
+
if (!this.rdf3xPrimary || !this.rdf3xDirty) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
this.requireRdf3xIndex().rebuildFromCurrentQuads();
|
|
223
|
+
this.rdf3xDirty = false;
|
|
224
|
+
}
|
|
197
225
|
}
|
|
198
226
|
exports.SolidRdfEngine = SolidRdfEngine;
|
|
199
227
|
function isRdfTextIndexOptions(input) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolidRdfEngine.js","sourceRoot":"","sources":["../../../src/storage/rdf/SolidRdfEngine.ts"],"names":[],"mappings":";;;AACA,2BAA8B;AAE9B,0CAAwC;AA0BxC,iDAA8C;AAC9C,yDAAsD;AACtD,iDAA8C;AAC9C,qDAAkD;A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I,GAAG,KAAK,QAAQ,IAAI,4BAA4B,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5D,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC;gBACtB,SAAS;YACX,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,yDAAyD,GAAG,SAAS,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACzI,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAc;IAC1C,OAAO,KAAK,KAAK,IAAI;WAChB,OAAO,KAAK,KAAK,QAAQ;WACzB,aAAa,IAAI,KAAK;WACtB,OAAQ,KAAmC,CAAC,WAAW,KAAK,QAAQ,CAAC;AAC5E,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAc;IAClD,OAAO,KAAK,KAAK,IAAI;WAChB,OAAO,KAAK,KAAK,QAAQ;WACzB,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC;WACtB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import type { Quad } from '@rdfjs/types';\nimport { termToId } from 'n3';\nimport type { QuintPattern, QuintStore } from '../quint/types';\nimport { isTerm } from '../quint/types';\nimport type {\n Rdf3xNumericObjectRangePattern,\n Rdf3xShadowJoinResult,\n Rdf3xShadowScanResult,\n Rdf3xTripleIndexOptions,\n Rdf3xTriplePattern,\n RdfIndexPutOptions,\n RdfPatternQuery,\n RdfQuadJoinOptions,\n RdfQuadJoinPattern,\n RdfQuadIndexOptions,\n RdfQuadIndexScanResult,\n RdfSourceInput,\n RdfShadowScanResult,\n RdfTextChunkInput,\n RdfTextIndexOptions,\n RdfTextSearchOptions,\n RdfTextSearchResult,\n RdfTextSourceInput,\n RdfVectorChunkInput,\n RdfVectorIndexOptions,\n RdfVectorSearchOptions,\n RdfVectorSearchResult,\n RdfVectorSourceInput,\n} from './types';\nimport { RdfQuadIndex } from './RdfQuadIndex';\nimport { Rdf3xTripleIndex } from './Rdf3xTripleIndex';\nimport { RdfTextIndex } from './RdfTextIndex';\nimport { RdfVectorIndex } from './RdfVectorIndex';\nimport { RdfShadowComparator, diffQuads } from './RdfShadowComparator';\nimport { RdfLocalQueryEngine } from './RdfLocalQueryEngine';\nimport type { RdfLocalQuery, RdfLocalQueryResult } from './types';\n\nexport interface SolidRdfEngineOptions {\n index: RdfQuadIndex | RdfQuadIndexOptions;\n textIndex?: RdfTextIndex | RdfTextIndexOptions;\n vectorIndex?: RdfVectorIndex | RdfVectorIndexOptions;\n rdf3xIndex?: Rdf3xTripleIndex | Rdf3xTripleIndexOptions;\n compatibilityStore?: QuintStore;\n autoOpen?: boolean;\n}\n\nexport class SolidRdfEngine {\n public readonly index: RdfQuadIndex;\n public readonly textIndex?: RdfTextIndex;\n public readonly vectorIndex?: RdfVectorIndex;\n public readonly rdf3xIndex?: Rdf3xTripleIndex;\n private readonly ownsIndex: boolean;\n private readonly ownsTextIndex: boolean;\n private readonly ownsVectorIndex: boolean;\n private readonly ownsRdf3xIndex: boolean;\n private readonly compatibilityStore?: QuintStore;\n private shadowComparator?: RdfShadowComparator;\n private readonly queryEngine: RdfLocalQueryEngine;\n\n public constructor(options: SolidRdfEngineOptions) {\n if (options.index instanceof RdfQuadIndex) {\n this.index = options.index;\n this.ownsIndex = false;\n } else {\n this.index = new RdfQuadIndex(options.index);\n this.ownsIndex = true;\n }\n if (options.textIndex instanceof RdfTextIndex) {\n this.textIndex = options.textIndex;\n this.ownsTextIndex = false;\n } else if (isRdfTextIndexOptions(options.textIndex)) {\n this.textIndex = new RdfTextIndex(options.textIndex);\n this.ownsTextIndex = true;\n } else {\n this.ownsTextIndex = false;\n }\n if (options.vectorIndex instanceof RdfVectorIndex) {\n this.vectorIndex = options.vectorIndex;\n this.ownsVectorIndex = false;\n } else if (isRdfVectorIndexOptions(options.vectorIndex)) {\n this.vectorIndex = new RdfVectorIndex(options.vectorIndex);\n this.ownsVectorIndex = true;\n } else {\n this.ownsVectorIndex = false;\n }\n if (options.rdf3xIndex instanceof Rdf3xTripleIndex) {\n this.rdf3xIndex = options.rdf3xIndex;\n this.ownsRdf3xIndex = false;\n } else if (isRdf3xTripleIndexOptions(options.rdf3xIndex)) {\n this.rdf3xIndex = new Rdf3xTripleIndex(options.rdf3xIndex);\n this.ownsRdf3xIndex = true;\n } else {\n this.ownsRdf3xIndex = false;\n }\n this.compatibilityStore = options.compatibilityStore;\n this.queryEngine = new RdfLocalQueryEngine(this.index, this.textIndex, this.vectorIndex);\n if (this.compatibilityStore) {\n this.shadowComparator = new RdfShadowComparator(this.index, this.compatibilityStore);\n }\n if (options.autoOpen) {\n this.open();\n }\n }\n\n public open(): void {\n this.index.open();\n this.textIndex?.open();\n this.vectorIndex?.open();\n this.rdf3xIndex?.open();\n }\n\n public async close(): Promise<void> {\n if (this.ownsRdf3xIndex) {\n this.rdf3xIndex?.close();\n }\n if (this.ownsVectorIndex) {\n this.vectorIndex?.close();\n }\n if (this.ownsTextIndex) {\n this.textIndex?.close();\n }\n if (this.ownsIndex) {\n this.index.close();\n }\n if (this.compatibilityStore) {\n await this.compatibilityStore.close();\n }\n }\n\n public put(quads: Quad | Quad[], options?: RdfIndexPutOptions): void {\n this.index.multiPut(Array.isArray(quads) ? quads : [quads], options);\n }\n\n public replaceSource(quads: Quad[], source: RdfSourceInput): void {\n this.index.replaceSource(quads, source);\n }\n\n public deleteSource(source: string): number {\n return this.index.deleteSource(source);\n }\n\n public delete(pattern: QuintPattern): number {\n return this.index.delete(pattern);\n }\n\n public scan(query: RdfPatternQuery): RdfQuadIndexScanResult {\n return this.index.scan(query.pattern, query.options);\n }\n\n public query(query: RdfLocalQuery): RdfLocalQueryResult {\n return this.queryEngine.query(query);\n }\n\n public indexTextSource(source: RdfTextSourceInput, text: string, chunks?: RdfTextChunkInput[]): void {\n this.requireTextIndex().indexText(source, text, chunks);\n }\n\n public deleteTextSource(source: string): number {\n return this.requireTextIndex().deleteSource(source);\n }\n\n public searchText(options: RdfTextSearchOptions | string): RdfTextSearchResult[] {\n return this.requireTextIndex().search(typeof options === 'string' ? { query: options } : options);\n }\n\n public indexVectorSource(source: RdfVectorSourceInput, chunks: RdfVectorChunkInput[]): void {\n this.requireVectorIndex().indexVector(source, chunks);\n }\n\n public deleteVectorSource(source: string): number {\n return this.requireVectorIndex().deleteSource(source);\n }\n\n public searchVector(options: RdfVectorSearchOptions): RdfVectorSearchResult[] {\n return this.requireVectorIndex().search(options);\n }\n\n public async shadowScan(query: RdfPatternQuery): Promise<RdfShadowScanResult> {\n if (!this.shadowComparator) {\n throw new Error('SolidRdfEngine shadowScan requires a compatibility QuintStore');\n }\n return this.shadowComparator.compareScan(query);\n }\n\n public shadowRdf3xScan(query: RdfPatternQuery): Rdf3xShadowScanResult {\n const rdf3xIndex = this.requireRdf3xIndex();\n const rdf3xPattern = toRdf3xTriplePattern(query.pattern);\n const rebuild = rdf3xIndex.rebuildFromCurrentQuads();\n const primary = this.index.scan(query.pattern, query.options);\n const rdf3x = rdf3xIndex.scan(rdf3xPattern, query.options);\n const diff = diffQuads(rdf3x.quads, primary.quads);\n const orderedMatch = canonicalQuadKeys(primary.quads).join('\\n') === canonicalQuadKeys(rdf3x.quads).join('\\n');\n return {\n matched: diff.missingFromPrimary.length === 0 && diff.extraInPrimary.length === 0,\n orderedMatch,\n primary: primary.quads,\n rdf3x: rdf3x.quads,\n diff: {\n missingFromRdf3x: diff.extraInPrimary,\n extraInRdf3x: diff.missingFromPrimary,\n },\n primaryMetrics: primary.metrics,\n rdf3xMetrics: rdf3x.metrics,\n rebuild,\n };\n }\n\n public shadowRdf3xJoin(\n patterns: RdfQuadJoinPattern[],\n options?: RdfQuadJoinOptions,\n ): Rdf3xShadowJoinResult {\n const rdf3xIndex = this.requireRdf3xIndex();\n const rebuild = rdf3xIndex.rebuildFromCurrentQuads();\n const primary = this.index.joinPatterns(patterns, options);\n const rdf3x = rdf3xIndex.joinPatterns(patterns, options);\n const primaryKeys = primary.bindings.map(canonicalBindingKey);\n const rdf3xKeys = rdf3x.bindings.map(canonicalBindingKey);\n const diff = diffBindingKeys(rdf3xKeys, primaryKeys);\n return {\n matched: diff.missingFromRdf3x.length === 0 && diff.extraInRdf3x.length === 0,\n orderedMatch: primaryKeys.join('\\n') === rdf3xKeys.join('\\n'),\n primary: primary.bindings,\n rdf3x: rdf3x.bindings,\n diff,\n primaryMetrics: primary.metrics,\n rdf3xMetrics: rdf3x.metrics,\n rebuild,\n };\n }\n\n public supportsPrimary(query: RdfPatternQuery): boolean {\n try {\n this.index.scan(query.pattern, { ...query.options, limit: 0 });\n return true;\n } catch {\n return false;\n }\n }\n\n private requireTextIndex(): RdfTextIndex {\n if (!this.textIndex) {\n throw new Error('SolidRdfEngine text index is not configured');\n }\n return this.textIndex;\n }\n\n private requireVectorIndex(): RdfVectorIndex {\n if (!this.vectorIndex) {\n throw new Error('SolidRdfEngine vector index is not configured');\n }\n return this.vectorIndex;\n }\n\n private requireRdf3xIndex(): Rdf3xTripleIndex {\n if (!this.rdf3xIndex) {\n throw new Error('SolidRdfEngine RDF-3X shadow index is not configured');\n }\n return this.rdf3xIndex;\n }\n}\n\nfunction isRdfTextIndexOptions(input: RdfTextIndex | RdfTextIndexOptions | undefined): input is RdfTextIndexOptions {\n return input !== undefined && !(input instanceof RdfTextIndex) && typeof input.path === 'string';\n}\n\nfunction isRdfVectorIndexOptions(input: RdfVectorIndex | RdfVectorIndexOptions | undefined): input is RdfVectorIndexOptions {\n return input !== undefined && !(input instanceof RdfVectorIndex) && typeof input.path === 'string';\n}\n\nfunction isRdf3xTripleIndexOptions(input: Rdf3xTripleIndex | Rdf3xTripleIndexOptions | undefined): input is Rdf3xTripleIndexOptions {\n return input !== undefined && !(input instanceof Rdf3xTripleIndex) && typeof input.path === 'string';\n}\n\nfunction canonicalQuadKeys(quads: Quad[]): string[] {\n return quads.map((quad) => [\n termToId(quad.graph as any),\n termToId(quad.subject as any),\n termToId(quad.predicate as any),\n termToId(quad.object as any),\n ].join('\\u001f'));\n}\n\nfunction canonicalBindingKey(binding: Record<string, unknown>): string {\n return Object.keys(binding)\n .sort()\n .map((key) => `${key}=${termToId(binding[key] as any)}`)\n .join('\\u001f');\n}\n\nfunction diffBindingKeys(\n rdf3xKeys: string[],\n primaryKeys: string[],\n): Rdf3xShadowJoinResult['diff'] {\n const rdf3xSet = new Set(rdf3xKeys);\n const primarySet = new Set(primaryKeys);\n return {\n missingFromRdf3x: Array.from(primarySet).filter((key) => !rdf3xSet.has(key)).sort(),\n extraInRdf3x: Array.from(rdf3xSet).filter((key) => !primarySet.has(key)).sort(),\n };\n}\n\nfunction toRdf3xTriplePattern(pattern: QuintPattern): Rdf3xTriplePattern {\n const result: Rdf3xTriplePattern = {};\n for (const key of ['graph', 'subject', 'predicate', 'object'] as const) {\n const value = pattern[key];\n if (!value) {\n continue;\n }\n if (!isTerm(value)) {\n if (key === 'graph' && isStartsWithOperator(value)) {\n result.graph = { $startsWith: value.$startsWith };\n continue;\n }\n if (key === 'object' && isNumericObjectRangeOperator(value)) {\n result.object = value;\n continue;\n }\n throw new Error(`SolidRdfEngine RDF-3X shadow scan only supports exact ${key} terms${key === 'graph' ? ' or graph $startsWith' : ''}`);\n }\n result[key] = value;\n }\n return result;\n}\n\nfunction isStartsWithOperator(value: unknown): value is { $startsWith: string } {\n return value !== null\n && typeof value === 'object'\n && '$startsWith' in value\n && typeof (value as { $startsWith?: unknown }).$startsWith === 'string';\n}\n\nfunction isNumericObjectRangeOperator(value: unknown): value is Rdf3xNumericObjectRangePattern {\n return value !== null\n && typeof value === 'object'\n && !('termType' in value)\n && ['$gt', '$gte', '$lt', '$lte'].some((operator) => operator in value);\n}\n"]}
|
|
1
|
+
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Q,IAAI,4BAA4B,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5D,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC;gBACtB,SAAS;YACX,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,yDAAyD,GAAG,SAAS,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACzI,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAc;IAC1C,OAAO,KAAK,KAAK,IAAI;WAChB,OAAO,KAAK,KAAK,QAAQ;WACzB,aAAa,IAAI,KAAK;WACtB,OAAQ,KAAmC,CAAC,WAAW,KAAK,QAAQ,CAAC;AAC5E,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAc;IAClD,OAAO,KAAK,KAAK,IAAI;WAChB,OAAO,KAAK,KAAK,QAAQ;WACzB,CAAC,CAAC,UAAU,IAAI,KAAK,CAAC;WACtB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import type { Quad } from '@rdfjs/types';\nimport { termToId } from 'n3';\nimport type { QuintPattern, QuintStore } from '../quint/types';\nimport { isTerm } from '../quint/types';\nimport type {\n Rdf3xNumericObjectRangePattern,\n Rdf3xShadowJoinResult,\n Rdf3xShadowScanResult,\n Rdf3xTripleIndexOptions,\n Rdf3xTriplePattern,\n RdfIndexPutOptions,\n RdfPatternQuery,\n RdfQuadJoinOptions,\n RdfQuadJoinPattern,\n RdfQuadIndexOptions,\n RdfQuadIndexScanResult,\n RdfSourceInput,\n RdfShadowScanResult,\n RdfTextChunkInput,\n RdfTextIndexOptions,\n RdfTextSearchOptions,\n RdfTextSearchResult,\n RdfTextSourceInput,\n RdfVectorChunkInput,\n RdfVectorIndexOptions,\n RdfVectorSearchOptions,\n RdfVectorSearchResult,\n RdfVectorSourceInput,\n} from './types';\nimport { RdfQuadIndex } from './RdfQuadIndex';\nimport { Rdf3xTripleIndex } from './Rdf3xTripleIndex';\nimport { RdfTextIndex } from './RdfTextIndex';\nimport { RdfVectorIndex } from './RdfVectorIndex';\nimport { RdfShadowComparator, diffQuads } from './RdfShadowComparator';\nimport { RdfLocalQueryEngine } from './RdfLocalQueryEngine';\nimport type { RdfLocalQuery, RdfLocalQueryResult } from './types';\n\nexport interface SolidRdfEngineOptions {\n index: RdfQuadIndex | RdfQuadIndexOptions;\n textIndex?: RdfTextIndex | RdfTextIndexOptions;\n vectorIndex?: RdfVectorIndex | RdfVectorIndexOptions;\n rdf3xIndex?: Rdf3xTripleIndex | Rdf3xTripleIndexOptions;\n rdf3xPrimary?: boolean;\n compatibilityStore?: QuintStore;\n autoOpen?: boolean;\n}\n\nexport class SolidRdfEngine {\n public readonly index: RdfQuadIndex;\n public readonly textIndex?: RdfTextIndex;\n public readonly vectorIndex?: RdfVectorIndex;\n public readonly rdf3xIndex?: Rdf3xTripleIndex;\n private readonly ownsIndex: boolean;\n private readonly ownsTextIndex: boolean;\n private readonly ownsVectorIndex: boolean;\n private readonly ownsRdf3xIndex: boolean;\n private readonly rdf3xPrimary: boolean;\n private readonly compatibilityStore?: QuintStore;\n private shadowComparator?: RdfShadowComparator;\n private readonly queryEngine: RdfLocalQueryEngine;\n private rdf3xDirty = true;\n\n public constructor(options: SolidRdfEngineOptions) {\n if (options.index instanceof RdfQuadIndex) {\n this.index = options.index;\n this.ownsIndex = false;\n } else {\n this.index = new RdfQuadIndex(options.index);\n this.ownsIndex = true;\n }\n if (options.textIndex instanceof RdfTextIndex) {\n this.textIndex = options.textIndex;\n this.ownsTextIndex = false;\n } else if (isRdfTextIndexOptions(options.textIndex)) {\n this.textIndex = new RdfTextIndex(options.textIndex);\n this.ownsTextIndex = true;\n } else {\n this.ownsTextIndex = false;\n }\n if (options.vectorIndex instanceof RdfVectorIndex) {\n this.vectorIndex = options.vectorIndex;\n this.ownsVectorIndex = false;\n } else if (isRdfVectorIndexOptions(options.vectorIndex)) {\n this.vectorIndex = new RdfVectorIndex(options.vectorIndex);\n this.ownsVectorIndex = true;\n } else {\n this.ownsVectorIndex = false;\n }\n if (options.rdf3xIndex instanceof Rdf3xTripleIndex) {\n this.rdf3xIndex = options.rdf3xIndex;\n this.ownsRdf3xIndex = false;\n } else if (isRdf3xTripleIndexOptions(options.rdf3xIndex)) {\n this.rdf3xIndex = new Rdf3xTripleIndex(options.rdf3xIndex);\n this.ownsRdf3xIndex = true;\n } else {\n this.ownsRdf3xIndex = false;\n }\n if (options.rdf3xPrimary && !this.rdf3xIndex) {\n throw new Error('SolidRdfEngine rdf3xPrimary requires an rdf3xIndex');\n }\n this.rdf3xPrimary = Boolean(options.rdf3xPrimary);\n this.compatibilityStore = options.compatibilityStore;\n this.queryEngine = new RdfLocalQueryEngine(\n this.index,\n this.textIndex,\n this.vectorIndex,\n this.rdf3xPrimary ? this.rdf3xIndex : undefined,\n );\n if (this.compatibilityStore) {\n this.shadowComparator = new RdfShadowComparator(this.index, this.compatibilityStore);\n }\n if (options.autoOpen) {\n this.open();\n }\n }\n\n public open(): void {\n this.index.open();\n this.textIndex?.open();\n this.vectorIndex?.open();\n this.rdf3xIndex?.open();\n }\n\n public async close(): Promise<void> {\n if (this.ownsRdf3xIndex) {\n this.rdf3xIndex?.close();\n }\n if (this.ownsVectorIndex) {\n this.vectorIndex?.close();\n }\n if (this.ownsTextIndex) {\n this.textIndex?.close();\n }\n if (this.ownsIndex) {\n this.index.close();\n }\n if (this.compatibilityStore) {\n await this.compatibilityStore.close();\n }\n }\n\n public put(quads: Quad | Quad[], options?: RdfIndexPutOptions): void {\n this.index.multiPut(Array.isArray(quads) ? quads : [quads], options);\n this.markRdf3xDirty();\n }\n\n public replaceSource(quads: Quad[], source: RdfSourceInput): void {\n this.index.replaceSource(quads, source);\n this.markRdf3xDirty();\n }\n\n public deleteSource(source: string): number {\n const changes = this.index.deleteSource(source);\n if (changes > 0) {\n this.markRdf3xDirty();\n }\n return changes;\n }\n\n public delete(pattern: QuintPattern): number {\n const changes = this.index.delete(pattern);\n if (changes > 0) {\n this.markRdf3xDirty();\n }\n return changes;\n }\n\n public scan(query: RdfPatternQuery): RdfQuadIndexScanResult {\n return this.index.scan(query.pattern, query.options);\n }\n\n public query(query: RdfLocalQuery): RdfLocalQueryResult {\n this.refreshRdf3xPrimary();\n return this.queryEngine.query(query);\n }\n\n public indexTextSource(source: RdfTextSourceInput, text: string, chunks?: RdfTextChunkInput[]): void {\n this.requireTextIndex().indexText(source, text, chunks);\n }\n\n public deleteTextSource(source: string): number {\n return this.requireTextIndex().deleteSource(source);\n }\n\n public searchText(options: RdfTextSearchOptions | string): RdfTextSearchResult[] {\n return this.requireTextIndex().search(typeof options === 'string' ? { query: options } : options);\n }\n\n public indexVectorSource(source: RdfVectorSourceInput, chunks: RdfVectorChunkInput[]): void {\n this.requireVectorIndex().indexVector(source, chunks);\n }\n\n public deleteVectorSource(source: string): number {\n return this.requireVectorIndex().deleteSource(source);\n }\n\n public searchVector(options: RdfVectorSearchOptions): RdfVectorSearchResult[] {\n return this.requireVectorIndex().search(options);\n }\n\n public async shadowScan(query: RdfPatternQuery): Promise<RdfShadowScanResult> {\n if (!this.shadowComparator) {\n throw new Error('SolidRdfEngine shadowScan requires a compatibility QuintStore');\n }\n return this.shadowComparator.compareScan(query);\n }\n\n public shadowRdf3xScan(query: RdfPatternQuery): Rdf3xShadowScanResult {\n const rdf3xIndex = this.requireRdf3xIndex();\n const rdf3xPattern = toRdf3xTriplePattern(query.pattern);\n const rebuild = rdf3xIndex.rebuildFromCurrentQuads();\n const primary = this.index.scan(query.pattern, query.options);\n const rdf3x = rdf3xIndex.scan(rdf3xPattern, query.options);\n const diff = diffQuads(rdf3x.quads, primary.quads);\n const orderedMatch = canonicalQuadKeys(primary.quads).join('\\n') === canonicalQuadKeys(rdf3x.quads).join('\\n');\n return {\n matched: diff.missingFromPrimary.length === 0 && diff.extraInPrimary.length === 0,\n orderedMatch,\n primary: primary.quads,\n rdf3x: rdf3x.quads,\n diff: {\n missingFromRdf3x: diff.extraInPrimary,\n extraInRdf3x: diff.missingFromPrimary,\n },\n primaryMetrics: primary.metrics,\n rdf3xMetrics: rdf3x.metrics,\n rebuild,\n };\n }\n\n public shadowRdf3xJoin(\n patterns: RdfQuadJoinPattern[],\n options?: RdfQuadJoinOptions,\n ): Rdf3xShadowJoinResult {\n const rdf3xIndex = this.requireRdf3xIndex();\n const rebuild = rdf3xIndex.rebuildFromCurrentQuads();\n const primary = this.index.joinPatterns(patterns, options);\n const rdf3x = rdf3xIndex.joinPatterns(patterns, options);\n const primaryKeys = primary.bindings.map(canonicalBindingKey);\n const rdf3xKeys = rdf3x.bindings.map(canonicalBindingKey);\n const diff = diffBindingKeys(rdf3xKeys, primaryKeys);\n return {\n matched: diff.missingFromRdf3x.length === 0 && diff.extraInRdf3x.length === 0,\n orderedMatch: primaryKeys.join('\\n') === rdf3xKeys.join('\\n'),\n primary: primary.bindings,\n rdf3x: rdf3x.bindings,\n diff,\n primaryMetrics: primary.metrics,\n rdf3xMetrics: rdf3x.metrics,\n rebuild,\n };\n }\n\n public supportsPrimary(query: RdfPatternQuery): boolean {\n try {\n this.index.scan(query.pattern, { ...query.options, limit: 0 });\n return true;\n } catch {\n return false;\n }\n }\n\n private requireTextIndex(): RdfTextIndex {\n if (!this.textIndex) {\n throw new Error('SolidRdfEngine text index is not configured');\n }\n return this.textIndex;\n }\n\n private requireVectorIndex(): RdfVectorIndex {\n if (!this.vectorIndex) {\n throw new Error('SolidRdfEngine vector index is not configured');\n }\n return this.vectorIndex;\n }\n\n private requireRdf3xIndex(): Rdf3xTripleIndex {\n if (!this.rdf3xIndex) {\n throw new Error('SolidRdfEngine RDF-3X shadow index is not configured');\n }\n return this.rdf3xIndex;\n }\n\n private markRdf3xDirty(): void {\n if (this.rdf3xIndex) {\n this.rdf3xDirty = true;\n }\n }\n\n private refreshRdf3xPrimary(): void {\n if (!this.rdf3xPrimary || !this.rdf3xDirty) {\n return;\n }\n this.requireRdf3xIndex().rebuildFromCurrentQuads();\n this.rdf3xDirty = false;\n }\n}\n\nfunction isRdfTextIndexOptions(input: RdfTextIndex | RdfTextIndexOptions | undefined): input is RdfTextIndexOptions {\n return input !== undefined && !(input instanceof RdfTextIndex) && typeof input.path === 'string';\n}\n\nfunction isRdfVectorIndexOptions(input: RdfVectorIndex | RdfVectorIndexOptions | undefined): input is RdfVectorIndexOptions {\n return input !== undefined && !(input instanceof RdfVectorIndex) && typeof input.path === 'string';\n}\n\nfunction isRdf3xTripleIndexOptions(input: Rdf3xTripleIndex | Rdf3xTripleIndexOptions | undefined): input is Rdf3xTripleIndexOptions {\n return input !== undefined && !(input instanceof Rdf3xTripleIndex) && typeof input.path === 'string';\n}\n\nfunction canonicalQuadKeys(quads: Quad[]): string[] {\n return quads.map((quad) => [\n termToId(quad.graph as any),\n termToId(quad.subject as any),\n termToId(quad.predicate as any),\n termToId(quad.object as any),\n ].join('\\u001f'));\n}\n\nfunction canonicalBindingKey(binding: Record<string, unknown>): string {\n return Object.keys(binding)\n .sort()\n .map((key) => `${key}=${termToId(binding[key] as any)}`)\n .join('\\u001f');\n}\n\nfunction diffBindingKeys(\n rdf3xKeys: string[],\n primaryKeys: string[],\n): Rdf3xShadowJoinResult['diff'] {\n const rdf3xSet = new Set(rdf3xKeys);\n const primarySet = new Set(primaryKeys);\n return {\n missingFromRdf3x: Array.from(primarySet).filter((key) => !rdf3xSet.has(key)).sort(),\n extraInRdf3x: Array.from(rdf3xSet).filter((key) => !primarySet.has(key)).sort(),\n };\n}\n\nfunction toRdf3xTriplePattern(pattern: QuintPattern): Rdf3xTriplePattern {\n const result: Rdf3xTriplePattern = {};\n for (const key of ['graph', 'subject', 'predicate', 'object'] as const) {\n const value = pattern[key];\n if (!value) {\n continue;\n }\n if (!isTerm(value)) {\n if (key === 'graph' && isStartsWithOperator(value)) {\n result.graph = { $startsWith: value.$startsWith };\n continue;\n }\n if (key === 'object' && isNumericObjectRangeOperator(value)) {\n result.object = value;\n continue;\n }\n throw new Error(`SolidRdfEngine RDF-3X shadow scan only supports exact ${key} terms${key === 'graph' ? ' or graph $startsWith' : ''}`);\n }\n result[key] = value;\n }\n return result;\n}\n\nfunction isStartsWithOperator(value: unknown): value is { $startsWith: string } {\n return value !== null\n && typeof value === 'object'\n && '$startsWith' in value\n && typeof (value as { $startsWith?: unknown }).$startsWith === 'string';\n}\n\nfunction isNumericObjectRangeOperator(value: unknown): value is Rdf3xNumericObjectRangePattern {\n return value !== null\n && typeof value === 'object'\n && !('termType' in value)\n && ['$gt', '$gte', '$lt', '$lte'].some((operator) => operator in value);\n}\n"]}
|
|
@@ -77,6 +77,18 @@
|
|
|
77
77
|
]
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
|
+
{
|
|
81
|
+
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine_options_rdf3xPrimary",
|
|
82
|
+
"range": {
|
|
83
|
+
"@type": "ParameterRangeUnion",
|
|
84
|
+
"parameterRangeElements": [
|
|
85
|
+
"xsd:boolean",
|
|
86
|
+
{
|
|
87
|
+
"@type": "ParameterRangeUndefined"
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
},
|
|
80
92
|
{
|
|
81
93
|
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine_options_compatibilityStore",
|
|
82
94
|
"range": {
|
|
@@ -139,6 +151,10 @@
|
|
|
139
151
|
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine__member_ownsRdf3xIndex",
|
|
140
152
|
"memberFieldName": "ownsRdf3xIndex"
|
|
141
153
|
},
|
|
154
|
+
{
|
|
155
|
+
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine__member_rdf3xPrimary",
|
|
156
|
+
"memberFieldName": "rdf3xPrimary"
|
|
157
|
+
},
|
|
142
158
|
{
|
|
143
159
|
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine__member_compatibilityStore",
|
|
144
160
|
"memberFieldName": "compatibilityStore"
|
|
@@ -151,6 +167,10 @@
|
|
|
151
167
|
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine__member_queryEngine",
|
|
152
168
|
"memberFieldName": "queryEngine"
|
|
153
169
|
},
|
|
170
|
+
{
|
|
171
|
+
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine__member_rdf3xDirty",
|
|
172
|
+
"memberFieldName": "rdf3xDirty"
|
|
173
|
+
},
|
|
154
174
|
{
|
|
155
175
|
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine__member_constructor",
|
|
156
176
|
"memberFieldName": "constructor"
|
|
@@ -238,6 +258,14 @@
|
|
|
238
258
|
{
|
|
239
259
|
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine__member_requireRdf3xIndex",
|
|
240
260
|
"memberFieldName": "requireRdf3xIndex"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine__member_markRdf3xDirty",
|
|
264
|
+
"memberFieldName": "markRdf3xDirty"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine__member_refreshRdf3xPrimary",
|
|
268
|
+
"memberFieldName": "refreshRdf3xPrimary"
|
|
241
269
|
}
|
|
242
270
|
],
|
|
243
271
|
"constructorArguments": [
|
|
@@ -318,6 +346,12 @@
|
|
|
318
346
|
]
|
|
319
347
|
}
|
|
320
348
|
},
|
|
349
|
+
{
|
|
350
|
+
"keyRaw": "rdf3xPrimary",
|
|
351
|
+
"value": {
|
|
352
|
+
"@id": "undefineds:dist/storage/rdf/SolidRdfEngine.jsonld#SolidRdfEngine_options_rdf3xPrimary"
|
|
353
|
+
}
|
|
354
|
+
},
|
|
321
355
|
{
|
|
322
356
|
"keyRaw": "compatibilityStore",
|
|
323
357
|
"value": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@undefineds.co/xpod",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"description": "Xpod is an extended Community Solid Server, offering rich-feature, production-level Solid Pod and identity management.",
|
|
5
5
|
"repository": "https://github.com/undefinedsco/xpod",
|
|
6
6
|
"author": "developer@undefineds.co",
|