@twin.org/api-service 0.0.3-next.28 → 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.
Files changed (51) hide show
  1. package/dist/es/healthRoutes.js +108 -0
  2. package/dist/es/healthRoutes.js.map +1 -0
  3. package/dist/es/healthService.js +136 -0
  4. package/dist/es/healthService.js.map +1 -0
  5. package/dist/es/hostingService.js +5 -10
  6. package/dist/es/hostingService.js.map +1 -1
  7. package/dist/es/index.js +7 -0
  8. package/dist/es/index.js.map +1 -1
  9. package/dist/es/informationRoutes.js +31 -65
  10. package/dist/es/informationRoutes.js.map +1 -1
  11. package/dist/es/informationService.js +9 -85
  12. package/dist/es/informationService.js.map +1 -1
  13. package/dist/es/models/IHealthServiceConfig.js +4 -0
  14. package/dist/es/models/IHealthServiceConfig.js.map +1 -0
  15. package/dist/es/models/IHealthServiceConstructorOptions.js +2 -0
  16. package/dist/es/models/IHealthServiceConstructorOptions.js.map +1 -0
  17. package/dist/es/models/IHostingServiceConstructorOptions.js.map +1 -1
  18. package/dist/es/models/IUrlTransformerServiceConfig.js +4 -0
  19. package/dist/es/models/IUrlTransformerServiceConfig.js.map +1 -0
  20. package/dist/es/models/IUrlTransformerServiceConstructorOptions.js +2 -0
  21. package/dist/es/models/IUrlTransformerServiceConstructorOptions.js.map +1 -0
  22. package/dist/es/restEntryPoints.js +7 -0
  23. package/dist/es/restEntryPoints.js.map +1 -1
  24. package/dist/es/urlTransformerService.js +214 -0
  25. package/dist/es/urlTransformerService.js.map +1 -0
  26. package/dist/types/healthRoutes.d.ts +20 -0
  27. package/dist/types/healthService.d.ts +42 -0
  28. package/dist/types/index.d.ts +7 -0
  29. package/dist/types/informationRoutes.d.ts +3 -3
  30. package/dist/types/informationService.d.ts +9 -21
  31. package/dist/types/models/IHealthServiceConfig.d.ts +10 -0
  32. package/dist/types/models/IHealthServiceConstructorOptions.d.ts +10 -0
  33. package/dist/types/models/IHostingServiceConstructorOptions.d.ts +1 -1
  34. package/dist/types/models/IUrlTransformerServiceConfig.d.ts +19 -0
  35. package/dist/types/models/IUrlTransformerServiceConstructorOptions.d.ts +15 -0
  36. package/dist/types/urlTransformerService.d.ts +81 -0
  37. package/docs/changelog.md +28 -0
  38. package/docs/reference/classes/HealthService.md +123 -0
  39. package/docs/reference/classes/InformationService.md +8 -84
  40. package/docs/reference/classes/UrlTransformerService.md +321 -0
  41. package/docs/reference/functions/generateRestRoutesHealth.md +25 -0
  42. package/docs/reference/functions/serverReadyz.md +31 -0
  43. package/docs/reference/index.md +10 -1
  44. package/docs/reference/interfaces/IHealthServiceConfig.md +17 -0
  45. package/docs/reference/interfaces/IHealthServiceConstructorOptions.md +11 -0
  46. package/docs/reference/interfaces/IHostingServiceConstructorOptions.md +1 -1
  47. package/docs/reference/interfaces/IUrlTransformerServiceConfig.md +32 -0
  48. package/docs/reference/interfaces/IUrlTransformerServiceConstructorOptions.md +25 -0
  49. package/docs/reference/variables/tagsHealth.md +5 -0
  50. package/locales/en.json +13 -1
  51. package/package.json +5 -2
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Configuration for the health service.
3
+ */
4
+ export interface IHealthServiceConfig {
5
+ /**
6
+ * The interval for checking the health of the components and setting it in the health service.
7
+ * @default 30000
8
+ */
9
+ healthCheckInterval?: number;
10
+ }
@@ -0,0 +1,10 @@
1
+ import type { IHealthServiceConfig } from "./IHealthServiceConfig.js";
2
+ /**
3
+ * Options for the HealthService constructor.
4
+ */
5
+ export interface IHealthServiceConstructorOptions {
6
+ /**
7
+ * The configuration for the service.
8
+ */
9
+ config?: IHealthServiceConfig;
10
+ }
@@ -1,6 +1,6 @@
1
1
  import type { IHostingServiceConfig } from "./IHostingServiceConfig.js";
2
2
  /**
3
- * Options for the IHostingService constructor.
3
+ * Options for the HostingService constructor.
4
4
  */
5
5
  export interface IHostingServiceConstructorOptions {
6
6
  /**
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Configuration for the URL transformer service.
3
+ */
4
+ export interface IUrlTransformerServiceConfig {
5
+ /**
6
+ * The name of the key to retrieve from the vault for encryption/decryption of parameters.
7
+ * @default param-encryption
8
+ */
9
+ paramEncryptionKeyName?: string;
10
+ /**
11
+ * A dictionary mapping logical token identifiers to their URL query parameter names.
12
+ * For example: { "tenant": "tenant-token" } maps the logical id "tenant" to the
13
+ * query param "tenant-token". When an id is not present the id itself is used as
14
+ * the param name.
15
+ */
16
+ queryParamNames?: {
17
+ [id: string]: string;
18
+ };
19
+ }
@@ -0,0 +1,15 @@
1
+ import type { IUrlTransformerServiceConfig } from "./IUrlTransformerServiceConfig.js";
2
+ /**
3
+ * Options for the UrlTransformerService constructor.
4
+ */
5
+ export interface IUrlTransformerServiceConstructorOptions {
6
+ /**
7
+ * The vault connector type.
8
+ * @default vault
9
+ */
10
+ vaultConnectorType?: string;
11
+ /**
12
+ * The configuration for the service.
13
+ */
14
+ config?: IUrlTransformerServiceConfig;
15
+ }
@@ -0,0 +1,81 @@
1
+ import type { IHttpRequestQuery, IUrlTransformerComponent } from "@twin.org/api-models";
2
+ import type { IUrlTransformerServiceConstructorOptions } from "./models/IUrlTransformerServiceConstructorOptions.js";
3
+ /**
4
+ * The URL transformer service for encrypting and decrypting URL parameters.
5
+ */
6
+ export declare class UrlTransformerService implements IUrlTransformerComponent {
7
+ /**
8
+ * Runtime name for the class.
9
+ */
10
+ static readonly CLASS_NAME: string;
11
+ /**
12
+ * Create a new instance of UrlTransformerService.
13
+ * @param options The options to create the service.
14
+ */
15
+ constructor(options?: IUrlTransformerServiceConstructorOptions);
16
+ /**
17
+ * Returns the class name of the component.
18
+ * @returns The class name of the component.
19
+ */
20
+ className(): string;
21
+ /**
22
+ * The component needs to be started when the node is initialized.
23
+ * @returns Nothing.
24
+ */
25
+ start(): Promise<void>;
26
+ /**
27
+ * Encrypt a named token value and append it as a query parameter to the given URL.
28
+ * @param url The URL to append the encrypted token to.
29
+ * @param id The logical token identifier (e.g. "tenant").
30
+ * @param value The value to encrypt and add.
31
+ * @returns The URL with the encrypted token added as a query parameter.
32
+ */
33
+ addEncryptedQueryParamToUrl(url: string, id: string, value: string): Promise<string>;
34
+ /**
35
+ * Get a named token value from the query parameters.
36
+ * @param queryParams The HTTP request query containing the parameters.
37
+ * @param id The logical token identifier (e.g. "tenant").
38
+ * @returns The decrypted token value if it exists.
39
+ */
40
+ getEncryptedQueryParam(queryParams: IHttpRequestQuery | undefined, id: string): Promise<string | undefined>;
41
+ /**
42
+ * Add encrypted key/value pairs to a URL's query string.
43
+ * @param url The base URL to add parameters to.
44
+ * @param params The key/value pairs to encrypt and append.
45
+ * @returns The URL with the encrypted parameters added.
46
+ */
47
+ addEncryptedParamsToUrl(url: string, params: IHttpRequestQuery): Promise<string>;
48
+ /**
49
+ * Decrypt specified keys from a query parameter object and return their plain-text values.
50
+ * @param queryParams The HTTP request query containing the encrypted parameters.
51
+ * @param keys The keys to decrypt.
52
+ * @returns A map of the decrypted key/value pairs that were present.
53
+ */
54
+ getDecryptedParamsFromQueryParams(queryParams: IHttpRequestQuery | undefined, keys: string[]): Promise<IHttpRequestQuery>;
55
+ /**
56
+ * Encrypt query parameters.
57
+ * @param httpRequestQuery The HTTP request query containing the parameters to encrypt.
58
+ * @param keys The keys of the parameters to encrypt.
59
+ * @returns A promise that resolves when the query parameters have been encrypted.
60
+ */
61
+ encryptQueryParams(httpRequestQuery: IHttpRequestQuery | undefined, keys: string[]): Promise<void>;
62
+ /**
63
+ * Decrypt query parameters.
64
+ * @param httpRequestQuery The HTTP request query containing the encrypted values.
65
+ * @param keys The keys of the parameters to decrypt.
66
+ * @returns A promise that resolves when the query parameters have been decrypted.
67
+ */
68
+ decryptQueryParams(httpRequestQuery: IHttpRequestQuery | undefined, keys: string[]): Promise<void>;
69
+ /**
70
+ * Encrypt a parameter value.
71
+ * @param paramValue The value of the parameter to encrypt.
72
+ * @returns A promise that resolves to the encrypted value of the parameter.
73
+ */
74
+ encryptParam(paramValue: string): Promise<string>;
75
+ /**
76
+ * Decrypt a parameter value.
77
+ * @param encryptedValue The encrypted value of the parameter.
78
+ * @returns A promise that resolves to the decrypted value of the parameter.
79
+ */
80
+ decryptParam(encryptedValue: string): Promise<string>;
81
+ }
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.30](https://github.com/twinfoundation/twin-api/compare/api-service-v0.0.3-next.29...api-service-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-models bumped from 0.0.3-next.29 to 0.0.3-next.30
16
+
17
+ ## [0.0.3-next.29](https://github.com/twinfoundation/twin-api/compare/api-service-v0.0.3-next.28...api-service-v0.0.3-next.29) (2026-05-01)
18
+
19
+
20
+ ### Features
21
+
22
+ * hosting service ([#109](https://github.com/twinfoundation/twin-api/issues/109)) ([985bf1f](https://github.com/twinfoundation/twin-api/commit/985bf1f5c07b09ecb800df7120bc2422ac7a6d25))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/api-models bumped from 0.0.3-next.28 to 0.0.3-next.29
30
+
3
31
  ## [0.0.3-next.28](https://github.com/twinfoundation/twin-api/compare/api-service-v0.0.3-next.27...api-service-v0.0.3-next.28) (2026-04-30)
4
32
 
5
33
 
@@ -0,0 +1,123 @@
1
+ # Class: HealthService
2
+
3
+ The health service for the server.
4
+
5
+ ## Implements
6
+
7
+ - `IHealthComponent`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new HealthService**(`options?`): `HealthService`
14
+
15
+ Create a new instance of HealthService.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`IHealthServiceConstructorOptions`](../interfaces/IHealthServiceConstructorOptions.md)
22
+
23
+ The constructor options.
24
+
25
+ #### Returns
26
+
27
+ `HealthService`
28
+
29
+ ## Properties
30
+
31
+ ### CLASS\_NAME {#class_name}
32
+
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
+
35
+ Runtime name for the class.
36
+
37
+ ## Methods
38
+
39
+ ### className() {#classname}
40
+
41
+ > **className**(): `string`
42
+
43
+ Returns the class name of the component.
44
+
45
+ #### Returns
46
+
47
+ `string`
48
+
49
+ The class name of the component.
50
+
51
+ #### Implementation of
52
+
53
+ `IHealthComponent.className`
54
+
55
+ ***
56
+
57
+ ### start() {#start}
58
+
59
+ > **start**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
60
+
61
+ The component needs to be started when the node is initialized.
62
+
63
+ #### Parameters
64
+
65
+ ##### nodeLoggingComponentType?
66
+
67
+ `string`
68
+
69
+ The node logging component type.
70
+
71
+ #### Returns
72
+
73
+ `Promise`\<`void`\>
74
+
75
+ Nothing.
76
+
77
+ #### Implementation of
78
+
79
+ `IHealthComponent.start`
80
+
81
+ ***
82
+
83
+ ### stop() {#stop}
84
+
85
+ > **stop**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
86
+
87
+ The component needs to be stopped when the node is closed.
88
+
89
+ #### Parameters
90
+
91
+ ##### nodeLoggingComponentType?
92
+
93
+ `string`
94
+
95
+ The node logging component type.
96
+
97
+ #### Returns
98
+
99
+ `Promise`\<`void`\>
100
+
101
+ Nothing.
102
+
103
+ #### Implementation of
104
+
105
+ `IHealthComponent.stop`
106
+
107
+ ***
108
+
109
+ ### healthStatus() {#healthstatus}
110
+
111
+ > **healthStatus**(): `Promise`\<\{ `status`: `HealthStatus`; `components`: `IHealth`[]; \}\>
112
+
113
+ Get the server health.
114
+
115
+ #### Returns
116
+
117
+ `Promise`\<\{ `status`: `HealthStatus`; `components`: `IHealth`[]; \}\>
118
+
119
+ The service health.
120
+
121
+ #### Implementation of
122
+
123
+ `IHealthComponent.healthStatus`
@@ -146,13 +146,13 @@ The OpenAPI spec.
146
146
 
147
147
  ### livez() {#livez}
148
148
 
149
- > **livez**(): `Promise`\<`boolean`\>
149
+ > **livez**(): `Promise`\<\{ `status`: `"alive"` \| `"dead"`; \}\>
150
150
 
151
151
  Is the server live.
152
152
 
153
153
  #### Returns
154
154
 
155
- `Promise`\<`boolean`\>
155
+ `Promise`\<\{ `status`: `"alive"` \| `"dead"`; \}\>
156
156
 
157
157
  True if the server is live.
158
158
 
@@ -162,94 +162,18 @@ True if the server is live.
162
162
 
163
163
  ***
164
164
 
165
- ### health() {#health}
165
+ ### readyz() {#readyz}
166
166
 
167
- > **health**(): `Promise`\<`IHealthInfo`\>
167
+ > **readyz**(): `Promise`\<\{ `status`: `"ready"` \| `"not ready"`; \}\>
168
168
 
169
- Get the server health.
169
+ Is the server ready.
170
170
 
171
171
  #### Returns
172
172
 
173
- `Promise`\<`IHealthInfo`\>
173
+ `Promise`\<\{ `status`: `"ready"` \| `"not ready"`; \}\>
174
174
 
175
- The service health.
175
+ The readyz status of the server.
176
176
 
177
177
  #### Implementation of
178
178
 
179
- `IInformationComponent.health`
180
-
181
- ***
182
-
183
- ### setComponentHealth() {#setcomponenthealth}
184
-
185
- > **setComponentHealth**(`name`, `status`, `details?`, `tenantId?`): `Promise`\<`void`\>
186
-
187
- Set the status of a component.
188
-
189
- #### Parameters
190
-
191
- ##### name
192
-
193
- `string`
194
-
195
- The component name.
196
-
197
- ##### status
198
-
199
- `HealthStatus`
200
-
201
- The status of the component.
202
-
203
- ##### details?
204
-
205
- `string`
206
-
207
- The details for the status.
208
-
209
- ##### tenantId?
210
-
211
- `string`
212
-
213
- The tenant id, optional if the health status is not tenant specific.
214
-
215
- #### Returns
216
-
217
- `Promise`\<`void`\>
218
-
219
- Nothing.
220
-
221
- #### Implementation of
222
-
223
- `IInformationComponent.setComponentHealth`
224
-
225
- ***
226
-
227
- ### removeComponentHealth() {#removecomponenthealth}
228
-
229
- > **removeComponentHealth**(`name`, `tenantId?`): `Promise`\<`void`\>
230
-
231
- Remove the status of a component.
232
-
233
- #### Parameters
234
-
235
- ##### name
236
-
237
- `string`
238
-
239
- The component name.
240
-
241
- ##### tenantId?
242
-
243
- `string`
244
-
245
- The tenant id, optional if the health status is not tenant specific.
246
-
247
- #### Returns
248
-
249
- `Promise`\<`void`\>
250
-
251
- Nothing.
252
-
253
- #### Implementation of
254
-
255
- `IInformationComponent.removeComponentHealth`
179
+ `IInformationComponent.readyz`