@twin.org/api-rest-client 0.0.3-next.7 → 0.0.3-next.9
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/dist/es/informationRestClient.js +14 -2
- package/dist/es/informationRestClient.js.map +1 -1
- package/dist/types/informationRestClient.d.ts +5 -0
- package/docs/changelog.md +44 -0
- package/docs/reference/classes/InformationRestClient.md +18 -0
- package/locales/en.json +7 -1
- package/package.json +3 -3
|
@@ -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, "
|
|
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, "
|
|
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,oBAAoB,CAAC;
|
|
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;IACI,MAAM,CAAU,UAAU,2BAA2C;IAE5E;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,0BAAkC,MAAM,EAAE,EAAE,CAAC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,qBAAqB,CAAC,UAAU,CAAC;IACzC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,IAAI;QAChB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAyC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,IAAI;QAChB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAyC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC1F,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,OAAO;QACnB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,cAAc,EACd,KAAK,CACL,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,IAAI;QAChB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAyC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC1F,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,KAAK;QACjB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAA0C,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC5F,OAAO,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,MAAM;QAClB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAA2C,SAAS,EAAE,KAAK,CAAC,CAAC;QAC9F,OAAO,QAAQ,CAAC,IAAI,CAAC;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,5 +1,49 @@
|
|
|
1
1
|
# @twin.org/api-rest-client - Changelog
|
|
2
2
|
|
|
3
|
+
## [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)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add context id features ([#42](https://github.com/twinfoundation/api/issues/42)) ([0186055](https://github.com/twinfoundation/api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
|
|
9
|
+
* add livez endpoint ([#57](https://github.com/twinfoundation/api/issues/57)) ([ef007db](https://github.com/twinfoundation/api/commit/ef007db8201736dd3053211f849ffd03baaa485e))
|
|
10
|
+
* add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
|
|
11
|
+
* add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
|
|
12
|
+
* eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
|
|
13
|
+
* update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
14
|
+
* update framework core ([d8eebf2](https://github.com/twinfoundation/api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
|
|
15
|
+
* update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
|
|
16
|
+
* use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* not supported error handling ([5cc1a50](https://github.com/twinfoundation/api/commit/5cc1a507243f37fda5855acb622b2a3f4d91080f))
|
|
22
|
+
* use correct format for log messaging ([1d28474](https://github.com/twinfoundation/api/commit/1d284744589aa7875327ccc053446f655f2a7f62))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/api-core bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
30
|
+
* @twin.org/api-models bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
31
|
+
|
|
32
|
+
## [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)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* not supported error handling ([5cc1a50](https://github.com/twinfoundation/api/commit/5cc1a507243f37fda5855acb622b2a3f4d91080f))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Dependencies
|
|
41
|
+
|
|
42
|
+
* The following workspace dependencies were updated
|
|
43
|
+
* dependencies
|
|
44
|
+
* @twin.org/api-core bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
45
|
+
* @twin.org/api-models bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
46
|
+
|
|
3
47
|
## [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)
|
|
4
48
|
|
|
5
49
|
|
|
@@ -134,6 +134,24 @@ The OpenAPI spec.
|
|
|
134
134
|
|
|
135
135
|
***
|
|
136
136
|
|
|
137
|
+
### livez()
|
|
138
|
+
|
|
139
|
+
> **livez**(): `Promise`\<`boolean`\>
|
|
140
|
+
|
|
141
|
+
Is the server live.
|
|
142
|
+
|
|
143
|
+
#### Returns
|
|
144
|
+
|
|
145
|
+
`Promise`\<`boolean`\>
|
|
146
|
+
|
|
147
|
+
True if the server is live.
|
|
148
|
+
|
|
149
|
+
#### Implementation of
|
|
150
|
+
|
|
151
|
+
`IInformationComponent.livez`
|
|
152
|
+
|
|
153
|
+
***
|
|
154
|
+
|
|
137
155
|
### health()
|
|
138
156
|
|
|
139
157
|
> **health**(): `Promise`\<`IHealthInfo`\>
|
package/locales/en.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/api-rest-client",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.9",
|
|
4
4
|
"description": "Information contract implementation which can connect to REST endpoints",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "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.
|
|
18
|
-
"@twin.org/api-models": "0.0.3-next.
|
|
17
|
+
"@twin.org/api-core": "0.0.3-next.9",
|
|
18
|
+
"@twin.org/api-models": "0.0.3-next.9",
|
|
19
19
|
"@twin.org/core": "next",
|
|
20
20
|
"@twin.org/nameof": "next",
|
|
21
21
|
"@twin.org/web": "next"
|