@origintrail-official/dkg-storage 10.0.14 → 10.0.16
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 +56 -0
- package/blazegraph-namespace-contract.cjs +66 -0
- package/blazegraph-namespace-contract.d.cts +10 -0
- package/dist/abortable-store-work-lifecycle.d.ts +14 -0
- package/dist/abortable-store-work-lifecycle.d.ts.map +1 -1
- package/dist/abortable-store-work-lifecycle.js +51 -0
- package/dist/abortable-store-work-lifecycle.js.map +1 -1
- package/dist/abortable-stream-work-lifecycle.d.ts +19 -0
- package/dist/abortable-stream-work-lifecycle.d.ts.map +1 -0
- package/dist/abortable-stream-work-lifecycle.js +95 -0
- package/dist/abortable-stream-work-lifecycle.js.map +1 -0
- package/dist/adapters/blazegraph.d.ts +19 -0
- package/dist/adapters/blazegraph.d.ts.map +1 -1
- package/dist/adapters/blazegraph.js +119 -61
- package/dist/adapters/blazegraph.js.map +1 -1
- package/dist/adapters/oxigraph-worker-impl.js +13 -3
- package/dist/adapters/oxigraph-worker-impl.js.map +1 -1
- package/dist/adapters/oxigraph-worker.d.ts +21 -2
- package/dist/adapters/oxigraph-worker.d.ts.map +1 -1
- package/dist/adapters/oxigraph-worker.js +123 -50
- package/dist/adapters/oxigraph-worker.js.map +1 -1
- package/dist/adapters/oxigraph.d.ts +20 -6
- package/dist/adapters/oxigraph.d.ts.map +1 -1
- package/dist/adapters/oxigraph.js +79 -20
- package/dist/adapters/oxigraph.js.map +1 -1
- package/dist/adapters/sparql-http.d.ts +108 -11
- package/dist/adapters/sparql-http.d.ts.map +1 -1
- package/dist/adapters/sparql-http.js +420 -149
- package/dist/adapters/sparql-http.js.map +1 -1
- package/dist/adapters/sparql-response-policy.d.ts +5 -1
- package/dist/adapters/sparql-response-policy.d.ts.map +1 -1
- package/dist/adapters/sparql-response-policy.js +13 -8
- package/dist/adapters/sparql-response-policy.js.map +1 -1
- package/dist/atomic-graph-replace.d.ts +4 -0
- package/dist/atomic-graph-replace.d.ts.map +1 -1
- package/dist/atomic-graph-replace.js +4 -4
- package/dist/atomic-graph-replace.js.map +1 -1
- package/dist/blazegraph-namespace-manager.d.ts +46 -0
- package/dist/blazegraph-namespace-manager.d.ts.map +1 -0
- package/dist/blazegraph-namespace-manager.js +185 -0
- package/dist/blazegraph-namespace-manager.js.map +1 -0
- package/dist/changelog-store.d.ts +11 -2
- package/dist/changelog-store.d.ts.map +1 -1
- package/dist/changelog-store.js +105 -67
- package/dist/changelog-store.js.map +1 -1
- package/dist/closed-data-snapshot.d.ts +7 -0
- package/dist/closed-data-snapshot.d.ts.map +1 -0
- package/dist/closed-data-snapshot.js +14 -0
- package/dist/closed-data-snapshot.js.map +1 -0
- package/dist/content-addressed-blob-single-flight.d.ts +16 -0
- package/dist/content-addressed-blob-single-flight.d.ts.map +1 -0
- package/dist/content-addressed-blob-single-flight.js +33 -0
- package/dist/content-addressed-blob-single-flight.js.map +1 -0
- package/dist/graph-set-catalog-state.d.ts +33 -0
- package/dist/graph-set-catalog-state.d.ts.map +1 -0
- package/dist/graph-set-catalog-state.js +78 -0
- package/dist/graph-set-catalog-state.js.map +1 -0
- package/dist/graph-set-index-store.d.ts +25 -5
- package/dist/graph-set-index-store.d.ts.map +1 -1
- package/dist/graph-set-index-store.js +148 -63
- package/dist/graph-set-index-store.js.map +1 -1
- package/dist/graph-write-gen.d.ts +77 -14
- package/dist/graph-write-gen.d.ts.map +1 -1
- package/dist/graph-write-gen.js +146 -16
- package/dist/graph-write-gen.js.map +1 -1
- package/dist/http-response-limit.d.ts.map +1 -1
- package/dist/http-response-limit.js +8 -32
- package/dist/http-response-limit.js.map +1 -1
- package/dist/index.d.ts +21 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/managed-oxigraph-runtime-store.d.ts +33 -0
- package/dist/managed-oxigraph-runtime-store.d.ts.map +1 -0
- package/dist/managed-oxigraph-runtime-store.js +123 -0
- package/dist/managed-oxigraph-runtime-store.js.map +1 -0
- package/dist/managed-read-recovery-coordinator.d.ts +27 -0
- package/dist/managed-read-recovery-coordinator.d.ts.map +1 -0
- package/dist/managed-read-recovery-coordinator.js +50 -0
- package/dist/managed-read-recovery-coordinator.js.map +1 -0
- package/dist/nquads-text.d.ts.map +1 -1
- package/dist/nquads-text.js +16 -6
- package/dist/nquads-text.js.map +1 -1
- package/dist/private-store.d.ts.map +1 -1
- package/dist/private-store.js +5 -5
- package/dist/private-store.js.map +1 -1
- package/dist/rfc64-author-commit-cas.d.ts +112 -0
- package/dist/rfc64-author-commit-cas.d.ts.map +1 -0
- package/dist/rfc64-author-commit-cas.js +586 -0
- package/dist/rfc64-author-commit-cas.js.map +1 -0
- package/dist/rfc64-author-commit-execution.d.ts +20 -0
- package/dist/rfc64-author-commit-execution.d.ts.map +1 -0
- package/dist/rfc64-author-commit-execution.js +47 -0
- package/dist/rfc64-author-commit-execution.js.map +1 -0
- package/dist/rfc64-author-commit-plan-codec.d.ts +104 -0
- package/dist/rfc64-author-commit-plan-codec.d.ts.map +1 -0
- package/dist/rfc64-author-commit-plan-codec.js +337 -0
- package/dist/rfc64-author-commit-plan-codec.js.map +1 -0
- package/dist/rfc64-author-seal-read-gateway.d.ts +28 -0
- package/dist/rfc64-author-seal-read-gateway.d.ts.map +1 -0
- package/dist/rfc64-author-seal-read-gateway.js +61 -0
- package/dist/rfc64-author-seal-read-gateway.js.map +1 -0
- package/dist/rfc64-closed-bindings-read-runner.d.ts +15 -0
- package/dist/rfc64-closed-bindings-read-runner.d.ts.map +1 -0
- package/dist/rfc64-closed-bindings-read-runner.js +66 -0
- package/dist/rfc64-closed-bindings-read-runner.js.map +1 -0
- package/dist/rfc64-exact-bindings-read-capability.d.ts +45 -0
- package/dist/rfc64-exact-bindings-read-capability.d.ts.map +1 -0
- package/dist/rfc64-exact-bindings-read-capability.js +176 -0
- package/dist/rfc64-exact-bindings-read-capability.js.map +1 -0
- package/dist/rfc64-http-shared-projection-runner.d.ts +29 -0
- package/dist/rfc64-http-shared-projection-runner.d.ts.map +1 -0
- package/dist/rfc64-http-shared-projection-runner.js +81 -0
- package/dist/rfc64-http-shared-projection-runner.js.map +1 -0
- package/dist/rfc64-semantic-author-commit-v1.d.ts +38 -0
- package/dist/rfc64-semantic-author-commit-v1.d.ts.map +1 -0
- package/dist/rfc64-semantic-author-commit-v1.js +285 -0
- package/dist/rfc64-semantic-author-commit-v1.js.map +1 -0
- package/dist/rfc64-semantic-read-gateway.d.ts +32 -0
- package/dist/rfc64-semantic-read-gateway.d.ts.map +1 -0
- package/dist/rfc64-semantic-read-gateway.js +68 -0
- package/dist/rfc64-semantic-read-gateway.js.map +1 -0
- package/dist/rfc64-shared-projection-http-spool.d.ts +43 -0
- package/dist/rfc64-shared-projection-http-spool.d.ts.map +1 -0
- package/dist/rfc64-shared-projection-http-spool.js +438 -0
- package/dist/rfc64-shared-projection-http-spool.js.map +1 -0
- package/dist/rfc64-shared-projection-stream-capability.d.ts +17 -0
- package/dist/rfc64-shared-projection-stream-capability.d.ts.map +1 -0
- package/dist/rfc64-shared-projection-stream-capability.js +28 -0
- package/dist/rfc64-shared-projection-stream-capability.js.map +1 -0
- package/dist/rfc64-shared-projection-stream-gateway.d.ts +37 -0
- package/dist/rfc64-shared-projection-stream-gateway.d.ts.map +1 -0
- package/dist/rfc64-shared-projection-stream-gateway.js +147 -0
- package/dist/rfc64-shared-projection-stream-gateway.js.map +1 -0
- package/dist/shared-memory-literal-blob-store.d.ts +9 -4
- package/dist/shared-memory-literal-blob-store.d.ts.map +1 -1
- package/dist/shared-memory-literal-blob-store.js +66 -34
- package/dist/shared-memory-literal-blob-store.js.map +1 -1
- package/dist/sorted-graph-catalog-projection.d.ts +9 -0
- package/dist/sorted-graph-catalog-projection.d.ts.map +1 -0
- package/dist/sorted-graph-catalog-projection.js +17 -0
- package/dist/sorted-graph-catalog-projection.js.map +1 -0
- package/dist/sparql-json-query-result.d.ts +46 -0
- package/dist/sparql-json-query-result.d.ts.map +1 -0
- package/dist/sparql-json-query-result.js +186 -0
- package/dist/sparql-json-query-result.js.map +1 -0
- package/dist/store-operation-outcome.d.ts +28 -0
- package/dist/store-operation-outcome.d.ts.map +1 -0
- package/dist/store-operation-outcome.js +54 -0
- package/dist/store-operation-outcome.js.map +1 -0
- package/dist/store-operation-timeout.d.ts +9 -2
- package/dist/store-operation-timeout.d.ts.map +1 -1
- package/dist/store-operation-timeout.js +8 -0
- package/dist/store-operation-timeout.js.map +1 -1
- package/dist/store-priority-scheduler.d.ts +25 -4
- package/dist/store-priority-scheduler.d.ts.map +1 -1
- package/dist/store-priority-scheduler.js +30 -15
- package/dist/store-priority-scheduler.js.map +1 -1
- package/dist/swm-materialization-witness.d.ts +4 -0
- package/dist/swm-materialization-witness.d.ts.map +1 -1
- package/dist/swm-materialization-witness.js +2 -2
- package/dist/swm-materialization-witness.js.map +1 -1
- package/dist/triple-store.d.ts +74 -2
- package/dist/triple-store.d.ts.map +1 -1
- package/dist/triple-store.js +75 -7
- package/dist/triple-store.js.map +1 -1
- package/dist/unsupported-capability-error.d.ts +7 -2
- package/dist/unsupported-capability-error.d.ts.map +1 -1
- package/dist/unsupported-capability-error.js +9 -0
- package/dist/unsupported-capability-error.js.map +1 -1
- package/dist/worker-error-protocol.d.ts +16 -0
- package/dist/worker-error-protocol.d.ts.map +1 -0
- package/dist/worker-error-protocol.js +27 -0
- package/dist/worker-error-protocol.js.map +1 -0
- package/package.json +22 -4
- package/dist/adapters/sparql-json-results.d.ts +0 -32
- package/dist/adapters/sparql-json-results.d.ts.map +0 -1
- package/dist/adapters/sparql-json-results.js +0 -37
- package/dist/adapters/sparql-json-results.js.map +0 -1
package/README.md
CHANGED
|
@@ -33,6 +33,56 @@ await store.insert(quads);
|
|
|
33
33
|
const result = await store.query('SELECT * WHERE { ?s ?p ?o } LIMIT 10');
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
## Oxigraph persistence contract
|
|
37
|
+
|
|
38
|
+
This contract applies to `OxigraphStore` when it is created with a persistence
|
|
39
|
+
path (`oxigraph-persistent`) and to `oxigraph-worker` when that worker is given
|
|
40
|
+
a persistence path. Plain `oxigraph`, and a worker without a persistence path,
|
|
41
|
+
are in-memory stores and provide no restart durability.
|
|
42
|
+
|
|
43
|
+
### Mutation and flush semantics
|
|
44
|
+
|
|
45
|
+
- Mutations update the in-memory store immediately and schedule a full N-Quads
|
|
46
|
+
snapshot after a 50 ms debounce. A successful mutation does not by itself
|
|
47
|
+
mean the snapshot has reached disk.
|
|
48
|
+
- Callers that require an operation to survive an immediate restart must await
|
|
49
|
+
`flush()`. It cancels a pending debounce, waits for an in-flight snapshot,
|
|
50
|
+
and then writes the current state.
|
|
51
|
+
- A snapshot is written to a sibling temporary file, the file is synced, and
|
|
52
|
+
then atomically renamed over the persistence file. The containing directory
|
|
53
|
+
is synced when the platform supports it. A crash before the rename retains
|
|
54
|
+
the previous complete snapshot; a temporary file may remain for cleanup.
|
|
55
|
+
- Background flush failures are logged. Explicit `flush()` and `close()` calls
|
|
56
|
+
reject on write, sync, or rename failures so their callers can report that
|
|
57
|
+
recent in-memory changes may not be durable.
|
|
58
|
+
|
|
59
|
+
### Hydration and corruption
|
|
60
|
+
|
|
61
|
+
- Construction synchronously loads an existing non-empty persistence file.
|
|
62
|
+
Read failures abort construction.
|
|
63
|
+
- Invalid N-Quads are never swallowed. The file is renamed to
|
|
64
|
+
`<persist-path>.corrupt-<timestamp>` for forensics, the failure is logged,
|
|
65
|
+
and construction throws. A later start can continue with an empty store
|
|
66
|
+
while the quarantined file remains available for investigation.
|
|
67
|
+
|
|
68
|
+
### Graceful shutdown
|
|
69
|
+
|
|
70
|
+
- `close()` cancels the debounce, waits for any in-flight snapshot, and runs a
|
|
71
|
+
final flush. For `oxigraph-worker`, the close request delegates to that same
|
|
72
|
+
final flush and is not subject to the read-operation timeout; the worker is
|
|
73
|
+
terminated only after the request settles.
|
|
74
|
+
- `DKGAgent.stop()` awaits `store.close()`. If the final flush fails, shutdown
|
|
75
|
+
continues but emits a loud operator-facing error stating that the on-disk
|
|
76
|
+
store may be missing recent inserts.
|
|
77
|
+
- Forced termination can still lose changes made after the last successful
|
|
78
|
+
flush. The atomic snapshot protocol protects the previously persisted file
|
|
79
|
+
from a torn overwrite; it cannot make unflushed memory durable.
|
|
80
|
+
|
|
81
|
+
The executable regression contract is in
|
|
82
|
+
[`test/oxigraph-persistence.test.ts`](test/oxigraph-persistence.test.ts). The
|
|
83
|
+
[archived WM persistence incident report](../../docs/archive/internal/bugs/wm-persistence-regression.md)
|
|
84
|
+
retains the original diagnosis, reproduction evidence, and fix history.
|
|
85
|
+
|
|
36
86
|
## Embedded worker store (`oxigraph-worker`) tuning
|
|
37
87
|
|
|
38
88
|
The embedded worker runs **all** store operations on a single worker thread, so
|
|
@@ -76,6 +126,12 @@ operation rejected before dispatch receives `StoreSchedulerBusyError` with
|
|
|
76
126
|
the operation closure starts, retrying it cannot duplicate a write that might
|
|
77
127
|
already have reached the store.
|
|
78
128
|
|
|
129
|
+
Each external adapter supplies the canonical store operation as queue-entry
|
|
130
|
+
metadata, and the scheduler binds it when creating either admission rejection.
|
|
131
|
+
Decorators validate that tagged operation-outcome contract rather than the
|
|
132
|
+
error class alone: a rejected nested read does not imply that an enclosing
|
|
133
|
+
replace failed before mutation.
|
|
134
|
+
|
|
79
135
|
| Environment variable | Default | Purpose |
|
|
80
136
|
|---|---:|---|
|
|
81
137
|
| `DKG_STORE_MAX_CONCURRENT` | `8` | Maximum external-store operations in flight. |
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { createHash } = require('node:crypto');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Canonical, buildless Blazegraph namespace contract shared by storage,
|
|
7
|
+
* product/CLI provisioning, shell entry points, and rollout certification.
|
|
8
|
+
* Keeping the policy in this leaf CJS module lets pre-build shell callers use
|
|
9
|
+
* the exact same normalization, validation, and XML rendering as TypeScript.
|
|
10
|
+
*/
|
|
11
|
+
const BLAZEGRAPH_NAMESPACE_XML_TEMPLATE = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
12
|
+
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
|
13
|
+
<properties>
|
|
14
|
+
<entry key="com.bigdata.rdf.sail.namespace">{namespace}</entry>
|
|
15
|
+
<entry key="com.bigdata.rdf.store.AbstractTripleStore.quads">true</entry>
|
|
16
|
+
<entry key="com.bigdata.rdf.store.AbstractTripleStore.statementIdentifiers">false</entry>
|
|
17
|
+
<entry key="com.bigdata.rdf.store.AbstractTripleStore.textIndex">false</entry>
|
|
18
|
+
<entry key="com.bigdata.rdf.sail.truthMaintenance">false</entry>
|
|
19
|
+
<entry key="com.bigdata.rdf.store.AbstractTripleStore.axiomsClass">com.bigdata.rdf.axioms.NoAxioms</entry>
|
|
20
|
+
</properties>`;
|
|
21
|
+
|
|
22
|
+
const BLAZEGRAPH_NAMESPACE_PATTERN = /^[A-Za-z0-9._-]{1,128}$/;
|
|
23
|
+
|
|
24
|
+
function assertBlazegraphNamespace(namespace) {
|
|
25
|
+
if (
|
|
26
|
+
typeof namespace !== 'string'
|
|
27
|
+
|| !BLAZEGRAPH_NAMESPACE_PATTERN.test(namespace)
|
|
28
|
+
|| namespace === '.'
|
|
29
|
+
|| namespace === '..'
|
|
30
|
+
) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`Blazegraph namespace ${JSON.stringify(namespace)} is invalid: it must match ${BLAZEGRAPH_NAMESPACE_PATTERN} and cannot be a URL dot segment`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function normalizeBlazegraphNamespace(namespace) {
|
|
38
|
+
if (typeof namespace !== 'string') {
|
|
39
|
+
throw new TypeError('Blazegraph namespace input must be a string');
|
|
40
|
+
}
|
|
41
|
+
const candidate = namespace
|
|
42
|
+
.normalize('NFKD')
|
|
43
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
44
|
+
.replace(/[^a-zA-Z0-9_.-]+/g, '-')
|
|
45
|
+
.replace(/^-+|-+$/g, '')
|
|
46
|
+
.toLowerCase();
|
|
47
|
+
const slug = candidate.length === 0 || candidate === '.' || candidate === '..'
|
|
48
|
+
? 'dkg-node'
|
|
49
|
+
: candidate;
|
|
50
|
+
if (slug.length <= 128) return slug;
|
|
51
|
+
const suffix = createHash('sha256').update(slug).digest('hex').slice(0, 12);
|
|
52
|
+
return `${slug.slice(0, 115)}-${suffix}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function renderBlazegraphNamespaceXml(namespace) {
|
|
56
|
+
assertBlazegraphNamespace(namespace);
|
|
57
|
+
return BLAZEGRAPH_NAMESPACE_XML_TEMPLATE.replace('{namespace}', namespace);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = Object.freeze({
|
|
61
|
+
BLAZEGRAPH_NAMESPACE_PATTERN,
|
|
62
|
+
BLAZEGRAPH_NAMESPACE_XML_TEMPLATE,
|
|
63
|
+
assertBlazegraphNamespace,
|
|
64
|
+
normalizeBlazegraphNamespace,
|
|
65
|
+
renderBlazegraphNamespaceXml,
|
|
66
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface BlazegraphNamespaceContract {
|
|
2
|
+
readonly BLAZEGRAPH_NAMESPACE_PATTERN: RegExp;
|
|
3
|
+
readonly BLAZEGRAPH_NAMESPACE_XML_TEMPLATE: string;
|
|
4
|
+
assertBlazegraphNamespace(namespace: string): void;
|
|
5
|
+
normalizeBlazegraphNamespace(namespace: string): string;
|
|
6
|
+
renderBlazegraphNamespaceXml(namespace: string): string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare const contract: BlazegraphNamespaceContract;
|
|
10
|
+
export = contract;
|
|
@@ -8,7 +8,21 @@ export interface AbortSignalScope {
|
|
|
8
8
|
readonly signal: AbortSignal | undefined;
|
|
9
9
|
dispose(): void;
|
|
10
10
|
}
|
|
11
|
+
export interface StoreWorkTimeoutRace {
|
|
12
|
+
readonly timeoutMs: number;
|
|
13
|
+
readonly timeoutError: () => Error;
|
|
14
|
+
}
|
|
15
|
+
export interface StoreWorkRaceOptions<T> {
|
|
16
|
+
readonly onLateResult?: (value: T) => void | Promise<void>;
|
|
17
|
+
readonly timeout?: StoreWorkTimeoutRace;
|
|
18
|
+
}
|
|
11
19
|
export declare function composeAbortSignals(primary: AbortSignal | undefined, secondary: AbortSignal | undefined): AbortSignalScope;
|
|
20
|
+
/**
|
|
21
|
+
* Race one already-started operation against cancellation without leaking a
|
|
22
|
+
* listener or an unhandled late settlement. An optional late-result hook owns
|
|
23
|
+
* resources that arrive after cancellation (for example a backend iterator).
|
|
24
|
+
*/
|
|
25
|
+
export declare function raceStoreWorkAgainstAbort<T>(work: Promise<T>, signal: AbortSignal | undefined, options?: StoreWorkRaceOptions<T>): Promise<T>;
|
|
12
26
|
/**
|
|
13
27
|
* Owns admission, cancellation, and draining for reusable store adapters.
|
|
14
28
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abortable-store-work-lifecycle.d.ts","sourceRoot":"","sources":["../src/abortable-store-work-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IACzC,OAAO,IAAI,IAAI,CAAC;CACjB;AAID,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,SAAS,EAAE,WAAW,GAAG,SAAS,GACjC,gBAAgB,CA8BlB;
|
|
1
|
+
{"version":3,"file":"abortable-store-work-lifecycle.d.ts","sourceRoot":"","sources":["../src/abortable-store-work-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IACzC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,KAAK,CAAC;CACpC;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAID,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,SAAS,EAAE,WAAW,GAAG,SAAS,GACjC,gBAAgB,CA8BlB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EACzC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,OAAO,GAAE,oBAAoB,CAAC,CAAC,CAAM,GACpC,OAAO,CAAC,CAAC,CAAC,CA0CZ;AAoBD;;;;;;;;GAQG;AACH,qBAAa,2BAA2B;IACtC,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,YAAY,CAA8B;IAElD,GAAG,CAAC,CAAC,EACH,YAAY,EAAE,WAAW,GAAG,SAAS,EACrC,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,GACrD,OAAO,CAAC,CAAC,CAAC;IAyBb,KAAK,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBpC"}
|
|
@@ -35,6 +35,57 @@ export function composeAbortSignals(primary, secondary) {
|
|
|
35
35
|
}
|
|
36
36
|
return { signal: combined.signal, dispose };
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Race one already-started operation against cancellation without leaking a
|
|
40
|
+
* listener or an unhandled late settlement. An optional late-result hook owns
|
|
41
|
+
* resources that arrive after cancellation (for example a backend iterator).
|
|
42
|
+
*/
|
|
43
|
+
export function raceStoreWorkAgainstAbort(work, signal, options = {}) {
|
|
44
|
+
const timeoutMs = options.timeout?.timeoutMs ?? 0;
|
|
45
|
+
if (!signal && timeoutMs <= 0)
|
|
46
|
+
return work;
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
let settled = false;
|
|
49
|
+
let timer;
|
|
50
|
+
const finish = (action) => {
|
|
51
|
+
if (settled)
|
|
52
|
+
return false;
|
|
53
|
+
settled = true;
|
|
54
|
+
if (timer)
|
|
55
|
+
clearTimeout(timer);
|
|
56
|
+
signal?.removeEventListener('abort', onAbort);
|
|
57
|
+
action();
|
|
58
|
+
return true;
|
|
59
|
+
};
|
|
60
|
+
const consumeLateResult = (value) => {
|
|
61
|
+
if (!options.onLateResult)
|
|
62
|
+
return;
|
|
63
|
+
void Promise.resolve()
|
|
64
|
+
.then(() => options.onLateResult?.(value))
|
|
65
|
+
.catch(() => undefined);
|
|
66
|
+
};
|
|
67
|
+
const onAbort = () => finish(() => reject(normalizeAbortReason(signal?.reason)));
|
|
68
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
69
|
+
// Attach both handlers before observing pre-abort so every started promise
|
|
70
|
+
// remains consumed even when cancellation wins the race immediately.
|
|
71
|
+
work.then((value) => {
|
|
72
|
+
if (!finish(() => resolve(value)))
|
|
73
|
+
consumeLateResult(value);
|
|
74
|
+
}, (cause) => finish(() => reject(cause)));
|
|
75
|
+
if (signal?.aborted) {
|
|
76
|
+
onAbort();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (timeoutMs > 0) {
|
|
80
|
+
timer = setTimeout(() => finish(() => reject(options.timeout.timeoutError())), timeoutMs);
|
|
81
|
+
if (typeof timer.unref === 'function')
|
|
82
|
+
timer.unref();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function normalizeAbortReason(reason) {
|
|
87
|
+
return reason instanceof Error ? reason : new Error(String(reason ?? 'aborted'));
|
|
88
|
+
}
|
|
38
89
|
function createGeneration() {
|
|
39
90
|
return {
|
|
40
91
|
controller: new AbortController(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abortable-store-work-lifecycle.js","sourceRoot":"","sources":["../src/abortable-store-work-lifecycle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abortable-store-work-lifecycle.js","sourceRoot":"","sources":["../src/abortable-store-work-lifecycle.ts"],"names":[],"mappings":"AAqBA,MAAM,YAAY,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAE9B,MAAM,UAAU,mBAAmB,CACjC,OAAgC,EAChC,SAAkC;IAElC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;IAClE,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;IAElE,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACvC,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,IAAI,QAAQ;YAAE,OAAO;QACrB,QAAQ,GAAG,IAAI,CAAC;QAChB,OAAO,CAAC,mBAAmB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QACrD,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAC3D,CAAC,CAAC;IACF,MAAM,cAAc,GAAG,GAAG,EAAE;QAC1B,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO;QAChD,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IACF,MAAM,gBAAgB,GAAG,GAAG,EAAE;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0,0 +1,19 @@
|
|
|
1
|
+
export interface LazyAbortableStreamOptions<T> {
|
|
2
|
+
/** Absolute monotonic deadline shared by open, reads, and cleanup. */
|
|
3
|
+
readonly deadlineAt: number;
|
|
4
|
+
readonly signal?: AbortSignal;
|
|
5
|
+
readonly timeoutMessage: string;
|
|
6
|
+
readonly open: (signal: AbortSignal | undefined) => Promise<AsyncIterable<T>>;
|
|
7
|
+
readonly invalidSource: () => never;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Open and consume one backend stream under a single lazy cancellation scope.
|
|
11
|
+
*
|
|
12
|
+
* The helper owns the generic resource lifecycle: no backend is opened before
|
|
13
|
+
* first iteration, non-cooperative open/read promises are raced against the
|
|
14
|
+
* deadline, a source arriving after cancellation is closed, early consumer
|
|
15
|
+
* return closes the acquired iterator, and signal listeners are always
|
|
16
|
+
* released. Protocol-specific validation remains with the caller.
|
|
17
|
+
*/
|
|
18
|
+
export declare function openLazyAbortableStream<T>(options: LazyAbortableStreamOptions<T>): AsyncIterable<T>;
|
|
19
|
+
//# sourceMappingURL=abortable-stream-work-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abortable-stream-work-lifecycle.d.ts","sourceRoot":"","sources":["../src/abortable-stream-work-lifecycle.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,0BAA0B,CAAC,CAAC;IAC3C,sEAAsE;IACtE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,QAAQ,CAAC,aAAa,EAAE,MAAM,KAAK,CAAC;CACrC;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,OAAO,EAAE,0BAA0B,CAAC,CAAC,CAAC,GACrC,aAAa,CAAC,CAAC,CAAC,CAsElB"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { composeAbortSignals, raceStoreWorkAgainstAbort, } from './abortable-store-work-lifecycle.js';
|
|
2
|
+
/**
|
|
3
|
+
* Open and consume one backend stream under a single lazy cancellation scope.
|
|
4
|
+
*
|
|
5
|
+
* The helper owns the generic resource lifecycle: no backend is opened before
|
|
6
|
+
* first iteration, non-cooperative open/read promises are raced against the
|
|
7
|
+
* deadline, a source arriving after cancellation is closed, early consumer
|
|
8
|
+
* return closes the acquired iterator, and signal listeners are always
|
|
9
|
+
* released. Protocol-specific validation remains with the caller.
|
|
10
|
+
*/
|
|
11
|
+
export function openLazyAbortableStream(options) {
|
|
12
|
+
return run();
|
|
13
|
+
async function* run() {
|
|
14
|
+
const remainingMs = options.deadlineAt - performance.now();
|
|
15
|
+
if (remainingMs <= 0)
|
|
16
|
+
throw timeout(options.timeoutMessage);
|
|
17
|
+
const deadlineSignal = AbortSignal.timeout(Math.max(1, Math.ceil(remainingMs)));
|
|
18
|
+
const signalScope = composeAbortSignals(options.signal, deadlineSignal);
|
|
19
|
+
try {
|
|
20
|
+
assertActive(signalScope.signal, options.deadlineAt, options.timeoutMessage);
|
|
21
|
+
const pendingSource = options.open(signalScope.signal);
|
|
22
|
+
let source;
|
|
23
|
+
try {
|
|
24
|
+
source = await raceStoreWorkAgainstAbort(pendingSource, signalScope.signal, {
|
|
25
|
+
onLateResult: async (lateSource) => {
|
|
26
|
+
if (isAsyncIterable(lateSource))
|
|
27
|
+
await closeAsyncIterable(lateSource);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch (cause) {
|
|
32
|
+
assertActive(signalScope.signal, options.deadlineAt, options.timeoutMessage);
|
|
33
|
+
throw cause;
|
|
34
|
+
}
|
|
35
|
+
if (!isAsyncIterable(source)) {
|
|
36
|
+
assertActive(signalScope.signal, options.deadlineAt, options.timeoutMessage);
|
|
37
|
+
options.invalidSource();
|
|
38
|
+
}
|
|
39
|
+
const iterator = source[Symbol.asyncIterator]();
|
|
40
|
+
let complete = false;
|
|
41
|
+
try {
|
|
42
|
+
// Once open() has produced a valid stream, its iterator must belong to
|
|
43
|
+
// this cleanup scope before observing cancellation again. Otherwise a
|
|
44
|
+
// cancellation delivered between promise settlement and this
|
|
45
|
+
// continuation can strand the acquired backend resource.
|
|
46
|
+
assertActive(signalScope.signal, options.deadlineAt, options.timeoutMessage);
|
|
47
|
+
while (true) {
|
|
48
|
+
assertActive(signalScope.signal, options.deadlineAt, options.timeoutMessage);
|
|
49
|
+
let next;
|
|
50
|
+
try {
|
|
51
|
+
next = await raceStoreWorkAgainstAbort(Promise.resolve(iterator.next()), signalScope.signal);
|
|
52
|
+
}
|
|
53
|
+
catch (cause) {
|
|
54
|
+
assertActive(signalScope.signal, options.deadlineAt, options.timeoutMessage);
|
|
55
|
+
throw cause;
|
|
56
|
+
}
|
|
57
|
+
assertActive(signalScope.signal, options.deadlineAt, options.timeoutMessage);
|
|
58
|
+
if (next.done) {
|
|
59
|
+
complete = true;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
yield next.value;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
if (!complete) {
|
|
67
|
+
await raceStoreWorkAgainstAbort(Promise.resolve().then(() => iterator.return?.()), signalScope.signal).catch(() => undefined);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
assertActive(signalScope.signal, options.deadlineAt, options.timeoutMessage);
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
signalScope.dispose();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function closeAsyncIterable(source) {
|
|
78
|
+
const iterator = source[Symbol.asyncIterator]();
|
|
79
|
+
await iterator.return?.();
|
|
80
|
+
}
|
|
81
|
+
function isAsyncIterable(value) {
|
|
82
|
+
return value !== null
|
|
83
|
+
&& (typeof value === 'object' || typeof value === 'function')
|
|
84
|
+
&& typeof value[Symbol.asyncIterator]
|
|
85
|
+
=== 'function';
|
|
86
|
+
}
|
|
87
|
+
function assertActive(signal, deadlineAt, timeoutMessage) {
|
|
88
|
+
signal?.throwIfAborted();
|
|
89
|
+
if (performance.now() >= deadlineAt)
|
|
90
|
+
throw timeout(timeoutMessage);
|
|
91
|
+
}
|
|
92
|
+
function timeout(message) {
|
|
93
|
+
return new DOMException(message, 'TimeoutError');
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=abortable-stream-work-lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abortable-stream-work-lifecycle.js","sourceRoot":"","sources":["../src/abortable-stream-work-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,qCAAqC,CAAC;AAW7C;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAsC;IAEtC,OAAO,GAAG,EAAE,CAAC;IAEb,KAAK,SAAS,CAAC,CAAC,GAAG;QACjB,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC3D,IAAI,WAAW,IAAI,CAAC;YAAE,MAAM,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAC5D,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAChF,MAAM,WAAW,GAAG,mBAAmB,CAAC,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QACxE,IAAI,CAAC;YACH,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;YAC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AAK,IAAI;WAChB,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;WAC1D,OAAQ,KAA8C,CAAC,MAAM,CAAC,aAAa,CAAC;gBACzE,UAAU,CAAC;AACrB,CAAC;AAED,SAAS,YAAY,CACnB,MAA+B,EAC/B,UAAkB,EAClB,cAAsB;IAEtB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,IAAI,WAAW,CAAC,GAAG,EAAE,IAAI,UAAU;QAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,OAAO,CAAC,OAAe;IAC9B,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { TripleStore, Quad as DKGQuad, QueryOptions, UpdateOptions, StorePressureSnapshot, TripleStoreQueryOptions, QueryResult } from '../triple-store.js';
|
|
2
|
+
import { type Rfc64SemanticReadOperationV1 } from '@origintrail-official/dkg-core';
|
|
3
|
+
import { type Rfc64ExactBindingsReadOperationV1 } from '../rfc64-exact-bindings-read-capability.js';
|
|
4
|
+
import { type StorePriorityScheduler } from '../store-priority-scheduler.js';
|
|
5
|
+
import { type Rfc64AuthorCommitCasInputV1, type Rfc64AuthorCommitCasResultV1 } from '../rfc64-author-commit-cas.js';
|
|
2
6
|
export declare const DEFAULT_BLAZEGRAPH_OPERATION_TIMEOUT_MS = 30000;
|
|
3
7
|
export interface BlazegraphStoreOptions {
|
|
4
8
|
/** End-to-end timeout including scheduler wait, HTTP work, and response decoding. */
|
|
5
9
|
timeout?: number;
|
|
10
|
+
/** Optional scheduler injection for embedded callers and adapter-boundary tests. */
|
|
11
|
+
scheduler?: StorePriorityScheduler;
|
|
6
12
|
}
|
|
7
13
|
/**
|
|
8
14
|
* BlazegraphStore — TripleStore adapter backed by a remote Blazegraph
|
|
@@ -14,14 +20,24 @@ export interface BlazegraphStoreOptions {
|
|
|
14
20
|
*/
|
|
15
21
|
export declare class BlazegraphStore implements TripleStore {
|
|
16
22
|
readonly queryCancellation: "interruptible";
|
|
23
|
+
readonly rfc64ExactBindingsReadCertifiedV1: true;
|
|
24
|
+
readonly rfc64SemanticReadCertifiedV1: true;
|
|
25
|
+
readonly rfc64SharedProjectionStreamCertifiedV1: true;
|
|
26
|
+
readonly rfc64SharedProjectionStreamV1: (operation: import("@origintrail-official/dkg-core").Rfc64SharedProjectionStreamOperationV1, options: import("../triple-store.js").Rfc64SharedProjectionStreamCapabilityOptionsV1) => Promise<AsyncIterable<Uint8Array>>;
|
|
17
27
|
private readonly url;
|
|
18
28
|
private readonly operationTimeoutMs;
|
|
29
|
+
private readonly scheduler;
|
|
19
30
|
constructor(url: string, options?: BlazegraphStoreOptions);
|
|
31
|
+
private runStreamingConstruct;
|
|
32
|
+
rfc64ExactBindingsReadV1(operation: Rfc64ExactBindingsReadOperationV1, options?: Pick<QueryOptions, 'signal'>): Promise<readonly import("@origintrail-official/dkg-core").TypedRdfStoreRowV1[]>;
|
|
33
|
+
rfc64SemanticReadV1(operation: Rfc64SemanticReadOperationV1, options?: Pick<QueryOptions, 'signal'>): Promise<import("../rfc64-exact-bindings-read-capability.js").Rfc64SemanticReadCapabilityResultV1>;
|
|
20
34
|
private runStoreWork;
|
|
21
35
|
getPressureSnapshot(): StorePressureSnapshot;
|
|
22
36
|
insert(quads: DKGQuad[], options?: QueryOptions): Promise<void>;
|
|
23
37
|
delete(quads: DKGQuad[], options?: QueryOptions): Promise<void>;
|
|
24
38
|
deleteByPattern(pattern: Partial<DKGQuad>, options?: QueryOptions): Promise<number>;
|
|
39
|
+
deleteByPatternWithoutCount(pattern: Partial<DKGQuad>, options?: QueryOptions): Promise<void>;
|
|
40
|
+
private applyDeleteByPattern;
|
|
25
41
|
deleteBySubjectPrefix(graphUri: string, prefix: string, options?: QueryOptions): Promise<number>;
|
|
26
42
|
/**
|
|
27
43
|
* Server-side SPARQL UPDATE — POSTs the update verbatim to the endpoint so a
|
|
@@ -37,7 +53,9 @@ export declare class BlazegraphStore implements TripleStore {
|
|
|
37
53
|
replaceGraph(graphUri: string, quads: DKGQuad[], options?: QueryOptions): Promise<void>;
|
|
38
54
|
replaceGraphAndSubject(graphUri: string, graphQuads: DKGQuad[], metaGraphUri: string, metadataSubject: string, metadataQuads: DKGQuad[], options?: QueryOptions): Promise<void>;
|
|
39
55
|
replaceSubject(graphUri: string, subject: string, quads: DKGQuad[], options?: QueryOptions): Promise<void>;
|
|
56
|
+
rfc64AuthorCommitCasV1(input: Rfc64AuthorCommitCasInputV1, options?: QueryOptions): Promise<Rfc64AuthorCommitCasResultV1>;
|
|
40
57
|
query(sparql: string, options?: TripleStoreQueryOptions): Promise<QueryResult>;
|
|
58
|
+
private queryWithOperation;
|
|
41
59
|
/**
|
|
42
60
|
* Server-side query bound sent with every read. See
|
|
43
61
|
* {@link SERVER_QUERY_DEADLINE_FACTOR} for why this is wider than the
|
|
@@ -51,6 +69,7 @@ export declare class BlazegraphStore implements TripleStore {
|
|
|
51
69
|
* leaving their distinct response decoding in the callers.
|
|
52
70
|
*/
|
|
53
71
|
private postReadQuery;
|
|
72
|
+
private postReadRequest;
|
|
54
73
|
private queryConstruct;
|
|
55
74
|
hasGraph(graphUri: string, options?: QueryOptions): Promise<boolean>;
|
|
56
75
|
createGraph(_graphUri: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blazegraph.d.ts","sourceRoot":"","sources":["../../src/adapters/blazegraph.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,IAAI,IAAI,OAAO,EACf,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,WAAW,
|
|
1
|
+
{"version":3,"file":"blazegraph.d.ts","sourceRoot":"","sources":["../../src/adapters/blazegraph.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,IAAI,IAAI,OAAO,EACf,YAAY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