@sixb/sqlite 0.1.4 → 0.1.6
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/index.js +40 -32
- package/dist/index.js.map +4 -4
- package/dist/ontology-storage/materialization-state.d.ts +7 -3
- package/dist/ontology-storage/materialization-state.d.ts.map +1 -1
- package/dist/ontology-storage/materializations.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/ontology-storage/materialization-state.ts +53 -33
- package/src/ontology-storage/materializations.ts +4 -5
package/dist/index.js
CHANGED
|
@@ -9181,6 +9181,14 @@ import {
|
|
|
9181
9181
|
} from "@sixb/core/internal/ontology-storage-provider";
|
|
9182
9182
|
var SQLITE_MATERIALIZATION_WORK_TABLE = "ontology_materialization_work";
|
|
9183
9183
|
var SQLITE_REPLACEMENT_WORK_TABLE = "ontology_replacement_work";
|
|
9184
|
+
function linkScopeRequestJson(scopes) {
|
|
9185
|
+
return canonicalJson(scopes.map(({ source, linkId }) => ({
|
|
9186
|
+
scopeSortKey: linkScopeSortKey(source, linkId),
|
|
9187
|
+
sourceTypeId: source.objectTypeId,
|
|
9188
|
+
sourceId: source.primaryId,
|
|
9189
|
+
linkId
|
|
9190
|
+
})));
|
|
9191
|
+
}
|
|
9184
9192
|
|
|
9185
9193
|
class SqliteMaterializationStateReader {
|
|
9186
9194
|
db;
|
|
@@ -9389,20 +9397,15 @@ class SqliteMaterializationStateReader {
|
|
|
9389
9397
|
return stored ? [stored] : [];
|
|
9390
9398
|
});
|
|
9391
9399
|
}
|
|
9392
|
-
|
|
9400
|
+
linkScopeRevisions(scopes) {
|
|
9393
9401
|
if (scopes.length === 0)
|
|
9394
9402
|
return [];
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
const accumulators = new Map(scopes.map(({ source, linkId }) => {
|
|
9402
|
-
const key = linkScopeSortKey(source, linkId);
|
|
9403
|
-
return [key, startScopeAccumulator(source, linkId)];
|
|
9404
|
-
}));
|
|
9405
|
-
const requestedJson = canonicalJson(requested);
|
|
9403
|
+
return this.readEffectiveLinkScopes(scopes, linkScopeRequestJson(scopes)).revisions;
|
|
9404
|
+
}
|
|
9405
|
+
linkSlotStates(scopes) {
|
|
9406
|
+
if (scopes.length === 0)
|
|
9407
|
+
return [];
|
|
9408
|
+
const requestedJson = linkScopeRequestJson(scopes);
|
|
9406
9409
|
const sourceRows = this.db.query(`WITH requested AS (
|
|
9407
9410
|
SELECT DISTINCT
|
|
9408
9411
|
json_extract(value, '$.sourceTypeId') AS source_type_id,
|
|
@@ -9441,6 +9444,22 @@ class SqliteMaterializationStateReader {
|
|
|
9441
9444
|
const stored = storedLinkSlotOverride(row);
|
|
9442
9445
|
return [linkScopeSortKey(stored.ref.source, stored.ref.linkId), stored];
|
|
9443
9446
|
}));
|
|
9447
|
+
const { revisions, effective } = this.readEffectiveLinkScopes(scopes, requestedJson);
|
|
9448
|
+
return scopes.map(({ source, linkId }, index) => {
|
|
9449
|
+
const key = linkScopeSortKey(source, linkId);
|
|
9450
|
+
return {
|
|
9451
|
+
...revisions[index],
|
|
9452
|
+
sourceAssertion: sources.get(key) ?? null,
|
|
9453
|
+
override: overrides.get(key) ?? null,
|
|
9454
|
+
effective: effective.get(key) ?? null
|
|
9455
|
+
};
|
|
9456
|
+
});
|
|
9457
|
+
}
|
|
9458
|
+
readEffectiveLinkScopes(scopes, requestedJson) {
|
|
9459
|
+
const accumulators = new Map(scopes.map(({ source, linkId }) => {
|
|
9460
|
+
const key = linkScopeSortKey(source, linkId);
|
|
9461
|
+
return [key, startScopeAccumulator(source, linkId)];
|
|
9462
|
+
}));
|
|
9444
9463
|
const effective = new Map;
|
|
9445
9464
|
const rows = this.db.query(`
|
|
9446
9465
|
WITH requested AS (
|
|
@@ -9469,22 +9488,10 @@ class SqliteMaterializationStateReader {
|
|
|
9469
9488
|
appendScopeSnapshot(accumulator2, snapshot);
|
|
9470
9489
|
effective.set(row.scope_sort_key, accumulator2.effectiveCount === 1 ? snapshot : null);
|
|
9471
9490
|
}
|
|
9472
|
-
return
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
sourceAssertion: sources.get(key) ?? null,
|
|
9477
|
-
override: overrides.get(key) ?? null,
|
|
9478
|
-
effective: effective.get(key) ?? null
|
|
9479
|
-
};
|
|
9480
|
-
});
|
|
9481
|
-
}
|
|
9482
|
-
linkScope(source, linkId) {
|
|
9483
|
-
const [scope] = this.linkScopes([{ source, linkId }]);
|
|
9484
|
-
if (!scope) {
|
|
9485
|
-
throw new MaterializationConflictError2("effective-state", "Link scope lookup returned no row.");
|
|
9486
|
-
}
|
|
9487
|
-
return scope;
|
|
9491
|
+
return {
|
|
9492
|
+
revisions: scopes.map(({ source, linkId }) => finishScopeAccumulator(accumulators.get(linkScopeSortKey(source, linkId)))),
|
|
9493
|
+
effective
|
|
9494
|
+
};
|
|
9488
9495
|
}
|
|
9489
9496
|
*incidentLinks(objects, pageRows) {
|
|
9490
9497
|
if (objects.length === 0)
|
|
@@ -10520,8 +10527,9 @@ class SqliteOntologyMaterializationStorage {
|
|
|
10520
10527
|
this.assertObject(reader, expected);
|
|
10521
10528
|
for (const expected of input.expected.links)
|
|
10522
10529
|
this.assertLink(reader, expected);
|
|
10523
|
-
|
|
10524
|
-
|
|
10530
|
+
const linkScopeRevisions = reader.linkScopeRevisions(input.expected.linkScopes);
|
|
10531
|
+
for (const [index, expected] of input.expected.linkScopes.entries()) {
|
|
10532
|
+
if (linkScopeRevisions[index]?.fingerprint !== expected.fingerprint) {
|
|
10525
10533
|
throw new MaterializationConflictError5("effective-state", `Expected link scope changed for ${expected.source.objectTypeId}:${expected.source.primaryId}.${expected.linkId}.`);
|
|
10526
10534
|
}
|
|
10527
10535
|
}
|
|
@@ -10567,7 +10575,7 @@ class SqliteOntologyMaterializationStorage {
|
|
|
10567
10575
|
yield {
|
|
10568
10576
|
objects: [],
|
|
10569
10577
|
links: [],
|
|
10570
|
-
linkScopes: reader.
|
|
10578
|
+
linkScopes: reader.linkSlotStates(scopes.slice(offset, offset + input.pageRows)),
|
|
10571
10579
|
points: []
|
|
10572
10580
|
};
|
|
10573
10581
|
}
|
|
@@ -14071,4 +14079,4 @@ export {
|
|
|
14071
14079
|
SqliteStorage
|
|
14072
14080
|
};
|
|
14073
14081
|
|
|
14074
|
-
//# debugId=
|
|
14082
|
+
//# debugId=65891EE349DAB6B764756E2164756E21
|