@twin.org/api-rest-client 0.0.3-next.2 → 0.0.3-next.21

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
1
  # TWIN API REST Client
2
2
 
3
- Information contract implementation which can connect to REST endpoints.
3
+ This package provides a REST client implementation for consuming information and hosting endpoints.
4
4
 
5
5
  ## Installation
6
6
 
@@ -56,6 +56,14 @@ export class InformationRestClient extends BaseRestClient {
56
56
  const response = await this.fetch("/spec", "GET");
57
57
  return response.body;
58
58
  }
59
+ /**
60
+ * Is the server live.
61
+ * @returns True if the server is live.
62
+ */
63
+ async livez() {
64
+ const response = await this.fetch("/livez", "GET");
65
+ return response.body === "ok";
66
+ }
59
67
  /**
60
68
  * Get the server health.
61
69
  * @returns The service health.
@@ -72,7 +80,9 @@ export class InformationRestClient extends BaseRestClient {
72
80
  * @returns Nothing.
73
81
  */
74
82
  async setComponentHealth(name, status, details) {
75
- throw new NotSupportedError(InformationRestClient.CLASS_NAME, "\"setComponentHealth\"");
83
+ throw new NotSupportedError(InformationRestClient.CLASS_NAME, "notSupportedOnClient", {
84
+ methodName: "setComponentHealth"
85
+ });
76
86
  }
77
87
  /**
78
88
  * Remove the status of a component.
@@ -80,7 +90,9 @@ export class InformationRestClient extends BaseRestClient {
80
90
  * @returns Nothing.
81
91
  */
82
92
  async removeComponentHealth(name) {
83
- throw new NotSupportedError(InformationRestClient.CLASS_NAME, "\"removeComponentHealth\"");
93
+ throw new NotSupportedError(InformationRestClient.CLASS_NAME, "notSupportedOnClient", {
94
+ methodName: "removeComponentHealth"
95
+ });
84
96
  }
85
97
  }
86
98
  //# sourceMappingURL=informationRestClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"informationRestClient.js","sourceRoot":"","sources":["../../src/informationRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oB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B,CAC9B,IAAY,EACZ,MAAoB,EACpB,OAAgB;QAEhB,MAAM,IAAI,iBAAiB,CAAC,qBAAqB,CAAC,UAAU,2BAA+B,CAAC;IAC7F,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,qBAAqB,CAAC,IAAY;QAC9C,MAAM,IAAI,iBAAiB,CAAC,qBAAqB,CAAC,UAAU,8BAAkC,CAAC;IAChG,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type {\n\tHealthStatus,\n\tIBaseRestClientConfig,\n\tIHealthInfo,\n\tIInformationComponent,\n\tINoContentRequest,\n\tIServerFavIconResponse,\n\tIServerHealthResponse,\n\tIServerInfo,\n\tIServerInfoResponse,\n\tIServerRootResponse,\n\tIServerSpecResponse\n} from \"@twin.org/api-models\";\nimport { NotSupportedError } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * The client to connect to the information service.\n */\nexport class InformationRestClient extends BaseRestClient implements IInformationComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<InformationRestClient>();\n\n\t/**\n\t * Create a new instance of InformationRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<InformationRestClient>(), config, \"\");\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 InformationRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Get the server root.\n\t * @returns The root root.\n\t */\n\tpublic async root(): Promise<string> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerRootResponse>(\"/\", \"GET\");\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Get the server information.\n\t * @returns The service information.\n\t */\n\tpublic async info(): Promise<IServerInfo> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerInfoResponse>(\"/info\", \"GET\");\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Get the favicon.\n\t * @returns The favicon.\n\t */\n\tpublic async favicon(): Promise<Uint8Array | undefined> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerFavIconResponse>(\n\t\t\t\"/favicon.ico\",\n\t\t\t\"GET\"\n\t\t);\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Get the OpenAPI spec.\n\t * @returns The OpenAPI spec.\n\t */\n\tpublic async spec(): Promise<unknown> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerSpecResponse>(\"/spec\", \"GET\");\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Get the server health.\n\t * @returns The service health.\n\t */\n\tpublic async health(): Promise<IHealthInfo> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerHealthResponse>(\"/health\", \"GET\");\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Set the status of a component.\n\t * @param name The component name.\n\t * @param status The status of the component.\n\t * @param details The details for the status.\n\t * @returns Nothing.\n\t */\n\tpublic async setComponentHealth(\n\t\tname: string,\n\t\tstatus: HealthStatus,\n\t\tdetails?: string\n\t): Promise<void> {\n\t\tthrow new NotSupportedError(InformationRestClient.CLASS_NAME, nameof(\"setComponentHealth\"));\n\t}\n\n\t/**\n\t * Remove the status of a component.\n\t * @param name The component name.\n\t * @returns Nothing.\n\t */\n\tpublic async removeComponentHealth(name: string): Promise<void> {\n\t\tthrow new NotSupportedError(InformationRestClient.CLASS_NAME, nameof(\"removeComponentHealth\"));\n\t}\n}\n"]}
1
+ {"version":3,"file":"informationRestClient.js","sourceRoot":"","sources":["../../src/informationRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAepD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,cAAc;IACxD;;OAEG;I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C;IACtB,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,kBAAkB,CAC9B,IAAY,EACZ,MAAoB,EACpB,OAAgB;QAEhB,MAAM,IAAI,iBAAiB,CAAC,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,EAAE;YACrF,UAAU,EAAE,oBAAoB;SAChC,CAAC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,qBAAqB,CAAC,IAAY;QAC9C,MAAM,IAAI,iBAAiB,CAAC,qBAAqB,CAAC,UAAU,EAAE,sBAAsB,EAAE;YACrF,UAAU,EAAE,uBAAuB;SACnC,CAAC,CAAC;IACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type {\n\tHealthStatus,\n\tIBaseRestClientConfig,\n\tIHealthInfo,\n\tIInformationComponent,\n\tINoContentRequest,\n\tIServerFavIconResponse,\n\tIServerHealthResponse,\n\tIServerInfo,\n\tIServerInfoResponse,\n\tIServerLivezResponse,\n\tIServerRootResponse,\n\tIServerSpecResponse\n} from \"@twin.org/api-models\";\nimport { NotSupportedError } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * The client to connect to the information service.\n */\nexport class InformationRestClient extends BaseRestClient implements IInformationComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<InformationRestClient>();\n\n\t/**\n\t * Create a new instance of InformationRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<InformationRestClient>(), config, \"\");\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 InformationRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Get the server root.\n\t * @returns The root root.\n\t */\n\tpublic async root(): Promise<string> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerRootResponse>(\"/\", \"GET\");\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Get the server information.\n\t * @returns The service information.\n\t */\n\tpublic async info(): Promise<IServerInfo> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerInfoResponse>(\"/info\", \"GET\");\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Get the favicon.\n\t * @returns The favicon.\n\t */\n\tpublic async favicon(): Promise<Uint8Array | undefined> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerFavIconResponse>(\n\t\t\t\"/favicon.ico\",\n\t\t\t\"GET\"\n\t\t);\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Get the OpenAPI spec.\n\t * @returns The OpenAPI spec.\n\t */\n\tpublic async spec(): Promise<unknown> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerSpecResponse>(\"/spec\", \"GET\");\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Is the server live.\n\t * @returns True if the server is live.\n\t */\n\tpublic async livez(): Promise<boolean> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerLivezResponse>(\"/livez\", \"GET\");\n\t\treturn response.body === \"ok\";\n\t}\n\n\t/**\n\t * Get the server health.\n\t * @returns The service health.\n\t */\n\tpublic async health(): Promise<IHealthInfo> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerHealthResponse>(\"/health\", \"GET\");\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Set the status of a component.\n\t * @param name The component name.\n\t * @param status The status of the component.\n\t * @param details The details for the status.\n\t * @returns Nothing.\n\t */\n\tpublic async setComponentHealth(\n\t\tname: string,\n\t\tstatus: HealthStatus,\n\t\tdetails?: string\n\t): Promise<void> {\n\t\tthrow new NotSupportedError(InformationRestClient.CLASS_NAME, \"notSupportedOnClient\", {\n\t\t\tmethodName: \"setComponentHealth\"\n\t\t});\n\t}\n\n\t/**\n\t * Remove the status of a component.\n\t * @param name The component name.\n\t * @returns Nothing.\n\t */\n\tpublic async removeComponentHealth(name: string): Promise<void> {\n\t\tthrow new NotSupportedError(InformationRestClient.CLASS_NAME, \"notSupportedOnClient\", {\n\t\t\tmethodName: \"removeComponentHealth\"\n\t\t});\n\t}\n}\n"]}
@@ -38,6 +38,11 @@ export declare class InformationRestClient extends BaseRestClient implements IIn
38
38
  * @returns The OpenAPI spec.
39
39
  */
40
40
  spec(): Promise<unknown>;
41
+ /**
42
+ * Is the server live.
43
+ * @returns True if the server is live.
44
+ */
45
+ livez(): Promise<boolean>;
41
46
  /**
42
47
  * Get the server health.
43
48
  * @returns The service health.
package/docs/changelog.md CHANGED
@@ -1,4 +1,315 @@
1
- # @twin.org/api-rest-client - Changelog
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.21](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.20...api-rest-client-v0.0.3-next.21) (2026-03-11)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **api-rest-client:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/api-core bumped from 0.0.3-next.20 to 0.0.3-next.21
16
+ * @twin.org/api-models bumped from 0.0.3-next.20 to 0.0.3-next.21
17
+
18
+ ## [0.0.3-next.20](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.19...api-rest-client-v0.0.3-next.20) (2026-02-09)
19
+
20
+
21
+ ### Miscellaneous Chores
22
+
23
+ * **api-rest-client:** Synchronize repo versions
24
+
25
+
26
+ ### Dependencies
27
+
28
+ * The following workspace dependencies were updated
29
+ * dependencies
30
+ * @twin.org/api-core bumped from 0.0.3-next.19 to 0.0.3-next.20
31
+ * @twin.org/api-models bumped from 0.0.3-next.19 to 0.0.3-next.20
32
+
33
+ ## [0.0.3-next.19](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.18...api-rest-client-v0.0.3-next.19) (2026-02-06)
34
+
35
+
36
+ ### Miscellaneous Chores
37
+
38
+ * **api-rest-client:** Synchronize repo versions
39
+
40
+
41
+ ### Dependencies
42
+
43
+ * The following workspace dependencies were updated
44
+ * dependencies
45
+ * @twin.org/api-core bumped from 0.0.3-next.18 to 0.0.3-next.19
46
+ * @twin.org/api-models bumped from 0.0.3-next.18 to 0.0.3-next.19
47
+
48
+ ## [0.0.3-next.18](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.17...api-rest-client-v0.0.3-next.18) (2026-02-04)
49
+
50
+
51
+ ### Miscellaneous Chores
52
+
53
+ * **api-rest-client:** Synchronize repo versions
54
+
55
+
56
+ ### Dependencies
57
+
58
+ * The following workspace dependencies were updated
59
+ * dependencies
60
+ * @twin.org/api-core bumped from 0.0.3-next.17 to 0.0.3-next.18
61
+ * @twin.org/api-models bumped from 0.0.3-next.17 to 0.0.3-next.18
62
+
63
+ ## [0.0.3-next.17](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.16...api-rest-client-v0.0.3-next.17) (2026-01-26)
64
+
65
+
66
+ ### Miscellaneous Chores
67
+
68
+ * **api-rest-client:** Synchronize repo versions
69
+
70
+
71
+ ### Dependencies
72
+
73
+ * The following workspace dependencies were updated
74
+ * dependencies
75
+ * @twin.org/api-core bumped from 0.0.3-next.16 to 0.0.3-next.17
76
+ * @twin.org/api-models bumped from 0.0.3-next.16 to 0.0.3-next.17
77
+
78
+ ## [0.0.3-next.16](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.15...api-rest-client-v0.0.3-next.16) (2026-01-26)
79
+
80
+
81
+ ### Miscellaneous Chores
82
+
83
+ * **api-rest-client:** Synchronize repo versions
84
+
85
+
86
+ ### Dependencies
87
+
88
+ * The following workspace dependencies were updated
89
+ * dependencies
90
+ * @twin.org/api-core bumped from 0.0.3-next.15 to 0.0.3-next.16
91
+ * @twin.org/api-models bumped from 0.0.3-next.15 to 0.0.3-next.16
92
+
93
+ ## [0.0.3-next.15](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.14...api-rest-client-v0.0.3-next.15) (2026-01-22)
94
+
95
+
96
+ ### Miscellaneous Chores
97
+
98
+ * **api-rest-client:** Synchronize repo versions
99
+
100
+
101
+ ### Dependencies
102
+
103
+ * The following workspace dependencies were updated
104
+ * dependencies
105
+ * @twin.org/api-core bumped from 0.0.3-next.14 to 0.0.3-next.15
106
+ * @twin.org/api-models bumped from 0.0.3-next.14 to 0.0.3-next.15
107
+
108
+ ## [0.0.3-next.14](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.13...api-rest-client-v0.0.3-next.14) (2026-01-20)
109
+
110
+
111
+ ### Miscellaneous Chores
112
+
113
+ * **api-rest-client:** Synchronize repo versions
114
+
115
+
116
+ ### Dependencies
117
+
118
+ * The following workspace dependencies were updated
119
+ * dependencies
120
+ * @twin.org/api-core bumped from 0.0.3-next.13 to 0.0.3-next.14
121
+ * @twin.org/api-models bumped from 0.0.3-next.13 to 0.0.3-next.14
122
+
123
+ ## [0.0.3-next.13](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.12...api-rest-client-v0.0.3-next.13) (2026-01-19)
124
+
125
+
126
+ ### Features
127
+
128
+ * remove authentication generators ([#66](https://github.com/twinfoundation/api/issues/66)) ([adaa169](https://github.com/twinfoundation/api/commit/adaa1698df1c5ccb0ad645a7a7c0d3ef82ef6ac1))
129
+
130
+
131
+ ### Dependencies
132
+
133
+ * The following workspace dependencies were updated
134
+ * dependencies
135
+ * @twin.org/api-core bumped from 0.0.3-next.12 to 0.0.3-next.13
136
+ * @twin.org/api-models bumped from 0.0.3-next.12 to 0.0.3-next.13
137
+
138
+ ## [0.0.3-next.12](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.11...api-rest-client-v0.0.3-next.12) (2026-01-12)
139
+
140
+
141
+ ### Miscellaneous Chores
142
+
143
+ * **api-rest-client:** Synchronize repo versions
144
+
145
+
146
+ ### Dependencies
147
+
148
+ * The following workspace dependencies were updated
149
+ * dependencies
150
+ * @twin.org/api-core bumped from 0.0.3-next.11 to 0.0.3-next.12
151
+ * @twin.org/api-models bumped from 0.0.3-next.11 to 0.0.3-next.12
152
+
153
+ ## [0.0.3-next.11](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.10...api-rest-client-v0.0.3-next.11) (2026-01-08)
154
+
155
+
156
+ ### Miscellaneous Chores
157
+
158
+ * **api-rest-client:** Synchronize repo versions
159
+
160
+
161
+ ### Dependencies
162
+
163
+ * The following workspace dependencies were updated
164
+ * dependencies
165
+ * @twin.org/api-core bumped from 0.0.3-next.10 to 0.0.3-next.11
166
+ * @twin.org/api-models bumped from 0.0.3-next.10 to 0.0.3-next.11
167
+
168
+ ## [0.0.3-next.10](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.9...api-rest-client-v0.0.3-next.10) (2026-01-05)
169
+
170
+
171
+ ### Miscellaneous Chores
172
+
173
+ * **api-rest-client:** Synchronize repo versions
174
+
175
+
176
+ ### Dependencies
177
+
178
+ * The following workspace dependencies were updated
179
+ * dependencies
180
+ * @twin.org/api-core bumped from 0.0.3-next.9 to 0.0.3-next.10
181
+ * @twin.org/api-models bumped from 0.0.3-next.9 to 0.0.3-next.10
182
+
183
+ ## [0.0.3-next.9](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.8...api-rest-client-v0.0.3-next.9) (2026-01-05)
184
+
185
+
186
+ ### Features
187
+
188
+ * add context id features ([#42](https://github.com/twinfoundation/api/issues/42)) ([0186055](https://github.com/twinfoundation/api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
189
+ * add livez endpoint ([#57](https://github.com/twinfoundation/api/issues/57)) ([ef007db](https://github.com/twinfoundation/api/commit/ef007db8201736dd3053211f849ffd03baaa485e))
190
+ * add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
191
+ * add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
192
+ * eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
193
+ * update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
194
+ * update framework core ([d8eebf2](https://github.com/twinfoundation/api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
195
+ * update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
196
+ * use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
197
+
198
+
199
+ ### Bug Fixes
200
+
201
+ * not supported error handling ([5cc1a50](https://github.com/twinfoundation/api/commit/5cc1a507243f37fda5855acb622b2a3f4d91080f))
202
+ * use correct format for log messaging ([1d28474](https://github.com/twinfoundation/api/commit/1d284744589aa7875327ccc053446f655f2a7f62))
203
+
204
+
205
+ ### Dependencies
206
+
207
+ * The following workspace dependencies were updated
208
+ * dependencies
209
+ * @twin.org/api-core bumped from 0.0.3-next.8 to 0.0.3-next.9
210
+ * @twin.org/api-models bumped from 0.0.3-next.8 to 0.0.3-next.9
211
+
212
+ ## [0.0.3-next.8](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.7...api-rest-client-v0.0.3-next.8) (2025-12-17)
213
+
214
+
215
+ ### Bug Fixes
216
+
217
+ * not supported error handling ([5cc1a50](https://github.com/twinfoundation/api/commit/5cc1a507243f37fda5855acb622b2a3f4d91080f))
218
+
219
+
220
+ ### Dependencies
221
+
222
+ * The following workspace dependencies were updated
223
+ * dependencies
224
+ * @twin.org/api-core bumped from 0.0.3-next.7 to 0.0.3-next.8
225
+ * @twin.org/api-models bumped from 0.0.3-next.7 to 0.0.3-next.8
226
+
227
+ ## [0.0.3-next.7](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.6...api-rest-client-v0.0.3-next.7) (2025-11-26)
228
+
229
+
230
+ ### Miscellaneous Chores
231
+
232
+ * **api-rest-client:** Synchronize repo versions
233
+
234
+
235
+ ### Dependencies
236
+
237
+ * The following workspace dependencies were updated
238
+ * dependencies
239
+ * @twin.org/api-core bumped from 0.0.3-next.6 to 0.0.3-next.7
240
+ * @twin.org/api-models bumped from 0.0.3-next.6 to 0.0.3-next.7
241
+
242
+ ## [0.0.3-next.6](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.5...api-rest-client-v0.0.3-next.6) (2025-11-20)
243
+
244
+
245
+ ### Miscellaneous Chores
246
+
247
+ * **api-rest-client:** Synchronize repo versions
248
+
249
+
250
+ ### Dependencies
251
+
252
+ * The following workspace dependencies were updated
253
+ * dependencies
254
+ * @twin.org/api-core bumped from 0.0.3-next.5 to 0.0.3-next.6
255
+ * @twin.org/api-models bumped from 0.0.3-next.5 to 0.0.3-next.6
256
+
257
+ ## [0.0.3-next.5](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.4...api-rest-client-v0.0.3-next.5) (2025-11-14)
258
+
259
+
260
+ ### Miscellaneous Chores
261
+
262
+ * **api-rest-client:** Synchronize repo versions
263
+
264
+
265
+ ### Dependencies
266
+
267
+ * The following workspace dependencies were updated
268
+ * dependencies
269
+ * @twin.org/api-core bumped from 0.0.3-next.4 to 0.0.3-next.5
270
+ * @twin.org/api-models bumped from 0.0.3-next.4 to 0.0.3-next.5
271
+
272
+ ## [0.0.3-next.4](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.3...api-rest-client-v0.0.3-next.4) (2025-11-14)
273
+
274
+
275
+ ### Features
276
+
277
+ * add context id features ([#42](https://github.com/twinfoundation/api/issues/42)) ([0186055](https://github.com/twinfoundation/api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
278
+ * add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
279
+ * add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
280
+ * eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
281
+ * update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
282
+ * update framework core ([d8eebf2](https://github.com/twinfoundation/api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
283
+ * update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
284
+ * use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
285
+
286
+
287
+ ### Bug Fixes
288
+
289
+ * use correct format for log messaging ([1d28474](https://github.com/twinfoundation/api/commit/1d284744589aa7875327ccc053446f655f2a7f62))
290
+
291
+
292
+ ### Dependencies
293
+
294
+ * The following workspace dependencies were updated
295
+ * dependencies
296
+ * @twin.org/api-core bumped from 0.0.3-next.3 to 0.0.3-next.4
297
+ * @twin.org/api-models bumped from 0.0.3-next.3 to 0.0.3-next.4
298
+
299
+ ## [0.0.3-next.3](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.2...api-rest-client-v0.0.3-next.3) (2025-11-14)
300
+
301
+
302
+ ### Miscellaneous Chores
303
+
304
+ * **api-rest-client:** Synchronize repo versions
305
+
306
+
307
+ ### Dependencies
308
+
309
+ * The following workspace dependencies were updated
310
+ * dependencies
311
+ * @twin.org/api-core bumped from 0.0.3-next.2 to 0.0.3-next.3
312
+ * @twin.org/api-models bumped from 0.0.3-next.2 to 0.0.3-next.3
2
313
 
3
314
  ## [0.0.3-next.2](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.1...api-rest-client-v0.0.3-next.2) (2025-11-12)
4
315
 
package/docs/examples.md CHANGED
@@ -1 +1,64 @@
1
- # @twin.org/api-rest-client - Examples
1
+ # Rest Client Examples
2
+
3
+ Use these snippets to call health, metadata, and specification endpoints from operational tools and integration tests.
4
+
5
+ ## InformationRestClient
6
+
7
+ ```typescript
8
+ import { InformationRestClient } from '@twin.org/api-rest-client';
9
+
10
+ const client = new InformationRestClient({
11
+ endpoint: 'https://api.example.org',
12
+ pathPrefix: 'v1'
13
+ });
14
+
15
+ console.log(client.className()); // InformationRestClient
16
+
17
+ const root = await client.root();
18
+ const info = await client.info();
19
+ const icon = await client.favicon();
20
+
21
+ console.log(root); // twin-api - 1.2.0
22
+ console.log(info.version); // 1.2.0
23
+ console.log((icon?.byteLength ?? 0) > 0); // true
24
+ ```
25
+
26
+ ```typescript
27
+ import { InformationRestClient } from '@twin.org/api-rest-client';
28
+
29
+ const client = new InformationRestClient({
30
+ endpoint: 'https://api.example.org',
31
+ pathPrefix: 'v1'
32
+ });
33
+
34
+ const openApi = await client.spec();
35
+ const live = await client.livez();
36
+ const health = await client.health();
37
+
38
+ console.log(typeof openApi); // object
39
+ console.log(live); // true
40
+ console.log(health.status); // ok
41
+ ```
42
+
43
+ ```typescript
44
+ import { InformationRestClient } from '@twin.org/api-rest-client';
45
+
46
+ const client = new InformationRestClient({
47
+ endpoint: 'https://api.example.org',
48
+ pathPrefix: 'v1'
49
+ });
50
+
51
+ try {
52
+ await client.setComponentHealth('database', 'ok');
53
+ } catch (err) {
54
+ const errorName = err instanceof Error ? err.name : 'Error';
55
+ console.log(errorName); // NotSupportedError
56
+ }
57
+
58
+ try {
59
+ await client.removeComponentHealth('database');
60
+ } catch (err) {
61
+ const errorName = err instanceof Error ? err.name : 'Error';
62
+ console.log(errorName); // NotSupportedError
63
+ }
64
+ ```
@@ -44,6 +44,72 @@ Runtime name for the class.
44
44
 
45
45
  ## Methods
46
46
 
47
+ ### getEndpointWithPrefix()
48
+
49
+ > **getEndpointWithPrefix**(): `string`
50
+
51
+ Get the endpoint with the prefix for the namespace.
52
+
53
+ #### Returns
54
+
55
+ `string`
56
+
57
+ The endpoint with namespace prefix attached.
58
+
59
+ #### Inherited from
60
+
61
+ `BaseRestClient.getEndpointWithPrefix`
62
+
63
+ ***
64
+
65
+ ### fetch()
66
+
67
+ > **fetch**\<`T`, `U`\>(`route`, `method`, `request?`): `Promise`\<`U`\>
68
+
69
+ Perform a request in json format.
70
+
71
+ #### Type Parameters
72
+
73
+ ##### T
74
+
75
+ `T` *extends* `IHttpRequest`\<`any`\>
76
+
77
+ ##### U
78
+
79
+ `U` *extends* `IHttpResponse`\<`any`\>
80
+
81
+ #### Parameters
82
+
83
+ ##### route
84
+
85
+ `string`
86
+
87
+ The route of the request.
88
+
89
+ ##### method
90
+
91
+ `HttpMethod`
92
+
93
+ The http method.
94
+
95
+ ##### request?
96
+
97
+ `T`
98
+
99
+ Request to send to the endpoint.
100
+
101
+ #### Returns
102
+
103
+ `Promise`\<`U`\>
104
+
105
+ The response.
106
+
107
+ #### Inherited from
108
+
109
+ `BaseRestClient.fetch`
110
+
111
+ ***
112
+
47
113
  ### className()
48
114
 
49
115
  > **className**(): `string`
@@ -134,6 +200,24 @@ The OpenAPI spec.
134
200
 
135
201
  ***
136
202
 
203
+ ### livez()
204
+
205
+ > **livez**(): `Promise`\<`boolean`\>
206
+
207
+ Is the server live.
208
+
209
+ #### Returns
210
+
211
+ `Promise`\<`boolean`\>
212
+
213
+ True if the server is live.
214
+
215
+ #### Implementation of
216
+
217
+ `IInformationComponent.livez`
218
+
219
+ ***
220
+
137
221
  ### health()
138
222
 
139
223
  > **health**(): `Promise`\<`IHealthInfo`\>
package/locales/en.json CHANGED
@@ -1 +1,7 @@
1
- {}
1
+ {
2
+ "error": {
3
+ "informationRestClient": {
4
+ "notSupportedOnClient": "The method \"{methodName}\" is not supported on the REST client, it can only be used on a server side component"
5
+ }
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/api-rest-client",
3
- "version": "0.0.3-next.2",
4
- "description": "Information contract implementation which can connect to REST endpoints",
3
+ "version": "0.0.3-next.21",
4
+ "description": "REST client implementation for consuming information and hosting endpoints.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/api.git",
@@ -14,8 +14,8 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-core": "0.0.3-next.2",
18
- "@twin.org/api-models": "0.0.3-next.2",
17
+ "@twin.org/api-core": "0.0.3-next.21",
18
+ "@twin.org/api-models": "0.0.3-next.21",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/nameof": "next",
21
21
  "@twin.org/web": "next"