@twin.org/api-models 0.0.3-next.1 → 0.0.3-next.10
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/es/helpers/httpErrorHelper.js +25 -19
- package/dist/es/helpers/httpErrorHelper.js.map +1 -1
- package/dist/es/index.js +2 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/api/IServerLivezResponse.js +2 -0
- package/dist/es/models/api/IServerLivezResponse.js.map +1 -0
- package/dist/es/models/api/IServerRootResponse.js +0 -2
- package/dist/es/models/api/IServerRootResponse.js.map +1 -1
- package/dist/es/models/protocol/IHttpRequestPathParams.js.map +1 -1
- package/dist/es/models/protocol/IHttpRequestQuery.js.map +1 -1
- package/dist/es/models/routes/IBaseRoute.js.map +1 -1
- package/dist/es/models/services/IHealthComponentInfo.js +2 -0
- package/dist/es/models/services/IHealthComponentInfo.js.map +1 -0
- package/dist/es/models/services/IHealthInfo.js.map +1 -1
- package/dist/es/models/services/IInformationComponent.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/models/api/IServerLivezResponse.d.ts +16 -0
- package/dist/types/models/api/IServerRootResponse.d.ts +7 -0
- package/dist/types/models/protocol/IHttpRequestPathParams.d.ts +1 -1
- package/dist/types/models/protocol/IHttpRequestQuery.d.ts +1 -1
- package/dist/types/models/routes/IBaseRoute.d.ts +5 -1
- package/dist/types/models/services/IHealthComponentInfo.d.ts +18 -0
- package/dist/types/models/services/IHealthInfo.d.ts +2 -14
- package/dist/types/models/services/IInformationComponent.d.ts +9 -2
- package/docs/changelog.md +94 -0
- package/docs/reference/index.md +2 -0
- package/docs/reference/interfaces/IBaseRoute.md +9 -1
- package/docs/reference/interfaces/IHealthComponentInfo.md +27 -0
- package/docs/reference/interfaces/IHealthInfo.md +1 -19
- package/docs/reference/interfaces/IHttpRequestPathParams.md +1 -1
- package/docs/reference/interfaces/IHttpRequestQuery.md +1 -1
- package/docs/reference/interfaces/IInformationComponent.md +28 -2
- package/docs/reference/interfaces/IRestRoute.md +13 -1
- package/docs/reference/interfaces/IServerLivezResponse.md +23 -0
- package/docs/reference/interfaces/IServerRootResponse.md +12 -0
- package/docs/reference/interfaces/ISocketRoute.md +13 -1
- package/package.json +1 -1
|
@@ -18,25 +18,31 @@ export class HttpErrorHelper {
|
|
|
18
18
|
// types then set the http response code accordingly
|
|
19
19
|
const flattened = BaseError.flatten(error);
|
|
20
20
|
let httpStatusCode = HttpStatusCode.internalServerError;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
const errorTypeMap = {
|
|
22
|
+
[GuardError.CLASS_NAME]: HttpStatusCode.badRequest,
|
|
23
|
+
[ValidationError.CLASS_NAME]: HttpStatusCode.badRequest,
|
|
24
|
+
[ConflictError.CLASS_NAME]: HttpStatusCode.conflict,
|
|
25
|
+
[AlreadyExistsError.CLASS_NAME]: HttpStatusCode.conflict,
|
|
26
|
+
[NotFoundError.CLASS_NAME]: HttpStatusCode.notFound,
|
|
27
|
+
[UnauthorizedError.CLASS_NAME]: HttpStatusCode.unauthorized,
|
|
28
|
+
[NotImplementedError.CLASS_NAME]: HttpStatusCode.forbidden,
|
|
29
|
+
[UnprocessableError.CLASS_NAME]: HttpStatusCode.unprocessableEntity
|
|
30
|
+
};
|
|
31
|
+
// First check the primary error, as we don't want to override that with a sub error
|
|
32
|
+
if (flattened.length > 0) {
|
|
33
|
+
const primaryError = flattened[0];
|
|
34
|
+
if (errorTypeMap[primaryError.name]) {
|
|
35
|
+
httpStatusCode = errorTypeMap[primaryError.name];
|
|
36
|
+
}
|
|
37
|
+
// The primary error is still internal server error, check the sub errors
|
|
38
|
+
if (httpStatusCode === HttpStatusCode.internalServerError) {
|
|
39
|
+
for (const className in errorTypeMap) {
|
|
40
|
+
if (flattened.some(e => BaseError.isErrorName(e, className))) {
|
|
41
|
+
httpStatusCode = errorTypeMap[className];
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
40
46
|
}
|
|
41
47
|
const returnError = error.toJsonObject(includeStack);
|
|
42
48
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpErrorHelper.js","sourceRoot":"","sources":["../../../src/helpers/httpErrorHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,UAAU,EAEV,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGvE;;GAEG;AACH,MAAM,OAAO,eAAe;IAC3B;;;;;OAKG;IACI,MAAM,CAAC,YAAY,CACzB,GAAY,EACZ,YAAsB;QAKtB,MAAM,KAAK,GAAc,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAElD,4DAA4D;QAC5D,oDAAoD;QACpD,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE3C,IAAI,cAAc,GAAmB,cAAc,CAAC,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"httpErrorHelper.js","sourceRoot":"","sources":["../../../src/helpers/httpErrorHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,UAAU,EAEV,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,E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AAE,CAAC;gBAC3D,KAAK,MAAM,SAAS,IAAI,YAAY,EAAE,CAAC;oBACtC,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;wBAC9D,cAAc,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;wBACzC,MAAM;oBACP,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAED,MAAM,WAAW,GAAG,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAErD,OAAO;YACN,KAAK,EAAE,WAAW;YAClB,cAAc;SACd,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,aAAa,CAC1B,QAAuB,EACvB,KAAa,EACb,UAA0B;QAE1B,QAAQ,CAAC,OAAO,KAAK,EAAE,CAAC;QACxB,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,GAAG,SAAS,CAAC,IAAI,iBAAiB,CAAC;QAC/E,QAAQ,CAAC,IAAI,GAAG,KAAK,CAAC;QACtB,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC;IAClC,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tAlreadyExistsError,\n\tBaseError,\n\tConflictError,\n\tGuardError,\n\ttype IError,\n\tNotFoundError,\n\tNotImplementedError,\n\tUnauthorizedError,\n\tUnprocessableError,\n\tValidationError\n} from \"@twin.org/core\";\nimport { HeaderTypes, HttpStatusCode, MimeTypes } from \"@twin.org/web\";\nimport type { IHttpResponse } from \"../models/protocol/IHttpResponse.js\";\n\n/**\n * Class to help with processing http errors.\n */\nexport class HttpErrorHelper {\n\t/**\n\t * Process the errors from the routes.\n\t * @param err The error to process.\n\t * @param includeStack Should the stack be included in the error.\n\t * @returns The status code and additional error data.\n\t */\n\tpublic static processError(\n\t\terr: unknown,\n\t\tincludeStack?: boolean\n\t): {\n\t\terror: IError;\n\t\thttpStatusCode: HttpStatusCode;\n\t} {\n\t\tconst error: BaseError = BaseError.fromError(err);\n\n\t\t// If the error or any of its sub errors are of the specific\n\t\t// types then set the http response code accordingly\n\t\tconst flattened = BaseError.flatten(error);\n\n\t\tlet httpStatusCode: HttpStatusCode = HttpStatusCode.internalServerError;\n\n\t\tconst errorTypeMap: { [id: string]: HttpStatusCode } = {\n\t\t\t[GuardError.CLASS_NAME]: HttpStatusCode.badRequest,\n\t\t\t[ValidationError.CLASS_NAME]: HttpStatusCode.badRequest,\n\t\t\t[ConflictError.CLASS_NAME]: HttpStatusCode.conflict,\n\t\t\t[AlreadyExistsError.CLASS_NAME]: HttpStatusCode.conflict,\n\t\t\t[NotFoundError.CLASS_NAME]: HttpStatusCode.notFound,\n\t\t\t[UnauthorizedError.CLASS_NAME]: HttpStatusCode.unauthorized,\n\t\t\t[NotImplementedError.CLASS_NAME]: HttpStatusCode.forbidden,\n\t\t\t[UnprocessableError.CLASS_NAME]: HttpStatusCode.unprocessableEntity\n\t\t};\n\n\t\t// First check the primary error, as we don't want to override that with a sub error\n\t\tif (flattened.length > 0) {\n\t\t\tconst primaryError = flattened[0];\n\t\t\tif (errorTypeMap[primaryError.name]) {\n\t\t\t\thttpStatusCode = errorTypeMap[primaryError.name];\n\t\t\t}\n\n\t\t\t// The primary error is still internal server error, check the sub errors\n\t\t\tif (httpStatusCode === HttpStatusCode.internalServerError) {\n\t\t\t\tfor (const className in errorTypeMap) {\n\t\t\t\t\tif (flattened.some(e => BaseError.isErrorName(e, className))) {\n\t\t\t\t\t\thttpStatusCode = errorTypeMap[className];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst returnError = error.toJsonObject(includeStack);\n\n\t\treturn {\n\t\t\terror: returnError,\n\t\t\thttpStatusCode\n\t\t};\n\t}\n\n\t/**\n\t * Build an error response.\n\t * @param response The response to build the error into.\n\t * @param error The error to build the response for.\n\t * @param statusCode The status code to use for the error.\n\t */\n\tpublic static buildResponse(\n\t\tresponse: IHttpResponse,\n\t\terror: IError,\n\t\tstatusCode: HttpStatusCode\n\t): void {\n\t\tresponse.headers ??= {};\n\t\tresponse.headers[HeaderTypes.ContentType] = `${MimeTypes.Json}; charset=utf-8`;\n\t\tresponse.body = error;\n\t\tresponse.statusCode = statusCode;\n\t}\n}\n"]}
|
package/dist/es/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./helpers/httpParameterHelper.js";
|
|
|
9
9
|
export * from "./models/api/IServerFavIconResponse.js";
|
|
10
10
|
export * from "./models/api/IServerHealthResponse.js";
|
|
11
11
|
export * from "./models/api/IServerInfoResponse.js";
|
|
12
|
+
export * from "./models/api/IServerLivezResponse.js";
|
|
12
13
|
export * from "./models/api/IServerRootResponse.js";
|
|
13
14
|
export * from "./models/api/IServerSpecResponse.js";
|
|
14
15
|
export * from "./models/client/IAuthenticationGenerator.js";
|
|
@@ -53,6 +54,7 @@ export * from "./models/server/ISocketRouteProcessor.js";
|
|
|
53
54
|
export * from "./models/server/IWebServer.js";
|
|
54
55
|
export * from "./models/server/IWebServerOptions.js";
|
|
55
56
|
export * from "./models/services/healthStatus.js";
|
|
57
|
+
export * from "./models/services/IHealthComponentInfo.js";
|
|
56
58
|
export * from "./models/services/IHealthInfo.js";
|
|
57
59
|
export * from "./models/services/IInformationComponent.js";
|
|
58
60
|
export * from "./models/services/IServerInfo.js";
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,+CAA+C,CAAC;AAC9D,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;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,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./factories/authenticationGeneratorFactory.js\";\nexport * from \"./factories/mimeTypeProcessorFactory.js\";\nexport * from \"./factories/restRouteProcessorFactory.js\";\nexport * from \"./factories/socketRouteProcessorFactory.js\";\nexport * from \"./helpers/httpErrorHelper.js\";\nexport * from \"./helpers/httpParameterHelper.js\";\nexport * from \"./models/api/IServerFavIconResponse.js\";\nexport * from \"./models/api/IServerHealthResponse.js\";\nexport * from \"./models/api/IServerInfoResponse.js\";\nexport * from \"./models/api/IServerRootResponse.js\";\nexport * from \"./models/api/IServerSpecResponse.js\";\nexport * from \"./models/client/IAuthenticationGenerator.js\";\nexport * from \"./models/config/IBaseRestClientConfig.js\";\nexport * from \"./models/config/IBaseSocketClientConfig.js\";\nexport * from \"./models/protocol/IHttpRequest.js\";\nexport * from \"./models/protocol/IHttpRequestContext.js\";\nexport * from \"./models/protocol/IHttpRequestPathParams.js\";\nexport * from \"./models/protocol/IHttpRequestQuery.js\";\nexport * from \"./models/protocol/IHttpResponse.js\";\nexport * from \"./models/protocol/IHttpServerRequest.js\";\nexport * from \"./models/protocol/ISocketRequestContext.js\";\nexport * from \"./models/protocol/ISocketServerRequest.js\";\nexport * from \"./models/requests/INoContentRequest.js\";\nexport * from \"./models/responses/errors/IBadRequestResponse.js\";\nexport * from \"./models/responses/errors/IConflictResponse.js\";\nexport * from \"./models/responses/errors/IForbiddenResponse.js\";\nexport * from \"./models/responses/errors/IInternalServerErrorResponse.js\";\nexport * from \"./models/responses/errors/INotFoundResponse.js\";\nexport * from \"./models/responses/errors/IUnauthorizedResponse.js\";\nexport * from \"./models/responses/errors/IUnprocessableEntityResponse.js\";\nexport * from \"./models/responses/success/IAcceptedResponse.js\";\nexport * from \"./models/responses/success/ICreatedResponse.js\";\nexport * from \"./models/responses/success/INoContentResponse.js\";\nexport * from \"./models/responses/success/IOkResponse.js\";\nexport * from \"./models/routes/IBaseRoute.js\";\nexport * from \"./models/routes/IBaseRouteEntryPoint.js\";\nexport * from \"./models/routes/IRestRoute.js\";\nexport * from \"./models/routes/IRestRouteEntryPoint.js\";\nexport * from \"./models/routes/IRestRouteExample.js\";\nexport * from \"./models/routes/IRestRouteRequestExample.js\";\nexport * from \"./models/routes/IRestRouteResponseAttachmentOptions.js\";\nexport * from \"./models/routes/IRestRouteResponseExample.js\";\nexport * from \"./models/routes/IRestRouteResponseOptions.js\";\nexport * from \"./models/routes/ISocketRoute.js\";\nexport * from \"./models/routes/ISocketRouteEntryPoint.js\";\nexport * from \"./models/routes/ITag.js\";\nexport * from \"./models/server/IBaseRouteProcessor.js\";\nexport * from \"./models/server/IMimeTypeProcessor.js\";\nexport * from \"./models/server/IRestRouteProcessor.js\";\nexport * from \"./models/server/ISocketRouteProcessor.js\";\nexport * from \"./models/server/IWebServer.js\";\nexport * from \"./models/server/IWebServerOptions.js\";\nexport * from \"./models/services/healthStatus.js\";\nexport * from \"./models/services/IHealthInfo.js\";\nexport * from \"./models/services/IInformationComponent.js\";\nexport * from \"./models/services/IServerInfo.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,+CAA+C,CAAC;AAC9D,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,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cesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./factories/authenticationGeneratorFactory.js\";\nexport * from \"./factories/mimeTypeProcessorFactory.js\";\nexport * from \"./factories/restRouteProcessorFactory.js\";\nexport * from \"./factories/socketRouteProcessorFactory.js\";\nexport * from \"./helpers/httpErrorHelper.js\";\nexport * from \"./helpers/httpParameterHelper.js\";\nexport * from \"./models/api/IServerFavIconResponse.js\";\nexport * from \"./models/api/IServerHealthResponse.js\";\nexport * from \"./models/api/IServerInfoResponse.js\";\nexport * from \"./models/api/IServerLivezResponse.js\";\nexport * from \"./models/api/IServerRootResponse.js\";\nexport * from \"./models/api/IServerSpecResponse.js\";\nexport * from \"./models/client/IAuthenticationGenerator.js\";\nexport * from \"./models/config/IBaseRestClientConfig.js\";\nexport * from \"./models/config/IBaseSocketClientConfig.js\";\nexport * from \"./models/protocol/IHttpRequest.js\";\nexport * from \"./models/protocol/IHttpRequestContext.js\";\nexport * from \"./models/protocol/IHttpRequestPathParams.js\";\nexport * from \"./models/protocol/IHttpRequestQuery.js\";\nexport * from \"./models/protocol/IHttpResponse.js\";\nexport * from \"./models/protocol/IHttpServerRequest.js\";\nexport * from \"./models/protocol/ISocketRequestContext.js\";\nexport * from \"./models/protocol/ISocketServerRequest.js\";\nexport * from \"./models/requests/INoContentRequest.js\";\nexport * from \"./models/responses/errors/IBadRequestResponse.js\";\nexport * from \"./models/responses/errors/IConflictResponse.js\";\nexport * from \"./models/responses/errors/IForbiddenResponse.js\";\nexport * from \"./models/responses/errors/IInternalServerErrorResponse.js\";\nexport * from \"./models/responses/errors/INotFoundResponse.js\";\nexport * from \"./models/responses/errors/IUnauthorizedResponse.js\";\nexport * from \"./models/responses/errors/IUnprocessableEntityResponse.js\";\nexport * from \"./models/responses/success/IAcceptedResponse.js\";\nexport * from \"./models/responses/success/ICreatedResponse.js\";\nexport * from \"./models/responses/success/INoContentResponse.js\";\nexport * from \"./models/responses/success/IOkResponse.js\";\nexport * from \"./models/routes/IBaseRoute.js\";\nexport * from \"./models/routes/IBaseRouteEntryPoint.js\";\nexport * from \"./models/routes/IRestRoute.js\";\nexport * from \"./models/routes/IRestRouteEntryPoint.js\";\nexport * from \"./models/routes/IRestRouteExample.js\";\nexport * from \"./models/routes/IRestRouteRequestExample.js\";\nexport * from \"./models/routes/IRestRouteResponseAttachmentOptions.js\";\nexport * from \"./models/routes/IRestRouteResponseExample.js\";\nexport * from \"./models/routes/IRestRouteResponseOptions.js\";\nexport * from \"./models/routes/ISocketRoute.js\";\nexport * from \"./models/routes/ISocketRouteEntryPoint.js\";\nexport * from \"./models/routes/ITag.js\";\nexport * from \"./models/server/IBaseRouteProcessor.js\";\nexport * from \"./models/server/IMimeTypeProcessor.js\";\nexport * from \"./models/server/IRestRouteProcessor.js\";\nexport * from \"./models/server/ISocketRouteProcessor.js\";\nexport * from \"./models/server/IWebServer.js\";\nexport * from \"./models/server/IWebServerOptions.js\";\nexport * from \"./models/services/healthStatus.js\";\nexport * from \"./models/services/IHealthComponentInfo.js\";\nexport * from \"./models/services/IHealthInfo.js\";\nexport * from \"./models/services/IInformationComponent.js\";\nexport * from \"./models/services/IServerInfo.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IServerLivezResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IServerLivezResponse.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { HeaderTypes, MimeTypes } from \"@twin.org/web\";\n\n/**\n * The livez of the server.\n */\nexport interface IServerLivezResponse {\n\t/**\n\t * The headers for the response.\n\t */\n\theaders: {\n\t\t[HeaderTypes.ContentType]: typeof MimeTypes.PlainText;\n\t};\n\n\t/**\n\t * The livez information for the server.\n\t */\n\tbody: \"ok\" | \"failed\";\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IServerRootResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IServerRootResponse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IServerRootResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IServerRootResponse.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { HeaderTypes, MimeTypes } from \"@twin.org/web\";\n\n/**\n * The root text for the server.\n */\nexport interface IServerRootResponse {\n\t/**\n\t * The headers for the response.\n\t */\n\theaders: {\n\t\t[HeaderTypes.ContentType]: typeof MimeTypes.PlainText;\n\t};\n\n\t/**\n\t * The root text for the server.\n\t */\n\tbody: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IHttpRequestPathParams.js","sourceRoot":"","sources":["../../../../src/models/protocol/IHttpRequestPathParams.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Model for the standard parameters for an http request.\n */\nexport interface IHttpRequestPathParams {\n\t[id: string]: string
|
|
1
|
+
{"version":3,"file":"IHttpRequestPathParams.js","sourceRoot":"","sources":["../../../../src/models/protocol/IHttpRequestPathParams.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Model for the standard parameters for an http request.\n */\nexport interface IHttpRequestPathParams {\n\t[id: string]: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IHttpRequestQuery.js","sourceRoot":"","sources":["../../../../src/models/protocol/IHttpRequestQuery.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Model used for Http request query parameters.\n */\nexport interface IHttpRequestQuery {\n\t[id: string]: string
|
|
1
|
+
{"version":3,"file":"IHttpRequestQuery.js","sourceRoot":"","sources":["../../../../src/models/protocol/IHttpRequestQuery.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Model used for Http request query parameters.\n */\nexport interface IHttpRequestQuery {\n\t[id: string]: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IBaseRoute.js","sourceRoot":"","sources":["../../../../src/models/routes/IBaseRoute.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Interface which defines a route.\n */\nexport interface IBaseRoute {\n\t/**\n\t * The id of the operation.\n\t */\n\toperationId: string;\n\n\t/**\n\t * The path to use for routing.\n\t */\n\tpath: string;\n\n\t/**\n\t * Skips the authentication for this route.\n\t */\n\tskipAuth?: boolean;\n\n\t/**\n\t * The features supported by additional processors to run for this route.\n\t */\n\tprocessorFeatures?: string[];\n\n\t/**\n\t * The data for additional processors to run for this route.\n\t */\n\tprocessorData?: {\n\t\t[key: string]: unknown;\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IBaseRoute.js","sourceRoot":"","sources":["../../../../src/models/routes/IBaseRoute.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Interface which defines a route.\n */\nexport interface IBaseRoute {\n\t/**\n\t * The id of the operation.\n\t */\n\toperationId: string;\n\n\t/**\n\t * The path to use for routing.\n\t */\n\tpath: string;\n\n\t/**\n\t * Skips the authentication requirement for this route.\n\t */\n\tskipAuth?: boolean;\n\n\t/**\n\t * Skips the tenant requirement for this route.\n\t */\n\tskipTenant?: boolean;\n\n\t/**\n\t * The features supported by additional processors to run for this route.\n\t */\n\tprocessorFeatures?: string[];\n\n\t/**\n\t * The data for additional processors to run for this route.\n\t */\n\tprocessorData?: {\n\t\t[key: string]: unknown;\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHealthComponentInfo.js","sourceRoot":"","sources":["../../../../src/models/services/IHealthComponentInfo.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { HealthStatus } from \"./healthStatus.js\";\n\n/**\n * The health component information.\n */\nexport interface IHealthComponentInfo {\n\t/**\n\t * The name of the component.\n\t */\n\tname: string;\n\n\t/**\n\t * The status of the component.\n\t */\n\tstatus: HealthStatus;\n\n\t/**\n\t * The details for the status.\n\t */\n\tdetails?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IHealthInfo.js","sourceRoot":"","sources":["../../../../src/models/services/IHealthInfo.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { HealthStatus } from \"./healthStatus.js\";\n\n/**\n * The status of the server.\n */\nexport interface IHealthInfo {\n\t/**\n\t * The status.\n\t */\n\tstatus: HealthStatus;\n\n\t/**\n\t * The status of the components.\n\t */\n\tcomponents?:
|
|
1
|
+
{"version":3,"file":"IHealthInfo.js","sourceRoot":"","sources":["../../../../src/models/services/IHealthInfo.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { HealthStatus } from \"./healthStatus.js\";\nimport type { IHealthComponentInfo } from \"./IHealthComponentInfo.js\";\n\n/**\n * The status of the server.\n */\nexport interface IHealthInfo {\n\t/**\n\t * The status.\n\t */\n\tstatus: HealthStatus;\n\n\t/**\n\t * The status of the components.\n\t */\n\tcomponents?: IHealthComponentInfo[];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IInformationComponent.js","sourceRoot":"","sources":["../../../../src/models/services/IInformationComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { HealthStatus } from \"./healthStatus.js\";\nimport type { IHealthInfo } from \"./IHealthInfo.js\";\nimport type { IServerInfo } from \"./IServerInfo.js\";\n\n/**\n * The information component for the server.\n */\nexport interface IInformationComponent extends IComponent {\n\t/**\n\t * Get the root information.\n\t * @returns The root information.\n\t */\n\troot(): Promise<string>;\n\n\t/**\n\t * Get the server information.\n\t * @returns The service information.\n\t */\n\tinfo(): Promise<IServerInfo>;\n\n\t/**\n\t * Get the favicon.\n\t * @returns The favicon.\n\t */\n\tfavicon(): Promise<Uint8Array | undefined>;\n\n\t/**\n\t * Get the OpenAPI spec.\n\t * @returns The OpenAPI spec.\n\t */\n\tspec(): Promise<unknown>;\n\n\t/**\n\t * Get the server health.\n\t * @returns The service health.\n\t */\n\thealth(): Promise<IHealthInfo>;\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\tsetComponentHealth(
|
|
1
|
+
{"version":3,"file":"IInformationComponent.js","sourceRoot":"","sources":["../../../../src/models/services/IInformationComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { HealthStatus } from \"./healthStatus.js\";\nimport type { IHealthInfo } from \"./IHealthInfo.js\";\nimport type { IServerInfo } from \"./IServerInfo.js\";\n\n/**\n * The information component for the server.\n */\nexport interface IInformationComponent extends IComponent {\n\t/**\n\t * Get the root information.\n\t * @returns The root information.\n\t */\n\troot(): Promise<string>;\n\n\t/**\n\t * Get the server information.\n\t * @returns The service information.\n\t */\n\tinfo(): Promise<IServerInfo>;\n\n\t/**\n\t * Get the favicon.\n\t * @returns The favicon.\n\t */\n\tfavicon(): Promise<Uint8Array | undefined>;\n\n\t/**\n\t * Get the OpenAPI spec.\n\t * @returns The OpenAPI spec.\n\t */\n\tspec(): Promise<unknown>;\n\n\t/**\n\t * Is the server live.\n\t * @returns True if the server is live.\n\t */\n\tlivez(): Promise<boolean>;\n\n\t/**\n\t * Get the server health.\n\t * @returns The service health.\n\t */\n\thealth(): Promise<IHealthInfo>;\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 * @param tenantId The tenant id, optional if the health status is not tenant specific.\n\t * @returns Nothing.\n\t */\n\tsetComponentHealth(\n\t\tname: string,\n\t\tstatus: HealthStatus,\n\t\tdetails?: string,\n\t\ttenantId?: string\n\t): Promise<void>;\n\n\t/**\n\t * Remove the status of a component.\n\t * @param name The component name.\n\t * @param tenantId The tenant id, optional if the health status is not tenant specific.\n\t * @returns Nothing.\n\t */\n\tremoveComponentHealth(name: string, tenantId?: string): Promise<void>;\n}\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./helpers/httpParameterHelper.js";
|
|
|
7
7
|
export * from "./models/api/IServerFavIconResponse.js";
|
|
8
8
|
export * from "./models/api/IServerHealthResponse.js";
|
|
9
9
|
export * from "./models/api/IServerInfoResponse.js";
|
|
10
|
+
export * from "./models/api/IServerLivezResponse.js";
|
|
10
11
|
export * from "./models/api/IServerRootResponse.js";
|
|
11
12
|
export * from "./models/api/IServerSpecResponse.js";
|
|
12
13
|
export * from "./models/client/IAuthenticationGenerator.js";
|
|
@@ -51,6 +52,7 @@ export * from "./models/server/ISocketRouteProcessor.js";
|
|
|
51
52
|
export * from "./models/server/IWebServer.js";
|
|
52
53
|
export * from "./models/server/IWebServerOptions.js";
|
|
53
54
|
export * from "./models/services/healthStatus.js";
|
|
55
|
+
export * from "./models/services/IHealthComponentInfo.js";
|
|
54
56
|
export * from "./models/services/IHealthInfo.js";
|
|
55
57
|
export * from "./models/services/IInformationComponent.js";
|
|
56
58
|
export * from "./models/services/IServerInfo.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HeaderTypes, MimeTypes } from "@twin.org/web";
|
|
2
|
+
/**
|
|
3
|
+
* The livez of the server.
|
|
4
|
+
*/
|
|
5
|
+
export interface IServerLivezResponse {
|
|
6
|
+
/**
|
|
7
|
+
* The headers for the response.
|
|
8
|
+
*/
|
|
9
|
+
headers: {
|
|
10
|
+
[HeaderTypes.ContentType]: typeof MimeTypes.PlainText;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The livez information for the server.
|
|
14
|
+
*/
|
|
15
|
+
body: "ok" | "failed";
|
|
16
|
+
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import type { HeaderTypes, MimeTypes } from "@twin.org/web";
|
|
1
2
|
/**
|
|
2
3
|
* The root text for the server.
|
|
3
4
|
*/
|
|
4
5
|
export interface IServerRootResponse {
|
|
6
|
+
/**
|
|
7
|
+
* The headers for the response.
|
|
8
|
+
*/
|
|
9
|
+
headers: {
|
|
10
|
+
[HeaderTypes.ContentType]: typeof MimeTypes.PlainText;
|
|
11
|
+
};
|
|
5
12
|
/**
|
|
6
13
|
* The root text for the server.
|
|
7
14
|
*/
|
|
@@ -11,9 +11,13 @@ export interface IBaseRoute {
|
|
|
11
11
|
*/
|
|
12
12
|
path: string;
|
|
13
13
|
/**
|
|
14
|
-
* Skips the authentication for this route.
|
|
14
|
+
* Skips the authentication requirement for this route.
|
|
15
15
|
*/
|
|
16
16
|
skipAuth?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Skips the tenant requirement for this route.
|
|
19
|
+
*/
|
|
20
|
+
skipTenant?: boolean;
|
|
17
21
|
/**
|
|
18
22
|
* The features supported by additional processors to run for this route.
|
|
19
23
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HealthStatus } from "./healthStatus.js";
|
|
2
|
+
/**
|
|
3
|
+
* The health component information.
|
|
4
|
+
*/
|
|
5
|
+
export interface IHealthComponentInfo {
|
|
6
|
+
/**
|
|
7
|
+
* The name of the component.
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* The status of the component.
|
|
12
|
+
*/
|
|
13
|
+
status: HealthStatus;
|
|
14
|
+
/**
|
|
15
|
+
* The details for the status.
|
|
16
|
+
*/
|
|
17
|
+
details?: string;
|
|
18
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HealthStatus } from "./healthStatus.js";
|
|
2
|
+
import type { IHealthComponentInfo } from "./IHealthComponentInfo.js";
|
|
2
3
|
/**
|
|
3
4
|
* The status of the server.
|
|
4
5
|
*/
|
|
@@ -10,18 +11,5 @@ export interface IHealthInfo {
|
|
|
10
11
|
/**
|
|
11
12
|
* The status of the components.
|
|
12
13
|
*/
|
|
13
|
-
components?:
|
|
14
|
-
/**
|
|
15
|
-
* The name of the component.
|
|
16
|
-
*/
|
|
17
|
-
name: string;
|
|
18
|
-
/**
|
|
19
|
-
* The status of the component.
|
|
20
|
-
*/
|
|
21
|
-
status: HealthStatus;
|
|
22
|
-
/**
|
|
23
|
-
* The details for the status.
|
|
24
|
-
*/
|
|
25
|
-
details?: string;
|
|
26
|
-
}[];
|
|
14
|
+
components?: IHealthComponentInfo[];
|
|
27
15
|
}
|
|
@@ -26,6 +26,11 @@ export interface IInformationComponent extends IComponent {
|
|
|
26
26
|
* @returns The OpenAPI spec.
|
|
27
27
|
*/
|
|
28
28
|
spec(): Promise<unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Is the server live.
|
|
31
|
+
* @returns True if the server is live.
|
|
32
|
+
*/
|
|
33
|
+
livez(): Promise<boolean>;
|
|
29
34
|
/**
|
|
30
35
|
* Get the server health.
|
|
31
36
|
* @returns The service health.
|
|
@@ -36,13 +41,15 @@ export interface IInformationComponent extends IComponent {
|
|
|
36
41
|
* @param name The component name.
|
|
37
42
|
* @param status The status of the component.
|
|
38
43
|
* @param details The details for the status.
|
|
44
|
+
* @param tenantId The tenant id, optional if the health status is not tenant specific.
|
|
39
45
|
* @returns Nothing.
|
|
40
46
|
*/
|
|
41
|
-
setComponentHealth(name: string, status: HealthStatus, details?: string): Promise<void>;
|
|
47
|
+
setComponentHealth(name: string, status: HealthStatus, details?: string, tenantId?: string): Promise<void>;
|
|
42
48
|
/**
|
|
43
49
|
* Remove the status of a component.
|
|
44
50
|
* @param name The component name.
|
|
51
|
+
* @param tenantId The tenant id, optional if the health status is not tenant specific.
|
|
45
52
|
* @returns Nothing.
|
|
46
53
|
*/
|
|
47
|
-
removeComponentHealth(name: string): Promise<void>;
|
|
54
|
+
removeComponentHealth(name: string, tenantId?: string): Promise<void>;
|
|
48
55
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,99 @@
|
|
|
1
1
|
# @twin.org/api-models - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.10](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.9...api-models-v0.0.3-next.10) (2026-01-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **api-models:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
## [0.0.3-next.9](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.8...api-models-v0.0.3-next.9) (2026-01-05)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add authentication generators and process features option ([a67edf1](https://github.com/twinfoundation/api/commit/a67edf1df212bd8ab94a40cddf5338551155696f))
|
|
16
|
+
* add context id features ([#42](https://github.com/twinfoundation/api/issues/42)) ([0186055](https://github.com/twinfoundation/api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
|
|
17
|
+
* add livez endpoint ([#57](https://github.com/twinfoundation/api/issues/57)) ([ef007db](https://github.com/twinfoundation/api/commit/ef007db8201736dd3053211f849ffd03baaa485e))
|
|
18
|
+
* add logging component type to request contexts ([210de1b](https://github.com/twinfoundation/api/commit/210de1b9e1c91079b59a2b90ddd57569668d647d))
|
|
19
|
+
* add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
|
|
20
|
+
* add socket id, connect and disconnect ([20b0d0e](https://github.com/twinfoundation/api/commit/20b0d0ec279cab46141fee09de2c4a7087cdce16))
|
|
21
|
+
* add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
|
|
22
|
+
* decodeURIComponent for query and path params ([ead68a2](https://github.com/twinfoundation/api/commit/ead68a257425c10dd912497f7edd473c469ca132))
|
|
23
|
+
* eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
|
|
24
|
+
* update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
25
|
+
* update framework core ([d8eebf2](https://github.com/twinfoundation/api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
|
|
26
|
+
* update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
|
|
27
|
+
* use new includeStackTrace flag for toJsonObject ([6452b15](https://github.com/twinfoundation/api/commit/6452b153af786eee14b21152420f8a2578b70593))
|
|
28
|
+
* use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
29
|
+
* validationError mapped to http status badrequest ([adc5eb1](https://github.com/twinfoundation/api/commit/adc5eb11d987abb0ab9f7e0dc8e1fdae207e436e))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* error handling make sure primary error takes precedence ([84b61f2](https://github.com/twinfoundation/api/commit/84b61f27fe5e4919c0c9f9a1edc8ff46dc45c1f7))
|
|
35
|
+
|
|
36
|
+
## [0.0.3-next.8](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.7...api-models-v0.0.3-next.8) (2025-12-17)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Miscellaneous Chores
|
|
40
|
+
|
|
41
|
+
* **api-models:** Synchronize repo versions
|
|
42
|
+
|
|
43
|
+
## [0.0.3-next.7](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.6...api-models-v0.0.3-next.7) (2025-11-26)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Bug Fixes
|
|
47
|
+
|
|
48
|
+
* error handling make sure primary error takes precedence ([84b61f2](https://github.com/twinfoundation/api/commit/84b61f27fe5e4919c0c9f9a1edc8ff46dc45c1f7))
|
|
49
|
+
|
|
50
|
+
## [0.0.3-next.6](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.5...api-models-v0.0.3-next.6) (2025-11-20)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Miscellaneous Chores
|
|
54
|
+
|
|
55
|
+
* **api-models:** Synchronize repo versions
|
|
56
|
+
|
|
57
|
+
## [0.0.3-next.5](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.4...api-models-v0.0.3-next.5) (2025-11-14)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### Features
|
|
61
|
+
|
|
62
|
+
* decodeURIComponent for query and path params ([ead68a2](https://github.com/twinfoundation/api/commit/ead68a257425c10dd912497f7edd473c469ca132))
|
|
63
|
+
|
|
64
|
+
## [0.0.3-next.4](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.3...api-models-v0.0.3-next.4) (2025-11-14)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Features
|
|
68
|
+
|
|
69
|
+
* add authentication generators and process features option ([a67edf1](https://github.com/twinfoundation/api/commit/a67edf1df212bd8ab94a40cddf5338551155696f))
|
|
70
|
+
* add context id features ([#42](https://github.com/twinfoundation/api/issues/42)) ([0186055](https://github.com/twinfoundation/api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
|
|
71
|
+
* add logging component type to request contexts ([210de1b](https://github.com/twinfoundation/api/commit/210de1b9e1c91079b59a2b90ddd57569668d647d))
|
|
72
|
+
* add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
|
|
73
|
+
* add socket id, connect and disconnect ([20b0d0e](https://github.com/twinfoundation/api/commit/20b0d0ec279cab46141fee09de2c4a7087cdce16))
|
|
74
|
+
* add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
|
|
75
|
+
* eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
|
|
76
|
+
* update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
77
|
+
* update framework core ([d8eebf2](https://github.com/twinfoundation/api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
|
|
78
|
+
* update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
|
|
79
|
+
* use new includeStackTrace flag for toJsonObject ([6452b15](https://github.com/twinfoundation/api/commit/6452b153af786eee14b21152420f8a2578b70593))
|
|
80
|
+
* use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
81
|
+
* validationError mapped to http status badrequest ([adc5eb1](https://github.com/twinfoundation/api/commit/adc5eb11d987abb0ab9f7e0dc8e1fdae207e436e))
|
|
82
|
+
|
|
83
|
+
## [0.0.3-next.3](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.2...api-models-v0.0.3-next.3) (2025-11-14)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
### Miscellaneous Chores
|
|
87
|
+
|
|
88
|
+
* **api-models:** Synchronize repo versions
|
|
89
|
+
|
|
90
|
+
## [0.0.3-next.2](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.1...api-models-v0.0.3-next.2) (2025-11-12)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
### Miscellaneous Chores
|
|
94
|
+
|
|
95
|
+
* **api-models:** Synchronize repo versions
|
|
96
|
+
|
|
3
97
|
## [0.0.3-next.1](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.0...api-models-v0.0.3-next.1) (2025-11-10)
|
|
4
98
|
|
|
5
99
|
|
package/docs/reference/index.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
- [IServerFavIconResponse](interfaces/IServerFavIconResponse.md)
|
|
11
11
|
- [IServerHealthResponse](interfaces/IServerHealthResponse.md)
|
|
12
12
|
- [IServerInfoResponse](interfaces/IServerInfoResponse.md)
|
|
13
|
+
- [IServerLivezResponse](interfaces/IServerLivezResponse.md)
|
|
13
14
|
- [IServerRootResponse](interfaces/IServerRootResponse.md)
|
|
14
15
|
- [IServerSpecResponse](interfaces/IServerSpecResponse.md)
|
|
15
16
|
- [IAuthenticationGenerator](interfaces/IAuthenticationGenerator.md)
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
- [ISocketRouteProcessor](interfaces/ISocketRouteProcessor.md)
|
|
52
53
|
- [IWebServer](interfaces/IWebServer.md)
|
|
53
54
|
- [IWebServerOptions](interfaces/IWebServerOptions.md)
|
|
55
|
+
- [IHealthComponentInfo](interfaces/IHealthComponentInfo.md)
|
|
54
56
|
- [IHealthInfo](interfaces/IHealthInfo.md)
|
|
55
57
|
- [IInformationComponent](interfaces/IInformationComponent.md)
|
|
56
58
|
- [IServerInfo](interfaces/IServerInfo.md)
|
|
@@ -29,7 +29,15 @@ The path to use for routing.
|
|
|
29
29
|
|
|
30
30
|
> `optional` **skipAuth**: `boolean`
|
|
31
31
|
|
|
32
|
-
Skips the authentication for this route.
|
|
32
|
+
Skips the authentication requirement for this route.
|
|
33
|
+
|
|
34
|
+
***
|
|
35
|
+
|
|
36
|
+
### skipTenant?
|
|
37
|
+
|
|
38
|
+
> `optional` **skipTenant**: `boolean`
|
|
39
|
+
|
|
40
|
+
Skips the tenant requirement for this route.
|
|
33
41
|
|
|
34
42
|
***
|
|
35
43
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Interface: IHealthComponentInfo
|
|
2
|
+
|
|
3
|
+
The health component information.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### name
|
|
8
|
+
|
|
9
|
+
> **name**: `string`
|
|
10
|
+
|
|
11
|
+
The name of the component.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### status
|
|
16
|
+
|
|
17
|
+
> **status**: [`HealthStatus`](../type-aliases/HealthStatus.md)
|
|
18
|
+
|
|
19
|
+
The status of the component.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### details?
|
|
24
|
+
|
|
25
|
+
> `optional` **details**: `string`
|
|
26
|
+
|
|
27
|
+
The details for the status.
|
|
@@ -14,24 +14,6 @@ The status.
|
|
|
14
14
|
|
|
15
15
|
### components?
|
|
16
16
|
|
|
17
|
-
> `optional` **components**: `
|
|
17
|
+
> `optional` **components**: [`IHealthComponentInfo`](IHealthComponentInfo.md)[]
|
|
18
18
|
|
|
19
19
|
The status of the components.
|
|
20
|
-
|
|
21
|
-
#### name
|
|
22
|
-
|
|
23
|
-
> **name**: `string`
|
|
24
|
-
|
|
25
|
-
The name of the component.
|
|
26
|
-
|
|
27
|
-
#### status
|
|
28
|
-
|
|
29
|
-
> **status**: [`HealthStatus`](../type-aliases/HealthStatus.md)
|
|
30
|
-
|
|
31
|
-
The status of the component.
|
|
32
|
-
|
|
33
|
-
#### details?
|
|
34
|
-
|
|
35
|
-
> `optional` **details**: `string`
|
|
36
|
-
|
|
37
|
-
The details for the status.
|
|
@@ -64,6 +64,20 @@ The OpenAPI spec.
|
|
|
64
64
|
|
|
65
65
|
***
|
|
66
66
|
|
|
67
|
+
### livez()
|
|
68
|
+
|
|
69
|
+
> **livez**(): `Promise`\<`boolean`\>
|
|
70
|
+
|
|
71
|
+
Is the server live.
|
|
72
|
+
|
|
73
|
+
#### Returns
|
|
74
|
+
|
|
75
|
+
`Promise`\<`boolean`\>
|
|
76
|
+
|
|
77
|
+
True if the server is live.
|
|
78
|
+
|
|
79
|
+
***
|
|
80
|
+
|
|
67
81
|
### health()
|
|
68
82
|
|
|
69
83
|
> **health**(): `Promise`\<[`IHealthInfo`](IHealthInfo.md)\>
|
|
@@ -80,7 +94,7 @@ The service health.
|
|
|
80
94
|
|
|
81
95
|
### setComponentHealth()
|
|
82
96
|
|
|
83
|
-
> **setComponentHealth**(`name`, `status`, `details?`): `Promise`\<`void`\>
|
|
97
|
+
> **setComponentHealth**(`name`, `status`, `details?`, `tenantId?`): `Promise`\<`void`\>
|
|
84
98
|
|
|
85
99
|
Set the status of a component.
|
|
86
100
|
|
|
@@ -104,6 +118,12 @@ The status of the component.
|
|
|
104
118
|
|
|
105
119
|
The details for the status.
|
|
106
120
|
|
|
121
|
+
##### tenantId?
|
|
122
|
+
|
|
123
|
+
`string`
|
|
124
|
+
|
|
125
|
+
The tenant id, optional if the health status is not tenant specific.
|
|
126
|
+
|
|
107
127
|
#### Returns
|
|
108
128
|
|
|
109
129
|
`Promise`\<`void`\>
|
|
@@ -114,7 +134,7 @@ Nothing.
|
|
|
114
134
|
|
|
115
135
|
### removeComponentHealth()
|
|
116
136
|
|
|
117
|
-
> **removeComponentHealth**(`name`): `Promise`\<`void`\>
|
|
137
|
+
> **removeComponentHealth**(`name`, `tenantId?`): `Promise`\<`void`\>
|
|
118
138
|
|
|
119
139
|
Remove the status of a component.
|
|
120
140
|
|
|
@@ -126,6 +146,12 @@ Remove the status of a component.
|
|
|
126
146
|
|
|
127
147
|
The component name.
|
|
128
148
|
|
|
149
|
+
##### tenantId?
|
|
150
|
+
|
|
151
|
+
`string`
|
|
152
|
+
|
|
153
|
+
The tenant id, optional if the health status is not tenant specific.
|
|
154
|
+
|
|
129
155
|
#### Returns
|
|
130
156
|
|
|
131
157
|
`Promise`\<`void`\>
|
|
@@ -46,7 +46,7 @@ The path to use for routing.
|
|
|
46
46
|
|
|
47
47
|
> `optional` **skipAuth**: `boolean`
|
|
48
48
|
|
|
49
|
-
Skips the authentication for this route.
|
|
49
|
+
Skips the authentication requirement for this route.
|
|
50
50
|
|
|
51
51
|
#### Inherited from
|
|
52
52
|
|
|
@@ -54,6 +54,18 @@ Skips the authentication for this route.
|
|
|
54
54
|
|
|
55
55
|
***
|
|
56
56
|
|
|
57
|
+
### skipTenant?
|
|
58
|
+
|
|
59
|
+
> `optional` **skipTenant**: `boolean`
|
|
60
|
+
|
|
61
|
+
Skips the tenant requirement for this route.
|
|
62
|
+
|
|
63
|
+
#### Inherited from
|
|
64
|
+
|
|
65
|
+
[`IBaseRoute`](IBaseRoute.md).[`skipTenant`](IBaseRoute.md#skiptenant)
|
|
66
|
+
|
|
67
|
+
***
|
|
68
|
+
|
|
57
69
|
### processorFeatures?
|
|
58
70
|
|
|
59
71
|
> `optional` **processorFeatures**: `string`[]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Interface: IServerLivezResponse
|
|
2
|
+
|
|
3
|
+
The livez of the server.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### headers
|
|
8
|
+
|
|
9
|
+
> **headers**: `object`
|
|
10
|
+
|
|
11
|
+
The headers for the response.
|
|
12
|
+
|
|
13
|
+
#### content-type
|
|
14
|
+
|
|
15
|
+
> **content-type**: `"text/plain"`
|
|
16
|
+
|
|
17
|
+
***
|
|
18
|
+
|
|
19
|
+
### body
|
|
20
|
+
|
|
21
|
+
> **body**: `"ok"` \| `"failed"`
|
|
22
|
+
|
|
23
|
+
The livez information for the server.
|
|
@@ -46,7 +46,7 @@ The path to use for routing.
|
|
|
46
46
|
|
|
47
47
|
> `optional` **skipAuth**: `boolean`
|
|
48
48
|
|
|
49
|
-
Skips the authentication for this route.
|
|
49
|
+
Skips the authentication requirement for this route.
|
|
50
50
|
|
|
51
51
|
#### Inherited from
|
|
52
52
|
|
|
@@ -54,6 +54,18 @@ Skips the authentication for this route.
|
|
|
54
54
|
|
|
55
55
|
***
|
|
56
56
|
|
|
57
|
+
### skipTenant?
|
|
58
|
+
|
|
59
|
+
> `optional` **skipTenant**: `boolean`
|
|
60
|
+
|
|
61
|
+
Skips the tenant requirement for this route.
|
|
62
|
+
|
|
63
|
+
#### Inherited from
|
|
64
|
+
|
|
65
|
+
[`IBaseRoute`](IBaseRoute.md).[`skipTenant`](IBaseRoute.md#skiptenant)
|
|
66
|
+
|
|
67
|
+
***
|
|
68
|
+
|
|
57
69
|
### processorFeatures?
|
|
58
70
|
|
|
59
71
|
> `optional` **processorFeatures**: `string`[]
|