@twin.org/synchronised-storage-models 0.0.1-next.3 → 0.0.1-next.4
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/dist/types/index.d.ts +4 -0
- package/dist/types/models/ISyncChange.d.ts +19 -0
- package/dist/types/models/ISyncChangeSet.d.ts +36 -0
- package/dist/types/models/ISynchronisedEntity.d.ts +4 -0
- package/dist/types/models/ISynchronisedStorageComponent.d.ts +13 -3
- package/dist/types/models/api/ISyncChangeSetRequest.d.ts +3 -7
- package/dist/types/models/api/ISyncDecryptionKeyRequest.d.ts +19 -0
- package/dist/types/models/api/ISyncDecryptionKeyResponse.d.ts +14 -0
- package/dist/types/models/eventBus/ISyncBatchResponse.d.ts +0 -4
- package/docs/changelog.md +7 -0
- package/docs/reference/index.md +4 -0
- package/docs/reference/interfaces/ISyncBatchResponse.md +0 -8
- package/docs/reference/interfaces/ISyncChange.md +33 -0
- package/docs/reference/interfaces/ISyncChangeSet.md +65 -0
- package/docs/reference/interfaces/ISyncChangeSetRequest.md +3 -9
- package/docs/reference/interfaces/ISyncDecryptionKeyRequest.md +23 -0
- package/docs/reference/interfaces/ISyncDecryptionKeyResponse.md +17 -0
- package/docs/reference/interfaces/ISynchronisedEntity.md +8 -0
- package/docs/reference/interfaces/ISynchronisedStorageComponent.md +34 -5
- package/package.json +3 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./models/api/ISyncChangeSetRequest";
|
|
2
|
+
export * from "./models/api/ISyncDecryptionKeyRequest";
|
|
3
|
+
export * from "./models/api/ISyncDecryptionKeyResponse";
|
|
2
4
|
export * from "./models/eventBus/ISyncBatchRequest";
|
|
3
5
|
export * from "./models/eventBus/ISyncBatchResponse";
|
|
4
6
|
export * from "./models/eventBus/ISyncItemChange";
|
|
@@ -8,6 +10,8 @@ export * from "./models/eventBus/ISyncItemResponse";
|
|
|
8
10
|
export * from "./models/eventBus/ISyncItemSet";
|
|
9
11
|
export * from "./models/eventBus/ISyncRegisterStorageKey";
|
|
10
12
|
export * from "./models/eventBus/syncChangeOperation";
|
|
13
|
+
export * from "./models/ISyncChange";
|
|
14
|
+
export * from "./models/ISyncChangeSet";
|
|
11
15
|
export * from "./models/ISynchronisedEntity";
|
|
12
16
|
export * from "./models/ISynchronisedStorageComponent";
|
|
13
17
|
export * from "./models/synchronisedStorageTopics";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SyncChangeOperation } from "./eventBus/syncChangeOperation";
|
|
2
|
+
import type { ISynchronisedEntity } from "./ISynchronisedEntity";
|
|
3
|
+
/**
|
|
4
|
+
* The object definition for a sync change.
|
|
5
|
+
*/
|
|
6
|
+
export interface ISyncChange<T extends ISynchronisedEntity = ISynchronisedEntity> {
|
|
7
|
+
/**
|
|
8
|
+
* Operation.
|
|
9
|
+
*/
|
|
10
|
+
operation: SyncChangeOperation;
|
|
11
|
+
/**
|
|
12
|
+
* The item id.
|
|
13
|
+
*/
|
|
14
|
+
id: string;
|
|
15
|
+
/**
|
|
16
|
+
* The entity to set.
|
|
17
|
+
*/
|
|
18
|
+
entity?: Omit<T, "id" | "nodeIdentity">;
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IProof } from "@twin.org/standards-w3c-did";
|
|
2
|
+
import type { ISyncChange } from "./ISyncChange";
|
|
3
|
+
import type { ISynchronisedEntity } from "./ISynchronisedEntity";
|
|
4
|
+
/**
|
|
5
|
+
* The object definition for a sync change set.
|
|
6
|
+
*/
|
|
7
|
+
export interface ISyncChangeSet<T extends ISynchronisedEntity = ISynchronisedEntity> {
|
|
8
|
+
/**
|
|
9
|
+
* The id of the change set.
|
|
10
|
+
*/
|
|
11
|
+
id: string;
|
|
12
|
+
/**
|
|
13
|
+
* The date the change set was created.
|
|
14
|
+
*/
|
|
15
|
+
dateCreated: string;
|
|
16
|
+
/**
|
|
17
|
+
* The storage key of the change set. This is used to identify the entities being synchronised.
|
|
18
|
+
*/
|
|
19
|
+
storageKey: string;
|
|
20
|
+
/**
|
|
21
|
+
* The date the change set was last modified.
|
|
22
|
+
*/
|
|
23
|
+
dateModified?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The changes to apply after a snapshot.
|
|
26
|
+
*/
|
|
27
|
+
changes: ISyncChange<T>[];
|
|
28
|
+
/**
|
|
29
|
+
* The identity of the node that created the change set.
|
|
30
|
+
*/
|
|
31
|
+
nodeIdentity: string;
|
|
32
|
+
/**
|
|
33
|
+
* The proof for the change set.
|
|
34
|
+
*/
|
|
35
|
+
proof?: IProof;
|
|
36
|
+
}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import type { IComponent } from "@twin.org/core";
|
|
2
|
+
import type { IProof } from "@twin.org/standards-w3c-did";
|
|
3
|
+
import type { ISyncChangeSet } from "./ISyncChangeSet";
|
|
2
4
|
/**
|
|
3
5
|
* Class for performing synchronised storage operations.
|
|
4
6
|
*/
|
|
5
7
|
export interface ISynchronisedStorageComponent extends IComponent {
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
+
* Get the decryption key for the synchronised storage.
|
|
10
|
+
* This is used to decrypt the data stored in the synchronised storage.
|
|
11
|
+
* @param nodeIdentity The identity of the node requesting the decryption key.
|
|
12
|
+
* @param proof The proof of the request so we know the request is from the specified node.
|
|
13
|
+
* @returns The decryption key.
|
|
14
|
+
*/
|
|
15
|
+
getDecryptionKey(nodeIdentity: string, proof: IProof): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Synchronise a set of changes from an untrusted node, assumes this is a trusted node.
|
|
18
|
+
* @param syncChangeSet The change set to synchronise.
|
|
9
19
|
* @returns Nothing.
|
|
10
20
|
*/
|
|
11
|
-
syncChangeSet(
|
|
21
|
+
syncChangeSet(syncChangeSet: ISyncChangeSet): Promise<void>;
|
|
12
22
|
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
+
import type { ISyncChangeSet } from "../ISyncChangeSet";
|
|
1
2
|
/**
|
|
2
3
|
* Request a trusted node to perform a sync request for a changeset.
|
|
3
4
|
*/
|
|
4
5
|
export interface ISyncChangeSetRequest {
|
|
5
6
|
/**
|
|
6
|
-
* The
|
|
7
|
+
* The body of the request.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The storage id of the changeset.
|
|
11
|
-
*/
|
|
12
|
-
changeSetStorageId: string;
|
|
13
|
-
};
|
|
9
|
+
body: ISyncChangeSet;
|
|
14
10
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IProof } from "@twin.org/standards-w3c-did";
|
|
2
|
+
/**
|
|
3
|
+
* Request for the decryption key for the synchronised storage.
|
|
4
|
+
*/
|
|
5
|
+
export interface ISyncDecryptionKeyRequest {
|
|
6
|
+
/**
|
|
7
|
+
* The body of the request.
|
|
8
|
+
*/
|
|
9
|
+
body: {
|
|
10
|
+
/**
|
|
11
|
+
* The identity of the node making the request.
|
|
12
|
+
*/
|
|
13
|
+
nodeIdentity: string;
|
|
14
|
+
/**
|
|
15
|
+
* The proof of the request.
|
|
16
|
+
*/
|
|
17
|
+
proof: IProof;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response to a request for the decryption key for the synchronised storage.
|
|
3
|
+
*/
|
|
4
|
+
export interface ISyncDecryptionKeyResponse {
|
|
5
|
+
/**
|
|
6
|
+
* The body of the response.
|
|
7
|
+
*/
|
|
8
|
+
body: {
|
|
9
|
+
/**
|
|
10
|
+
* The decryption key for the synchronised storage as base64.
|
|
11
|
+
*/
|
|
12
|
+
decryptionKey: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -7,10 +7,6 @@ export interface ISyncBatchResponse<T extends ISynchronisedEntity> {
|
|
|
7
7
|
* The key of the storage for the entities in the batch.
|
|
8
8
|
*/
|
|
9
9
|
storageKey: string;
|
|
10
|
-
/**
|
|
11
|
-
* The primary key of the entity in the sync item response.
|
|
12
|
-
*/
|
|
13
|
-
primaryKey: keyof T;
|
|
14
10
|
/**
|
|
15
11
|
* The entities in the batch.
|
|
16
12
|
*/
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.1-next.4](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-models-v0.0.1-next.3...synchronised-storage-models-v0.0.1-next.4) (2025-08-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* blob storage connector instead of component ([#7](https://github.com/twinfoundation/synchronised-storage/issues/7)) ([ea27241](https://github.com/twinfoundation/synchronised-storage/commit/ea27241cf0810b52ab7a6be7346809d127b7109a))
|
|
9
|
+
|
|
3
10
|
## [0.0.1-next.3](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-models-v0.0.1-next.2...synchronised-storage-models-v0.0.1-next.3) (2025-07-25)
|
|
4
11
|
|
|
5
12
|
|
package/docs/reference/index.md
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Interfaces
|
|
4
4
|
|
|
5
|
+
- [ISyncChange](interfaces/ISyncChange.md)
|
|
6
|
+
- [ISyncChangeSet](interfaces/ISyncChangeSet.md)
|
|
5
7
|
- [ISynchronisedEntity](interfaces/ISynchronisedEntity.md)
|
|
6
8
|
- [ISynchronisedStorageComponent](interfaces/ISynchronisedStorageComponent.md)
|
|
7
9
|
- [ISyncChangeSetRequest](interfaces/ISyncChangeSetRequest.md)
|
|
10
|
+
- [ISyncDecryptionKeyRequest](interfaces/ISyncDecryptionKeyRequest.md)
|
|
11
|
+
- [ISyncDecryptionKeyResponse](interfaces/ISyncDecryptionKeyResponse.md)
|
|
8
12
|
- [ISyncBatchRequest](interfaces/ISyncBatchRequest.md)
|
|
9
13
|
- [ISyncBatchResponse](interfaces/ISyncBatchResponse.md)
|
|
10
14
|
- [ISyncItemChange](interfaces/ISyncItemChange.md)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Interface: ISyncChange\<T\>
|
|
2
|
+
|
|
3
|
+
The object definition for a sync change.
|
|
4
|
+
|
|
5
|
+
## Type Parameters
|
|
6
|
+
|
|
7
|
+
### T
|
|
8
|
+
|
|
9
|
+
`T` *extends* [`ISynchronisedEntity`](ISynchronisedEntity.md) = [`ISynchronisedEntity`](ISynchronisedEntity.md)
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### operation
|
|
14
|
+
|
|
15
|
+
> **operation**: [`SyncChangeOperation`](../type-aliases/SyncChangeOperation.md)
|
|
16
|
+
|
|
17
|
+
Operation.
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### id
|
|
22
|
+
|
|
23
|
+
> **id**: `string`
|
|
24
|
+
|
|
25
|
+
The item id.
|
|
26
|
+
|
|
27
|
+
***
|
|
28
|
+
|
|
29
|
+
### entity?
|
|
30
|
+
|
|
31
|
+
> `optional` **entity**: `Omit`\<`T`, `"id"` \| `"nodeIdentity"`\>
|
|
32
|
+
|
|
33
|
+
The entity to set.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Interface: ISyncChangeSet\<T\>
|
|
2
|
+
|
|
3
|
+
The object definition for a sync change set.
|
|
4
|
+
|
|
5
|
+
## Type Parameters
|
|
6
|
+
|
|
7
|
+
### T
|
|
8
|
+
|
|
9
|
+
`T` *extends* [`ISynchronisedEntity`](ISynchronisedEntity.md) = [`ISynchronisedEntity`](ISynchronisedEntity.md)
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### id
|
|
14
|
+
|
|
15
|
+
> **id**: `string`
|
|
16
|
+
|
|
17
|
+
The id of the change set.
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### dateCreated
|
|
22
|
+
|
|
23
|
+
> **dateCreated**: `string`
|
|
24
|
+
|
|
25
|
+
The date the change set was created.
|
|
26
|
+
|
|
27
|
+
***
|
|
28
|
+
|
|
29
|
+
### storageKey
|
|
30
|
+
|
|
31
|
+
> **storageKey**: `string`
|
|
32
|
+
|
|
33
|
+
The storage key of the change set. This is used to identify the entities being synchronised.
|
|
34
|
+
|
|
35
|
+
***
|
|
36
|
+
|
|
37
|
+
### dateModified?
|
|
38
|
+
|
|
39
|
+
> `optional` **dateModified**: `string`
|
|
40
|
+
|
|
41
|
+
The date the change set was last modified.
|
|
42
|
+
|
|
43
|
+
***
|
|
44
|
+
|
|
45
|
+
### changes
|
|
46
|
+
|
|
47
|
+
> **changes**: [`ISyncChange`](ISyncChange.md)\<`T`\>[]
|
|
48
|
+
|
|
49
|
+
The changes to apply after a snapshot.
|
|
50
|
+
|
|
51
|
+
***
|
|
52
|
+
|
|
53
|
+
### nodeIdentity
|
|
54
|
+
|
|
55
|
+
> **nodeIdentity**: `string`
|
|
56
|
+
|
|
57
|
+
The identity of the node that created the change set.
|
|
58
|
+
|
|
59
|
+
***
|
|
60
|
+
|
|
61
|
+
### proof?
|
|
62
|
+
|
|
63
|
+
> `optional` **proof**: `IProof`
|
|
64
|
+
|
|
65
|
+
The proof for the change set.
|
|
@@ -4,14 +4,8 @@ Request a trusted node to perform a sync request for a changeset.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### body
|
|
8
8
|
|
|
9
|
-
> **
|
|
9
|
+
> **body**: [`ISyncChangeSet`](ISyncChangeSet.md)
|
|
10
10
|
|
|
11
|
-
The
|
|
12
|
-
|
|
13
|
-
#### changeSetStorageId
|
|
14
|
-
|
|
15
|
-
> **changeSetStorageId**: `string`
|
|
16
|
-
|
|
17
|
-
The storage id of the changeset.
|
|
11
|
+
The body of the request.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Interface: ISyncDecryptionKeyRequest
|
|
2
|
+
|
|
3
|
+
Request for the decryption key for the synchronised storage.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### body
|
|
8
|
+
|
|
9
|
+
> **body**: `object`
|
|
10
|
+
|
|
11
|
+
The body of the request.
|
|
12
|
+
|
|
13
|
+
#### nodeIdentity
|
|
14
|
+
|
|
15
|
+
> **nodeIdentity**: `string`
|
|
16
|
+
|
|
17
|
+
The identity of the node making the request.
|
|
18
|
+
|
|
19
|
+
#### proof
|
|
20
|
+
|
|
21
|
+
> **proof**: `IProof`
|
|
22
|
+
|
|
23
|
+
The proof of the request.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Interface: ISyncDecryptionKeyResponse
|
|
2
|
+
|
|
3
|
+
Response to a request for the decryption key for the synchronised storage.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### body
|
|
8
|
+
|
|
9
|
+
> **body**: `object`
|
|
10
|
+
|
|
11
|
+
The body of the response.
|
|
12
|
+
|
|
13
|
+
#### decryptionKey
|
|
14
|
+
|
|
15
|
+
> **decryptionKey**: `string`
|
|
16
|
+
|
|
17
|
+
The decryption key for the synchronised storage as base64.
|
|
@@ -8,19 +8,48 @@ Class for performing synchronised storage operations.
|
|
|
8
8
|
|
|
9
9
|
## Methods
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### getDecryptionKey()
|
|
12
12
|
|
|
13
|
-
> **
|
|
13
|
+
> **getDecryptionKey**(`nodeIdentity`, `proof`): `Promise`\<`string`\>
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Get the decryption key for the synchronised storage.
|
|
16
|
+
This is used to decrypt the data stored in the synchronised storage.
|
|
16
17
|
|
|
17
18
|
#### Parameters
|
|
18
19
|
|
|
19
|
-
#####
|
|
20
|
+
##### nodeIdentity
|
|
20
21
|
|
|
21
22
|
`string`
|
|
22
23
|
|
|
23
|
-
The
|
|
24
|
+
The identity of the node requesting the decryption key.
|
|
25
|
+
|
|
26
|
+
##### proof
|
|
27
|
+
|
|
28
|
+
`IProof`
|
|
29
|
+
|
|
30
|
+
The proof of the request so we know the request is from the specified node.
|
|
31
|
+
|
|
32
|
+
#### Returns
|
|
33
|
+
|
|
34
|
+
`Promise`\<`string`\>
|
|
35
|
+
|
|
36
|
+
The decryption key.
|
|
37
|
+
|
|
38
|
+
***
|
|
39
|
+
|
|
40
|
+
### syncChangeSet()
|
|
41
|
+
|
|
42
|
+
> **syncChangeSet**(`syncChangeSet`): `Promise`\<`void`\>
|
|
43
|
+
|
|
44
|
+
Synchronise a set of changes from an untrusted node, assumes this is a trusted node.
|
|
45
|
+
|
|
46
|
+
#### Parameters
|
|
47
|
+
|
|
48
|
+
##### syncChangeSet
|
|
49
|
+
|
|
50
|
+
[`ISyncChangeSet`](ISyncChangeSet.md)
|
|
51
|
+
|
|
52
|
+
The change set to synchronise.
|
|
24
53
|
|
|
25
54
|
#### Returns
|
|
26
55
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/synchronised-storage-models",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.4",
|
|
4
4
|
"description": "Models which define the structure of the synchronised storage connectors and services",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
18
|
"@twin.org/entity": "next",
|
|
19
|
-
"@twin.org/nameof": "next"
|
|
19
|
+
"@twin.org/nameof": "next",
|
|
20
|
+
"@twin.org/standards-w3c-did": "next"
|
|
20
21
|
},
|
|
21
22
|
"main": "./dist/cjs/index.cjs",
|
|
22
23
|
"module": "./dist/esm/index.mjs",
|