@twin.org/entity-storage-models 0.0.3-next.5 → 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 +15 -1
- package/docs/examples.md +87 -1
- package/docs/reference/interfaces/IEntityStorageComponent.md +4 -4
- package/docs/reference/interfaces/IEntityStorageConnector.md +5 -5
- package/docs/reference/interfaces/IEntityStorageGetRequest.md +2 -2
- package/docs/reference/interfaces/IEntityStorageGetResponse.md +1 -1
- package/docs/reference/interfaces/IEntityStorageListRequest.md +1 -1
- package/docs/reference/interfaces/IEntityStorageListResponse.md +1 -1
- package/docs/reference/interfaces/IEntityStorageRemoveRequest.md +1 -1
- package/docs/reference/interfaces/IEntityStorageSetRequest.md +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Entity Storage Models
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package defines the shared domain models that standardise storage contracts, requests, responses and connector capabilities. 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,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.3-next.7](https://github.com/twinfoundation/entity-storage/compare/entity-storage-models-v0.0.3-next.6...entity-storage-models-v0.0.3-next.7) (2026-03-13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **entity-storage-models:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
## [0.0.3-next.6](https://github.com/twinfoundation/entity-storage/compare/entity-storage-models-v0.0.3-next.5...entity-storage-models-v0.0.3-next.6) (2026-01-21)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Miscellaneous Chores
|
|
14
|
+
|
|
15
|
+
* **entity-storage-models:** Synchronize repo versions
|
|
2
16
|
|
|
3
17
|
## [0.0.3-next.5](https://github.com/twinfoundation/entity-storage/compare/entity-storage-models-v0.0.3-next.4...entity-storage-models-v0.0.3-next.5) (2026-01-06)
|
|
4
18
|
|
package/docs/examples.md
CHANGED
|
@@ -1 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Entity Storage Models Examples
|
|
2
|
+
|
|
3
|
+
These examples focus on wiring connectors through the shared factory and shaping typed API request and response contracts.
|
|
4
|
+
|
|
5
|
+
## EntityStorageConnectorFactory
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
|
|
9
|
+
import { MemoryEntityStorageConnector } from '@twin.org/entity-storage-connector-memory';
|
|
10
|
+
|
|
11
|
+
interface Profile {
|
|
12
|
+
id: string;
|
|
13
|
+
email: string;
|
|
14
|
+
status: 'active' | 'inactive';
|
|
15
|
+
createdAt: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
EntityStorageConnectorFactory.register(
|
|
19
|
+
'profile-storage',
|
|
20
|
+
() =>
|
|
21
|
+
new MemoryEntityStorageConnector<Profile>({
|
|
22
|
+
entitySchema: 'Profile'
|
|
23
|
+
})
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const connector =
|
|
27
|
+
EntityStorageConnectorFactory.get<MemoryEntityStorageConnector<Profile>>('profile-storage');
|
|
28
|
+
|
|
29
|
+
await connector.set({
|
|
30
|
+
id: 'profile-1',
|
|
31
|
+
email: 'ada@example.com',
|
|
32
|
+
status: 'active',
|
|
33
|
+
createdAt: '2026-03-09T10:30:00.000Z'
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import type {
|
|
39
|
+
IEntityStorageGetRequest,
|
|
40
|
+
IEntityStorageGetResponse,
|
|
41
|
+
IEntityStorageListRequest,
|
|
42
|
+
IEntityStorageListResponse,
|
|
43
|
+
IEntityStorageRemoveRequest,
|
|
44
|
+
IEntityStorageSetRequest
|
|
45
|
+
} from '@twin.org/entity-storage-models';
|
|
46
|
+
|
|
47
|
+
interface Profile {
|
|
48
|
+
id: string;
|
|
49
|
+
email: string;
|
|
50
|
+
status: 'active' | 'inactive';
|
|
51
|
+
createdAt: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const setRequest: IEntityStorageSetRequest = {
|
|
55
|
+
body: {
|
|
56
|
+
id: 'profile-1',
|
|
57
|
+
email: 'ada@example.com',
|
|
58
|
+
status: 'active',
|
|
59
|
+
createdAt: '2026-03-09T10:30:00.000Z'
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const getRequest: IEntityStorageGetRequest = {
|
|
64
|
+
pathParams: { id: 'profile-1' }
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const listRequest: IEntityStorageListRequest = {
|
|
68
|
+
query: {
|
|
69
|
+
limit: '25'
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const getResponse: IEntityStorageGetResponse = {
|
|
74
|
+
body: setRequest.body
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const listResponse: IEntityStorageListResponse = {
|
|
78
|
+
body: {
|
|
79
|
+
entities: [setRequest.body],
|
|
80
|
+
cursor: 'next-page-token'
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const removeRequest: IEntityStorageRemoveRequest = {
|
|
85
|
+
pathParams: { id: 'profile-1' }
|
|
86
|
+
};
|
|
87
|
+
```
|
|
@@ -14,7 +14,7 @@ Interface describing an entity storage component.
|
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
17
|
-
### set()
|
|
17
|
+
### set() {#set}
|
|
18
18
|
|
|
19
19
|
> **set**(`entity`): `Promise`\<`void`\>
|
|
20
20
|
|
|
@@ -36,7 +36,7 @@ The id of the entity.
|
|
|
36
36
|
|
|
37
37
|
***
|
|
38
38
|
|
|
39
|
-
### get()
|
|
39
|
+
### get() {#get}
|
|
40
40
|
|
|
41
41
|
> **get**(`id`, `secondaryIndex?`): `Promise`\<`T` \| `undefined`\>
|
|
42
42
|
|
|
@@ -64,7 +64,7 @@ The object if it can be found or undefined.
|
|
|
64
64
|
|
|
65
65
|
***
|
|
66
66
|
|
|
67
|
-
### remove()
|
|
67
|
+
### remove() {#remove}
|
|
68
68
|
|
|
69
69
|
> **remove**(`id`): `Promise`\<`void`\>
|
|
70
70
|
|
|
@@ -86,7 +86,7 @@ Nothing.
|
|
|
86
86
|
|
|
87
87
|
***
|
|
88
88
|
|
|
89
|
-
### query()
|
|
89
|
+
### query() {#query}
|
|
90
90
|
|
|
91
91
|
> **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
|
92
92
|
|
|
@@ -14,7 +14,7 @@ Interface describing an entity storage connector.
|
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
17
|
-
### getSchema()
|
|
17
|
+
### getSchema() {#getschema}
|
|
18
18
|
|
|
19
19
|
> **getSchema**(): `IEntitySchema`
|
|
20
20
|
|
|
@@ -28,7 +28,7 @@ The schema for the entities.
|
|
|
28
28
|
|
|
29
29
|
***
|
|
30
30
|
|
|
31
|
-
### set()
|
|
31
|
+
### set() {#set}
|
|
32
32
|
|
|
33
33
|
> **set**(`entity`, `conditions?`): `Promise`\<`void`\>
|
|
34
34
|
|
|
@@ -56,7 +56,7 @@ The id of the entity.
|
|
|
56
56
|
|
|
57
57
|
***
|
|
58
58
|
|
|
59
|
-
### get()
|
|
59
|
+
### get() {#get}
|
|
60
60
|
|
|
61
61
|
> **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`T` \| `undefined`\>
|
|
62
62
|
|
|
@@ -90,7 +90,7 @@ The object if it can be found or undefined.
|
|
|
90
90
|
|
|
91
91
|
***
|
|
92
92
|
|
|
93
|
-
### remove()
|
|
93
|
+
### remove() {#remove}
|
|
94
94
|
|
|
95
95
|
> **remove**(`id`, `conditions?`): `Promise`\<`void`\>
|
|
96
96
|
|
|
@@ -118,7 +118,7 @@ Nothing.
|
|
|
118
118
|
|
|
119
119
|
***
|
|
120
120
|
|
|
121
|
-
### query()
|
|
121
|
+
### query() {#query}
|
|
122
122
|
|
|
123
123
|
> **query**(`conditions?`, `sortProperties?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
|
124
124
|
|
|
@@ -4,7 +4,7 @@ Get an entry from entity storage.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### pathParams
|
|
7
|
+
### pathParams {#pathparams}
|
|
8
8
|
|
|
9
9
|
> **pathParams**: `object`
|
|
10
10
|
|
|
@@ -18,7 +18,7 @@ The id of the entity to get.
|
|
|
18
18
|
|
|
19
19
|
***
|
|
20
20
|
|
|
21
|
-
### query?
|
|
21
|
+
### query? {#query}
|
|
22
22
|
|
|
23
23
|
> `optional` **query**: `object`
|
|
24
24
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/entity-storage-models",
|
|
3
|
-
"version": "0.0.3-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3-next.7",
|
|
4
|
+
"description": "Shared models for storage contracts, requests, responses and connector capabilities.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/twinfoundation/entity-storage.git",
|