@utaba/deep-memory 0.18.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-B2p_XThQ.d.ts → StorageProvider-CgWRfvIZ.d.ts} +1 -1
- package/dist/{StorageProvider-CadKZ85j.d.cts → StorageProvider-RPhT7vtH.d.cts} +1 -1
- package/dist/index.cjs +81 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +81 -9
- package/dist/index.js.map +1 -1
- package/dist/{portability-CAeyzSCx.d.cts → portability-BHyXmv5-.d.cts} +6 -0
- package/dist/{portability-CAeyzSCx.d.ts → portability-BHyXmv5-.d.ts} +6 -0
- package/dist/providers/index.d.cts +3 -3
- package/dist/providers/index.d.ts +3 -3
- package/dist/testing/conformance.cjs +28 -0
- 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 +28 -0
- package/dist/testing/conformance.js.map +1 -1
- package/dist/{traversal-WLcdLN-Z.d.cts → traversal-BK_3Cqj3.d.cts} +1 -1
- package/dist/{traversal-Dql81Wh4.d.ts → traversal-CIGJcdCb.d.ts} +1 -1
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/package.json +1 -1
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
|
|
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
|
|
package/dist/index.js
CHANGED
|
@@ -3591,7 +3591,7 @@ var EventBus = class {
|
|
|
3591
3591
|
};
|
|
3592
3592
|
|
|
3593
3593
|
// src/portability/RepositoryExporter.ts
|
|
3594
|
-
var LIBRARY_VERSION = true ? "0.
|
|
3594
|
+
var LIBRARY_VERSION = true ? "0.19.0" : "0.1.0";
|
|
3595
3595
|
var RepositoryExporter = class {
|
|
3596
3596
|
storage;
|
|
3597
3597
|
provenance;
|
|
@@ -3623,6 +3623,9 @@ var RepositoryExporter = class {
|
|
|
3623
3623
|
type: repo.type,
|
|
3624
3624
|
label: repo.label,
|
|
3625
3625
|
description: repo.description,
|
|
3626
|
+
legal: repo.legal,
|
|
3627
|
+
owner: repo.owner,
|
|
3628
|
+
metadata: repo.metadata,
|
|
3626
3629
|
vocabularyVersion: vocabulary.version,
|
|
3627
3630
|
governanceMode: repo.governanceConfig.mode
|
|
3628
3631
|
},
|
|
@@ -4020,7 +4023,10 @@ var RepositoryImporter = class {
|
|
|
4020
4023
|
type: target.config.type,
|
|
4021
4024
|
label: target.config.label,
|
|
4022
4025
|
description: target.config.description,
|
|
4026
|
+
legal: target.config.legal,
|
|
4027
|
+
owner: target.config.owner,
|
|
4023
4028
|
governanceConfig: target.config.governance ?? { mode: "open" },
|
|
4029
|
+
metadata: target.config.metadata,
|
|
4024
4030
|
createdAt: now,
|
|
4025
4031
|
createdBy: this.actorId
|
|
4026
4032
|
});
|
|
@@ -4535,6 +4541,7 @@ var DeepMemory = class {
|
|
|
4535
4541
|
/** Import a repository from a portable archive */
|
|
4536
4542
|
async importRepository(archive, options) {
|
|
4537
4543
|
await this.ensureInitialized();
|
|
4544
|
+
this.validateRepositoryId(options.target.repositoryId);
|
|
4538
4545
|
await this.globalEventBus.emit("import:started", { repositoryId: options.target.repositoryId });
|
|
4539
4546
|
const importer = new RepositoryImporter({
|
|
4540
4547
|
storage: this.storage,
|
|
@@ -4635,6 +4642,7 @@ var DeepMemory = class {
|
|
|
4635
4642
|
*/
|
|
4636
4643
|
async importRepositoryStream(header, chunks, options) {
|
|
4637
4644
|
await this.ensureInitialized();
|
|
4645
|
+
this.validateRepositoryId(options.target.repositoryId);
|
|
4638
4646
|
const importer = new RepositoryImporter({
|
|
4639
4647
|
storage: this.storage,
|
|
4640
4648
|
actorId: this.provenance.getContext().actorId,
|
|
@@ -4906,12 +4914,16 @@ var GremlinCompiler = class {
|
|
|
4906
4914
|
}
|
|
4907
4915
|
}
|
|
4908
4916
|
}
|
|
4909
|
-
|
|
4917
|
+
const emitProjection = spec.projection !== void 0 && returnMode === "terminal";
|
|
4918
|
+
if (returnMode === "terminal" && !emitProjection && spec.dedup !== false) {
|
|
4910
4919
|
parts.push(".dedup()");
|
|
4911
4920
|
}
|
|
4912
4921
|
if (returnMode === "path") {
|
|
4913
4922
|
parts.push(".simplePath()");
|
|
4914
4923
|
}
|
|
4924
|
+
if (emitProjection) {
|
|
4925
|
+
parts.push(emitProjectionTerminal(spec.projection));
|
|
4926
|
+
}
|
|
4915
4927
|
const limit = spec.limit ?? 50;
|
|
4916
4928
|
const offset = spec.offset ?? 0;
|
|
4917
4929
|
const pOffset = nextParam(offset);
|
|
@@ -4919,7 +4931,8 @@ var GremlinCompiler = class {
|
|
|
4919
4931
|
parts.push(`.range(${pOffset}, ${pEnd})`);
|
|
4920
4932
|
params["_limit"] = limit;
|
|
4921
4933
|
params["_offset"] = offset;
|
|
4922
|
-
if (
|
|
4934
|
+
if (emitProjection) {
|
|
4935
|
+
} else if (returnMode === "terminal") {
|
|
4923
4936
|
parts.push(`.${VERTEX_PROJECT_EXPR}`);
|
|
4924
4937
|
} else {
|
|
4925
4938
|
parts.push(`.path().by(${VERTEX_PROJECT_EXPR}).by(${EDGE_PROJECT_EXPR})`);
|
|
@@ -5015,6 +5028,31 @@ function compileRepeatStep(step, nextParam, useEdgeEmission) {
|
|
|
5015
5028
|
}
|
|
5016
5029
|
return parts.join("");
|
|
5017
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
|
+
}
|
|
5018
5056
|
function compilePropertyFilter(filter, nextParam) {
|
|
5019
5057
|
const key = nextParam(filter.key);
|
|
5020
5058
|
switch (filter.operator) {
|
|
@@ -5124,17 +5162,35 @@ var CypherCompiler = class {
|
|
|
5124
5162
|
}
|
|
5125
5163
|
lastNode = targetNode;
|
|
5126
5164
|
}
|
|
5127
|
-
const
|
|
5165
|
+
const bindPath = spec.returnMode === "path";
|
|
5166
|
+
const pathBinding = bindPath ? "p = " : "";
|
|
5167
|
+
const matchClause = `MATCH ${pathBinding}${matchParts[0]}${matchParts.slice(1).join("")}`;
|
|
5128
5168
|
const whereClause = whereClauses.length > 0 ? `
|
|
5129
5169
|
WHERE ${whereClauses.join(" AND ")}` : "";
|
|
5130
5170
|
let returnClause;
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
const
|
|
5134
|
-
|
|
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";
|
|
5135
5189
|
} else if (spec.returnMode === "all") {
|
|
5136
5190
|
const allNodes = Array.from({ length: nodeIndex }, (_, i) => `n${i}`);
|
|
5137
|
-
|
|
5191
|
+
const allRels = steps.map((_, i) => `r${i}`);
|
|
5192
|
+
const projection = [...allNodes, ...allRels].join(", ");
|
|
5193
|
+
returnClause = spec.dedup !== false ? `RETURN DISTINCT ${projection}` : `RETURN ${projection}`;
|
|
5138
5194
|
} else {
|
|
5139
5195
|
returnClause = spec.dedup !== false ? `RETURN DISTINCT ${lastNode}` : `RETURN ${lastNode}`;
|
|
5140
5196
|
}
|
|
@@ -5155,6 +5211,14 @@ ${returnClause}${skipClause}${limitClause}`;
|
|
|
5155
5211
|
};
|
|
5156
5212
|
}
|
|
5157
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
|
+
}
|
|
5158
5222
|
function compilePropertyFilterCypher(nodeAlias, filter, nextParam) {
|
|
5159
5223
|
const prop = `${nodeAlias}.${filter.key}`;
|
|
5160
5224
|
switch (filter.operator) {
|
|
@@ -5559,6 +5623,7 @@ var InMemoryStorageProvider = class {
|
|
|
5559
5623
|
for (let depth = 0; depth < options.depth; depth++) {
|
|
5560
5624
|
const layer = {};
|
|
5561
5625
|
const nextFrontier = /* @__PURE__ */ new Set();
|
|
5626
|
+
const layerBucketSeen = /* @__PURE__ */ new Map();
|
|
5562
5627
|
for (const frontierEntityId of currentFrontier) {
|
|
5563
5628
|
for (const rel of store.relationships.values()) {
|
|
5564
5629
|
const isSource = rel.sourceEntityId === frontierEntityId;
|
|
@@ -5596,6 +5661,13 @@ var InMemoryStorageProvider = class {
|
|
|
5596
5661
|
continue;
|
|
5597
5662
|
}
|
|
5598
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);
|
|
5599
5671
|
if (!layer[relType]) {
|
|
5600
5672
|
layer[relType] = { total: 0, entities: [], relationships: [] };
|
|
5601
5673
|
}
|