@twin.org/entity 0.10.1-next.5 → 0.10.1-next.6

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.
@@ -50,10 +50,10 @@ export class EntitySorter {
50
50
  res = 0;
51
51
  }
52
52
  else if (b1) {
53
- res = -1;
53
+ res = 1;
54
54
  }
55
55
  else {
56
- res = 1;
56
+ res = -1;
57
57
  }
58
58
  }
59
59
  else if (type === "string") {
@@ -1 +1 @@
1
- {"version":3,"file":"entitySorter.js","sourceRoot":"","sources":["../../../src/utils/entitySorter.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGpC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,YAAY;IACxB;;;;;OAKG;IACI,MAAM,CAAC,IAAI,CAAI,QAAa,EAAE,aAAgC;QACpE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;YACzD,OAAO,QAAQ,CAAC;QACjB,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC7B,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;gBAC1C,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CACzC,CAAC,EACD,CAAC,EACD,YAAY,CAAC,QAAQ,EACrB,YAAY,CAAC,IAAI,EACjB,YAAY,CAAC,aAAa,CAC1B,CAAC;gBACF,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;oBACzB,OAAO,aAAa,CAAC;gBACtB,CAAC;YACF,CAAC;YACD,OAAO,CAAC,CAAC;QACV,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,OAAO,CACpB,OA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AAa,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Is } from \"@twin.org/core\";\nimport type { EntitySchemaPropertyType } from \"../models/entitySchemaPropertyType.js\";\nimport type { IEntitySort } from \"../models/IEntitySort.js\";\nimport { SortDirection } from \"../models/sortDirection.js\";\n\n/**\n * Class to perform sort operations on entities.\n */\nexport class EntitySorter {\n\t/**\n\t * Sort a list of entities using multiple keys and direction.\n\t * @param entities The list of entities.\n\t * @param entitySorters The sort keys to use.\n\t * @returns The sorted list.\n\t */\n\tpublic static sort<T>(entities: T[], entitySorters?: IEntitySort<T>[]): T[] {\n\t\tif (!Is.arrayValue(entities) || Is.empty(entitySorters)) {\n\t\t\treturn entities;\n\t\t}\n\n\t\treturn entities.sort((a, b) => {\n\t\t\tfor (const entitySorter of entitySorters) {\n\t\t\t\tconst compareResult = EntitySorter.compare(\n\t\t\t\t\ta,\n\t\t\t\t\tb,\n\t\t\t\t\tentitySorter.property,\n\t\t\t\t\tentitySorter.type,\n\t\t\t\t\tentitySorter.sortDirection\n\t\t\t\t);\n\t\t\t\tif (compareResult !== 0) {\n\t\t\t\t\treturn compareResult;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\t/**\n\t * Compare two properties.\n\t * @param entity1 The first entity.\n\t * @param entity2 The second entity.\n\t * @param prop The property to compare.\n\t * @param type The type of the property.\n\t * @param direction The direction of the sort.\n\t * @returns The result of the comparison.\n\t */\n\tpublic static compare<T>(\n\t\tentity1: T,\n\t\tentity2: T,\n\t\tprop: keyof T,\n\t\ttype: EntitySchemaPropertyType,\n\t\tdirection: SortDirection = SortDirection.Ascending\n\t): number {\n\t\tlet res = 0;\n\t\tconst hasProp1 = !Is.empty(entity1[prop]);\n\t\tconst hasProp2 = !Is.empty(entity2[prop]);\n\n\t\tif (hasProp1 && hasProp2) {\n\t\t\tif (type === \"number\" || type === \"integer\") {\n\t\t\t\tres = (entity1[prop] as unknown as number) - (entity2[prop] as unknown as number);\n\t\t\t} else if (type === \"boolean\") {\n\t\t\t\tconst b1 = entity1[prop] as unknown as boolean;\n\t\t\t\tconst b2 = entity2[prop] as unknown as boolean;\n\t\t\t\tif (b1 === b2) {\n\t\t\t\t\tres = 0;\n\t\t\t\t} else if (b1) {\n\t\t\t\t\tres = -1;\n\t\t\t\t} else {\n\t\t\t\t\tres = 1;\n\t\t\t\t}\n\t\t\t} else if (type === \"string\") {\n\t\t\t\tres = (entity1[prop] as unknown as string).localeCompare(\n\t\t\t\t\tentity2[prop] as unknown as string\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (hasProp1) {\n\t\t\tres = -1;\n\t\t} else if (hasProp2) {\n\t\t\tres = 1;\n\t\t}\n\n\t\treturn direction === SortDirection.Ascending ? res : res * -1;\n\t}\n}\n"]}
1
+ {"version":3,"file":"entitySorter.js","sourceRoot":"","sources":["../../../src/utils/entitySorter.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAGpC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,YAAY;IACxB;;;;;OAKG;IACI,MAAM,CAAC,IAAI,CAAI,QAAa,EAAE,aAAgC;QACpE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;YACzD,OAAO,QAAQ,CAAC;QACjB,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC7B,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;gBAC1C,MAAM,aAAa,GAAG,YAAY,CA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,QAAQ,EAAE,CAAC;gBAC9B,GAAG,GAAI,OAAO,CAAC,IAAI,CAAuB,CAAC,aAAa,CACvD,OAAO,CAAC,IAAI,CAAsB,CAClC,CAAC;YACH,CAAC;QACF,CAAC;aAAM,IAAI,QAAQ,EAAE,CAAC;YACrB,GAAG,GAAG,CAAC,CAAC,CAAC;QACV,CAAC;aAAM,IAAI,QAAQ,EAAE,CAAC;YACrB,GAAG,GAAG,CAAC,CAAC;QACT,CAAC;QAED,OAAO,SAAS,KAAK,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Is } from \"@twin.org/core\";\nimport type { EntitySchemaPropertyType } from \"../models/entitySchemaPropertyType.js\";\nimport type { IEntitySort } from \"../models/IEntitySort.js\";\nimport { SortDirection } from \"../models/sortDirection.js\";\n\n/**\n * Class to perform sort operations on entities.\n */\nexport class EntitySorter {\n\t/**\n\t * Sort a list of entities using multiple keys and direction.\n\t * @param entities The list of entities.\n\t * @param entitySorters The sort keys to use.\n\t * @returns The sorted list.\n\t */\n\tpublic static sort<T>(entities: T[], entitySorters?: IEntitySort<T>[]): T[] {\n\t\tif (!Is.arrayValue(entities) || Is.empty(entitySorters)) {\n\t\t\treturn entities;\n\t\t}\n\n\t\treturn entities.sort((a, b) => {\n\t\t\tfor (const entitySorter of entitySorters) {\n\t\t\t\tconst compareResult = EntitySorter.compare(\n\t\t\t\t\ta,\n\t\t\t\t\tb,\n\t\t\t\t\tentitySorter.property,\n\t\t\t\t\tentitySorter.type,\n\t\t\t\t\tentitySorter.sortDirection\n\t\t\t\t);\n\t\t\t\tif (compareResult !== 0) {\n\t\t\t\t\treturn compareResult;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn 0;\n\t\t});\n\t}\n\n\t/**\n\t * Compare two properties.\n\t * @param entity1 The first entity.\n\t * @param entity2 The second entity.\n\t * @param prop The property to compare.\n\t * @param type The type of the property.\n\t * @param direction The direction of the sort.\n\t * @returns The result of the comparison.\n\t */\n\tpublic static compare<T>(\n\t\tentity1: T,\n\t\tentity2: T,\n\t\tprop: keyof T,\n\t\ttype: EntitySchemaPropertyType,\n\t\tdirection: SortDirection = SortDirection.Ascending\n\t): number {\n\t\tlet res = 0;\n\t\tconst hasProp1 = !Is.empty(entity1[prop]);\n\t\tconst hasProp2 = !Is.empty(entity2[prop]);\n\n\t\tif (hasProp1 && hasProp2) {\n\t\t\tif (type === \"number\" || type === \"integer\") {\n\t\t\t\tres = (entity1[prop] as unknown as number) - (entity2[prop] as unknown as number);\n\t\t\t} else if (type === \"boolean\") {\n\t\t\t\tconst b1 = entity1[prop] as unknown as boolean;\n\t\t\t\tconst b2 = entity2[prop] as unknown as boolean;\n\t\t\t\tif (b1 === b2) {\n\t\t\t\t\tres = 0;\n\t\t\t\t} else if (b1) {\n\t\t\t\t\tres = 1;\n\t\t\t\t} else {\n\t\t\t\t\tres = -1;\n\t\t\t\t}\n\t\t\t} else if (type === \"string\") {\n\t\t\t\tres = (entity1[prop] as unknown as string).localeCompare(\n\t\t\t\t\tentity2[prop] as unknown as string\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (hasProp1) {\n\t\t\tres = -1;\n\t\t} else if (hasProp2) {\n\t\t\tres = 1;\n\t\t}\n\n\t\treturn direction === SortDirection.Ascending ? res : res * -1;\n\t}\n}\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.10.1-next.6](https://github.com/iotaledger/twin-framework/compare/entity-v0.10.1-next.5...entity-v0.10.1-next.6) (2026-09-21)
4
+
5
+
6
+ ### Features
7
+
8
+ * native enhancements ([#527](https://github.com/iotaledger/twin-framework/issues/527)) ([dc77328](https://github.com/iotaledger/twin-framework/commit/dc77328df201ff77809d8e8792c27780bfb6d8c4))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/core bumped from 0.10.1-next.5 to 0.10.1-next.6
16
+ * @twin.org/nameof bumped from 0.10.1-next.5 to 0.10.1-next.6
17
+ * devDependencies
18
+ * @twin.org/nameof-transformer bumped from 0.10.1-next.5 to 0.10.1-next.6
19
+ * @twin.org/nameof-vitest-plugin bumped from 0.10.1-next.5 to 0.10.1-next.6
20
+ * @twin.org/validate-locales bumped from 0.10.1-next.5 to 0.10.1-next.6
21
+
3
22
  ## [0.10.1-next.5](https://github.com/iotaledger/twin-framework/compare/entity-v0.10.1-next.4...entity-v0.10.1-next.5) (2026-09-18)
4
23
 
5
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity",
3
- "version": "0.10.1-next.5",
3
+ "version": "0.10.1-next.6",
4
4
  "description": "Helpers for defining and working with entities",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,8 +14,8 @@
14
14
  "node": ">=24.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "0.10.1-next.5",
18
- "@twin.org/nameof": "0.10.1-next.5",
17
+ "@twin.org/core": "0.10.1-next.6",
18
+ "@twin.org/nameof": "0.10.1-next.6",
19
19
  "reflect-metadata": "0.2.2",
20
20
  "tslib": "2.8.1"
21
21
  },