@twin.org/synchronised-storage-models 0.0.1-next.1 → 0.0.1-next.2

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.
Files changed (25) hide show
  1. package/dist/cjs/index.cjs +30 -8
  2. package/dist/esm/index.mjs +30 -9
  3. package/dist/types/index.d.ts +6 -2
  4. package/dist/types/models/eventBus/ISyncBatchRequest.d.ts +13 -0
  5. package/dist/types/models/eventBus/{ISyncConsolidationBatchResponse.d.ts → ISyncBatchResponse.d.ts} +8 -7
  6. package/dist/types/models/eventBus/ISyncItemChange.d.ts +18 -0
  7. package/dist/types/models/eventBus/ISyncItemRequest.d.ts +13 -0
  8. package/dist/types/models/eventBus/ISyncItemResponse.d.ts +18 -0
  9. package/dist/types/models/eventBus/ISyncItemSet.d.ts +0 -4
  10. package/dist/types/models/eventBus/syncChangeOperation.d.ts +17 -0
  11. package/dist/types/models/synchronisedStorageTopics.d.ts +12 -8
  12. package/docs/changelog.md +7 -0
  13. package/docs/reference/index.md +7 -2
  14. package/docs/reference/interfaces/ISyncBatchRequest.md +19 -0
  15. package/docs/reference/interfaces/{ISyncConsolidationBatchResponse.md → ISyncBatchResponse.md} +9 -9
  16. package/docs/reference/interfaces/ISyncItemChange.md +27 -0
  17. package/docs/reference/interfaces/ISyncItemRequest.md +19 -0
  18. package/docs/reference/interfaces/ISyncItemResponse.md +33 -0
  19. package/docs/reference/interfaces/ISyncItemSet.md +0 -8
  20. package/docs/reference/type-aliases/SyncChangeOperation.md +5 -0
  21. package/docs/reference/variables/SyncChangeOperation.md +19 -0
  22. package/docs/reference/variables/SynchronisedStorageTopics.md +18 -12
  23. package/package.json +1 -1
  24. package/dist/types/models/eventBus/ISyncConsolidationBatchRequest.d.ts +0 -13
  25. package/docs/reference/interfaces/ISyncConsolidationBatchRequest.md +0 -19
@@ -1,5 +1,22 @@
1
1
  'use strict';
2
2
 
3
+ // Copyright 2024 IOTA Stiftung.
4
+ // SPDX-License-Identifier: Apache-2.0.
5
+ /**
6
+ * The operations for a change.
7
+ */
8
+ // eslint-disable-next-line @typescript-eslint/naming-convention
9
+ const SyncChangeOperation = {
10
+ /**
11
+ * An item was set in the storage.
12
+ */
13
+ Set: "set",
14
+ /**
15
+ * An item was deleted from the storage.
16
+ */
17
+ Delete: "delete"
18
+ };
19
+
3
20
  // Copyright 2024 IOTA Stiftung.
4
21
  // SPDX-License-Identifier: Apache-2.0.
5
22
  /**
@@ -12,21 +29,25 @@ const SynchronisedStorageTopics = {
12
29
  */
13
30
  RegisterSchemaType: "synchronised-storage:register-schema-type",
14
31
  /**
15
- * An item was set in the storage by the local node.
32
+ * An item was changed in the storage by the local node.
33
+ */
34
+ LocalItemChange: "synchronised-storage:local-item-change",
35
+ /**
36
+ * A request has been made for a local item.
16
37
  */
17
- LocalItemSet: "synchronised-storage:local-item-set",
38
+ LocalItemRequest: "synchronised-storage:local-item-request",
18
39
  /**
19
- * An item was removed from the storage by the local node.
40
+ * A response to a local item request.
20
41
  */
21
- LocalItemRemove: "synchronised-storage:local-item-remove",
42
+ LocalItemResponse: "synchronised-storage:local-item-response",
22
43
  /**
23
- * A request has been made for a consolidation batch.
44
+ * A request has been made for a batch.
24
45
  */
25
- ConsolidationBatchRequest: "synchronised-storage:consolidation-batch-request",
46
+ BatchRequest: "synchronised-storage:batch-request",
26
47
  /**
27
- * A response to a consolidation batch.
48
+ * A response to a batch.
28
49
  */
29
- ConsolidationBatchResponse: "synchronised-storage:consolidation-batch-response",
50
+ BatchResponse: "synchronised-storage:batch-response",
30
51
  /**
31
52
  * An item was set in the storage by the remote node.
32
53
  */
@@ -37,4 +58,5 @@ const SynchronisedStorageTopics = {
37
58
  RemoteItemRemove: "synchronised-storage:remote-item-remove"
38
59
  };
39
60
 
61
+ exports.SyncChangeOperation = SyncChangeOperation;
40
62
  exports.SynchronisedStorageTopics = SynchronisedStorageTopics;
@@ -1,3 +1,20 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ /**
4
+ * The operations for a change.
5
+ */
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ const SyncChangeOperation = {
8
+ /**
9
+ * An item was set in the storage.
10
+ */
11
+ Set: "set",
12
+ /**
13
+ * An item was deleted from the storage.
14
+ */
15
+ Delete: "delete"
16
+ };
17
+
1
18
  // Copyright 2024 IOTA Stiftung.
2
19
  // SPDX-License-Identifier: Apache-2.0.
3
20
  /**
@@ -10,21 +27,25 @@ const SynchronisedStorageTopics = {
10
27
  */
11
28
  RegisterSchemaType: "synchronised-storage:register-schema-type",
12
29
  /**
13
- * An item was set in the storage by the local node.
30
+ * An item was changed in the storage by the local node.
31
+ */
32
+ LocalItemChange: "synchronised-storage:local-item-change",
33
+ /**
34
+ * A request has been made for a local item.
14
35
  */
15
- LocalItemSet: "synchronised-storage:local-item-set",
36
+ LocalItemRequest: "synchronised-storage:local-item-request",
16
37
  /**
17
- * An item was removed from the storage by the local node.
38
+ * A response to a local item request.
18
39
  */
19
- LocalItemRemove: "synchronised-storage:local-item-remove",
40
+ LocalItemResponse: "synchronised-storage:local-item-response",
20
41
  /**
21
- * A request has been made for a consolidation batch.
42
+ * A request has been made for a batch.
22
43
  */
23
- ConsolidationBatchRequest: "synchronised-storage:consolidation-batch-request",
44
+ BatchRequest: "synchronised-storage:batch-request",
24
45
  /**
25
- * A response to a consolidation batch.
46
+ * A response to a batch.
26
47
  */
27
- ConsolidationBatchResponse: "synchronised-storage:consolidation-batch-response",
48
+ BatchResponse: "synchronised-storage:batch-response",
28
49
  /**
29
50
  * An item was set in the storage by the remote node.
30
51
  */
@@ -35,4 +56,4 @@ const SynchronisedStorageTopics = {
35
56
  RemoteItemRemove: "synchronised-storage:remote-item-remove"
36
57
  };
37
58
 
38
- export { SynchronisedStorageTopics };
59
+ export { SyncChangeOperation, SynchronisedStorageTopics };
@@ -1,9 +1,13 @@
1
1
  export * from "./models/api/ISyncChangeSetRequest";
2
- export * from "./models/eventBus/ISyncConsolidationBatchRequest";
3
- export * from "./models/eventBus/ISyncConsolidationBatchResponse";
2
+ export * from "./models/eventBus/ISyncBatchRequest";
3
+ export * from "./models/eventBus/ISyncBatchResponse";
4
+ export * from "./models/eventBus/ISyncItemChange";
4
5
  export * from "./models/eventBus/ISyncItemRemove";
6
+ export * from "./models/eventBus/ISyncItemRequest";
7
+ export * from "./models/eventBus/ISyncItemResponse";
5
8
  export * from "./models/eventBus/ISyncItemSet";
6
9
  export * from "./models/eventBus/ISyncRegisterSchemaType";
10
+ export * from "./models/eventBus/syncChangeOperation";
7
11
  export * from "./models/ISynchronisedEntity";
8
12
  export * from "./models/ISynchronisedStorageComponent";
9
13
  export * from "./models/synchronisedStorageTopics";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Request for a local batch.
3
+ */
4
+ export interface ISyncBatchRequest {
5
+ /**
6
+ * The type of the schema for the entities in the batch.
7
+ */
8
+ schemaType: string;
9
+ /**
10
+ * The size of the batch.
11
+ */
12
+ batchSize: number;
13
+ }
@@ -1,19 +1,20 @@
1
1
  import type { ISynchronisedEntity } from "../ISynchronisedEntity";
2
2
  /**
3
- * Response for a local consolidation batch.
3
+ * Response for a local batch.
4
4
  */
5
- export interface ISyncConsolidationBatchResponse<T extends ISynchronisedEntity> {
5
+ export interface ISyncBatchResponse<T extends ISynchronisedEntity> {
6
6
  /**
7
7
  * The type of the schema for the entities in the batch.
8
8
  */
9
9
  schemaType: string;
10
10
  /**
11
- * The entities in the consolidation batch.
11
+ * The primary key of the entity in the sync item response.
12
12
  */
13
- entities: {
14
- id: string;
15
- entity: T;
16
- }[];
13
+ primaryKey: keyof T;
14
+ /**
15
+ * The entities in the batch.
16
+ */
17
+ entities: T[];
17
18
  /**
18
19
  * Is this the last entry in the batch?
19
20
  */
@@ -0,0 +1,18 @@
1
+ import type { SyncChangeOperation } from "./syncChangeOperation";
2
+ /**
3
+ * The payload for an item change.
4
+ */
5
+ export interface ISyncItemChange {
6
+ /**
7
+ * The type of the schema being changed.
8
+ */
9
+ schemaType: string;
10
+ /**
11
+ * The operation being performed on the item.
12
+ */
13
+ operation: SyncChangeOperation;
14
+ /**
15
+ * The id of the item being changed.
16
+ */
17
+ id: string;
18
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Request for a local item.
3
+ */
4
+ export interface ISyncItemRequest {
5
+ /**
6
+ * The type of the schema for the entities in the batch.
7
+ */
8
+ schemaType: string;
9
+ /**
10
+ * The item id being requested.
11
+ */
12
+ id: string;
13
+ }
@@ -0,0 +1,18 @@
1
+ import type { ISynchronisedEntity } from "../ISynchronisedEntity";
2
+ /**
3
+ * Response for a sync item request.
4
+ */
5
+ export interface ISyncItemResponse<T extends ISynchronisedEntity> {
6
+ /**
7
+ * The type of the schema for the entities in the batch.
8
+ */
9
+ schemaType: string;
10
+ /**
11
+ * The id of the entity in the sync item response.
12
+ */
13
+ id: string;
14
+ /**
15
+ * The entity in the sync item response, undefined if not found.
16
+ */
17
+ entity?: T;
18
+ }
@@ -7,10 +7,6 @@ export interface ISyncItemSet<T extends ISynchronisedEntity = ISynchronisedEntit
7
7
  * The type of the schema being set.
8
8
  */
9
9
  schemaType: string;
10
- /**
11
- * The id of the item being set.
12
- */
13
- id: string;
14
10
  /**
15
11
  * The entity being set in the item set.
16
12
  */
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The operations for a change.
3
+ */
4
+ export declare const SyncChangeOperation: {
5
+ /**
6
+ * An item was set in the storage.
7
+ */
8
+ readonly Set: "set";
9
+ /**
10
+ * An item was deleted from the storage.
11
+ */
12
+ readonly Delete: "delete";
13
+ };
14
+ /**
15
+ * The operations for a change
16
+ */
17
+ export type SyncChangeOperation = (typeof SyncChangeOperation)[keyof typeof SyncChangeOperation];
@@ -7,21 +7,25 @@ export declare const SynchronisedStorageTopics: {
7
7
  */
8
8
  readonly RegisterSchemaType: "synchronised-storage:register-schema-type";
9
9
  /**
10
- * An item was set in the storage by the local node.
10
+ * An item was changed in the storage by the local node.
11
11
  */
12
- readonly LocalItemSet: "synchronised-storage:local-item-set";
12
+ readonly LocalItemChange: "synchronised-storage:local-item-change";
13
13
  /**
14
- * An item was removed from the storage by the local node.
14
+ * A request has been made for a local item.
15
15
  */
16
- readonly LocalItemRemove: "synchronised-storage:local-item-remove";
16
+ readonly LocalItemRequest: "synchronised-storage:local-item-request";
17
17
  /**
18
- * A request has been made for a consolidation batch.
18
+ * A response to a local item request.
19
19
  */
20
- readonly ConsolidationBatchRequest: "synchronised-storage:consolidation-batch-request";
20
+ readonly LocalItemResponse: "synchronised-storage:local-item-response";
21
21
  /**
22
- * A response to a consolidation batch.
22
+ * A request has been made for a batch.
23
23
  */
24
- readonly ConsolidationBatchResponse: "synchronised-storage:consolidation-batch-response";
24
+ readonly BatchRequest: "synchronised-storage:batch-request";
25
+ /**
26
+ * A response to a batch.
27
+ */
28
+ readonly BatchResponse: "synchronised-storage:batch-response";
25
29
  /**
26
30
  * An item was set in the storage by the remote node.
27
31
  */
package/docs/changelog.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.1-next.2](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-models-v0.0.1-next.1...synchronised-storage-models-v0.0.1-next.2) (2025-07-22)
4
+
5
+
6
+ ### Features
7
+
8
+ * add async item requests to reduce storage overhead ([#3](https://github.com/twinfoundation/synchronised-storage/issues/3)) ([af4e17d](https://github.com/twinfoundation/synchronised-storage/commit/af4e17d826f0a8278fd60dc69aaa21fe6895425f))
9
+
3
10
  ## [0.0.1-next.1](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-models-v0.0.1-next.0...synchronised-storage-models-v0.0.1-next.1) (2025-07-18)
4
11
 
5
12
 
@@ -5,16 +5,21 @@
5
5
  - [ISynchronisedEntity](interfaces/ISynchronisedEntity.md)
6
6
  - [ISynchronisedStorageComponent](interfaces/ISynchronisedStorageComponent.md)
7
7
  - [ISyncChangeSetRequest](interfaces/ISyncChangeSetRequest.md)
8
- - [ISyncConsolidationBatchRequest](interfaces/ISyncConsolidationBatchRequest.md)
9
- - [ISyncConsolidationBatchResponse](interfaces/ISyncConsolidationBatchResponse.md)
8
+ - [ISyncBatchRequest](interfaces/ISyncBatchRequest.md)
9
+ - [ISyncBatchResponse](interfaces/ISyncBatchResponse.md)
10
+ - [ISyncItemChange](interfaces/ISyncItemChange.md)
10
11
  - [ISyncItemRemove](interfaces/ISyncItemRemove.md)
12
+ - [ISyncItemRequest](interfaces/ISyncItemRequest.md)
13
+ - [ISyncItemResponse](interfaces/ISyncItemResponse.md)
11
14
  - [ISyncItemSet](interfaces/ISyncItemSet.md)
12
15
  - [ISyncRegisterSchemaType](interfaces/ISyncRegisterSchemaType.md)
13
16
 
14
17
  ## Type Aliases
15
18
 
19
+ - [SyncChangeOperation](type-aliases/SyncChangeOperation.md)
16
20
  - [SynchronisedStorageTopics](type-aliases/SynchronisedStorageTopics.md)
17
21
 
18
22
  ## Variables
19
23
 
24
+ - [SyncChangeOperation](variables/SyncChangeOperation.md)
20
25
  - [SynchronisedStorageTopics](variables/SynchronisedStorageTopics.md)
@@ -0,0 +1,19 @@
1
+ # Interface: ISyncBatchRequest
2
+
3
+ Request for a local batch.
4
+
5
+ ## Properties
6
+
7
+ ### schemaType
8
+
9
+ > **schemaType**: `string`
10
+
11
+ The type of the schema for the entities in the batch.
12
+
13
+ ***
14
+
15
+ ### batchSize
16
+
17
+ > **batchSize**: `number`
18
+
19
+ The size of the batch.
@@ -1,6 +1,6 @@
1
- # Interface: ISyncConsolidationBatchResponse\<T\>
1
+ # Interface: ISyncBatchResponse\<T\>
2
2
 
3
- Response for a local consolidation batch.
3
+ Response for a local batch.
4
4
 
5
5
  ## Type Parameters
6
6
 
@@ -18,19 +18,19 @@ The type of the schema for the entities in the batch.
18
18
 
19
19
  ***
20
20
 
21
- ### entities
21
+ ### primaryKey
22
22
 
23
- > **entities**: `object`[]
23
+ > **primaryKey**: keyof `T`
24
24
 
25
- The entities in the consolidation batch.
25
+ The primary key of the entity in the sync item response.
26
26
 
27
- #### id
27
+ ***
28
28
 
29
- > **id**: `string`
29
+ ### entities
30
30
 
31
- #### entity
31
+ > **entities**: `T`[]
32
32
 
33
- > **entity**: `T`
33
+ The entities in the batch.
34
34
 
35
35
  ***
36
36
 
@@ -0,0 +1,27 @@
1
+ # Interface: ISyncItemChange
2
+
3
+ The payload for an item change.
4
+
5
+ ## Properties
6
+
7
+ ### schemaType
8
+
9
+ > **schemaType**: `string`
10
+
11
+ The type of the schema being changed.
12
+
13
+ ***
14
+
15
+ ### operation
16
+
17
+ > **operation**: [`SyncChangeOperation`](../type-aliases/SyncChangeOperation.md)
18
+
19
+ The operation being performed on the item.
20
+
21
+ ***
22
+
23
+ ### id
24
+
25
+ > **id**: `string`
26
+
27
+ The id of the item being changed.
@@ -0,0 +1,19 @@
1
+ # Interface: ISyncItemRequest
2
+
3
+ Request for a local item.
4
+
5
+ ## Properties
6
+
7
+ ### schemaType
8
+
9
+ > **schemaType**: `string`
10
+
11
+ The type of the schema for the entities in the batch.
12
+
13
+ ***
14
+
15
+ ### id
16
+
17
+ > **id**: `string`
18
+
19
+ The item id being requested.
@@ -0,0 +1,33 @@
1
+ # Interface: ISyncItemResponse\<T\>
2
+
3
+ Response for a sync item request.
4
+
5
+ ## Type Parameters
6
+
7
+ ### T
8
+
9
+ `T` *extends* [`ISynchronisedEntity`](ISynchronisedEntity.md)
10
+
11
+ ## Properties
12
+
13
+ ### schemaType
14
+
15
+ > **schemaType**: `string`
16
+
17
+ The type of the schema for the entities in the batch.
18
+
19
+ ***
20
+
21
+ ### id
22
+
23
+ > **id**: `string`
24
+
25
+ The id of the entity in the sync item response.
26
+
27
+ ***
28
+
29
+ ### entity?
30
+
31
+ > `optional` **entity**: `T`
32
+
33
+ The entity in the sync item response, undefined if not found.
@@ -18,14 +18,6 @@ The type of the schema being set.
18
18
 
19
19
  ***
20
20
 
21
- ### id
22
-
23
- > **id**: `string`
24
-
25
- The id of the item being set.
26
-
27
- ***
28
-
29
21
  ### entity
30
22
 
31
23
  > **entity**: `T`
@@ -0,0 +1,5 @@
1
+ # Type Alias: SyncChangeOperation
2
+
3
+ > **SyncChangeOperation** = *typeof* [`SyncChangeOperation`](../variables/SyncChangeOperation.md)\[keyof *typeof* [`SyncChangeOperation`](../variables/SyncChangeOperation.md)\]
4
+
5
+ The operations for a change
@@ -0,0 +1,19 @@
1
+ # Variable: SyncChangeOperation
2
+
3
+ > `const` **SyncChangeOperation**: `object`
4
+
5
+ The operations for a change.
6
+
7
+ ## Type declaration
8
+
9
+ ### Set
10
+
11
+ > `readonly` **Set**: `"set"` = `"set"`
12
+
13
+ An item was set in the storage.
14
+
15
+ ### Delete
16
+
17
+ > `readonly` **Delete**: `"delete"` = `"delete"`
18
+
19
+ An item was deleted from the storage.
@@ -12,29 +12,35 @@ The topics for synchronised storage event bus notifications.
12
12
 
13
13
  Register a schema type for the synchronised storage.
14
14
 
15
- ### LocalItemSet
15
+ ### LocalItemChange
16
16
 
17
- > `readonly` **LocalItemSet**: `"synchronised-storage:local-item-set"` = `"synchronised-storage:local-item-set"`
17
+ > `readonly` **LocalItemChange**: `"synchronised-storage:local-item-change"` = `"synchronised-storage:local-item-change"`
18
18
 
19
- An item was set in the storage by the local node.
19
+ An item was changed in the storage by the local node.
20
20
 
21
- ### LocalItemRemove
21
+ ### LocalItemRequest
22
22
 
23
- > `readonly` **LocalItemRemove**: `"synchronised-storage:local-item-remove"` = `"synchronised-storage:local-item-remove"`
23
+ > `readonly` **LocalItemRequest**: `"synchronised-storage:local-item-request"` = `"synchronised-storage:local-item-request"`
24
24
 
25
- An item was removed from the storage by the local node.
25
+ A request has been made for a local item.
26
26
 
27
- ### ConsolidationBatchRequest
27
+ ### LocalItemResponse
28
28
 
29
- > `readonly` **ConsolidationBatchRequest**: `"synchronised-storage:consolidation-batch-request"` = `"synchronised-storage:consolidation-batch-request"`
29
+ > `readonly` **LocalItemResponse**: `"synchronised-storage:local-item-response"` = `"synchronised-storage:local-item-response"`
30
30
 
31
- A request has been made for a consolidation batch.
31
+ A response to a local item request.
32
32
 
33
- ### ConsolidationBatchResponse
33
+ ### BatchRequest
34
34
 
35
- > `readonly` **ConsolidationBatchResponse**: `"synchronised-storage:consolidation-batch-response"` = `"synchronised-storage:consolidation-batch-response"`
35
+ > `readonly` **BatchRequest**: `"synchronised-storage:batch-request"` = `"synchronised-storage:batch-request"`
36
36
 
37
- A response to a consolidation batch.
37
+ A request has been made for a batch.
38
+
39
+ ### BatchResponse
40
+
41
+ > `readonly` **BatchResponse**: `"synchronised-storage:batch-response"` = `"synchronised-storage:batch-response"`
42
+
43
+ A response to a batch.
38
44
 
39
45
  ### RemoteItemSet
40
46
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/synchronised-storage-models",
3
- "version": "0.0.1-next.1",
3
+ "version": "0.0.1-next.2",
4
4
  "description": "Models which define the structure of the synchronised storage connectors and services",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,13 +0,0 @@
1
- /**
2
- * Request for a local consolidation batch.
3
- */
4
- export interface ISyncConsolidationBatchRequest {
5
- /**
6
- * The type of the schema for the entities in the batch.
7
- */
8
- schemaType: string;
9
- /**
10
- * The size of the consolidation batch.
11
- */
12
- consolidationBatchSize: number;
13
- }
@@ -1,19 +0,0 @@
1
- # Interface: ISyncConsolidationBatchRequest
2
-
3
- Request for a local consolidation batch.
4
-
5
- ## Properties
6
-
7
- ### schemaType
8
-
9
- > **schemaType**: `string`
10
-
11
- The type of the schema for the entities in the batch.
12
-
13
- ***
14
-
15
- ### consolidationBatchSize
16
-
17
- > **consolidationBatchSize**: `number`
18
-
19
- The size of the consolidation batch.