@twin.org/entity-storage-rest-client 0.0.3-next.1 → 0.0.3-next.10

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 CHANGED
@@ -1,6 +1,6 @@
1
- # TWIN Entity Storage REST Client
1
+ # Entity Storage REST Client
2
2
 
3
- Entity Storage contract implementation which can connect to REST endpoints.
3
+ This package provides a client layer for calling storage service endpoints through a consistent REST interface. 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
 
@@ -36,6 +36,17 @@ export class EntityStorageRestClient extends BaseRestClient {
36
36
  body: entity
37
37
  });
38
38
  }
39
+ /**
40
+ * Set multiple entities in a batch.
41
+ * @param entities The entities to set.
42
+ * @returns Nothing.
43
+ */
44
+ async setBatch(entities) {
45
+ Guards.arrayValue(EntityStorageRestClient.CLASS_NAME, "entities", entities);
46
+ await this.fetch("/batch", "POST", {
47
+ body: entities
48
+ });
49
+ }
39
50
  /**
40
51
  * Get an entity.
41
52
  * @param id The id of the entity to get, or the index value if secondaryIndex is set.
@@ -67,6 +78,32 @@ export class EntityStorageRestClient extends BaseRestClient {
67
78
  }
68
79
  });
69
80
  }
81
+ /**
82
+ * Remove multiple entities by id.
83
+ * @param ids The ids of the entities to remove.
84
+ * @returns Nothing.
85
+ */
86
+ async removeBatch(ids) {
87
+ Guards.arrayValue(EntityStorageRestClient.CLASS_NAME, "ids", ids);
88
+ await this.fetch("/batch", "DELETE", {
89
+ body: ids
90
+ });
91
+ }
92
+ /**
93
+ * Remove all entities from the storage.
94
+ * @returns Nothing.
95
+ */
96
+ async empty() {
97
+ await this.fetch("/", "DELETE", {});
98
+ }
99
+ /**
100
+ * Count all the entities which match the conditions.
101
+ * @returns The total count of entities in the storage.
102
+ */
103
+ async count() {
104
+ const result = await this.fetch("/count", "GET", {});
105
+ return result.body.count;
106
+ }
70
107
  /**
71
108
  * Query all the entities which match the conditions.
72
109
  * @param conditions The conditions to match for the entities.
@@ -1 +1 @@
1
- {"version":3,"file":"entityStorageRestClient.js","sourceRoot":"","sources":["../../src/entityStorageRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACN,mBAAmB,EAGnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAahD;;GAEG;AACH,MAAM,OAAO,uBACZ,SAAQ,cAAc;IAGtB;;OAEG;IACI,MAAM,CAAU,UAAU,6BAAsD;IAEvF;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,4BAAuC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACvE,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,uBAAuB,CAAC,UAAU,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,GAAG,CAAC,MAAS;QACzB,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,UAAU,YAAkB,MAAM,CAAC,CAAC;QAE1E,MAAM,IAAI,CAAC,KAAK,CAA+C,GAAG,EAAE,MAAM,EAAE;YAC3E,IAAI,EAAE,MAAM;SACZ,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAAG,CAAC,EAAU,EAAE,cAAwB;QACpD,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,UAAU,QAAc,EAAE,CAAC,CAAC;QAEvE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,MAAM,EACN,KAAK,EACL;YACC,UAAU,EAAE;gBACX,EAAE;aACF;YACD,KAAK,EAAE;gBACN,cAAc,EAAE,cAAwB;aACxC;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAS,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,MAAM,CAAC,EAAU;QAC7B,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,UAAU,QAAc,EAAE,CAAC,CAAC;QAEvE,MAAM,IAAI,CAAC,KAAK,CAAkD,MAAM,EAAE,QAAQ,EAAE;YACnF,UAAU,EAAE;gBACX,EAAE;aACF;SACD,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACI,KAAK,CAAC,KAAK,CACjB,UAA+B,EAC/B,OAAiB,EACjB,gBAAgC,EAChC,UAAwB,EACxB,MAAe,EACf,KAAc;QAWd,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAC9B,GAAG,EACH,KAAK,EACL;YACC,KAAK,EAAE;gBACN,UAAU,EAAE,mBAAmB,CAAC,cAAc,CAAC,UAAU,CAAC;gBAC1D,OAAO,EAAE,OAAiB;gBAC1B,gBAAgB;gBAChB,UAAU,EAAE,mBAAmB,CAAC,aAAa,CAAC,UAAU,CAAC;gBACzD,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC3B,MAAM;aACN;SACD,CACD,CAAC;QAEF,OAAO;YACN,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,QAAwB;YAC9C,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM;SAC1B,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport {\n\tHttpParameterHelper,\n\ttype IBaseRestClientConfig,\n\ttype INoContentResponse\n} from \"@twin.org/api-models\";\nimport { Coerce, Guards } from \"@twin.org/core\";\nimport type { EntityCondition, SortDirection } from \"@twin.org/entity\";\nimport type {\n\tIEntityStorageComponent,\n\tIEntityStorageGetRequest,\n\tIEntityStorageGetResponse,\n\tIEntityStorageListRequest,\n\tIEntityStorageListResponse,\n\tIEntityStorageRemoveRequest,\n\tIEntityStorageSetRequest\n} from \"@twin.org/entity-storage-models\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Client for performing entity storage through to REST endpoints.\n */\nexport class EntityStorageRestClient<T>\n\textends BaseRestClient\n\timplements IEntityStorageComponent<T>\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageRestClient<unknown>>();\n\n\t/**\n\t * Create a new instance of EntityStorageRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<EntityStorageRestClient<T>>(), config, \"entity-storage\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Set an entity.\n\t * @param entity The entity to set.\n\t * @returns The id of the entity.\n\t */\n\tpublic async set(entity: T): Promise<void> {\n\t\tGuards.object(EntityStorageRestClient.CLASS_NAME, nameof(entity), entity);\n\n\t\tawait this.fetch<IEntityStorageSetRequest, INoContentResponse>(\"/\", \"POST\", {\n\t\t\tbody: entity\n\t\t});\n\t}\n\n\t/**\n\t * Get an entity.\n\t * @param id The id of the entity to get, or the index value if secondaryIndex is set.\n\t * @param secondaryIndex Get the item using a secondary index.\n\t * @returns The object if it can be found or undefined.\n\t */\n\tpublic async get(id: string, secondaryIndex?: keyof T): Promise<T | undefined> {\n\t\tGuards.stringValue(EntityStorageRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tconst response = await this.fetch<IEntityStorageGetRequest, IEntityStorageGetResponse>(\n\t\t\t\"/:id\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tid\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\tsecondaryIndex: secondaryIndex as string\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body as T;\n\t}\n\n\t/**\n\t * Remove the entity.\n\t * @param id The id of the entity to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(id: string): Promise<void> {\n\t\tGuards.stringValue(EntityStorageRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tawait this.fetch<IEntityStorageRemoveRequest, INoContentResponse>(\"/:id\", \"DELETE\", {\n\t\t\tpathParams: {\n\t\t\t\tid\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Query all the entities which match the conditions.\n\t * @param conditions The conditions to match for the entities.\n\t * @param orderBy The order for the results.\n\t * @param orderByDirection The direction for the order, defaults to ascending.\n\t * @param properties The optional properties to return, defaults to all.\n\t * @param cursor The cursor to request the next chunk of entities.\n\t * @param limit The suggested number of entities to return in each chunk, in some scenarios can return a different amount.\n\t * @returns All the entities for the storage matching the conditions,\n\t * and a cursor which can be used to request more entities.\n\t */\n\tpublic async query(\n\t\tconditions?: EntityCondition<T>,\n\t\torderBy?: keyof T,\n\t\torderByDirection?: SortDirection,\n\t\tproperties?: (keyof T)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The entities, which can be partial if a limited keys list was provided.\n\t\t */\n\t\tentities: Partial<T>[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\tconst result = await this.fetch<IEntityStorageListRequest, IEntityStorageListResponse>(\n\t\t\t\"/\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tquery: {\n\t\t\t\t\tconditions: HttpParameterHelper.objectToString(conditions),\n\t\t\t\t\torderBy: orderBy as string,\n\t\t\t\t\torderByDirection,\n\t\t\t\t\tproperties: HttpParameterHelper.arrayToString(properties),\n\t\t\t\t\tlimit: Coerce.string(limit),\n\t\t\t\t\tcursor\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn {\n\t\t\tentities: result.body.entities as Partial<T>[],\n\t\t\tcursor: result.body.cursor\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"entityStorageRestClient.js","sourceRoot":"","sources":["../../src/entityStorageRestClient.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport {\n\tHttpParameterHelper,\n\ttype IBaseRestClientConfig,\n\ttype INoContentResponse\n} from \"@twin.org/api-models\";\nimport { Coerce, Guards } from \"@twin.org/core\";\nimport type { EntityCondition, SortDirection } from \"@twin.org/entity\";\nimport type {\n\tIEntityStorageComponent,\n\tIEntityStorageCountRequest,\n\tIEntityStorageCountResponse,\n\tIEntityStorageEmptyRequest,\n\tIEntityStorageGetRequest,\n\tIEntityStorageGetResponse,\n\tIEntityStorageListRequest,\n\tIEntityStorageListResponse,\n\tIEntityStorageRemoveBatchRequest,\n\tIEntityStorageRemoveRequest,\n\tIEntityStorageSetBatchRequest,\n\tIEntityStorageSetRequest\n} from \"@twin.org/entity-storage-models\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Client for performing entity storage through to REST endpoints.\n */\nexport class EntityStorageRestClient<T>\n\textends BaseRestClient\n\timplements IEntityStorageComponent<T>\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageRestClient<unknown>>();\n\n\t/**\n\t * Create a new instance of EntityStorageRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<EntityStorageRestClient<T>>(), config, \"entity-storage\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Set an entity.\n\t * @param entity The entity to set.\n\t * @returns The id of the entity.\n\t */\n\tpublic async set(entity: T): Promise<void> {\n\t\tGuards.object(EntityStorageRestClient.CLASS_NAME, nameof(entity), entity);\n\n\t\tawait this.fetch<IEntityStorageSetRequest, INoContentResponse>(\"/\", \"POST\", {\n\t\t\tbody: entity\n\t\t});\n\t}\n\n\t/**\n\t * Set multiple entities in a batch.\n\t * @param entities The entities to set.\n\t * @returns Nothing.\n\t */\n\tpublic async setBatch(entities: T[]): Promise<void> {\n\t\tGuards.arrayValue(EntityStorageRestClient.CLASS_NAME, nameof(entities), entities);\n\n\t\tawait this.fetch<IEntityStorageSetBatchRequest, INoContentResponse>(\"/batch\", \"POST\", {\n\t\t\tbody: entities as unknown[]\n\t\t});\n\t}\n\n\t/**\n\t * Get an entity.\n\t * @param id The id of the entity to get, or the index value if secondaryIndex is set.\n\t * @param secondaryIndex Get the item using a secondary index.\n\t * @returns The object if it can be found or undefined.\n\t */\n\tpublic async get(id: string, secondaryIndex?: keyof T): Promise<T | undefined> {\n\t\tGuards.stringValue(EntityStorageRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tconst response = await this.fetch<IEntityStorageGetRequest, IEntityStorageGetResponse>(\n\t\t\t\"/:id\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tid\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\tsecondaryIndex: secondaryIndex as string\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body as T;\n\t}\n\n\t/**\n\t * Remove the entity.\n\t * @param id The id of the entity to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(id: string): Promise<void> {\n\t\tGuards.stringValue(EntityStorageRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tawait this.fetch<IEntityStorageRemoveRequest, INoContentResponse>(\"/:id\", \"DELETE\", {\n\t\t\tpathParams: {\n\t\t\t\tid\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Remove multiple entities by id.\n\t * @param ids The ids of the entities to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async removeBatch(ids: string[]): Promise<void> {\n\t\tGuards.arrayValue(EntityStorageRestClient.CLASS_NAME, nameof(ids), ids);\n\n\t\tawait this.fetch<IEntityStorageRemoveBatchRequest, INoContentResponse>(\"/batch\", \"DELETE\", {\n\t\t\tbody: ids\n\t\t});\n\t}\n\n\t/**\n\t * Remove all entities from the storage.\n\t * @returns Nothing.\n\t */\n\tpublic async empty(): Promise<void> {\n\t\tawait this.fetch<IEntityStorageEmptyRequest, INoContentResponse>(\"/\", \"DELETE\", {});\n\t}\n\n\t/**\n\t * Count all the entities which match the conditions.\n\t * @returns The total count of entities in the storage.\n\t */\n\tpublic async count(): Promise<number> {\n\t\tconst result = await this.fetch<IEntityStorageCountRequest, IEntityStorageCountResponse>(\n\t\t\t\"/count\",\n\t\t\t\"GET\",\n\t\t\t{}\n\t\t);\n\t\treturn result.body.count;\n\t}\n\n\t/**\n\t * Query all the entities which match the conditions.\n\t * @param conditions The conditions to match for the entities.\n\t * @param orderBy The order for the results.\n\t * @param orderByDirection The direction for the order, defaults to ascending.\n\t * @param properties The optional properties to return, defaults to all.\n\t * @param cursor The cursor to request the next chunk of entities.\n\t * @param limit The suggested number of entities to return in each chunk, in some scenarios can return a different amount.\n\t * @returns All the entities for the storage matching the conditions,\n\t * and a cursor which can be used to request more entities.\n\t */\n\tpublic async query(\n\t\tconditions?: EntityCondition<T>,\n\t\torderBy?: keyof T,\n\t\torderByDirection?: SortDirection,\n\t\tproperties?: (keyof T)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The entities, which can be partial if a limited keys list was provided.\n\t\t */\n\t\tentities: Partial<T>[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\tconst result = await this.fetch<IEntityStorageListRequest, IEntityStorageListResponse>(\n\t\t\t\"/\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tquery: {\n\t\t\t\t\tconditions: HttpParameterHelper.objectToString(conditions),\n\t\t\t\t\torderBy: orderBy as string,\n\t\t\t\t\torderByDirection,\n\t\t\t\t\tproperties: HttpParameterHelper.arrayToString(properties),\n\t\t\t\t\tlimit: Coerce.string(limit),\n\t\t\t\t\tcursor\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn {\n\t\t\tentities: result.body.entities as Partial<T>[],\n\t\t\tcursor: result.body.cursor\n\t\t};\n\t}\n}\n"]}
@@ -26,6 +26,12 @@ export declare class EntityStorageRestClient<T> extends BaseRestClient implement
26
26
  * @returns The id of the entity.
27
27
  */
28
28
  set(entity: T): Promise<void>;
29
+ /**
30
+ * Set multiple entities in a batch.
31
+ * @param entities The entities to set.
32
+ * @returns Nothing.
33
+ */
34
+ setBatch(entities: T[]): Promise<void>;
29
35
  /**
30
36
  * Get an entity.
31
37
  * @param id The id of the entity to get, or the index value if secondaryIndex is set.
@@ -39,6 +45,22 @@ export declare class EntityStorageRestClient<T> extends BaseRestClient implement
39
45
  * @returns Nothing.
40
46
  */
41
47
  remove(id: string): Promise<void>;
48
+ /**
49
+ * Remove multiple entities by id.
50
+ * @param ids The ids of the entities to remove.
51
+ * @returns Nothing.
52
+ */
53
+ removeBatch(ids: string[]): Promise<void>;
54
+ /**
55
+ * Remove all entities from the storage.
56
+ * @returns Nothing.
57
+ */
58
+ empty(): Promise<void>;
59
+ /**
60
+ * Count all the entities which match the conditions.
61
+ * @returns The total count of entities in the storage.
62
+ */
63
+ count(): Promise<number>;
42
64
  /**
43
65
  * Query all the entities which match the conditions.
44
66
  * @param conditions The conditions to match for the entities.
package/docs/changelog.md CHANGED
@@ -1,22 +1,148 @@
1
- # @twin.org/entity-storage-rest-client - Changelog
1
+ # Changelog
2
2
 
3
- ## [0.0.3-next.1](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.3-next.0...entity-storage-rest-client-v0.0.3-next.1) (2025-11-10)
3
+ ## [0.0.3-next.10](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.3-next.9...entity-storage-rest-client-v0.0.3-next.10) (2026-05-07)
4
4
 
5
5
 
6
6
  ### Features
7
7
 
8
- * add context id features ([#55](https://github.com/twinfoundation/entity-storage/issues/55)) ([99c15a2](https://github.com/twinfoundation/entity-storage/commit/99c15a257539b61d9da63649ce573ebf47699fc9))
9
- * add production release automation ([1eb4c8e](https://github.com/twinfoundation/entity-storage/commit/1eb4c8ee3eb099defdfc2d063ae44935276dcae8))
10
- * add validate-locales ([e66ef0d](https://github.com/twinfoundation/entity-storage/commit/e66ef0de26ca2f82b3fe89bb5c7a15a0978a9644))
11
- * eslint migration to flat config ([f033b64](https://github.com/twinfoundation/entity-storage/commit/f033b64984c0e6a8129d929c9dd816dcc1b8dab0))
12
- * update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
13
- * update framework core ([b59a380](https://github.com/twinfoundation/entity-storage/commit/b59a380bb7fba2b43610f69074dcdee24a4737da))
14
- * use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
8
+ * entity storage enhancements ([#86](https://github.com/iotaledger/twin-entity-storage/issues/86)) ([1279af4](https://github.com/iotaledger/twin-entity-storage/commit/1279af42615c6497bb06539842cee44842dd1f75))
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.9 to 0.0.3-next.10
16
+
17
+ ## [0.0.3-next.9](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.3-next.8...entity-storage-rest-client-v0.0.3-next.9) (2026-04-22)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **entity-storage-rest-client:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/entity-storage-models bumped from 0.0.3-next.8 to 0.0.3-next.9
30
+
31
+ ## [0.0.3-next.8](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.3-next.7...entity-storage-rest-client-v0.0.3-next.8) (2026-03-20)
32
+
33
+
34
+ ### Miscellaneous Chores
35
+
36
+ * **entity-storage-rest-client:** Synchronize repo versions
37
+
38
+
39
+ ### Dependencies
40
+
41
+ * The following workspace dependencies were updated
42
+ * dependencies
43
+ * @twin.org/entity-storage-models bumped from 0.0.3-next.7 to 0.0.3-next.8
44
+
45
+ ## [0.0.3-next.7](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.3-next.6...entity-storage-rest-client-v0.0.3-next.7) (2026-03-13)
46
+
47
+
48
+ ### Miscellaneous Chores
49
+
50
+ * **entity-storage-rest-client:** Synchronize repo versions
51
+
52
+
53
+ ### Dependencies
54
+
55
+ * The following workspace dependencies were updated
56
+ * dependencies
57
+ * @twin.org/entity-storage-models bumped from 0.0.3-next.6 to 0.0.3-next.7
58
+
59
+ ## [0.0.3-next.6](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.3-next.5...entity-storage-rest-client-v0.0.3-next.6) (2026-01-21)
60
+
61
+
62
+ ### Miscellaneous Chores
63
+
64
+ * **entity-storage-rest-client:** Synchronize repo versions
65
+
66
+
67
+ ### Dependencies
68
+
69
+ * The following workspace dependencies were updated
70
+ * dependencies
71
+ * @twin.org/entity-storage-models bumped from 0.0.3-next.5 to 0.0.3-next.6
72
+
73
+ ## [0.0.3-next.5](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.3-next.4...entity-storage-rest-client-v0.0.3-next.5) (2026-01-06)
74
+
75
+
76
+ ### Miscellaneous Chores
77
+
78
+ * **entity-storage-rest-client:** Synchronize repo versions
79
+
80
+
81
+ ### Dependencies
82
+
83
+ * The following workspace dependencies were updated
84
+ * dependencies
85
+ * @twin.org/entity-storage-models bumped from 0.0.3-next.4 to 0.0.3-next.5
86
+
87
+ ## [0.0.3-next.4](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.3-next.3...entity-storage-rest-client-v0.0.3-next.4) (2025-12-03)
88
+
89
+
90
+ ### Miscellaneous Chores
91
+
92
+ * **entity-storage-rest-client:** Synchronize repo versions
93
+
94
+
95
+ ### Dependencies
96
+
97
+ * The following workspace dependencies were updated
98
+ * dependencies
99
+ * @twin.org/entity-storage-models bumped from 0.0.3-next.3 to 0.0.3-next.4
100
+
101
+ ## [0.0.3-next.3](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.3-next.2...entity-storage-rest-client-v0.0.3-next.3) (2025-11-26)
102
+
103
+
104
+ ### Miscellaneous Chores
105
+
106
+ * **entity-storage-rest-client:** Synchronize repo versions
107
+
108
+
109
+ ### Dependencies
110
+
111
+ * The following workspace dependencies were updated
112
+ * dependencies
113
+ * @twin.org/entity-storage-models bumped from 0.0.3-next.2 to 0.0.3-next.3
114
+
115
+ ## [0.0.3-next.2](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.3-next.1...entity-storage-rest-client-v0.0.3-next.2) (2025-11-13)
116
+
117
+
118
+ ### Miscellaneous Chores
119
+
120
+ * **entity-storage-rest-client:** Synchronize repo versions
121
+
122
+
123
+ ### Dependencies
124
+
125
+ * The following workspace dependencies were updated
126
+ * dependencies
127
+ * @twin.org/entity-storage-models bumped from 0.0.3-next.1 to 0.0.3-next.2
128
+
129
+ ## [0.0.3-next.1](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.3-next.0...entity-storage-rest-client-v0.0.3-next.1) (2025-11-10)
130
+
131
+
132
+ ### Features
133
+
134
+ * add context id features ([#55](https://github.com/iotaledger/twin-entity-storage/issues/55)) ([99c15a2](https://github.com/iotaledger/twin-entity-storage/commit/99c15a257539b61d9da63649ce573ebf47699fc9))
135
+ * add production release automation ([1eb4c8e](https://github.com/iotaledger/twin-entity-storage/commit/1eb4c8ee3eb099defdfc2d063ae44935276dcae8))
136
+ * add validate-locales ([e66ef0d](https://github.com/iotaledger/twin-entity-storage/commit/e66ef0de26ca2f82b3fe89bb5c7a15a0978a9644))
137
+ * eslint migration to flat config ([f033b64](https://github.com/iotaledger/twin-entity-storage/commit/f033b64984c0e6a8129d929c9dd816dcc1b8dab0))
138
+ * update dependencies ([7ccc0c4](https://github.com/iotaledger/twin-entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
139
+ * update framework core ([b59a380](https://github.com/iotaledger/twin-entity-storage/commit/b59a380bb7fba2b43610f69074dcdee24a4737da))
140
+ * use shared store mechanism ([#34](https://github.com/iotaledger/twin-entity-storage/issues/34)) ([68b6b71](https://github.com/iotaledger/twin-entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
15
141
 
16
142
 
17
143
  ### Bug Fixes
18
144
 
19
- * query params force coercion ([dd6aa87](https://github.com/twinfoundation/entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
145
+ * query params force coercion ([dd6aa87](https://github.com/iotaledger/twin-entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
20
146
 
21
147
 
22
148
  ### Dependencies
@@ -25,12 +151,12 @@
25
151
  * dependencies
26
152
  * @twin.org/entity-storage-models bumped from 0.0.3-next.0 to 0.0.3-next.1
27
153
 
28
- ## [0.0.2-next.10](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.2-next.9...entity-storage-rest-client-v0.0.2-next.10) (2025-10-09)
154
+ ## [0.0.2-next.10](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.2-next.9...entity-storage-rest-client-v0.0.2-next.10) (2025-10-09)
29
155
 
30
156
 
31
157
  ### Features
32
158
 
33
- * add validate-locales ([e66ef0d](https://github.com/twinfoundation/entity-storage/commit/e66ef0de26ca2f82b3fe89bb5c7a15a0978a9644))
159
+ * add validate-locales ([e66ef0d](https://github.com/iotaledger/twin-entity-storage/commit/e66ef0de26ca2f82b3fe89bb5c7a15a0978a9644))
34
160
 
35
161
 
36
162
  ### Dependencies
@@ -39,7 +165,7 @@
39
165
  * dependencies
40
166
  * @twin.org/entity-storage-models bumped from 0.0.2-next.9 to 0.0.2-next.10
41
167
 
42
- ## [0.0.2-next.9](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.2-next.8...entity-storage-rest-client-v0.0.2-next.9) (2025-10-02)
168
+ ## [0.0.2-next.9](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.2-next.8...entity-storage-rest-client-v0.0.2-next.9) (2025-10-02)
43
169
 
44
170
 
45
171
  ### Miscellaneous Chores
@@ -53,12 +179,12 @@
53
179
  * dependencies
54
180
  * @twin.org/entity-storage-models bumped from 0.0.2-next.8 to 0.0.2-next.9
55
181
 
56
- ## [0.0.2-next.8](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.2-next.7...entity-storage-rest-client-v0.0.2-next.8) (2025-08-29)
182
+ ## [0.0.2-next.8](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.2-next.7...entity-storage-rest-client-v0.0.2-next.8) (2025-08-29)
57
183
 
58
184
 
59
185
  ### Features
60
186
 
61
- * eslint migration to flat config ([f033b64](https://github.com/twinfoundation/entity-storage/commit/f033b64984c0e6a8129d929c9dd816dcc1b8dab0))
187
+ * eslint migration to flat config ([f033b64](https://github.com/iotaledger/twin-entity-storage/commit/f033b64984c0e6a8129d929c9dd816dcc1b8dab0))
62
188
 
63
189
 
64
190
  ### Dependencies
@@ -67,7 +193,7 @@
67
193
  * dependencies
68
194
  * @twin.org/entity-storage-models bumped from 0.0.2-next.7 to 0.0.2-next.8
69
195
 
70
- ## [0.0.2-next.7](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.2-next.6...entity-storage-rest-client-v0.0.2-next.7) (2025-08-20)
196
+ ## [0.0.2-next.7](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.2-next.6...entity-storage-rest-client-v0.0.2-next.7) (2025-08-20)
71
197
 
72
198
 
73
199
  ### Miscellaneous Chores
@@ -81,12 +207,12 @@
81
207
  * dependencies
82
208
  * @twin.org/entity-storage-models bumped from 0.0.2-next.6 to 0.0.2-next.7
83
209
 
84
- ## [0.0.2-next.6](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.2-next.5...entity-storage-rest-client-v0.0.2-next.6) (2025-08-19)
210
+ ## [0.0.2-next.6](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.2-next.5...entity-storage-rest-client-v0.0.2-next.6) (2025-08-19)
85
211
 
86
212
 
87
213
  ### Features
88
214
 
89
- * update framework core ([b59a380](https://github.com/twinfoundation/entity-storage/commit/b59a380bb7fba2b43610f69074dcdee24a4737da))
215
+ * update framework core ([b59a380](https://github.com/iotaledger/twin-entity-storage/commit/b59a380bb7fba2b43610f69074dcdee24a4737da))
90
216
 
91
217
 
92
218
  ### Dependencies
@@ -95,7 +221,7 @@
95
221
  * dependencies
96
222
  * @twin.org/entity-storage-models bumped from 0.0.2-next.5 to 0.0.2-next.6
97
223
 
98
- ## [0.0.2-next.5](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.2-next.4...entity-storage-rest-client-v0.0.2-next.5) (2025-08-11)
224
+ ## [0.0.2-next.5](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.2-next.4...entity-storage-rest-client-v0.0.2-next.5) (2025-08-11)
99
225
 
100
226
 
101
227
  ### Miscellaneous Chores
@@ -109,7 +235,7 @@
109
235
  * dependencies
110
236
  * @twin.org/entity-storage-models bumped from 0.0.2-next.4 to 0.0.2-next.5
111
237
 
112
- ## [0.0.2-next.4](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.2-next.3...entity-storage-rest-client-v0.0.2-next.4) (2025-08-08)
238
+ ## [0.0.2-next.4](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.2-next.3...entity-storage-rest-client-v0.0.2-next.4) (2025-08-08)
113
239
 
114
240
 
115
241
  ### Miscellaneous Chores
@@ -123,7 +249,7 @@
123
249
  * dependencies
124
250
  * @twin.org/entity-storage-models bumped from 0.0.2-next.3 to 0.0.2-next.4
125
251
 
126
- ## [0.0.2-next.3](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.2-next.2...entity-storage-rest-client-v0.0.2-next.3) (2025-07-25)
252
+ ## [0.0.2-next.3](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.2-next.2...entity-storage-rest-client-v0.0.2-next.3) (2025-07-25)
127
253
 
128
254
 
129
255
  ### Miscellaneous Chores
@@ -137,7 +263,7 @@
137
263
  * dependencies
138
264
  * @twin.org/entity-storage-models bumped from 0.0.2-next.2 to 0.0.2-next.3
139
265
 
140
- ## [0.0.2-next.2](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.2-next.1...entity-storage-rest-client-v0.0.2-next.2) (2025-07-24)
266
+ ## [0.0.2-next.2](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.2-next.1...entity-storage-rest-client-v0.0.2-next.2) (2025-07-24)
141
267
 
142
268
 
143
269
  ### Miscellaneous Chores
@@ -151,19 +277,19 @@
151
277
  * dependencies
152
278
  * @twin.org/entity-storage-models bumped from 0.0.2-next.1 to 0.0.2-next.2
153
279
 
154
- ## [0.0.2-next.1](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.2-next.0...entity-storage-rest-client-v0.0.2-next.1) (2025-07-17)
280
+ ## [0.0.2-next.1](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.2-next.0...entity-storage-rest-client-v0.0.2-next.1) (2025-07-17)
155
281
 
156
282
 
157
283
  ### Features
158
284
 
159
- * add production release automation ([1eb4c8e](https://github.com/twinfoundation/entity-storage/commit/1eb4c8ee3eb099defdfc2d063ae44935276dcae8))
160
- * update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
161
- * use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
285
+ * add production release automation ([1eb4c8e](https://github.com/iotaledger/twin-entity-storage/commit/1eb4c8ee3eb099defdfc2d063ae44935276dcae8))
286
+ * update dependencies ([7ccc0c4](https://github.com/iotaledger/twin-entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
287
+ * use shared store mechanism ([#34](https://github.com/iotaledger/twin-entity-storage/issues/34)) ([68b6b71](https://github.com/iotaledger/twin-entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
162
288
 
163
289
 
164
290
  ### Bug Fixes
165
291
 
166
- * query params force coercion ([dd6aa87](https://github.com/twinfoundation/entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
292
+ * query params force coercion ([dd6aa87](https://github.com/iotaledger/twin-entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
167
293
 
168
294
 
169
295
  ### Dependencies
@@ -177,15 +303,15 @@
177
303
 
178
304
  ### Features
179
305
 
180
- * add production release automation ([1eb4c8e](https://github.com/twinfoundation/entity-storage/commit/1eb4c8ee3eb099defdfc2d063ae44935276dcae8))
181
- * release to production ([a309051](https://github.com/twinfoundation/entity-storage/commit/a3090519adebf7943232b4df12e4c6bd5afe7eed))
182
- * update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
183
- * use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
306
+ * add production release automation ([1eb4c8e](https://github.com/iotaledger/twin-entity-storage/commit/1eb4c8ee3eb099defdfc2d063ae44935276dcae8))
307
+ * release to production ([a309051](https://github.com/iotaledger/twin-entity-storage/commit/a3090519adebf7943232b4df12e4c6bd5afe7eed))
308
+ * update dependencies ([7ccc0c4](https://github.com/iotaledger/twin-entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
309
+ * use shared store mechanism ([#34](https://github.com/iotaledger/twin-entity-storage/issues/34)) ([68b6b71](https://github.com/iotaledger/twin-entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
184
310
 
185
311
 
186
312
  ### Bug Fixes
187
313
 
188
- * query params force coercion ([dd6aa87](https://github.com/twinfoundation/entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
314
+ * query params force coercion ([dd6aa87](https://github.com/iotaledger/twin-entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
189
315
 
190
316
 
191
317
  ### Dependencies
@@ -194,12 +320,12 @@
194
320
  * dependencies
195
321
  * @twin.org/entity-storage-models bumped from ^0.0.0 to ^0.0.1
196
322
 
197
- ## [0.0.1-next.31](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.1-next.30...entity-storage-rest-client-v0.0.1-next.31) (2025-06-20)
323
+ ## [0.0.1-next.31](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.1-next.30...entity-storage-rest-client-v0.0.1-next.31) (2025-06-20)
198
324
 
199
325
 
200
326
  ### Bug Fixes
201
327
 
202
- * query params force coercion ([dd6aa87](https://github.com/twinfoundation/entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
328
+ * query params force coercion ([dd6aa87](https://github.com/iotaledger/twin-entity-storage/commit/dd6aa87efdfb60bab7d6756a86888863c45c51a7))
203
329
 
204
330
 
205
331
  ### Dependencies
@@ -208,12 +334,12 @@
208
334
  * dependencies
209
335
  * @twin.org/entity-storage-models bumped from 0.0.1-next.30 to 0.0.1-next.31
210
336
 
211
- ## [0.0.1-next.30](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.1-next.29...entity-storage-rest-client-v0.0.1-next.30) (2025-06-12)
337
+ ## [0.0.1-next.30](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.1-next.29...entity-storage-rest-client-v0.0.1-next.30) (2025-06-12)
212
338
 
213
339
 
214
340
  ### Features
215
341
 
216
- * update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
342
+ * update dependencies ([7ccc0c4](https://github.com/iotaledger/twin-entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
217
343
 
218
344
 
219
345
  ### Dependencies
@@ -222,12 +348,12 @@
222
348
  * dependencies
223
349
  * @twin.org/entity-storage-models bumped from 0.0.1-next.29 to 0.0.1-next.30
224
350
 
225
- ## [0.0.1-next.29](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.1-next.28...entity-storage-rest-client-v0.0.1-next.29) (2025-04-17)
351
+ ## [0.0.1-next.29](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.1-next.28...entity-storage-rest-client-v0.0.1-next.29) (2025-04-17)
226
352
 
227
353
 
228
354
  ### Features
229
355
 
230
- * use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
356
+ * use shared store mechanism ([#34](https://github.com/iotaledger/twin-entity-storage/issues/34)) ([68b6b71](https://github.com/iotaledger/twin-entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
231
357
 
232
358
 
233
359
  ### Dependencies
@@ -236,7 +362,7 @@
236
362
  * dependencies
237
363
  * @twin.org/entity-storage-models bumped from 0.0.1-next.28 to 0.0.1-next.29
238
364
 
239
- ## [0.0.1-next.28](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.1-next.27...entity-storage-rest-client-v0.0.1-next.28) (2025-04-09)
365
+ ## [0.0.1-next.28](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.1-next.27...entity-storage-rest-client-v0.0.1-next.28) (2025-04-09)
240
366
 
241
367
 
242
368
  ### Miscellaneous Chores
@@ -250,7 +376,7 @@
250
376
  * dependencies
251
377
  * @twin.org/entity-storage-models bumped from 0.0.1-next.27 to 0.0.1-next.28
252
378
 
253
- ## [0.0.1-next.27](https://github.com/twinfoundation/entity-storage/compare/entity-storage-rest-client-v0.0.1-next.26...entity-storage-rest-client-v0.0.1-next.27) (2025-03-28)
379
+ ## [0.0.1-next.27](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-rest-client-v0.0.1-next.26...entity-storage-rest-client-v0.0.1-next.27) (2025-03-28)
254
380
 
255
381
 
256
382
  ### Miscellaneous Chores
package/docs/examples.md CHANGED
@@ -1 +1,60 @@
1
- # @twin.org/entity-storage-rest-client - Examples
1
+ # Entity Storage REST Client Examples
2
+
3
+ These snippets show how to call the REST endpoints with typed payloads and how to shape filtered list requests.
4
+
5
+ ## EntityStorageRestClient
6
+
7
+ ```typescript
8
+ import { EntityStorageRestClient } from '@twin.org/entity-storage-rest-client';
9
+ import {
10
+ ComparisonOperator,
11
+ LogicalOperator,
12
+ SortDirection,
13
+ type EntityCondition
14
+ } from '@twin.org/entity';
15
+
16
+ interface Profile {
17
+ id: string;
18
+ email: string;
19
+ status: 'active' | 'inactive';
20
+ createdAt: string;
21
+ }
22
+
23
+ const client = new EntityStorageRestClient<Profile>({
24
+ endpoint: 'http://localhost:8080'
25
+ });
26
+
27
+ const className = client.className();
28
+
29
+ await client.set({
30
+ id: 'profile-1',
31
+ email: 'ada@example.com',
32
+ status: 'active',
33
+ createdAt: '2026-03-09T10:30:00.000Z'
34
+ });
35
+
36
+ const byPrimaryKey = await client.get('profile-1');
37
+ const bySecondaryIndex = await client.get('ada@example.com', 'email');
38
+
39
+ const activeCondition: EntityCondition<Profile> = {
40
+ logicalOperator: LogicalOperator.And,
41
+ conditions: [
42
+ {
43
+ property: 'status',
44
+ comparison: ComparisonOperator.Equals,
45
+ value: 'active'
46
+ }
47
+ ]
48
+ };
49
+
50
+ const result = await client.query(
51
+ activeCondition,
52
+ 'createdAt',
53
+ SortDirection.Descending,
54
+ ['id', 'email', 'status'],
55
+ undefined,
56
+ 25
57
+ );
58
+
59
+ await client.remove('profile-1');
60
+ ```
@@ -42,7 +42,7 @@ The configuration for the client.
42
42
 
43
43
  ## Properties
44
44
 
45
- ### CLASS\_NAME
45
+ ### CLASS\_NAME {#class_name}
46
46
 
47
47
  > `readonly` `static` **CLASS\_NAME**: `string`
48
48
 
@@ -50,7 +50,7 @@ Runtime name for the class.
50
50
 
51
51
  ## Methods
52
52
 
53
- ### className()
53
+ ### className() {#classname}
54
54
 
55
55
  > **className**(): `string`
56
56
 
@@ -68,7 +68,7 @@ The class name of the component.
68
68
 
69
69
  ***
70
70
 
71
- ### set()
71
+ ### set() {#set}
72
72
 
73
73
  > **set**(`entity`): `Promise`\<`void`\>
74
74
 
@@ -94,7 +94,33 @@ The id of the entity.
94
94
 
95
95
  ***
96
96
 
97
- ### get()
97
+ ### setBatch() {#setbatch}
98
+
99
+ > **setBatch**(`entities`): `Promise`\<`void`\>
100
+
101
+ Set multiple entities in a batch.
102
+
103
+ #### Parameters
104
+
105
+ ##### entities
106
+
107
+ `T`[]
108
+
109
+ The entities to set.
110
+
111
+ #### Returns
112
+
113
+ `Promise`\<`void`\>
114
+
115
+ Nothing.
116
+
117
+ #### Implementation of
118
+
119
+ `IEntityStorageComponent.setBatch`
120
+
121
+ ***
122
+
123
+ ### get() {#get}
98
124
 
99
125
  > **get**(`id`, `secondaryIndex?`): `Promise`\<`T` \| `undefined`\>
100
126
 
@@ -126,7 +152,7 @@ The object if it can be found or undefined.
126
152
 
127
153
  ***
128
154
 
129
- ### remove()
155
+ ### remove() {#remove}
130
156
 
131
157
  > **remove**(`id`): `Promise`\<`void`\>
132
158
 
@@ -152,7 +178,69 @@ Nothing.
152
178
 
153
179
  ***
154
180
 
155
- ### query()
181
+ ### removeBatch() {#removebatch}
182
+
183
+ > **removeBatch**(`ids`): `Promise`\<`void`\>
184
+
185
+ Remove multiple entities by id.
186
+
187
+ #### Parameters
188
+
189
+ ##### ids
190
+
191
+ `string`[]
192
+
193
+ The ids of the entities to remove.
194
+
195
+ #### Returns
196
+
197
+ `Promise`\<`void`\>
198
+
199
+ Nothing.
200
+
201
+ #### Implementation of
202
+
203
+ `IEntityStorageComponent.removeBatch`
204
+
205
+ ***
206
+
207
+ ### empty() {#empty}
208
+
209
+ > **empty**(): `Promise`\<`void`\>
210
+
211
+ Remove all entities from the storage.
212
+
213
+ #### Returns
214
+
215
+ `Promise`\<`void`\>
216
+
217
+ Nothing.
218
+
219
+ #### Implementation of
220
+
221
+ `IEntityStorageComponent.empty`
222
+
223
+ ***
224
+
225
+ ### count() {#count}
226
+
227
+ > **count**(): `Promise`\<`number`\>
228
+
229
+ Count all the entities which match the conditions.
230
+
231
+ #### Returns
232
+
233
+ `Promise`\<`number`\>
234
+
235
+ The total count of entities in the storage.
236
+
237
+ #### Implementation of
238
+
239
+ `IEntityStorageComponent.count`
240
+
241
+ ***
242
+
243
+ ### query() {#query}
156
244
 
157
245
  > **query**(`conditions?`, `orderBy?`, `orderByDirection?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
158
246
 
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/entity-storage-rest-client",
3
- "version": "0.0.3-next.1",
4
- "description": "Entity Storage contract implementation which can connect to REST endpoints",
3
+ "version": "0.0.3-next.10",
4
+ "description": "REST client for calling storage services from applications and tools.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/twinfoundation/entity-storage.git",
7
+ "url": "git+https://github.com/iotaledger/entity-storage.git",
8
8
  "directory": "packages/entity-storage-rest-client"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
@@ -18,7 +18,7 @@
18
18
  "@twin.org/api-models": "next",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/entity": "next",
21
- "@twin.org/entity-storage-models": "0.0.3-next.1",
21
+ "@twin.org/entity-storage-models": "0.0.3-next.10",
22
22
  "@twin.org/nameof": "next",
23
23
  "@twin.org/web": "next"
24
24
  },
@@ -51,7 +51,7 @@
51
51
  "database"
52
52
  ],
53
53
  "bugs": {
54
- "url": "git+https://github.com/twinfoundation/entity-storage/issues"
54
+ "url": "git+https://github.com/iotaledger/entity-storage/issues"
55
55
  },
56
56
  "homepage": "https://twindev.org"
57
57
  }