@twin.org/entity-storage-service 0.0.3-next.6 → 0.0.3-next.8
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 +33 -1
- package/docs/examples.md +77 -1
- package/docs/open-api/spec.json +8 -36
- package/docs/reference/classes/EntityStorageService.md +6 -6
- package/docs/reference/interfaces/IEntityStorageRoutesExamples.md +8 -8
- package/docs/reference/interfaces/IEntityStorageServiceConstructorOptions.md +3 -3
- 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,36 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.3-next.8](https://github.com/twinfoundation/entity-storage/compare/entity-storage-service-v0.0.3-next.7...entity-storage-service-v0.0.3-next.8) (2026-03-20)
|
|
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.7 to 0.0.3-next.8
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @twin.org/entity-storage-connector-memory bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
18
|
+
|
|
19
|
+
## [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)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Miscellaneous Chores
|
|
23
|
+
|
|
24
|
+
* **entity-storage-service:** Synchronize repo versions
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
|
|
29
|
+
* The following workspace dependencies were updated
|
|
30
|
+
* dependencies
|
|
31
|
+
* @twin.org/entity-storage-models bumped from 0.0.3-next.6 to 0.0.3-next.7
|
|
32
|
+
* devDependencies
|
|
33
|
+
* @twin.org/entity-storage-connector-memory bumped from 0.0.3-next.6 to 0.0.3-next.7
|
|
2
34
|
|
|
3
35
|
## [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
36
|
|
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,13 +529,13 @@
|
|
|
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": {
|
|
536
535
|
"description": "The data to be used in the entity."
|
|
537
536
|
},
|
|
538
537
|
"Error": {
|
|
538
|
+
"description": "Model to describe serialized error.",
|
|
539
539
|
"type": "object",
|
|
540
540
|
"properties": {
|
|
541
541
|
"name": {
|
|
@@ -566,63 +566,35 @@
|
|
|
566
566
|
"required": [
|
|
567
567
|
"name",
|
|
568
568
|
"message"
|
|
569
|
-
]
|
|
570
|
-
"additionalProperties": false,
|
|
571
|
-
"description": "Model to describe serialized error."
|
|
569
|
+
]
|
|
572
570
|
},
|
|
573
571
|
"NotFoundResponse": {
|
|
574
572
|
"type": "object",
|
|
575
|
-
"additionalProperties": false,
|
|
576
573
|
"properties": {
|
|
577
574
|
"notFoundId": {
|
|
578
575
|
"type": "string",
|
|
579
576
|
"description": "The id if the item that was not found."
|
|
580
|
-
},
|
|
581
|
-
"name": {
|
|
582
|
-
"type": "string",
|
|
583
|
-
"description": "The name for the error."
|
|
584
|
-
},
|
|
585
|
-
"message": {
|
|
586
|
-
"type": "string",
|
|
587
|
-
"description": "The message for the error."
|
|
588
|
-
},
|
|
589
|
-
"source": {
|
|
590
|
-
"type": "string",
|
|
591
|
-
"description": "The source of the error."
|
|
592
|
-
},
|
|
593
|
-
"properties": {
|
|
594
|
-
"type": "object",
|
|
595
|
-
"additionalProperties": {},
|
|
596
|
-
"description": "Any additional information for the error."
|
|
597
|
-
},
|
|
598
|
-
"stack": {
|
|
599
|
-
"type": "string",
|
|
600
|
-
"description": "The stack trace for the error."
|
|
601
|
-
},
|
|
602
|
-
"cause": {
|
|
603
|
-
"$ref": "#/components/schemas/Error"
|
|
604
577
|
}
|
|
605
578
|
},
|
|
606
|
-
"
|
|
607
|
-
|
|
608
|
-
|
|
579
|
+
"allOf": [
|
|
580
|
+
{
|
|
581
|
+
"$ref": "#/components/schemas/Error"
|
|
582
|
+
}
|
|
609
583
|
],
|
|
610
584
|
"description": "The body which contains the error."
|
|
611
585
|
},
|
|
612
586
|
"SortDirection": {
|
|
587
|
+
"description": "The sort directions.",
|
|
613
588
|
"anyOf": [
|
|
614
589
|
{
|
|
615
|
-
"type": "string",
|
|
616
590
|
"const": "asc",
|
|
617
591
|
"description": "Ascending."
|
|
618
592
|
},
|
|
619
593
|
{
|
|
620
|
-
"type": "string",
|
|
621
594
|
"const": "desc",
|
|
622
595
|
"description": "Descending."
|
|
623
596
|
}
|
|
624
|
-
]
|
|
625
|
-
"description": "The sort directions."
|
|
597
|
+
]
|
|
626
598
|
}
|
|
627
599
|
},
|
|
628
600
|
"securitySchemes": {
|
|
@@ -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,9 +4,9 @@ Examples for the entity storage routes.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### set?
|
|
7
|
+
### set? {#set}
|
|
8
8
|
|
|
9
|
-
> `optional` **set
|
|
9
|
+
> `optional` **set?**: `object`
|
|
10
10
|
|
|
11
11
|
Examples for the set route.
|
|
12
12
|
|
|
@@ -16,9 +16,9 @@ Examples for the set route.
|
|
|
16
16
|
|
|
17
17
|
***
|
|
18
18
|
|
|
19
|
-
### get?
|
|
19
|
+
### get? {#get}
|
|
20
20
|
|
|
21
|
-
> `optional` **get
|
|
21
|
+
> `optional` **get?**: `object`
|
|
22
22
|
|
|
23
23
|
Examples for the get route.
|
|
24
24
|
|
|
@@ -32,9 +32,9 @@ Examples for the get route.
|
|
|
32
32
|
|
|
33
33
|
***
|
|
34
34
|
|
|
35
|
-
### remove?
|
|
35
|
+
### remove? {#remove}
|
|
36
36
|
|
|
37
|
-
> `optional` **remove
|
|
37
|
+
> `optional` **remove?**: `object`
|
|
38
38
|
|
|
39
39
|
Examples for the remove route.
|
|
40
40
|
|
|
@@ -44,9 +44,9 @@ Examples for the remove route.
|
|
|
44
44
|
|
|
45
45
|
***
|
|
46
46
|
|
|
47
|
-
### list?
|
|
47
|
+
### list? {#list}
|
|
48
48
|
|
|
49
|
-
> `optional` **list
|
|
49
|
+
> `optional` **list?**: `object`
|
|
50
50
|
|
|
51
51
|
Examples for the list route.
|
|
52
52
|
|
|
@@ -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,8 +12,8 @@ The type of the entity storage.
|
|
|
12
12
|
|
|
13
13
|
***
|
|
14
14
|
|
|
15
|
-
### config?
|
|
15
|
+
### config? {#config}
|
|
16
16
|
|
|
17
|
-
> `optional` **config
|
|
17
|
+
> `optional` **config?**: [`IEntityStorageServiceConfig`](IEntityStorageServiceConfig.md)
|
|
18
18
|
|
|
19
19
|
The configuration for the service.
|
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.8",
|
|
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.8",
|
|
21
21
|
"@twin.org/nameof": "next",
|
|
22
22
|
"@twin.org/web": "next"
|
|
23
23
|
},
|