@origintrail-official/dkg-query 10.0.0-rc.8 → 10.0.0
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 +16 -5
- package/dist/dkg-query-engine.d.ts +42 -3
- package/dist/dkg-query-engine.d.ts.map +1 -1
- package/dist/dkg-query-engine.js +1392 -50
- package/dist/dkg-query-engine.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/query-engine.d.ts +35 -3
- package/dist/query-engine.d.ts.map +1 -1
- package/dist/query-handler.d.ts +31 -1
- package/dist/query-handler.d.ts.map +1 -1
- package/dist/query-handler.js +117 -28
- package/dist/query-handler.js.map +1 -1
- package/dist/sparql-guard.d.ts +0 -20
- package/dist/sparql-guard.d.ts.map +1 -1
- package/dist/sparql-guard.js +68 -8
- package/dist/sparql-guard.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -19,16 +19,27 @@ const engine = new DKGQueryEngine(store);
|
|
|
19
19
|
|
|
20
20
|
const results = await engine.query(
|
|
21
21
|
'SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10',
|
|
22
|
-
{ contextGraphId: '
|
|
22
|
+
{ contextGraphId: 'example', view: 'verifiable-memory' },
|
|
23
23
|
);
|
|
24
24
|
|
|
25
|
-
//
|
|
26
|
-
const
|
|
27
|
-
'SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10',
|
|
28
|
-
{ contextGraphId: '
|
|
25
|
+
// Inspect allowed named graphs without expanding the selected scope.
|
|
26
|
+
const graphResults = await engine.query(
|
|
27
|
+
'SELECT ?g ?s ?p ?o WHERE { GRAPH ?g { ?s ?p ?o } } LIMIT 10',
|
|
28
|
+
{ contextGraphId: 'example', view: 'shared-working-memory' },
|
|
29
29
|
);
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
contextGraphId and view are authoritative for local queries. A local
|
|
33
|
+
`GRAPH ?g` pattern is constrained locally to the graph set resolved from those
|
|
34
|
+
fields; it cannot range over another context graph or memory view. Local scoped
|
|
35
|
+
queries reject explicit out-of-scope `GRAPH <iri>` targets and `FROM` /
|
|
36
|
+
`FROM NAMED` clauses because those would let caller SPARQL redefine the dataset.
|
|
37
|
+
|
|
38
|
+
Remote raw SPARQL handled by `QueryHandler` remains stricter: `GRAPH`, `FROM`,
|
|
39
|
+
and `FROM NAMED` clauses are rejected before execution. Structured remote
|
|
40
|
+
lookups such as `ENTITIES_BY_TYPE` and `ENTITY_TRIPLES` continue to build their
|
|
41
|
+
own internal graph patterns.
|
|
42
|
+
|
|
32
43
|
## Internal Dependencies
|
|
33
44
|
|
|
34
45
|
- `@origintrail-official/dkg-core` — configuration, logging, protocol streams
|
|
@@ -10,26 +10,39 @@ export interface ViewResolution {
|
|
|
10
10
|
/**
|
|
11
11
|
* Graph URI prefixes — the engine discovers all named graphs matching
|
|
12
12
|
* each prefix and unions the results. Used for working-memory (multiple
|
|
13
|
-
* assertions) and
|
|
13
|
+
* assertions) and verifiable-memory (multiple quorum graphs).
|
|
14
14
|
*/
|
|
15
15
|
graphPrefixes: string[];
|
|
16
16
|
}
|
|
17
|
+
export declare class ScopedQueryViolationError extends Error {
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
17
20
|
/**
|
|
18
21
|
* Resolves a V10 GetView + context graph ID to the named-graph URIs (or
|
|
19
22
|
* prefixes) that the query engine should target.
|
|
20
23
|
*
|
|
21
24
|
* Spec reference: §12 GET — Declared State Views.
|
|
22
25
|
*
|
|
23
|
-
* Trust-level semantics for `
|
|
24
|
-
* signal. The root graph and `/
|
|
26
|
+
* Trust-level semantics for `verifiable-memory`: graph scope is not a trust
|
|
27
|
+
* signal. The root graph and `/_verifiable_memory/*` graphs are candidates;
|
|
25
28
|
* `minTrust` is enforced by explicit writer-side `dkg:trustLevel` metadata.
|
|
26
29
|
*/
|
|
27
30
|
export declare function resolveViewGraphs(view: GetView, contextGraphId: string, opts?: {
|
|
28
31
|
agentAddress?: string;
|
|
32
|
+
/** Same-identity WM namespace aliases — see QueryOptions.agentAddressAliases. */
|
|
33
|
+
agentAddressAliases?: string[];
|
|
29
34
|
verifiedGraph?: string;
|
|
30
35
|
assertionName?: string;
|
|
36
|
+
/** Resolved KA number for single-graph by-name reads under the uniform layout. */
|
|
37
|
+
kaNumber?: bigint;
|
|
31
38
|
/** Spec §12/§14 trust-gradient filter. Enforced after graph resolution. */
|
|
32
39
|
minTrust?: TrustLevel;
|
|
40
|
+
/**
|
|
41
|
+
* GH #184 — when set, the view is scoped to this registered sub-graph: the
|
|
42
|
+
* uniform layout stores sub-graph layer data at `…/{sub}/{slug}/…`, so the
|
|
43
|
+
* per-layer prefixes below gain the `/{sub}` segment.
|
|
44
|
+
*/
|
|
45
|
+
subGraphName?: string;
|
|
33
46
|
}): ViewResolution;
|
|
34
47
|
/**
|
|
35
48
|
* Local-only query engine that executes SPARQL against this node's own
|
|
@@ -40,6 +53,7 @@ export declare function resolveViewGraphs(view: GetView, contextGraphId: string,
|
|
|
40
53
|
export declare class DKGQueryEngine implements QueryEngine {
|
|
41
54
|
private readonly store;
|
|
42
55
|
private readonly graphManager;
|
|
56
|
+
private readonly scopedContentGraphAllowListInFlight;
|
|
43
57
|
constructor(store: TripleStore);
|
|
44
58
|
query(sparql: string, options?: QueryOptions): Promise<QueryResult>;
|
|
45
59
|
/**
|
|
@@ -53,9 +67,34 @@ export declare class DKGQueryEngine implements QueryEngine {
|
|
|
53
67
|
private queryWithView;
|
|
54
68
|
private queryMultipleGraphs;
|
|
55
69
|
private discoverGraphsByPrefix;
|
|
70
|
+
/**
|
|
71
|
+
* GH #1098 — discover the per-cgId VM DATA graphs `<cg>/context/<onChainId>`
|
|
72
|
+
* for a context graph. Chain-reconciled / per-cgId-only publishes materialise
|
|
73
|
+
* confirmed VM content here rather than in the root content graph. We keep
|
|
74
|
+
* ONLY the bare `<cg>/context/<id>` data graphs: `discoverGraphsByPrefix`
|
|
75
|
+
* already drops `/_meta` + `/staging/`, and the extra `!rest.includes('/')`
|
|
76
|
+
* guard excludes any nested per-cgId sub-partition (`…/context/<id>/_private`,
|
|
77
|
+
* `…/context/<id>/_shared_memory`, …) so a VM content read never pulls
|
|
78
|
+
* private/SWM rows.
|
|
79
|
+
*/
|
|
80
|
+
private discoverContextGraphPerCgIdDataGraphs;
|
|
81
|
+
/**
|
|
82
|
+
* Resolve a WM assertion's allocated KA number (`dkg:kaId`) off its lifecycle URN
|
|
83
|
+
* in `_meta`, for single-graph by-name reads under the uniform layout. Returns
|
|
84
|
+
* `undefined` for an unallocated draft (legacy name-keyed graph fallback). Mirrors
|
|
85
|
+
* the publisher's `resolveKaNumber`.
|
|
86
|
+
*/
|
|
87
|
+
private resolveWorkingMemoryKaNumber;
|
|
88
|
+
private resolveScopedGraphVariableAllowList;
|
|
89
|
+
private resolveScopedContentGraphAllowList;
|
|
90
|
+
private discoverScopedContentGraphAllowList;
|
|
91
|
+
private discoverRegisteredSubGraphNames;
|
|
92
|
+
private discoverRegisteredAssertionGraphs;
|
|
93
|
+
private discoverKnownChildContextGraphUris;
|
|
56
94
|
private execAndNormalize;
|
|
57
95
|
resolveKA(ual: string): Promise<{
|
|
58
96
|
rootEntity: string;
|
|
97
|
+
rootEntities: string[];
|
|
59
98
|
contextGraphId: string;
|
|
60
99
|
quads: Quad[];
|
|
61
100
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dkg-query-engine.d.ts","sourceRoot":"","sources":["../src/dkg-query-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAmC,MAAM,mCAAmC,CAAC;AAE5G,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,
|
|
1
|
+
{"version":3,"file":"dkg-query-engine.d.ts","sourceRoot":"","sources":["../src/dkg-query-engine.ts"],"names":[],"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