@twin.org/entity 0.0.1-next.9 → 0.0.2-next.3
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/cjs/index.cjs +64 -2
- package/dist/esm/index.mjs +64 -2
- package/dist/types/utils/entitySchemaHelper.d.ts +7 -0
- package/docs/changelog.md +394 -1
- package/docs/reference/classes/DecoratorHelper.md +18 -8
- package/docs/reference/classes/EntityConditions.md +22 -10
- package/docs/reference/classes/EntitySchemaHelper.md +67 -13
- package/docs/reference/classes/EntitySorter.md +31 -13
- package/docs/reference/functions/entity.md +4 -2
- package/docs/reference/functions/property.md +3 -1
- package/docs/reference/interfaces/IComparatorGroup.md +3 -1
- package/docs/reference/interfaces/IEntitySchema.md +3 -1
- package/docs/reference/interfaces/IEntitySchemaProperty.md +3 -1
- package/docs/reference/interfaces/IEntitySort.md +3 -1
- package/docs/reference/type-aliases/ComparisonOperator.md +1 -1
- package/docs/reference/type-aliases/EntityCondition.md +4 -2
- package/docs/reference/type-aliases/EntitySchemaPropertyFormat.md +1 -1
- package/docs/reference/type-aliases/EntitySchemaPropertyType.md +1 -1
- package/docs/reference/type-aliases/LogicalOperator.md +1 -1
- package/docs/reference/type-aliases/SortDirection.md +1 -1
- package/locales/en.json +5 -1
- package/package.json +6 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -61,7 +61,7 @@ function property(options) {
|
|
|
61
61
|
const entitySchema = DecoratorHelper.getSchema(target);
|
|
62
62
|
entitySchema.properties ??= [];
|
|
63
63
|
const idx = entitySchema.properties.findIndex(p => p.property === propertyKey);
|
|
64
|
-
if (idx
|
|
64
|
+
if (idx !== -1) {
|
|
65
65
|
entitySchema.properties[idx] = {
|
|
66
66
|
...options,
|
|
67
67
|
property: propertyKey
|
|
@@ -533,6 +533,60 @@ class EntitySchemaHelper {
|
|
|
533
533
|
}
|
|
534
534
|
return finalSortKeys;
|
|
535
535
|
}
|
|
536
|
+
/**
|
|
537
|
+
* Validate the entity against the schema.
|
|
538
|
+
* @param entity The entity to validate.
|
|
539
|
+
* @param entitySchema The schema to validate against.
|
|
540
|
+
* @throws If the entity is invalid.
|
|
541
|
+
*/
|
|
542
|
+
static validateEntity(entity, entitySchema) {
|
|
543
|
+
core.Guards.object(EntitySchemaHelper._CLASS_NAME, "entity", entity);
|
|
544
|
+
core.Guards.object(EntitySchemaHelper._CLASS_NAME, "entitySchema", entitySchema);
|
|
545
|
+
const properties = entitySchema.properties ?? [];
|
|
546
|
+
if (properties.length === 0 && core.Is.objectValue(entity)) {
|
|
547
|
+
throw new core.GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidEntityProperties");
|
|
548
|
+
}
|
|
549
|
+
const allKeys = Object.keys(entity);
|
|
550
|
+
for (const prop of properties) {
|
|
551
|
+
const idx = allKeys.indexOf(prop.property);
|
|
552
|
+
if (idx !== -1) {
|
|
553
|
+
allKeys.splice(idx, 1);
|
|
554
|
+
}
|
|
555
|
+
const value = entity[prop.property];
|
|
556
|
+
if (core.Is.empty(value)) {
|
|
557
|
+
// If the value is empty but the property is not optional, then it's invalid
|
|
558
|
+
if (!prop.optional) {
|
|
559
|
+
throw new core.GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidOptional", {
|
|
560
|
+
property: prop.property,
|
|
561
|
+
type: prop.type
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
else if (prop.type === "integer" && core.Is.integer(value)) ;
|
|
566
|
+
else if (prop.type === "object" &&
|
|
567
|
+
(core.Is.object(value) ||
|
|
568
|
+
core.Is.array(value) ||
|
|
569
|
+
core.Is.string(value) ||
|
|
570
|
+
core.Is.number(value) ||
|
|
571
|
+
core.Is.boolean(value) ||
|
|
572
|
+
core.Is.null(value))) ;
|
|
573
|
+
else if (prop.type === "array" && core.Is.array(value)) ;
|
|
574
|
+
else if (prop.type !== typeof value) {
|
|
575
|
+
// The schema type does not match the value type
|
|
576
|
+
throw new core.GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidEntityProperty", {
|
|
577
|
+
value,
|
|
578
|
+
property: prop.property,
|
|
579
|
+
type: prop.type
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
if (allKeys.length > 0) {
|
|
584
|
+
// There are keys in the entity that are not in the schema
|
|
585
|
+
throw new core.GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidEntityKeys", {
|
|
586
|
+
keys: allKeys.join(", ")
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
}
|
|
536
590
|
}
|
|
537
591
|
|
|
538
592
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -572,7 +626,9 @@ class EntitySorter {
|
|
|
572
626
|
*/
|
|
573
627
|
static compare(entity1, entity2, prop, type, direction = SortDirection.Ascending) {
|
|
574
628
|
let res = 0;
|
|
575
|
-
|
|
629
|
+
const hasProp1 = !core.Is.empty(entity1[prop]);
|
|
630
|
+
const hasProp2 = !core.Is.empty(entity2[prop]);
|
|
631
|
+
if (hasProp1 && hasProp2) {
|
|
576
632
|
if (type === "number" || type === "integer") {
|
|
577
633
|
res = entity1[prop] - entity2[prop];
|
|
578
634
|
}
|
|
@@ -593,6 +649,12 @@ class EntitySorter {
|
|
|
593
649
|
res = entity1[prop].localeCompare(entity2[prop]);
|
|
594
650
|
}
|
|
595
651
|
}
|
|
652
|
+
else if (hasProp1) {
|
|
653
|
+
res = -1;
|
|
654
|
+
}
|
|
655
|
+
else {
|
|
656
|
+
res = 1;
|
|
657
|
+
}
|
|
596
658
|
return direction === SortDirection.Ascending ? res : res * -1;
|
|
597
659
|
}
|
|
598
660
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -59,7 +59,7 @@ function property(options) {
|
|
|
59
59
|
const entitySchema = DecoratorHelper.getSchema(target);
|
|
60
60
|
entitySchema.properties ??= [];
|
|
61
61
|
const idx = entitySchema.properties.findIndex(p => p.property === propertyKey);
|
|
62
|
-
if (idx
|
|
62
|
+
if (idx !== -1) {
|
|
63
63
|
entitySchema.properties[idx] = {
|
|
64
64
|
...options,
|
|
65
65
|
property: propertyKey
|
|
@@ -531,6 +531,60 @@ class EntitySchemaHelper {
|
|
|
531
531
|
}
|
|
532
532
|
return finalSortKeys;
|
|
533
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* Validate the entity against the schema.
|
|
536
|
+
* @param entity The entity to validate.
|
|
537
|
+
* @param entitySchema The schema to validate against.
|
|
538
|
+
* @throws If the entity is invalid.
|
|
539
|
+
*/
|
|
540
|
+
static validateEntity(entity, entitySchema) {
|
|
541
|
+
Guards.object(EntitySchemaHelper._CLASS_NAME, "entity", entity);
|
|
542
|
+
Guards.object(EntitySchemaHelper._CLASS_NAME, "entitySchema", entitySchema);
|
|
543
|
+
const properties = entitySchema.properties ?? [];
|
|
544
|
+
if (properties.length === 0 && Is.objectValue(entity)) {
|
|
545
|
+
throw new GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidEntityProperties");
|
|
546
|
+
}
|
|
547
|
+
const allKeys = Object.keys(entity);
|
|
548
|
+
for (const prop of properties) {
|
|
549
|
+
const idx = allKeys.indexOf(prop.property);
|
|
550
|
+
if (idx !== -1) {
|
|
551
|
+
allKeys.splice(idx, 1);
|
|
552
|
+
}
|
|
553
|
+
const value = entity[prop.property];
|
|
554
|
+
if (Is.empty(value)) {
|
|
555
|
+
// If the value is empty but the property is not optional, then it's invalid
|
|
556
|
+
if (!prop.optional) {
|
|
557
|
+
throw new GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidOptional", {
|
|
558
|
+
property: prop.property,
|
|
559
|
+
type: prop.type
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
else if (prop.type === "integer" && Is.integer(value)) ;
|
|
564
|
+
else if (prop.type === "object" &&
|
|
565
|
+
(Is.object(value) ||
|
|
566
|
+
Is.array(value) ||
|
|
567
|
+
Is.string(value) ||
|
|
568
|
+
Is.number(value) ||
|
|
569
|
+
Is.boolean(value) ||
|
|
570
|
+
Is.null(value))) ;
|
|
571
|
+
else if (prop.type === "array" && Is.array(value)) ;
|
|
572
|
+
else if (prop.type !== typeof value) {
|
|
573
|
+
// The schema type does not match the value type
|
|
574
|
+
throw new GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidEntityProperty", {
|
|
575
|
+
value,
|
|
576
|
+
property: prop.property,
|
|
577
|
+
type: prop.type
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
if (allKeys.length > 0) {
|
|
582
|
+
// There are keys in the entity that are not in the schema
|
|
583
|
+
throw new GeneralError(EntitySchemaHelper._CLASS_NAME, "invalidEntityKeys", {
|
|
584
|
+
keys: allKeys.join(", ")
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
}
|
|
534
588
|
}
|
|
535
589
|
|
|
536
590
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -570,7 +624,9 @@ class EntitySorter {
|
|
|
570
624
|
*/
|
|
571
625
|
static compare(entity1, entity2, prop, type, direction = SortDirection.Ascending) {
|
|
572
626
|
let res = 0;
|
|
573
|
-
|
|
627
|
+
const hasProp1 = !Is.empty(entity1[prop]);
|
|
628
|
+
const hasProp2 = !Is.empty(entity2[prop]);
|
|
629
|
+
if (hasProp1 && hasProp2) {
|
|
574
630
|
if (type === "number" || type === "integer") {
|
|
575
631
|
res = entity1[prop] - entity2[prop];
|
|
576
632
|
}
|
|
@@ -591,6 +647,12 @@ class EntitySorter {
|
|
|
591
647
|
res = entity1[prop].localeCompare(entity2[prop]);
|
|
592
648
|
}
|
|
593
649
|
}
|
|
650
|
+
else if (hasProp1) {
|
|
651
|
+
res = -1;
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
res = 1;
|
|
655
|
+
}
|
|
594
656
|
return direction === SortDirection.Ascending ? res : res * -1;
|
|
595
657
|
}
|
|
596
658
|
}
|
|
@@ -35,4 +35,11 @@ export declare class EntitySchemaHelper {
|
|
|
35
35
|
property: keyof T;
|
|
36
36
|
sortDirection: SortDirection;
|
|
37
37
|
}[]): IEntitySort<T>[] | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Validate the entity against the schema.
|
|
40
|
+
* @param entity The entity to validate.
|
|
41
|
+
* @param entitySchema The schema to validate against.
|
|
42
|
+
* @throws If the entity is invalid.
|
|
43
|
+
*/
|
|
44
|
+
static validateEntity<T>(entity: T, entitySchema: IEntitySchema<T>): void;
|
|
38
45
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,398 @@
|
|
|
1
1
|
# @twin.org/entity - Changelog
|
|
2
2
|
|
|
3
|
-
## 0.0.
|
|
3
|
+
## [0.0.2-next.3](https://github.com/twinfoundation/framework/compare/entity-v0.0.2-next.2...entity-v0.0.2-next.3) (2025-08-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
|
|
9
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
10
|
+
* update dependencies ([f3bd015](https://github.com/twinfoundation/framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
|
|
11
|
+
* use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Dependencies
|
|
15
|
+
|
|
16
|
+
* The following workspace dependencies were updated
|
|
17
|
+
* dependencies
|
|
18
|
+
* @twin.org/nameof bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
19
|
+
* @twin.org/core bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
20
|
+
* devDependencies
|
|
21
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
22
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
23
|
+
|
|
24
|
+
## [0.0.2-next.2](https://github.com/twinfoundation/framework/compare/entity-v0.0.2-next.1...entity-v0.0.2-next.2) (2025-08-06)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
|
|
30
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
31
|
+
* update dependencies ([f3bd015](https://github.com/twinfoundation/framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
|
|
32
|
+
* use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Dependencies
|
|
36
|
+
|
|
37
|
+
* The following workspace dependencies were updated
|
|
38
|
+
* dependencies
|
|
39
|
+
* @twin.org/nameof bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
40
|
+
* @twin.org/core bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
41
|
+
* devDependencies
|
|
42
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
43
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
44
|
+
|
|
45
|
+
## [0.0.2-next.1](https://github.com/twinfoundation/framework/compare/entity-v0.0.2-next.0...entity-v0.0.2-next.1) (2025-08-06)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Features
|
|
49
|
+
|
|
50
|
+
* add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
|
|
51
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
52
|
+
* update dependencies ([f3bd015](https://github.com/twinfoundation/framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
|
|
53
|
+
* use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Dependencies
|
|
57
|
+
|
|
58
|
+
* The following workspace dependencies were updated
|
|
59
|
+
* dependencies
|
|
60
|
+
* @twin.org/nameof bumped from 0.0.2-next.0 to 0.0.2-next.1
|
|
61
|
+
* @twin.org/core bumped from 0.0.2-next.0 to 0.0.2-next.1
|
|
62
|
+
* devDependencies
|
|
63
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.0 to 0.0.2-next.1
|
|
64
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.0 to 0.0.2-next.1
|
|
65
|
+
|
|
66
|
+
## 0.0.1 (2025-07-03)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
### Features
|
|
70
|
+
|
|
71
|
+
* release to production ([829d53d](https://github.com/twinfoundation/framework/commit/829d53d3953b1e1b40b0243c04cfdfd3842aac7b))
|
|
72
|
+
* release to production ([5cf3a76](https://github.com/twinfoundation/framework/commit/5cf3a76a09eff2e6414d0cba846c7c37400a11d6))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### Dependencies
|
|
76
|
+
|
|
77
|
+
* The following workspace dependencies were updated
|
|
78
|
+
* dependencies
|
|
79
|
+
* @twin.org/nameof bumped from ^0.0.0 to ^0.0.1
|
|
80
|
+
* @twin.org/core bumped from ^0.0.0 to ^0.0.1
|
|
81
|
+
* devDependencies
|
|
82
|
+
* @twin.org/nameof-transformer bumped from ^0.0.0 to ^0.0.1
|
|
83
|
+
* @twin.org/nameof-vitest-plugin bumped from ^0.0.0 to ^0.0.1
|
|
84
|
+
|
|
85
|
+
## [0.0.1-next.70](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.69...entity-v0.0.1-next.70) (2025-07-02)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
### Features
|
|
89
|
+
|
|
90
|
+
* add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
|
|
91
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
92
|
+
* use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
### Dependencies
|
|
96
|
+
|
|
97
|
+
* The following workspace dependencies were updated
|
|
98
|
+
* dependencies
|
|
99
|
+
* @twin.org/nameof bumped from 0.0.1-next.69 to 0.0.1-next.70
|
|
100
|
+
* @twin.org/core bumped from 0.0.1-next.69 to 0.0.1-next.70
|
|
101
|
+
* devDependencies
|
|
102
|
+
* @twin.org/nameof-transformer bumped from 0.0.1-next.69 to 0.0.1-next.70
|
|
103
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.69 to 0.0.1-next.70
|
|
104
|
+
|
|
105
|
+
## [0.0.1-next.69](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.68...entity-v0.0.1-next.69) (2025-07-02)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
### Features
|
|
109
|
+
|
|
110
|
+
* add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
|
|
111
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
112
|
+
* use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
### Dependencies
|
|
116
|
+
|
|
117
|
+
* The following workspace dependencies were updated
|
|
118
|
+
* dependencies
|
|
119
|
+
* @twin.org/nameof bumped from 0.0.1-next.68 to 0.0.1-next.69
|
|
120
|
+
* @twin.org/core bumped from 0.0.1-next.68 to 0.0.1-next.69
|
|
121
|
+
* devDependencies
|
|
122
|
+
* @twin.org/nameof-transformer bumped from 0.0.1-next.68 to 0.0.1-next.69
|
|
123
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.68 to 0.0.1-next.69
|
|
124
|
+
|
|
125
|
+
## [0.0.1-next.68](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.67...entity-v0.0.1-next.68) (2025-07-02)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### Features
|
|
129
|
+
|
|
130
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/twinfoundation/framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
### Dependencies
|
|
134
|
+
|
|
135
|
+
* The following workspace dependencies were updated
|
|
136
|
+
* dependencies
|
|
137
|
+
* @twin.org/nameof bumped from 0.0.1-next.67 to 0.0.1-next.68
|
|
138
|
+
* @twin.org/core bumped from 0.0.1-next.67 to 0.0.1-next.68
|
|
139
|
+
* devDependencies
|
|
140
|
+
* @twin.org/nameof-transformer bumped from 0.0.1-next.67 to 0.0.1-next.68
|
|
141
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.1-next.67 to 0.0.1-next.68
|
|
142
|
+
|
|
143
|
+
## [0.0.1-next.67](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.66...entity-v0.0.1-next.67) (2025-06-26)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
### Miscellaneous Chores
|
|
147
|
+
|
|
148
|
+
* **entity:** Synchronize repo versions
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
### Dependencies
|
|
152
|
+
|
|
153
|
+
* The following workspace dependencies were updated
|
|
154
|
+
* dependencies
|
|
155
|
+
* @twin.org/core bumped from 0.0.1-next.66 to 0.0.1-next.67
|
|
156
|
+
|
|
157
|
+
## [0.0.1-next.66](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.65...entity-v0.0.1-next.66) (2025-06-26)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
### Miscellaneous Chores
|
|
161
|
+
|
|
162
|
+
* **entity:** Synchronize repo versions
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
### Dependencies
|
|
166
|
+
|
|
167
|
+
* The following workspace dependencies were updated
|
|
168
|
+
* dependencies
|
|
169
|
+
* @twin.org/core bumped from 0.0.1-next.65 to 0.0.1-next.66
|
|
170
|
+
|
|
171
|
+
## [0.0.1-next.65](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.64...entity-v0.0.1-next.65) (2025-06-19)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
### Miscellaneous Chores
|
|
175
|
+
|
|
176
|
+
* **entity:** Synchronize repo versions
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
### Dependencies
|
|
180
|
+
|
|
181
|
+
* The following workspace dependencies were updated
|
|
182
|
+
* dependencies
|
|
183
|
+
* @twin.org/core bumped from 0.0.1-next.64 to 0.0.1-next.65
|
|
184
|
+
|
|
185
|
+
## [0.0.1-next.64](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.63...entity-v0.0.1-next.64) (2025-06-19)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
### Miscellaneous Chores
|
|
189
|
+
|
|
190
|
+
* **entity:** Synchronize repo versions
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
### Dependencies
|
|
194
|
+
|
|
195
|
+
* The following workspace dependencies were updated
|
|
196
|
+
* dependencies
|
|
197
|
+
* @twin.org/core bumped from 0.0.1-next.63 to 0.0.1-next.64
|
|
198
|
+
|
|
199
|
+
## [0.0.1-next.63](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.62...entity-v0.0.1-next.63) (2025-06-18)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
### Miscellaneous Chores
|
|
203
|
+
|
|
204
|
+
* **entity:** Synchronize repo versions
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
### Dependencies
|
|
208
|
+
|
|
209
|
+
* The following workspace dependencies were updated
|
|
210
|
+
* dependencies
|
|
211
|
+
* @twin.org/core bumped from 0.0.1-next.62 to 0.0.1-next.63
|
|
212
|
+
|
|
213
|
+
## [0.0.1-next.62](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.61...entity-v0.0.1-next.62) (2025-06-17)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
### Features
|
|
217
|
+
|
|
218
|
+
* add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
|
|
219
|
+
* use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
### Dependencies
|
|
223
|
+
|
|
224
|
+
* The following workspace dependencies were updated
|
|
225
|
+
* dependencies
|
|
226
|
+
* @twin.org/core bumped from 0.0.1-next.61 to 0.0.1-next.62
|
|
227
|
+
|
|
228
|
+
## [0.0.1-next.61](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.60...entity-v0.0.1-next.61) (2025-06-17)
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
### Miscellaneous Chores
|
|
232
|
+
|
|
233
|
+
* **entity:** Synchronize repo versions
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
### Dependencies
|
|
237
|
+
|
|
238
|
+
* The following workspace dependencies were updated
|
|
239
|
+
* dependencies
|
|
240
|
+
* @twin.org/core bumped from 0.0.1-next.60 to 0.0.1-next.61
|
|
241
|
+
|
|
242
|
+
## [0.0.1-next.60](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.59...entity-v0.0.1-next.60) (2025-06-17)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
### Miscellaneous Chores
|
|
246
|
+
|
|
247
|
+
* **entity:** Synchronize repo versions
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
### Dependencies
|
|
251
|
+
|
|
252
|
+
* The following workspace dependencies were updated
|
|
253
|
+
* dependencies
|
|
254
|
+
* @twin.org/core bumped from 0.0.1-next.59 to 0.0.1-next.60
|
|
255
|
+
|
|
256
|
+
## [0.0.1-next.59](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.58...entity-v0.0.1-next.59) (2025-06-17)
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
### Miscellaneous Chores
|
|
260
|
+
|
|
261
|
+
* **entity:** Synchronize repo versions
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
### Dependencies
|
|
265
|
+
|
|
266
|
+
* The following workspace dependencies were updated
|
|
267
|
+
* dependencies
|
|
268
|
+
* @twin.org/core bumped from 0.0.1-next.58 to 0.0.1-next.59
|
|
269
|
+
|
|
270
|
+
## [0.0.1-next.58](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.57...entity-v0.0.1-next.58) (2025-06-13)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
### Miscellaneous Chores
|
|
274
|
+
|
|
275
|
+
* **entity:** Synchronize repo versions
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
### Dependencies
|
|
279
|
+
|
|
280
|
+
* The following workspace dependencies were updated
|
|
281
|
+
* dependencies
|
|
282
|
+
* @twin.org/core bumped from 0.0.1-next.57 to 0.0.1-next.58
|
|
283
|
+
|
|
284
|
+
## [0.0.1-next.57](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.56...entity-v0.0.1-next.57) (2025-06-10)
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
### Features
|
|
288
|
+
|
|
289
|
+
* add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/twinfoundation/framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
### Dependencies
|
|
293
|
+
|
|
294
|
+
* The following workspace dependencies were updated
|
|
295
|
+
* dependencies
|
|
296
|
+
* @twin.org/core bumped from 0.0.1-next.56 to 0.0.1-next.57
|
|
297
|
+
|
|
298
|
+
## [0.0.1-next.56](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.55...entity-v0.0.1-next.56) (2025-05-08)
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
### Miscellaneous Chores
|
|
302
|
+
|
|
303
|
+
* **entity:** Synchronize repo versions
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
### Dependencies
|
|
307
|
+
|
|
308
|
+
* The following workspace dependencies were updated
|
|
309
|
+
* dependencies
|
|
310
|
+
* @twin.org/core bumped from 0.0.1-next.55 to 0.0.1-next.56
|
|
311
|
+
|
|
312
|
+
## [0.0.1-next.55](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.54...entity-v0.0.1-next.55) (2025-05-07)
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
### Miscellaneous Chores
|
|
316
|
+
|
|
317
|
+
* **entity:** Synchronize repo versions
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
### Dependencies
|
|
321
|
+
|
|
322
|
+
* The following workspace dependencies were updated
|
|
323
|
+
* dependencies
|
|
324
|
+
* @twin.org/core bumped from 0.0.1-next.54 to 0.0.1-next.55
|
|
325
|
+
|
|
326
|
+
## [0.0.1-next.54](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.53...entity-v0.0.1-next.54) (2025-05-06)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
### Miscellaneous Chores
|
|
330
|
+
|
|
331
|
+
* **entity:** Synchronize repo versions
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
### Dependencies
|
|
335
|
+
|
|
336
|
+
* The following workspace dependencies were updated
|
|
337
|
+
* dependencies
|
|
338
|
+
* @twin.org/core bumped from 0.0.1-next.53 to 0.0.1-next.54
|
|
339
|
+
|
|
340
|
+
## [0.0.1-next.53](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.52...entity-v0.0.1-next.53) (2025-05-01)
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
### Miscellaneous Chores
|
|
344
|
+
|
|
345
|
+
* **entity:** Synchronize repo versions
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
### Dependencies
|
|
349
|
+
|
|
350
|
+
* The following workspace dependencies were updated
|
|
351
|
+
* dependencies
|
|
352
|
+
* @twin.org/core bumped from 0.0.1-next.52 to 0.0.1-next.53
|
|
353
|
+
|
|
354
|
+
## [0.0.1-next.52](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.51...entity-v0.0.1-next.52) (2025-04-17)
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
### Features
|
|
358
|
+
|
|
359
|
+
* use new shared store mechanism ([#131](https://github.com/twinfoundation/framework/issues/131)) ([934385b](https://github.com/twinfoundation/framework/commit/934385b2fbaf9f5c00a505ebf9d093bd5a425f55))
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
### Dependencies
|
|
363
|
+
|
|
364
|
+
* The following workspace dependencies were updated
|
|
365
|
+
* dependencies
|
|
366
|
+
* @twin.org/core bumped from 0.0.1-next.51 to 0.0.1-next.52
|
|
367
|
+
|
|
368
|
+
## [0.0.1-next.51](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.50...entity-v0.0.1-next.51) (2025-03-27)
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
### Miscellaneous Chores
|
|
372
|
+
|
|
373
|
+
* **entity:** Synchronize repo versions
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
### Dependencies
|
|
377
|
+
|
|
378
|
+
* The following workspace dependencies were updated
|
|
379
|
+
* dependencies
|
|
380
|
+
* @twin.org/core bumped from 0.0.1-next.50 to 0.0.1-next.51
|
|
381
|
+
|
|
382
|
+
## [0.0.1-next.50](https://github.com/twinfoundation/framework/compare/entity-v0.0.1-next.49...entity-v0.0.1-next.50) (2025-03-26)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
### Miscellaneous Chores
|
|
386
|
+
|
|
387
|
+
* **entity:** Synchronize repo versions
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
### Dependencies
|
|
391
|
+
|
|
392
|
+
* The following workspace dependencies were updated
|
|
393
|
+
* dependencies
|
|
394
|
+
* @twin.org/core bumped from 0.0.1-next.49 to 0.0.1-next.50
|
|
395
|
+
|
|
396
|
+
## 0.0.1-next.49
|
|
4
397
|
|
|
5
398
|
- Initial Release
|
|
@@ -4,13 +4,13 @@ Class to help with decorators.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new DecoratorHelper**():
|
|
9
|
+
> **new DecoratorHelper**(): `DecoratorHelper`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`DecoratorHelper`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
@@ -22,11 +22,15 @@ Get the schema from the reflection metadata.
|
|
|
22
22
|
|
|
23
23
|
#### Type Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### T
|
|
26
|
+
|
|
27
|
+
`T` = `unknown`
|
|
26
28
|
|
|
27
29
|
#### Parameters
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### target
|
|
32
|
+
|
|
33
|
+
`any`
|
|
30
34
|
|
|
31
35
|
The object to get the schema data from.
|
|
32
36
|
|
|
@@ -46,15 +50,21 @@ Set the schema from the reflection metadata.
|
|
|
46
50
|
|
|
47
51
|
#### Type Parameters
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
##### T
|
|
54
|
+
|
|
55
|
+
`T` = `unknown`
|
|
50
56
|
|
|
51
57
|
#### Parameters
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
##### target
|
|
60
|
+
|
|
61
|
+
`any`
|
|
54
62
|
|
|
55
63
|
The object to get the schema data from.
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
##### entitySchema
|
|
66
|
+
|
|
67
|
+
[`IEntitySchema`](../interfaces/IEntitySchema.md)\<`T`\>
|
|
58
68
|
|
|
59
69
|
The schema to set.
|
|
60
70
|
|
|
@@ -4,33 +4,39 @@ Class to perform condition checks.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new EntityConditions**():
|
|
9
|
+
> **new EntityConditions**(): `EntityConditions`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`EntityConditions`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
17
17
|
### check()
|
|
18
18
|
|
|
19
|
-
> `static` **check**\<`T`\>(`entity`, `condition
|
|
19
|
+
> `static` **check**\<`T`\>(`entity`, `condition?`): `boolean`
|
|
20
20
|
|
|
21
21
|
See if the entity matches the conditions.
|
|
22
22
|
|
|
23
23
|
#### Type Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### T
|
|
26
|
+
|
|
27
|
+
`T`
|
|
26
28
|
|
|
27
29
|
#### Parameters
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### entity
|
|
32
|
+
|
|
33
|
+
`T`
|
|
30
34
|
|
|
31
35
|
The entity to test.
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
##### condition?
|
|
38
|
+
|
|
39
|
+
[`EntityCondition`](../type-aliases/EntityCondition.md)\<`T`\>
|
|
34
40
|
|
|
35
41
|
The conditions to test.
|
|
36
42
|
|
|
@@ -50,15 +56,21 @@ See if the entity matches the conditions.
|
|
|
50
56
|
|
|
51
57
|
#### Type Parameters
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
##### T
|
|
60
|
+
|
|
61
|
+
`T`
|
|
54
62
|
|
|
55
63
|
#### Parameters
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
##### entity
|
|
66
|
+
|
|
67
|
+
`T`
|
|
58
68
|
|
|
59
69
|
The entity to test.
|
|
60
70
|
|
|
61
|
-
|
|
71
|
+
##### comparator
|
|
72
|
+
|
|
73
|
+
[`IComparator`](../interfaces/IComparator.md)
|
|
62
74
|
|
|
63
75
|
The condition to test.
|
|
64
76
|
|
|
@@ -4,13 +4,13 @@ Class to help with entity schema operations.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new EntitySchemaHelper**():
|
|
9
|
+
> **new EntitySchemaHelper**(): `EntitySchemaHelper`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`EntitySchemaHelper`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
@@ -22,11 +22,15 @@ Get the schema for the specified object.
|
|
|
22
22
|
|
|
23
23
|
#### Type Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### T
|
|
26
|
+
|
|
27
|
+
`T` = `unknown`
|
|
26
28
|
|
|
27
29
|
#### Parameters
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### target
|
|
32
|
+
|
|
33
|
+
`any`
|
|
30
34
|
|
|
31
35
|
The object to get the schema data for.
|
|
32
36
|
|
|
@@ -46,11 +50,15 @@ Get the primary key from the entity schema.
|
|
|
46
50
|
|
|
47
51
|
#### Type Parameters
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
##### T
|
|
54
|
+
|
|
55
|
+
`T`
|
|
50
56
|
|
|
51
57
|
#### Parameters
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
##### entitySchema
|
|
60
|
+
|
|
61
|
+
[`IEntitySchema`](../interfaces/IEntitySchema.md)\<`T`\>
|
|
54
62
|
|
|
55
63
|
The entity schema to find the primary key from.
|
|
56
64
|
|
|
@@ -74,11 +82,15 @@ Get the sort properties from the schema.
|
|
|
74
82
|
|
|
75
83
|
#### Type Parameters
|
|
76
84
|
|
|
77
|
-
|
|
85
|
+
##### T
|
|
86
|
+
|
|
87
|
+
`T`
|
|
78
88
|
|
|
79
89
|
#### Parameters
|
|
80
90
|
|
|
81
|
-
|
|
91
|
+
##### entitySchema
|
|
92
|
+
|
|
93
|
+
[`IEntitySchema`](../interfaces/IEntitySchema.md)\<`T`\>
|
|
82
94
|
|
|
83
95
|
The entity schema to find the primary key from.
|
|
84
96
|
|
|
@@ -92,21 +104,27 @@ The sort keys from the schema or undefined if there are none.
|
|
|
92
104
|
|
|
93
105
|
### buildSortProperties()
|
|
94
106
|
|
|
95
|
-
> `static` **buildSortProperties**\<`T`\>(`entitySchema`, `overrideSortKeys
|
|
107
|
+
> `static` **buildSortProperties**\<`T`\>(`entitySchema`, `overrideSortKeys?`): `undefined` \| [`IEntitySort`](../interfaces/IEntitySort.md)\<`T`\>[]
|
|
96
108
|
|
|
97
109
|
Build sort properties from the schema and override if necessary.
|
|
98
110
|
|
|
99
111
|
#### Type Parameters
|
|
100
112
|
|
|
101
|
-
|
|
113
|
+
##### T
|
|
114
|
+
|
|
115
|
+
`T`
|
|
102
116
|
|
|
103
117
|
#### Parameters
|
|
104
118
|
|
|
105
|
-
|
|
119
|
+
##### entitySchema
|
|
120
|
+
|
|
121
|
+
[`IEntitySchema`](../interfaces/IEntitySchema.md)\<`T`\>
|
|
106
122
|
|
|
107
123
|
The entity schema to retrieve the default sort keys.
|
|
108
124
|
|
|
109
|
-
|
|
125
|
+
##### overrideSortKeys?
|
|
126
|
+
|
|
127
|
+
`object`[]
|
|
110
128
|
|
|
111
129
|
The override sort keys.
|
|
112
130
|
|
|
@@ -115,3 +133,39 @@ The override sort keys.
|
|
|
115
133
|
`undefined` \| [`IEntitySort`](../interfaces/IEntitySort.md)\<`T`\>[]
|
|
116
134
|
|
|
117
135
|
The finalised sort keys.
|
|
136
|
+
|
|
137
|
+
***
|
|
138
|
+
|
|
139
|
+
### validateEntity()
|
|
140
|
+
|
|
141
|
+
> `static` **validateEntity**\<`T`\>(`entity`, `entitySchema`): `void`
|
|
142
|
+
|
|
143
|
+
Validate the entity against the schema.
|
|
144
|
+
|
|
145
|
+
#### Type Parameters
|
|
146
|
+
|
|
147
|
+
##### T
|
|
148
|
+
|
|
149
|
+
`T`
|
|
150
|
+
|
|
151
|
+
#### Parameters
|
|
152
|
+
|
|
153
|
+
##### entity
|
|
154
|
+
|
|
155
|
+
`T`
|
|
156
|
+
|
|
157
|
+
The entity to validate.
|
|
158
|
+
|
|
159
|
+
##### entitySchema
|
|
160
|
+
|
|
161
|
+
[`IEntitySchema`](../interfaces/IEntitySchema.md)\<`T`\>
|
|
162
|
+
|
|
163
|
+
The schema to validate against.
|
|
164
|
+
|
|
165
|
+
#### Returns
|
|
166
|
+
|
|
167
|
+
`void`
|
|
168
|
+
|
|
169
|
+
#### Throws
|
|
170
|
+
|
|
171
|
+
If the entity is invalid.
|
|
@@ -4,33 +4,39 @@ Class to perform sort operations on entities.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new EntitySorter**():
|
|
9
|
+
> **new EntitySorter**(): `EntitySorter`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`EntitySorter`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
17
17
|
### sort()
|
|
18
18
|
|
|
19
|
-
> `static` **sort**\<`T`\>(`entities`, `entitySorters
|
|
19
|
+
> `static` **sort**\<`T`\>(`entities`, `entitySorters?`): `T`[]
|
|
20
20
|
|
|
21
21
|
Sort a list of entities using multiple keys and direction.
|
|
22
22
|
|
|
23
23
|
#### Type Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### T
|
|
26
|
+
|
|
27
|
+
`T`
|
|
26
28
|
|
|
27
29
|
#### Parameters
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### entities
|
|
32
|
+
|
|
33
|
+
`T`[]
|
|
30
34
|
|
|
31
35
|
The list of entities.
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
##### entitySorters?
|
|
38
|
+
|
|
39
|
+
[`IEntitySort`](../interfaces/IEntitySort.md)\<`T`\>[]
|
|
34
40
|
|
|
35
41
|
The sort keys to use.
|
|
36
42
|
|
|
@@ -50,27 +56,39 @@ Compare two properties.
|
|
|
50
56
|
|
|
51
57
|
#### Type Parameters
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
##### T
|
|
60
|
+
|
|
61
|
+
`T`
|
|
54
62
|
|
|
55
63
|
#### Parameters
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
##### entity1
|
|
66
|
+
|
|
67
|
+
`T`
|
|
58
68
|
|
|
59
69
|
The first entity.
|
|
60
70
|
|
|
61
|
-
|
|
71
|
+
##### entity2
|
|
72
|
+
|
|
73
|
+
`T`
|
|
62
74
|
|
|
63
75
|
The second entity.
|
|
64
76
|
|
|
65
|
-
|
|
77
|
+
##### prop
|
|
78
|
+
|
|
79
|
+
keyof `T`
|
|
66
80
|
|
|
67
81
|
The property to compare.
|
|
68
82
|
|
|
69
|
-
|
|
83
|
+
##### type
|
|
84
|
+
|
|
85
|
+
[`EntitySchemaPropertyType`](../type-aliases/EntitySchemaPropertyType.md)
|
|
70
86
|
|
|
71
87
|
The type of the property.
|
|
72
88
|
|
|
73
|
-
|
|
89
|
+
##### direction
|
|
90
|
+
|
|
91
|
+
[`SortDirection`](../type-aliases/SortDirection.md) = `SortDirection.Ascending`
|
|
74
92
|
|
|
75
93
|
The direction of the sort.
|
|
76
94
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# Function: entity()
|
|
2
2
|
|
|
3
|
-
> **entity**(`options
|
|
3
|
+
> **entity**(`options?`): `any`
|
|
4
4
|
|
|
5
5
|
Decorator to produce schema data for entity.
|
|
6
6
|
|
|
7
7
|
## Parameters
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### options?
|
|
10
|
+
|
|
11
|
+
[`IEntitySchemaOptions`](../interfaces/IEntitySchemaOptions.md)
|
|
10
12
|
|
|
11
13
|
The options for the entity.
|
|
12
14
|
|
|
@@ -6,7 +6,9 @@ Decorator to produce schema property data for entities.
|
|
|
6
6
|
|
|
7
7
|
## Parameters
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### options
|
|
10
|
+
|
|
11
|
+
`Omit`\<[`IEntitySchemaProperty`](../interfaces/IEntitySchemaProperty.md), `"property"`\>
|
|
10
12
|
|
|
11
13
|
The options for the property.
|
|
12
14
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Type Alias: ComparisonOperator
|
|
2
2
|
|
|
3
|
-
> **ComparisonOperator
|
|
3
|
+
> **ComparisonOperator** = *typeof* [`ComparisonOperator`](../variables/ComparisonOperator.md)\[keyof *typeof* [`ComparisonOperator`](../variables/ComparisonOperator.md)\]
|
|
4
4
|
|
|
5
5
|
The types of comparisons.
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# Type Alias: EntityCondition\<T\>
|
|
2
2
|
|
|
3
|
-
> **EntityCondition**\<`T
|
|
3
|
+
> **EntityCondition**\<`T`\> = [`IComparator`](../interfaces/IComparator.md) \| [`IComparatorGroup`](../interfaces/IComparatorGroup.md)\<`T`\>
|
|
4
4
|
|
|
5
5
|
Type defining condition for entities filtering.
|
|
6
6
|
|
|
7
7
|
## Type Parameters
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### T
|
|
10
|
+
|
|
11
|
+
`T`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Type Alias: EntitySchemaPropertyFormat
|
|
2
2
|
|
|
3
|
-
> **EntitySchemaPropertyFormat
|
|
3
|
+
> **EntitySchemaPropertyFormat** = *typeof* [`EntitySchemaPropertyFormat`](../variables/EntitySchemaPropertyFormat.md)\[keyof *typeof* [`EntitySchemaPropertyFormat`](../variables/EntitySchemaPropertyFormat.md)\]
|
|
4
4
|
|
|
5
5
|
Definition of the entity property type's format.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Type Alias: EntitySchemaPropertyType
|
|
2
2
|
|
|
3
|
-
> **EntitySchemaPropertyType
|
|
3
|
+
> **EntitySchemaPropertyType** = *typeof* [`EntitySchemaPropertyType`](../variables/EntitySchemaPropertyType.md)\[keyof *typeof* [`EntitySchemaPropertyType`](../variables/EntitySchemaPropertyType.md)\]
|
|
4
4
|
|
|
5
5
|
Definition of the entity property types.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Type Alias: LogicalOperator
|
|
2
2
|
|
|
3
|
-
> **LogicalOperator
|
|
3
|
+
> **LogicalOperator** = *typeof* [`LogicalOperator`](../variables/LogicalOperator.md)\[keyof *typeof* [`LogicalOperator`](../variables/LogicalOperator.md)\]
|
|
4
4
|
|
|
5
5
|
The logical operators for condition combining.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Type Alias: SortDirection
|
|
2
2
|
|
|
3
|
-
> **SortDirection
|
|
3
|
+
> **SortDirection** = *typeof* [`SortDirection`](../variables/SortDirection.md)\[keyof *typeof* [`SortDirection`](../variables/SortDirection.md)\]
|
|
4
4
|
|
|
5
5
|
The sort directions.
|
package/locales/en.json
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
"error": {
|
|
3
3
|
"entitySchemaHelper": {
|
|
4
4
|
"noIsPrimary": "Property \"entitySchema.properties\" must contain a value with isPrimary set",
|
|
5
|
-
"multipleIsPrimary": "Property \"entitySchema.properties\" contains more than one property with isPrimary set"
|
|
5
|
+
"multipleIsPrimary": "Property \"entitySchema.properties\" contains more than one property with isPrimary set",
|
|
6
|
+
"invalidEntityProperties": "The schema has no properties defined, but the entity has properties",
|
|
7
|
+
"invalidEntityProperty": "The entity value of \"{value}\" does not match the type \"{type}\" for property \"{property}\"",
|
|
8
|
+
"invalidOptional": "The entity property \"{property}\" of type \"{type}\" is not optional, but no value has been provided",
|
|
9
|
+
"invalidEntityKeys": "The entity had additional properties that are not in the schema, \"{keys}\""
|
|
6
10
|
}
|
|
7
11
|
}
|
|
8
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/entity",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-next.3",
|
|
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.
|
|
18
|
-
"@twin.org/nameof": "next",
|
|
17
|
+
"@twin.org/core": "0.0.2-next.3",
|
|
18
|
+
"@twin.org/nameof": "0.0.2-next.3",
|
|
19
19
|
"reflect-metadata": "0.2.2"
|
|
20
20
|
},
|
|
21
21
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"types": "./dist/types/index.d.ts",
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
|
+
"types": "./dist/types/index.d.ts",
|
|
26
27
|
"require": "./dist/cjs/index.cjs",
|
|
27
|
-
"import": "./dist/esm/index.mjs"
|
|
28
|
-
"types": "./dist/types/index.d.ts"
|
|
28
|
+
"import": "./dist/esm/index.mjs"
|
|
29
29
|
},
|
|
30
|
-
"./locales": "./locales"
|
|
30
|
+
"./locales/*.json": "./locales/*.json"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"dist/cjs",
|