@twin.org/api-rest-client 0.0.3-next.29 → 0.0.3-next.30

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.
@@ -0,0 +1,35 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { BaseRestClient } from "@twin.org/api-core";
4
+ /**
5
+ * The client to connect to the health service.
6
+ */
7
+ export class HealthRestClient extends BaseRestClient {
8
+ /**
9
+ * Runtime name for the class.
10
+ */
11
+ static CLASS_NAME = "HealthRestClient";
12
+ /**
13
+ * Create a new instance of HealthRestClient.
14
+ * @param config The configuration for the client.
15
+ */
16
+ constructor(config) {
17
+ super("HealthRestClient", config, "");
18
+ }
19
+ /**
20
+ * Returns the class name of the component.
21
+ * @returns The class name of the component.
22
+ */
23
+ className() {
24
+ return HealthRestClient.CLASS_NAME;
25
+ }
26
+ /**
27
+ * Get the server health.
28
+ * @returns The service health.
29
+ */
30
+ async healthStatus() {
31
+ const response = await this.fetch("/health", "GET");
32
+ return response.body;
33
+ }
34
+ }
35
+ //# sourceMappingURL=healthRestClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"healthRestClient.js","sourceRoot":"","sources":["../../src/healthRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAUpD;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IACnD;;OAEG;IACI,MAAM,CAAU,UAAU,sBAAsC;IAEvE;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,qBAA6B,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,gBAAgB,CAAC,UAAU,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,YAAY;QAIxB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAA2C,SAAS,EAAE,KAAK,CAAC,CAAC;QAC9F,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type {\n\tIBaseRestClientConfig,\n\tIHealthComponent,\n\tINoContentRequest,\n\tIServerHealthResponse\n} from \"@twin.org/api-models\";\nimport type { HealthStatus, IHealth } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * The client to connect to the health service.\n */\nexport class HealthRestClient extends BaseRestClient implements IHealthComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<HealthRestClient>();\n\n\t/**\n\t * Create a new instance of HealthRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<HealthRestClient>(), 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 HealthRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Get the server health.\n\t * @returns The service health.\n\t */\n\tpublic async healthStatus(): Promise<{\n\t\tstatus: HealthStatus;\n\t\tcomponents: IHealth[];\n\t}> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerHealthResponse>(\"/health\", \"GET\");\n\t\treturn response.body;\n\t}\n}\n"]}
package/dist/es/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // Copyright 2024 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./healthRestClient.js";
3
4
  export * from "./informationRestClient.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,4BAA4B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./informationRestClient.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./healthRestClient.js\";\nexport * from \"./informationRestClient.js\";\n"]}
@@ -1,7 +1,6 @@
1
1
  // Copyright 2024 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
3
  import { BaseRestClient } from "@twin.org/api-core";
4
- import { NotSupportedError } from "@twin.org/core";
5
4
  /**
6
5
  * The client to connect to the information service.
7
6
  */
@@ -62,37 +61,15 @@ export class InformationRestClient extends BaseRestClient {
62
61
  */
63
62
  async livez() {
64
63
  const response = await this.fetch("/livez", "GET");
65
- return response.body === "ok";
64
+ return { status: response.body };
66
65
  }
67
66
  /**
68
- * Get the server health.
69
- * @returns The service health.
67
+ * Is the server ready.
68
+ * @returns True if the server is ready.
70
69
  */
71
- async health() {
72
- const response = await this.fetch("/health", "GET");
73
- return response.body;
74
- }
75
- /**
76
- * Set the status of a component.
77
- * @param name The component name.
78
- * @param status The status of the component.
79
- * @param details The details for the status.
80
- * @returns Nothing.
81
- */
82
- async setComponentHealth(name, status, details) {
83
- throw new NotSupportedError(InformationRestClient.CLASS_NAME, "notSupportedOnClient", {
84
- methodName: "setComponentHealth"
85
- });
86
- }
87
- /**
88
- * Remove the status of a component.
89
- * @param name The component name.
90
- * @returns Nothing.
91
- */
92
- async removeComponentHealth(name) {
93
- throw new NotSupportedError(InformationRestClient.CLASS_NAME, "notSupportedOnClient", {
94
- methodName: "removeComponentHealth"
95
- });
70
+ async readyz() {
71
+ const response = await this.fetch("/readyz", "GET");
72
+ return { status: response.body };
96
73
  }
97
74
  }
98
75
  //# 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;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"]}
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;;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,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IAClC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,MAAM;QAClB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAA2C,SAAS,EAAE,KAAK,CAAC,CAAC;QAC9F,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IAClC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type {\n\tIBaseRestClientConfig,\n\tIInformationComponent,\n\tINoContentRequest,\n\tIServerFavIconResponse,\n\tIServerInfo,\n\tIServerInfoResponse,\n\tIServerLivezResponse,\n\tIServerReadyzResponse,\n\tIServerRootResponse,\n\tIServerSpecResponse\n} from \"@twin.org/api-models\";\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<{ status: \"alive\" | \"dead\" }> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerLivezResponse>(\"/livez\", \"GET\");\n\t\treturn { status: response.body };\n\t}\n\n\t/**\n\t * Is the server ready.\n\t * @returns True if the server is ready.\n\t */\n\tpublic async readyz(): Promise<{ status: \"ready\" | \"not ready\" }> {\n\t\tconst response = await this.fetch<INoContentRequest, IServerReadyzResponse>(\"/readyz\", \"GET\");\n\t\treturn { status: response.body };\n\t}\n}\n"]}
@@ -0,0 +1,30 @@
1
+ import { BaseRestClient } from "@twin.org/api-core";
2
+ import type { IBaseRestClientConfig, IHealthComponent } from "@twin.org/api-models";
3
+ import type { HealthStatus, IHealth } from "@twin.org/core";
4
+ /**
5
+ * The client to connect to the health service.
6
+ */
7
+ export declare class HealthRestClient extends BaseRestClient implements IHealthComponent {
8
+ /**
9
+ * Runtime name for the class.
10
+ */
11
+ static readonly CLASS_NAME: string;
12
+ /**
13
+ * Create a new instance of HealthRestClient.
14
+ * @param config The configuration for the client.
15
+ */
16
+ constructor(config: IBaseRestClientConfig);
17
+ /**
18
+ * Returns the class name of the component.
19
+ * @returns The class name of the component.
20
+ */
21
+ className(): string;
22
+ /**
23
+ * Get the server health.
24
+ * @returns The service health.
25
+ */
26
+ healthStatus(): Promise<{
27
+ status: HealthStatus;
28
+ components: IHealth[];
29
+ }>;
30
+ }
@@ -1 +1,2 @@
1
+ export * from "./healthRestClient.js";
1
2
  export * from "./informationRestClient.js";
@@ -1,5 +1,5 @@
1
1
  import { BaseRestClient } from "@twin.org/api-core";
2
- import type { HealthStatus, IBaseRestClientConfig, IHealthInfo, IInformationComponent, IServerInfo } from "@twin.org/api-models";
2
+ import type { IBaseRestClientConfig, IInformationComponent, IServerInfo } from "@twin.org/api-models";
3
3
  /**
4
4
  * The client to connect to the information service.
5
5
  */
@@ -42,24 +42,14 @@ export declare class InformationRestClient extends BaseRestClient implements IIn
42
42
  * Is the server live.
43
43
  * @returns True if the server is live.
44
44
  */
45
- livez(): Promise<boolean>;
45
+ livez(): Promise<{
46
+ status: "alive" | "dead";
47
+ }>;
46
48
  /**
47
- * Get the server health.
48
- * @returns The service health.
49
+ * Is the server ready.
50
+ * @returns True if the server is ready.
49
51
  */
50
- health(): Promise<IHealthInfo>;
51
- /**
52
- * Set the status of a component.
53
- * @param name The component name.
54
- * @param status The status of the component.
55
- * @param details The details for the status.
56
- * @returns Nothing.
57
- */
58
- setComponentHealth(name: string, status: HealthStatus, details?: string): Promise<void>;
59
- /**
60
- * Remove the status of a component.
61
- * @param name The component name.
62
- * @returns Nothing.
63
- */
64
- removeComponentHealth(name: string): Promise<void>;
52
+ readyz(): Promise<{
53
+ status: "ready" | "not ready";
54
+ }>;
65
55
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.30](https://github.com/twinfoundation/twin-api/compare/api-rest-client-v0.0.3-next.29...api-rest-client-v0.0.3-next.30) (2026-05-05)
4
+
5
+
6
+ ### Features
7
+
8
+ * separate service responsibilities ([#116](https://github.com/twinfoundation/twin-api/issues/116)) ([2234648](https://github.com/twinfoundation/twin-api/commit/2234648de4a2de5b7356aadde328f40470bc12e3))
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.29 to 0.0.3-next.30
16
+ * @twin.org/api-models bumped from 0.0.3-next.29 to 0.0.3-next.30
17
+
3
18
  ## [0.0.3-next.29](https://github.com/twinfoundation/twin-api/compare/api-rest-client-v0.0.3-next.28...api-rest-client-v0.0.3-next.29) (2026-05-01)
4
19
 
5
20
 
@@ -0,0 +1,145 @@
1
+ # Class: HealthRestClient
2
+
3
+ The client to connect to the health service.
4
+
5
+ ## Extends
6
+
7
+ - `BaseRestClient`
8
+
9
+ ## Implements
10
+
11
+ - `IHealthComponent`
12
+
13
+ ## Constructors
14
+
15
+ ### Constructor
16
+
17
+ > **new HealthRestClient**(`config`): `HealthRestClient`
18
+
19
+ Create a new instance of HealthRestClient.
20
+
21
+ #### Parameters
22
+
23
+ ##### config
24
+
25
+ `IBaseRestClientConfig`
26
+
27
+ The configuration for the client.
28
+
29
+ #### Returns
30
+
31
+ `HealthRestClient`
32
+
33
+ #### Overrides
34
+
35
+ `BaseRestClient.constructor`
36
+
37
+ ## Properties
38
+
39
+ ### CLASS\_NAME {#class_name}
40
+
41
+ > `readonly` `static` **CLASS\_NAME**: `string`
42
+
43
+ Runtime name for the class.
44
+
45
+ ## Methods
46
+
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}
114
+
115
+ > **className**(): `string`
116
+
117
+ Returns the class name of the component.
118
+
119
+ #### Returns
120
+
121
+ `string`
122
+
123
+ The class name of the component.
124
+
125
+ #### Implementation of
126
+
127
+ `IHealthComponent.className`
128
+
129
+ ***
130
+
131
+ ### healthStatus() {#healthstatus}
132
+
133
+ > **healthStatus**(): `Promise`\<\{ `status`: `HealthStatus`; `components`: `IHealth`[]; \}\>
134
+
135
+ Get the server health.
136
+
137
+ #### Returns
138
+
139
+ `Promise`\<\{ `status`: `HealthStatus`; `components`: `IHealth`[]; \}\>
140
+
141
+ The service health.
142
+
143
+ #### Implementation of
144
+
145
+ `IHealthComponent.healthStatus`
@@ -202,13 +202,13 @@ The OpenAPI spec.
202
202
 
203
203
  ### livez() {#livez}
204
204
 
205
- > **livez**(): `Promise`\<`boolean`\>
205
+ > **livez**(): `Promise`\<\{ `status`: `"alive"` \| `"dead"`; \}\>
206
206
 
207
207
  Is the server live.
208
208
 
209
209
  #### Returns
210
210
 
211
- `Promise`\<`boolean`\>
211
+ `Promise`\<\{ `status`: `"alive"` \| `"dead"`; \}\>
212
212
 
213
213
  True if the server is live.
214
214
 
@@ -218,82 +218,18 @@ True if the server is live.
218
218
 
219
219
  ***
220
220
 
221
- ### health() {#health}
221
+ ### readyz() {#readyz}
222
222
 
223
- > **health**(): `Promise`\<`IHealthInfo`\>
223
+ > **readyz**(): `Promise`\<\{ `status`: `"ready"` \| `"not ready"`; \}\>
224
224
 
225
- Get the server health.
225
+ Is the server ready.
226
226
 
227
227
  #### Returns
228
228
 
229
- `Promise`\<`IHealthInfo`\>
229
+ `Promise`\<\{ `status`: `"ready"` \| `"not ready"`; \}\>
230
230
 
231
- The service health.
231
+ True if the server is ready.
232
232
 
233
233
  #### Implementation of
234
234
 
235
- `IInformationComponent.health`
236
-
237
- ***
238
-
239
- ### setComponentHealth() {#setcomponenthealth}
240
-
241
- > **setComponentHealth**(`name`, `status`, `details?`): `Promise`\<`void`\>
242
-
243
- Set the status of a component.
244
-
245
- #### Parameters
246
-
247
- ##### name
248
-
249
- `string`
250
-
251
- The component name.
252
-
253
- ##### status
254
-
255
- `HealthStatus`
256
-
257
- The status of the component.
258
-
259
- ##### details?
260
-
261
- `string`
262
-
263
- The details for the status.
264
-
265
- #### Returns
266
-
267
- `Promise`\<`void`\>
268
-
269
- Nothing.
270
-
271
- #### Implementation of
272
-
273
- `IInformationComponent.setComponentHealth`
274
-
275
- ***
276
-
277
- ### removeComponentHealth() {#removecomponenthealth}
278
-
279
- > **removeComponentHealth**(`name`): `Promise`\<`void`\>
280
-
281
- Remove the status of a component.
282
-
283
- #### Parameters
284
-
285
- ##### name
286
-
287
- `string`
288
-
289
- The component name.
290
-
291
- #### Returns
292
-
293
- `Promise`\<`void`\>
294
-
295
- Nothing.
296
-
297
- #### Implementation of
298
-
299
- `IInformationComponent.removeComponentHealth`
235
+ `IInformationComponent.readyz`
@@ -2,4 +2,5 @@
2
2
 
3
3
  ## Classes
4
4
 
5
+ - [HealthRestClient](classes/HealthRestClient.md)
5
6
  - [InformationRestClient](classes/InformationRestClient.md)
package/locales/en.json CHANGED
@@ -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
- }
1
+ {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-rest-client",
3
- "version": "0.0.3-next.29",
3
+ "version": "0.0.3-next.30",
4
4
  "description": "REST client implementation for consuming information and hosting 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.29",
18
- "@twin.org/api-models": "0.0.3-next.29",
17
+ "@twin.org/api-core": "0.0.3-next.30",
18
+ "@twin.org/api-models": "0.0.3-next.30",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/nameof": "next",
21
21
  "@twin.org/web": "next"