@twin.org/api-models 0.0.2-next.9 → 0.0.3-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/factories/authenticationGeneratorFactory.js +9 -0
- package/dist/es/factories/authenticationGeneratorFactory.js.map +1 -0
- package/dist/es/factories/mimeTypeProcessorFactory.js +9 -0
- package/dist/es/factories/mimeTypeProcessorFactory.js.map +1 -0
- package/dist/es/factories/restRouteProcessorFactory.js +9 -0
- package/dist/es/factories/restRouteProcessorFactory.js.map +1 -0
- package/dist/es/factories/socketRouteProcessorFactory.js +9 -0
- package/dist/es/factories/socketRouteProcessorFactory.js.map +1 -0
- package/dist/es/helpers/httpErrorHelper.js +60 -0
- package/dist/es/helpers/httpErrorHelper.js.map +1 -0
- package/dist/es/helpers/httpParameterHelper.js +41 -0
- package/dist/es/helpers/httpParameterHelper.js.map +1 -0
- package/dist/es/index.js +59 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/api/IServerFavIconResponse.js +2 -0
- package/dist/es/models/api/IServerFavIconResponse.js.map +1 -0
- package/dist/es/models/api/IServerHealthResponse.js +2 -0
- package/dist/es/models/api/IServerHealthResponse.js.map +1 -0
- package/dist/es/models/api/IServerInfoResponse.js +2 -0
- package/dist/es/models/api/IServerInfoResponse.js.map +1 -0
- package/dist/es/models/api/IServerRootResponse.js +4 -0
- package/dist/es/models/api/IServerRootResponse.js.map +1 -0
- package/dist/es/models/api/IServerSpecResponse.js +2 -0
- package/dist/es/models/api/IServerSpecResponse.js.map +1 -0
- package/dist/es/models/client/IAuthenticationGenerator.js +2 -0
- package/dist/es/models/client/IAuthenticationGenerator.js.map +1 -0
- package/dist/es/models/config/IBaseRestClientConfig.js +2 -0
- package/dist/es/models/config/IBaseRestClientConfig.js.map +1 -0
- package/dist/es/models/config/IBaseSocketClientConfig.js +2 -0
- package/dist/es/models/config/IBaseSocketClientConfig.js.map +1 -0
- package/dist/es/models/protocol/IHttpRequest.js +2 -0
- package/dist/es/models/protocol/IHttpRequest.js.map +1 -0
- package/dist/es/models/protocol/IHttpRequestContext.js +2 -0
- package/dist/es/models/protocol/IHttpRequestContext.js.map +1 -0
- package/dist/es/models/protocol/IHttpRequestPathParams.js +4 -0
- package/dist/es/models/protocol/IHttpRequestPathParams.js.map +1 -0
- package/dist/es/models/protocol/IHttpRequestQuery.js +4 -0
- package/dist/es/models/protocol/IHttpRequestQuery.js.map +1 -0
- package/dist/es/models/protocol/IHttpResponse.js +2 -0
- package/dist/es/models/protocol/IHttpResponse.js.map +1 -0
- package/dist/es/models/protocol/IHttpServerRequest.js +2 -0
- package/dist/es/models/protocol/IHttpServerRequest.js.map +1 -0
- package/dist/es/models/protocol/ISocketRequestContext.js +2 -0
- package/dist/es/models/protocol/ISocketRequestContext.js.map +1 -0
- package/dist/es/models/protocol/ISocketServerRequest.js +2 -0
- package/dist/es/models/protocol/ISocketServerRequest.js.map +1 -0
- package/dist/es/models/requests/INoContentRequest.js +2 -0
- package/dist/es/models/requests/INoContentRequest.js.map +1 -0
- package/dist/es/models/responses/errors/IBadRequestResponse.js +2 -0
- package/dist/es/models/responses/errors/IBadRequestResponse.js.map +1 -0
- package/dist/es/models/responses/errors/IConflictResponse.js +2 -0
- package/dist/es/models/responses/errors/IConflictResponse.js.map +1 -0
- package/dist/es/models/responses/errors/IForbiddenResponse.js +2 -0
- package/dist/es/models/responses/errors/IForbiddenResponse.js.map +1 -0
- package/dist/es/models/responses/errors/IInternalServerErrorResponse.js +2 -0
- package/dist/es/models/responses/errors/IInternalServerErrorResponse.js.map +1 -0
- package/dist/es/models/responses/errors/INotFoundResponse.js +2 -0
- package/dist/es/models/responses/errors/INotFoundResponse.js.map +1 -0
- package/dist/es/models/responses/errors/IUnauthorizedResponse.js +2 -0
- package/dist/es/models/responses/errors/IUnauthorizedResponse.js.map +1 -0
- package/dist/es/models/responses/errors/IUnprocessableEntityResponse.js +2 -0
- package/dist/es/models/responses/errors/IUnprocessableEntityResponse.js.map +1 -0
- package/dist/es/models/responses/success/IAcceptedResponse.js +2 -0
- package/dist/es/models/responses/success/IAcceptedResponse.js.map +1 -0
- package/dist/es/models/responses/success/ICreatedResponse.js +2 -0
- package/dist/es/models/responses/success/ICreatedResponse.js.map +1 -0
- package/dist/es/models/responses/success/INoContentResponse.js +2 -0
- package/dist/es/models/responses/success/INoContentResponse.js.map +1 -0
- package/dist/es/models/responses/success/IOkResponse.js +2 -0
- package/dist/es/models/responses/success/IOkResponse.js.map +1 -0
- package/dist/es/models/routes/IBaseRoute.js +4 -0
- package/dist/es/models/routes/IBaseRoute.js.map +1 -0
- package/dist/es/models/routes/IBaseRouteEntryPoint.js +2 -0
- package/dist/es/models/routes/IBaseRouteEntryPoint.js.map +1 -0
- package/dist/es/models/routes/IRestRoute.js +2 -0
- package/dist/es/models/routes/IRestRoute.js.map +1 -0
- package/dist/es/models/routes/IRestRouteEntryPoint.js +2 -0
- package/dist/es/models/routes/IRestRouteEntryPoint.js.map +1 -0
- package/dist/es/models/routes/IRestRouteExample.js +4 -0
- package/dist/es/models/routes/IRestRouteExample.js.map +1 -0
- package/dist/es/models/routes/IRestRouteRequestExample.js +2 -0
- package/dist/es/models/routes/IRestRouteRequestExample.js.map +1 -0
- package/dist/es/models/routes/IRestRouteResponseAttachmentOptions.js +4 -0
- package/dist/es/models/routes/IRestRouteResponseAttachmentOptions.js.map +1 -0
- package/dist/es/models/routes/IRestRouteResponseExample.js +2 -0
- package/dist/es/models/routes/IRestRouteResponseExample.js.map +1 -0
- package/dist/es/models/routes/IRestRouteResponseOptions.js +2 -0
- package/dist/es/models/routes/IRestRouteResponseOptions.js.map +1 -0
- package/dist/es/models/routes/ISocketRoute.js +2 -0
- package/dist/es/models/routes/ISocketRoute.js.map +1 -0
- package/dist/es/models/routes/ISocketRouteEntryPoint.js +2 -0
- package/dist/es/models/routes/ISocketRouteEntryPoint.js.map +1 -0
- package/dist/es/models/routes/ITag.js +4 -0
- package/dist/es/models/routes/ITag.js.map +1 -0
- package/dist/es/models/server/IBaseRouteProcessor.js +2 -0
- package/dist/es/models/server/IBaseRouteProcessor.js.map +1 -0
- package/dist/es/models/server/IMimeTypeProcessor.js +2 -0
- package/dist/es/models/server/IMimeTypeProcessor.js.map +1 -0
- package/dist/es/models/server/IRestRouteProcessor.js +2 -0
- package/dist/es/models/server/IRestRouteProcessor.js.map +1 -0
- package/dist/es/models/server/ISocketRouteProcessor.js +2 -0
- package/dist/es/models/server/ISocketRouteProcessor.js.map +1 -0
- package/dist/es/models/server/IWebServer.js +2 -0
- package/dist/es/models/server/IWebServer.js.map +1 -0
- package/dist/es/models/server/IWebServerOptions.js +2 -0
- package/dist/es/models/server/IWebServerOptions.js.map +1 -0
- package/dist/es/models/services/IHealthInfo.js +2 -0
- package/dist/es/models/services/IHealthInfo.js.map +1 -0
- package/dist/es/models/services/IInformationComponent.js +2 -0
- package/dist/es/models/services/IInformationComponent.js.map +1 -0
- package/dist/es/models/services/IServerInfo.js +4 -0
- package/dist/es/models/services/IServerInfo.js.map +1 -0
- package/dist/es/models/services/healthStatus.js +21 -0
- package/dist/es/models/services/healthStatus.js.map +1 -0
- package/dist/types/factories/authenticationGeneratorFactory.d.ts +6 -0
- package/dist/types/factories/mimeTypeProcessorFactory.d.ts +1 -1
- package/dist/types/factories/restRouteProcessorFactory.d.ts +1 -1
- package/dist/types/factories/socketRouteProcessorFactory.d.ts +1 -1
- package/dist/types/helpers/httpErrorHelper.d.ts +1 -1
- package/dist/types/index.d.ts +56 -55
- package/dist/types/models/api/IServerHealthResponse.d.ts +1 -1
- package/dist/types/models/api/IServerInfoResponse.d.ts +1 -1
- package/dist/types/models/client/IAuthenticationGenerator.d.ts +14 -0
- package/dist/types/models/protocol/IHttpRequest.d.ts +2 -2
- package/dist/types/models/protocol/IHttpRequestContext.d.ts +2 -3
- package/dist/types/models/protocol/IHttpServerRequest.d.ts +1 -1
- package/dist/types/models/protocol/ISocketRequestContext.d.ts +1 -1
- package/dist/types/models/protocol/ISocketServerRequest.d.ts +1 -1
- package/dist/types/models/requests/INoContentRequest.d.ts +1 -1
- package/dist/types/models/routes/IBaseRoute.d.ts +10 -0
- package/dist/types/models/routes/IBaseRouteEntryPoint.d.ts +1 -1
- package/dist/types/models/routes/IRestRoute.d.ts +7 -7
- package/dist/types/models/routes/IRestRouteEntryPoint.d.ts +2 -2
- package/dist/types/models/routes/IRestRouteRequestExample.d.ts +1 -1
- package/dist/types/models/routes/IRestRouteResponseExample.d.ts +1 -1
- package/dist/types/models/routes/IRestRouteResponseOptions.d.ts +1 -1
- package/dist/types/models/routes/ISocketRoute.d.ts +4 -4
- package/dist/types/models/routes/ISocketRouteEntryPoint.d.ts +2 -2
- package/dist/types/models/server/IBaseRouteProcessor.d.ts +15 -8
- package/dist/types/models/server/IRestRouteProcessor.d.ts +5 -7
- package/dist/types/models/server/ISocketRouteProcessor.d.ts +5 -7
- package/dist/types/models/server/IWebServer.d.ts +5 -5
- package/dist/types/models/services/IHealthInfo.d.ts +1 -1
- package/dist/types/models/services/IInformationComponent.d.ts +3 -3
- package/docs/changelog.md +47 -0
- package/docs/reference/classes/HttpParameterHelper.md +8 -8
- package/docs/reference/index.md +2 -1
- package/docs/reference/interfaces/IAuthenticationGenerator.md +35 -0
- package/docs/reference/interfaces/IBaseRoute.md +20 -0
- package/docs/reference/interfaces/IBaseRouteProcessor.md +26 -10
- package/docs/reference/interfaces/IHttpRequestContext.md +0 -28
- package/docs/reference/interfaces/IInformationComponent.md +2 -2
- package/docs/reference/interfaces/IRestRoute.md +28 -0
- package/docs/reference/interfaces/IRestRouteProcessor.md +32 -18
- package/docs/reference/interfaces/ISocketRequestContext.md +0 -24
- package/docs/reference/interfaces/ISocketRoute.md +28 -0
- package/docs/reference/interfaces/ISocketRouteProcessor.md +34 -20
- package/docs/reference/variables/AuthenticationGeneratorFactory.md +5 -0
- package/locales/en.json +1 -9
- package/package.json +23 -8
- package/dist/cjs/index.cjs +0 -154
- package/dist/esm/index.mjs +0 -147
- package/dist/types/models/protocol/IHttpRequestIdentity.d.ts +0 -13
- package/docs/reference/interfaces/IHttpRequestIdentity.md +0 -23
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRestRouteRequestExample.js","sourceRoot":"","sources":["../../../../src/models/routes/IRestRouteRequestExample.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteExample } from \"./IRestRouteExample.js\";\n\n/**\n * Interface which defines a REST route request example.\n */\nexport interface IRestRouteRequestExample<T> extends IRestRouteExample {\n\t/**\n\t * The example request object.\n\t */\n\trequest: T;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRestRouteResponseAttachmentOptions.js","sourceRoot":"","sources":["../../../../src/models/routes/IRestRouteResponseAttachmentOptions.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 REST route response for attachments.\n */\nexport interface IRestRouteResponseAttachmentOptions {\n\t/**\n\t * The content type to use in the response.\n\t */\n\tmimeType?: string;\n\n\t/**\n\t * The filename to use in content disposition.\n\t */\n\tfilename?: string;\n\n\t/**\n\t * Whether to inline the content.\n\t */\n\tinline?: boolean;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRestRouteResponseExample.js","sourceRoot":"","sources":["../../../../src/models/routes/IRestRouteResponseExample.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteExample } from \"./IRestRouteExample.js\";\n\n/**\n * Interface which defines a REST route response example.\n */\nexport interface IRestRouteResponseExample<T> extends IRestRouteExample {\n\t/**\n\t * The example response object.\n\t */\n\tresponse: T;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRestRouteResponseOptions.js","sourceRoot":"","sources":["../../../../src/models/routes/IRestRouteResponseOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteResponseAttachmentOptions } from \"./IRestRouteResponseAttachmentOptions.js\";\n\n/**\n * Interface which defines a REST route response.\n */\nexport interface IRestRouteResponseOptions {\n\t/**\n\t * Additional options that can be used to control the response.\n\t */\n\tattachment?: IRestRouteResponseAttachmentOptions;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ISocketRoute.js","sourceRoot":"","sources":["../../../../src/models/routes/ISocketRoute.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IBaseRoute } from \"./IBaseRoute.js\";\nimport type { IHttpRequest } from \"../protocol/IHttpRequest.js\";\nimport type { IHttpResponse } from \"../protocol/IHttpResponse.js\";\nimport type { ISocketRequestContext } from \"../protocol/ISocketRequestContext.js\";\n\n/**\n * Interface which defines a socket route.\n */\nexport interface ISocketRoute<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tT extends IHttpRequest = any,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tU extends IHttpResponse = any\n> extends IBaseRoute {\n\t/**\n\t * The handler module.\n\t */\n\thandler: (\n\t\t/**\n\t\t * The request context.\n\t\t */\n\t\tsocketRequestContext: ISocketRequestContext,\n\n\t\t/**\n\t\t * The request object.\n\t\t */\n\t\trequest: T,\n\n\t\t/**\n\t\t * The function to emit an event.\n\t\t */\n\t\temit: (event: string, response: U) => Promise<void>\n\t) => void;\n\n\t/**\n\t * The connected handler.\n\t */\n\tconnected?: (\n\t\t/**\n\t\t * The request context.\n\t\t */\n\t\tsocketRequestContext: ISocketRequestContext\n\t) => void;\n\n\t/**\n\t * The disconnected handler.\n\t */\n\tdisconnected?: (\n\t\t/**\n\t\t * The request context.\n\t\t */\n\t\tsocketRequestContext: ISocketRequestContext\n\t) => void;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ISocketRouteEntryPoint.js","sourceRoot":"","sources":["../../../../src/models/routes/ISocketRouteEntryPoint.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IBaseRouteEntryPoint } from \"./IBaseRouteEntryPoint.js\";\nimport type { ISocketRoute } from \"./ISocketRoute.js\";\n\n/**\n * Route entry points are used for exposing the socket routes from a package.\n */\nexport type ISocketRouteEntryPoint = IBaseRouteEntryPoint<ISocketRoute>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ITag.js","sourceRoot":"","sources":["../../../../src/models/routes/ITag.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Tag for routes used to generate OpenAPI information.\n */\nexport interface ITag {\n\t/**\n\t * The name of the tag.\n\t */\n\tname: string;\n\n\t/**\n\t * Description for the tag.\n\t */\n\tdescription: string;\n}\n"]}
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMimeTypeProcessor.js","sourceRoot":"","sources":["../../../../src/models/server/IMimeTypeProcessor.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\n\n/**\n * The definition for a handler for a specific MIME type.\n */\nexport interface IMimeTypeProcessor extends IComponent {\n\t/**\n\t * Get the MIME types that this handler can handle.\n\t * @returns The MIME types that this handler can handle.\n\t */\n\tgetTypes(): string[];\n\n\t/**\n\t * Handle content.\n\t * @param body The body to process.\n\t * @returns The processed body.\n\t */\n\thandle(body: Uint8Array): Promise<unknown>;\n}\n"]}
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ISocketRouteProcessor.js","sourceRoot":"","sources":["../../../../src/models/server/ISocketRouteProcessor.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 { ISocketServerRequest } from \"../protocol/ISocketServerRequest.js\";\nimport type { ISocketRoute } from \"../routes/ISocketRoute.js\";\n\n/**\n * The definition for a processor for handling socket routes.\n */\nexport interface ISocketRouteProcessor\n\textends IBaseRouteProcessor<ISocketRoute, ISocketServerRequest> {\n\t/**\n\t * Process the connected event.\n\t * @param request The server request object containing the socket id and other parameters.\n\t * @param route The route being requested, if a matching one was found.\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\tconnected?(\n\t\trequest: ISocketServerRequest,\n\t\troute: ISocketRoute | undefined,\n\t\tloggingComponentType?: string\n\t): Promise<void>;\n\n\t/**\n\t * Process the disconnected event.\n\t * @param request The server request object containing the socket id and other parameters.\n\t * @param route The route being requested, if a matching one was found.\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\tdisconnected?(\n\t\trequest: ISocketServerRequest,\n\t\troute: ISocketRoute | undefined,\n\t\tloggingComponentType?: string\n\t): Promise<void>;\n\n\t/**\n\t * Process the REST request for the specified route.\n\t * @param request The server request object containing the socket id and other parameters.\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 responseEmitter The function to emit a response.\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: ISocketServerRequest,\n\t\tresponse: IHttpResponse,\n\t\troute: ISocketRoute | undefined,\n\t\tprocessorState: { [id: string]: unknown },\n\t\tresponseEmitter: (topic: string, response: IHttpResponse) => Promise<void>,\n\t\tloggingComponentType?: string\n\t): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IWebServer.js","sourceRoot":"","sources":["../../../../src/models/server/IWebServer.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteProcessor } from \"./IRestRouteProcessor.js\";\nimport type { ISocketRouteProcessor } from \"./ISocketRouteProcessor.js\";\nimport type { IWebServerOptions } from \"./IWebServerOptions.js\";\nimport type { IRestRoute } from \"../routes/IRestRoute.js\";\nimport type { ISocketRoute } from \"../routes/ISocketRoute.js\";\n\n/**\n * Interface describing a web server.\n */\nexport interface IWebServer<T> {\n\t/**\n\t * Get the web server instance.\n\t * @returns The web server instance.\n\t */\n\tgetInstance(): T;\n\n\t/**\n\t * Build the server.\n\t * @param restRouteProcessors The processors for incoming requests over REST.\n\t * @param restRoutes The REST routes.\n\t * @param socketRouteProcessors The processors for incoming requests over Sockets.\n\t * @param socketRoutes The socket routes.\n\t * @param options Options for building the server.\n\t * @returns Nothing.\n\t */\n\tbuild(\n\t\trestRouteProcessors?: IRestRouteProcessor[],\n\t\trestRoutes?: IRestRoute[],\n\t\tsocketRouteProcessors?: ISocketRouteProcessor[],\n\t\tsocketRoutes?: ISocketRoute[],\n\t\toptions?: IWebServerOptions\n\t): Promise<void>;\n\n\t/**\n\t * Start the server.\n\t * @returns Nothing.\n\t */\n\tstart(): Promise<void>;\n\n\t/**\n\t * Stop the server.\n\t * @returns Nothing.\n\t */\n\tstop(): Promise<void>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IWebServerOptions.js","sourceRoot":"","sources":["../../../../src/models/server/IWebServerOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { HttpMethod } from \"@twin.org/web\";\n\n/**\n * Options for the web server.\n */\nexport interface IWebServerOptions {\n\t/**\n\t * The port to bind the web server to.\n\t * @default 3000\n\t */\n\tport?: number;\n\n\t/**\n\t * The address to bind the web server to.\n\t * @default localhost\n\t */\n\thost?: string;\n\n\t/**\n\t * The methods that the server accepts.\n\t * @default [\"GET\", \"PUT\", \"POST\", \"DELETE\", \"OPTIONS\"]\n\t */\n\tmethods?: HttpMethod[];\n\n\t/**\n\t * Any additional allowed headers.\n\t */\n\tallowedHeaders?: string[];\n\n\t/**\n\t * And additional exposed headers.\n\t */\n\texposedHeaders?: string[];\n\n\t/**\n\t * The allowed CORS domains.\n\t * @default [\"*\"]\n\t */\n\tcorsOrigins?: string | string[];\n}\n"]}
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IServerInfo.js","sourceRoot":"","sources":["../../../../src/models/services/IServerInfo.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The information about the server.\n */\nexport interface IServerInfo {\n\t/**\n\t * The application name.\n\t */\n\tname: string;\n\n\t/**\n\t * The version of the server.\n\t */\n\tversion: string;\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
/**
|
|
4
|
+
* The health status of the component.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const HealthStatus = {
|
|
8
|
+
/**
|
|
9
|
+
* OK.
|
|
10
|
+
*/
|
|
11
|
+
Ok: "ok",
|
|
12
|
+
/**
|
|
13
|
+
* Warning.
|
|
14
|
+
*/
|
|
15
|
+
Warning: "warning",
|
|
16
|
+
/**
|
|
17
|
+
* Error.
|
|
18
|
+
*/
|
|
19
|
+
Error: "error"
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=healthStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"healthStatus.js","sourceRoot":"","sources":["../../../../src/models/services/healthStatus.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B;;OAEG;IACH,EAAE,EAAE,IAAI;IAER;;OAEG;IACH,OAAO,EAAE,SAAS;IAElB;;OAEG;IACH,KAAK,EAAE,OAAO;CACL,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The health status of the component.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const HealthStatus = {\n\t/**\n\t * OK.\n\t */\n\tOk: \"ok\",\n\n\t/**\n\t * Warning.\n\t */\n\tWarning: \"warning\",\n\n\t/**\n\t * Error.\n\t */\n\tError: \"error\"\n} as const;\n\n/**\n * The health status of the component.\n */\nexport type HealthStatus = (typeof HealthStatus)[keyof typeof HealthStatus];\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Factory } from "@twin.org/core";
|
|
2
|
+
import type { IAuthenticationGenerator } from "../models/client/IAuthenticationGenerator.js";
|
|
3
|
+
/**
|
|
4
|
+
* Factory for creating implementation of authentication generator types.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AuthenticationGeneratorFactory: Factory<IAuthenticationGenerator>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Factory } from "@twin.org/core";
|
|
2
|
-
import type { IMimeTypeProcessor } from "../models/server/IMimeTypeProcessor";
|
|
2
|
+
import type { IMimeTypeProcessor } from "../models/server/IMimeTypeProcessor.js";
|
|
3
3
|
/**
|
|
4
4
|
* Factory for creating implementation of mime type processor types.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Factory } from "@twin.org/core";
|
|
2
|
-
import type { IRestRouteProcessor } from "../models/server/IRestRouteProcessor";
|
|
2
|
+
import type { IRestRouteProcessor } from "../models/server/IRestRouteProcessor.js";
|
|
3
3
|
/**
|
|
4
4
|
* Factory for creating implementation of REST route processor types.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Factory } from "@twin.org/core";
|
|
2
|
-
import type { ISocketRouteProcessor } from "../models/server/ISocketRouteProcessor";
|
|
2
|
+
import type { ISocketRouteProcessor } from "../models/server/ISocketRouteProcessor.js";
|
|
3
3
|
/**
|
|
4
4
|
* Factory for creating implementation of socket route processor types.
|
|
5
5
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type IError } from "@twin.org/core";
|
|
2
2
|
import { HttpStatusCode } from "@twin.org/web";
|
|
3
|
-
import type { IHttpResponse } from "../models/protocol/IHttpResponse";
|
|
3
|
+
import type { IHttpResponse } from "../models/protocol/IHttpResponse.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class to help with processing http errors.
|
|
6
6
|
*/
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
export * from "./factories/
|
|
2
|
-
export * from "./factories/
|
|
3
|
-
export * from "./factories/
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./helpers/
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./models/api/
|
|
8
|
-
export * from "./models/api/
|
|
9
|
-
export * from "./models/api/
|
|
10
|
-
export * from "./models/api/
|
|
11
|
-
export * from "./models/
|
|
12
|
-
export * from "./models/
|
|
13
|
-
export * from "./models/
|
|
14
|
-
export * from "./models/
|
|
15
|
-
export * from "./models/protocol/
|
|
16
|
-
export * from "./models/protocol/
|
|
17
|
-
export * from "./models/protocol/
|
|
18
|
-
export * from "./models/protocol/
|
|
19
|
-
export * from "./models/protocol/
|
|
20
|
-
export * from "./models/protocol/
|
|
21
|
-
export * from "./models/protocol/
|
|
22
|
-
export * from "./models/
|
|
23
|
-
export * from "./models/
|
|
24
|
-
export * from "./models/responses/errors/
|
|
25
|
-
export * from "./models/responses/errors/
|
|
26
|
-
export * from "./models/responses/errors/
|
|
27
|
-
export * from "./models/responses/errors/
|
|
28
|
-
export * from "./models/responses/errors/
|
|
29
|
-
export * from "./models/responses/errors/
|
|
30
|
-
export * from "./models/responses/
|
|
31
|
-
export * from "./models/responses/success/
|
|
32
|
-
export * from "./models/responses/success/
|
|
33
|
-
export * from "./models/responses/success/
|
|
34
|
-
export * from "./models/
|
|
35
|
-
export * from "./models/routes/
|
|
36
|
-
export * from "./models/routes/
|
|
37
|
-
export * from "./models/routes/
|
|
38
|
-
export * from "./models/routes/
|
|
39
|
-
export * from "./models/routes/
|
|
40
|
-
export * from "./models/routes/
|
|
41
|
-
export * from "./models/routes/
|
|
42
|
-
export * from "./models/routes/
|
|
43
|
-
export * from "./models/routes/
|
|
44
|
-
export * from "./models/routes/
|
|
45
|
-
export * from "./models/routes/
|
|
46
|
-
export * from "./models/
|
|
47
|
-
export * from "./models/server/
|
|
48
|
-
export * from "./models/server/
|
|
49
|
-
export * from "./models/server/
|
|
50
|
-
export * from "./models/server/
|
|
51
|
-
export * from "./models/server/
|
|
52
|
-
export * from "./models/
|
|
53
|
-
export * from "./models/services/
|
|
54
|
-
export * from "./models/services/
|
|
55
|
-
export * from "./models/services/
|
|
1
|
+
export * from "./factories/authenticationGeneratorFactory.js";
|
|
2
|
+
export * from "./factories/mimeTypeProcessorFactory.js";
|
|
3
|
+
export * from "./factories/restRouteProcessorFactory.js";
|
|
4
|
+
export * from "./factories/socketRouteProcessorFactory.js";
|
|
5
|
+
export * from "./helpers/httpErrorHelper.js";
|
|
6
|
+
export * from "./helpers/httpParameterHelper.js";
|
|
7
|
+
export * from "./models/api/IServerFavIconResponse.js";
|
|
8
|
+
export * from "./models/api/IServerHealthResponse.js";
|
|
9
|
+
export * from "./models/api/IServerInfoResponse.js";
|
|
10
|
+
export * from "./models/api/IServerRootResponse.js";
|
|
11
|
+
export * from "./models/api/IServerSpecResponse.js";
|
|
12
|
+
export * from "./models/client/IAuthenticationGenerator.js";
|
|
13
|
+
export * from "./models/config/IBaseRestClientConfig.js";
|
|
14
|
+
export * from "./models/config/IBaseSocketClientConfig.js";
|
|
15
|
+
export * from "./models/protocol/IHttpRequest.js";
|
|
16
|
+
export * from "./models/protocol/IHttpRequestContext.js";
|
|
17
|
+
export * from "./models/protocol/IHttpRequestPathParams.js";
|
|
18
|
+
export * from "./models/protocol/IHttpRequestQuery.js";
|
|
19
|
+
export * from "./models/protocol/IHttpResponse.js";
|
|
20
|
+
export * from "./models/protocol/IHttpServerRequest.js";
|
|
21
|
+
export * from "./models/protocol/ISocketRequestContext.js";
|
|
22
|
+
export * from "./models/protocol/ISocketServerRequest.js";
|
|
23
|
+
export * from "./models/requests/INoContentRequest.js";
|
|
24
|
+
export * from "./models/responses/errors/IBadRequestResponse.js";
|
|
25
|
+
export * from "./models/responses/errors/IConflictResponse.js";
|
|
26
|
+
export * from "./models/responses/errors/IForbiddenResponse.js";
|
|
27
|
+
export * from "./models/responses/errors/IInternalServerErrorResponse.js";
|
|
28
|
+
export * from "./models/responses/errors/INotFoundResponse.js";
|
|
29
|
+
export * from "./models/responses/errors/IUnauthorizedResponse.js";
|
|
30
|
+
export * from "./models/responses/errors/IUnprocessableEntityResponse.js";
|
|
31
|
+
export * from "./models/responses/success/IAcceptedResponse.js";
|
|
32
|
+
export * from "./models/responses/success/ICreatedResponse.js";
|
|
33
|
+
export * from "./models/responses/success/INoContentResponse.js";
|
|
34
|
+
export * from "./models/responses/success/IOkResponse.js";
|
|
35
|
+
export * from "./models/routes/IBaseRoute.js";
|
|
36
|
+
export * from "./models/routes/IBaseRouteEntryPoint.js";
|
|
37
|
+
export * from "./models/routes/IRestRoute.js";
|
|
38
|
+
export * from "./models/routes/IRestRouteEntryPoint.js";
|
|
39
|
+
export * from "./models/routes/IRestRouteExample.js";
|
|
40
|
+
export * from "./models/routes/IRestRouteRequestExample.js";
|
|
41
|
+
export * from "./models/routes/IRestRouteResponseAttachmentOptions.js";
|
|
42
|
+
export * from "./models/routes/IRestRouteResponseExample.js";
|
|
43
|
+
export * from "./models/routes/IRestRouteResponseOptions.js";
|
|
44
|
+
export * from "./models/routes/ISocketRoute.js";
|
|
45
|
+
export * from "./models/routes/ISocketRouteEntryPoint.js";
|
|
46
|
+
export * from "./models/routes/ITag.js";
|
|
47
|
+
export * from "./models/server/IBaseRouteProcessor.js";
|
|
48
|
+
export * from "./models/server/IMimeTypeProcessor.js";
|
|
49
|
+
export * from "./models/server/IRestRouteProcessor.js";
|
|
50
|
+
export * from "./models/server/ISocketRouteProcessor.js";
|
|
51
|
+
export * from "./models/server/IWebServer.js";
|
|
52
|
+
export * from "./models/server/IWebServerOptions.js";
|
|
53
|
+
export * from "./models/services/healthStatus.js";
|
|
54
|
+
export * from "./models/services/IHealthInfo.js";
|
|
55
|
+
export * from "./models/services/IInformationComponent.js";
|
|
56
|
+
export * from "./models/services/IServerInfo.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IComponent } from "@twin.org/core";
|
|
2
|
+
import type { IHttpHeaders } from "@twin.org/web";
|
|
3
|
+
/**
|
|
4
|
+
* Definition for the authentication generator component.
|
|
5
|
+
*/
|
|
6
|
+
export interface IAuthenticationGenerator extends IComponent {
|
|
7
|
+
/**
|
|
8
|
+
* Adds authentication information to the request headers.
|
|
9
|
+
* @param requestHeaders The request headers to add authentication information to.
|
|
10
|
+
* @param authData Optional authentication data passed from the request.
|
|
11
|
+
* @returns A promise that resolves when the authentication information has been added.
|
|
12
|
+
*/
|
|
13
|
+
addAuthentication(requestHeaders: IHttpHeaders, authData?: unknown): Promise<void>;
|
|
14
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IHttpHeaders } from "@twin.org/web";
|
|
2
|
-
import type { IHttpRequestPathParams } from "./IHttpRequestPathParams";
|
|
3
|
-
import type { IHttpRequestQuery } from "./IHttpRequestQuery";
|
|
2
|
+
import type { IHttpRequestPathParams } from "./IHttpRequestPathParams.js";
|
|
3
|
+
import type { IHttpRequestQuery } from "./IHttpRequestQuery.js";
|
|
4
4
|
/**
|
|
5
5
|
* Model for the standard parameters for an http request.
|
|
6
6
|
*/
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { IHttpServerRequest } from "./IHttpServerRequest";
|
|
1
|
+
import type { IHttpServerRequest } from "./IHttpServerRequest.js";
|
|
3
2
|
/**
|
|
4
3
|
* Context data from the HTTP request.
|
|
5
4
|
*/
|
|
6
|
-
export interface IHttpRequestContext
|
|
5
|
+
export interface IHttpRequestContext {
|
|
7
6
|
/**
|
|
8
7
|
* The raw HTTP request.
|
|
9
8
|
*/
|
|
@@ -14,4 +14,14 @@ export interface IBaseRoute {
|
|
|
14
14
|
* Skips the authentication for this route.
|
|
15
15
|
*/
|
|
16
16
|
skipAuth?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The features supported by additional processors to run for this route.
|
|
19
|
+
*/
|
|
20
|
+
processorFeatures?: string[];
|
|
21
|
+
/**
|
|
22
|
+
* The data for additional processors to run for this route.
|
|
23
|
+
*/
|
|
24
|
+
processorData?: {
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
};
|
|
17
27
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { HttpMethod } from "@twin.org/web";
|
|
2
|
-
import type { IBaseRoute } from "./IBaseRoute";
|
|
3
|
-
import type { IRestRouteRequestExample } from "./IRestRouteRequestExample";
|
|
4
|
-
import type { IRestRouteResponseExample } from "./IRestRouteResponseExample";
|
|
5
|
-
import type { IRestRouteResponseOptions } from "./IRestRouteResponseOptions";
|
|
6
|
-
import type { IHttpRequest } from "../protocol/IHttpRequest";
|
|
7
|
-
import type { IHttpRequestContext } from "../protocol/IHttpRequestContext";
|
|
8
|
-
import type { IHttpResponse } from "../protocol/IHttpResponse";
|
|
2
|
+
import type { IBaseRoute } from "./IBaseRoute.js";
|
|
3
|
+
import type { IRestRouteRequestExample } from "./IRestRouteRequestExample.js";
|
|
4
|
+
import type { IRestRouteResponseExample } from "./IRestRouteResponseExample.js";
|
|
5
|
+
import type { IRestRouteResponseOptions } from "./IRestRouteResponseOptions.js";
|
|
6
|
+
import type { IHttpRequest } from "../protocol/IHttpRequest.js";
|
|
7
|
+
import type { IHttpRequestContext } from "../protocol/IHttpRequestContext.js";
|
|
8
|
+
import type { IHttpResponse } from "../protocol/IHttpResponse.js";
|
|
9
9
|
/**
|
|
10
10
|
* Interface which defines a REST route.
|
|
11
11
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IBaseRouteEntryPoint } from "./IBaseRouteEntryPoint";
|
|
2
|
-
import type { IRestRoute } from "./IRestRoute";
|
|
1
|
+
import type { IBaseRouteEntryPoint } from "./IBaseRouteEntryPoint.js";
|
|
2
|
+
import type { IRestRoute } from "./IRestRoute.js";
|
|
3
3
|
/**
|
|
4
4
|
* Route entry points are used for exposing the REST routes from a package.
|
|
5
5
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IBaseRoute } from "./IBaseRoute";
|
|
2
|
-
import type { IHttpRequest } from "../protocol/IHttpRequest";
|
|
3
|
-
import type { IHttpResponse } from "../protocol/IHttpResponse";
|
|
4
|
-
import type { ISocketRequestContext } from "../protocol/ISocketRequestContext";
|
|
1
|
+
import type { IBaseRoute } from "./IBaseRoute.js";
|
|
2
|
+
import type { IHttpRequest } from "../protocol/IHttpRequest.js";
|
|
3
|
+
import type { IHttpResponse } from "../protocol/IHttpResponse.js";
|
|
4
|
+
import type { ISocketRequestContext } from "../protocol/ISocketRequestContext.js";
|
|
5
5
|
/**
|
|
6
6
|
* Interface which defines a socket route.
|
|
7
7
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IBaseRouteEntryPoint } from "./IBaseRouteEntryPoint";
|
|
2
|
-
import type { ISocketRoute } from "./ISocketRoute";
|
|
1
|
+
import type { IBaseRouteEntryPoint } from "./IBaseRouteEntryPoint.js";
|
|
2
|
+
import type { ISocketRoute } from "./ISocketRoute.js";
|
|
3
3
|
/**
|
|
4
4
|
* Route entry points are used for exposing the socket routes from a package.
|
|
5
5
|
*/
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
+
import type { IContextIds } from "@twin.org/context";
|
|
1
2
|
import type { IComponent } from "@twin.org/core";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { IBaseRoute } from "../routes/IBaseRoute";
|
|
3
|
+
import type { IHttpResponse } from "../protocol/IHttpResponse.js";
|
|
4
|
+
import type { IHttpServerRequest } from "../protocol/IHttpServerRequest.js";
|
|
5
|
+
import type { IBaseRoute } from "../routes/IBaseRoute.js";
|
|
6
6
|
/**
|
|
7
7
|
* The definition for a base processor for handling REST routes.
|
|
8
8
|
*/
|
|
9
9
|
export interface IBaseRouteProcessor<T = IBaseRoute, R = IHttpServerRequest> extends IComponent {
|
|
10
|
+
/**
|
|
11
|
+
* Features supported by this processor.
|
|
12
|
+
* If a route has any of these features listed, this processor will be run for that route.
|
|
13
|
+
* If this is not implemented, the processor will run for all routes.
|
|
14
|
+
* @returns The features supported by this processor.
|
|
15
|
+
*/
|
|
16
|
+
features?(): string[];
|
|
10
17
|
/**
|
|
11
18
|
* Pre process the REST request for the specified route.
|
|
12
19
|
* @param request The request to handle.
|
|
13
20
|
* @param response The response data to send if any.
|
|
14
21
|
* @param route The route being requested, if a matching one was found.
|
|
15
|
-
* @param
|
|
22
|
+
* @param contextIds The context IDs of the request.
|
|
16
23
|
* @param processorState The state handed through the processors.
|
|
17
24
|
* @param loggingComponentType The logging component type for the request.
|
|
18
25
|
* @returns Promise that resolves when the request is processed.
|
|
19
26
|
*/
|
|
20
|
-
pre?(request: R, response: IHttpResponse, route: T | undefined,
|
|
27
|
+
pre?(request: R, response: IHttpResponse, route: T | undefined, contextIds: IContextIds, processorState: {
|
|
21
28
|
[id: string]: unknown;
|
|
22
29
|
}, loggingComponentType?: string): Promise<void>;
|
|
23
30
|
/**
|
|
@@ -25,12 +32,12 @@ export interface IBaseRouteProcessor<T = IBaseRoute, R = IHttpServerRequest> ext
|
|
|
25
32
|
* @param request The request to handle.
|
|
26
33
|
* @param response The response data to send if any.
|
|
27
34
|
* @param route The route being requested, if a matching one was found.
|
|
28
|
-
* @param
|
|
35
|
+
* @param contextIds The context IDs of the request.
|
|
29
36
|
* @param processorState The state handed through the processors.
|
|
30
37
|
* @param loggingComponentType The logging component type for the request.
|
|
31
38
|
* @returns Promise that resolves when the request is processed.
|
|
32
39
|
*/
|
|
33
|
-
post?(request: R, response: IHttpResponse, route: T | undefined,
|
|
40
|
+
post?(request: R, response: IHttpResponse, route: T | undefined, contextIds: IContextIds, processorState: {
|
|
34
41
|
[id: string]: unknown;
|
|
35
42
|
}, loggingComponentType?: string): Promise<void>;
|
|
36
43
|
}
|