@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,321 @@
1
+ # Class: UrlTransformerService
2
+
3
+ The URL transformer service for encrypting and decrypting URL parameters.
4
+
5
+ ## Implements
6
+
7
+ - `IUrlTransformerComponent`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new UrlTransformerService**(`options?`): `UrlTransformerService`
14
+
15
+ Create a new instance of UrlTransformerService.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`IUrlTransformerServiceConstructorOptions`](../interfaces/IUrlTransformerServiceConstructorOptions.md)
22
+
23
+ The options to create the service.
24
+
25
+ #### Returns
26
+
27
+ `UrlTransformerService`
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
+ `IUrlTransformerComponent.className`
54
+
55
+ ***
56
+
57
+ ### start() {#start}
58
+
59
+ > **start**(): `Promise`\<`void`\>
60
+
61
+ The component needs to be started when the node is initialized.
62
+
63
+ #### Returns
64
+
65
+ `Promise`\<`void`\>
66
+
67
+ Nothing.
68
+
69
+ #### Implementation of
70
+
71
+ `IUrlTransformerComponent.start`
72
+
73
+ ***
74
+
75
+ ### addEncryptedQueryParamToUrl() {#addencryptedqueryparamtourl}
76
+
77
+ > **addEncryptedQueryParamToUrl**(`url`, `id`, `value`): `Promise`\<`string`\>
78
+
79
+ Encrypt a named token value and append it as a query parameter to the given URL.
80
+
81
+ #### Parameters
82
+
83
+ ##### url
84
+
85
+ `string`
86
+
87
+ The URL to append the encrypted token to.
88
+
89
+ ##### id
90
+
91
+ `string`
92
+
93
+ The logical token identifier (e.g. "tenant").
94
+
95
+ ##### value
96
+
97
+ `string`
98
+
99
+ The value to encrypt and add.
100
+
101
+ #### Returns
102
+
103
+ `Promise`\<`string`\>
104
+
105
+ The URL with the encrypted token added as a query parameter.
106
+
107
+ #### Implementation of
108
+
109
+ `IUrlTransformerComponent.addEncryptedQueryParamToUrl`
110
+
111
+ ***
112
+
113
+ ### getEncryptedQueryParam() {#getencryptedqueryparam}
114
+
115
+ > **getEncryptedQueryParam**(`queryParams`, `id`): `Promise`\<`string` \| `undefined`\>
116
+
117
+ Get a named token value from the query parameters.
118
+
119
+ #### Parameters
120
+
121
+ ##### queryParams
122
+
123
+ `IHttpRequestQuery` \| `undefined`
124
+
125
+ The HTTP request query containing the parameters.
126
+
127
+ ##### id
128
+
129
+ `string`
130
+
131
+ The logical token identifier (e.g. "tenant").
132
+
133
+ #### Returns
134
+
135
+ `Promise`\<`string` \| `undefined`\>
136
+
137
+ The decrypted token value if it exists.
138
+
139
+ #### Implementation of
140
+
141
+ `IUrlTransformerComponent.getEncryptedQueryParam`
142
+
143
+ ***
144
+
145
+ ### addEncryptedParamsToUrl() {#addencryptedparamstourl}
146
+
147
+ > **addEncryptedParamsToUrl**(`url`, `params`): `Promise`\<`string`\>
148
+
149
+ Add encrypted key/value pairs to a URL's query string.
150
+
151
+ #### Parameters
152
+
153
+ ##### url
154
+
155
+ `string`
156
+
157
+ The base URL to add parameters to.
158
+
159
+ ##### params
160
+
161
+ `IHttpRequestQuery`
162
+
163
+ The key/value pairs to encrypt and append.
164
+
165
+ #### Returns
166
+
167
+ `Promise`\<`string`\>
168
+
169
+ The URL with the encrypted parameters added.
170
+
171
+ #### Implementation of
172
+
173
+ `IUrlTransformerComponent.addEncryptedParamsToUrl`
174
+
175
+ ***
176
+
177
+ ### getDecryptedParamsFromQueryParams() {#getdecryptedparamsfromqueryparams}
178
+
179
+ > **getDecryptedParamsFromQueryParams**(`queryParams`, `keys`): `Promise`\<`IHttpRequestQuery`\>
180
+
181
+ Decrypt specified keys from a query parameter object and return their plain-text values.
182
+
183
+ #### Parameters
184
+
185
+ ##### queryParams
186
+
187
+ `IHttpRequestQuery` \| `undefined`
188
+
189
+ The HTTP request query containing the encrypted parameters.
190
+
191
+ ##### keys
192
+
193
+ `string`[]
194
+
195
+ The keys to decrypt.
196
+
197
+ #### Returns
198
+
199
+ `Promise`\<`IHttpRequestQuery`\>
200
+
201
+ A map of the decrypted key/value pairs that were present.
202
+
203
+ #### Implementation of
204
+
205
+ `IUrlTransformerComponent.getDecryptedParamsFromQueryParams`
206
+
207
+ ***
208
+
209
+ ### encryptQueryParams() {#encryptqueryparams}
210
+
211
+ > **encryptQueryParams**(`httpRequestQuery`, `keys`): `Promise`\<`void`\>
212
+
213
+ Encrypt query parameters.
214
+
215
+ #### Parameters
216
+
217
+ ##### httpRequestQuery
218
+
219
+ `IHttpRequestQuery` \| `undefined`
220
+
221
+ The HTTP request query containing the parameters to encrypt.
222
+
223
+ ##### keys
224
+
225
+ `string`[]
226
+
227
+ The keys of the parameters to encrypt.
228
+
229
+ #### Returns
230
+
231
+ `Promise`\<`void`\>
232
+
233
+ A promise that resolves when the query parameters have been encrypted.
234
+
235
+ #### Implementation of
236
+
237
+ `IUrlTransformerComponent.encryptQueryParams`
238
+
239
+ ***
240
+
241
+ ### decryptQueryParams() {#decryptqueryparams}
242
+
243
+ > **decryptQueryParams**(`httpRequestQuery`, `keys`): `Promise`\<`void`\>
244
+
245
+ Decrypt query parameters.
246
+
247
+ #### Parameters
248
+
249
+ ##### httpRequestQuery
250
+
251
+ `IHttpRequestQuery` \| `undefined`
252
+
253
+ The HTTP request query containing the encrypted values.
254
+
255
+ ##### keys
256
+
257
+ `string`[]
258
+
259
+ The keys of the parameters to decrypt.
260
+
261
+ #### Returns
262
+
263
+ `Promise`\<`void`\>
264
+
265
+ A promise that resolves when the query parameters have been decrypted.
266
+
267
+ #### Implementation of
268
+
269
+ `IUrlTransformerComponent.decryptQueryParams`
270
+
271
+ ***
272
+
273
+ ### encryptParam() {#encryptparam}
274
+
275
+ > **encryptParam**(`paramValue`): `Promise`\<`string`\>
276
+
277
+ Encrypt a parameter value.
278
+
279
+ #### Parameters
280
+
281
+ ##### paramValue
282
+
283
+ `string`
284
+
285
+ The value of the parameter to encrypt.
286
+
287
+ #### Returns
288
+
289
+ `Promise`\<`string`\>
290
+
291
+ A promise that resolves to the encrypted value of the parameter.
292
+
293
+ #### Implementation of
294
+
295
+ `IUrlTransformerComponent.encryptParam`
296
+
297
+ ***
298
+
299
+ ### decryptParam() {#decryptparam}
300
+
301
+ > **decryptParam**(`encryptedValue`): `Promise`\<`string`\>
302
+
303
+ Decrypt a parameter value.
304
+
305
+ #### Parameters
306
+
307
+ ##### encryptedValue
308
+
309
+ `string`
310
+
311
+ The encrypted value of the parameter.
312
+
313
+ #### Returns
314
+
315
+ `Promise`\<`string`\>
316
+
317
+ A promise that resolves to the decrypted value of the parameter.
318
+
319
+ #### Implementation of
320
+
321
+ `IUrlTransformerComponent.decryptParam`
@@ -0,0 +1,25 @@
1
+ # Function: generateRestRoutesHealth()
2
+
3
+ > **generateRestRoutesHealth**(`baseRouteName`, `componentName`): `IRestRoute`\<`any`, `any`\>[]
4
+
5
+ The REST routes for server health.
6
+
7
+ ## Parameters
8
+
9
+ ### baseRouteName
10
+
11
+ `string`
12
+
13
+ Prefix to prepend to the paths.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes stored in the ComponentFactory.
20
+
21
+ ## Returns
22
+
23
+ `IRestRoute`\<`any`, `any`\>[]
24
+
25
+ The generated routes.
@@ -0,0 +1,31 @@
1
+ # Function: serverReadyz()
2
+
3
+ > **serverReadyz**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`IServerReadyzResponse`\>
4
+
5
+ Get the readyz for the server.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `INoContentRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`IServerReadyzResponse`\>
30
+
31
+ The response object with additional http response properties.
@@ -2,27 +2,36 @@
2
2
 
3
3
  ## Classes
4
4
 
5
+ - [HealthService](classes/HealthService.md)
5
6
  - [HostingService](classes/HostingService.md)
6
7
  - [InformationService](classes/InformationService.md)
8
+ - [UrlTransformerService](classes/UrlTransformerService.md)
7
9
 
8
10
  ## Interfaces
9
11
 
12
+ - [IHealthServiceConfig](interfaces/IHealthServiceConfig.md)
13
+ - [IHealthServiceConstructorOptions](interfaces/IHealthServiceConstructorOptions.md)
10
14
  - [IHostingServiceConfig](interfaces/IHostingServiceConfig.md)
11
15
  - [IHostingServiceConstructorOptions](interfaces/IHostingServiceConstructorOptions.md)
12
16
  - [IInformationServiceConfig](interfaces/IInformationServiceConfig.md)
13
17
  - [IInformationServiceConstructorOptions](interfaces/IInformationServiceConstructorOptions.md)
18
+ - [IUrlTransformerServiceConfig](interfaces/IUrlTransformerServiceConfig.md)
19
+ - [IUrlTransformerServiceConstructorOptions](interfaces/IUrlTransformerServiceConstructorOptions.md)
14
20
 
15
21
  ## Variables
16
22
 
23
+ - [tagsHealth](variables/tagsHealth.md)
17
24
  - [tagsInformation](variables/tagsInformation.md)
18
25
  - [restEntryPoints](variables/restEntryPoints.md)
19
26
 
20
27
  ## Functions
21
28
 
29
+ - [generateRestRoutesHealth](functions/generateRestRoutesHealth.md)
30
+ - [serverHealth](functions/serverHealth.md)
22
31
  - [generateRestRoutesInformation](functions/generateRestRoutesInformation.md)
23
32
  - [serverRoot](functions/serverRoot.md)
24
33
  - [serverInfo](functions/serverInfo.md)
25
34
  - [serverLivez](functions/serverLivez.md)
26
- - [serverHealth](functions/serverHealth.md)
35
+ - [serverReadyz](functions/serverReadyz.md)
27
36
  - [serverFavIcon](functions/serverFavIcon.md)
28
37
  - [serverSpec](functions/serverSpec.md)
@@ -0,0 +1,17 @@
1
+ # Interface: IHealthServiceConfig
2
+
3
+ Configuration for the health service.
4
+
5
+ ## Properties
6
+
7
+ ### healthCheckInterval? {#healthcheckinterval}
8
+
9
+ > `optional` **healthCheckInterval?**: `number`
10
+
11
+ The interval for checking the health of the components and setting it in the health service.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ 30000
17
+ ```
@@ -0,0 +1,11 @@
1
+ # Interface: IHealthServiceConstructorOptions
2
+
3
+ Options for the HealthService constructor.
4
+
5
+ ## Properties
6
+
7
+ ### config? {#config}
8
+
9
+ > `optional` **config?**: [`IHealthServiceConfig`](IHealthServiceConfig.md)
10
+
11
+ The configuration for the service.
@@ -1,6 +1,6 @@
1
1
  # Interface: IHostingServiceConstructorOptions
2
2
 
3
- Options for the IHostingService constructor.
3
+ Options for the HostingService constructor.
4
4
 
5
5
  ## Properties
6
6
 
@@ -0,0 +1,32 @@
1
+ # Interface: IUrlTransformerServiceConfig
2
+
3
+ Configuration for the URL transformer service.
4
+
5
+ ## Properties
6
+
7
+ ### paramEncryptionKeyName? {#paramencryptionkeyname}
8
+
9
+ > `optional` **paramEncryptionKeyName?**: `string`
10
+
11
+ The name of the key to retrieve from the vault for encryption/decryption of parameters.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ param-encryption
17
+ ```
18
+
19
+ ***
20
+
21
+ ### queryParamNames? {#queryparamnames}
22
+
23
+ > `optional` **queryParamNames?**: `object`
24
+
25
+ A dictionary mapping logical token identifiers to their URL query parameter names.
26
+ For example: { "tenant": "tenant-token" } maps the logical id "tenant" to the
27
+ query param "tenant-token". When an id is not present the id itself is used as
28
+ the param name.
29
+
30
+ #### Index Signature
31
+
32
+ \[`id`: `string`\]: `string`
@@ -0,0 +1,25 @@
1
+ # Interface: IUrlTransformerServiceConstructorOptions
2
+
3
+ Options for the UrlTransformerService constructor.
4
+
5
+ ## Properties
6
+
7
+ ### vaultConnectorType? {#vaultconnectortype}
8
+
9
+ > `optional` **vaultConnectorType?**: `string`
10
+
11
+ The vault connector type.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ vault
17
+ ```
18
+
19
+ ***
20
+
21
+ ### config? {#config}
22
+
23
+ > `optional` **config?**: [`IUrlTransformerServiceConfig`](IUrlTransformerServiceConfig.md)
24
+
25
+ The configuration for the service.
@@ -0,0 +1,5 @@
1
+ # Variable: tagsHealth
2
+
3
+ > `const` **tagsHealth**: `ITag`[]
4
+
5
+ The tag to associate with the routes.
package/locales/en.json CHANGED
@@ -1 +1,13 @@
1
- {}
1
+ {
2
+ "error": {
3
+ "urlTransformerService": {
4
+ "encryptionUnavailable": "Encryption is unavailable because no nodeId is configured",
5
+ "decryptionUnavailable": "Decryption is unavailable because no nodeId is configured",
6
+ "encryptionFailed": "An error occurred during encryption",
7
+ "decryptionFailed": "An error occurred during decryption"
8
+ },
9
+ "healthService": {
10
+ "componentHealthCheckFailed": "Health check failed for component \"{className}\""
11
+ }
12
+ }
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-service",
3
- "version": "0.0.3-next.28",
3
+ "version": "0.0.3-next.30",
4
4
  "description": "Information and hosting service implementations with generated REST route handlers.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,10 +14,13 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-models": "0.0.3-next.28",
17
+ "@twin.org/api-models": "0.0.3-next.30",
18
18
  "@twin.org/context": "next",
19
19
  "@twin.org/core": "next",
20
+ "@twin.org/engine-models": "next",
21
+ "@twin.org/logging-models": "next",
20
22
  "@twin.org/nameof": "next",
23
+ "@twin.org/vault-models": "next",
21
24
  "@twin.org/web": "next"
22
25
  },
23
26
  "main": "./dist/es/index.js",