@twin.org/entity-storage-service 0.0.1-next.5

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.
@@ -0,0 +1,210 @@
1
+ # Class: EntityStorageService\<T\>
2
+
3
+ Class for performing entity service operations.
4
+
5
+ ## Type Parameters
6
+
7
+ • **T** *extends* `object` = `any`
8
+
9
+ ## Implements
10
+
11
+ - `IEntityStorageComponent`\<`T`\>
12
+
13
+ ## Constructors
14
+
15
+ ### new EntityStorageService()
16
+
17
+ > **new EntityStorageService**\<`T`\>(`options`): [`EntityStorageService`](EntityStorageService.md)\<`T`\>
18
+
19
+ Create a new instance of EntityStorageService.
20
+
21
+ #### Parameters
22
+
23
+ • **options**
24
+
25
+ The dependencies for the entity storage service.
26
+
27
+ • **options.entityStorageType**: `string`
28
+
29
+ The entity storage type.
30
+
31
+ • **options.config?**: [`IEntityStorageConfig`](../interfaces/IEntityStorageConfig.md)
32
+
33
+ The configuration for the service.
34
+
35
+ #### Returns
36
+
37
+ [`EntityStorageService`](EntityStorageService.md)\<`T`\>
38
+
39
+ ## Properties
40
+
41
+ ### CLASS\_NAME
42
+
43
+ > `readonly` **CLASS\_NAME**: `string`
44
+
45
+ Runtime name for the class.
46
+
47
+ #### Implementation of
48
+
49
+ `IEntityStorageComponent.CLASS_NAME`
50
+
51
+ ## Methods
52
+
53
+ ### set()
54
+
55
+ > **set**(`entity`, `userIdentity`?, `nodeIdentity`?): `Promise`\<`void`\>
56
+
57
+ Set an entity.
58
+
59
+ #### Parameters
60
+
61
+ • **entity**: `T`
62
+
63
+ The entity to set.
64
+
65
+ • **userIdentity?**: `string`
66
+
67
+ The user identity to use with storage operations.
68
+
69
+ • **nodeIdentity?**: `string`
70
+
71
+ The node identity to use with storage operations.
72
+
73
+ #### Returns
74
+
75
+ `Promise`\<`void`\>
76
+
77
+ The id of the entity.
78
+
79
+ #### Implementation of
80
+
81
+ `IEntityStorageComponent.set`
82
+
83
+ ***
84
+
85
+ ### get()
86
+
87
+ > **get**(`id`, `secondaryIndex`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`undefined` \| `T`\>
88
+
89
+ Get an entity.
90
+
91
+ #### Parameters
92
+
93
+ • **id**: `string`
94
+
95
+ The id of the entity to get, or the index value if secondaryIndex is set.
96
+
97
+ • **secondaryIndex?**: keyof `T`
98
+
99
+ Get the item using a secondary index.
100
+
101
+ • **userIdentity?**: `string`
102
+
103
+ The user identity to use with storage operations.
104
+
105
+ • **nodeIdentity?**: `string`
106
+
107
+ The node identity to use with storage operations.
108
+
109
+ #### Returns
110
+
111
+ `Promise`\<`undefined` \| `T`\>
112
+
113
+ The object if it can be found or undefined.
114
+
115
+ #### Implementation of
116
+
117
+ `IEntityStorageComponent.get`
118
+
119
+ ***
120
+
121
+ ### remove()
122
+
123
+ > **remove**(`id`, `userIdentity`?, `nodeIdentity`?): `Promise`\<`void`\>
124
+
125
+ Remove the entity.
126
+
127
+ #### Parameters
128
+
129
+ • **id**: `string`
130
+
131
+ The id of the entity to remove.
132
+
133
+ • **userIdentity?**: `string`
134
+
135
+ The user identity to use with storage operations.
136
+
137
+ • **nodeIdentity?**: `string`
138
+
139
+ The node identity to use with storage operations.
140
+
141
+ #### Returns
142
+
143
+ `Promise`\<`void`\>
144
+
145
+ Nothing.
146
+
147
+ #### Implementation of
148
+
149
+ `IEntityStorageComponent.remove`
150
+
151
+ ***
152
+
153
+ ### query()
154
+
155
+ > **query**(`conditions`?, `sortProperties`?, `properties`?, `cursor`?, `pageSize`?, `userIdentity`?, `nodeIdentity`?): `Promise`\<`object`\>
156
+
157
+ Query all the entities which match the conditions.
158
+
159
+ #### Parameters
160
+
161
+ • **conditions?**: `EntityCondition`\<`T`\>
162
+
163
+ The conditions to match for the entities.
164
+
165
+ • **sortProperties?**: `object`[]
166
+
167
+ The optional sort order.
168
+
169
+ • **properties?**: keyof `T`[]
170
+
171
+ The optional properties to return, defaults to all.
172
+
173
+ • **cursor?**: `string`
174
+
175
+ The cursor to request the next page of entities.
176
+
177
+ • **pageSize?**: `number`
178
+
179
+ The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
180
+
181
+ • **userIdentity?**: `string`
182
+
183
+ The user identity to use with storage operations.
184
+
185
+ • **nodeIdentity?**: `string`
186
+
187
+ The node identity to use with storage operations.
188
+
189
+ #### Returns
190
+
191
+ `Promise`\<`object`\>
192
+
193
+ All the entities for the storage matching the conditions,
194
+ and a cursor which can be used to request more entities.
195
+
196
+ ##### entities
197
+
198
+ > **entities**: `Partial`\<`T`\>[]
199
+
200
+ The entities, which can be partial if a limited keys list was provided.
201
+
202
+ ##### cursor?
203
+
204
+ > `optional` **cursor**: `string`
205
+
206
+ An optional cursor, when defined can be used to call find to get more entities.
207
+
208
+ #### Implementation of
209
+
210
+ `IEntityStorageComponent.query`
@@ -0,0 +1,25 @@
1
+ # Function: entityStorageGet()
2
+
3
+ > **entityStorageGet**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`IEntityStorageGetResponse`\>
4
+
5
+ Get the entry from entity storage.
6
+
7
+ ## Parameters
8
+
9
+ • **httpRequestContext**: `IHttpRequestContext`
10
+
11
+ The request context for the API.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes.
16
+
17
+ • **request**: `IEntityStorageGetRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`IEntityStorageGetResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: entityStorageList()
2
+
3
+ > **entityStorageList**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`IEntityStorageListResponse`\>
4
+
5
+ Query the entries from entity storage.
6
+
7
+ ## Parameters
8
+
9
+ • **httpRequestContext**: `IHttpRequestContext`
10
+
11
+ The request context for the API.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes.
16
+
17
+ • **request**: `IEntityStorageListRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`IEntityStorageListResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: entityStorageRemove()
2
+
3
+ > **entityStorageRemove**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ Remove the entry from entity storage.
6
+
7
+ ## Parameters
8
+
9
+ • **httpRequestContext**: `IHttpRequestContext`
10
+
11
+ The request context for the API.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes.
16
+
17
+ • **request**: `IEntityStorageRemoveRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`INoContentResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: entityStorageSet()
2
+
3
+ > **entityStorageSet**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ Set the entry in entity storage.
6
+
7
+ ## Parameters
8
+
9
+ • **httpRequestContext**: `IHttpRequestContext`
10
+
11
+ The request context for the API.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes.
16
+
17
+ • **request**: `IEntityStorageSetRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`INoContentResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,37 @@
1
+ # Function: generateRestRoutesEntityStorage()
2
+
3
+ > **generateRestRoutesEntityStorage**(`baseRouteName`, `componentName`, `options`?): `IRestRoute`[]
4
+
5
+ The REST routes for entity storage.
6
+
7
+ ## Parameters
8
+
9
+ • **baseRouteName**: `string`
10
+
11
+ Prefix to prepend to the paths.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes stored in the ComponentFactory.
16
+
17
+ • **options?**
18
+
19
+ Additional options for the routes.
20
+
21
+ • **options.typeName?**: `string`
22
+
23
+ Optional type name to use in the routes, defaults to Entity Storage.
24
+
25
+ • **options.tagName?**: `string`
26
+
27
+ Optional name to use in OpenAPI spec for tag.
28
+
29
+ • **options.examples?**: [`IEntityStorageRoutesExamples`](../interfaces/IEntityStorageRoutesExamples.md)
30
+
31
+ Optional examples to use in the routes.
32
+
33
+ ## Returns
34
+
35
+ `IRestRoute`[]
36
+
37
+ The generated routes.
@@ -0,0 +1,23 @@
1
+ # @twin.org/entity-storage-service
2
+
3
+ ## Classes
4
+
5
+ - [EntityStorageService](classes/EntityStorageService.md)
6
+
7
+ ## Interfaces
8
+
9
+ - [IEntityStorageConfig](interfaces/IEntityStorageConfig.md)
10
+ - [IEntityStorageRoutesExamples](interfaces/IEntityStorageRoutesExamples.md)
11
+
12
+ ## Variables
13
+
14
+ - [tagsEntityStorage](variables/tagsEntityStorage.md)
15
+ - [restEntryPoints](variables/restEntryPoints.md)
16
+
17
+ ## Functions
18
+
19
+ - [generateRestRoutesEntityStorage](functions/generateRestRoutesEntityStorage.md)
20
+ - [entityStorageSet](functions/entityStorageSet.md)
21
+ - [entityStorageGet](functions/entityStorageGet.md)
22
+ - [entityStorageRemove](functions/entityStorageRemove.md)
23
+ - [entityStorageList](functions/entityStorageList.md)
@@ -0,0 +1,19 @@
1
+ # Interface: IEntityStorageConfig
2
+
3
+ Configuration for the entity storage service.
4
+
5
+ ## Properties
6
+
7
+ ### includeNodeIdentity?
8
+
9
+ > `optional` **includeNodeIdentity**: `boolean`
10
+
11
+ Include the node identity when performing storage operations, defaults to true.
12
+
13
+ ***
14
+
15
+ ### includeUserIdentity?
16
+
17
+ > `optional` **includeUserIdentity**: `boolean`
18
+
19
+ Include the user identity when performing storage operations, defaults to true.
@@ -0,0 +1,59 @@
1
+ # Interface: IEntityStorageRoutesExamples
2
+
3
+ Examples for the entity storage routes.
4
+
5
+ ## Properties
6
+
7
+ ### set?
8
+
9
+ > `optional` **set**: `object`
10
+
11
+ Examples for the set route.
12
+
13
+ #### requestExamples
14
+
15
+ > **requestExamples**: `IRestRouteRequestExample`\<`IEntityStorageSetRequest`\>[]
16
+
17
+ ***
18
+
19
+ ### get?
20
+
21
+ > `optional` **get**: `object`
22
+
23
+ Examples for the get route.
24
+
25
+ #### requestExamples
26
+
27
+ > **requestExamples**: `IRestRouteRequestExample`\<`IEntityStorageGetRequest`\>[]
28
+
29
+ #### responseExamples
30
+
31
+ > **responseExamples**: `IRestRouteResponseExample`\<`IEntityStorageGetResponse`\>[]
32
+
33
+ ***
34
+
35
+ ### remove?
36
+
37
+ > `optional` **remove**: `object`
38
+
39
+ Examples for the remove route.
40
+
41
+ #### requestExamples
42
+
43
+ > **requestExamples**: `IRestRouteRequestExample`\<`IEntityStorageRemoveRequest`\>[]
44
+
45
+ ***
46
+
47
+ ### list?
48
+
49
+ > `optional` **list**: `object`
50
+
51
+ Examples for the list route.
52
+
53
+ #### requestExamples
54
+
55
+ > **requestExamples**: `IRestRouteRequestExample`\<`IEntityStorageListRequest`\>[]
56
+
57
+ #### responseExamples
58
+
59
+ > **responseExamples**: `IRestRouteResponseExample`\<`IEntityStorageListResponse`\>[]
@@ -0,0 +1,7 @@
1
+ # Variable: restEntryPoints
2
+
3
+ > `const` **restEntryPoints**: `IRestRouteEntryPoint`[]
4
+
5
+ These are dummy entry points for the entity storage service.
6
+ In reality your application would create its own entry points based on the
7
+ entity storage schema objects it wants to store, using a custom defaultBaseRoute.
@@ -0,0 +1,5 @@
1
+ # Variable: tagsEntityStorage
2
+
3
+ > `const` **tagsEntityStorage**: `ITag`[]
4
+
5
+ The tag to associate with the routes.
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": {}
3
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@twin.org/entity-storage-service",
3
+ "version": "0.0.1-next.5",
4
+ "description": "Entity Storage contract implementation and REST endpoint definitions",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/entity-storage.git",
8
+ "directory": "packages/entity-storage-service"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "dependencies": {
17
+ "@twin.org/api-models": "next",
18
+ "@twin.org/core": "next",
19
+ "@twin.org/entity": "next",
20
+ "@twin.org/entity-storage-models": "0.0.1-next.5",
21
+ "@twin.org/nameof": "next",
22
+ "@twin.org/web": "next"
23
+ },
24
+ "main": "./dist/cjs/index.cjs",
25
+ "module": "./dist/esm/index.mjs",
26
+ "types": "./dist/types/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "require": "./dist/cjs/index.cjs",
30
+ "import": "./dist/esm/index.mjs",
31
+ "types": "./dist/types/index.d.ts"
32
+ },
33
+ "./locales": "./locales"
34
+ },
35
+ "files": [
36
+ "dist/cjs",
37
+ "dist/esm",
38
+ "dist/types",
39
+ "locales",
40
+ "docs"
41
+ ]
42
+ }