@twin.org/entity-storage-models 0.0.1-next.9 → 0.0.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.
@@ -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 sortProperties The optional sort order.
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>, sortProperties?: {
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 sort property array as JSON serialization of property,direction.
15
+ * The order property for the results.
15
16
  */
16
- sortProperties?: string;
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
  */
@@ -9,7 +9,7 @@ export interface IEntityStorageListResponse {
9
9
  /**
10
10
  * The entities from the query.
11
11
  */
12
- entities?: unknown[];
12
+ entities: unknown[];
13
13
  /**
14
14
  * The cursor for the next page.
15
15
  */
package/docs/changelog.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # @twin.org/entity-storage-models - Changelog
2
2
 
3
- ## v0.0.1-next.9
3
+ ## 0.0.1 (2025-07-04)
4
+
5
+
6
+ ### Features
7
+
8
+ * add production release automation ([1eb4c8e](https://github.com/twinfoundation/entity-storage/commit/1eb4c8ee3eb099defdfc2d063ae44935276dcae8))
9
+ * release to production ([a309051](https://github.com/twinfoundation/entity-storage/commit/a3090519adebf7943232b4df12e4c6bd5afe7eed))
10
+ * update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
11
+ * use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * query params force coercion ([dd6aa87](https://github.com/twinfoundation/entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
17
+
18
+ ## [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)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * query params force coercion ([dd6aa87](https://github.com/twinfoundation/entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
24
+
25
+ ## [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)
26
+
27
+
28
+ ### Features
29
+
30
+ * update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
31
+
32
+ ## [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)
33
+
34
+
35
+ ### Features
36
+
37
+ * use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
38
+
39
+ ## [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)
40
+
41
+
42
+ ### Miscellaneous Chores
43
+
44
+ * **entity-storage-models:** Synchronize repo versions
45
+
46
+ ## [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)
47
+
48
+
49
+ ### Miscellaneous Chores
50
+
51
+ * **entity-storage-models:** Synchronize repo versions
52
+
53
+ ## v0.0.1-next.26
4
54
 
5
55
  - Initial Release
@@ -8,27 +8,35 @@ Interface describing an entity storage component.
8
8
 
9
9
  ## Type Parameters
10
10
 
11
- **T** = `unknown`
11
+ ### T
12
+
13
+ `T` = `unknown`
12
14
 
13
15
  ## Methods
14
16
 
15
17
  ### set()
16
18
 
17
- > **set**(`entity`, `userIdentity`?, `nodeIdentity`?): `Promise`\<`void`\>
19
+ > **set**(`entity`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`void`\>
18
20
 
19
21
  Set an entity.
20
22
 
21
23
  #### Parameters
22
24
 
23
- **entity**: `T`
25
+ ##### entity
26
+
27
+ `T`
24
28
 
25
29
  The entity to set.
26
30
 
27
- **userIdentity?**: `string`
31
+ ##### userIdentity?
32
+
33
+ `string`
28
34
 
29
35
  The user identity to use with storage operations.
30
36
 
31
- **nodeIdentity?**: `string`
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`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`undefined` \| `T`\>
53
+ > **get**(`id`, `secondaryIndex?`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`undefined` \| `T`\>
46
54
 
47
55
  Get an entity.
48
56
 
49
57
  #### Parameters
50
58
 
51
- **id**: `string`
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
- **secondaryIndex?**: keyof `T`
65
+ ##### secondaryIndex?
66
+
67
+ keyof `T`
56
68
 
57
69
  Get the item using a secondary index.
58
70
 
59
- **userIdentity?**: `string`
71
+ ##### userIdentity?
72
+
73
+ `string`
60
74
 
61
75
  The user identity to use with storage operations.
62
76
 
63
- **nodeIdentity?**: `string`
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`?, `nodeIdentity`?): `Promise`\<`void`\>
93
+ > **remove**(`id`, `userIdentity?`, `nodeIdentity?`): `Promise`\<`void`\>
78
94
 
79
95
  Remove the entity.
80
96
 
81
97
  #### Parameters
82
98
 
83
- **id**: `string`
99
+ ##### id
100
+
101
+ `string`
84
102
 
85
103
  The id of the entity to remove.
86
104
 
87
- **userIdentity?**: `string`
105
+ ##### userIdentity?
106
+
107
+ `string`
88
108
 
89
109
  The user identity to use with storage operations.
90
110
 
91
- **nodeIdentity?**: `string`
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`?, `sortProperties`?, `properties`?, `cursor`?, `pageSize`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`object`\>
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
- **conditions?**: `EntityCondition`\<`T`\>
133
+ ##### conditions?
134
+
135
+ `EntityCondition`\<`T`\>
112
136
 
113
137
  The conditions to match for the entities.
114
138
 
115
- **sortProperties?**: `object`[]
139
+ ##### orderBy?
140
+
141
+ keyof `T`
142
+
143
+ The order for the results.
144
+
145
+ ##### orderByDirection?
116
146
 
117
- The optional sort order.
147
+ `SortDirection`
118
148
 
119
- **properties?**: keyof `T`[]
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
- **cursor?**: `string`
157
+ ##### cursor?
158
+
159
+ `string`
124
160
 
125
161
  The cursor to request the next page of entities.
126
162
 
127
- **pageSize?**: `number`
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
- **userIdentity?**: `string`
169
+ ##### userIdentity?
170
+
171
+ `string`
132
172
 
133
173
  The user identity to use with storage operations.
134
174
 
135
- **nodeIdentity?**: `string`
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`\<`object`\>
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
- **T** = `unknown`
11
+ ### T
12
+
13
+ `T` = `unknown`
12
14
 
13
15
  ## Methods
14
16
 
15
17
  ### getSchema()
16
18
 
17
- > **getSchema**(): `IEntitySchema`\<`unknown`\>
19
+ > **getSchema**(): `IEntitySchema`
18
20
 
19
21
  Get the schema for the entities.
20
22
 
21
23
  #### Returns
22
24
 
23
- `IEntitySchema`\<`unknown`\>
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`?): `Promise`\<`void`\>
33
+ > **set**(`entity`, `conditions?`): `Promise`\<`void`\>
32
34
 
33
35
  Set an entity.
34
36
 
35
37
  #### Parameters
36
38
 
37
- **entity**: `T`
39
+ ##### entity
40
+
41
+ `T`
38
42
 
39
43
  The entity to set.
40
44
 
41
- **conditions?**: `object`[]
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`?, `conditions`?): `Promise`\<`undefined` \| `T`\>
61
+ > **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`undefined` \| `T`\>
56
62
 
57
63
  Get an entity.
58
64
 
59
65
  #### Parameters
60
66
 
61
- **id**: `string`
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
- **secondaryIndex?**: keyof `T`
73
+ ##### secondaryIndex?
74
+
75
+ keyof `T`
66
76
 
67
77
  Get the item using a secondary index.
68
78
 
69
- **conditions?**: `object`[]
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`?): `Promise`\<`void`\>
95
+ > **remove**(`id`, `conditions?`): `Promise`\<`void`\>
84
96
 
85
97
  Remove the entity.
86
98
 
87
99
  #### Parameters
88
100
 
89
- **id**: `string`
101
+ ##### id
102
+
103
+ `string`
90
104
 
91
105
  The id of the entity to remove.
92
106
 
93
- **conditions?**: `object`[]
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`?, `sortProperties`?, `properties`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
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
- **conditions?**: `EntityCondition`\<`T`\>
129
+ ##### conditions?
130
+
131
+ `EntityCondition`\<`T`\>
114
132
 
115
133
  The conditions to match for the entities.
116
134
 
117
- **sortProperties?**: `object`[]
135
+ ##### sortProperties?
136
+
137
+ `object`[]
118
138
 
119
139
  The optional sort order.
120
140
 
121
- **properties?**: keyof `T`[]
141
+ ##### properties?
142
+
143
+ keyof `T`[]
122
144
 
123
145
  The optional properties to return, defaults to all.
124
146
 
125
- **cursor?**: `string`
147
+ ##### cursor?
148
+
149
+ `string`
126
150
 
127
151
  The cursor to request the next page of entities.
128
152
 
129
- **pageSize?**: `number`
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`\<`object`\>
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
- #### sortProperties?
19
+ #### orderBy?
20
20
 
21
- > `optional` **sortProperties**: `string`
21
+ > `optional` **orderBy**: `string`
22
22
 
23
- The sort property array as JSON serialization of property,direction.
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
 
@@ -10,9 +10,9 @@ Response to getting the list of entries from a query.
10
10
 
11
11
  The list of entries from the query.
12
12
 
13
- #### entities?
13
+ #### entities
14
14
 
15
- > `optional` **entities**: `unknown`[]
15
+ > **entities**: `unknown`[]
16
16
 
17
17
  The entities from the query.
18
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity-storage-models",
3
- "version": "0.0.1-next.9",
3
+ "version": "0.0.1",
4
4
  "description": "Models which define the structure of the entity storage contracts and connectors",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,20 +14,20 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "next",
18
- "@twin.org/entity": "next",
19
- "@twin.org/nameof": "next"
17
+ "@twin.org/core": "^0.0.1",
18
+ "@twin.org/entity": "^0.0.1",
19
+ "@twin.org/nameof": "^0.0.1"
20
20
  },
21
21
  "main": "./dist/cjs/index.cjs",
22
22
  "module": "./dist/esm/index.mjs",
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",