@twin.org/api-rest-client 0.0.3-next.20 → 0.0.3-next.22

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
 
package/docs/changelog.md CHANGED
@@ -1,4 +1,34 @@
1
- # @twin.org/api-rest-client - Changelog
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.22](https://github.com/twinfoundation/api/compare/api-rest-client-v0.0.3-next.21...api-rest-client-v0.0.3-next.22) (2026-03-27)
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.21 to 0.0.3-next.22
16
+ * @twin.org/api-models bumped from 0.0.3-next.21 to 0.0.3-next.22
17
+
18
+ ## [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)
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.20 to 0.0.3-next.21
31
+ * @twin.org/api-models bumped from 0.0.3-next.20 to 0.0.3-next.21
2
32
 
3
33
  ## [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)
4
34
 
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
+ ```
@@ -36,7 +36,7 @@ The configuration for the client.
36
36
 
37
37
  ## Properties
38
38
 
39
- ### CLASS\_NAME
39
+ ### CLASS\_NAME {#class_name}
40
40
 
41
41
  > `readonly` `static` **CLASS\_NAME**: `string`
42
42
 
@@ -44,7 +44,73 @@ Runtime name for the class.
44
44
 
45
45
  ## Methods
46
46
 
47
- ### className()
47
+ ### getEndpointWithPrefix() {#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() {#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
+
113
+ ### className() {#classname}
48
114
 
49
115
  > **className**(): `string`
50
116
 
@@ -62,7 +128,7 @@ The class name of the component.
62
128
 
63
129
  ***
64
130
 
65
- ### root()
131
+ ### root() {#root}
66
132
 
67
133
  > **root**(): `Promise`\<`string`\>
68
134
 
@@ -80,7 +146,7 @@ The root root.
80
146
 
81
147
  ***
82
148
 
83
- ### info()
149
+ ### info() {#info}
84
150
 
85
151
  > **info**(): `Promise`\<`IServerInfo`\>
86
152
 
@@ -98,7 +164,7 @@ The service information.
98
164
 
99
165
  ***
100
166
 
101
- ### favicon()
167
+ ### favicon() {#favicon}
102
168
 
103
169
  > **favicon**(): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\> \| `undefined`\>
104
170
 
@@ -116,7 +182,7 @@ The favicon.
116
182
 
117
183
  ***
118
184
 
119
- ### spec()
185
+ ### spec() {#spec}
120
186
 
121
187
  > **spec**(): `Promise`\<`unknown`\>
122
188
 
@@ -134,7 +200,7 @@ The OpenAPI spec.
134
200
 
135
201
  ***
136
202
 
137
- ### livez()
203
+ ### livez() {#livez}
138
204
 
139
205
  > **livez**(): `Promise`\<`boolean`\>
140
206
 
@@ -152,7 +218,7 @@ True if the server is live.
152
218
 
153
219
  ***
154
220
 
155
- ### health()
221
+ ### health() {#health}
156
222
 
157
223
  > **health**(): `Promise`\<`IHealthInfo`\>
158
224
 
@@ -170,7 +236,7 @@ The service health.
170
236
 
171
237
  ***
172
238
 
173
- ### setComponentHealth()
239
+ ### setComponentHealth() {#setcomponenthealth}
174
240
 
175
241
  > **setComponentHealth**(`name`, `status`, `details?`): `Promise`\<`void`\>
176
242
 
@@ -208,7 +274,7 @@ Nothing.
208
274
 
209
275
  ***
210
276
 
211
- ### removeComponentHealth()
277
+ ### removeComponentHealth() {#removecomponenthealth}
212
278
 
213
279
  > **removeComponentHealth**(`name`): `Promise`\<`void`\>
214
280
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/api-rest-client",
3
- "version": "0.0.3-next.20",
4
- "description": "Information contract implementation which can connect to REST endpoints",
3
+ "version": "0.0.3-next.22",
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.20",
18
- "@twin.org/api-models": "0.0.3-next.20",
17
+ "@twin.org/api-core": "0.0.3-next.22",
18
+ "@twin.org/api-models": "0.0.3-next.22",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/nameof": "next",
21
21
  "@twin.org/web": "next"