@twin.org/synchronised-storage-service 0.0.3-next.9 → 0.9.0
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/dist/es/helpers/blobStorageHelper.js +1 -1
- package/dist/es/helpers/blobStorageHelper.js.map +1 -1
- package/dist/es/helpers/changeSetHelper.js +3 -3
- package/dist/es/helpers/changeSetHelper.js.map +1 -1
- package/dist/es/helpers/localSyncStateHelper.js +7 -7
- package/dist/es/helpers/localSyncStateHelper.js.map +1 -1
- package/dist/es/helpers/remoteSyncStateHelper.js +14 -9
- package/dist/es/helpers/remoteSyncStateHelper.js.map +1 -1
- package/dist/es/helpers/versions.js +9 -0
- package/dist/es/helpers/versions.js.map +1 -1
- package/dist/es/restEntryPoints.js +3 -0
- package/dist/es/restEntryPoints.js.map +1 -1
- package/dist/es/synchronisedStorageRoutes.js +4 -2
- package/dist/es/synchronisedStorageRoutes.js.map +1 -1
- package/dist/es/synchronisedStorageService.js +14 -11
- package/dist/es/synchronisedStorageService.js.map +1 -1
- package/dist/types/helpers/blobStorageHelper.d.ts +1 -1
- package/dist/types/helpers/changeSetHelper.d.ts +3 -3
- package/dist/types/helpers/localSyncStateHelper.d.ts +5 -5
- package/dist/types/helpers/remoteSyncStateHelper.d.ts +10 -19
- package/dist/types/helpers/versions.d.ts +9 -0
- package/dist/types/restEntryPoints.d.ts +3 -0
- package/dist/types/synchronisedStorageService.d.ts +3 -3
- package/docs/changelog.md +229 -76
- package/docs/examples.md +80 -1
- package/docs/open-api/spec.json +17 -21
- package/docs/reference/classes/SyncSnapshotEntry.md +12 -12
- package/docs/reference/classes/SynchronisedStorageService.md +9 -9
- package/docs/reference/interfaces/ISyncPointerStore.md +2 -2
- package/docs/reference/interfaces/ISyncSnapshot.md +7 -7
- package/docs/reference/interfaces/ISyncState.md +3 -3
- package/docs/reference/interfaces/ISynchronisedStorageServiceConfig.md +13 -13
- package/docs/reference/interfaces/ISynchronisedStorageServiceConstructorOptions.md +19 -19
- package/docs/reference/variables/restEntryPoints.md +2 -0
- package/package.json +20 -22
|
@@ -37,7 +37,7 @@ export declare class ChangeSetHelper {
|
|
|
37
37
|
/**
|
|
38
38
|
* Apply a sync changeset.
|
|
39
39
|
* @param syncChangeset The sync changeset to apply.
|
|
40
|
-
* @returns
|
|
40
|
+
* @returns A promise that resolves when all changes in the set have been published to the event bus.
|
|
41
41
|
*/
|
|
42
42
|
applyChangeset(syncChangeset: ISyncChangeSet): Promise<void>;
|
|
43
43
|
/**
|
|
@@ -58,8 +58,8 @@ export declare class ChangeSetHelper {
|
|
|
58
58
|
/**
|
|
59
59
|
* Reset the storage for a given storage key.
|
|
60
60
|
* @param storageKey The key of the storage to reset.
|
|
61
|
-
* @param resetMode The reset mode,
|
|
62
|
-
* @returns
|
|
61
|
+
* @param resetMode The reset mode, which uses the nodeId in the entities to determine which are local or remote.
|
|
62
|
+
* @returns A promise that resolves when the reset event is published to the event bus.
|
|
63
63
|
*/
|
|
64
64
|
reset(storageKey: string, resetMode: SyncNodeIdMode): Promise<void>;
|
|
65
65
|
}
|
|
@@ -24,7 +24,7 @@ export declare class LocalSyncStateHelper {
|
|
|
24
24
|
* @param storageKey The storage key of the snapshot to add the change for.
|
|
25
25
|
* @param operation The operation to perform.
|
|
26
26
|
* @param id The id of the entity to add the change for.
|
|
27
|
-
* @returns
|
|
27
|
+
* @returns A promise that resolves when the change is recorded in the local snapshot.
|
|
28
28
|
*/
|
|
29
29
|
addLocalChange(storageKey: string, operation: SyncChangeOperation, id: string): Promise<void>;
|
|
30
30
|
/**
|
|
@@ -37,20 +37,20 @@ export declare class LocalSyncStateHelper {
|
|
|
37
37
|
/**
|
|
38
38
|
* Set the current local snapshot with changes for this node.
|
|
39
39
|
* @param localChangeSnapshot The local change snapshot to set.
|
|
40
|
-
* @returns
|
|
40
|
+
* @returns A promise that resolves when the snapshot is persisted to entity storage.
|
|
41
41
|
*/
|
|
42
42
|
setLocalChangeSnapshot(localChangeSnapshot: SyncSnapshotEntry): Promise<void>;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Remove the local snapshot entry from storage.
|
|
45
45
|
* @param localChangeSnapshot The local change snapshot to remove.
|
|
46
|
-
* @returns
|
|
46
|
+
* @returns A promise that resolves when the snapshot is removed from entity storage.
|
|
47
47
|
*/
|
|
48
48
|
removeLocalChangeSnapshot(localChangeSnapshot: SyncSnapshotEntry): Promise<void>;
|
|
49
49
|
/**
|
|
50
50
|
* Apply a sync state to the local node.
|
|
51
51
|
* @param storageKey The storage key of the snapshot to sync with.
|
|
52
52
|
* @param syncState The sync state to sync with.
|
|
53
|
-
* @returns
|
|
53
|
+
* @returns A promise that resolves when all new and modified snapshots have been processed.
|
|
54
54
|
*/
|
|
55
55
|
applySyncState(storageKey: string, syncState: ISyncState): Promise<void>;
|
|
56
56
|
}
|
|
@@ -32,6 +32,7 @@ export declare class RemoteSyncStateHelper {
|
|
|
32
32
|
setNodeId(nodeId: string): void;
|
|
33
33
|
/**
|
|
34
34
|
* Start the remote sync state helper.
|
|
35
|
+
* @returns A promise that resolves when all event bus subscriptions are registered.
|
|
35
36
|
*/
|
|
36
37
|
start(): Promise<void>;
|
|
37
38
|
/**
|
|
@@ -40,32 +41,32 @@ export declare class RemoteSyncStateHelper {
|
|
|
40
41
|
*/
|
|
41
42
|
setSynchronisedStorageKey(synchronisedStorageKey: string): void;
|
|
42
43
|
/**
|
|
43
|
-
* Build a changeset.
|
|
44
|
+
* Build a changeset and invoke the callback when complete.
|
|
44
45
|
* @param storageKey The storage key of the change set.
|
|
45
46
|
* @param changes The changes to apply.
|
|
46
|
-
* @param completeCallback The callback
|
|
47
|
-
* @returns
|
|
47
|
+
* @param completeCallback The callback invoked when the changeset is created and stored.
|
|
48
|
+
* @returns A promise that resolves when item requests are dispatched or the changeset is finalised immediately.
|
|
48
49
|
*/
|
|
49
50
|
buildChangeSet(storageKey: string, changes: ISyncChange[], completeCallback: (syncChangeSet?: ISyncChangeSet, id?: string) => Promise<void>): Promise<void>;
|
|
50
51
|
/**
|
|
51
52
|
* Finalise the full details for the sync change set.
|
|
52
53
|
* @param storageKey The storage key of the change set.
|
|
53
|
-
* @param completeCallback The callback
|
|
54
|
-
* @returns
|
|
54
|
+
* @param completeCallback The callback invoked when the changeset is populated and optionally stored.
|
|
55
|
+
* @returns A promise that resolves when the changeset is built and the callback is invoked.
|
|
55
56
|
*/
|
|
56
57
|
finaliseFullChanges(storageKey: string, completeCallback: (syncChangeSet?: ISyncChangeSet, id?: string) => Promise<void>): Promise<void>;
|
|
57
58
|
/**
|
|
58
59
|
* Add a new changeset into the sync state.
|
|
59
60
|
* @param storageKey The storage key of the change set to add.
|
|
60
|
-
* @param changeSetStorageId The id of the change set to add
|
|
61
|
-
* @returns
|
|
61
|
+
* @param changeSetStorageId The id of the change set to add.
|
|
62
|
+
* @returns A promise that resolves when the sync state and verifiable sync pointer are updated.
|
|
62
63
|
*/
|
|
63
64
|
addChangeSetToSyncState(storageKey: string, changeSetStorageId: string): Promise<void>;
|
|
64
65
|
/**
|
|
65
66
|
* Create a consolidated snapshot for the entire storage.
|
|
66
67
|
* @param storageKey The storage key of the snapshot to create.
|
|
67
68
|
* @param batchSize The batch size to use for consolidation.
|
|
68
|
-
* @returns
|
|
69
|
+
* @returns A promise that resolves when the batch request is published to the event bus.
|
|
69
70
|
*/
|
|
70
71
|
consolidationStart(storageKey: string, batchSize: number): Promise<void>;
|
|
71
72
|
/**
|
|
@@ -76,7 +77,7 @@ export declare class RemoteSyncStateHelper {
|
|
|
76
77
|
/**
|
|
77
78
|
* Store the verifiable sync pointer in the verifiable storage.
|
|
78
79
|
* @param syncPointerStore The sync pointer store to store.
|
|
79
|
-
* @returns
|
|
80
|
+
* @returns A promise that resolves when the pointer store is persisted to verifiable storage.
|
|
80
81
|
*/
|
|
81
82
|
storeVerifiableSyncPointerStore(syncPointerStore: ISyncPointerStore): Promise<void>;
|
|
82
83
|
/**
|
|
@@ -91,14 +92,4 @@ export declare class RemoteSyncStateHelper {
|
|
|
91
92
|
* @returns The remote sync state.
|
|
92
93
|
*/
|
|
93
94
|
getSyncState(syncPointerId: string): Promise<ISyncState | undefined>;
|
|
94
|
-
/**
|
|
95
|
-
* Handle the batch response which is triggered from a consolidation request.
|
|
96
|
-
* @param response The batch response to handle.
|
|
97
|
-
*/
|
|
98
|
-
private handleBatchResponse;
|
|
99
|
-
/**
|
|
100
|
-
* Handle the item response.
|
|
101
|
-
* @param response The item response to handle.
|
|
102
|
-
*/
|
|
103
|
-
private handleLocalItemResponse;
|
|
104
95
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Current schema version for sync state objects.
|
|
3
|
+
*/
|
|
1
4
|
export declare const SYNC_STATE_VERSION: string;
|
|
5
|
+
/**
|
|
6
|
+
* Current schema version for sync pointer store objects.
|
|
7
|
+
*/
|
|
2
8
|
export declare const SYNC_POINTER_STORE_VERSION: string;
|
|
9
|
+
/**
|
|
10
|
+
* Current schema version for sync snapshot entry objects.
|
|
11
|
+
*/
|
|
3
12
|
export declare const SYNC_SNAPSHOT_VERSION: string;
|
|
@@ -21,13 +21,13 @@ export declare class SynchronisedStorageService implements ISynchronisedStorageC
|
|
|
21
21
|
/**
|
|
22
22
|
* The component needs to be started when the node is initialized.
|
|
23
23
|
* @param nodeLoggingComponentType The node logging component type.
|
|
24
|
-
* @returns
|
|
24
|
+
* @returns A promise that resolves when the service is started and all event bus subscriptions are active.
|
|
25
25
|
*/
|
|
26
26
|
start(nodeLoggingComponentType?: string): Promise<void>;
|
|
27
27
|
/**
|
|
28
28
|
* The component needs to be stopped when the node is closed.
|
|
29
29
|
* @param nodeLoggingComponentType The node logging component type.
|
|
30
|
-
* @returns
|
|
30
|
+
* @returns A promise that resolves when all scheduled tasks are removed and storage keys are deactivated.
|
|
31
31
|
*/
|
|
32
32
|
stop(nodeLoggingComponentType?: string): Promise<void>;
|
|
33
33
|
/**
|
|
@@ -41,7 +41,7 @@ export declare class SynchronisedStorageService implements ISynchronisedStorageC
|
|
|
41
41
|
* Synchronise a set of changes from an untrusted node, assumes this is a trusted node.
|
|
42
42
|
* @param syncChangeSet The change set to synchronise.
|
|
43
43
|
* @param trustPayload Trust payload to verify the requesters identity.
|
|
44
|
-
* @returns
|
|
44
|
+
* @returns A promise that resolves when the change set has been applied and the sync state updated.
|
|
45
45
|
*/
|
|
46
46
|
syncChangeSet(syncChangeSet: ISyncChangeSet, trustPayload: unknown): Promise<void>;
|
|
47
47
|
}
|