@utaba/deep-memory 0.17.0 → 0.18.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/dist/{StorageProvider-DDTLUcuj.d.ts → StorageProvider-B2p_XThQ.d.ts} +1 -1
- package/dist/{StorageProvider-DGH7bVuK.d.cts → StorageProvider-CadKZ85j.d.cts} +1 -1
- package/dist/index.cjs +51 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +51 -37
- package/dist/index.js.map +1 -1
- package/dist/{portability-Dbm6vCdD.d.cts → portability-CAeyzSCx.d.cts} +15 -5
- package/dist/{portability-Dbm6vCdD.d.ts → portability-CAeyzSCx.d.ts} +15 -5
- package/dist/providers/index.d.cts +4 -4
- package/dist/providers/index.d.ts +4 -4
- package/dist/testing/conformance.cjs +2 -2
- package/dist/testing/conformance.cjs.map +1 -1
- package/dist/testing/conformance.d.cts +2 -2
- package/dist/testing/conformance.d.ts +2 -2
- package/dist/testing/conformance.js +2 -2
- package/dist/testing/conformance.js.map +1 -1
- package/dist/{traversal-1f35drOx.d.cts → traversal-Dql81Wh4.d.ts} +12 -7
- package/dist/{traversal-OkXViSTI.d.ts → traversal-WLcdLN-Z.d.cts} +12 -7
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { au as StorageRepositoryConfig, aB as StoredRepository, ad as RepositoryFilter, T as PaginatedResult, aC as StoredRepositorySummary, ah as RepositoryUpdate, g as DeleteProgressCallback, af as RepositoryStats, O as MemoryVocabulary, U as PaginationOptions, aM as VocabularyChangeRecord, ay as StoredEntity, az as StoredEntityUpdate, an as StorageFindQuery, aA as StoredRelationship, a5 as RelationshipQueryOptions, am as StorageExploreOptions, ao as StorageNeighborhood, as as StoragePathOptions, at as StoragePathResult, aw as StorageTimelineOptions, ax as StorageTimelineResult, s as ExportChunk, J as ImportChunk, B as BulkImportOptions, d as BulkImportResult } from './portability-
|
|
1
|
+
import { au as StorageRepositoryConfig, aB as StoredRepository, ad as RepositoryFilter, T as PaginatedResult, aC as StoredRepositorySummary, ah as RepositoryUpdate, g as DeleteProgressCallback, af as RepositoryStats, O as MemoryVocabulary, U as PaginationOptions, aM as VocabularyChangeRecord, ay as StoredEntity, az as StoredEntityUpdate, an as StorageFindQuery, aA as StoredRelationship, a5 as RelationshipQueryOptions, am as StorageExploreOptions, ao as StorageNeighborhood, as as StoragePathOptions, at as StoragePathResult, aw as StorageTimelineOptions, ax as StorageTimelineResult, s as ExportChunk, J as ImportChunk, B as BulkImportOptions, d as BulkImportResult } from './portability-CAeyzSCx.js';
|
|
2
2
|
|
|
3
3
|
/** Result returned by ensureSchema describing what actions were taken. */
|
|
4
4
|
interface EnsureSchemaResult {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { au as StorageRepositoryConfig, aB as StoredRepository, ad as RepositoryFilter, T as PaginatedResult, aC as StoredRepositorySummary, ah as RepositoryUpdate, g as DeleteProgressCallback, af as RepositoryStats, O as MemoryVocabulary, U as PaginationOptions, aM as VocabularyChangeRecord, ay as StoredEntity, az as StoredEntityUpdate, an as StorageFindQuery, aA as StoredRelationship, a5 as RelationshipQueryOptions, am as StorageExploreOptions, ao as StorageNeighborhood, as as StoragePathOptions, at as StoragePathResult, aw as StorageTimelineOptions, ax as StorageTimelineResult, s as ExportChunk, J as ImportChunk, B as BulkImportOptions, d as BulkImportResult } from './portability-
|
|
1
|
+
import { au as StorageRepositoryConfig, aB as StoredRepository, ad as RepositoryFilter, T as PaginatedResult, aC as StoredRepositorySummary, ah as RepositoryUpdate, g as DeleteProgressCallback, af as RepositoryStats, O as MemoryVocabulary, U as PaginationOptions, aM as VocabularyChangeRecord, ay as StoredEntity, az as StoredEntityUpdate, an as StorageFindQuery, aA as StoredRelationship, a5 as RelationshipQueryOptions, am as StorageExploreOptions, ao as StorageNeighborhood, as as StoragePathOptions, at as StoragePathResult, aw as StorageTimelineOptions, ax as StorageTimelineResult, s as ExportChunk, J as ImportChunk, B as BulkImportOptions, d as BulkImportResult } from './portability-CAeyzSCx.cjs';
|
|
2
2
|
|
|
3
3
|
/** Result returned by ensureSchema describing what actions were taken. */
|
|
4
4
|
interface EnsureSchemaResult {
|
package/dist/index.cjs
CHANGED
|
@@ -1438,13 +1438,36 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1438
1438
|
unionFullLength = unionElements.length;
|
|
1439
1439
|
const pageSlice = unionElements.slice(offset, offset + limit);
|
|
1440
1440
|
const pageEntries = [];
|
|
1441
|
+
const pageEntityIds = /* @__PURE__ */ new Set();
|
|
1441
1442
|
for (const element of pageSlice) {
|
|
1442
1443
|
if (element.kind === "entity") {
|
|
1443
|
-
|
|
1444
|
+
if (!pageEntityIds.has(element.entry.entity.id)) {
|
|
1445
|
+
pageEntityIds.add(element.entry.entity.id);
|
|
1446
|
+
pageEntries.push(element.entry);
|
|
1447
|
+
}
|
|
1444
1448
|
} else {
|
|
1445
1449
|
pagedAllRels.push(element.rel);
|
|
1446
1450
|
}
|
|
1447
1451
|
}
|
|
1452
|
+
if (pagedAllRels.length > 0) {
|
|
1453
|
+
const entityIndex = /* @__PURE__ */ new Map();
|
|
1454
|
+
for (const el of unionElements) {
|
|
1455
|
+
if (el.kind === "entity" && !entityIndex.has(el.entry.entity.id)) {
|
|
1456
|
+
entityIndex.set(el.entry.entity.id, el.entry);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
for (const rel of pagedAllRels) {
|
|
1460
|
+
for (const endpointId of [rel.sourceEntityId, rel.targetEntityId]) {
|
|
1461
|
+
if (!pageEntityIds.has(endpointId)) {
|
|
1462
|
+
const entry = entityIndex.get(endpointId);
|
|
1463
|
+
if (entry) {
|
|
1464
|
+
pageEntityIds.add(endpointId);
|
|
1465
|
+
pageEntries.push(entry);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1448
1471
|
paged = pageEntries;
|
|
1449
1472
|
total = pageEntries.length + pagedAllRels.length;
|
|
1450
1473
|
} else {
|
|
@@ -1472,13 +1495,13 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1472
1495
|
direction: "both",
|
|
1473
1496
|
limit: 1e4
|
|
1474
1497
|
});
|
|
1475
|
-
const summary = {
|
|
1498
|
+
const summary = { out: {}, in: {} };
|
|
1476
1499
|
for (const rel of result.items) {
|
|
1477
1500
|
if (rel.sourceEntityId === entry.entity.id) {
|
|
1478
|
-
summary.
|
|
1501
|
+
summary.out[rel.relationshipType] = (summary.out[rel.relationshipType] ?? 0) + 1;
|
|
1479
1502
|
}
|
|
1480
1503
|
if (rel.targetEntityId === entry.entity.id) {
|
|
1481
|
-
summary.
|
|
1504
|
+
summary.in[rel.relationshipType] = (summary.in[rel.relationshipType] ?? 0) + 1;
|
|
1482
1505
|
}
|
|
1483
1506
|
}
|
|
1484
1507
|
return summary;
|
|
@@ -1541,7 +1564,7 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1541
1564
|
type: rel.relationshipType,
|
|
1542
1565
|
sourceEntityId: rel.sourceEntityId,
|
|
1543
1566
|
targetEntityId: rel.targetEntityId,
|
|
1544
|
-
direction: "
|
|
1567
|
+
direction: "out",
|
|
1545
1568
|
properties: rel.properties
|
|
1546
1569
|
}));
|
|
1547
1570
|
} else if (!suppressEntities && spec.returnMode === "path") {
|
|
@@ -1556,7 +1579,7 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1556
1579
|
type: rel.relationshipType,
|
|
1557
1580
|
sourceEntityId: rel.sourceEntityId,
|
|
1558
1581
|
targetEntityId: rel.targetEntityId,
|
|
1559
|
-
direction: fromId === rel.sourceEntityId ? "
|
|
1582
|
+
direction: fromId === rel.sourceEntityId ? "out" : "in",
|
|
1560
1583
|
properties: rel.properties
|
|
1561
1584
|
});
|
|
1562
1585
|
}
|
|
@@ -1595,7 +1618,7 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1595
1618
|
type: rel.relationshipType,
|
|
1596
1619
|
sourceEntityId: rel.sourceEntityId,
|
|
1597
1620
|
targetEntityId: rel.targetEntityId,
|
|
1598
|
-
direction: fromId === rel.sourceEntityId ? "
|
|
1621
|
+
direction: fromId === rel.sourceEntityId ? "out" : "in",
|
|
1599
1622
|
properties: rel.properties
|
|
1600
1623
|
};
|
|
1601
1624
|
})
|
|
@@ -1624,7 +1647,7 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1624
1647
|
};
|
|
1625
1648
|
}
|
|
1626
1649
|
async function executeSingleStep(repositoryId, storage, frontier, step, onStorageCall) {
|
|
1627
|
-
const direction =
|
|
1650
|
+
const direction = step.direction;
|
|
1628
1651
|
const pendingEdges = [];
|
|
1629
1652
|
for (const entry of frontier) {
|
|
1630
1653
|
const rels = await storage.getEntityRelationships(repositoryId, entry.entity.id, {
|
|
@@ -1719,16 +1742,6 @@ async function resolveEntity(repositoryId, storage, idOrSlug) {
|
|
|
1719
1742
|
if (byId) return byId;
|
|
1720
1743
|
return storage.getEntityBySlug(repositoryId, idOrSlug);
|
|
1721
1744
|
}
|
|
1722
|
-
function mapDirection(direction) {
|
|
1723
|
-
switch (direction) {
|
|
1724
|
-
case "out":
|
|
1725
|
-
return "outbound";
|
|
1726
|
-
case "in":
|
|
1727
|
-
return "inbound";
|
|
1728
|
-
case "both":
|
|
1729
|
-
return "both";
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
1745
|
function getTargetId(rel, currentEntityId) {
|
|
1733
1746
|
if (rel.sourceEntityId === currentEntityId) {
|
|
1734
1747
|
return rel.targetEntityId;
|
|
@@ -1771,6 +1784,12 @@ function buildAllModeUnion(entries) {
|
|
|
1771
1784
|
}
|
|
1772
1785
|
for (let depth = 1; depth <= maxDepth; depth++) {
|
|
1773
1786
|
const bucket = byDepth.get(depth) ?? [];
|
|
1787
|
+
for (const entry of bucket) {
|
|
1788
|
+
if (!seenEntities.has(entry.entity.id)) {
|
|
1789
|
+
seenEntities.add(entry.entity.id);
|
|
1790
|
+
result.push({ kind: "entity", entry });
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1774
1793
|
for (const entry of bucket) {
|
|
1775
1794
|
const newRel = entry.relationshipPath[depth - 1];
|
|
1776
1795
|
if (newRel && !seenRels.has(newRel.id)) {
|
|
@@ -1778,12 +1797,6 @@ function buildAllModeUnion(entries) {
|
|
|
1778
1797
|
result.push({ kind: "relationship", rel: newRel });
|
|
1779
1798
|
}
|
|
1780
1799
|
}
|
|
1781
|
-
for (const entry of bucket) {
|
|
1782
|
-
if (!seenEntities.has(entry.entity.id)) {
|
|
1783
|
-
seenEntities.add(entry.entity.id);
|
|
1784
|
-
result.push({ kind: "entity", entry });
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
1800
|
}
|
|
1788
1801
|
return result;
|
|
1789
1802
|
}
|
|
@@ -1923,7 +1936,7 @@ var GraphTraversal = class {
|
|
|
1923
1936
|
return {
|
|
1924
1937
|
id: rid,
|
|
1925
1938
|
type: r?.type ?? "unknown",
|
|
1926
|
-
direction: r?.sourceEntityId === currentEntityId ? "
|
|
1939
|
+
direction: r?.sourceEntityId === currentEntityId ? "out" : "in",
|
|
1927
1940
|
properties: r?.properties ?? {}
|
|
1928
1941
|
};
|
|
1929
1942
|
})
|
|
@@ -2550,7 +2563,7 @@ var MemoryRepository = class {
|
|
|
2550
2563
|
inbound[rel.relationshipType] = (inbound[rel.relationshipType] ?? 0) + 1;
|
|
2551
2564
|
}
|
|
2552
2565
|
}
|
|
2553
|
-
return { outbound, inbound };
|
|
2566
|
+
return { out: outbound, in: inbound };
|
|
2554
2567
|
}
|
|
2555
2568
|
async getRelationshipsForEntities(entityIds) {
|
|
2556
2569
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2758,9 +2771,10 @@ var MemoryRepository = class {
|
|
|
2758
2771
|
### Step 1 \u2014 Discover before you traverse
|
|
2759
2772
|
|
|
2760
2773
|
Before following relationships from an entity, check that it actually has relationships.
|
|
2761
|
-
Graph queries include \`relationshipSummary\` on every returned entity by default
|
|
2762
|
-
(
|
|
2763
|
-
zero
|
|
2774
|
+
Graph queries include \`relationshipSummary\` on every returned entity by default \u2014
|
|
2775
|
+
\`out\` (entity is source) and \`in\` (entity is target) counts by relationship type.
|
|
2776
|
+
Inspect this before traversing: entities with zero counts for the relationship type
|
|
2777
|
+
you need have no connections to follow.
|
|
2764
2778
|
To skip summaries and reduce response size, set \`includeRelationshipSummary: false\`.
|
|
2765
2779
|
|
|
2766
2780
|
### Step 2 \u2014 Use projection for aggregation
|
|
@@ -3643,7 +3657,7 @@ var EventBus = class {
|
|
|
3643
3657
|
};
|
|
3644
3658
|
|
|
3645
3659
|
// src/portability/RepositoryExporter.ts
|
|
3646
|
-
var LIBRARY_VERSION = true ? "0.
|
|
3660
|
+
var LIBRARY_VERSION = true ? "0.18.0" : "0.1.0";
|
|
3647
3661
|
var RepositoryExporter = class {
|
|
3648
3662
|
storage;
|
|
3649
3663
|
provenance;
|
|
@@ -4921,8 +4935,8 @@ var GremlinCompiler = class {
|
|
|
4921
4935
|
const branches = [`__.identity().${VERTEX_PROJECT_EXPR}`];
|
|
4922
4936
|
let prefix = "";
|
|
4923
4937
|
for (const { edge, vertex, entityFilters } of compiledSteps) {
|
|
4924
|
-
branches.push(`__${prefix}${edge}.${EDGE_PROJECT_EXPR}`);
|
|
4925
4938
|
branches.push(`__${prefix}${edge}${vertex}${entityFilters}.${VERTEX_PROJECT_EXPR}`);
|
|
4939
|
+
branches.push(`__${prefix}${edge}.${EDGE_PROJECT_EXPR}`);
|
|
4926
4940
|
prefix = `${prefix}${edge}${vertex}`;
|
|
4927
4941
|
estimatedFanOut *= DEFAULT_ESTIMATED_FANOUT_PER_HOP;
|
|
4928
4942
|
}
|
|
@@ -5517,9 +5531,9 @@ var InMemoryStorageProvider = class {
|
|
|
5517
5531
|
const isTarget = rel.targetEntityId === entityId;
|
|
5518
5532
|
const isBidirectionalTarget = rel.bidirectional && isTarget;
|
|
5519
5533
|
switch (direction) {
|
|
5520
|
-
case "
|
|
5534
|
+
case "out":
|
|
5521
5535
|
return isSource || isBidirectionalTarget;
|
|
5522
|
-
case "
|
|
5536
|
+
case "in":
|
|
5523
5537
|
return isTarget || rel.bidirectional && isSource;
|
|
5524
5538
|
case "both":
|
|
5525
5539
|
default:
|
|
@@ -5617,17 +5631,17 @@ var InMemoryStorageProvider = class {
|
|
|
5617
5631
|
const isTarget = rel.targetEntityId === frontierEntityId;
|
|
5618
5632
|
let matchesDirection = false;
|
|
5619
5633
|
let connectedEntityId;
|
|
5620
|
-
if (isSource && (options.direction === "
|
|
5634
|
+
if (isSource && (options.direction === "out" || options.direction === "both")) {
|
|
5621
5635
|
matchesDirection = true;
|
|
5622
5636
|
connectedEntityId = rel.targetEntityId;
|
|
5623
|
-
} else if (isTarget && (options.direction === "
|
|
5637
|
+
} else if (isTarget && (options.direction === "in" || options.direction === "both")) {
|
|
5624
5638
|
matchesDirection = true;
|
|
5625
5639
|
connectedEntityId = rel.sourceEntityId;
|
|
5626
5640
|
} else if (rel.bidirectional) {
|
|
5627
|
-
if (isSource && options.direction === "
|
|
5641
|
+
if (isSource && options.direction === "in") {
|
|
5628
5642
|
matchesDirection = true;
|
|
5629
5643
|
connectedEntityId = rel.targetEntityId;
|
|
5630
|
-
} else if (isTarget && options.direction === "
|
|
5644
|
+
} else if (isTarget && options.direction === "out") {
|
|
5631
5645
|
matchesDirection = true;
|
|
5632
5646
|
connectedEntityId = rel.sourceEntityId;
|
|
5633
5647
|
}
|