@twin.org/entity-storage-service 0.0.3-next.6 → 0.0.3-next.7
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/README.md +2 -2
- package/docs/changelog.md +17 -1
- package/docs/examples.md +77 -1
- package/docs/open-api/spec.json +0 -3
- package/docs/reference/classes/EntityStorageService.md +6 -6
- package/docs/reference/interfaces/IEntityStorageRoutesExamples.md +4 -4
- package/docs/reference/interfaces/IEntityStorageServiceConstructorOptions.md +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Entity Storage Service
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package defines the service-facing contracts and REST endpoint definitions used to expose storage behaviour consistently. It is designed to work with the wider storage ecosystem so applications can keep behaviour consistent across connectors and environments.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.3-next.7](https://github.com/twinfoundation/entity-storage/compare/entity-storage-service-v0.0.3-next.6...entity-storage-service-v0.0.3-next.7) (2026-03-13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **entity-storage-service:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/entity-storage-models bumped from 0.0.3-next.6 to 0.0.3-next.7
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @twin.org/entity-storage-connector-memory bumped from 0.0.3-next.6 to 0.0.3-next.7
|
|
2
18
|
|
|
3
19
|
## [0.0.3-next.6](https://github.com/twinfoundation/entity-storage/compare/entity-storage-service-v0.0.3-next.5...entity-storage-service-v0.0.3-next.6) (2026-01-21)
|
|
4
20
|
|
package/docs/examples.md
CHANGED
|
@@ -1 +1,77 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Entity Storage Service Examples
|
|
2
|
+
|
|
3
|
+
Use these snippets to wire a registered connector into the service layer and to expose matching REST routes.
|
|
4
|
+
|
|
5
|
+
## EntityStorageService
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import {
|
|
9
|
+
EntityStorageService,
|
|
10
|
+
generateRestRoutesEntityStorage
|
|
11
|
+
} from '@twin.org/entity-storage-service';
|
|
12
|
+
import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
|
|
13
|
+
import { MemoryEntityStorageConnector } from '@twin.org/entity-storage-connector-memory';
|
|
14
|
+
import {
|
|
15
|
+
ComparisonOperator,
|
|
16
|
+
LogicalOperator,
|
|
17
|
+
SortDirection,
|
|
18
|
+
type EntityCondition
|
|
19
|
+
} from '@twin.org/entity';
|
|
20
|
+
|
|
21
|
+
interface Profile {
|
|
22
|
+
id: string;
|
|
23
|
+
email: string;
|
|
24
|
+
status: 'active' | 'inactive';
|
|
25
|
+
createdAt: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
EntityStorageConnectorFactory.register(
|
|
29
|
+
'profile-storage',
|
|
30
|
+
() =>
|
|
31
|
+
new MemoryEntityStorageConnector<Profile>({
|
|
32
|
+
entitySchema: 'Profile'
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const service = new EntityStorageService<Profile>({
|
|
37
|
+
entityStorageType: 'profile-storage'
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const className = service.className();
|
|
41
|
+
|
|
42
|
+
await service.set({
|
|
43
|
+
id: 'profile-1',
|
|
44
|
+
email: 'ada@example.com',
|
|
45
|
+
status: 'active',
|
|
46
|
+
createdAt: '2026-03-09T10:30:00.000Z'
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const byPrimaryKey = await service.get('profile-1');
|
|
50
|
+
const bySecondaryIndex = await service.get('ada@example.com', 'email');
|
|
51
|
+
|
|
52
|
+
const activeCondition: EntityCondition<Profile> = {
|
|
53
|
+
logicalOperator: LogicalOperator.And,
|
|
54
|
+
conditions: [
|
|
55
|
+
{
|
|
56
|
+
property: 'status',
|
|
57
|
+
comparison: ComparisonOperator.Equals,
|
|
58
|
+
value: 'active'
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const result = await service.query(
|
|
64
|
+
activeCondition,
|
|
65
|
+
'createdAt',
|
|
66
|
+
SortDirection.Descending,
|
|
67
|
+
['id', 'email', 'status'],
|
|
68
|
+
undefined,
|
|
69
|
+
25
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
await service.remove('profile-1');
|
|
73
|
+
|
|
74
|
+
const routes = generateRestRoutesEntityStorage('/profiles', 'profileStorageComponent', {
|
|
75
|
+
typeName: 'Profile'
|
|
76
|
+
});
|
|
77
|
+
```
|
package/docs/open-api/spec.json
CHANGED
|
@@ -529,7 +529,6 @@
|
|
|
529
529
|
"required": [
|
|
530
530
|
"entities"
|
|
531
531
|
],
|
|
532
|
-
"additionalProperties": false,
|
|
533
532
|
"description": "The list of entries from the query."
|
|
534
533
|
},
|
|
535
534
|
"EntityStorageSetRequest": {
|
|
@@ -567,12 +566,10 @@
|
|
|
567
566
|
"name",
|
|
568
567
|
"message"
|
|
569
568
|
],
|
|
570
|
-
"additionalProperties": false,
|
|
571
569
|
"description": "Model to describe serialized error."
|
|
572
570
|
},
|
|
573
571
|
"NotFoundResponse": {
|
|
574
572
|
"type": "object",
|
|
575
|
-
"additionalProperties": false,
|
|
576
573
|
"properties": {
|
|
577
574
|
"notFoundId": {
|
|
578
575
|
"type": "string",
|
|
@@ -34,7 +34,7 @@ The dependencies for the entity storage service.
|
|
|
34
34
|
|
|
35
35
|
## Properties
|
|
36
36
|
|
|
37
|
-
### CLASS\_NAME
|
|
37
|
+
### CLASS\_NAME {#class_name}
|
|
38
38
|
|
|
39
39
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@ Runtime name for the class.
|
|
|
42
42
|
|
|
43
43
|
## Methods
|
|
44
44
|
|
|
45
|
-
### className()
|
|
45
|
+
### className() {#classname}
|
|
46
46
|
|
|
47
47
|
> **className**(): `string`
|
|
48
48
|
|
|
@@ -60,7 +60,7 @@ The class name of the component.
|
|
|
60
60
|
|
|
61
61
|
***
|
|
62
62
|
|
|
63
|
-
### set()
|
|
63
|
+
### set() {#set}
|
|
64
64
|
|
|
65
65
|
> **set**(`entity`): `Promise`\<`void`\>
|
|
66
66
|
|
|
@@ -86,7 +86,7 @@ The id of the entity.
|
|
|
86
86
|
|
|
87
87
|
***
|
|
88
88
|
|
|
89
|
-
### get()
|
|
89
|
+
### get() {#get}
|
|
90
90
|
|
|
91
91
|
> **get**(`id`, `secondaryIndex?`): `Promise`\<`T` \| `undefined`\>
|
|
92
92
|
|
|
@@ -118,7 +118,7 @@ The object if it can be found or undefined.
|
|
|
118
118
|
|
|
119
119
|
***
|
|
120
120
|
|
|
121
|
-
### remove()
|
|
121
|
+
### remove() {#remove}
|
|
122
122
|
|
|
123
123
|
> **remove**(`id`): `Promise`\<`void`\>
|
|
124
124
|
|
|
@@ -144,7 +144,7 @@ Nothing.
|
|
|
144
144
|
|
|
145
145
|
***
|
|
146
146
|
|
|
147
|
-
### query()
|
|
147
|
+
### query() {#query}
|
|
148
148
|
|
|
149
149
|
> **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
|
150
150
|
|
|
@@ -4,7 +4,7 @@ Examples for the entity storage routes.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### set?
|
|
7
|
+
### set? {#set}
|
|
8
8
|
|
|
9
9
|
> `optional` **set**: `object`
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ Examples for the set route.
|
|
|
16
16
|
|
|
17
17
|
***
|
|
18
18
|
|
|
19
|
-
### get?
|
|
19
|
+
### get? {#get}
|
|
20
20
|
|
|
21
21
|
> `optional` **get**: `object`
|
|
22
22
|
|
|
@@ -32,7 +32,7 @@ Examples for the get route.
|
|
|
32
32
|
|
|
33
33
|
***
|
|
34
34
|
|
|
35
|
-
### remove?
|
|
35
|
+
### remove? {#remove}
|
|
36
36
|
|
|
37
37
|
> `optional` **remove**: `object`
|
|
38
38
|
|
|
@@ -44,7 +44,7 @@ Examples for the remove route.
|
|
|
44
44
|
|
|
45
45
|
***
|
|
46
46
|
|
|
47
|
-
### list?
|
|
47
|
+
### list? {#list}
|
|
48
48
|
|
|
49
49
|
> `optional` **list**: `object`
|
|
50
50
|
|
|
@@ -4,7 +4,7 @@ Options for the Entity Storage Service constructor.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### entityStorageType
|
|
7
|
+
### entityStorageType {#entitystoragetype}
|
|
8
8
|
|
|
9
9
|
> **entityStorageType**: `string`
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ The type of the entity storage.
|
|
|
12
12
|
|
|
13
13
|
***
|
|
14
14
|
|
|
15
|
-
### config?
|
|
15
|
+
### config? {#config}
|
|
16
16
|
|
|
17
17
|
> `optional` **config**: [`IEntityStorageServiceConfig`](IEntityStorageServiceConfig.md)
|
|
18
18
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/entity-storage-service",
|
|
3
|
-
"version": "0.0.3-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3-next.7",
|
|
4
|
+
"description": "Service layer exposing storage contracts and REST endpoint definitions.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/twinfoundation/entity-storage.git",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@twin.org/api-models": "next",
|
|
18
18
|
"@twin.org/core": "next",
|
|
19
19
|
"@twin.org/entity": "next",
|
|
20
|
-
"@twin.org/entity-storage-models": "0.0.3-next.
|
|
20
|
+
"@twin.org/entity-storage-models": "0.0.3-next.7",
|
|
21
21
|
"@twin.org/nameof": "next",
|
|
22
22
|
"@twin.org/web": "next"
|
|
23
23
|
},
|