@twin.org/api-models 0.0.3-next.2 → 0.0.3-next.20

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 (78) hide show
  1. package/dist/es/helpers/httpErrorHelper.js +28 -19
  2. package/dist/es/helpers/httpErrorHelper.js.map +1 -1
  3. package/dist/es/helpers/httpUrlHelper.js +92 -0
  4. package/dist/es/helpers/httpUrlHelper.js.map +1 -0
  5. package/dist/es/index.js +6 -2
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/es/models/api/IServerLivezResponse.js +2 -0
  8. package/dist/es/models/api/IServerLivezResponse.js.map +1 -0
  9. package/dist/es/models/api/IServerRootResponse.js +0 -2
  10. package/dist/es/models/api/IServerRootResponse.js.map +1 -1
  11. package/dist/es/models/protocol/IHttpRequestContext.js.map +1 -1
  12. package/dist/es/models/protocol/IHttpRequestPathParams.js.map +1 -1
  13. package/dist/es/models/protocol/IHttpRequestQuery.js.map +1 -1
  14. package/dist/es/models/protocol/IHttpServerRequest.js.map +1 -1
  15. package/dist/es/models/routes/IBaseRoute.js.map +1 -1
  16. package/dist/es/models/server/IBaseRouteProcessor.js.map +1 -1
  17. package/dist/es/models/server/IRestRouteProcessor.js.map +1 -1
  18. package/dist/es/models/services/IHealthComponentInfo.js +2 -0
  19. package/dist/es/models/services/IHealthComponentInfo.js.map +1 -0
  20. package/dist/es/models/services/IHealthInfo.js.map +1 -1
  21. package/dist/es/models/services/IHostingComponent.js +2 -0
  22. package/dist/es/models/services/IHostingComponent.js.map +1 -0
  23. package/dist/es/models/services/IInformationComponent.js.map +1 -1
  24. package/dist/es/models/services/ITenant.js +4 -0
  25. package/dist/es/models/services/ITenant.js.map +1 -0
  26. package/dist/es/models/services/ITenantAdminComponent.js +2 -0
  27. package/dist/es/models/services/ITenantAdminComponent.js.map +1 -0
  28. package/dist/types/helpers/httpErrorHelper.d.ts +6 -0
  29. package/dist/types/helpers/httpUrlHelper.d.ts +46 -0
  30. package/dist/types/index.d.ts +6 -2
  31. package/dist/types/models/api/IServerLivezResponse.d.ts +16 -0
  32. package/dist/types/models/api/IServerRootResponse.d.ts +7 -0
  33. package/dist/types/models/protocol/IHttpRequestContext.d.ts +4 -0
  34. package/dist/types/models/protocol/IHttpRequestPathParams.d.ts +1 -1
  35. package/dist/types/models/protocol/IHttpRequestQuery.d.ts +1 -1
  36. package/dist/types/models/protocol/IHttpServerRequest.d.ts +4 -4
  37. package/dist/types/models/routes/IBaseRoute.d.ts +9 -1
  38. package/dist/types/models/server/IBaseRouteProcessor.d.ts +14 -4
  39. package/dist/types/models/server/IRestRouteProcessor.d.ts +7 -2
  40. package/dist/types/models/services/IHealthComponentInfo.d.ts +18 -0
  41. package/dist/types/models/services/IHealthInfo.d.ts +2 -14
  42. package/dist/types/models/services/IHostingComponent.d.ts +24 -0
  43. package/dist/types/models/services/IInformationComponent.d.ts +9 -2
  44. package/dist/types/models/services/ITenant.d.ts +33 -0
  45. package/dist/types/models/services/ITenantAdminComponent.d.ts +63 -0
  46. package/docs/changelog.md +157 -0
  47. package/docs/reference/classes/HttpErrorHelper.md +12 -0
  48. package/docs/reference/classes/HttpUrlHelper.md +169 -0
  49. package/docs/reference/index.md +6 -2
  50. package/docs/reference/interfaces/IBaseRoute.md +17 -1
  51. package/docs/reference/interfaces/IBaseRouteProcessor.md +26 -6
  52. package/docs/reference/interfaces/IHealthComponentInfo.md +27 -0
  53. package/docs/reference/interfaces/IHealthInfo.md +1 -19
  54. package/docs/reference/interfaces/IHostingComponent.md +73 -0
  55. package/docs/reference/interfaces/IHttpRequestContext.md +8 -0
  56. package/docs/reference/interfaces/IHttpRequestPathParams.md +1 -1
  57. package/docs/reference/interfaces/IHttpRequestQuery.md +1 -1
  58. package/docs/reference/interfaces/IHttpServerRequest.md +6 -6
  59. package/docs/reference/interfaces/IInformationComponent.md +28 -2
  60. package/docs/reference/interfaces/IRestRoute.md +25 -1
  61. package/docs/reference/interfaces/IRestRouteProcessor.md +39 -9
  62. package/docs/reference/interfaces/IServerLivezResponse.md +23 -0
  63. package/docs/reference/interfaces/IServerRootResponse.md +12 -0
  64. package/docs/reference/interfaces/ISocketRequestContext.md +12 -0
  65. package/docs/reference/interfaces/ISocketRoute.md +25 -1
  66. package/docs/reference/interfaces/ISocketRouteProcessor.md +26 -6
  67. package/docs/reference/interfaces/ISocketServerRequest.md +8 -8
  68. package/docs/reference/interfaces/ITenant.md +59 -0
  69. package/docs/reference/interfaces/ITenantAdminComponent.md +193 -0
  70. package/package.json +1 -1
  71. package/dist/es/factories/authenticationGeneratorFactory.js +0 -9
  72. package/dist/es/factories/authenticationGeneratorFactory.js.map +0 -1
  73. package/dist/es/models/client/IAuthenticationGenerator.js +0 -2
  74. package/dist/es/models/client/IAuthenticationGenerator.js.map +0 -1
  75. package/dist/types/factories/authenticationGeneratorFactory.d.ts +0 -6
  76. package/dist/types/models/client/IAuthenticationGenerator.d.ts +0 -14
  77. package/docs/reference/interfaces/IAuthenticationGenerator.md +0 -35
  78. package/docs/reference/variables/AuthenticationGeneratorFactory.md +0 -5
@@ -6,6 +6,19 @@ import { HeaderTypes, HttpStatusCode, MimeTypes } from "@twin.org/web";
6
6
  * Class to help with processing http errors.
7
7
  */
8
8
  export class HttpErrorHelper {
9
+ /**
10
+ * Mapping of error types to status codes.
11
+ */
12
+ static ERROR_TYPE_MAP = {
13
+ [GuardError.CLASS_NAME]: HttpStatusCode.badRequest,
14
+ [ValidationError.CLASS_NAME]: HttpStatusCode.badRequest,
15
+ [ConflictError.CLASS_NAME]: HttpStatusCode.conflict,
16
+ [AlreadyExistsError.CLASS_NAME]: HttpStatusCode.conflict,
17
+ [NotFoundError.CLASS_NAME]: HttpStatusCode.notFound,
18
+ [UnauthorizedError.CLASS_NAME]: HttpStatusCode.unauthorized,
19
+ [NotImplementedError.CLASS_NAME]: HttpStatusCode.forbidden,
20
+ [UnprocessableError.CLASS_NAME]: HttpStatusCode.unprocessableEntity
21
+ };
9
22
  /**
10
23
  * Process the errors from the routes.
11
24
  * @param err The error to process.
@@ -18,25 +31,21 @@ export class HttpErrorHelper {
18
31
  // types then set the http response code accordingly
19
32
  const flattened = BaseError.flatten(error);
20
33
  let httpStatusCode = HttpStatusCode.internalServerError;
21
- if (flattened.some(e => BaseError.isErrorName(e, GuardError.CLASS_NAME)) ||
22
- flattened.some(e => BaseError.isErrorName(e, ValidationError.CLASS_NAME))) {
23
- httpStatusCode = HttpStatusCode.badRequest;
24
- }
25
- else if (flattened.some(e => BaseError.isErrorName(e, ConflictError.CLASS_NAME)) ||
26
- flattened.some(e => BaseError.isErrorName(e, AlreadyExistsError.CLASS_NAME))) {
27
- httpStatusCode = HttpStatusCode.conflict;
28
- }
29
- else if (flattened.some(e => BaseError.isErrorName(e, NotFoundError.CLASS_NAME))) {
30
- httpStatusCode = HttpStatusCode.notFound;
31
- }
32
- else if (flattened.some(e => BaseError.isErrorName(e, UnauthorizedError.CLASS_NAME))) {
33
- httpStatusCode = HttpStatusCode.unauthorized;
34
- }
35
- else if (flattened.some(e => BaseError.isErrorName(e, NotImplementedError.CLASS_NAME))) {
36
- httpStatusCode = HttpStatusCode.forbidden;
37
- }
38
- else if (flattened.some(e => BaseError.isErrorName(e, UnprocessableError.CLASS_NAME))) {
39
- httpStatusCode = HttpStatusCode.unprocessableEntity;
34
+ // First check the primary error, as we don't want to override that with a sub error
35
+ if (flattened.length > 0) {
36
+ const primaryError = flattened[0];
37
+ if (HttpErrorHelper.ERROR_TYPE_MAP[primaryError.name]) {
38
+ httpStatusCode = HttpErrorHelper.ERROR_TYPE_MAP[primaryError.name];
39
+ }
40
+ // The primary error is still internal server error, check the sub errors
41
+ if (httpStatusCode === HttpStatusCode.internalServerError) {
42
+ for (const className in HttpErrorHelper.ERROR_TYPE_MAP) {
43
+ if (flattened.some(e => BaseError.isErrorName(e, className))) {
44
+ httpStatusCode = HttpErrorHelper.ERROR_TYPE_MAP[className];
45
+ break;
46
+ }
47
+ }
48
+ }
40
49
  }
41
50
  const returnError = error.toJsonObject(includeStack);
42
51
  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;QACxE,IACC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;YACpE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC,EACxE,CAAC;YACF,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC;QAC5C,CAAC;aAAM,IACN,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;YACvE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,kBAAkB,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;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\t\tif (\n\t\t\tflattened.some(e => BaseError.isErrorName(e, GuardError.CLASS_NAME)) ||\n\t\t\tflattened.some(e => BaseError.isErrorName(e, ValidationError.CLASS_NAME))\n\t\t) {\n\t\t\thttpStatusCode = HttpStatusCode.badRequest;\n\t\t} else if (\n\t\t\tflattened.some(e => BaseError.isErrorName(e, ConflictError.CLASS_NAME)) ||\n\t\t\tflattened.some(e => BaseError.isErrorName(e, AlreadyExistsError.CLASS_NAME))\n\t\t) {\n\t\t\thttpStatusCode = HttpStatusCode.conflict;\n\t\t} else if (flattened.some(e => BaseError.isErrorName(e, NotFoundError.CLASS_NAME))) {\n\t\t\thttpStatusCode = HttpStatusCode.notFound;\n\t\t} else if (flattened.some(e => BaseError.isErrorName(e, UnauthorizedError.CLASS_NAME))) {\n\t\t\thttpStatusCode = HttpStatusCode.unauthorized;\n\t\t} else if (flattened.some(e => BaseError.isErrorName(e, NotImplementedError.CLASS_NAME))) {\n\t\t\thttpStatusCode = HttpStatusCode.forbidden;\n\t\t} else if (flattened.some(e => BaseError.isErrorName(e, UnprocessableError.CLASS_NAME))) {\n\t\t\thttpStatusCode = HttpStatusCode.unprocessableEntity;\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"]}
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;;OAEG;IACI,MAAM,CAAU,cAAc,GAAqC;QACzE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC,UAAU;QAClD,CAAC,eAAe,CAAC,UAAU,C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AAE,CAAC;wBAC9D,cAAc,GAAG,eAAe,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;wBAC3D,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","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 * Mapping of error types to status codes.\n\t */\n\tpublic static readonly ERROR_TYPE_MAP: { [id: string]: HttpStatusCode } = {\n\t\t[GuardError.CLASS_NAME]: HttpStatusCode.badRequest,\n\t\t[ValidationError.CLASS_NAME]: HttpStatusCode.badRequest,\n\t\t[ConflictError.CLASS_NAME]: HttpStatusCode.conflict,\n\t\t[AlreadyExistsError.CLASS_NAME]: HttpStatusCode.conflict,\n\t\t[NotFoundError.CLASS_NAME]: HttpStatusCode.notFound,\n\t\t[UnauthorizedError.CLASS_NAME]: HttpStatusCode.unauthorized,\n\t\t[NotImplementedError.CLASS_NAME]: HttpStatusCode.forbidden,\n\t\t[UnprocessableError.CLASS_NAME]: HttpStatusCode.unprocessableEntity\n\t};\n\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\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 (HttpErrorHelper.ERROR_TYPE_MAP[primaryError.name]) {\n\t\t\t\thttpStatusCode = HttpErrorHelper.ERROR_TYPE_MAP[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 HttpErrorHelper.ERROR_TYPE_MAP) {\n\t\t\t\t\tif (flattened.some(e => BaseError.isErrorName(e, className))) {\n\t\t\t\t\t\thttpStatusCode = HttpErrorHelper.ERROR_TYPE_MAP[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"]}
@@ -0,0 +1,92 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { Is, StringHelper } from "@twin.org/core";
4
+ /**
5
+ * Class to help with handling http URLs.
6
+ */
7
+ export class HttpUrlHelper {
8
+ /**
9
+ * Extract the origin from the url which includes protocol,host,port.
10
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/URL/origin
11
+ * @param url The url to extract the origin from.
12
+ * @returns The extracted origin.
13
+ */
14
+ static extractOrigin(url) {
15
+ try {
16
+ const convertedUrl = new URL(url);
17
+ return convertedUrl.origin;
18
+ }
19
+ catch { }
20
+ }
21
+ /**
22
+ * Extract the path from the url.
23
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/URL/pathname
24
+ * @param url The url to extract the path from.
25
+ * @returns The extracted path.
26
+ */
27
+ static extractPath(url) {
28
+ try {
29
+ const convertedUrl = new URL(url);
30
+ return convertedUrl.pathname;
31
+ }
32
+ catch { }
33
+ }
34
+ /**
35
+ * Extract the search from the url.
36
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/URL/search
37
+ * @param url The url to extract the search from.
38
+ * @returns The extracted search.
39
+ */
40
+ static extractSearch(url) {
41
+ try {
42
+ const convertedUrl = new URL(url);
43
+ return convertedUrl.search;
44
+ }
45
+ catch { }
46
+ }
47
+ /**
48
+ * Extract the path and search from the url.
49
+ * @param url The url to extract the path and search from.
50
+ * @returns The extracted path and search.
51
+ */
52
+ static extractPathAndSearch(url) {
53
+ try {
54
+ const convertedUrl = new URL(url);
55
+ return `${convertedUrl.pathname}${convertedUrl.search}`;
56
+ }
57
+ catch { }
58
+ }
59
+ /**
60
+ * Combine the urls parts.
61
+ * @param origin The origin to combine.
62
+ * @param pathAndSearch The path and search to combine.
63
+ * @returns The combined parts.
64
+ */
65
+ static combineParts(origin, pathAndSearch) {
66
+ if (Is.string(origin) && Is.string(pathAndSearch)) {
67
+ return `${StringHelper.trimTrailingSlashes(origin)}/${StringHelper.trimLeadingSlashes(pathAndSearch)}`;
68
+ }
69
+ }
70
+ /**
71
+ * Replace the origin in the url.
72
+ * @param url The url to replace the origin in.
73
+ * @param newOrigin The new origin to use.
74
+ * @returns The url with the replaced origin.
75
+ */
76
+ static replaceOrigin(url, newOrigin) {
77
+ if (!Is.stringValue(url) || !Is.stringValue(newOrigin) || !newOrigin.startsWith("http")) {
78
+ return url;
79
+ }
80
+ try {
81
+ const parsedUrl = new URL(url.startsWith("/") ? `http://placeholder${url}` : url);
82
+ const newParsedUrl = new URL(newOrigin);
83
+ parsedUrl.protocol = newParsedUrl.protocol;
84
+ parsedUrl.host = newParsedUrl.host;
85
+ parsedUrl.port = newParsedUrl.port;
86
+ return parsedUrl.toString();
87
+ }
88
+ catch { }
89
+ return url;
90
+ }
91
+ }
92
+ //# sourceMappingURL=httpUrlHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpUrlHelper.js","sourceRoot":"","sources":["../../../src/helpers/httpUrlHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,aAAa;IACzB;;;;;OAKG;IACI,MAAM,CAAC,aAAa,CAAC,GAAW;QACtC,IAAI,CAAC;YACJ,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;YAClC,OAAO,YAAY,CAAC,MAAM,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACX,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,WAAW,CAAC,GAAW;QACpC,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AM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YAClF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;YACxC,SAAS,CAAC,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAC;YAC3C,SAAS,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;YACnC,SAAS,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;YACnC,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,OAAO,GAAG,CAAC;IACZ,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Is, StringHelper } from \"@twin.org/core\";\n\n/**\n * Class to help with handling http URLs.\n */\nexport class HttpUrlHelper {\n\t/**\n\t * Extract the origin from the url which includes protocol,host,port.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/URL/origin\n\t * @param url The url to extract the origin from.\n\t * @returns The extracted origin.\n\t */\n\tpublic static extractOrigin(url: string): string | undefined {\n\t\ttry {\n\t\t\tconst convertedUrl = new URL(url);\n\t\t\treturn convertedUrl.origin;\n\t\t} catch {}\n\t}\n\n\t/**\n\t * Extract the path from the url.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/URL/pathname\n\t * @param url The url to extract the path from.\n\t * @returns The extracted path.\n\t */\n\tpublic static extractPath(url: string): string | undefined {\n\t\ttry {\n\t\t\tconst convertedUrl = new URL(url);\n\t\t\treturn convertedUrl.pathname;\n\t\t} catch {}\n\t}\n\n\t/**\n\t * Extract the search from the url.\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/URL/search\n\t * @param url The url to extract the search from.\n\t * @returns The extracted search.\n\t */\n\tpublic static extractSearch(url: string): string | undefined {\n\t\ttry {\n\t\t\tconst convertedUrl = new URL(url);\n\t\t\treturn convertedUrl.search;\n\t\t} catch {}\n\t}\n\n\t/**\n\t * Extract the path and search from the url.\n\t * @param url The url to extract the path and search from.\n\t * @returns The extracted path and search.\n\t */\n\tpublic static extractPathAndSearch(url: string): string | undefined {\n\t\ttry {\n\t\t\tconst convertedUrl = new URL(url);\n\t\t\treturn `${convertedUrl.pathname}${convertedUrl.search}`;\n\t\t} catch {}\n\t}\n\n\t/**\n\t * Combine the urls parts.\n\t * @param origin The origin to combine.\n\t * @param pathAndSearch The path and search to combine.\n\t * @returns The combined parts.\n\t */\n\tpublic static combineParts(origin: string, pathAndSearch: string): string | undefined {\n\t\tif (Is.string(origin) && Is.string(pathAndSearch)) {\n\t\t\treturn `${StringHelper.trimTrailingSlashes(origin)}/${StringHelper.trimLeadingSlashes(pathAndSearch)}`;\n\t\t}\n\t}\n\n\t/**\n\t * Replace the origin in the url.\n\t * @param url The url to replace the origin in.\n\t * @param newOrigin The new origin to use.\n\t * @returns The url with the replaced origin.\n\t */\n\tpublic static replaceOrigin(url: string, newOrigin?: string): string {\n\t\tif (!Is.stringValue(url) || !Is.stringValue(newOrigin) || !newOrigin.startsWith(\"http\")) {\n\t\t\treturn url;\n\t\t}\n\n\t\ttry {\n\t\t\tconst parsedUrl = new URL(url.startsWith(\"/\") ? `http://placeholder${url}` : url);\n\t\t\tconst newParsedUrl = new URL(newOrigin);\n\t\t\tparsedUrl.protocol = newParsedUrl.protocol;\n\t\t\tparsedUrl.host = newParsedUrl.host;\n\t\t\tparsedUrl.port = newParsedUrl.port;\n\t\t\treturn parsedUrl.toString();\n\t\t} catch {}\n\n\t\treturn url;\n\t}\n}\n"]}
package/dist/es/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  // Copyright 2024 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
- export * from "./factories/authenticationGeneratorFactory.js";
4
3
  export * from "./factories/mimeTypeProcessorFactory.js";
5
4
  export * from "./factories/restRouteProcessorFactory.js";
6
5
  export * from "./factories/socketRouteProcessorFactory.js";
7
6
  export * from "./helpers/httpErrorHelper.js";
8
7
  export * from "./helpers/httpParameterHelper.js";
8
+ export * from "./helpers/httpUrlHelper.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
- export * from "./models/client/IAuthenticationGenerator.js";
15
15
  export * from "./models/config/IBaseRestClientConfig.js";
16
16
  export * from "./models/config/IBaseSocketClientConfig.js";
17
17
  export * from "./models/protocol/IHttpRequest.js";
@@ -53,7 +53,11 @@ export * from "./models/server/ISocketRouteProcessor.js";
53
53
  export * from "./models/server/IWebServer.js";
54
54
  export * from "./models/server/IWebServerOptions.js";
55
55
  export * from "./models/services/healthStatus.js";
56
+ export * from "./models/services/IHealthComponentInfo.js";
56
57
  export * from "./models/services/IHealthInfo.js";
58
+ export * from "./models/services/IHostingComponent.js";
57
59
  export * from "./models/services/IInformationComponent.js";
58
60
  export * from "./models/services/IServerInfo.js";
61
+ export * from "./models/services/ITenant.js";
62
+ export * from "./models/services/ITenantAdminComponent.js";
59
63
  //# sourceMappingURL=index.js.map
@@ -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;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,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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,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,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,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mCAAmC,CAAC;AAClD,cAAc,0CAA0C,CAAC;AACzD,cAAc,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.0.\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 \"./helpers/httpUrlHelper.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/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/IHostingComponent.js\";\nexport * from \"./models/services/IInformationComponent.js\";\nexport * from \"./models/services/IServerInfo.js\";\nexport * from \"./models/services/ITenant.js\";\nexport * from \"./models/services/ITenantAdminComponent.js\";\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IServerLivezResponse.js.map
@@ -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,4 +1,2 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
1
  export {};
4
2
  //# sourceMappingURL=IServerRootResponse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IServerRootResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IServerRootResponse.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The root text for the server.\n */\nexport interface IServerRootResponse {\n\t/**\n\t * The root text for the server.\n\t */\n\tbody: string;\n}\n"]}
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":"IHttpRequestContext.js","sourceRoot":"","sources":["../../../../src/models/protocol/IHttpRequestContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IHttpServerRequest } from \"./IHttpServerRequest.js\";\n\n/**\n * Context data from the HTTP request.\n */\nexport interface IHttpRequestContext {\n\t/**\n\t * The raw HTTP request.\n\t */\n\tserverRequest: IHttpServerRequest;\n\n\t/**\n\t * The state handed through the processors.\n\t */\n\tprocessorState: { [id: string]: unknown };\n\n\t/**\n\t * Logging component type for the request.\n\t */\n\tloggingComponentType?: string;\n}\n"]}
1
+ {"version":3,"file":"IHttpRequestContext.js","sourceRoot":"","sources":["../../../../src/models/protocol/IHttpRequestContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IHttpServerRequest } from \"./IHttpServerRequest.js\";\n\n/**\n * Context data from the HTTP request.\n */\nexport interface IHttpRequestContext {\n\t/**\n\t * The raw HTTP request.\n\t */\n\tserverRequest: IHttpServerRequest;\n\n\t/**\n\t * The state handed through the processors.\n\t */\n\tprocessorState: { [id: string]: unknown };\n\n\t/**\n\t * Logging component type for the request.\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * Hosting component type for the request.\n\t */\n\thostingComponentType?: 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 | number | boolean;\n}\n"]}
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 | number | boolean;\n}\n"]}
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":"IHttpServerRequest.js","sourceRoot":"","sources":["../../../../src/models/protocol/IHttpServerRequest.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { HttpMethod } from \"@twin.org/web\";\nimport type { IHttpRequest } from \"./IHttpRequest.js\";\n\n/**\n * Model for the standard parameters for an http request.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface IHttpServerRequest<T = any> extends IHttpRequest<T> {\n\t/**\n\t * The request method.\n\t */\n\tmethod?: HttpMethod;\n\n\t/**\n\t * The request url.\n\t */\n\turl?: string;\n}\n"]}
1
+ {"version":3,"file":"IHttpServerRequest.js","sourceRoot":"","sources":["../../../../src/models/protocol/IHttpServerRequest.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { HttpMethod } from \"@twin.org/web\";\nimport type { IHttpRequest } from \"./IHttpRequest.js\";\n\n/**\n * Model for the standard parameters for an http request.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface IHttpServerRequest<T = any> extends IHttpRequest<T> {\n\t/**\n\t * The request url.\n\t */\n\turl: string;\n\n\t/**\n\t * The request method.\n\t */\n\tmethod?: HttpMethod;\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 user must have one of the specified scopes to access the route.\n\t */\n\trequiredScope?: string[];\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 +1 @@
1
- {"version":3,"file":"IBaseRouteProcessor.js","sourceRoot":"","sources":["../../../../src/models/server/IBaseRouteProcessor.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IContextIds } from \"@twin.org/context\";\nimport type { IComponent } from \"@twin.org/core\";\nimport type { IHttpResponse } from \"../protocol/IHttpResponse.js\";\nimport type { IHttpServerRequest } from \"../protocol/IHttpServerRequest.js\";\nimport type { IBaseRoute } from \"../routes/IBaseRoute.js\";\n\n/**\n * The definition for a base processor for handling REST routes.\n */\nexport interface IBaseRouteProcessor<T = IBaseRoute, R = IHttpServerRequest> extends IComponent {\n\t/**\n\t * Features supported by this processor.\n\t * If a route has any of these features listed, this processor will be run for that route.\n\t * If this is not implemented, the processor will run for all routes.\n\t * @returns The features supported by this processor.\n\t */\n\tfeatures?(): string[];\n\n\t/**\n\t * Pre process the REST request for the specified route.\n\t * @param request The request to handle.\n\t * @param response The response data to send if any.\n\t * @param route The route being requested, if a matching one was found.\n\t * @param contextIds The context IDs of the request.\n\t * @param processorState The state handed through the processors.\n\t * @param loggingComponentType The logging component type for the request.\n\t * @returns Promise that resolves when the request is processed.\n\t */\n\tpre?(\n\t\trequest: R,\n\t\tresponse: IHttpResponse,\n\t\troute: T | undefined,\n\t\tcontextIds: IContextIds,\n\t\tprocessorState: { [id: string]: unknown },\n\t\tloggingComponentType?: string\n\t): Promise<void>;\n\n\t/**\n\t * Post process the REST request for the specified route.\n\t * @param request The request to handle.\n\t * @param response The response data to send if any.\n\t * @param route The route being requested, if a matching one was found.\n\t * @param contextIds The context IDs of the request.\n\t * @param processorState The state handed through the processors.\n\t * @param loggingComponentType The logging component type for the request.\n\t * @returns Promise that resolves when the request is processed.\n\t */\n\tpost?(\n\t\trequest: R,\n\t\tresponse: IHttpResponse,\n\t\troute: T | undefined,\n\t\tcontextIds: IContextIds,\n\t\tprocessorState: { [id: string]: unknown },\n\t\tloggingComponentType?: string\n\t): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"IBaseRouteProcessor.js","sourceRoot":"","sources":["../../../../src/models/server/IBaseRouteProcessor.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IContextIds } from \"@twin.org/context\";\nimport type { IComponent } from \"@twin.org/core\";\nimport type { IHttpResponse } from \"../protocol/IHttpResponse.js\";\nimport type { IHttpServerRequest } from \"../protocol/IHttpServerRequest.js\";\nimport type { IBaseRoute } from \"../routes/IBaseRoute.js\";\n\n/**\n * The definition for a base processor for handling REST routes.\n */\nexport interface IBaseRouteProcessor<T = IBaseRoute, R = IHttpServerRequest> extends IComponent {\n\t/**\n\t * Features supported by this processor.\n\t * If a route has any of these features listed, this processor will be run for that route.\n\t * If this is not implemented, the processor will run for all routes.\n\t * @returns The features supported by this processor.\n\t */\n\tfeatures?(): string[];\n\n\t/**\n\t * Pre process the REST request for the specified route.\n\t * @param request The request to handle.\n\t * @param response The response data to send if any.\n\t * @param route The route being requested, if a matching one was found.\n\t * @param contextIds The context IDs of the request.\n\t * @param processorState The state handed through the processors.\n\t * @param componentTypes The component types for the request.\n\t * @param componentTypes.loggingComponentType The logging component type.\n\t * @param componentTypes.hostingComponentType The hosting component type.\n\t * @returns Promise that resolves when the request is processed.\n\t */\n\tpre?(\n\t\trequest: R,\n\t\tresponse: IHttpResponse,\n\t\troute: T | undefined,\n\t\tcontextIds: IContextIds,\n\t\tprocessorState: { [id: string]: unknown },\n\t\tcomponentTypes?: {\n\t\t\tloggingComponentType?: string;\n\t\t\thostingComponentType?: string;\n\t\t}\n\t): Promise<void>;\n\n\t/**\n\t * Post process the REST request for the specified route.\n\t * @param request The request to handle.\n\t * @param response The response data to send if any.\n\t * @param route The route being requested, if a matching one was found.\n\t * @param contextIds The context IDs of the request.\n\t * @param processorState The state handed through the processors.\n\t * @param componentTypes The component types for the request.\n\t * @param componentTypes.loggingComponentType The logging component type.\n\t * @param componentTypes.hostingComponentType The hosting component type.\n\t * @returns Promise that resolves when the request is processed.\n\t */\n\tpost?(\n\t\trequest: R,\n\t\tresponse: IHttpResponse,\n\t\troute: T | undefined,\n\t\tcontextIds: IContextIds,\n\t\tprocessorState: { [id: string]: unknown },\n\t\tcomponentTypes?: {\n\t\t\tloggingComponentType?: string;\n\t\t\thostingComponentType?: string;\n\t\t}\n\t): Promise<void>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IRestRouteProcessor.js","sourceRoot":"","sources":["../../../../src/models/server/IRestRouteProcessor.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IBaseRouteProcessor } from \"./IBaseRouteProcessor.js\";\nimport type { IHttpResponse } from \"../protocol/IHttpResponse.js\";\nimport type { IHttpServerRequest } from \"../protocol/IHttpServerRequest.js\";\nimport type { IRestRoute } from \"../routes/IRestRoute.js\";\n\n/**\n * The definition for a processor for handling REST routes.\n */\nexport interface IRestRouteProcessor extends IBaseRouteProcessor<IRestRoute> {\n\t/**\n\t * Process the REST request for the specified route.\n\t * @param request The request to handle.\n\t * @param response The response data to send if any.\n\t * @param route The route being requested, if a matching one was found.\n\t * @param processorState The state handed through the processors.\n\t * @param loggingComponentType The logging component type for the request.\n\t * @returns Promise that resolves when the request is processed.\n\t */\n\tprocess?(\n\t\trequest: IHttpServerRequest,\n\t\tresponse: IHttpResponse,\n\t\troute: IRestRoute | undefined,\n\t\tprocessorState: { [id: string]: unknown },\n\t\tloggingComponentType?: string\n\t): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"IRestRouteProcessor.js","sourceRoot":"","sources":["../../../../src/models/server/IRestRouteProcessor.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IBaseRouteProcessor } from \"./IBaseRouteProcessor.js\";\nimport type { IHttpResponse } from \"../protocol/IHttpResponse.js\";\nimport type { IHttpServerRequest } from \"../protocol/IHttpServerRequest.js\";\nimport type { IRestRoute } from \"../routes/IRestRoute.js\";\n\n/**\n * The definition for a processor for handling REST routes.\n */\nexport interface IRestRouteProcessor extends IBaseRouteProcessor<IRestRoute> {\n\t/**\n\t * Process the REST request for the specified route.\n\t * @param request The request to handle.\n\t * @param response The response data to send if any.\n\t * @param route The route being requested, if a matching one was found.\n\t * @param processorState The state handed through the processors.\n\t * @param componentTypes The component types for the request.\n\t * @param componentTypes.loggingComponentType The logging component type.\n\t * @param componentTypes.hostingComponentType The hosting component type.\n\t * @returns Promise that resolves when the request is processed.\n\t */\n\tprocess?(\n\t\trequest: IHttpServerRequest,\n\t\tresponse: IHttpResponse,\n\t\troute: IRestRoute | undefined,\n\t\tprocessorState: { [id: string]: unknown },\n\t\tcomponentTypes?: {\n\t\t\tloggingComponentType?: string;\n\t\t\thostingComponentType?: string;\n\t\t}\n\t): Promise<void>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IHealthComponentInfo.js.map
@@ -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?: {\n\t\t/**\n\t\t * The name of the component.\n\t\t */\n\t\tname: string;\n\n\t\t/**\n\t\t * The status of the component.\n\t\t */\n\t\tstatus: HealthStatus;\n\n\t\t/**\n\t\t * The details for the status.\n\t\t */\n\t\tdetails?: string;\n\t}[];\n}\n"]}
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"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IHostingComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IHostingComponent.js","sourceRoot":"","sources":["../../../../src/models/services/IHostingComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\n\n/**\n * The information about the hosting of the API.\n */\nexport interface IHostingComponent extends IComponent {\n\t/**\n\t * Get the public origin for the hosting.\n\t * @param serverRequestUrl The url of the current server request if there is one.\n\t * @returns The public origin.\n\t */\n\tgetPublicOrigin(serverRequestUrl?: string): Promise<string>;\n\n\t/**\n\t * Get the public origin for the tenant if one exists.\n\t * @param tenantId The tenant identifier.\n\t * @returns The public origin for the tenant.\n\t */\n\tgetTenantOrigin(tenantId: string): Promise<string | undefined>;\n\n\t/**\n\t * Build a public url based on the public origin and the url provided.\n\t * @param url The url to build upon the public origin.\n\t * @returns The full url based on the public origin.\n\t */\n\tbuildPublicUrl(url: string): Promise<string>;\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(name: string, status: HealthStatus, details?: string): Promise<void>;\n\n\t/**\n\t * Remove the status of a component.\n\t * @param name The component name.\n\t * @returns Nothing.\n\t */\n\tremoveComponentHealth(name: string): Promise<void>;\n}\n"]}
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"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2025 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=ITenant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITenant.js","sourceRoot":"","sources":["../../../../src/models/services/ITenant.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Model defining the tenant.\n */\nexport interface ITenant {\n\t/**\n\t * The unique identifier for the tenant.\n\t */\n\tid: string;\n\n\t/**\n\t * The api key for the tenant.\n\t */\n\tapiKey: string;\n\n\t/**\n\t * The label of the tenant.\n\t */\n\tlabel: string;\n\n\t/**\n\t * The date the tenant was created.\n\t */\n\tdateCreated: string;\n\n\t/**\n\t * The date the tenant was modified.\n\t */\n\tdateModified: string;\n\n\t/**\n\t * The public origin available to the public for accessing the API.\n\t */\n\tpublicOrigin?: string;\n\n\t/**\n\t * Indicates whether the tenant is the node tenant.\n\t */\n\tisNodeTenant: boolean;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ITenantAdminComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITenantAdminComponent.js","sourceRoot":"","sources":["../../../../src/models/services/ITenantAdminComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { ITenant } from \"./ITenant.js\";\n\n/**\n * Configuration for the tenant admin component\n */\nexport interface ITenantAdminComponent extends IComponent {\n\t/**\n\t * Create a tenant.\n\t * @param tenant The tenant to store.\n\t * @returns The tenant id.\n\t */\n\tcreate(\n\t\ttenant: Omit<ITenant, \"id\" | \"dateCreated\" | \"dateModified\"> & { id?: string }\n\t): Promise<string>;\n\n\t/**\n\t * Update a tenant.\n\t * @param tenant The tenant to update.\n\t * @returns Nothing.\n\t */\n\tupdate(tenant: Partial<Omit<ITenant, \"dateCreated\" | \"dateModified\">>): Promise<void>;\n\n\t/**\n\t * Get a tenant by its id.\n\t * @param tenantId The id of the tenant.\n\t * @returns The tenant.\n\t * @throws Error if the tenant is not found.\n\t */\n\tget(tenantId: string): Promise<ITenant>;\n\n\t/**\n\t * Get a tenant by its api key.\n\t * @param apiKey The api key of the tenant.\n\t * @returns The tenant.\n\t * @throws Error if the tenant is not found.\n\t */\n\tgetByApiKey(apiKey: string): Promise<ITenant>;\n\n\t/**\n\t * Get a tenant by its public origin.\n\t * @param publicOrigin The origin of the tenant.\n\t * @returns The tenant.\n\t * @throws Error if the tenant is not found.\n\t */\n\tgetByPublicOrigin(publicOrigin: string): Promise<ITenant>;\n\n\t/**\n\t * Remove a tenant by its id.\n\t * @param tenantId The id of the tenant.\n\t * @returns Nothing.\n\t * @throws Error if the tenant is not found.\n\t */\n\tremove(tenantId: string): Promise<void>;\n\n\t/**\n\t * Query tenants with pagination.\n\t * @param options Optional query options.\n\t * @param options.isNodeTenant Whether to filter for node admin tenants.\n\t * @param cursor The cursor to start from.\n\t * @param limit The maximum number of tenants to return.\n\t * @returns The tenants and the next cursor if more tenants are available.\n\t */\n\tquery(\n\t\toptions?: { isNodeTenant?: boolean },\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{ tenants: ITenant[]; cursor?: string }>;\n}\n"]}
@@ -5,6 +5,12 @@ import type { IHttpResponse } from "../models/protocol/IHttpResponse.js";
5
5
  * Class to help with processing http errors.
6
6
  */
7
7
  export declare class HttpErrorHelper {
8
+ /**
9
+ * Mapping of error types to status codes.
10
+ */
11
+ static readonly ERROR_TYPE_MAP: {
12
+ [id: string]: HttpStatusCode;
13
+ };
8
14
  /**
9
15
  * Process the errors from the routes.
10
16
  * @param err The error to process.
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Class to help with handling http URLs.
3
+ */
4
+ export declare class HttpUrlHelper {
5
+ /**
6
+ * Extract the origin from the url which includes protocol,host,port.
7
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/URL/origin
8
+ * @param url The url to extract the origin from.
9
+ * @returns The extracted origin.
10
+ */
11
+ static extractOrigin(url: string): string | undefined;
12
+ /**
13
+ * Extract the path from the url.
14
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/URL/pathname
15
+ * @param url The url to extract the path from.
16
+ * @returns The extracted path.
17
+ */
18
+ static extractPath(url: string): string | undefined;
19
+ /**
20
+ * Extract the search from the url.
21
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/URL/search
22
+ * @param url The url to extract the search from.
23
+ * @returns The extracted search.
24
+ */
25
+ static extractSearch(url: string): string | undefined;
26
+ /**
27
+ * Extract the path and search from the url.
28
+ * @param url The url to extract the path and search from.
29
+ * @returns The extracted path and search.
30
+ */
31
+ static extractPathAndSearch(url: string): string | undefined;
32
+ /**
33
+ * Combine the urls parts.
34
+ * @param origin The origin to combine.
35
+ * @param pathAndSearch The path and search to combine.
36
+ * @returns The combined parts.
37
+ */
38
+ static combineParts(origin: string, pathAndSearch: string): string | undefined;
39
+ /**
40
+ * Replace the origin in the url.
41
+ * @param url The url to replace the origin in.
42
+ * @param newOrigin The new origin to use.
43
+ * @returns The url with the replaced origin.
44
+ */
45
+ static replaceOrigin(url: string, newOrigin?: string): string;
46
+ }
@@ -1,15 +1,15 @@
1
- export * from "./factories/authenticationGeneratorFactory.js";
2
1
  export * from "./factories/mimeTypeProcessorFactory.js";
3
2
  export * from "./factories/restRouteProcessorFactory.js";
4
3
  export * from "./factories/socketRouteProcessorFactory.js";
5
4
  export * from "./helpers/httpErrorHelper.js";
6
5
  export * from "./helpers/httpParameterHelper.js";
6
+ export * from "./helpers/httpUrlHelper.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
- export * from "./models/client/IAuthenticationGenerator.js";
13
13
  export * from "./models/config/IBaseRestClientConfig.js";
14
14
  export * from "./models/config/IBaseSocketClientConfig.js";
15
15
  export * from "./models/protocol/IHttpRequest.js";
@@ -51,6 +51,10 @@ export * from "./models/server/ISocketRouteProcessor.js";
51
51
  export * from "./models/server/IWebServer.js";
52
52
  export * from "./models/server/IWebServerOptions.js";
53
53
  export * from "./models/services/healthStatus.js";
54
+ export * from "./models/services/IHealthComponentInfo.js";
54
55
  export * from "./models/services/IHealthInfo.js";
56
+ export * from "./models/services/IHostingComponent.js";
55
57
  export * from "./models/services/IInformationComponent.js";
56
58
  export * from "./models/services/IServerInfo.js";
59
+ export * from "./models/services/ITenant.js";
60
+ export * from "./models/services/ITenantAdminComponent.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
  */
@@ -17,4 +17,8 @@ export interface IHttpRequestContext {
17
17
  * Logging component type for the request.
18
18
  */
19
19
  loggingComponentType?: string;
20
+ /**
21
+ * Hosting component type for the request.
22
+ */
23
+ hostingComponentType?: string;
20
24
  }
@@ -2,5 +2,5 @@
2
2
  * Model for the standard parameters for an http request.
3
3
  */
4
4
  export interface IHttpRequestPathParams {
5
- [id: string]: string | number | boolean;
5
+ [id: string]: string;
6
6
  }
@@ -2,5 +2,5 @@
2
2
  * Model used for Http request query parameters.
3
3
  */
4
4
  export interface IHttpRequestQuery {
5
- [id: string]: string | number | boolean;
5
+ [id: string]: string;
6
6
  }
@@ -5,11 +5,11 @@ import type { IHttpRequest } from "./IHttpRequest.js";
5
5
  */
6
6
  export interface IHttpServerRequest<T = any> extends IHttpRequest<T> {
7
7
  /**
8
- * The request method.
8
+ * The request url.
9
9
  */
10
- method?: HttpMethod;
10
+ url: string;
11
11
  /**
12
- * The request url.
12
+ * The request method.
13
13
  */
14
- url?: string;
14
+ method?: HttpMethod;
15
15
  }
@@ -11,9 +11,17 @@ 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;
21
+ /**
22
+ * The user must have one of the specified scopes to access the route.
23
+ */
24
+ requiredScope?: string[];
17
25
  /**
18
26
  * The features supported by additional processors to run for this route.
19
27
  */