@twin.org/entity-storage-models 0.0.1-next.8 → 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
  */
@@ -12,22 +12,34 @@ export interface IEntityStorageConnector<T = unknown> extends IComponent {
12
12
  /**
13
13
  * Set an entity.
14
14
  * @param entity The entity to set.
15
+ * @param conditions The optional conditions to match for the entities.
15
16
  * @returns The id of the entity.
16
17
  */
17
- set(entity: T): Promise<void>;
18
+ set(entity: T, conditions?: {
19
+ property: keyof T;
20
+ value: unknown;
21
+ }[]): Promise<void>;
18
22
  /**
19
23
  * Get an entity.
20
24
  * @param id The id of the entity to get, or the index value if secondaryIndex is set.
21
25
  * @param secondaryIndex Get the item using a secondary index.
26
+ * @param conditions The optional conditions to match for the entities.
22
27
  * @returns The object if it can be found or undefined.
23
28
  */
24
- get(id: string, secondaryIndex?: keyof T): Promise<T | undefined>;
29
+ get(id: string, secondaryIndex?: keyof T, conditions?: {
30
+ property: keyof T;
31
+ value: unknown;
32
+ }[]): Promise<T | undefined>;
25
33
  /**
26
34
  * Remove the entity.
27
35
  * @param id The id of the entity to remove.
36
+ * @param conditions The optional conditions to match for the entities.
28
37
  * @returns Nothing.
29
38
  */
30
- remove(id: string): Promise<void>;
39
+ remove(id: string, conditions?: {
40
+ property: keyof T;
41
+ value: unknown;
42
+ }[]): Promise<void>;
31
43
  /**
32
44
  * Query all the entities which match the conditions.
33
45
  * @param conditions The conditions to match for the entities.
@@ -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.8
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,16 +30,24 @@ The schema for the entities.
28
30
 
29
31
  ### set()
30
32
 
31
- > **set**(`entity`): `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
 
45
+ ##### conditions?
46
+
47
+ `object`[]
48
+
49
+ The optional conditions to match for the entities.
50
+
41
51
  #### Returns
42
52
 
43
53
  `Promise`\<`void`\>
@@ -48,20 +58,30 @@ The id of the entity.
48
58
 
49
59
  ### get()
50
60
 
51
- > **get**(`id`, `secondaryIndex`?): `Promise`\<`undefined` \| `T`\>
61
+ > **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`undefined` \| `T`\>
52
62
 
53
63
  Get an entity.
54
64
 
55
65
  #### Parameters
56
66
 
57
- **id**: `string`
67
+ ##### id
68
+
69
+ `string`
58
70
 
59
71
  The id of the entity to get, or the index value if secondaryIndex is set.
60
72
 
61
- **secondaryIndex?**: keyof `T`
73
+ ##### secondaryIndex?
74
+
75
+ keyof `T`
62
76
 
63
77
  Get the item using a secondary index.
64
78
 
79
+ ##### conditions?
80
+
81
+ `object`[]
82
+
83
+ The optional conditions to match for the entities.
84
+
65
85
  #### Returns
66
86
 
67
87
  `Promise`\<`undefined` \| `T`\>
@@ -72,16 +92,24 @@ The object if it can be found or undefined.
72
92
 
73
93
  ### remove()
74
94
 
75
- > **remove**(`id`): `Promise`\<`void`\>
95
+ > **remove**(`id`, `conditions?`): `Promise`\<`void`\>
76
96
 
77
97
  Remove the entity.
78
98
 
79
99
  #### Parameters
80
100
 
81
- **id**: `string`
101
+ ##### id
102
+
103
+ `string`
82
104
 
83
105
  The id of the entity to remove.
84
106
 
107
+ ##### conditions?
108
+
109
+ `object`[]
110
+
111
+ The optional conditions to match for the entities.
112
+
85
113
  #### Returns
86
114
 
87
115
  `Promise`\<`void`\>
@@ -92,47 +120,45 @@ Nothing.
92
120
 
93
121
  ### query()
94
122
 
95
- > **query**(`conditions`?, `sortProperties`?, `properties`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
123
+ > **query**(`conditions?`, `sortProperties?`, `properties?`, `cursor?`, `pageSize?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
96
124
 
97
125
  Query all the entities which match the conditions.
98
126
 
99
127
  #### Parameters
100
128
 
101
- **conditions?**: `EntityCondition`\<`T`\>
129
+ ##### conditions?
130
+
131
+ `EntityCondition`\<`T`\>
102
132
 
103
133
  The conditions to match for the entities.
104
134
 
105
- **sortProperties?**: `object`[]
135
+ ##### sortProperties?
136
+
137
+ `object`[]
106
138
 
107
139
  The optional sort order.
108
140
 
109
- **properties?**: keyof `T`[]
141
+ ##### properties?
142
+
143
+ keyof `T`[]
110
144
 
111
145
  The optional properties to return, defaults to all.
112
146
 
113
- **cursor?**: `string`
147
+ ##### cursor?
148
+
149
+ `string`
114
150
 
115
151
  The cursor to request the next page of entities.
116
152
 
117
- **pageSize?**: `number`
153
+ ##### pageSize?
154
+
155
+ `number`
118
156
 
119
157
  The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
120
158
 
121
159
  #### Returns
122
160
 
123
- `Promise`\<`object`\>
161
+ `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
124
162
 
125
163
  All the entities for the storage matching the conditions,
126
164
  and a cursor which can be used to request more entities.
127
-
128
- ##### entities
129
-
130
- > **entities**: `Partial`\<`T`\>[]
131
-
132
- The entities, which can be partial if a limited keys list was provided.
133
-
134
- ##### cursor?
135
-
136
- > `optional` **cursor**: `string`
137
-
138
- 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.8",
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",