@utaba/deep-memory 0.17.0 → 0.19.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-CgWRfvIZ.d.ts} +1 -1
- package/dist/{StorageProvider-DGH7bVuK.d.cts → StorageProvider-RPhT7vtH.d.cts} +1 -1
- package/dist/index.cjs +131 -45
- 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 +131 -45
- package/dist/index.js.map +1 -1
- package/dist/{portability-Dbm6vCdD.d.cts → portability-BHyXmv5-.d.cts} +21 -5
- package/dist/{portability-Dbm6vCdD.d.ts → portability-BHyXmv5-.d.ts} +21 -5
- package/dist/providers/index.d.cts +4 -4
- package/dist/providers/index.d.ts +4 -4
- package/dist/testing/conformance.cjs +30 -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 +30 -2
- package/dist/testing/conformance.js.map +1 -1
- package/dist/{traversal-OkXViSTI.d.ts → traversal-BK_3Cqj3.d.cts} +12 -7
- package/dist/{traversal-1f35drOx.d.cts → traversal-CIGJcdCb.d.ts} +12 -7
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { z as GovernanceConfig, O as MemoryVocabulary, ai as ResolvedVocabulary, e as CreateEntityInput, aL as ValidationResult, aI as UpdateEntityInput, f as CreateRelationshipInput, m as EntityTypeDefinition, aO as VocabularyProposal, aP as VocabularyProposalResult, a0 as ProvenanceContext, $ as Provenance, i as Entity, h as DetailLevel, l as EntitySummary, j as EntityBrief, F as FindEntitiesQuery, T as PaginatedResult, D as DeleteEntitiesResult, a2 as ReembedResult, a3 as Relationship, ab as RemoveRelationshipsResult, Y as PropertyFilter, a6 as RelationshipSummary, I as GraphResult, q as ExploreOptions, P as Neighborhood, W as PathOptions, X as PathResult, C as ConceptSearchOptions, aj as ScoredEntity, aF as TimelineOptions, aH as TimelineResult, af as RepositoryStats, aJ as ValidateEntitiesOptions, p as EntityValidationPage, aK as ValidateRelationshipsOptions, aa as RelationshipValidationPage, ac as RepositoryConfig, aB as StoredRepository, ad as RepositoryFilter, ag as RepositorySummary, ah as RepositoryUpdate, v as ExportOptions, r as ExportArchive, K as ImportOptions, L as ImportResult, x as ExportStreamItem, M as ImportStreamHeader, J as ImportChunk, ay as StoredEntity, au as StorageRepositoryConfig, aC as StoredRepositorySummary, g as DeleteProgressCallback, U as PaginationOptions, aM as VocabularyChangeRecord, 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, B as BulkImportOptions, d as BulkImportResult, al as SearchOptions, ak as SearchHit } from './portability-
|
|
2
|
-
export { A as AdaptiveConcurrencyAdjustEvent, a as AdaptiveConcurrencyAdjustReason, b as AdaptiveConcurrencyHandle, c as AdaptiveConcurrencyOptions, E as EnrichedRelationship, k as EntityMap, n as EntityTypeInput, o as EntityValidationIssue, t as ExportLegalMetadata, u as ExportManifest, w as ExportPipelineMetadata, G as GetEntitiesOptions, y as GetEntityOptions, H as GovernanceMode, N as ImportWarning, Q as NeighborhoodCenter, R as NeighborhoodGroup, S as NeighborhoodLayer, V as Path, Z as PropertySchema, _ as PropertyType, a1 as ProvenanceFilter, a4 as RelationshipDirection, a7 as RelationshipTypeDefinition, a8 as RelationshipTypeInput, a9 as RelationshipValidationIssue, ae as RepositoryMetadata, ap as StorageNeighborhoodGroup, aq as StorageNeighborhoodLayer, ar as StoragePath, av as StorageTimelineEvent, aD as TimelineEntityRef, aE as TimelineEvent, aG as TimelineRelationshipDetail, aN as VocabularyInput } from './portability-
|
|
1
|
+
import { z as GovernanceConfig, O as MemoryVocabulary, ai as ResolvedVocabulary, e as CreateEntityInput, aL as ValidationResult, aI as UpdateEntityInput, f as CreateRelationshipInput, m as EntityTypeDefinition, aO as VocabularyProposal, aP as VocabularyProposalResult, a0 as ProvenanceContext, $ as Provenance, i as Entity, h as DetailLevel, l as EntitySummary, j as EntityBrief, F as FindEntitiesQuery, T as PaginatedResult, D as DeleteEntitiesResult, a2 as ReembedResult, a3 as Relationship, ab as RemoveRelationshipsResult, Y as PropertyFilter, a6 as RelationshipSummary, I as GraphResult, q as ExploreOptions, P as Neighborhood, W as PathOptions, X as PathResult, C as ConceptSearchOptions, aj as ScoredEntity, aF as TimelineOptions, aH as TimelineResult, af as RepositoryStats, aJ as ValidateEntitiesOptions, p as EntityValidationPage, aK as ValidateRelationshipsOptions, aa as RelationshipValidationPage, ac as RepositoryConfig, aB as StoredRepository, ad as RepositoryFilter, ag as RepositorySummary, ah as RepositoryUpdate, v as ExportOptions, r as ExportArchive, K as ImportOptions, L as ImportResult, x as ExportStreamItem, M as ImportStreamHeader, J as ImportChunk, ay as StoredEntity, au as StorageRepositoryConfig, aC as StoredRepositorySummary, g as DeleteProgressCallback, U as PaginationOptions, aM as VocabularyChangeRecord, 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, B as BulkImportOptions, d as BulkImportResult, al as SearchOptions, ak as SearchHit } from './portability-BHyXmv5-.cjs';
|
|
2
|
+
export { A as AdaptiveConcurrencyAdjustEvent, a as AdaptiveConcurrencyAdjustReason, b as AdaptiveConcurrencyHandle, c as AdaptiveConcurrencyOptions, E as EnrichedRelationship, k as EntityMap, n as EntityTypeInput, o as EntityValidationIssue, t as ExportLegalMetadata, u as ExportManifest, w as ExportPipelineMetadata, G as GetEntitiesOptions, y as GetEntityOptions, H as GovernanceMode, N as ImportWarning, Q as NeighborhoodCenter, R as NeighborhoodGroup, S as NeighborhoodLayer, V as Path, Z as PropertySchema, _ as PropertyType, a1 as ProvenanceFilter, a4 as RelationshipDirection, a7 as RelationshipTypeDefinition, a8 as RelationshipTypeInput, a9 as RelationshipValidationIssue, ae as RepositoryMetadata, ap as StorageNeighborhoodGroup, aq as StorageNeighborhoodLayer, ar as StoragePath, av as StorageTimelineEvent, aD as TimelineEntityRef, aE as TimelineEvent, aG as TimelineRelationshipDetail, aN as VocabularyInput } from './portability-BHyXmv5-.cjs';
|
|
3
3
|
import { DeepMemoryEventType, EventHandler, Unsubscribe, DeepMemoryEvent, HookResult, EventPayload, UsageSink } from './types/index.cjs';
|
|
4
4
|
export { OperationUsage } from './types/index.cjs';
|
|
5
|
-
import { f as TraversalSpec, d as TraversalResult } from './traversal-
|
|
6
|
-
export { Q as QueryMetadata, T as TraversalAggregation, a as TraversalPath, b as TraversalProjection, c as TraversalRelationship, e as TraversalReturnMode, g as TraversalStart, h as TraversalStep } from './traversal-
|
|
7
|
-
import { S as StorageProvider, E as EnsureSchemaResult, a as EntityReadOptions } from './StorageProvider-
|
|
5
|
+
import { f as TraversalSpec, d as TraversalResult } from './traversal-BK_3Cqj3.cjs';
|
|
6
|
+
export { Q as QueryMetadata, T as TraversalAggregation, a as TraversalPath, b as TraversalProjection, c as TraversalRelationship, e as TraversalReturnMode, g as TraversalStart, h as TraversalStep } from './traversal-BK_3Cqj3.cjs';
|
|
7
|
+
import { S as StorageProvider, E as EnsureSchemaResult, a as EntityReadOptions } from './StorageProvider-RPhT7vtH.cjs';
|
|
8
8
|
import { EmbeddingProvider, SearchProvider, EmbeddingProviderFactory, GraphTraversalProvider, LockProvider, SearchableEntity } from './providers/index.cjs';
|
|
9
9
|
export { GraphTraversalCapabilities, LockHandle, LockOptions } from './providers/index.cjs';
|
|
10
10
|
|
|
@@ -366,7 +366,7 @@ declare class MemoryRepository {
|
|
|
366
366
|
removeRelationships(ids: string[]): Promise<RemoveRelationshipsResult>;
|
|
367
367
|
getRelationships(entityId: string, options?: {
|
|
368
368
|
relationshipTypes?: string[];
|
|
369
|
-
direction?: '
|
|
369
|
+
direction?: 'out' | 'in' | 'both';
|
|
370
370
|
limit?: number;
|
|
371
371
|
offset?: number;
|
|
372
372
|
propertyFilters?: PropertyFilter[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { z as GovernanceConfig, O as MemoryVocabulary, ai as ResolvedVocabulary, e as CreateEntityInput, aL as ValidationResult, aI as UpdateEntityInput, f as CreateRelationshipInput, m as EntityTypeDefinition, aO as VocabularyProposal, aP as VocabularyProposalResult, a0 as ProvenanceContext, $ as Provenance, i as Entity, h as DetailLevel, l as EntitySummary, j as EntityBrief, F as FindEntitiesQuery, T as PaginatedResult, D as DeleteEntitiesResult, a2 as ReembedResult, a3 as Relationship, ab as RemoveRelationshipsResult, Y as PropertyFilter, a6 as RelationshipSummary, I as GraphResult, q as ExploreOptions, P as Neighborhood, W as PathOptions, X as PathResult, C as ConceptSearchOptions, aj as ScoredEntity, aF as TimelineOptions, aH as TimelineResult, af as RepositoryStats, aJ as ValidateEntitiesOptions, p as EntityValidationPage, aK as ValidateRelationshipsOptions, aa as RelationshipValidationPage, ac as RepositoryConfig, aB as StoredRepository, ad as RepositoryFilter, ag as RepositorySummary, ah as RepositoryUpdate, v as ExportOptions, r as ExportArchive, K as ImportOptions, L as ImportResult, x as ExportStreamItem, M as ImportStreamHeader, J as ImportChunk, ay as StoredEntity, au as StorageRepositoryConfig, aC as StoredRepositorySummary, g as DeleteProgressCallback, U as PaginationOptions, aM as VocabularyChangeRecord, 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, B as BulkImportOptions, d as BulkImportResult, al as SearchOptions, ak as SearchHit } from './portability-
|
|
2
|
-
export { A as AdaptiveConcurrencyAdjustEvent, a as AdaptiveConcurrencyAdjustReason, b as AdaptiveConcurrencyHandle, c as AdaptiveConcurrencyOptions, E as EnrichedRelationship, k as EntityMap, n as EntityTypeInput, o as EntityValidationIssue, t as ExportLegalMetadata, u as ExportManifest, w as ExportPipelineMetadata, G as GetEntitiesOptions, y as GetEntityOptions, H as GovernanceMode, N as ImportWarning, Q as NeighborhoodCenter, R as NeighborhoodGroup, S as NeighborhoodLayer, V as Path, Z as PropertySchema, _ as PropertyType, a1 as ProvenanceFilter, a4 as RelationshipDirection, a7 as RelationshipTypeDefinition, a8 as RelationshipTypeInput, a9 as RelationshipValidationIssue, ae as RepositoryMetadata, ap as StorageNeighborhoodGroup, aq as StorageNeighborhoodLayer, ar as StoragePath, av as StorageTimelineEvent, aD as TimelineEntityRef, aE as TimelineEvent, aG as TimelineRelationshipDetail, aN as VocabularyInput } from './portability-
|
|
1
|
+
import { z as GovernanceConfig, O as MemoryVocabulary, ai as ResolvedVocabulary, e as CreateEntityInput, aL as ValidationResult, aI as UpdateEntityInput, f as CreateRelationshipInput, m as EntityTypeDefinition, aO as VocabularyProposal, aP as VocabularyProposalResult, a0 as ProvenanceContext, $ as Provenance, i as Entity, h as DetailLevel, l as EntitySummary, j as EntityBrief, F as FindEntitiesQuery, T as PaginatedResult, D as DeleteEntitiesResult, a2 as ReembedResult, a3 as Relationship, ab as RemoveRelationshipsResult, Y as PropertyFilter, a6 as RelationshipSummary, I as GraphResult, q as ExploreOptions, P as Neighborhood, W as PathOptions, X as PathResult, C as ConceptSearchOptions, aj as ScoredEntity, aF as TimelineOptions, aH as TimelineResult, af as RepositoryStats, aJ as ValidateEntitiesOptions, p as EntityValidationPage, aK as ValidateRelationshipsOptions, aa as RelationshipValidationPage, ac as RepositoryConfig, aB as StoredRepository, ad as RepositoryFilter, ag as RepositorySummary, ah as RepositoryUpdate, v as ExportOptions, r as ExportArchive, K as ImportOptions, L as ImportResult, x as ExportStreamItem, M as ImportStreamHeader, J as ImportChunk, ay as StoredEntity, au as StorageRepositoryConfig, aC as StoredRepositorySummary, g as DeleteProgressCallback, U as PaginationOptions, aM as VocabularyChangeRecord, 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, B as BulkImportOptions, d as BulkImportResult, al as SearchOptions, ak as SearchHit } from './portability-BHyXmv5-.js';
|
|
2
|
+
export { A as AdaptiveConcurrencyAdjustEvent, a as AdaptiveConcurrencyAdjustReason, b as AdaptiveConcurrencyHandle, c as AdaptiveConcurrencyOptions, E as EnrichedRelationship, k as EntityMap, n as EntityTypeInput, o as EntityValidationIssue, t as ExportLegalMetadata, u as ExportManifest, w as ExportPipelineMetadata, G as GetEntitiesOptions, y as GetEntityOptions, H as GovernanceMode, N as ImportWarning, Q as NeighborhoodCenter, R as NeighborhoodGroup, S as NeighborhoodLayer, V as Path, Z as PropertySchema, _ as PropertyType, a1 as ProvenanceFilter, a4 as RelationshipDirection, a7 as RelationshipTypeDefinition, a8 as RelationshipTypeInput, a9 as RelationshipValidationIssue, ae as RepositoryMetadata, ap as StorageNeighborhoodGroup, aq as StorageNeighborhoodLayer, ar as StoragePath, av as StorageTimelineEvent, aD as TimelineEntityRef, aE as TimelineEvent, aG as TimelineRelationshipDetail, aN as VocabularyInput } from './portability-BHyXmv5-.js';
|
|
3
3
|
import { DeepMemoryEventType, EventHandler, Unsubscribe, DeepMemoryEvent, HookResult, EventPayload, UsageSink } from './types/index.js';
|
|
4
4
|
export { OperationUsage } from './types/index.js';
|
|
5
|
-
import { f as TraversalSpec, d as TraversalResult } from './traversal-
|
|
6
|
-
export { Q as QueryMetadata, T as TraversalAggregation, a as TraversalPath, b as TraversalProjection, c as TraversalRelationship, e as TraversalReturnMode, g as TraversalStart, h as TraversalStep } from './traversal-
|
|
7
|
-
import { S as StorageProvider, E as EnsureSchemaResult, a as EntityReadOptions } from './StorageProvider-
|
|
5
|
+
import { f as TraversalSpec, d as TraversalResult } from './traversal-CIGJcdCb.js';
|
|
6
|
+
export { Q as QueryMetadata, T as TraversalAggregation, a as TraversalPath, b as TraversalProjection, c as TraversalRelationship, e as TraversalReturnMode, g as TraversalStart, h as TraversalStep } from './traversal-CIGJcdCb.js';
|
|
7
|
+
import { S as StorageProvider, E as EnsureSchemaResult, a as EntityReadOptions } from './StorageProvider-CgWRfvIZ.js';
|
|
8
8
|
import { EmbeddingProvider, SearchProvider, EmbeddingProviderFactory, GraphTraversalProvider, LockProvider, SearchableEntity } from './providers/index.js';
|
|
9
9
|
export { GraphTraversalCapabilities, LockHandle, LockOptions } from './providers/index.js';
|
|
10
10
|
|
|
@@ -366,7 +366,7 @@ declare class MemoryRepository {
|
|
|
366
366
|
removeRelationships(ids: string[]): Promise<RemoveRelationshipsResult>;
|
|
367
367
|
getRelationships(entityId: string, options?: {
|
|
368
368
|
relationshipTypes?: string[];
|
|
369
|
-
direction?: '
|
|
369
|
+
direction?: 'out' | 'in' | 'both';
|
|
370
370
|
limit?: number;
|
|
371
371
|
offset?: number;
|
|
372
372
|
propertyFilters?: PropertyFilter[];
|
package/dist/index.js
CHANGED
|
@@ -1372,13 +1372,36 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1372
1372
|
unionFullLength = unionElements.length;
|
|
1373
1373
|
const pageSlice = unionElements.slice(offset, offset + limit);
|
|
1374
1374
|
const pageEntries = [];
|
|
1375
|
+
const pageEntityIds = /* @__PURE__ */ new Set();
|
|
1375
1376
|
for (const element of pageSlice) {
|
|
1376
1377
|
if (element.kind === "entity") {
|
|
1377
|
-
|
|
1378
|
+
if (!pageEntityIds.has(element.entry.entity.id)) {
|
|
1379
|
+
pageEntityIds.add(element.entry.entity.id);
|
|
1380
|
+
pageEntries.push(element.entry);
|
|
1381
|
+
}
|
|
1378
1382
|
} else {
|
|
1379
1383
|
pagedAllRels.push(element.rel);
|
|
1380
1384
|
}
|
|
1381
1385
|
}
|
|
1386
|
+
if (pagedAllRels.length > 0) {
|
|
1387
|
+
const entityIndex = /* @__PURE__ */ new Map();
|
|
1388
|
+
for (const el of unionElements) {
|
|
1389
|
+
if (el.kind === "entity" && !entityIndex.has(el.entry.entity.id)) {
|
|
1390
|
+
entityIndex.set(el.entry.entity.id, el.entry);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
for (const rel of pagedAllRels) {
|
|
1394
|
+
for (const endpointId of [rel.sourceEntityId, rel.targetEntityId]) {
|
|
1395
|
+
if (!pageEntityIds.has(endpointId)) {
|
|
1396
|
+
const entry = entityIndex.get(endpointId);
|
|
1397
|
+
if (entry) {
|
|
1398
|
+
pageEntityIds.add(endpointId);
|
|
1399
|
+
pageEntries.push(entry);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1382
1405
|
paged = pageEntries;
|
|
1383
1406
|
total = pageEntries.length + pagedAllRels.length;
|
|
1384
1407
|
} else {
|
|
@@ -1406,13 +1429,13 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1406
1429
|
direction: "both",
|
|
1407
1430
|
limit: 1e4
|
|
1408
1431
|
});
|
|
1409
|
-
const summary = {
|
|
1432
|
+
const summary = { out: {}, in: {} };
|
|
1410
1433
|
for (const rel of result.items) {
|
|
1411
1434
|
if (rel.sourceEntityId === entry.entity.id) {
|
|
1412
|
-
summary.
|
|
1435
|
+
summary.out[rel.relationshipType] = (summary.out[rel.relationshipType] ?? 0) + 1;
|
|
1413
1436
|
}
|
|
1414
1437
|
if (rel.targetEntityId === entry.entity.id) {
|
|
1415
|
-
summary.
|
|
1438
|
+
summary.in[rel.relationshipType] = (summary.in[rel.relationshipType] ?? 0) + 1;
|
|
1416
1439
|
}
|
|
1417
1440
|
}
|
|
1418
1441
|
return summary;
|
|
@@ -1475,7 +1498,7 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1475
1498
|
type: rel.relationshipType,
|
|
1476
1499
|
sourceEntityId: rel.sourceEntityId,
|
|
1477
1500
|
targetEntityId: rel.targetEntityId,
|
|
1478
|
-
direction: "
|
|
1501
|
+
direction: "out",
|
|
1479
1502
|
properties: rel.properties
|
|
1480
1503
|
}));
|
|
1481
1504
|
} else if (!suppressEntities && spec.returnMode === "path") {
|
|
@@ -1490,7 +1513,7 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1490
1513
|
type: rel.relationshipType,
|
|
1491
1514
|
sourceEntityId: rel.sourceEntityId,
|
|
1492
1515
|
targetEntityId: rel.targetEntityId,
|
|
1493
|
-
direction: fromId === rel.sourceEntityId ? "
|
|
1516
|
+
direction: fromId === rel.sourceEntityId ? "out" : "in",
|
|
1494
1517
|
properties: rel.properties
|
|
1495
1518
|
});
|
|
1496
1519
|
}
|
|
@@ -1529,7 +1552,7 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1529
1552
|
type: rel.relationshipType,
|
|
1530
1553
|
sourceEntityId: rel.sourceEntityId,
|
|
1531
1554
|
targetEntityId: rel.targetEntityId,
|
|
1532
|
-
direction: fromId === rel.sourceEntityId ? "
|
|
1555
|
+
direction: fromId === rel.sourceEntityId ? "out" : "in",
|
|
1533
1556
|
properties: rel.properties
|
|
1534
1557
|
};
|
|
1535
1558
|
})
|
|
@@ -1558,7 +1581,7 @@ async function executeFallbackTraversal(repositoryId, storage, spec) {
|
|
|
1558
1581
|
};
|
|
1559
1582
|
}
|
|
1560
1583
|
async function executeSingleStep(repositoryId, storage, frontier, step, onStorageCall) {
|
|
1561
|
-
const direction =
|
|
1584
|
+
const direction = step.direction;
|
|
1562
1585
|
const pendingEdges = [];
|
|
1563
1586
|
for (const entry of frontier) {
|
|
1564
1587
|
const rels = await storage.getEntityRelationships(repositoryId, entry.entity.id, {
|
|
@@ -1653,16 +1676,6 @@ async function resolveEntity(repositoryId, storage, idOrSlug) {
|
|
|
1653
1676
|
if (byId) return byId;
|
|
1654
1677
|
return storage.getEntityBySlug(repositoryId, idOrSlug);
|
|
1655
1678
|
}
|
|
1656
|
-
function mapDirection(direction) {
|
|
1657
|
-
switch (direction) {
|
|
1658
|
-
case "out":
|
|
1659
|
-
return "outbound";
|
|
1660
|
-
case "in":
|
|
1661
|
-
return "inbound";
|
|
1662
|
-
case "both":
|
|
1663
|
-
return "both";
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
1679
|
function getTargetId(rel, currentEntityId) {
|
|
1667
1680
|
if (rel.sourceEntityId === currentEntityId) {
|
|
1668
1681
|
return rel.targetEntityId;
|
|
@@ -1705,6 +1718,12 @@ function buildAllModeUnion(entries) {
|
|
|
1705
1718
|
}
|
|
1706
1719
|
for (let depth = 1; depth <= maxDepth; depth++) {
|
|
1707
1720
|
const bucket = byDepth.get(depth) ?? [];
|
|
1721
|
+
for (const entry of bucket) {
|
|
1722
|
+
if (!seenEntities.has(entry.entity.id)) {
|
|
1723
|
+
seenEntities.add(entry.entity.id);
|
|
1724
|
+
result.push({ kind: "entity", entry });
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1708
1727
|
for (const entry of bucket) {
|
|
1709
1728
|
const newRel = entry.relationshipPath[depth - 1];
|
|
1710
1729
|
if (newRel && !seenRels.has(newRel.id)) {
|
|
@@ -1712,12 +1731,6 @@ function buildAllModeUnion(entries) {
|
|
|
1712
1731
|
result.push({ kind: "relationship", rel: newRel });
|
|
1713
1732
|
}
|
|
1714
1733
|
}
|
|
1715
|
-
for (const entry of bucket) {
|
|
1716
|
-
if (!seenEntities.has(entry.entity.id)) {
|
|
1717
|
-
seenEntities.add(entry.entity.id);
|
|
1718
|
-
result.push({ kind: "entity", entry });
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
1734
|
}
|
|
1722
1735
|
return result;
|
|
1723
1736
|
}
|
|
@@ -1857,7 +1870,7 @@ var GraphTraversal = class {
|
|
|
1857
1870
|
return {
|
|
1858
1871
|
id: rid,
|
|
1859
1872
|
type: r?.type ?? "unknown",
|
|
1860
|
-
direction: r?.sourceEntityId === currentEntityId ? "
|
|
1873
|
+
direction: r?.sourceEntityId === currentEntityId ? "out" : "in",
|
|
1861
1874
|
properties: r?.properties ?? {}
|
|
1862
1875
|
};
|
|
1863
1876
|
})
|
|
@@ -2484,7 +2497,7 @@ var MemoryRepository = class {
|
|
|
2484
2497
|
inbound[rel.relationshipType] = (inbound[rel.relationshipType] ?? 0) + 1;
|
|
2485
2498
|
}
|
|
2486
2499
|
}
|
|
2487
|
-
return { outbound, inbound };
|
|
2500
|
+
return { out: outbound, in: inbound };
|
|
2488
2501
|
}
|
|
2489
2502
|
async getRelationshipsForEntities(entityIds) {
|
|
2490
2503
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2692,9 +2705,10 @@ var MemoryRepository = class {
|
|
|
2692
2705
|
### Step 1 \u2014 Discover before you traverse
|
|
2693
2706
|
|
|
2694
2707
|
Before following relationships from an entity, check that it actually has relationships.
|
|
2695
|
-
Graph queries include \`relationshipSummary\` on every returned entity by default
|
|
2696
|
-
(
|
|
2697
|
-
zero
|
|
2708
|
+
Graph queries include \`relationshipSummary\` on every returned entity by default \u2014
|
|
2709
|
+
\`out\` (entity is source) and \`in\` (entity is target) counts by relationship type.
|
|
2710
|
+
Inspect this before traversing: entities with zero counts for the relationship type
|
|
2711
|
+
you need have no connections to follow.
|
|
2698
2712
|
To skip summaries and reduce response size, set \`includeRelationshipSummary: false\`.
|
|
2699
2713
|
|
|
2700
2714
|
### Step 2 \u2014 Use projection for aggregation
|
|
@@ -3577,7 +3591,7 @@ var EventBus = class {
|
|
|
3577
3591
|
};
|
|
3578
3592
|
|
|
3579
3593
|
// src/portability/RepositoryExporter.ts
|
|
3580
|
-
var LIBRARY_VERSION = true ? "0.
|
|
3594
|
+
var LIBRARY_VERSION = true ? "0.19.0" : "0.1.0";
|
|
3581
3595
|
var RepositoryExporter = class {
|
|
3582
3596
|
storage;
|
|
3583
3597
|
provenance;
|
|
@@ -3609,6 +3623,9 @@ var RepositoryExporter = class {
|
|
|
3609
3623
|
type: repo.type,
|
|
3610
3624
|
label: repo.label,
|
|
3611
3625
|
description: repo.description,
|
|
3626
|
+
legal: repo.legal,
|
|
3627
|
+
owner: repo.owner,
|
|
3628
|
+
metadata: repo.metadata,
|
|
3612
3629
|
vocabularyVersion: vocabulary.version,
|
|
3613
3630
|
governanceMode: repo.governanceConfig.mode
|
|
3614
3631
|
},
|
|
@@ -4006,7 +4023,10 @@ var RepositoryImporter = class {
|
|
|
4006
4023
|
type: target.config.type,
|
|
4007
4024
|
label: target.config.label,
|
|
4008
4025
|
description: target.config.description,
|
|
4026
|
+
legal: target.config.legal,
|
|
4027
|
+
owner: target.config.owner,
|
|
4009
4028
|
governanceConfig: target.config.governance ?? { mode: "open" },
|
|
4029
|
+
metadata: target.config.metadata,
|
|
4010
4030
|
createdAt: now,
|
|
4011
4031
|
createdBy: this.actorId
|
|
4012
4032
|
});
|
|
@@ -4521,6 +4541,7 @@ var DeepMemory = class {
|
|
|
4521
4541
|
/** Import a repository from a portable archive */
|
|
4522
4542
|
async importRepository(archive, options) {
|
|
4523
4543
|
await this.ensureInitialized();
|
|
4544
|
+
this.validateRepositoryId(options.target.repositoryId);
|
|
4524
4545
|
await this.globalEventBus.emit("import:started", { repositoryId: options.target.repositoryId });
|
|
4525
4546
|
const importer = new RepositoryImporter({
|
|
4526
4547
|
storage: this.storage,
|
|
@@ -4621,6 +4642,7 @@ var DeepMemory = class {
|
|
|
4621
4642
|
*/
|
|
4622
4643
|
async importRepositoryStream(header, chunks, options) {
|
|
4623
4644
|
await this.ensureInitialized();
|
|
4645
|
+
this.validateRepositoryId(options.target.repositoryId);
|
|
4624
4646
|
const importer = new RepositoryImporter({
|
|
4625
4647
|
storage: this.storage,
|
|
4626
4648
|
actorId: this.provenance.getContext().actorId,
|
|
@@ -4855,8 +4877,8 @@ var GremlinCompiler = class {
|
|
|
4855
4877
|
const branches = [`__.identity().${VERTEX_PROJECT_EXPR}`];
|
|
4856
4878
|
let prefix = "";
|
|
4857
4879
|
for (const { edge, vertex, entityFilters } of compiledSteps) {
|
|
4858
|
-
branches.push(`__${prefix}${edge}.${EDGE_PROJECT_EXPR}`);
|
|
4859
4880
|
branches.push(`__${prefix}${edge}${vertex}${entityFilters}.${VERTEX_PROJECT_EXPR}`);
|
|
4881
|
+
branches.push(`__${prefix}${edge}.${EDGE_PROJECT_EXPR}`);
|
|
4860
4882
|
prefix = `${prefix}${edge}${vertex}`;
|
|
4861
4883
|
estimatedFanOut *= DEFAULT_ESTIMATED_FANOUT_PER_HOP;
|
|
4862
4884
|
}
|
|
@@ -4892,12 +4914,16 @@ var GremlinCompiler = class {
|
|
|
4892
4914
|
}
|
|
4893
4915
|
}
|
|
4894
4916
|
}
|
|
4895
|
-
|
|
4917
|
+
const emitProjection = spec.projection !== void 0 && returnMode === "terminal";
|
|
4918
|
+
if (returnMode === "terminal" && !emitProjection && spec.dedup !== false) {
|
|
4896
4919
|
parts.push(".dedup()");
|
|
4897
4920
|
}
|
|
4898
4921
|
if (returnMode === "path") {
|
|
4899
4922
|
parts.push(".simplePath()");
|
|
4900
4923
|
}
|
|
4924
|
+
if (emitProjection) {
|
|
4925
|
+
parts.push(emitProjectionTerminal(spec.projection));
|
|
4926
|
+
}
|
|
4901
4927
|
const limit = spec.limit ?? 50;
|
|
4902
4928
|
const offset = spec.offset ?? 0;
|
|
4903
4929
|
const pOffset = nextParam(offset);
|
|
@@ -4905,7 +4931,8 @@ var GremlinCompiler = class {
|
|
|
4905
4931
|
parts.push(`.range(${pOffset}, ${pEnd})`);
|
|
4906
4932
|
params["_limit"] = limit;
|
|
4907
4933
|
params["_offset"] = offset;
|
|
4908
|
-
if (
|
|
4934
|
+
if (emitProjection) {
|
|
4935
|
+
} else if (returnMode === "terminal") {
|
|
4909
4936
|
parts.push(`.${VERTEX_PROJECT_EXPR}`);
|
|
4910
4937
|
} else {
|
|
4911
4938
|
parts.push(`.path().by(${VERTEX_PROJECT_EXPR}).by(${EDGE_PROJECT_EXPR})`);
|
|
@@ -5001,6 +5028,31 @@ function compileRepeatStep(step, nextParam, useEdgeEmission) {
|
|
|
5001
5028
|
}
|
|
5002
5029
|
return parts.join("");
|
|
5003
5030
|
}
|
|
5031
|
+
var SAFE_PROJECTION_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
5032
|
+
function assertSafeProjectionKey(key) {
|
|
5033
|
+
if (!SAFE_PROJECTION_KEY_RE.test(key)) {
|
|
5034
|
+
throw new Error(
|
|
5035
|
+
`Unsafe projection property name: "${key}". Property names must match ${SAFE_PROJECTION_KEY_RE.source}.`
|
|
5036
|
+
);
|
|
5037
|
+
}
|
|
5038
|
+
}
|
|
5039
|
+
function emitProjectionTerminal(projection) {
|
|
5040
|
+
const properties = projection.properties;
|
|
5041
|
+
const mode = projection.mode ?? "values";
|
|
5042
|
+
const distinct = projection.distinct ?? false;
|
|
5043
|
+
for (const prop of properties) {
|
|
5044
|
+
assertSafeProjectionKey(prop);
|
|
5045
|
+
}
|
|
5046
|
+
const singleProperty = properties.length === 1;
|
|
5047
|
+
const keyExpr = singleProperty ? `values('${properties[0]}')` : `project(${properties.map((p) => `'${p}'`).join(",")})${properties.map((p) => `.by(values('${p}'))`).join("")}`;
|
|
5048
|
+
if (mode === "count") {
|
|
5049
|
+
return `.group().by(${keyExpr}).by(count()).unfold()`;
|
|
5050
|
+
}
|
|
5051
|
+
if (distinct) {
|
|
5052
|
+
return `.${keyExpr}.dedup()`;
|
|
5053
|
+
}
|
|
5054
|
+
return `.${keyExpr}`;
|
|
5055
|
+
}
|
|
5004
5056
|
function compilePropertyFilter(filter, nextParam) {
|
|
5005
5057
|
const key = nextParam(filter.key);
|
|
5006
5058
|
switch (filter.operator) {
|
|
@@ -5110,17 +5162,35 @@ var CypherCompiler = class {
|
|
|
5110
5162
|
}
|
|
5111
5163
|
lastNode = targetNode;
|
|
5112
5164
|
}
|
|
5113
|
-
const
|
|
5165
|
+
const bindPath = spec.returnMode === "path";
|
|
5166
|
+
const pathBinding = bindPath ? "p = " : "";
|
|
5167
|
+
const matchClause = `MATCH ${pathBinding}${matchParts[0]}${matchParts.slice(1).join("")}`;
|
|
5114
5168
|
const whereClause = whereClauses.length > 0 ? `
|
|
5115
5169
|
WHERE ${whereClauses.join(" AND ")}` : "";
|
|
5116
5170
|
let returnClause;
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
const
|
|
5120
|
-
|
|
5171
|
+
const emitProjection = spec.projection !== void 0 && spec.returnMode !== "path" && spec.returnMode !== "all";
|
|
5172
|
+
if (emitProjection) {
|
|
5173
|
+
const projection = spec.projection;
|
|
5174
|
+
const mode = projection.mode ?? "values";
|
|
5175
|
+
const distinct = projection.distinct ?? false;
|
|
5176
|
+
const projectionColumns = projection.properties.map((prop) => {
|
|
5177
|
+
assertSafeProjectionKey2(prop);
|
|
5178
|
+
return `${lastNode}.${prop} AS ${prop}`;
|
|
5179
|
+
});
|
|
5180
|
+
if (mode === "count") {
|
|
5181
|
+
returnClause = `RETURN ${projectionColumns.join(", ")}, count(*) AS count`;
|
|
5182
|
+
} else if (distinct) {
|
|
5183
|
+
returnClause = `RETURN DISTINCT ${projectionColumns.join(", ")}`;
|
|
5184
|
+
} else {
|
|
5185
|
+
returnClause = `RETURN ${projectionColumns.join(", ")}`;
|
|
5186
|
+
}
|
|
5187
|
+
} else if (spec.returnMode === "path") {
|
|
5188
|
+
returnClause = "RETURN nodes(p) AS pathNodes, relationships(p) AS pathRels, length(p) AS pathLength";
|
|
5121
5189
|
} else if (spec.returnMode === "all") {
|
|
5122
5190
|
const allNodes = Array.from({ length: nodeIndex }, (_, i) => `n${i}`);
|
|
5123
|
-
|
|
5191
|
+
const allRels = steps.map((_, i) => `r${i}`);
|
|
5192
|
+
const projection = [...allNodes, ...allRels].join(", ");
|
|
5193
|
+
returnClause = spec.dedup !== false ? `RETURN DISTINCT ${projection}` : `RETURN ${projection}`;
|
|
5124
5194
|
} else {
|
|
5125
5195
|
returnClause = spec.dedup !== false ? `RETURN DISTINCT ${lastNode}` : `RETURN ${lastNode}`;
|
|
5126
5196
|
}
|
|
@@ -5141,6 +5211,14 @@ ${returnClause}${skipClause}${limitClause}`;
|
|
|
5141
5211
|
};
|
|
5142
5212
|
}
|
|
5143
5213
|
};
|
|
5214
|
+
var SAFE_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
5215
|
+
function assertSafeProjectionKey2(key) {
|
|
5216
|
+
if (!SAFE_KEY_RE.test(key)) {
|
|
5217
|
+
throw new Error(
|
|
5218
|
+
`Unsafe projection property name: "${key}". Property names must match ${SAFE_KEY_RE.source}.`
|
|
5219
|
+
);
|
|
5220
|
+
}
|
|
5221
|
+
}
|
|
5144
5222
|
function compilePropertyFilterCypher(nodeAlias, filter, nextParam) {
|
|
5145
5223
|
const prop = `${nodeAlias}.${filter.key}`;
|
|
5146
5224
|
switch (filter.operator) {
|
|
@@ -5451,9 +5529,9 @@ var InMemoryStorageProvider = class {
|
|
|
5451
5529
|
const isTarget = rel.targetEntityId === entityId;
|
|
5452
5530
|
const isBidirectionalTarget = rel.bidirectional && isTarget;
|
|
5453
5531
|
switch (direction) {
|
|
5454
|
-
case "
|
|
5532
|
+
case "out":
|
|
5455
5533
|
return isSource || isBidirectionalTarget;
|
|
5456
|
-
case "
|
|
5534
|
+
case "in":
|
|
5457
5535
|
return isTarget || rel.bidirectional && isSource;
|
|
5458
5536
|
case "both":
|
|
5459
5537
|
default:
|
|
@@ -5545,23 +5623,24 @@ var InMemoryStorageProvider = class {
|
|
|
5545
5623
|
for (let depth = 0; depth < options.depth; depth++) {
|
|
5546
5624
|
const layer = {};
|
|
5547
5625
|
const nextFrontier = /* @__PURE__ */ new Set();
|
|
5626
|
+
const layerBucketSeen = /* @__PURE__ */ new Map();
|
|
5548
5627
|
for (const frontierEntityId of currentFrontier) {
|
|
5549
5628
|
for (const rel of store.relationships.values()) {
|
|
5550
5629
|
const isSource = rel.sourceEntityId === frontierEntityId;
|
|
5551
5630
|
const isTarget = rel.targetEntityId === frontierEntityId;
|
|
5552
5631
|
let matchesDirection = false;
|
|
5553
5632
|
let connectedEntityId;
|
|
5554
|
-
if (isSource && (options.direction === "
|
|
5633
|
+
if (isSource && (options.direction === "out" || options.direction === "both")) {
|
|
5555
5634
|
matchesDirection = true;
|
|
5556
5635
|
connectedEntityId = rel.targetEntityId;
|
|
5557
|
-
} else if (isTarget && (options.direction === "
|
|
5636
|
+
} else if (isTarget && (options.direction === "in" || options.direction === "both")) {
|
|
5558
5637
|
matchesDirection = true;
|
|
5559
5638
|
connectedEntityId = rel.sourceEntityId;
|
|
5560
5639
|
} else if (rel.bidirectional) {
|
|
5561
|
-
if (isSource && options.direction === "
|
|
5640
|
+
if (isSource && options.direction === "in") {
|
|
5562
5641
|
matchesDirection = true;
|
|
5563
5642
|
connectedEntityId = rel.targetEntityId;
|
|
5564
|
-
} else if (isTarget && options.direction === "
|
|
5643
|
+
} else if (isTarget && options.direction === "out") {
|
|
5565
5644
|
matchesDirection = true;
|
|
5566
5645
|
connectedEntityId = rel.sourceEntityId;
|
|
5567
5646
|
}
|
|
@@ -5582,6 +5661,13 @@ var InMemoryStorageProvider = class {
|
|
|
5582
5661
|
continue;
|
|
5583
5662
|
}
|
|
5584
5663
|
const relType = rel.relationshipType;
|
|
5664
|
+
let bucketSeen = layerBucketSeen.get(relType);
|
|
5665
|
+
if (!bucketSeen) {
|
|
5666
|
+
bucketSeen = /* @__PURE__ */ new Set();
|
|
5667
|
+
layerBucketSeen.set(relType, bucketSeen);
|
|
5668
|
+
}
|
|
5669
|
+
if (bucketSeen.has(connectedEntityId)) continue;
|
|
5670
|
+
bucketSeen.add(connectedEntityId);
|
|
5585
5671
|
if (!layer[relType]) {
|
|
5586
5672
|
layer[relType] = { total: 0, entities: [], relationships: [] };
|
|
5587
5673
|
}
|