@twin.org/api-service 0.0.1-next.2 → 0.0.1-next.21
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/cjs/index.cjs +22 -15
- package/dist/esm/index.mjs +23 -16
- package/dist/types/index.d.ts +2 -1
- package/dist/types/informationService.d.ts +10 -3
- package/dist/types/models/IInformationServiceConfig.d.ts +14 -0
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/InformationService.md +13 -5
- package/docs/reference/index.md +4 -0
- package/docs/reference/interfaces/IInformationServiceConfig.md +19 -0
- package/package.json +2 -29
package/dist/cjs/index.cjs
CHANGED
|
@@ -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,18 @@ class InformationService {
|
|
|
252
247
|
_openApiSpec;
|
|
253
248
|
/**
|
|
254
249
|
* Create a new instance of InformationService.
|
|
255
|
-
* @param
|
|
256
|
-
* @param
|
|
250
|
+
* @param options The options to create the service.
|
|
251
|
+
* @param options.config The configuration for the service.
|
|
257
252
|
*/
|
|
258
|
-
constructor(
|
|
259
|
-
this.
|
|
253
|
+
constructor(options) {
|
|
254
|
+
core.Guards.object(this.CLASS_NAME, "options", options);
|
|
255
|
+
core.Guards.object(this.CLASS_NAME, "options.config", options.config);
|
|
256
|
+
core.Guards.object(this.CLASS_NAME, "options.config.serverInfo", options.config.serverInfo);
|
|
257
|
+
this._serverInfo = options.config.serverInfo;
|
|
260
258
|
this._healthInfo = {
|
|
261
259
|
status: "ok"
|
|
262
260
|
};
|
|
263
|
-
this._openApiSpecPath = openApiSpecPath;
|
|
261
|
+
this._openApiSpecPath = options.config.openApiSpecPath;
|
|
264
262
|
}
|
|
265
263
|
/**
|
|
266
264
|
* The service needs to be started when the application is initialized.
|
|
@@ -339,13 +337,22 @@ class InformationService {
|
|
|
339
337
|
async removeComponentHealth(name) {
|
|
340
338
|
if (core.Is.arrayValue(this._healthInfo.components)) {
|
|
341
339
|
const componentIndex = this._healthInfo.components.findIndex(c => c.name === name);
|
|
342
|
-
if (componentIndex
|
|
340
|
+
if (componentIndex !== -1) {
|
|
343
341
|
this._healthInfo.components.splice(componentIndex, 1);
|
|
344
342
|
}
|
|
345
343
|
}
|
|
346
344
|
}
|
|
347
345
|
}
|
|
348
346
|
|
|
347
|
+
const restEntryPoints = [
|
|
348
|
+
{
|
|
349
|
+
name: "information",
|
|
350
|
+
defaultBaseRoute: "",
|
|
351
|
+
tags: tagsInformation,
|
|
352
|
+
generateRoutes: generateRestRoutesInformation
|
|
353
|
+
}
|
|
354
|
+
];
|
|
355
|
+
|
|
349
356
|
exports.InformationService = InformationService;
|
|
350
357
|
exports.generateRestRoutesInformation = generateRestRoutesInformation;
|
|
351
358
|
exports.restEntryPoints = restEntryPoints;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -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,18 @@ class InformationService {
|
|
|
250
245
|
_openApiSpec;
|
|
251
246
|
/**
|
|
252
247
|
* Create a new instance of InformationService.
|
|
253
|
-
* @param
|
|
254
|
-
* @param
|
|
248
|
+
* @param options The options to create the service.
|
|
249
|
+
* @param options.config The configuration for the service.
|
|
255
250
|
*/
|
|
256
|
-
constructor(
|
|
257
|
-
this.
|
|
251
|
+
constructor(options) {
|
|
252
|
+
Guards.object(this.CLASS_NAME, "options", options);
|
|
253
|
+
Guards.object(this.CLASS_NAME, "options.config", options.config);
|
|
254
|
+
Guards.object(this.CLASS_NAME, "options.config.serverInfo", options.config.serverInfo);
|
|
255
|
+
this._serverInfo = options.config.serverInfo;
|
|
258
256
|
this._healthInfo = {
|
|
259
257
|
status: "ok"
|
|
260
258
|
};
|
|
261
|
-
this._openApiSpecPath = openApiSpecPath;
|
|
259
|
+
this._openApiSpecPath = options.config.openApiSpecPath;
|
|
262
260
|
}
|
|
263
261
|
/**
|
|
264
262
|
* The service needs to be started when the application is initialized.
|
|
@@ -337,11 +335,20 @@ class InformationService {
|
|
|
337
335
|
async removeComponentHealth(name) {
|
|
338
336
|
if (Is.arrayValue(this._healthInfo.components)) {
|
|
339
337
|
const componentIndex = this._healthInfo.components.findIndex(c => c.name === name);
|
|
340
|
-
if (componentIndex
|
|
338
|
+
if (componentIndex !== -1) {
|
|
341
339
|
this._healthInfo.components.splice(componentIndex, 1);
|
|
342
340
|
}
|
|
343
341
|
}
|
|
344
342
|
}
|
|
345
343
|
}
|
|
346
344
|
|
|
345
|
+
const restEntryPoints = [
|
|
346
|
+
{
|
|
347
|
+
name: "information",
|
|
348
|
+
defaultBaseRoute: "",
|
|
349
|
+
tags: tagsInformation,
|
|
350
|
+
generateRoutes: generateRestRoutesInformation
|
|
351
|
+
}
|
|
352
|
+
];
|
|
353
|
+
|
|
347
354
|
export { InformationService, generateRestRoutesInformation, restEntryPoints, serverHealth, serverInfo, serverSpec, tagsInformation };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import type { HealthStatus, IHealthInfo, IInformationComponent, IServerInfo } from "@twin.org/api-models";
|
|
2
|
+
import type { IInformationServiceConfig } from "./models/IInformationServiceConfig";
|
|
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
|
|
13
|
-
* @param
|
|
17
|
+
* @param options The options to create the service.
|
|
18
|
+
* @param options.config The configuration for the service.
|
|
14
19
|
*/
|
|
15
|
-
constructor(
|
|
20
|
+
constructor(options: {
|
|
21
|
+
config: IInformationServiceConfig;
|
|
22
|
+
});
|
|
16
23
|
/**
|
|
17
24
|
* The service needs to be started when the application is initialized.
|
|
18
25
|
* @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
|
+
}
|
package/docs/changelog.md
CHANGED
|
@@ -10,19 +10,19 @@ The information service for the server.
|
|
|
10
10
|
|
|
11
11
|
### new InformationService()
|
|
12
12
|
|
|
13
|
-
> **new InformationService**(`
|
|
13
|
+
> **new InformationService**(`options`): [`InformationService`](InformationService.md)
|
|
14
14
|
|
|
15
15
|
Create a new instance of InformationService.
|
|
16
16
|
|
|
17
17
|
#### Parameters
|
|
18
18
|
|
|
19
|
-
• **
|
|
19
|
+
• **options**
|
|
20
20
|
|
|
21
|
-
The
|
|
21
|
+
The options to create the service.
|
|
22
22
|
|
|
23
|
-
• **
|
|
23
|
+
• **options.config**: [`IInformationServiceConfig`](../interfaces/IInformationServiceConfig.md)
|
|
24
24
|
|
|
25
|
-
The
|
|
25
|
+
The configuration for the service.
|
|
26
26
|
|
|
27
27
|
#### Returns
|
|
28
28
|
|
|
@@ -30,6 +30,14 @@ The path to the spec file.
|
|
|
30
30
|
|
|
31
31
|
## Properties
|
|
32
32
|
|
|
33
|
+
### NAMESPACE
|
|
34
|
+
|
|
35
|
+
> `readonly` `static` **NAMESPACE**: `string` = `"information"`
|
|
36
|
+
|
|
37
|
+
The namespace supported by the information service.
|
|
38
|
+
|
|
39
|
+
***
|
|
40
|
+
|
|
33
41
|
### CLASS\_NAME
|
|
34
42
|
|
|
35
43
|
> `readonly` **CLASS\_NAME**: `string`
|
package/docs/reference/index.md
CHANGED
|
@@ -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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/api-service",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.21",
|
|
4
4
|
"description": "Information contract implementation and REST endpoint definitions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,39 +13,12 @@
|
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"clean": "rimraf dist coverage",
|
|
18
|
-
"build": "tspc",
|
|
19
|
-
"test": "vitest --run --config ./vitest.config.ts --no-cache",
|
|
20
|
-
"coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
|
|
21
|
-
"bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
|
|
22
|
-
"bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
|
|
23
|
-
"bundle": "npm run bundle:esm && npm run bundle:cjs",
|
|
24
|
-
"docs:clean": "rimraf docs/reference",
|
|
25
|
-
"docs:generate": "typedoc",
|
|
26
|
-
"docs": "npm run docs:clean && npm run docs:generate",
|
|
27
|
-
"dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
|
|
28
|
-
},
|
|
29
16
|
"dependencies": {
|
|
30
|
-
"@twin.org/api-models": "0.0.1-next.
|
|
17
|
+
"@twin.org/api-models": "0.0.1-next.21",
|
|
31
18
|
"@twin.org/core": "next",
|
|
32
19
|
"@twin.org/nameof": "next",
|
|
33
20
|
"@twin.org/web": "next"
|
|
34
21
|
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@twin.org/nameof-transformer": "next",
|
|
37
|
-
"@vitest/coverage-v8": "2.1.1",
|
|
38
|
-
"@types/node": "22.5.5",
|
|
39
|
-
"copyfiles": "2.4.1",
|
|
40
|
-
"rimraf": "6.0.1",
|
|
41
|
-
"rollup": "4.21.3",
|
|
42
|
-
"rollup-plugin-typescript2": "0.36.0",
|
|
43
|
-
"ts-patch": "3.2.1",
|
|
44
|
-
"typedoc": "0.26.7",
|
|
45
|
-
"typedoc-plugin-markdown": "4.2.7",
|
|
46
|
-
"typescript": "5.6.2",
|
|
47
|
-
"vitest": "2.1.1"
|
|
48
|
-
},
|
|
49
22
|
"main": "./dist/cjs/index.cjs",
|
|
50
23
|
"module": "./dist/esm/index.mjs",
|
|
51
24
|
"types": "./dist/types/index.d.ts",
|