simple-graph-query 2.1.2 → 2.1.4

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.
@@ -48599,7 +48599,8 @@ function dotJoin(left, right) {
48599
48599
  if (result.some(tuple => tuple.length === 0)) {
48600
48600
  throw new Error("Join would create a relation of arity 0");
48601
48601
  }
48602
- return result;
48602
+ // Deduplicate results to ensure set semantics
48603
+ return deduplicateTuples(result);
48603
48604
  }
48604
48605
  function bitwidthWraparound(value, bitwidth) {
48605
48606
  const modulus = Math.pow(2, bitwidth); // total number of Int values
@@ -48742,9 +48743,16 @@ class ForgeExprEvaluator extends AbstractParseTreeVisitor_1.AbstractParseTreeVis
48742
48743
  getIden() {
48743
48744
  const instanceTypes = this.instanceData.getTypes();
48744
48745
  const result = [];
48746
+ // Track unique atom IDs to avoid duplicates
48747
+ const seenAtomIds = new Set();
48745
48748
  for (const t of instanceTypes) {
48746
48749
  const typeAtoms = t.atoms;
48747
48750
  typeAtoms.forEach((atom) => {
48751
+ // Skip if we've already seen this atom ID
48752
+ if (seenAtomIds.has(atom.id)) {
48753
+ return;
48754
+ }
48755
+ seenAtomIds.add(atom.id);
48748
48756
  let value = atom.id;
48749
48757
  // do some type conversions so we don't return a string if the value
48750
48758
  // is a number or boolean
@@ -50001,7 +50009,15 @@ class ForgeExprEvaluator extends AbstractParseTreeVisitor_1.AbstractParseTreeVis
50001
50009
  const typeNames = this.instanceData.getTypes().map((t) => t.id);
50002
50010
  if (typeNames.includes(identifier)) {
50003
50011
  const typeAtoms = this.instanceData.getTypes().find(t => t.id === identifier)?.atoms || [];
50004
- const desiredValues = typeAtoms.map((atom) => atom.id);
50012
+ // Deduplicate atoms by ID to handle data sources with duplicate entries
50013
+ const uniqueAtomIds = new Set();
50014
+ const desiredValues = [];
50015
+ for (const atom of typeAtoms) {
50016
+ if (!uniqueAtomIds.has(atom.id)) {
50017
+ uniqueAtomIds.add(atom.id);
50018
+ desiredValues.push(atom.id);
50019
+ }
50020
+ }
50005
50021
  result = desiredValues.map((singleValue) => [singleValue]);
50006
50022
  }
50007
50023
  for (const typeObj of this.instanceData.getTypes()) {
@@ -50120,7 +50136,15 @@ class ForgeExprEvaluator extends AbstractParseTreeVisitor_1.AbstractParseTreeVis
50120
50136
  if (!intType) {
50121
50137
  throw new Error('Type "Int" not found in instance data');
50122
50138
  }
50123
- const intVals = intType.atoms.map((atom) => [Number(atom.id)]);
50139
+ // Deduplicate atoms by ID to handle data sources with duplicate entries
50140
+ const uniqueAtomIds = new Set();
50141
+ const intVals = [];
50142
+ for (const atom of intType.atoms) {
50143
+ if (!uniqueAtomIds.has(atom.id)) {
50144
+ uniqueAtomIds.add(atom.id);
50145
+ intVals.push([Number(atom.id)]);
50146
+ }
50147
+ }
50124
50148
  return intVals;
50125
50149
  }
50126
50150
  return this.visitChildren(ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-graph-query",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "TypeScript evaluator for Forge expressions with browser-compatible UMD bundle",
5
5
  "main": "dist/simple-graph-query.bundle.js",
6
6
  "types": "dist/index.d.ts",