@utaba/deep-memory-storage-cosmosdb 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/index.cjs +35 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +35 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1251,10 +1251,10 @@ async function getEntityRelationships(conn, repositoryId, entityId, options) {
|
|
|
1251
1251
|
};
|
|
1252
1252
|
let edgeTraversal;
|
|
1253
1253
|
switch (direction) {
|
|
1254
|
-
case "
|
|
1254
|
+
case "out":
|
|
1255
1255
|
edgeTraversal = "g.V().has('repositoryId', rid).hasId(eid).has('entityType').outE()";
|
|
1256
1256
|
break;
|
|
1257
|
-
case "
|
|
1257
|
+
case "in":
|
|
1258
1258
|
edgeTraversal = "g.V().has('repositoryId', rid).hasId(eid).has('entityType').inE()";
|
|
1259
1259
|
break;
|
|
1260
1260
|
case "both":
|
|
@@ -1273,9 +1273,9 @@ async function getEntityRelationships(conn, repositoryId, entityId, options) {
|
|
|
1273
1273
|
typeFilter = `.hasLabel(${typeParams.join(", ")})`;
|
|
1274
1274
|
}
|
|
1275
1275
|
let unionQuery = null;
|
|
1276
|
-
if (direction === "
|
|
1276
|
+
if (direction === "out") {
|
|
1277
1277
|
unionQuery = `g.V().has('repositoryId', rid).hasId(eid).has('entityType').union(outE()${typeFilter}, inE()${typeFilter}.has('bidirectional', true))`;
|
|
1278
|
-
} else if (direction === "
|
|
1278
|
+
} else if (direction === "in") {
|
|
1279
1279
|
unionQuery = `g.V().has('repositoryId', rid).hasId(eid).has('entityType').union(inE()${typeFilter}, outE()${typeFilter}.has('bidirectional', true))`;
|
|
1280
1280
|
}
|
|
1281
1281
|
const baseQuery = unionQuery ?? `${edgeTraversal}${typeFilter}`;
|
|
@@ -2364,11 +2364,11 @@ Verify the ARM/Bicep template that provisioned the container.`
|
|
|
2364
2364
|
*
|
|
2365
2365
|
* The server-side step direction is fixed to `'both'` (catches every edge
|
|
2366
2366
|
* in either direction). The directional + bidirectional filter is applied
|
|
2367
|
-
* client-side per hop — i.e. `direction: '
|
|
2367
|
+
* client-side per hop — i.e. `direction: 'out'` includes inbound edges
|
|
2368
2368
|
* where `bidirectional` is true. The CosmosDB Gremlin compiler does not
|
|
2369
2369
|
* natively express the `union(outE, inE.has(bidirectional))` shape that
|
|
2370
2370
|
* would push this filter server-side, so it stays client-side; the
|
|
2371
|
-
* observable contract (which edges count toward
|
|
2371
|
+
* observable contract (which edges count toward `'out'` given
|
|
2372
2372
|
* bidirectionality) is preserved.
|
|
2373
2373
|
*
|
|
2374
2374
|
* Round-trips per call: `options.depth` (one per layer). The previous BFS
|
|
@@ -2414,17 +2414,17 @@ Verify the ARM/Bicep template that provisioned the container.`
|
|
|
2414
2414
|
const isTarget = rel.targetEntityId === fv;
|
|
2415
2415
|
let matchesDirection = false;
|
|
2416
2416
|
let connectedId;
|
|
2417
|
-
if (isSource && (options.direction === "
|
|
2417
|
+
if (isSource && (options.direction === "out" || options.direction === "both")) {
|
|
2418
2418
|
matchesDirection = true;
|
|
2419
2419
|
connectedId = rel.targetEntityId;
|
|
2420
|
-
} else if (isTarget && (options.direction === "
|
|
2420
|
+
} else if (isTarget && (options.direction === "in" || options.direction === "both")) {
|
|
2421
2421
|
matchesDirection = true;
|
|
2422
2422
|
connectedId = rel.sourceEntityId;
|
|
2423
2423
|
} else if (rel.bidirectional) {
|
|
2424
|
-
if (isSource && options.direction === "
|
|
2424
|
+
if (isSource && options.direction === "in") {
|
|
2425
2425
|
matchesDirection = true;
|
|
2426
2426
|
connectedId = rel.targetEntityId;
|
|
2427
|
-
} else if (isTarget && options.direction === "
|
|
2427
|
+
} else if (isTarget && options.direction === "out") {
|
|
2428
2428
|
matchesDirection = true;
|
|
2429
2429
|
connectedId = rel.sourceEntityId;
|
|
2430
2430
|
}
|
|
@@ -2666,7 +2666,7 @@ Verify the ARM/Bicep template that provisioned the container.`
|
|
|
2666
2666
|
}
|
|
2667
2667
|
return projected;
|
|
2668
2668
|
};
|
|
2669
|
-
const projectStoredRelationship = (rel, direction = "
|
|
2669
|
+
const projectStoredRelationship = (rel, direction = "out") => ({
|
|
2670
2670
|
id: rel.id,
|
|
2671
2671
|
type: rel.relationshipType,
|
|
2672
2672
|
sourceEntityId: rel.sourceEntityId,
|
|
@@ -2677,10 +2677,27 @@ Verify the ARM/Bicep template that provisioned the container.`
|
|
|
2677
2677
|
let entities = [];
|
|
2678
2678
|
let relationships;
|
|
2679
2679
|
let paths;
|
|
2680
|
+
const rangeRowCount = spec.returnMode === "all" ? raw.allEntities.length + raw.allRelationships.length : 0;
|
|
2680
2681
|
if (spec.returnMode === "terminal") {
|
|
2681
2682
|
entities = raw.terminalEntities.map(projectStoredEntity);
|
|
2682
2683
|
relationships = void 0;
|
|
2683
2684
|
} else if (spec.returnMode === "all") {
|
|
2685
|
+
const missingIds = /* @__PURE__ */ new Set();
|
|
2686
|
+
for (const rel of raw.allRelationships) {
|
|
2687
|
+
if (!raw.entityMap.has(rel.sourceEntityId)) {
|
|
2688
|
+
missingIds.add(rel.sourceEntityId);
|
|
2689
|
+
}
|
|
2690
|
+
if (!raw.entityMap.has(rel.targetEntityId)) {
|
|
2691
|
+
missingIds.add(rel.targetEntityId);
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
if (missingIds.size > 0) {
|
|
2695
|
+
const fetched = await this.getEntities(repositoryId, [...missingIds]);
|
|
2696
|
+
for (const stored of fetched.values()) {
|
|
2697
|
+
raw.allEntities.push(stored);
|
|
2698
|
+
raw.entityMap.set(stored.id, stored);
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2684
2701
|
entities = raw.allEntities.map(projectStoredEntity);
|
|
2685
2702
|
relationships = raw.allRelationships.map((r) => projectStoredRelationship(r));
|
|
2686
2703
|
} else {
|
|
@@ -2708,7 +2725,7 @@ Verify the ARM/Bicep template that provisioned the container.`
|
|
|
2708
2725
|
})
|
|
2709
2726
|
}));
|
|
2710
2727
|
relationships = Array.from(raw.relationshipMap.values()).map(
|
|
2711
|
-
(rel) => projectStoredRelationship(rel, raw.pathRelFirstDirection.get(rel.id) ?? "
|
|
2728
|
+
(rel) => projectStoredRelationship(rel, raw.pathRelFirstDirection.get(rel.id) ?? "out")
|
|
2712
2729
|
);
|
|
2713
2730
|
}
|
|
2714
2731
|
const limit = spec.limit ?? 50;
|
|
@@ -2720,6 +2737,8 @@ Verify the ARM/Bicep template that provisioned the container.`
|
|
|
2720
2737
|
} else {
|
|
2721
2738
|
total = entities.length;
|
|
2722
2739
|
}
|
|
2740
|
+
const paginationSignal = spec.returnMode === "all" ? rangeRowCount : total;
|
|
2741
|
+
const truncated = paginationSignal >= limit;
|
|
2723
2742
|
const queryMetadata = {
|
|
2724
2743
|
executionTimeMs: raw.executionTimeMs,
|
|
2725
2744
|
resourceCost: raw.requestCharge != null ? { units: "RU", value: raw.requestCharge } : void 0,
|
|
@@ -2729,8 +2748,8 @@ Verify the ARM/Bicep template that provisioned the container.`
|
|
|
2729
2748
|
maxResults: limit,
|
|
2730
2749
|
maxDepth: spec.steps?.length
|
|
2731
2750
|
},
|
|
2732
|
-
truncated
|
|
2733
|
-
truncationReason:
|
|
2751
|
+
truncated,
|
|
2752
|
+
truncationReason: truncated ? "result_limit" : void 0
|
|
2734
2753
|
};
|
|
2735
2754
|
return {
|
|
2736
2755
|
entities,
|
|
@@ -2738,7 +2757,7 @@ Verify the ARM/Bicep template that provisioned the container.`
|
|
|
2738
2757
|
paths,
|
|
2739
2758
|
total,
|
|
2740
2759
|
returned: total,
|
|
2741
|
-
hasMore:
|
|
2760
|
+
hasMore: truncated,
|
|
2742
2761
|
queryMetadata
|
|
2743
2762
|
};
|
|
2744
2763
|
}
|
|
@@ -2829,7 +2848,7 @@ Verify the ARM/Bicep template that provisioned the container.`
|
|
|
2829
2848
|
const stored = relationshipFromGremlin(props);
|
|
2830
2849
|
raw.relationshipMap.set(stored.id, stored);
|
|
2831
2850
|
pathRelIds.push(stored.id);
|
|
2832
|
-
const direction = lastVertexId === stored.sourceEntityId ? "
|
|
2851
|
+
const direction = lastVertexId === stored.sourceEntityId ? "out" : "in";
|
|
2833
2852
|
pathRelDirections.push(direction);
|
|
2834
2853
|
if (!raw.pathRelFirstDirection.has(stored.id)) {
|
|
2835
2854
|
raw.pathRelFirstDirection.set(stored.id, direction);
|