@twin.org/entity 0.0.3-next.2 → 0.0.3-next.21

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.
@@ -169,6 +169,14 @@ export class EntityConditions {
169
169
  }
170
170
  return false;
171
171
  }
172
+ else if (Is.object(val)) {
173
+ if (comparator.comparison === ComparisonOperator.Equals) {
174
+ return ObjectHelper.equal(val, conditionValue);
175
+ }
176
+ else if (comparator.comparison === ComparisonOperator.NotEquals) {
177
+ return !ObjectHelper.equal(val, conditionValue);
178
+ }
179
+ }
172
180
  return false;
173
181
  }
174
182
  }
@@ -1 +1 @@
1
- {"version":3,"file":"entityConditions.js","sourceRoot":"","sources":["../../../src/utils/entityConditions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAGrE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC5B;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAI,MAAS,EAAE,SAA8B;QAC/D,iDAAiD;QACjD,IAAI,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QACb,CAAC;QAED,IAAI,YAAY,IAAI,SAAS,EAAE,CAAC;YAC/B,mGAAmG;YACnG,MAAM,OAAO,GAAc,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;YAC5F,IAAI,CAAC,SAAS,CAAC,eAAe,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,eAAe,CAAC,GAAG,EAAE,CAAC;gBAChF,OAAO,OAAO,CAAC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EAAE,CAAC;4BAC5C,OAAO,IAAI,CAAC;wBACb,CAAC;oBACF,CAAC;gBACF,CAAC;YACF,CAAC;YACD,OAAO,KAAK,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ArrayHelper, Is, ObjectHelper } from \"@twin.org/core\";\nimport { ComparisonOperator } from \"../models/comparisonOperator.js\";\nimport type { EntityCondition } from \"../models/entityCondition.js\";\nimport type { IComparator } from \"../models/IComparator.js\";\nimport { LogicalOperator } from \"../models/logicalOperator.js\";\n\n/**\n * Class to perform condition checks.\n */\nexport class EntityConditions {\n\t/**\n\t * See if the entity matches the conditions.\n\t * @param entity The entity to test.\n\t * @param condition The conditions to test.\n\t * @returns True if the entity matches.\n\t */\n\tpublic static check<T>(entity: T, condition?: EntityCondition<T>): boolean {\n\t\t// If no conditions are defined then it's a match\n\t\tif (Is.undefined(condition)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (\"conditions\" in condition) {\n\t\t\t// It's a group of comparisons, so check the individual items and combine with the logical operator\n\t\t\tconst results: boolean[] = condition.conditions.map(c => EntityConditions.check(entity, c));\n\t\t\tif ((condition.logicalOperator ?? LogicalOperator.And) === LogicalOperator.And) {\n\t\t\t\treturn results.every(Boolean);\n\t\t\t}\n\t\t\treturn results.some(Boolean);\n\t\t}\n\n\t\tif (condition.property.includes(\".\")) {\n\t\t\t// It's a child property comparison, so evaluate the child property\n\t\t\t// and then compare it to the conditions\n\t\t\tconst path = condition.property.split(\".\");\n\n\t\t\tconst child = ObjectHelper.propertyGet(entity, path[0]);\n\n\t\t\t// If the child is an array then check each item\n\t\t\tif (Is.array(child)) {\n\t\t\t\tfor (const c of child) {\n\t\t\t\t\tconst check = EntityConditions.check(c, {\n\t\t\t\t\t\t...condition,\n\t\t\t\t\t\tproperty: path.slice(1).join(\".\")\n\t\t\t\t\t});\n\t\t\t\t\tif (check) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// It's a single value so just check the condition\n\t\treturn EntityConditions.compare(entity, condition);\n\t}\n\n\t/**\n\t * See if the entity matches the conditions.\n\t * @param entity The entity to test.\n\t * @param comparator The condition to test.\n\t * @returns True if the entity matches.\n\t */\n\tpublic static compare<T>(entity: T, comparator: IComparator): boolean {\n\t\tconst val = ObjectHelper.propertyGet(entity, comparator.property);\n\t\tconst conditionValue = comparator.value;\n\n\t\tif (Is.undefined(conditionValue)) {\n\t\t\tconst valUndefined = Is.undefined(val);\n\t\t\tif (valUndefined && comparator.comparison === ComparisonOperator.Equals) {\n\t\t\t\treturn true;\n\t\t\t} else if (!valUndefined && comparator.comparison === ComparisonOperator.NotEquals) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if (Is.string(val)) {\n\t\t\tif (Is.string(conditionValue)) {\n\t\t\t\tif (\n\t\t\t\t\t!(\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Equals && val === conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotEquals && val !== conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.GreaterThan && val > conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.LessThan && val < conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.GreaterThanOrEqual &&\n\t\t\t\t\t\t\tval >= conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.LessThanOrEqual &&\n\t\t\t\t\t\t\tval <= conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Includes &&\n\t\t\t\t\t\t\tval.includes(conditionValue)) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotIncludes &&\n\t\t\t\t\t\t\t!val.includes(conditionValue))\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else if (Is.array(conditionValue)) {\n\t\t\t\tif (!(comparator.comparison === ComparisonOperator.In && conditionValue.includes(val))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if (Is.number(val)) {\n\t\t\tif (Is.number(conditionValue)) {\n\t\t\t\tif (\n\t\t\t\t\t!(\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Equals && val === conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotEquals && val !== conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.GreaterThan && val > conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.LessThan && val < conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.GreaterThanOrEqual &&\n\t\t\t\t\t\t\tval >= conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.LessThanOrEqual && val <= conditionValue)\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else if (Is.array(conditionValue)) {\n\t\t\t\tif (!(comparator.comparison === ComparisonOperator.In && conditionValue.includes(val))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if (Is.boolean(val)) {\n\t\t\tif (Is.boolean(conditionValue)) {\n\t\t\t\tif (\n\t\t\t\t\t!(\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Equals && val === conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotEquals && val !== conditionValue)\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if (Is.array(val)) {\n\t\t\tif (Is.array(conditionValue)) {\n\t\t\t\tif (\n\t\t\t\t\tcomparator.comparison === ComparisonOperator.Equals ||\n\t\t\t\t\tcomparator.comparison === ComparisonOperator.NotEquals\n\t\t\t\t) {\n\t\t\t\t\tconst matches = ArrayHelper.matches(val, conditionValue);\n\t\t\t\t\tif (\n\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Equals && matches) ||\n\t\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotEquals && !matches)\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t} else if (Is.number(conditionValue) || Is.string(conditionValue)) {\n\t\t\t\tif (\n\t\t\t\t\tcomparator.comparison === ComparisonOperator.Includes ||\n\t\t\t\t\tcomparator.comparison === ComparisonOperator.NotIncludes ||\n\t\t\t\t\tcomparator.comparison === ComparisonOperator.In\n\t\t\t\t) {\n\t\t\t\t\tconst includes = val.includes(conditionValue);\n\t\t\t\t\tif (\n\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Includes && includes) ||\n\t\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotIncludes && !includes) ||\n\t\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.In && includes)\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t} else if (Is.object(conditionValue)) {\n\t\t\t\tif (comparator.comparison === ComparisonOperator.Includes) {\n\t\t\t\t\tfor (const v of val) {\n\t\t\t\t\t\tif (ObjectHelper.equal(v, conditionValue)) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (comparator.comparison === ComparisonOperator.NotIncludes) {\n\t\t\t\t\tfor (const v of val) {\n\t\t\t\t\t\tif (!ObjectHelper.equal(v, conditionValue)) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\treturn false;\n\t}\n}\n"]}
1
+ {"version":3,"file":"entityConditions.js","sourceRoot":"","sources":["../../../src/utils/entityConditions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAGrE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC5B;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAI,MAAS,EAAE,SAA8B;QAC/D,iDAAiD;QACjD,IAAI,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QACb,CAAC;QAED,IAAI,YAAY,IAAI,SAAS,EAAE,CAAC;YAC/B,mGAAmG;YACnG,MAAM,OAAO,GAAc,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;YAC5F,IAAI,CAAC,SAAS,CAAC,eAAe,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,eAAe,CAAC,GAAG,EAAE,CAAC;gBAChF,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;YACD,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,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;YAC3B,IAAI,UAAU,CAAC,UAAU,KAAK,kBAAkB,CAAC,MAAM,EAAE,CAAC;gBACzD,OAAO,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;YAChD,CAAC;iBAAM,IAAI,UAAU,CAAC,UAAU,KAAK,kBAAkB,CAAC,SAAS,EAAE,CAAC;gBACnE,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;YACjD,CAAC;QACF,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ArrayHelper, Is, ObjectHelper } from \"@twin.org/core\";\nimport { ComparisonOperator } from \"../models/comparisonOperator.js\";\nimport type { EntityCondition } from \"../models/entityCondition.js\";\nimport type { IComparator } from \"../models/IComparator.js\";\nimport { LogicalOperator } from \"../models/logicalOperator.js\";\n\n/**\n * Class to perform condition checks.\n */\nexport class EntityConditions {\n\t/**\n\t * See if the entity matches the conditions.\n\t * @param entity The entity to test.\n\t * @param condition The conditions to test.\n\t * @returns True if the entity matches.\n\t */\n\tpublic static check<T>(entity: T, condition?: EntityCondition<T>): boolean {\n\t\t// If no conditions are defined then it's a match\n\t\tif (Is.undefined(condition)) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (\"conditions\" in condition) {\n\t\t\t// It's a group of comparisons, so check the individual items and combine with the logical operator\n\t\t\tconst results: boolean[] = condition.conditions.map(c => EntityConditions.check(entity, c));\n\t\t\tif ((condition.logicalOperator ?? LogicalOperator.And) === LogicalOperator.And) {\n\t\t\t\treturn results.every(Boolean);\n\t\t\t}\n\t\t\treturn results.some(Boolean);\n\t\t}\n\n\t\tif (condition.property.includes(\".\")) {\n\t\t\t// It's a child property comparison, so evaluate the child property\n\t\t\t// and then compare it to the conditions\n\t\t\tconst path = condition.property.split(\".\");\n\n\t\t\tconst child = ObjectHelper.propertyGet(entity, path[0]);\n\n\t\t\t// If the child is an array then check each item\n\t\t\tif (Is.array(child)) {\n\t\t\t\tfor (const c of child) {\n\t\t\t\t\tconst check = EntityConditions.check(c, {\n\t\t\t\t\t\t...condition,\n\t\t\t\t\t\tproperty: path.slice(1).join(\".\")\n\t\t\t\t\t});\n\t\t\t\t\tif (check) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// It's a single value so just check the condition\n\t\treturn EntityConditions.compare(entity, condition);\n\t}\n\n\t/**\n\t * See if the entity matches the conditions.\n\t * @param entity The entity to test.\n\t * @param comparator The condition to test.\n\t * @returns True if the entity matches.\n\t */\n\tpublic static compare<T>(entity: T, comparator: IComparator): boolean {\n\t\tconst val = ObjectHelper.propertyGet(entity, comparator.property);\n\t\tconst conditionValue = comparator.value;\n\n\t\tif (Is.undefined(conditionValue)) {\n\t\t\tconst valUndefined = Is.undefined(val);\n\t\t\tif (valUndefined && comparator.comparison === ComparisonOperator.Equals) {\n\t\t\t\treturn true;\n\t\t\t} else if (!valUndefined && comparator.comparison === ComparisonOperator.NotEquals) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if (Is.string(val)) {\n\t\t\tif (Is.string(conditionValue)) {\n\t\t\t\tif (\n\t\t\t\t\t!(\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Equals && val === conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotEquals && val !== conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.GreaterThan && val > conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.LessThan && val < conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.GreaterThanOrEqual &&\n\t\t\t\t\t\t\tval >= conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.LessThanOrEqual &&\n\t\t\t\t\t\t\tval <= conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Includes &&\n\t\t\t\t\t\t\tval.includes(conditionValue)) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotIncludes &&\n\t\t\t\t\t\t\t!val.includes(conditionValue))\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else if (Is.array(conditionValue)) {\n\t\t\t\tif (!(comparator.comparison === ComparisonOperator.In && conditionValue.includes(val))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if (Is.number(val)) {\n\t\t\tif (Is.number(conditionValue)) {\n\t\t\t\tif (\n\t\t\t\t\t!(\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Equals && val === conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotEquals && val !== conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.GreaterThan && val > conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.LessThan && val < conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.GreaterThanOrEqual &&\n\t\t\t\t\t\t\tval >= conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.LessThanOrEqual && val <= conditionValue)\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t} else if (Is.array(conditionValue)) {\n\t\t\t\tif (!(comparator.comparison === ComparisonOperator.In && conditionValue.includes(val))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if (Is.boolean(val)) {\n\t\t\tif (Is.boolean(conditionValue)) {\n\t\t\t\tif (\n\t\t\t\t\t!(\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Equals && val === conditionValue) ||\n\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotEquals && val !== conditionValue)\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if (Is.array(val)) {\n\t\t\tif (Is.array(conditionValue)) {\n\t\t\t\tif (\n\t\t\t\t\tcomparator.comparison === ComparisonOperator.Equals ||\n\t\t\t\t\tcomparator.comparison === ComparisonOperator.NotEquals\n\t\t\t\t) {\n\t\t\t\t\tconst matches = ArrayHelper.matches(val, conditionValue);\n\t\t\t\t\tif (\n\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Equals && matches) ||\n\t\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotEquals && !matches)\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t} else if (Is.number(conditionValue) || Is.string(conditionValue)) {\n\t\t\t\tif (\n\t\t\t\t\tcomparator.comparison === ComparisonOperator.Includes ||\n\t\t\t\t\tcomparator.comparison === ComparisonOperator.NotIncludes ||\n\t\t\t\t\tcomparator.comparison === ComparisonOperator.In\n\t\t\t\t) {\n\t\t\t\t\tconst includes = val.includes(conditionValue);\n\t\t\t\t\tif (\n\t\t\t\t\t\t!(\n\t\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.Includes && includes) ||\n\t\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.NotIncludes && !includes) ||\n\t\t\t\t\t\t\t(comparator.comparison === ComparisonOperator.In && includes)\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t} else if (Is.object(conditionValue)) {\n\t\t\t\tif (comparator.comparison === ComparisonOperator.Includes) {\n\t\t\t\t\tfor (const v of val) {\n\t\t\t\t\t\tif (ObjectHelper.equal(v, conditionValue)) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (comparator.comparison === ComparisonOperator.NotIncludes) {\n\t\t\t\t\tfor (const v of val) {\n\t\t\t\t\t\tif (!ObjectHelper.equal(v, conditionValue)) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if (Is.object(val)) {\n\t\t\tif (comparator.comparison === ComparisonOperator.Equals) {\n\t\t\t\treturn ObjectHelper.equal(val, conditionValue);\n\t\t\t} else if (comparator.comparison === ComparisonOperator.NotEquals) {\n\t\t\t\treturn !ObjectHelper.equal(val, conditionValue);\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n}\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,381 @@
1
1
  # @twin.org/entity - Changelog
2
2
 
3
+ ## [0.0.3-next.21](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.20...entity-v0.0.3-next.21) (2026-02-26)
4
+
5
+
6
+ ### Features
7
+
8
+ * add context id features ([#206](https://github.com/twinfoundation/framework/issues/206)) ([ef0d4ee](https://github.com/twinfoundation/framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
9
+ * add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
10
+ * eslint migration to flat config ([74427d7](https://github.com/twinfoundation/framework/commit/74427d78d342167f7850e49ab87269326355befe))
11
+ * locales validation ([#197](https://github.com/twinfoundation/framework/issues/197)) ([55fdadb](https://github.com/twinfoundation/framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
12
+ * relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
13
+ * support for object comparisons in entity conditions ([edae91d](https://github.com/twinfoundation/framework/commit/edae91d3205524080188a35e0ab04da036fa4f39))
14
+ * update dependencies ([f3bd015](https://github.com/twinfoundation/framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
15
+ * use cause instead of inner for errors ([1f4acc4](https://github.com/twinfoundation/framework/commit/1f4acc4d7a6b71a134d9547da9bf40de1e1e49da))
16
+ * use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
17
+
18
+
19
+ ### Dependencies
20
+
21
+ * The following workspace dependencies were updated
22
+ * dependencies
23
+ * @twin.org/nameof bumped from 0.0.3-next.20 to 0.0.3-next.21
24
+ * @twin.org/core bumped from 0.0.3-next.20 to 0.0.3-next.21
25
+ * devDependencies
26
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.20 to 0.0.3-next.21
27
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.20 to 0.0.3-next.21
28
+ * @twin.org/validate-locales bumped from 0.0.3-next.20 to 0.0.3-next.21
29
+
30
+ ## [0.0.3-next.20](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.19...entity-v0.0.3-next.20) (2026-02-26)
31
+
32
+
33
+ ### Miscellaneous Chores
34
+
35
+ * **entity:** Synchronize repo versions
36
+
37
+
38
+ ### Dependencies
39
+
40
+ * The following workspace dependencies were updated
41
+ * dependencies
42
+ * @twin.org/nameof bumped from 0.0.3-next.19 to 0.0.3-next.20
43
+ * @twin.org/core bumped from 0.0.3-next.19 to 0.0.3-next.20
44
+ * devDependencies
45
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.19 to 0.0.3-next.20
46
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.19 to 0.0.3-next.20
47
+ * @twin.org/validate-locales bumped from 0.0.3-next.19 to 0.0.3-next.20
48
+
49
+ ## [0.0.3-next.19](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.18...entity-v0.0.3-next.19) (2026-02-26)
50
+
51
+
52
+ ### Miscellaneous Chores
53
+
54
+ * **entity:** Synchronize repo versions
55
+
56
+
57
+ ### Dependencies
58
+
59
+ * The following workspace dependencies were updated
60
+ * dependencies
61
+ * @twin.org/nameof bumped from 0.0.3-next.18 to 0.0.3-next.19
62
+ * @twin.org/core bumped from 0.0.3-next.18 to 0.0.3-next.19
63
+ * devDependencies
64
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.18 to 0.0.3-next.19
65
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.18 to 0.0.3-next.19
66
+ * @twin.org/validate-locales bumped from 0.0.3-next.18 to 0.0.3-next.19
67
+
68
+ ## [0.0.3-next.18](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.17...entity-v0.0.3-next.18) (2026-02-23)
69
+
70
+
71
+ ### Miscellaneous Chores
72
+
73
+ * **entity:** Synchronize repo versions
74
+
75
+
76
+ ### Dependencies
77
+
78
+ * The following workspace dependencies were updated
79
+ * dependencies
80
+ * @twin.org/nameof bumped from 0.0.3-next.17 to 0.0.3-next.18
81
+ * @twin.org/core bumped from 0.0.3-next.17 to 0.0.3-next.18
82
+ * devDependencies
83
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.17 to 0.0.3-next.18
84
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.17 to 0.0.3-next.18
85
+ * @twin.org/validate-locales bumped from 0.0.3-next.17 to 0.0.3-next.18
86
+
87
+ ## [0.0.3-next.17](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.16...entity-v0.0.3-next.17) (2026-02-09)
88
+
89
+
90
+ ### Miscellaneous Chores
91
+
92
+ * **entity:** Synchronize repo versions
93
+
94
+
95
+ ### Dependencies
96
+
97
+ * The following workspace dependencies were updated
98
+ * dependencies
99
+ * @twin.org/nameof bumped from 0.0.3-next.16 to 0.0.3-next.17
100
+ * @twin.org/core bumped from 0.0.3-next.16 to 0.0.3-next.17
101
+ * devDependencies
102
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.16 to 0.0.3-next.17
103
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.16 to 0.0.3-next.17
104
+ * @twin.org/validate-locales bumped from 0.0.3-next.16 to 0.0.3-next.17
105
+
106
+ ## [0.0.3-next.16](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.15...entity-v0.0.3-next.16) (2026-02-06)
107
+
108
+
109
+ ### Miscellaneous Chores
110
+
111
+ * **entity:** Synchronize repo versions
112
+
113
+
114
+ ### Dependencies
115
+
116
+ * The following workspace dependencies were updated
117
+ * dependencies
118
+ * @twin.org/nameof bumped from 0.0.3-next.15 to 0.0.3-next.16
119
+ * @twin.org/core bumped from 0.0.3-next.15 to 0.0.3-next.16
120
+ * devDependencies
121
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.15 to 0.0.3-next.16
122
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.15 to 0.0.3-next.16
123
+ * @twin.org/validate-locales bumped from 0.0.3-next.15 to 0.0.3-next.16
124
+
125
+ ## [0.0.3-next.15](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.14...entity-v0.0.3-next.15) (2026-01-29)
126
+
127
+
128
+ ### Miscellaneous Chores
129
+
130
+ * **entity:** Synchronize repo versions
131
+
132
+
133
+ ### Dependencies
134
+
135
+ * The following workspace dependencies were updated
136
+ * dependencies
137
+ * @twin.org/nameof bumped from 0.0.3-next.14 to 0.0.3-next.15
138
+ * @twin.org/core bumped from 0.0.3-next.14 to 0.0.3-next.15
139
+ * devDependencies
140
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.14 to 0.0.3-next.15
141
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.14 to 0.0.3-next.15
142
+ * @twin.org/validate-locales bumped from 0.0.3-next.14 to 0.0.3-next.15
143
+
144
+ ## [0.0.3-next.14](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.13...entity-v0.0.3-next.14) (2026-01-22)
145
+
146
+
147
+ ### Miscellaneous Chores
148
+
149
+ * **entity:** Synchronize repo versions
150
+
151
+
152
+ ### Dependencies
153
+
154
+ * The following workspace dependencies were updated
155
+ * dependencies
156
+ * @twin.org/nameof bumped from 0.0.3-next.13 to 0.0.3-next.14
157
+ * @twin.org/core bumped from 0.0.3-next.13 to 0.0.3-next.14
158
+ * devDependencies
159
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.13 to 0.0.3-next.14
160
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.13 to 0.0.3-next.14
161
+ * @twin.org/validate-locales bumped from 0.0.3-next.13 to 0.0.3-next.14
162
+
163
+ ## [0.0.3-next.13](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.12...entity-v0.0.3-next.13) (2026-01-08)
164
+
165
+
166
+ ### Miscellaneous Chores
167
+
168
+ * **entity:** Synchronize repo versions
169
+
170
+
171
+ ### Dependencies
172
+
173
+ * The following workspace dependencies were updated
174
+ * dependencies
175
+ * @twin.org/nameof bumped from 0.0.3-next.12 to 0.0.3-next.13
176
+ * @twin.org/core bumped from 0.0.3-next.12 to 0.0.3-next.13
177
+ * devDependencies
178
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.12 to 0.0.3-next.13
179
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.12 to 0.0.3-next.13
180
+ * @twin.org/validate-locales bumped from 0.0.3-next.12 to 0.0.3-next.13
181
+
182
+ ## [0.0.3-next.12](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.11...entity-v0.0.3-next.12) (2026-01-08)
183
+
184
+
185
+ ### Miscellaneous Chores
186
+
187
+ * **entity:** Synchronize repo versions
188
+
189
+
190
+ ### Dependencies
191
+
192
+ * The following workspace dependencies were updated
193
+ * dependencies
194
+ * @twin.org/nameof bumped from 0.0.3-next.11 to 0.0.3-next.12
195
+ * @twin.org/core bumped from 0.0.3-next.11 to 0.0.3-next.12
196
+ * devDependencies
197
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.11 to 0.0.3-next.12
198
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.11 to 0.0.3-next.12
199
+ * @twin.org/validate-locales bumped from 0.0.3-next.11 to 0.0.3-next.12
200
+
201
+ ## [0.0.3-next.11](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.10...entity-v0.0.3-next.11) (2026-01-07)
202
+
203
+
204
+ ### Miscellaneous Chores
205
+
206
+ * **entity:** Synchronize repo versions
207
+
208
+
209
+ ### Dependencies
210
+
211
+ * The following workspace dependencies were updated
212
+ * dependencies
213
+ * @twin.org/nameof bumped from 0.0.3-next.10 to 0.0.3-next.11
214
+ * @twin.org/core bumped from 0.0.3-next.10 to 0.0.3-next.11
215
+ * devDependencies
216
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.10 to 0.0.3-next.11
217
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.10 to 0.0.3-next.11
218
+ * @twin.org/validate-locales bumped from 0.0.3-next.10 to 0.0.3-next.11
219
+
220
+ ## [0.0.3-next.10](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.9...entity-v0.0.3-next.10) (2026-01-07)
221
+
222
+
223
+ ### Miscellaneous Chores
224
+
225
+ * **entity:** Synchronize repo versions
226
+
227
+
228
+ ### Dependencies
229
+
230
+ * The following workspace dependencies were updated
231
+ * dependencies
232
+ * @twin.org/nameof bumped from 0.0.3-next.9 to 0.0.3-next.10
233
+ * @twin.org/core bumped from 0.0.3-next.9 to 0.0.3-next.10
234
+ * devDependencies
235
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.9 to 0.0.3-next.10
236
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.9 to 0.0.3-next.10
237
+ * @twin.org/validate-locales bumped from 0.0.3-next.9 to 0.0.3-next.10
238
+
239
+ ## [0.0.3-next.9](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.8...entity-v0.0.3-next.9) (2026-01-05)
240
+
241
+
242
+ ### Miscellaneous Chores
243
+
244
+ * **entity:** Synchronize repo versions
245
+
246
+
247
+ ### Dependencies
248
+
249
+ * The following workspace dependencies were updated
250
+ * dependencies
251
+ * @twin.org/nameof bumped from 0.0.3-next.8 to 0.0.3-next.9
252
+ * @twin.org/core bumped from 0.0.3-next.8 to 0.0.3-next.9
253
+ * devDependencies
254
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.8 to 0.0.3-next.9
255
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.8 to 0.0.3-next.9
256
+ * @twin.org/validate-locales bumped from 0.0.3-next.8 to 0.0.3-next.9
257
+
258
+ ## [0.0.3-next.8](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.7...entity-v0.0.3-next.8) (2025-11-26)
259
+
260
+
261
+ ### Features
262
+
263
+ * support for object comparisons in entity conditions ([edae91d](https://github.com/twinfoundation/framework/commit/edae91d3205524080188a35e0ab04da036fa4f39))
264
+
265
+
266
+ ### Dependencies
267
+
268
+ * The following workspace dependencies were updated
269
+ * dependencies
270
+ * @twin.org/nameof bumped from 0.0.3-next.7 to 0.0.3-next.8
271
+ * @twin.org/core bumped from 0.0.3-next.7 to 0.0.3-next.8
272
+ * devDependencies
273
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.7 to 0.0.3-next.8
274
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.7 to 0.0.3-next.8
275
+ * @twin.org/validate-locales bumped from 0.0.3-next.7 to 0.0.3-next.8
276
+
277
+ ## [0.0.3-next.7](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.6...entity-v0.0.3-next.7) (2025-11-25)
278
+
279
+
280
+ ### Features
281
+
282
+ * add context id features ([#206](https://github.com/twinfoundation/framework/issues/206)) ([ef0d4ee](https://github.com/twinfoundation/framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
283
+ * add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
284
+ * eslint migration to flat config ([74427d7](https://github.com/twinfoundation/framework/commit/74427d78d342167f7850e49ab87269326355befe))
285
+ * locales validation ([#197](https://github.com/twinfoundation/framework/issues/197)) ([55fdadb](https://github.com/twinfoundation/framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
286
+ * relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
287
+ * update dependencies ([f3bd015](https://github.com/twinfoundation/framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
288
+ * use cause instead of inner for errors ([1f4acc4](https://github.com/twinfoundation/framework/commit/1f4acc4d7a6b71a134d9547da9bf40de1e1e49da))
289
+ * use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
290
+
291
+
292
+ ### Dependencies
293
+
294
+ * The following workspace dependencies were updated
295
+ * dependencies
296
+ * @twin.org/nameof bumped from 0.0.3-next.6 to 0.0.3-next.7
297
+ * @twin.org/core bumped from 0.0.3-next.6 to 0.0.3-next.7
298
+ * devDependencies
299
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.6 to 0.0.3-next.7
300
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.6 to 0.0.3-next.7
301
+ * @twin.org/validate-locales bumped from 0.0.3-next.6 to 0.0.3-next.7
302
+
303
+ ## [0.0.3-next.6](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.5...entity-v0.0.3-next.6) (2025-11-25)
304
+
305
+
306
+ ### Miscellaneous Chores
307
+
308
+ * **entity:** Synchronize repo versions
309
+
310
+
311
+ ### Dependencies
312
+
313
+ * The following workspace dependencies were updated
314
+ * dependencies
315
+ * @twin.org/nameof bumped from 0.0.3-next.5 to 0.0.3-next.6
316
+ * @twin.org/core bumped from 0.0.3-next.5 to 0.0.3-next.6
317
+ * devDependencies
318
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.5 to 0.0.3-next.6
319
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.5 to 0.0.3-next.6
320
+ * @twin.org/validate-locales bumped from 0.0.3-next.5 to 0.0.3-next.6
321
+
322
+ ## [0.0.3-next.5](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.4...entity-v0.0.3-next.5) (2025-11-20)
323
+
324
+
325
+ ### Miscellaneous Chores
326
+
327
+ * **entity:** Synchronize repo versions
328
+
329
+
330
+ ### Dependencies
331
+
332
+ * The following workspace dependencies were updated
333
+ * dependencies
334
+ * @twin.org/nameof bumped from 0.0.3-next.4 to 0.0.3-next.5
335
+ * @twin.org/core bumped from 0.0.3-next.4 to 0.0.3-next.5
336
+ * devDependencies
337
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.4 to 0.0.3-next.5
338
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.4 to 0.0.3-next.5
339
+ * @twin.org/validate-locales bumped from 0.0.3-next.4 to 0.0.3-next.5
340
+
341
+ ## [0.0.3-next.4](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.3...entity-v0.0.3-next.4) (2025-11-13)
342
+
343
+
344
+ ### Miscellaneous Chores
345
+
346
+ * **entity:** Synchronize repo versions
347
+
348
+
349
+ ### Dependencies
350
+
351
+ * The following workspace dependencies were updated
352
+ * dependencies
353
+ * @twin.org/nameof bumped from 0.0.3-next.3 to 0.0.3-next.4
354
+ * @twin.org/core bumped from 0.0.3-next.3 to 0.0.3-next.4
355
+ * devDependencies
356
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.3 to 0.0.3-next.4
357
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.3 to 0.0.3-next.4
358
+ * @twin.org/validate-locales bumped from 0.0.3-next.3 to 0.0.3-next.4
359
+
360
+ ## [0.0.3-next.3](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.2...entity-v0.0.3-next.3) (2025-11-12)
361
+
362
+
363
+ ### Miscellaneous Chores
364
+
365
+ * **entity:** Synchronize repo versions
366
+
367
+
368
+ ### Dependencies
369
+
370
+ * The following workspace dependencies were updated
371
+ * dependencies
372
+ * @twin.org/nameof bumped from 0.0.3-next.2 to 0.0.3-next.3
373
+ * @twin.org/core bumped from 0.0.3-next.2 to 0.0.3-next.3
374
+ * devDependencies
375
+ * @twin.org/nameof-transformer bumped from 0.0.3-next.2 to 0.0.3-next.3
376
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.2 to 0.0.3-next.3
377
+ * @twin.org/validate-locales bumped from 0.0.3-next.2 to 0.0.3-next.3
378
+
3
379
  ## [0.0.3-next.2](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.1...entity-v0.0.3-next.2) (2025-11-12)
4
380
 
5
381
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity",
3
- "version": "0.0.3-next.2",
3
+ "version": "0.0.3-next.21",
4
4
  "description": "Helpers for defining and working with entities",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,8 +14,8 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "0.0.3-next.2",
18
- "@twin.org/nameof": "0.0.3-next.2",
17
+ "@twin.org/core": "0.0.3-next.21",
18
+ "@twin.org/nameof": "0.0.3-next.21",
19
19
  "reflect-metadata": "0.2.2"
20
20
  },
21
21
  "main": "./dist/es/index.js",