@twin.org/entity 0.10.0 → 0.10.1-next.10
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/es/decorators/propertyDecorator.js +25 -0
- package/dist/es/decorators/propertyDecorator.js.map +1 -1
- package/dist/es/index.js +1 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IEntitySchemaProperty.js.map +1 -1
- package/dist/es/models/IEntitySchemaPropertyIndex.js +2 -0
- package/dist/es/models/IEntitySchemaPropertyIndex.js.map +1 -0
- package/dist/es/models/comparisonOperator.js +6 -1
- package/dist/es/models/comparisonOperator.js.map +1 -1
- package/dist/es/utils/entityConditions.js +122 -125
- package/dist/es/utils/entityConditions.js.map +1 -1
- package/dist/es/utils/entitySchemaDiffHelper.js +27 -1
- package/dist/es/utils/entitySchemaDiffHelper.js.map +1 -1
- package/dist/es/utils/entitySchemaHelper.js +65 -0
- package/dist/es/utils/entitySchemaHelper.js.map +1 -1
- package/dist/es/utils/entitySorter.js +2 -2
- package/dist/es/utils/entitySorter.js.map +1 -1
- package/dist/types/decorators/propertyDecorator.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/models/IEntitySchemaProperty.d.ts +7 -0
- package/dist/types/models/IEntitySchemaPropertyIndex.d.ts +18 -0
- package/dist/types/models/comparisonOperator.d.ts +6 -1
- package/dist/types/utils/entitySchemaDiffHelper.d.ts +1 -1
- package/dist/types/utils/entitySchemaHelper.d.ts +17 -1
- package/docs/changelog.md +263 -0
- package/docs/reference/classes/EntitySchemaDiffHelper.md +1 -1
- package/docs/reference/classes/EntitySchemaHelper.md +36 -0
- package/docs/reference/functions/property.md +8 -0
- package/docs/reference/index.md +1 -0
- package/docs/reference/interfaces/IEntitySchemaProperty.md +10 -0
- package/docs/reference/interfaces/IEntitySchemaPropertyIndex.md +27 -0
- package/docs/reference/variables/ComparisonOperator.md +8 -1
- package/locales/en.json +8 -0
- package/package.json +3 -3
|
@@ -154,6 +154,42 @@ The sort keys from the schema or undefined if there are none.
|
|
|
154
154
|
|
|
155
155
|
***
|
|
156
156
|
|
|
157
|
+
### getIndexGroups() {#getindexgroups}
|
|
158
|
+
|
|
159
|
+
> `static` **getIndexGroups**\<`T`\>(`entitySchema`): `object`
|
|
160
|
+
|
|
161
|
+
Get the composite index groups from the schema.
|
|
162
|
+
Each property can be part of multiple indexes through its `indexGroup` list, so a property
|
|
163
|
+
can appear in more than one group. The properties within a group are ordered by the `index`
|
|
164
|
+
of their index entry, and each is returned with the sort direction it declared for that group.
|
|
165
|
+
|
|
166
|
+
#### Type Parameters
|
|
167
|
+
|
|
168
|
+
##### T
|
|
169
|
+
|
|
170
|
+
`T`
|
|
171
|
+
|
|
172
|
+
#### Parameters
|
|
173
|
+
|
|
174
|
+
##### entitySchema
|
|
175
|
+
|
|
176
|
+
[`IEntitySchema`](../interfaces/IEntitySchema.md)\<`T`\>
|
|
177
|
+
|
|
178
|
+
The entity schema to find the index groups from.
|
|
179
|
+
|
|
180
|
+
#### Returns
|
|
181
|
+
|
|
182
|
+
`object`
|
|
183
|
+
|
|
184
|
+
The properties and their directions keyed by the group name, empty if there are no groups.
|
|
185
|
+
|
|
186
|
+
#### Throws
|
|
187
|
+
|
|
188
|
+
GeneralError if an index entry has an invalid direction or index, or if two properties
|
|
189
|
+
claim the same index within the same group, or if a group contains fewer than two properties.
|
|
190
|
+
|
|
191
|
+
***
|
|
192
|
+
|
|
157
193
|
### buildSortProperties() {#buildsortproperties}
|
|
158
194
|
|
|
159
195
|
> `static` **buildSortProperties**\<`T`\>(`entitySchema`, `overrideSortKeys?`): [`IEntitySort`](../interfaces/IEntitySort.md)\<`T`\>[] \| `undefined`
|
|
@@ -17,3 +17,11 @@ The options for the property.
|
|
|
17
17
|
`any`
|
|
18
18
|
|
|
19
19
|
The property decorator.
|
|
20
|
+
|
|
21
|
+
## Throws
|
|
22
|
+
|
|
23
|
+
GeneralError if an index group is declared on an object or array property.
|
|
24
|
+
|
|
25
|
+
## Throws
|
|
26
|
+
|
|
27
|
+
GeneralError if the same index group name is declared more than once for the property.
|
package/docs/reference/index.md
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
- [IEntitySchemaDiff](interfaces/IEntitySchemaDiff.md)
|
|
17
17
|
- [IEntitySchemaOptions](interfaces/IEntitySchemaOptions.md)
|
|
18
18
|
- [IEntitySchemaProperty](interfaces/IEntitySchemaProperty.md)
|
|
19
|
+
- [IEntitySchemaPropertyIndex](interfaces/IEntitySchemaPropertyIndex.md)
|
|
19
20
|
- [IEntitySort](interfaces/IEntitySort.md)
|
|
20
21
|
|
|
21
22
|
## Type Aliases
|
|
@@ -58,6 +58,16 @@ Is this a secondary index property.
|
|
|
58
58
|
|
|
59
59
|
***
|
|
60
60
|
|
|
61
|
+
### indexGroup? {#indexgroup}
|
|
62
|
+
|
|
63
|
+
> `optional` **indexGroup?**: [`IEntitySchemaPropertyIndex`](IEntitySchemaPropertyIndex.md)[]
|
|
64
|
+
|
|
65
|
+
The composite indexes this property is part of.
|
|
66
|
+
Connectors can use these to build a composite index for each group name,
|
|
67
|
+
combining all the properties which share that name, ordered by their index.
|
|
68
|
+
|
|
69
|
+
***
|
|
70
|
+
|
|
61
71
|
### isVersion? {#isversion}
|
|
62
72
|
|
|
63
73
|
> `optional` **isVersion?**: `boolean`
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Interface: IEntitySchemaPropertyIndex
|
|
2
|
+
|
|
3
|
+
Definition of a composite index that a property is part of.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### name {#name}
|
|
8
|
+
|
|
9
|
+
> **name**: `string`
|
|
10
|
+
|
|
11
|
+
The name of the composite index group.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### direction {#direction}
|
|
16
|
+
|
|
17
|
+
> **direction**: [`SortDirection`](../type-aliases/SortDirection.md)
|
|
18
|
+
|
|
19
|
+
The sort direction for the property within the index.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### index {#index}
|
|
24
|
+
|
|
25
|
+
> **index**: `number`
|
|
26
|
+
|
|
27
|
+
The position of the property within the index, ordered ascending.
|
|
@@ -47,7 +47,7 @@ Less Than Or Equal.
|
|
|
47
47
|
> `readonly` **Includes**: `"includes"` = `"includes"`
|
|
48
48
|
|
|
49
49
|
Includes.
|
|
50
|
-
A string in a substring.
|
|
50
|
+
A string in a substring, this is a scan and cannot use an index.
|
|
51
51
|
A set contains an element.
|
|
52
52
|
A list contains an element.
|
|
53
53
|
|
|
@@ -60,6 +60,13 @@ A string not in a substring.
|
|
|
60
60
|
A set does not contain an element.
|
|
61
61
|
A list does not contain an element.
|
|
62
62
|
|
|
63
|
+
### StartsWith {#startswith}
|
|
64
|
+
|
|
65
|
+
> `readonly` **StartsWith**: `"starts-with"` = `"starts-with"`
|
|
66
|
+
|
|
67
|
+
Starts With.
|
|
68
|
+
A string begins with a prefix, the anchored match can use an index.
|
|
69
|
+
|
|
63
70
|
### In {#in}
|
|
64
71
|
|
|
65
72
|
> `readonly` **In**: `"in"` = `"in"`
|
package/locales/en.json
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
"duplicateOldProperty": "The oldProperties array contains a duplicate property key \"{property}\"",
|
|
5
5
|
"duplicateNewProperty": "The newProperties array contains a duplicate property key \"{property}\""
|
|
6
6
|
},
|
|
7
|
+
"propertyDecorator": {
|
|
8
|
+
"indexGroupTypeNotSupported": "The property \"{property}\" of type \"{type}\" cannot be part of an index group",
|
|
9
|
+
"duplicateIndexGroup": "The property \"{property}\" declares the index group \"{group}\" more than once"
|
|
10
|
+
},
|
|
7
11
|
"entitySchemaHelper": {
|
|
8
12
|
"noIsPrimary": "Property \"entitySchema.properties\" must contain a value with isPrimary set",
|
|
9
13
|
"multipleIsPrimary": "Property \"entitySchema.properties\" contains more than one property with isPrimary set",
|
|
@@ -14,6 +18,10 @@
|
|
|
14
18
|
"maxLengthExceeded": "The entity property \"{property}\" has a length of {length} which exceeds the maximum length of {maxLength}",
|
|
15
19
|
"versionMustBeGreaterThanOrEqualZero": "Property \"entitySchema.version\" must be an integer >= 0, but got {version}",
|
|
16
20
|
"multipleVersionProperties": "The schema has more than one property with isVersion set, only one is allowed",
|
|
21
|
+
"invalidIndexGroupDirection": "The index group \"{group}\" on the property \"{property}\" has the direction \"{direction}\" which is not a valid sort direction",
|
|
22
|
+
"invalidIndexGroupIndex": "The index group \"{group}\" on the property \"{property}\" has the index {index} which must be an integer >= 0",
|
|
23
|
+
"duplicateIndexGroupIndex": "The index group \"{group}\" has more than one property using the index {index}, found again on the property \"{property}\"",
|
|
24
|
+
"indexGroupMustHaveAtLeastTwoProperties": "The index group \"{group}\" must contain at least two properties, but contains {count}",
|
|
17
25
|
"versionPropertyMustBeInteger": "The version property \"{property}\" has type \"{type}\" but must be of type integer"
|
|
18
26
|
}
|
|
19
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/entity",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1-next.10",
|
|
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": "
|
|
18
|
-
"@twin.org/nameof": "
|
|
17
|
+
"@twin.org/core": "0.10.1-next.10",
|
|
18
|
+
"@twin.org/nameof": "0.10.1-next.10",
|
|
19
19
|
"reflect-metadata": "0.2.2",
|
|
20
20
|
"tslib": "2.8.1"
|
|
21
21
|
},
|