@twin.org/entity-storage-models 0.0.1-next.9 → 0.0.2-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.
- package/dist/types/models/IEntityStorageComponent.d.ts +3 -5
- package/dist/types/models/api/IEntityStorageListRequest.d.ts +8 -3
- package/dist/types/models/api/IEntityStorageListResponse.d.ts +1 -1
- package/docs/changelog.md +65 -1
- package/docs/reference/interfaces/IEntityStorageComponent.md +66 -36
- package/docs/reference/interfaces/IEntityStorageConnector.md +46 -32
- package/docs/reference/interfaces/IEntityStorageListRequest.md +10 -4
- package/docs/reference/interfaces/IEntityStorageListResponse.md +2 -2
- package/package.json +4 -4
@@ -32,7 +32,8 @@ export interface IEntityStorageComponent<T = unknown> extends IComponent {
|
|
32
32
|
/**
|
33
33
|
* Query all the entities which match the conditions.
|
34
34
|
* @param conditions The conditions to match for the entities.
|
35
|
-
* @param
|
35
|
+
* @param orderBy The order for the results.
|
36
|
+
* @param orderByDirection The direction for the order, defaults to ascending.
|
36
37
|
* @param properties The optional properties to return, defaults to all.
|
37
38
|
* @param cursor The cursor to request the next page of entities.
|
38
39
|
* @param pageSize The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
|
@@ -41,10 +42,7 @@ export interface IEntityStorageComponent<T = unknown> extends IComponent {
|
|
41
42
|
* @returns All the entities for the storage matching the conditions,
|
42
43
|
* and a cursor which can be used to request more entities.
|
43
44
|
*/
|
44
|
-
query(conditions?: EntityCondition<T>,
|
45
|
-
property: keyof T;
|
46
|
-
sortDirection: SortDirection;
|
47
|
-
}[], properties?: (keyof T)[], cursor?: string, pageSize?: number, userIdentity?: string, nodeIdentity?: string): Promise<{
|
45
|
+
query(conditions?: EntityCondition<T>, orderBy?: keyof T, orderByDirection?: SortDirection, properties?: (keyof T)[], cursor?: string, pageSize?: number, userIdentity?: string, nodeIdentity?: string): Promise<{
|
48
46
|
/**
|
49
47
|
* The entities, which can be partial if a limited keys list was provided.
|
50
48
|
*/
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { SortDirection } from "@twin.org/entity";
|
1
2
|
/**
|
2
3
|
* Query the entries from entity storage.
|
3
4
|
*/
|
@@ -11,9 +12,13 @@ export interface IEntityStorageListRequest {
|
|
11
12
|
*/
|
12
13
|
conditions?: string;
|
13
14
|
/**
|
14
|
-
* The
|
15
|
+
* The order property for the results.
|
15
16
|
*/
|
16
|
-
|
17
|
+
orderBy?: string;
|
18
|
+
/**
|
19
|
+
* The direction for the order, defaults to desc.
|
20
|
+
*/
|
21
|
+
orderByDirection?: SortDirection;
|
17
22
|
/**
|
18
23
|
* The properties to return in the response as a comma separated list, by default returns all properties.
|
19
24
|
*/
|
@@ -21,7 +26,7 @@ export interface IEntityStorageListRequest {
|
|
21
26
|
/**
|
22
27
|
* The number of entries to return per page.
|
23
28
|
*/
|
24
|
-
pageSize?: number;
|
29
|
+
pageSize?: number | string;
|
25
30
|
/**
|
26
31
|
* The cursor to get next chunk of data, returned in previous response.
|
27
32
|
*/
|
package/docs/changelog.md
CHANGED
@@ -1,5 +1,69 @@
|
|
1
1
|
# @twin.org/entity-storage-models - Changelog
|
2
2
|
|
3
|
-
##
|
3
|
+
## [0.0.2-next.1](https://github.com/twinfoundation/entity-storage/compare/entity-storage-models-v0.0.2-next.0...entity-storage-models-v0.0.2-next.1) (2025-07-17)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* add production release automation ([1eb4c8e](https://github.com/twinfoundation/entity-storage/commit/1eb4c8ee3eb099defdfc2d063ae44935276dcae8))
|
9
|
+
* update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
|
10
|
+
* use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* query params force coercion ([dd6aa87](https://github.com/twinfoundation/entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
|
16
|
+
|
17
|
+
## 0.0.1 (2025-07-04)
|
18
|
+
|
19
|
+
|
20
|
+
### Features
|
21
|
+
|
22
|
+
* add production release automation ([1eb4c8e](https://github.com/twinfoundation/entity-storage/commit/1eb4c8ee3eb099defdfc2d063ae44935276dcae8))
|
23
|
+
* release to production ([a309051](https://github.com/twinfoundation/entity-storage/commit/a3090519adebf7943232b4df12e4c6bd5afe7eed))
|
24
|
+
* update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
|
25
|
+
* use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
|
26
|
+
|
27
|
+
|
28
|
+
### Bug Fixes
|
29
|
+
|
30
|
+
* query params force coercion ([dd6aa87](https://github.com/twinfoundation/entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
|
31
|
+
|
32
|
+
## [0.0.1-next.31](https://github.com/twinfoundation/entity-storage/compare/entity-storage-models-v0.0.1-next.30...entity-storage-models-v0.0.1-next.31) (2025-06-20)
|
33
|
+
|
34
|
+
|
35
|
+
### Bug Fixes
|
36
|
+
|
37
|
+
* query params force coercion ([dd6aa87](https://github.com/twinfoundation/entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
|
38
|
+
|
39
|
+
## [0.0.1-next.30](https://github.com/twinfoundation/entity-storage/compare/entity-storage-models-v0.0.1-next.29...entity-storage-models-v0.0.1-next.30) (2025-06-12)
|
40
|
+
|
41
|
+
|
42
|
+
### Features
|
43
|
+
|
44
|
+
* update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
|
45
|
+
|
46
|
+
## [0.0.1-next.29](https://github.com/twinfoundation/entity-storage/compare/entity-storage-models-v0.0.1-next.28...entity-storage-models-v0.0.1-next.29) (2025-04-17)
|
47
|
+
|
48
|
+
|
49
|
+
### Features
|
50
|
+
|
51
|
+
* use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
|
52
|
+
|
53
|
+
## [0.0.1-next.28](https://github.com/twinfoundation/entity-storage/compare/entity-storage-models-v0.0.1-next.27...entity-storage-models-v0.0.1-next.28) (2025-04-09)
|
54
|
+
|
55
|
+
|
56
|
+
### Miscellaneous Chores
|
57
|
+
|
58
|
+
* **entity-storage-models:** Synchronize repo versions
|
59
|
+
|
60
|
+
## [0.0.1-next.27](https://github.com/twinfoundation/entity-storage/compare/entity-storage-models-v0.0.1-next.26...entity-storage-models-v0.0.1-next.27) (2025-03-28)
|
61
|
+
|
62
|
+
|
63
|
+
### Miscellaneous Chores
|
64
|
+
|
65
|
+
* **entity-storage-models:** Synchronize repo versions
|
66
|
+
|
67
|
+
## v0.0.1-next.26
|
4
68
|
|
5
69
|
- Initial Release
|
@@ -8,27 +8,35 @@ Interface describing an entity storage component.
|
|
8
8
|
|
9
9
|
## Type Parameters
|
10
10
|
|
11
|
-
|
11
|
+
### T
|
12
|
+
|
13
|
+
`T` = `unknown`
|
12
14
|
|
13
15
|
## Methods
|
14
16
|
|
15
17
|
### set()
|
16
18
|
|
17
|
-
> **set**(`entity`, `userIdentity
|
19
|
+
> **set**(`entity`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`void`\>
|
18
20
|
|
19
21
|
Set an entity.
|
20
22
|
|
21
23
|
#### Parameters
|
22
24
|
|
23
|
-
|
25
|
+
##### entity
|
26
|
+
|
27
|
+
`T`
|
24
28
|
|
25
29
|
The entity to set.
|
26
30
|
|
27
|
-
|
31
|
+
##### userIdentity?
|
32
|
+
|
33
|
+
`string`
|
28
34
|
|
29
35
|
The user identity to use with storage operations.
|
30
36
|
|
31
|
-
|
37
|
+
##### nodeIdentity?
|
38
|
+
|
39
|
+
`string`
|
32
40
|
|
33
41
|
The node identity to use with storage operations.
|
34
42
|
|
@@ -42,25 +50,33 @@ The id of the entity.
|
|
42
50
|
|
43
51
|
### get()
|
44
52
|
|
45
|
-
> **get**(`id`, `secondaryIndex
|
53
|
+
> **get**(`id`, `secondaryIndex?`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`undefined` \| `T`\>
|
46
54
|
|
47
55
|
Get an entity.
|
48
56
|
|
49
57
|
#### Parameters
|
50
58
|
|
51
|
-
|
59
|
+
##### id
|
60
|
+
|
61
|
+
`string`
|
52
62
|
|
53
63
|
The id of the entity to get, or the index value if secondaryIndex is set.
|
54
64
|
|
55
|
-
|
65
|
+
##### secondaryIndex?
|
66
|
+
|
67
|
+
keyof `T`
|
56
68
|
|
57
69
|
Get the item using a secondary index.
|
58
70
|
|
59
|
-
|
71
|
+
##### userIdentity?
|
72
|
+
|
73
|
+
`string`
|
60
74
|
|
61
75
|
The user identity to use with storage operations.
|
62
76
|
|
63
|
-
|
77
|
+
##### nodeIdentity?
|
78
|
+
|
79
|
+
`string`
|
64
80
|
|
65
81
|
The node identity to use with storage operations.
|
66
82
|
|
@@ -74,21 +90,27 @@ The object if it can be found or undefined.
|
|
74
90
|
|
75
91
|
### remove()
|
76
92
|
|
77
|
-
> **remove**(`id`, `userIdentity
|
93
|
+
> **remove**(`id`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`void`\>
|
78
94
|
|
79
95
|
Remove the entity.
|
80
96
|
|
81
97
|
#### Parameters
|
82
98
|
|
83
|
-
|
99
|
+
##### id
|
100
|
+
|
101
|
+
`string`
|
84
102
|
|
85
103
|
The id of the entity to remove.
|
86
104
|
|
87
|
-
|
105
|
+
##### userIdentity?
|
106
|
+
|
107
|
+
`string`
|
88
108
|
|
89
109
|
The user identity to use with storage operations.
|
90
110
|
|
91
|
-
|
111
|
+
##### nodeIdentity?
|
112
|
+
|
113
|
+
`string`
|
92
114
|
|
93
115
|
The node identity to use with storage operations.
|
94
116
|
|
@@ -102,55 +124,63 @@ Nothing.
|
|
102
124
|
|
103
125
|
### query()
|
104
126
|
|
105
|
-
> **query**(`conditions
|
127
|
+
> **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `properties?`, `cursor?`, `pageSize?`, `userIdentity?`, `nodeIdentity?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
106
128
|
|
107
129
|
Query all the entities which match the conditions.
|
108
130
|
|
109
131
|
#### Parameters
|
110
132
|
|
111
|
-
|
133
|
+
##### conditions?
|
134
|
+
|
135
|
+
`EntityCondition`\<`T`\>
|
112
136
|
|
113
137
|
The conditions to match for the entities.
|
114
138
|
|
115
|
-
|
139
|
+
##### orderBy?
|
140
|
+
|
141
|
+
keyof `T`
|
142
|
+
|
143
|
+
The order for the results.
|
144
|
+
|
145
|
+
##### orderByDirection?
|
116
146
|
|
117
|
-
|
147
|
+
`SortDirection`
|
118
148
|
|
119
|
-
|
149
|
+
The direction for the order, defaults to ascending.
|
150
|
+
|
151
|
+
##### properties?
|
152
|
+
|
153
|
+
keyof `T`[]
|
120
154
|
|
121
155
|
The optional properties to return, defaults to all.
|
122
156
|
|
123
|
-
|
157
|
+
##### cursor?
|
158
|
+
|
159
|
+
`string`
|
124
160
|
|
125
161
|
The cursor to request the next page of entities.
|
126
162
|
|
127
|
-
|
163
|
+
##### pageSize?
|
164
|
+
|
165
|
+
`number`
|
128
166
|
|
129
167
|
The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
|
130
168
|
|
131
|
-
|
169
|
+
##### userIdentity?
|
170
|
+
|
171
|
+
`string`
|
132
172
|
|
133
173
|
The user identity to use with storage operations.
|
134
174
|
|
135
|
-
|
175
|
+
##### nodeIdentity?
|
176
|
+
|
177
|
+
`string`
|
136
178
|
|
137
179
|
The node identity to use with storage operations.
|
138
180
|
|
139
181
|
#### Returns
|
140
182
|
|
141
|
-
`Promise`\<`
|
183
|
+
`Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
142
184
|
|
143
185
|
All the entities for the storage matching the conditions,
|
144
186
|
and a cursor which can be used to request more entities.
|
145
|
-
|
146
|
-
##### entities
|
147
|
-
|
148
|
-
> **entities**: `Partial`\<`T`\>[]
|
149
|
-
|
150
|
-
The entities, which can be partial if a limited keys list was provided.
|
151
|
-
|
152
|
-
##### cursor?
|
153
|
-
|
154
|
-
> `optional` **cursor**: `string`
|
155
|
-
|
156
|
-
An optional cursor, when defined can be used to call find to get more entities.
|
@@ -8,19 +8,21 @@ Interface describing an entity storage connector.
|
|
8
8
|
|
9
9
|
## Type Parameters
|
10
10
|
|
11
|
-
|
11
|
+
### T
|
12
|
+
|
13
|
+
`T` = `unknown`
|
12
14
|
|
13
15
|
## Methods
|
14
16
|
|
15
17
|
### getSchema()
|
16
18
|
|
17
|
-
> **getSchema**(): `IEntitySchema
|
19
|
+
> **getSchema**(): `IEntitySchema`
|
18
20
|
|
19
21
|
Get the schema for the entities.
|
20
22
|
|
21
23
|
#### Returns
|
22
24
|
|
23
|
-
`IEntitySchema
|
25
|
+
`IEntitySchema`
|
24
26
|
|
25
27
|
The schema for the entities.
|
26
28
|
|
@@ -28,17 +30,21 @@ The schema for the entities.
|
|
28
30
|
|
29
31
|
### set()
|
30
32
|
|
31
|
-
> **set**(`entity`, `conditions
|
33
|
+
> **set**(`entity`, `conditions?`): `Promise`\<`void`\>
|
32
34
|
|
33
35
|
Set an entity.
|
34
36
|
|
35
37
|
#### Parameters
|
36
38
|
|
37
|
-
|
39
|
+
##### entity
|
40
|
+
|
41
|
+
`T`
|
38
42
|
|
39
43
|
The entity to set.
|
40
44
|
|
41
|
-
|
45
|
+
##### conditions?
|
46
|
+
|
47
|
+
`object`[]
|
42
48
|
|
43
49
|
The optional conditions to match for the entities.
|
44
50
|
|
@@ -52,21 +58,27 @@ The id of the entity.
|
|
52
58
|
|
53
59
|
### get()
|
54
60
|
|
55
|
-
> **get**(`id`, `secondaryIndex
|
61
|
+
> **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`undefined` \| `T`\>
|
56
62
|
|
57
63
|
Get an entity.
|
58
64
|
|
59
65
|
#### Parameters
|
60
66
|
|
61
|
-
|
67
|
+
##### id
|
68
|
+
|
69
|
+
`string`
|
62
70
|
|
63
71
|
The id of the entity to get, or the index value if secondaryIndex is set.
|
64
72
|
|
65
|
-
|
73
|
+
##### secondaryIndex?
|
74
|
+
|
75
|
+
keyof `T`
|
66
76
|
|
67
77
|
Get the item using a secondary index.
|
68
78
|
|
69
|
-
|
79
|
+
##### conditions?
|
80
|
+
|
81
|
+
`object`[]
|
70
82
|
|
71
83
|
The optional conditions to match for the entities.
|
72
84
|
|
@@ -80,17 +92,21 @@ The object if it can be found or undefined.
|
|
80
92
|
|
81
93
|
### remove()
|
82
94
|
|
83
|
-
> **remove**(`id`, `conditions
|
95
|
+
> **remove**(`id`, `conditions?`): `Promise`\<`void`\>
|
84
96
|
|
85
97
|
Remove the entity.
|
86
98
|
|
87
99
|
#### Parameters
|
88
100
|
|
89
|
-
|
101
|
+
##### id
|
102
|
+
|
103
|
+
`string`
|
90
104
|
|
91
105
|
The id of the entity to remove.
|
92
106
|
|
93
|
-
|
107
|
+
##### conditions?
|
108
|
+
|
109
|
+
`object`[]
|
94
110
|
|
95
111
|
The optional conditions to match for the entities.
|
96
112
|
|
@@ -104,47 +120,45 @@ Nothing.
|
|
104
120
|
|
105
121
|
### query()
|
106
122
|
|
107
|
-
> **query**(`conditions
|
123
|
+
> **query**(`conditions?`, `sortProperties?`, `properties?`, `cursor?`, `pageSize?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
108
124
|
|
109
125
|
Query all the entities which match the conditions.
|
110
126
|
|
111
127
|
#### Parameters
|
112
128
|
|
113
|
-
|
129
|
+
##### conditions?
|
130
|
+
|
131
|
+
`EntityCondition`\<`T`\>
|
114
132
|
|
115
133
|
The conditions to match for the entities.
|
116
134
|
|
117
|
-
|
135
|
+
##### sortProperties?
|
136
|
+
|
137
|
+
`object`[]
|
118
138
|
|
119
139
|
The optional sort order.
|
120
140
|
|
121
|
-
|
141
|
+
##### properties?
|
142
|
+
|
143
|
+
keyof `T`[]
|
122
144
|
|
123
145
|
The optional properties to return, defaults to all.
|
124
146
|
|
125
|
-
|
147
|
+
##### cursor?
|
148
|
+
|
149
|
+
`string`
|
126
150
|
|
127
151
|
The cursor to request the next page of entities.
|
128
152
|
|
129
|
-
|
153
|
+
##### pageSize?
|
154
|
+
|
155
|
+
`number`
|
130
156
|
|
131
157
|
The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
|
132
158
|
|
133
159
|
#### Returns
|
134
160
|
|
135
|
-
`Promise`\<`
|
161
|
+
`Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
136
162
|
|
137
163
|
All the entities for the storage matching the conditions,
|
138
164
|
and a cursor which can be used to request more entities.
|
139
|
-
|
140
|
-
##### entities
|
141
|
-
|
142
|
-
> **entities**: `Partial`\<`T`\>[]
|
143
|
-
|
144
|
-
The entities, which can be partial if a limited keys list was provided.
|
145
|
-
|
146
|
-
##### cursor?
|
147
|
-
|
148
|
-
> `optional` **cursor**: `string`
|
149
|
-
|
150
|
-
An optional cursor, when defined can be used to call find to get more entities.
|
@@ -16,11 +16,17 @@ The parameters from the query.
|
|
16
16
|
|
17
17
|
The condition for the query as JSON version of EntityCondition type.
|
18
18
|
|
19
|
-
####
|
19
|
+
#### orderBy?
|
20
20
|
|
21
|
-
> `optional` **
|
21
|
+
> `optional` **orderBy**: `string`
|
22
22
|
|
23
|
-
The
|
23
|
+
The order property for the results.
|
24
|
+
|
25
|
+
#### orderByDirection?
|
26
|
+
|
27
|
+
> `optional` **orderByDirection**: `SortDirection`
|
28
|
+
|
29
|
+
The direction for the order, defaults to desc.
|
24
30
|
|
25
31
|
#### properties?
|
26
32
|
|
@@ -30,7 +36,7 @@ The properties to return in the response as a comma separated list, by default r
|
|
30
36
|
|
31
37
|
#### pageSize?
|
32
38
|
|
33
|
-
> `optional` **pageSize**: `number`
|
39
|
+
> `optional` **pageSize**: `string` \| `number`
|
34
40
|
|
35
41
|
The number of entries to return per page.
|
36
42
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@twin.org/entity-storage-models",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.2-next.1",
|
4
4
|
"description": "Models which define the structure of the entity storage contracts and connectors",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -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",
|