@twin.org/entity 0.0.1-next.1

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.
Files changed (53) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +25 -0
  3. package/dist/cjs/index.cjs +611 -0
  4. package/dist/esm/index.mjs +598 -0
  5. package/dist/types/decorators/entityDecorator.d.ts +8 -0
  6. package/dist/types/decorators/propertyDecorator.d.ts +8 -0
  7. package/dist/types/factories/entitySchemaFactory.d.ts +6 -0
  8. package/dist/types/index.d.ts +19 -0
  9. package/dist/types/models/IComparator.d.ts +18 -0
  10. package/dist/types/models/IComparatorGroup.d.ts +15 -0
  11. package/dist/types/models/IEntitySchema.d.ts +19 -0
  12. package/dist/types/models/IEntitySchemaOptions.d.ts +9 -0
  13. package/dist/types/models/IEntitySchemaProperty.d.ts +52 -0
  14. package/dist/types/models/IEntitySort.d.ts +19 -0
  15. package/dist/types/models/comparisonOperator.d.ts +52 -0
  16. package/dist/types/models/entityCondition.d.ts +6 -0
  17. package/dist/types/models/entitySchemaPropertyFormat.d.ts +77 -0
  18. package/dist/types/models/entitySchemaPropertyType.d.ts +33 -0
  19. package/dist/types/models/logicalOperator.d.ts +17 -0
  20. package/dist/types/models/sortDirection.d.ts +17 -0
  21. package/dist/types/utils/decoratorHelper.d.ts +19 -0
  22. package/dist/types/utils/entityConditions.d.ts +21 -0
  23. package/dist/types/utils/entitySchemaHelper.d.ts +38 -0
  24. package/dist/types/utils/entitySorter.d.ts +25 -0
  25. package/docs/changelog.md +5 -0
  26. package/docs/examples.md +1 -0
  27. package/docs/reference/classes/DecoratorHelper.md +63 -0
  28. package/docs/reference/classes/EntityConditions.md +69 -0
  29. package/docs/reference/classes/EntitySchemaHelper.md +117 -0
  30. package/docs/reference/classes/EntitySorter.md +81 -0
  31. package/docs/reference/functions/entity.md +17 -0
  32. package/docs/reference/functions/property.md +17 -0
  33. package/docs/reference/index.md +40 -0
  34. package/docs/reference/interfaces/IComparator.md +27 -0
  35. package/docs/reference/interfaces/IComparatorGroup.md +23 -0
  36. package/docs/reference/interfaces/IEntitySchema.md +31 -0
  37. package/docs/reference/interfaces/IEntitySchemaOptions.md +11 -0
  38. package/docs/reference/interfaces/IEntitySchemaProperty.md +95 -0
  39. package/docs/reference/interfaces/IEntitySort.md +31 -0
  40. package/docs/reference/type-aliases/ComparisonOperator.md +5 -0
  41. package/docs/reference/type-aliases/EntityCondition.md +9 -0
  42. package/docs/reference/type-aliases/EntitySchemaPropertyFormat.md +5 -0
  43. package/docs/reference/type-aliases/EntitySchemaPropertyType.md +5 -0
  44. package/docs/reference/type-aliases/LogicalOperator.md +5 -0
  45. package/docs/reference/type-aliases/SortDirection.md +5 -0
  46. package/docs/reference/variables/ComparisonOperator.md +68 -0
  47. package/docs/reference/variables/EntitySchemaFactory.md +5 -0
  48. package/docs/reference/variables/EntitySchemaPropertyFormat.md +109 -0
  49. package/docs/reference/variables/EntitySchemaPropertyType.md +43 -0
  50. package/docs/reference/variables/LogicalOperator.md +19 -0
  51. package/docs/reference/variables/SortDirection.md +19 -0
  52. package/locales/en.json +8 -0
  53. package/package.json +65 -0
@@ -0,0 +1,81 @@
1
+ # Class: EntitySorter
2
+
3
+ Class to perform sort operations on entities.
4
+
5
+ ## Constructors
6
+
7
+ ### new EntitySorter()
8
+
9
+ > **new EntitySorter**(): [`EntitySorter`](EntitySorter.md)
10
+
11
+ #### Returns
12
+
13
+ [`EntitySorter`](EntitySorter.md)
14
+
15
+ ## Methods
16
+
17
+ ### sort()
18
+
19
+ > `static` **sort**\<`T`\>(`entities`, `entitySorters`?): `T`[]
20
+
21
+ Sort a list of entities using multiple keys and direction.
22
+
23
+ #### Type Parameters
24
+
25
+ • **T**
26
+
27
+ #### Parameters
28
+
29
+ • **entities**: `T`[]
30
+
31
+ The list of entities.
32
+
33
+ • **entitySorters?**: [`IEntitySort`](../interfaces/IEntitySort.md)\<`T`\>[]
34
+
35
+ The sort keys to use.
36
+
37
+ #### Returns
38
+
39
+ `T`[]
40
+
41
+ The sorted list.
42
+
43
+ ***
44
+
45
+ ### compare()
46
+
47
+ > `static` **compare**\<`T`\>(`entity1`, `entity2`, `prop`, `type`, `direction`): `number`
48
+
49
+ Compare two properties.
50
+
51
+ #### Type Parameters
52
+
53
+ • **T**
54
+
55
+ #### Parameters
56
+
57
+ • **entity1**: `T`
58
+
59
+ The first entity.
60
+
61
+ • **entity2**: `T`
62
+
63
+ The second entity.
64
+
65
+ • **prop**: keyof `T`
66
+
67
+ The property to compare.
68
+
69
+ • **type**: [`EntitySchemaPropertyType`](../type-aliases/EntitySchemaPropertyType.md)
70
+
71
+ The type of the property.
72
+
73
+ • **direction**: [`SortDirection`](../type-aliases/SortDirection.md) = `SortDirection.Ascending`
74
+
75
+ The direction of the sort.
76
+
77
+ #### Returns
78
+
79
+ `number`
80
+
81
+ The result of the comparison.
@@ -0,0 +1,17 @@
1
+ # Function: entity()
2
+
3
+ > **entity**(`options`?): `any`
4
+
5
+ Decorator to produce schema data for entity.
6
+
7
+ ## Parameters
8
+
9
+ • **options?**: [`IEntitySchemaOptions`](../interfaces/IEntitySchemaOptions.md)
10
+
11
+ The options for the entity.
12
+
13
+ ## Returns
14
+
15
+ `any`
16
+
17
+ The class decorator.
@@ -0,0 +1,17 @@
1
+ # Function: property()
2
+
3
+ > **property**(`options`): `any`
4
+
5
+ Decorator to produce schema property data for entities.
6
+
7
+ ## Parameters
8
+
9
+ • **options**: `Omit`\<[`IEntitySchemaProperty`](../interfaces/IEntitySchemaProperty.md)\<`unknown`\>, `"property"`\>
10
+
11
+ The options for the property.
12
+
13
+ ## Returns
14
+
15
+ `any`
16
+
17
+ The property decorator.
@@ -0,0 +1,40 @@
1
+ # @twin.org/entity
2
+
3
+ ## Classes
4
+
5
+ - [DecoratorHelper](classes/DecoratorHelper.md)
6
+ - [EntityConditions](classes/EntityConditions.md)
7
+ - [EntitySchemaHelper](classes/EntitySchemaHelper.md)
8
+ - [EntitySorter](classes/EntitySorter.md)
9
+
10
+ ## Interfaces
11
+
12
+ - [IComparator](interfaces/IComparator.md)
13
+ - [IComparatorGroup](interfaces/IComparatorGroup.md)
14
+ - [IEntitySchema](interfaces/IEntitySchema.md)
15
+ - [IEntitySchemaOptions](interfaces/IEntitySchemaOptions.md)
16
+ - [IEntitySchemaProperty](interfaces/IEntitySchemaProperty.md)
17
+ - [IEntitySort](interfaces/IEntitySort.md)
18
+
19
+ ## Type Aliases
20
+
21
+ - [ComparisonOperator](type-aliases/ComparisonOperator.md)
22
+ - [EntityCondition](type-aliases/EntityCondition.md)
23
+ - [EntitySchemaPropertyFormat](type-aliases/EntitySchemaPropertyFormat.md)
24
+ - [EntitySchemaPropertyType](type-aliases/EntitySchemaPropertyType.md)
25
+ - [LogicalOperator](type-aliases/LogicalOperator.md)
26
+ - [SortDirection](type-aliases/SortDirection.md)
27
+
28
+ ## Variables
29
+
30
+ - [EntitySchemaFactory](variables/EntitySchemaFactory.md)
31
+ - [ComparisonOperator](variables/ComparisonOperator.md)
32
+ - [EntitySchemaPropertyFormat](variables/EntitySchemaPropertyFormat.md)
33
+ - [EntitySchemaPropertyType](variables/EntitySchemaPropertyType.md)
34
+ - [LogicalOperator](variables/LogicalOperator.md)
35
+ - [SortDirection](variables/SortDirection.md)
36
+
37
+ ## Functions
38
+
39
+ - [entity](functions/entity.md)
40
+ - [property](functions/property.md)
@@ -0,0 +1,27 @@
1
+ # Interface: IComparator
2
+
3
+ Interface defining comparator operator.
4
+
5
+ ## Properties
6
+
7
+ ### property
8
+
9
+ > **property**: `string`
10
+
11
+ The name of the property in the object to check.
12
+
13
+ ***
14
+
15
+ ### value
16
+
17
+ > **value**: `unknown`
18
+
19
+ The value of the property to check.
20
+
21
+ ***
22
+
23
+ ### comparison
24
+
25
+ > **comparison**: [`ComparisonOperator`](../type-aliases/ComparisonOperator.md)
26
+
27
+ The comparison to perform.
@@ -0,0 +1,23 @@
1
+ # Interface: IComparatorGroup\<T\>
2
+
3
+ Interface defining condition group operator.
4
+
5
+ ## Type Parameters
6
+
7
+ • **T** = `unknown`
8
+
9
+ ## Properties
10
+
11
+ ### conditions
12
+
13
+ > **conditions**: [`EntityCondition`](../type-aliases/EntityCondition.md)\<`T`\>[]
14
+
15
+ The conditions to join in a group.
16
+
17
+ ***
18
+
19
+ ### logicalOperator?
20
+
21
+ > `optional` **logicalOperator**: [`LogicalOperator`](../type-aliases/LogicalOperator.md)
22
+
23
+ The logical operator to use.
@@ -0,0 +1,31 @@
1
+ # Interface: IEntitySchema\<T\>
2
+
3
+ Definition for an entity schema.
4
+
5
+ ## Type Parameters
6
+
7
+ • **T** = `unknown`
8
+
9
+ ## Properties
10
+
11
+ ### type
12
+
13
+ > **type**: `undefined` \| `string`
14
+
15
+ The type of the entity.
16
+
17
+ ***
18
+
19
+ ### options?
20
+
21
+ > `optional` **options**: [`IEntitySchemaOptions`](IEntitySchemaOptions.md)
22
+
23
+ The options for the entity.
24
+
25
+ ***
26
+
27
+ ### properties?
28
+
29
+ > `optional` **properties**: [`IEntitySchemaProperty`](IEntitySchemaProperty.md)\<`T`\>[]
30
+
31
+ The properties of the entity.
@@ -0,0 +1,11 @@
1
+ # Interface: IEntitySchemaOptions
2
+
3
+ Definition for an entity schema options.
4
+
5
+ ## Properties
6
+
7
+ ### description?
8
+
9
+ > `optional` **description**: `string`
10
+
11
+ Description of the object.
@@ -0,0 +1,95 @@
1
+ # Interface: IEntitySchemaProperty\<T\>
2
+
3
+ Definition for an entity schema property.
4
+
5
+ ## Type Parameters
6
+
7
+ • **T** = `unknown`
8
+
9
+ ## Properties
10
+
11
+ ### property
12
+
13
+ > **property**: keyof `T`
14
+
15
+ The property name from the entity.
16
+
17
+ ***
18
+
19
+ ### type
20
+
21
+ > **type**: [`EntitySchemaPropertyType`](../type-aliases/EntitySchemaPropertyType.md)
22
+
23
+ The type of the property.
24
+
25
+ ***
26
+
27
+ ### format?
28
+
29
+ > `optional` **format**: [`EntitySchemaPropertyFormat`](../type-aliases/EntitySchemaPropertyFormat.md)
30
+
31
+ The format of the property.
32
+
33
+ ***
34
+
35
+ ### isPrimary?
36
+
37
+ > `optional` **isPrimary**: `boolean`
38
+
39
+ Is this the primary index property.
40
+
41
+ ***
42
+
43
+ ### isSecondary?
44
+
45
+ > `optional` **isSecondary**: `boolean`
46
+
47
+ Is this a secondary index property.
48
+
49
+ ***
50
+
51
+ ### sortDirection?
52
+
53
+ > `optional` **sortDirection**: [`SortDirection`](../type-aliases/SortDirection.md)
54
+
55
+ Default sort direction for this field, leave empty if not sortable.
56
+
57
+ ***
58
+
59
+ ### optional?
60
+
61
+ > `optional` **optional**: `boolean`
62
+
63
+ Is the property optional.
64
+
65
+ ***
66
+
67
+ ### itemType?
68
+
69
+ > `optional` **itemType**: [`EntitySchemaPropertyType`](../type-aliases/EntitySchemaPropertyType.md)
70
+
71
+ The type of the item (only applies when type is `array`).
72
+
73
+ ***
74
+
75
+ ### itemTypeRef?
76
+
77
+ > `optional` **itemTypeRef**: `string`
78
+
79
+ The type ref of the item (only applies when type is either `array` or `object`).
80
+
81
+ ***
82
+
83
+ ### description?
84
+
85
+ > `optional` **description**: `string`
86
+
87
+ Description of the object.
88
+
89
+ ***
90
+
91
+ ### examples?
92
+
93
+ > `optional` **examples**: `unknown`[]
94
+
95
+ Examples of the property values.
@@ -0,0 +1,31 @@
1
+ # Interface: IEntitySort\<T\>
2
+
3
+ Definition of an entity property sort details.
4
+
5
+ ## Type Parameters
6
+
7
+ • **T**
8
+
9
+ ## Properties
10
+
11
+ ### property
12
+
13
+ > **property**: keyof `T`
14
+
15
+ The name of the property.
16
+
17
+ ***
18
+
19
+ ### type
20
+
21
+ > **type**: [`EntitySchemaPropertyType`](../type-aliases/EntitySchemaPropertyType.md)
22
+
23
+ The type of the property.
24
+
25
+ ***
26
+
27
+ ### sortDirection
28
+
29
+ > **sortDirection**: [`SortDirection`](../type-aliases/SortDirection.md)
30
+
31
+ Default sort direction for this column, leave empty if not sortable.
@@ -0,0 +1,5 @@
1
+ # Type Alias: ComparisonOperator
2
+
3
+ > **ComparisonOperator**: *typeof* [`ComparisonOperator`](../variables/ComparisonOperator.md)\[keyof *typeof* [`ComparisonOperator`](../variables/ComparisonOperator.md)\]
4
+
5
+ The types of comparisons.
@@ -0,0 +1,9 @@
1
+ # Type Alias: EntityCondition\<T\>
2
+
3
+ > **EntityCondition**\<`T`\>: [`IComparator`](../interfaces/IComparator.md) \| [`IComparatorGroup`](../interfaces/IComparatorGroup.md)\<`T`\>
4
+
5
+ Type defining condition for entities filtering.
6
+
7
+ ## Type Parameters
8
+
9
+ • **T**
@@ -0,0 +1,5 @@
1
+ # Type Alias: EntitySchemaPropertyFormat
2
+
3
+ > **EntitySchemaPropertyFormat**: *typeof* [`EntitySchemaPropertyFormat`](../variables/EntitySchemaPropertyFormat.md)\[keyof *typeof* [`EntitySchemaPropertyFormat`](../variables/EntitySchemaPropertyFormat.md)\]
4
+
5
+ Definition of the entity property type's format.
@@ -0,0 +1,5 @@
1
+ # Type Alias: EntitySchemaPropertyType
2
+
3
+ > **EntitySchemaPropertyType**: *typeof* [`EntitySchemaPropertyType`](../variables/EntitySchemaPropertyType.md)\[keyof *typeof* [`EntitySchemaPropertyType`](../variables/EntitySchemaPropertyType.md)\]
4
+
5
+ Definition of the entity property types.
@@ -0,0 +1,5 @@
1
+ # Type Alias: LogicalOperator
2
+
3
+ > **LogicalOperator**: *typeof* [`LogicalOperator`](../variables/LogicalOperator.md)\[keyof *typeof* [`LogicalOperator`](../variables/LogicalOperator.md)\]
4
+
5
+ The logical operators for condition combining.
@@ -0,0 +1,5 @@
1
+ # Type Alias: SortDirection
2
+
3
+ > **SortDirection**: *typeof* [`SortDirection`](../variables/SortDirection.md)\[keyof *typeof* [`SortDirection`](../variables/SortDirection.md)\]
4
+
5
+ The sort directions.
@@ -0,0 +1,68 @@
1
+ # Variable: ComparisonOperator
2
+
3
+ > `const` **ComparisonOperator**: `object`
4
+
5
+ The types of comparisons.
6
+
7
+ ## Type declaration
8
+
9
+ ### Equals
10
+
11
+ > `readonly` **Equals**: `"equals"` = `"equals"`
12
+
13
+ Equals.
14
+
15
+ ### NotEquals
16
+
17
+ > `readonly` **NotEquals**: `"not-equals"` = `"not-equals"`
18
+
19
+ Not Equals.
20
+
21
+ ### GreaterThan
22
+
23
+ > `readonly` **GreaterThan**: `"greater-than"` = `"greater-than"`
24
+
25
+ Greater Than.
26
+
27
+ ### GreaterThanOrEqual
28
+
29
+ > `readonly` **GreaterThanOrEqual**: `"greater-than-or-equal"` = `"greater-than-or-equal"`
30
+
31
+ Greater Than Or Equal.
32
+
33
+ ### LessThan
34
+
35
+ > `readonly` **LessThan**: `"less-than"` = `"less-than"`
36
+
37
+ Less Than.
38
+
39
+ ### LessThanOrEqual
40
+
41
+ > `readonly` **LessThanOrEqual**: `"less-than-or-equal"` = `"less-than-or-equal"`
42
+
43
+ Less Than Or Equal.
44
+
45
+ ### Includes
46
+
47
+ > `readonly` **Includes**: `"includes"` = `"includes"`
48
+
49
+ Includes.
50
+ A string in a substring.
51
+ A set contains an element.
52
+ A list contains an element.
53
+
54
+ ### NotIncludes
55
+
56
+ > `readonly` **NotIncludes**: `"not-includes"` = `"not-includes"`
57
+
58
+ Not Includes.
59
+ A string not in a substring.
60
+ A set does not contain an element.
61
+ A list does not contain an element.
62
+
63
+ ### In
64
+
65
+ > `readonly` **In**: `"in"` = `"in"`
66
+
67
+ In.
68
+ A element is in a set.
@@ -0,0 +1,5 @@
1
+ # Variable: EntitySchemaFactory
2
+
3
+ > `const` **EntitySchemaFactory**: `Factory`\<[`IEntitySchema`](../interfaces/IEntitySchema.md)\<`unknown`\>\>
4
+
5
+ Factory for creating entity schemas.
@@ -0,0 +1,109 @@
1
+ # Variable: EntitySchemaPropertyFormat
2
+
3
+ > `const` **EntitySchemaPropertyFormat**: `object`
4
+
5
+ Definition of the entity property format.
6
+
7
+ ## Type declaration
8
+
9
+ ### Uuid
10
+
11
+ > `readonly` **Uuid**: `"uuid"` = `"uuid"`
12
+
13
+ UUID.
14
+
15
+ ### Uri
16
+
17
+ > `readonly` **Uri**: `"uri"` = `"uri"`
18
+
19
+ URI.
20
+
21
+ ### Email
22
+
23
+ > `readonly` **Email**: `"email"` = `"email"`
24
+
25
+ email.
26
+
27
+ ### Int8
28
+
29
+ > `readonly` **Int8**: `"int8"` = `"int8"`
30
+
31
+ int8.
32
+
33
+ ### Uint8
34
+
35
+ > `readonly` **Uint8**: `"uint8"` = `"uint8"`
36
+
37
+ uint8.
38
+
39
+ ### Int16
40
+
41
+ > `readonly` **Int16**: `"int16"` = `"int16"`
42
+
43
+ int16.
44
+
45
+ ### Uint16
46
+
47
+ > `readonly` **Uint16**: `"uint16"` = `"uint16"`
48
+
49
+ uint16.
50
+
51
+ ### Int32
52
+
53
+ > `readonly` **Int32**: `"int32"` = `"int32"`
54
+
55
+ int32.
56
+
57
+ ### Uint32
58
+
59
+ > `readonly` **Uint32**: `"uint32"` = `"uint32"`
60
+
61
+ uint32.
62
+
63
+ ### Float
64
+
65
+ > `readonly` **Float**: `"float"` = `"float"`
66
+
67
+ float.
68
+
69
+ ### Double
70
+
71
+ > `readonly` **Double**: `"double"` = `"double"`
72
+
73
+ double.
74
+
75
+ ### Int64
76
+
77
+ > `readonly` **Int64**: `"int64"` = `"int64"`
78
+
79
+ int64.
80
+
81
+ ### Uint64
82
+
83
+ > `readonly` **Uint64**: `"uint64"` = `"uint64"`
84
+
85
+ uint64.
86
+
87
+ ### Date
88
+
89
+ > `readonly` **Date**: `"date"` = `"date"`
90
+
91
+ date.
92
+
93
+ ### Time
94
+
95
+ > `readonly` **Time**: `"time"` = `"time"`
96
+
97
+ time.
98
+
99
+ ### DateTime
100
+
101
+ > `readonly` **DateTime**: `"date-time"` = `"date-time"`
102
+
103
+ date-time.
104
+
105
+ ### Json
106
+
107
+ > `readonly` **Json**: `"json"` = `"json"`
108
+
109
+ JSON.
@@ -0,0 +1,43 @@
1
+ # Variable: EntitySchemaPropertyType
2
+
3
+ > `const` **EntitySchemaPropertyType**: `object`
4
+
5
+ Definition of the entity property types.
6
+
7
+ ## Type declaration
8
+
9
+ ### String
10
+
11
+ > `readonly` **String**: `"string"` = `"string"`
12
+
13
+ String.
14
+
15
+ ### Number
16
+
17
+ > `readonly` **Number**: `"number"` = `"number"`
18
+
19
+ Number.
20
+
21
+ ### Integer
22
+
23
+ > `readonly` **Integer**: `"integer"` = `"integer"`
24
+
25
+ Integer.
26
+
27
+ ### Boolean
28
+
29
+ > `readonly` **Boolean**: `"boolean"` = `"boolean"`
30
+
31
+ Boolean.
32
+
33
+ ### Array
34
+
35
+ > `readonly` **Array**: `"array"` = `"array"`
36
+
37
+ Array.
38
+
39
+ ### Object
40
+
41
+ > `readonly` **Object**: `"object"` = `"object"`
42
+
43
+ Object.
@@ -0,0 +1,19 @@
1
+ # Variable: LogicalOperator
2
+
3
+ > `const` **LogicalOperator**: `object`
4
+
5
+ The logical operators for condition combining.
6
+
7
+ ## Type declaration
8
+
9
+ ### And
10
+
11
+ > `readonly` **And**: `"and"` = `"and"`
12
+
13
+ Logical operator AND.
14
+
15
+ ### Or
16
+
17
+ > `readonly` **Or**: `"or"` = `"or"`
18
+
19
+ Logical operator OR.
@@ -0,0 +1,19 @@
1
+ # Variable: SortDirection
2
+
3
+ > `const` **SortDirection**: `object`
4
+
5
+ The sort directions.
6
+
7
+ ## Type declaration
8
+
9
+ ### Ascending
10
+
11
+ > `readonly` **Ascending**: `"asc"` = `"asc"`
12
+
13
+ Ascending.
14
+
15
+ ### Descending
16
+
17
+ > `readonly` **Descending**: `"desc"` = `"desc"`
18
+
19
+ Descending.