@twin.org/api-service 0.0.1-next.8 → 0.0.1

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.
@@ -211,21 +211,16 @@ async function serverSpec(httpRequestContext, componentName, request) {
211
211
  };
212
212
  }
213
213
 
214
- const restEntryPoints = [
215
- {
216
- name: "information",
217
- defaultBaseRoute: "",
218
- tags: tagsInformation,
219
- generateRoutes: generateRestRoutesInformation
220
- }
221
- ];
222
-
223
214
  // Copyright 2024 IOTA Stiftung.
224
215
  // SPDX-License-Identifier: Apache-2.0.
225
216
  /**
226
217
  * The information service for the server.
227
218
  */
228
219
  class InformationService {
220
+ /**
221
+ * The namespace supported by the information service.
222
+ */
223
+ static NAMESPACE = "information";
229
224
  /**
230
225
  * Runtime name for the class.
231
226
  */
@@ -252,15 +247,17 @@ class InformationService {
252
247
  _openApiSpec;
253
248
  /**
254
249
  * Create a new instance of InformationService.
255
- * @param serverInfo The server information.
256
- * @param openApiSpecPath The path to the spec file.
250
+ * @param options The options to create the service.
257
251
  */
258
- constructor(serverInfo, openApiSpecPath) {
259
- this._serverInfo = serverInfo;
252
+ constructor(options) {
253
+ core.Guards.object(this.CLASS_NAME, "options", options);
254
+ core.Guards.object(this.CLASS_NAME, "options.config", options.config);
255
+ core.Guards.object(this.CLASS_NAME, "options.config.serverInfo", options.config.serverInfo);
256
+ this._serverInfo = options.config.serverInfo;
260
257
  this._healthInfo = {
261
258
  status: "ok"
262
259
  };
263
- this._openApiSpecPath = openApiSpecPath;
260
+ this._openApiSpecPath = options.config.openApiSpecPath;
264
261
  }
265
262
  /**
266
263
  * The service needs to be started when the application is initialized.
@@ -339,13 +336,22 @@ class InformationService {
339
336
  async removeComponentHealth(name) {
340
337
  if (core.Is.arrayValue(this._healthInfo.components)) {
341
338
  const componentIndex = this._healthInfo.components.findIndex(c => c.name === name);
342
- if (componentIndex >= 0) {
339
+ if (componentIndex !== -1) {
343
340
  this._healthInfo.components.splice(componentIndex, 1);
344
341
  }
345
342
  }
346
343
  }
347
344
  }
348
345
 
346
+ const restEntryPoints = [
347
+ {
348
+ name: "information",
349
+ defaultBaseRoute: "",
350
+ tags: tagsInformation,
351
+ generateRoutes: generateRestRoutesInformation
352
+ }
353
+ ];
354
+
349
355
  exports.InformationService = InformationService;
350
356
  exports.generateRestRoutesInformation = generateRestRoutesInformation;
351
357
  exports.restEntryPoints = restEntryPoints;
@@ -1,4 +1,4 @@
1
- import { ComponentFactory, Is } from '@twin.org/core';
1
+ import { ComponentFactory, Is, Guards } from '@twin.org/core';
2
2
  import { HttpStatusCode } from '@twin.org/web';
3
3
  import { readFile } from 'node:fs/promises';
4
4
 
@@ -209,21 +209,16 @@ async function serverSpec(httpRequestContext, componentName, request) {
209
209
  };
210
210
  }
211
211
 
212
- const restEntryPoints = [
213
- {
214
- name: "information",
215
- defaultBaseRoute: "",
216
- tags: tagsInformation,
217
- generateRoutes: generateRestRoutesInformation
218
- }
219
- ];
220
-
221
212
  // Copyright 2024 IOTA Stiftung.
222
213
  // SPDX-License-Identifier: Apache-2.0.
223
214
  /**
224
215
  * The information service for the server.
225
216
  */
226
217
  class InformationService {
218
+ /**
219
+ * The namespace supported by the information service.
220
+ */
221
+ static NAMESPACE = "information";
227
222
  /**
228
223
  * Runtime name for the class.
229
224
  */
@@ -250,15 +245,17 @@ class InformationService {
250
245
  _openApiSpec;
251
246
  /**
252
247
  * Create a new instance of InformationService.
253
- * @param serverInfo The server information.
254
- * @param openApiSpecPath The path to the spec file.
248
+ * @param options The options to create the service.
255
249
  */
256
- constructor(serverInfo, openApiSpecPath) {
257
- this._serverInfo = serverInfo;
250
+ constructor(options) {
251
+ Guards.object(this.CLASS_NAME, "options", options);
252
+ Guards.object(this.CLASS_NAME, "options.config", options.config);
253
+ Guards.object(this.CLASS_NAME, "options.config.serverInfo", options.config.serverInfo);
254
+ this._serverInfo = options.config.serverInfo;
258
255
  this._healthInfo = {
259
256
  status: "ok"
260
257
  };
261
- this._openApiSpecPath = openApiSpecPath;
258
+ this._openApiSpecPath = options.config.openApiSpecPath;
262
259
  }
263
260
  /**
264
261
  * The service needs to be started when the application is initialized.
@@ -337,11 +334,20 @@ class InformationService {
337
334
  async removeComponentHealth(name) {
338
335
  if (Is.arrayValue(this._healthInfo.components)) {
339
336
  const componentIndex = this._healthInfo.components.findIndex(c => c.name === name);
340
- if (componentIndex >= 0) {
337
+ if (componentIndex !== -1) {
341
338
  this._healthInfo.components.splice(componentIndex, 1);
342
339
  }
343
340
  }
344
341
  }
345
342
  }
346
343
 
344
+ const restEntryPoints = [
345
+ {
346
+ name: "information",
347
+ defaultBaseRoute: "",
348
+ tags: tagsInformation,
349
+ generateRoutes: generateRestRoutesInformation
350
+ }
351
+ ];
352
+
347
353
  export { InformationService, generateRestRoutesInformation, restEntryPoints, serverHealth, serverInfo, serverSpec, tagsInformation };
@@ -1,3 +1,5 @@
1
1
  export * from "./informationRoutes";
2
- export * from "./restEntryPoints";
3
2
  export * from "./informationService";
3
+ export * from "./models/IInformationServiceConfig";
4
+ export * from "./models/IInformationServiceConstructorOptions";
5
+ export * from "./restEntryPoints";
@@ -1,18 +1,22 @@
1
1
  import type { HealthStatus, IHealthInfo, IInformationComponent, IServerInfo } from "@twin.org/api-models";
2
+ import type { IInformationServiceConstructorOptions } from "./models/IInformationServiceConstructorOptions";
2
3
  /**
3
4
  * The information service for the server.
4
5
  */
5
6
  export declare class InformationService implements IInformationComponent {
7
+ /**
8
+ * The namespace supported by the information service.
9
+ */
10
+ static readonly NAMESPACE: string;
6
11
  /**
7
12
  * Runtime name for the class.
8
13
  */
9
14
  readonly CLASS_NAME: string;
10
15
  /**
11
16
  * Create a new instance of InformationService.
12
- * @param serverInfo The server information.
13
- * @param openApiSpecPath The path to the spec file.
17
+ * @param options The options to create the service.
14
18
  */
15
- constructor(serverInfo: IServerInfo, openApiSpecPath?: string);
19
+ constructor(options: IInformationServiceConstructorOptions);
16
20
  /**
17
21
  * The service needs to be started when the application is initialized.
18
22
  * @returns Nothing.
@@ -0,0 +1,14 @@
1
+ import type { IServerInfo } from "@twin.org/api-models";
2
+ /**
3
+ * Configuration for the information service.
4
+ */
5
+ export interface IInformationServiceConfig {
6
+ /**
7
+ * The server information.
8
+ */
9
+ serverInfo: IServerInfo;
10
+ /**
11
+ * The path to the OpenAPI Spec.
12
+ */
13
+ openApiSpecPath?: string;
14
+ }
@@ -0,0 +1,10 @@
1
+ import type { IInformationServiceConfig } from "./IInformationServiceConfig";
2
+ /**
3
+ * Options for the InformationService constructor.
4
+ */
5
+ export interface IInformationServiceConstructorOptions {
6
+ /**
7
+ * The configuration for the service.
8
+ */
9
+ config: IInformationServiceConfig;
10
+ }
package/docs/changelog.md CHANGED
@@ -1,5 +1,89 @@
1
1
  # @twin.org/api-service - Changelog
2
2
 
3
- ## v0.0.1-next.8
3
+ ## 0.0.1 (2025-07-03)
4
+
5
+
6
+ ### Features
7
+
8
+ * release to production ([70ee2d5](https://github.com/twinfoundation/api/commit/70ee2d56a1dc9537d7c9c154d4cb78a235678a3a))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/api-models bumped from ^0.0.0 to ^0.0.1
16
+
17
+ ## [0.0.1-next.36](https://github.com/twinfoundation/api/compare/api-service-v0.0.1-next.35...api-service-v0.0.1-next.36) (2025-06-17)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **api-service:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/api-models bumped from 0.0.1-next.35 to 0.0.1-next.36
30
+
31
+ ## [0.0.1-next.35](https://github.com/twinfoundation/api/compare/api-service-v0.0.1-next.34...api-service-v0.0.1-next.35) (2025-06-11)
32
+
33
+
34
+ ### Features
35
+
36
+ * update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
37
+
38
+
39
+ ### Dependencies
40
+
41
+ * The following workspace dependencies were updated
42
+ * dependencies
43
+ * @twin.org/api-models bumped from 0.0.1-next.34 to 0.0.1-next.35
44
+
45
+ ## [0.0.1-next.34](https://github.com/twinfoundation/api/compare/api-service-v0.0.1-next.33...api-service-v0.0.1-next.34) (2025-05-27)
46
+
47
+
48
+ ### Miscellaneous Chores
49
+
50
+ * **api-service:** Synchronize repo versions
51
+
52
+
53
+ ### Dependencies
54
+
55
+ * The following workspace dependencies were updated
56
+ * dependencies
57
+ * @twin.org/api-models bumped from 0.0.1-next.33 to 0.0.1-next.34
58
+
59
+ ## [0.0.1-next.33](https://github.com/twinfoundation/api/compare/api-service-v0.0.1-next.32...api-service-v0.0.1-next.33) (2025-04-17)
60
+
61
+
62
+ ### Features
63
+
64
+ * use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
65
+
66
+
67
+ ### Dependencies
68
+
69
+ * The following workspace dependencies were updated
70
+ * dependencies
71
+ * @twin.org/api-models bumped from 0.0.1-next.32 to 0.0.1-next.33
72
+
73
+ ## [0.0.1-next.32](https://github.com/twinfoundation/api/compare/api-service-v0.0.1-next.31...api-service-v0.0.1-next.32) (2025-03-28)
74
+
75
+
76
+ ### Miscellaneous Chores
77
+
78
+ * **api-service:** Synchronize repo versions
79
+
80
+
81
+ ### Dependencies
82
+
83
+ * The following workspace dependencies were updated
84
+ * dependencies
85
+ * @twin.org/api-models bumped from 0.0.1-next.31 to 0.0.1-next.32
86
+
87
+ ## v0.0.1-next.31
4
88
 
5
89
  - Initial Release
@@ -8,28 +8,34 @@ The information service for the server.
8
8
 
9
9
  ## Constructors
10
10
 
11
- ### new InformationService()
11
+ ### Constructor
12
12
 
13
- > **new InformationService**(`serverInfo`, `openApiSpecPath`?): [`InformationService`](InformationService.md)
13
+ > **new InformationService**(`options`): `InformationService`
14
14
 
15
15
  Create a new instance of InformationService.
16
16
 
17
17
  #### Parameters
18
18
 
19
- **serverInfo**: `IServerInfo`
19
+ ##### options
20
20
 
21
- The server information.
21
+ [`IInformationServiceConstructorOptions`](../interfaces/IInformationServiceConstructorOptions.md)
22
22
 
23
- **openApiSpecPath?**: `string`
24
-
25
- The path to the spec file.
23
+ The options to create the service.
26
24
 
27
25
  #### Returns
28
26
 
29
- [`InformationService`](InformationService.md)
27
+ `InformationService`
30
28
 
31
29
  ## Properties
32
30
 
31
+ ### NAMESPACE
32
+
33
+ > `readonly` `static` **NAMESPACE**: `string` = `"information"`
34
+
35
+ The namespace supported by the information service.
36
+
37
+ ***
38
+
33
39
  ### CLASS\_NAME
34
40
 
35
41
  > `readonly` **CLASS\_NAME**: `string`
@@ -116,21 +122,27 @@ The service health.
116
122
 
117
123
  ### setComponentHealth()
118
124
 
119
- > **setComponentHealth**(`name`, `status`, `details`?): `Promise`\<`void`\>
125
+ > **setComponentHealth**(`name`, `status`, `details?`): `Promise`\<`void`\>
120
126
 
121
127
  Set the status of a component.
122
128
 
123
129
  #### Parameters
124
130
 
125
- **name**: `string`
131
+ ##### name
132
+
133
+ `string`
126
134
 
127
135
  The component name.
128
136
 
129
- **status**: `HealthStatus`
137
+ ##### status
138
+
139
+ `HealthStatus`
130
140
 
131
141
  The status of the component.
132
142
 
133
- **details?**: `string`
143
+ ##### details?
144
+
145
+ `string`
134
146
 
135
147
  The details for the status.
136
148
 
@@ -154,7 +166,9 @@ Remove the status of a component.
154
166
 
155
167
  #### Parameters
156
168
 
157
- **name**: `string`
169
+ ##### name
170
+
171
+ `string`
158
172
 
159
173
  The component name.
160
174
 
@@ -1,21 +1,25 @@
1
1
  # Function: generateRestRoutesInformation()
2
2
 
3
- > **generateRestRoutesInformation**(`baseRouteName`, `componentName`): `IRestRoute`[]
3
+ > **generateRestRoutesInformation**(`baseRouteName`, `componentName`): `IRestRoute`\<`any`, `any`\>[]
4
4
 
5
5
  The REST routes for server information.
6
6
 
7
7
  ## Parameters
8
8
 
9
- **baseRouteName**: `string`
9
+ ### baseRouteName
10
+
11
+ `string`
10
12
 
11
13
  Prefix to prepend to the paths.
12
14
 
13
- **componentName**: `string`
15
+ ### componentName
16
+
17
+ `string`
14
18
 
15
19
  The name of the component to use in the routes stored in the ComponentFactory.
16
20
 
17
21
  ## Returns
18
22
 
19
- `IRestRoute`[]
23
+ `IRestRoute`\<`any`, `any`\>[]
20
24
 
21
25
  The generated routes.
@@ -6,15 +6,21 @@ Get the health for the server.
6
6
 
7
7
  ## Parameters
8
8
 
9
- **httpRequestContext**: `IHttpRequestContext`
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
10
12
 
11
13
  The request context for the API.
12
14
 
13
- **componentName**: `string`
15
+ ### componentName
16
+
17
+ `string`
14
18
 
15
19
  The name of the component to use in the routes.
16
20
 
17
- **request**: `INoContentRequest`
21
+ ### request
22
+
23
+ `INoContentRequest`
18
24
 
19
25
  The request.
20
26
 
@@ -6,15 +6,21 @@ Get the information for the server.
6
6
 
7
7
  ## Parameters
8
8
 
9
- **httpRequestContext**: `IHttpRequestContext`
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
10
12
 
11
13
  The request context for the API.
12
14
 
13
- **componentName**: `string`
15
+ ### componentName
16
+
17
+ `string`
14
18
 
15
19
  The name of the component to use in the routes.
16
20
 
17
- **request**: `INoContentRequest`
21
+ ### request
22
+
23
+ `INoContentRequest`
18
24
 
19
25
  The request.
20
26
 
@@ -6,15 +6,21 @@ Get the spec for the server.
6
6
 
7
7
  ## Parameters
8
8
 
9
- **httpRequestContext**: `IHttpRequestContext`
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
10
12
 
11
13
  The request context for the API.
12
14
 
13
- **componentName**: `string`
15
+ ### componentName
16
+
17
+ `string`
14
18
 
15
19
  The name of the component to use in the routes.
16
20
 
17
- **request**: `INoContentRequest`
21
+ ### request
22
+
23
+ `INoContentRequest`
18
24
 
19
25
  The request.
20
26
 
@@ -4,6 +4,11 @@
4
4
 
5
5
  - [InformationService](classes/InformationService.md)
6
6
 
7
+ ## Interfaces
8
+
9
+ - [IInformationServiceConfig](interfaces/IInformationServiceConfig.md)
10
+ - [IInformationServiceConstructorOptions](interfaces/IInformationServiceConstructorOptions.md)
11
+
7
12
  ## Variables
8
13
 
9
14
  - [tagsInformation](variables/tagsInformation.md)
@@ -0,0 +1,19 @@
1
+ # Interface: IInformationServiceConfig
2
+
3
+ Configuration for the information service.
4
+
5
+ ## Properties
6
+
7
+ ### serverInfo
8
+
9
+ > **serverInfo**: `IServerInfo`
10
+
11
+ The server information.
12
+
13
+ ***
14
+
15
+ ### openApiSpecPath?
16
+
17
+ > `optional` **openApiSpecPath**: `string`
18
+
19
+ The path to the OpenAPI Spec.
@@ -0,0 +1,11 @@
1
+ # Interface: IInformationServiceConstructorOptions
2
+
3
+ Options for the InformationService constructor.
4
+
5
+ ## Properties
6
+
7
+ ### config
8
+
9
+ > **config**: [`IInformationServiceConfig`](IInformationServiceConfig.md)
10
+
11
+ The configuration for the service.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-service",
3
- "version": "0.0.1-next.8",
3
+ "version": "0.0.1",
4
4
  "description": "Information contract implementation and REST endpoint definitions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,19 +14,19 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-models": "0.0.1-next.8",
18
- "@twin.org/core": "next",
19
- "@twin.org/nameof": "next",
20
- "@twin.org/web": "next"
17
+ "@twin.org/api-models": "^0.0.1",
18
+ "@twin.org/core": "^0.0.1",
19
+ "@twin.org/nameof": "^0.0.1",
20
+ "@twin.org/web": "^0.0.1"
21
21
  },
22
22
  "main": "./dist/cjs/index.cjs",
23
23
  "module": "./dist/esm/index.mjs",
24
24
  "types": "./dist/types/index.d.ts",
25
25
  "exports": {
26
26
  ".": {
27
+ "types": "./dist/types/index.d.ts",
27
28
  "require": "./dist/cjs/index.cjs",
28
- "import": "./dist/esm/index.mjs",
29
- "types": "./dist/types/index.d.ts"
29
+ "import": "./dist/esm/index.mjs"
30
30
  }
31
31
  },
32
32
  "files": [