@twin.org/api-models 0.0.2-next.1 → 0.0.2-next.11

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 (42) hide show
  1. package/dist/cjs/index.cjs +9 -0
  2. package/dist/esm/index.mjs +9 -1
  3. package/dist/types/factories/authenticationGeneratorFactory.d.ts +6 -0
  4. package/dist/types/index.d.ts +6 -0
  5. package/dist/types/models/api/IServerFavIconResponse.d.ts +23 -0
  6. package/dist/types/models/api/IServerRootResponse.d.ts +9 -0
  7. package/dist/types/models/client/IAuthenticationGenerator.d.ts +14 -0
  8. package/dist/types/models/config/IBaseRestClientConfig.d.ts +4 -0
  9. package/dist/types/models/protocol/IHttpRequest.d.ts +4 -0
  10. package/dist/types/models/protocol/IHttpRequestContext.d.ts +4 -0
  11. package/dist/types/models/protocol/ISocketRequestContext.d.ts +10 -0
  12. package/dist/types/models/protocol/ISocketServerRequest.d.ts +10 -0
  13. package/dist/types/models/routes/IBaseRoute.d.ts +4 -0
  14. package/dist/types/models/routes/ISocketRoute.d.ts +18 -2
  15. package/dist/types/models/server/IBaseRouteProcessor.d.ts +14 -5
  16. package/dist/types/models/server/IRestRouteProcessor.d.ts +2 -1
  17. package/dist/types/models/server/ISocketRouteProcessor.d.ts +12 -15
  18. package/dist/types/models/services/IInformationComponent.d.ts +10 -0
  19. package/docs/changelog.md +75 -0
  20. package/docs/reference/index.md +6 -0
  21. package/docs/reference/interfaces/IAuthenticationGenerator.md +35 -0
  22. package/docs/reference/interfaces/IBaseRestClientConfig.md +8 -0
  23. package/docs/reference/interfaces/IBaseRoute.md +8 -0
  24. package/docs/reference/interfaces/IBaseRouteProcessor.md +37 -5
  25. package/docs/reference/interfaces/IConflictResponse.md +1 -1
  26. package/docs/reference/interfaces/IHttpRequest.md +8 -0
  27. package/docs/reference/interfaces/IHttpRequestContext.md +12 -0
  28. package/docs/reference/interfaces/IHttpServerRequest.md +16 -0
  29. package/docs/reference/interfaces/IInformationComponent.md +28 -0
  30. package/docs/reference/interfaces/INoContentRequest.md +12 -0
  31. package/docs/reference/interfaces/INotFoundResponse.md +1 -1
  32. package/docs/reference/interfaces/IRestRoute.md +12 -0
  33. package/docs/reference/interfaces/IRestRouteProcessor.md +41 -3
  34. package/docs/reference/interfaces/IServerFavIconResponse.md +33 -0
  35. package/docs/reference/interfaces/IServerRootResponse.md +11 -0
  36. package/docs/reference/interfaces/ISocketRequestContext.md +79 -0
  37. package/docs/reference/interfaces/ISocketRoute.md +55 -3
  38. package/docs/reference/interfaces/ISocketRouteProcessor.md +60 -18
  39. package/docs/reference/interfaces/ISocketServerRequest.md +105 -0
  40. package/docs/reference/variables/AuthenticationGeneratorFactory.md +5 -0
  41. package/docs/reference/variables/HealthStatus.md +1 -1
  42. package/package.json +1 -1
@@ -3,6 +3,14 @@
3
3
  var core = require('@twin.org/core');
4
4
  var web = require('@twin.org/web');
5
5
 
6
+ // Copyright 2024 IOTA Stiftung.
7
+ // SPDX-License-Identifier: Apache-2.0.
8
+ /**
9
+ * Factory for creating implementation of authentication generator types.
10
+ */
11
+ // eslint-disable-next-line @typescript-eslint/naming-convention
12
+ const AuthenticationGeneratorFactory = core.Factory.createFactory("authentication-generator");
13
+
6
14
  // Copyright 2024 IOTA Stiftung.
7
15
  // SPDX-License-Identifier: Apache-2.0.
8
16
  /**
@@ -146,6 +154,7 @@ const HealthStatus = {
146
154
  Error: "error"
147
155
  };
148
156
 
157
+ exports.AuthenticationGeneratorFactory = AuthenticationGeneratorFactory;
149
158
  exports.HealthStatus = HealthStatus;
150
159
  exports.HttpErrorHelper = HttpErrorHelper;
151
160
  exports.HttpParameterHelper = HttpParameterHelper;
@@ -1,6 +1,14 @@
1
1
  import { Factory, BaseError, GuardError, ValidationError, ConflictError, AlreadyExistsError, NotFoundError, UnauthorizedError, NotImplementedError, UnprocessableError, Is } from '@twin.org/core';
2
2
  import { HttpStatusCode, MimeTypes, HeaderTypes } from '@twin.org/web';
3
3
 
4
+ // Copyright 2024 IOTA Stiftung.
5
+ // SPDX-License-Identifier: Apache-2.0.
6
+ /**
7
+ * Factory for creating implementation of authentication generator types.
8
+ */
9
+ // eslint-disable-next-line @typescript-eslint/naming-convention
10
+ const AuthenticationGeneratorFactory = Factory.createFactory("authentication-generator");
11
+
4
12
  // Copyright 2024 IOTA Stiftung.
5
13
  // SPDX-License-Identifier: Apache-2.0.
6
14
  /**
@@ -144,4 +152,4 @@ const HealthStatus = {
144
152
  Error: "error"
145
153
  };
146
154
 
147
- export { HealthStatus, HttpErrorHelper, HttpParameterHelper, MimeTypeProcessorFactory, RestRouteProcessorFactory, SocketRouteProcessorFactory };
155
+ export { AuthenticationGeneratorFactory, HealthStatus, HttpErrorHelper, HttpParameterHelper, MimeTypeProcessorFactory, RestRouteProcessorFactory, SocketRouteProcessorFactory };
@@ -0,0 +1,6 @@
1
+ import { Factory } from "@twin.org/core";
2
+ import type { IAuthenticationGenerator } from "../models/client/IAuthenticationGenerator";
3
+ /**
4
+ * Factory for creating implementation of authentication generator types.
5
+ */
6
+ export declare const AuthenticationGeneratorFactory: Factory<IAuthenticationGenerator>;
@@ -1,11 +1,15 @@
1
+ export * from "./factories/authenticationGeneratorFactory";
1
2
  export * from "./factories/mimeTypeProcessorFactory";
2
3
  export * from "./factories/restRouteProcessorFactory";
3
4
  export * from "./factories/socketRouteProcessorFactory";
4
5
  export * from "./helpers/httpErrorHelper";
5
6
  export * from "./helpers/httpParameterHelper";
7
+ export * from "./models/api/IServerFavIconResponse";
6
8
  export * from "./models/api/IServerHealthResponse";
7
9
  export * from "./models/api/IServerInfoResponse";
10
+ export * from "./models/api/IServerRootResponse";
8
11
  export * from "./models/api/IServerSpecResponse";
12
+ export * from "./models/client/IAuthenticationGenerator";
9
13
  export * from "./models/config/IBaseRestClientConfig";
10
14
  export * from "./models/config/IBaseSocketClientConfig";
11
15
  export * from "./models/protocol/IHttpRequest";
@@ -15,6 +19,8 @@ export * from "./models/protocol/IHttpRequestPathParams";
15
19
  export * from "./models/protocol/IHttpRequestQuery";
16
20
  export * from "./models/protocol/IHttpResponse";
17
21
  export * from "./models/protocol/IHttpServerRequest";
22
+ export * from "./models/protocol/ISocketRequestContext";
23
+ export * from "./models/protocol/ISocketServerRequest";
18
24
  export * from "./models/requests/INoContentRequest";
19
25
  export * from "./models/responses/errors/IBadRequestResponse";
20
26
  export * from "./models/responses/errors/IConflictResponse";
@@ -0,0 +1,23 @@
1
+ import type { HeaderTypes, HttpStatusCode } from "@twin.org/web";
2
+ /**
3
+ * The favicon for the server.
4
+ */
5
+ export interface IServerFavIconResponse {
6
+ /**
7
+ * Additional response headers.
8
+ */
9
+ headers?: {
10
+ /**
11
+ * The content type for the response.
12
+ */
13
+ [HeaderTypes.ContentType]?: string;
14
+ };
15
+ /**
16
+ * Response status code.
17
+ */
18
+ statusCode?: HttpStatusCode;
19
+ /**
20
+ * The favicon for the server.
21
+ */
22
+ body?: Uint8Array;
23
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The root text for the server.
3
+ */
4
+ export interface IServerRootResponse {
5
+ /**
6
+ * The root text for the server.
7
+ */
8
+ body: string;
9
+ }
@@ -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
+ }
@@ -23,4 +23,8 @@ export interface IBaseRestClientConfig {
23
23
  * Include credentials in the request, defaults to true.
24
24
  */
25
25
  includeCredentials?: boolean;
26
+ /**
27
+ * The type of authentication generator to use.
28
+ */
29
+ authenticationGeneratorType?: string;
26
30
  }
@@ -21,4 +21,8 @@ export interface IHttpRequest<T = any> {
21
21
  * Data to return send as the body.
22
22
  */
23
23
  body?: T;
24
+ /**
25
+ * Used to authenticate and will be passed to the configured authentication provider for the request.
26
+ */
27
+ authentication?: unknown;
24
28
  }
@@ -14,4 +14,8 @@ export interface IHttpRequestContext extends IHttpRequestIdentity {
14
14
  processorState: {
15
15
  [id: string]: unknown;
16
16
  };
17
+ /**
18
+ * Logging component type for the request.
19
+ */
20
+ loggingComponentType?: string;
17
21
  }
@@ -0,0 +1,10 @@
1
+ import type { IHttpRequestContext } from "./IHttpRequestContext";
2
+ /**
3
+ * Context data from the socket request.
4
+ */
5
+ export interface ISocketRequestContext extends IHttpRequestContext {
6
+ /**
7
+ * The id of the socket.
8
+ */
9
+ socketId: string;
10
+ }
@@ -0,0 +1,10 @@
1
+ import type { IHttpServerRequest } from "./IHttpServerRequest";
2
+ /**
3
+ * Model for the standard parameters for an http request.
4
+ */
5
+ export interface ISocketServerRequest<T = any> extends IHttpServerRequest<T> {
6
+ /**
7
+ * The socket id.
8
+ */
9
+ socketId: string;
10
+ }
@@ -14,4 +14,8 @@ 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[];
17
21
  }
@@ -1,7 +1,7 @@
1
1
  import type { IBaseRoute } from "./IBaseRoute";
2
2
  import type { IHttpRequest } from "../protocol/IHttpRequest";
3
- import type { IHttpRequestContext } from "../protocol/IHttpRequestContext";
4
3
  import type { IHttpResponse } from "../protocol/IHttpResponse";
4
+ import type { ISocketRequestContext } from "../protocol/ISocketRequestContext";
5
5
  /**
6
6
  * Interface which defines a socket route.
7
7
  */
@@ -13,7 +13,7 @@ export interface ISocketRoute<T extends IHttpRequest = any, U extends IHttpRespo
13
13
  /**
14
14
  * The request context.
15
15
  */
16
- httpRequestContext: IHttpRequestContext,
16
+ socketRequestContext: ISocketRequestContext,
17
17
  /**
18
18
  * The request object.
19
19
  */
@@ -22,4 +22,20 @@ export interface ISocketRoute<T extends IHttpRequest = any, U extends IHttpRespo
22
22
  * The function to emit an event.
23
23
  */
24
24
  emit: (event: string, response: U) => Promise<void>) => void;
25
+ /**
26
+ * The connected handler.
27
+ */
28
+ connected?: (
29
+ /**
30
+ * The request context.
31
+ */
32
+ socketRequestContext: ISocketRequestContext) => void;
33
+ /**
34
+ * The disconnected handler.
35
+ */
36
+ disconnected?: (
37
+ /**
38
+ * The request context.
39
+ */
40
+ socketRequestContext: ISocketRequestContext) => void;
25
41
  }
@@ -6,7 +6,14 @@ import type { IBaseRoute } from "../routes/IBaseRoute";
6
6
  /**
7
7
  * The definition for a base processor for handling REST routes.
8
8
  */
9
- export interface IBaseRouteProcessor<T = IBaseRoute> extends IComponent {
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.
@@ -14,11 +21,12 @@ export interface IBaseRouteProcessor<T = IBaseRoute> extends IComponent {
14
21
  * @param route The route being requested, if a matching one was found.
15
22
  * @param requestIdentity The identity context for the request.
16
23
  * @param processorState The state handed through the processors.
24
+ * @param loggingComponentType The logging component type for the request.
17
25
  * @returns Promise that resolves when the request is processed.
18
26
  */
19
- pre?(request: IHttpServerRequest, response: IHttpResponse, route: T | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
27
+ pre?(request: R, response: IHttpResponse, route: T | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
20
28
  [id: string]: unknown;
21
- }): Promise<void>;
29
+ }, loggingComponentType?: string): Promise<void>;
22
30
  /**
23
31
  * Post process the REST request for the specified route.
24
32
  * @param request The request to handle.
@@ -26,9 +34,10 @@ export interface IBaseRouteProcessor<T = IBaseRoute> extends IComponent {
26
34
  * @param route The route being requested, if a matching one was found.
27
35
  * @param requestIdentity The identity context for the request.
28
36
  * @param processorState The state handed through the processors.
37
+ * @param loggingComponentType The logging component type for the request.
29
38
  * @returns Promise that resolves when the request is processed.
30
39
  */
31
- post?(request: IHttpServerRequest, response: IHttpResponse, route: T | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
40
+ post?(request: R, response: IHttpResponse, route: T | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
32
41
  [id: string]: unknown;
33
- }): Promise<void>;
42
+ }, loggingComponentType?: string): Promise<void>;
34
43
  }
@@ -14,9 +14,10 @@ export interface IRestRouteProcessor extends IBaseRouteProcessor<IRestRoute> {
14
14
  * @param route The route being requested, if a matching one was found.
15
15
  * @param requestIdentity The identity context for the request.
16
16
  * @param processorState The state handed through the processors.
17
+ * @param loggingComponentType The logging component type for the request.
17
18
  * @returns Promise that resolves when the request is processed.
18
19
  */
19
20
  process?(request: IHttpServerRequest, response: IHttpResponse, route: IRestRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
20
21
  [id: string]: unknown;
21
- }): Promise<void>;
22
+ }, loggingComponentType?: string): Promise<void>;
22
23
  }
@@ -1,43 +1,40 @@
1
1
  import type { IBaseRouteProcessor } from "./IBaseRouteProcessor";
2
2
  import type { IHttpRequestIdentity } from "../protocol/IHttpRequestIdentity";
3
3
  import type { IHttpResponse } from "../protocol/IHttpResponse";
4
- import type { IHttpServerRequest } from "../protocol/IHttpServerRequest";
4
+ import type { ISocketServerRequest } from "../protocol/ISocketServerRequest";
5
5
  import type { ISocketRoute } from "../routes/ISocketRoute";
6
6
  /**
7
7
  * The definition for a processor for handling socket routes.
8
8
  */
9
- export interface ISocketRouteProcessor extends IBaseRouteProcessor<ISocketRoute> {
9
+ export interface ISocketRouteProcessor extends IBaseRouteProcessor<ISocketRoute, ISocketServerRequest> {
10
10
  /**
11
11
  * Process the connected event.
12
- * @param request The request to handle.
12
+ * @param request The server request object containing the socket id and other parameters.
13
13
  * @param route The route being requested, if a matching one was found.
14
- * @param processorState The state handed through the processors.
14
+ * @param loggingComponentType The logging component type for the request.
15
15
  * @returns Promise that resolves when the request is processed.
16
16
  */
17
- connected?(request: IHttpServerRequest, route: ISocketRoute | undefined, processorState: {
18
- [id: string]: unknown;
19
- }): Promise<void>;
17
+ connected?(request: ISocketServerRequest, route: ISocketRoute | undefined, loggingComponentType?: string): Promise<void>;
20
18
  /**
21
19
  * Process the disconnected event.
22
- * @param request The request to handle.
20
+ * @param request The server request object containing the socket id and other parameters.
23
21
  * @param route The route being requested, if a matching one was found.
24
- * @param processorState The state handed through the processors.
22
+ * @param loggingComponentType The logging component type for the request.
25
23
  * @returns Promise that resolves when the request is processed.
26
24
  */
27
- disconnected?(request: IHttpServerRequest, route: ISocketRoute | undefined, processorState: {
28
- [id: string]: unknown;
29
- }): Promise<void>;
25
+ disconnected?(request: ISocketServerRequest, route: ISocketRoute | undefined, loggingComponentType?: string): Promise<void>;
30
26
  /**
31
27
  * Process the REST request for the specified route.
32
- * @param request The request to handle.
28
+ * @param request The server request object containing the socket id and other parameters.
33
29
  * @param response The response data to send if any.
34
30
  * @param route The route being requested, if a matching one was found.
35
31
  * @param requestIdentity The identity context for the request.
36
32
  * @param processorState The state handed through the processors.
37
33
  * @param responseEmitter The function to emit a response.
34
+ * @param loggingComponentType The logging component type for the request.
38
35
  * @returns Promise that resolves when the request is processed.
39
36
  */
40
- process?(request: IHttpServerRequest, response: IHttpResponse, route: ISocketRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
37
+ process?(request: ISocketServerRequest, response: IHttpResponse, route: ISocketRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
41
38
  [id: string]: unknown;
42
- }, responseEmitter: (topic: string, response: IHttpResponse) => Promise<void>): Promise<void>;
39
+ }, responseEmitter: (topic: string, response: IHttpResponse) => Promise<void>, loggingComponentType?: string): Promise<void>;
43
40
  }
@@ -6,11 +6,21 @@ import type { IServerInfo } from "./IServerInfo";
6
6
  * The information component for the server.
7
7
  */
8
8
  export interface IInformationComponent extends IComponent {
9
+ /**
10
+ * Get the root information.
11
+ * @returns The root information.
12
+ */
13
+ root(): Promise<string>;
9
14
  /**
10
15
  * Get the server information.
11
16
  * @returns The service information.
12
17
  */
13
18
  info(): Promise<IServerInfo>;
19
+ /**
20
+ * Get the favicon.
21
+ * @returns The favicon.
22
+ */
23
+ favicon(): Promise<Uint8Array | undefined>;
14
24
  /**
15
25
  * Get the OpenAPI spec.
16
26
  * @returns The OpenAPI spec.
package/docs/changelog.md CHANGED
@@ -1,5 +1,80 @@
1
1
  # @twin.org/api-models - Changelog
2
2
 
3
+ ## [0.0.2-next.11](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.10...api-models-v0.0.2-next.11) (2025-09-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
9
+
10
+ ## [0.0.2-next.10](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.9...api-models-v0.0.2-next.10) (2025-09-23)
11
+
12
+
13
+ ### Features
14
+
15
+ * add authentication generators and process features option ([a67edf1](https://github.com/twinfoundation/api/commit/a67edf1df212bd8ab94a40cddf5338551155696f))
16
+
17
+ ## [0.0.2-next.9](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.8...api-models-v0.0.2-next.9) (2025-08-29)
18
+
19
+
20
+ ### Features
21
+
22
+ * eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
23
+
24
+ ## [0.0.2-next.8](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.7...api-models-v0.0.2-next.8) (2025-08-21)
25
+
26
+
27
+ ### Features
28
+
29
+ * add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
30
+
31
+ ## [0.0.2-next.7](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.6...api-models-v0.0.2-next.7) (2025-08-20)
32
+
33
+
34
+ ### Miscellaneous Chores
35
+
36
+ * **api-models:** Synchronize repo versions
37
+
38
+ ## [0.0.2-next.6](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.5...api-models-v0.0.2-next.6) (2025-08-19)
39
+
40
+
41
+ ### Features
42
+
43
+ * update framework core ([d8eebf2](https://github.com/twinfoundation/api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
44
+
45
+ ## [0.0.2-next.5](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.4...api-models-v0.0.2-next.5) (2025-07-25)
46
+
47
+
48
+ ### Features
49
+
50
+ * add logging component type to request contexts ([210de1b](https://github.com/twinfoundation/api/commit/210de1b9e1c91079b59a2b90ddd57569668d647d))
51
+ * add socket id, connect and disconnect ([20b0d0e](https://github.com/twinfoundation/api/commit/20b0d0ec279cab46141fee09de2c4a7087cdce16))
52
+ * update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
53
+ * use new includeStackTrace flag for toJsonObject ([6452b15](https://github.com/twinfoundation/api/commit/6452b153af786eee14b21152420f8a2578b70593))
54
+ * use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
55
+ * validationError mapped to http status badrequest ([adc5eb1](https://github.com/twinfoundation/api/commit/adc5eb11d987abb0ab9f7e0dc8e1fdae207e436e))
56
+
57
+ ## [0.0.2-next.4](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.3...api-models-v0.0.2-next.4) (2025-07-25)
58
+
59
+
60
+ ### Features
61
+
62
+ * add logging component type to request contexts ([210de1b](https://github.com/twinfoundation/api/commit/210de1b9e1c91079b59a2b90ddd57569668d647d))
63
+
64
+ ## [0.0.2-next.3](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.2...api-models-v0.0.2-next.3) (2025-07-24)
65
+
66
+
67
+ ### Features
68
+
69
+ * add socket id, connect and disconnect ([20b0d0e](https://github.com/twinfoundation/api/commit/20b0d0ec279cab46141fee09de2c4a7087cdce16))
70
+
71
+ ## [0.0.2-next.2](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.1...api-models-v0.0.2-next.2) (2025-07-17)
72
+
73
+
74
+ ### Miscellaneous Chores
75
+
76
+ * **api-models:** Synchronize repo versions
77
+
3
78
  ## [0.0.2-next.1](https://github.com/twinfoundation/api/compare/api-models-v0.0.2-next.0...api-models-v0.0.2-next.1) (2025-07-08)
4
79
 
5
80
 
@@ -7,9 +7,12 @@
7
7
 
8
8
  ## Interfaces
9
9
 
10
+ - [IServerFavIconResponse](interfaces/IServerFavIconResponse.md)
10
11
  - [IServerHealthResponse](interfaces/IServerHealthResponse.md)
11
12
  - [IServerInfoResponse](interfaces/IServerInfoResponse.md)
13
+ - [IServerRootResponse](interfaces/IServerRootResponse.md)
12
14
  - [IServerSpecResponse](interfaces/IServerSpecResponse.md)
15
+ - [IAuthenticationGenerator](interfaces/IAuthenticationGenerator.md)
13
16
  - [IBaseRestClientConfig](interfaces/IBaseRestClientConfig.md)
14
17
  - [IBaseSocketClientConfig](interfaces/IBaseSocketClientConfig.md)
15
18
  - [IHttpRequest](interfaces/IHttpRequest.md)
@@ -19,6 +22,8 @@
19
22
  - [IHttpRequestQuery](interfaces/IHttpRequestQuery.md)
20
23
  - [IHttpResponse](interfaces/IHttpResponse.md)
21
24
  - [IHttpServerRequest](interfaces/IHttpServerRequest.md)
25
+ - [ISocketRequestContext](interfaces/ISocketRequestContext.md)
26
+ - [ISocketServerRequest](interfaces/ISocketServerRequest.md)
22
27
  - [INoContentRequest](interfaces/INoContentRequest.md)
23
28
  - [IBadRequestResponse](interfaces/IBadRequestResponse.md)
24
29
  - [IConflictResponse](interfaces/IConflictResponse.md)
@@ -59,6 +64,7 @@
59
64
 
60
65
  ## Variables
61
66
 
67
+ - [AuthenticationGeneratorFactory](variables/AuthenticationGeneratorFactory.md)
62
68
  - [MimeTypeProcessorFactory](variables/MimeTypeProcessorFactory.md)
63
69
  - [RestRouteProcessorFactory](variables/RestRouteProcessorFactory.md)
64
70
  - [SocketRouteProcessorFactory](variables/SocketRouteProcessorFactory.md)
@@ -0,0 +1,35 @@
1
+ # Interface: IAuthenticationGenerator
2
+
3
+ Definition for the authentication generator component.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Methods
10
+
11
+ ### addAuthentication()
12
+
13
+ > **addAuthentication**(`requestHeaders`, `authData?`): `Promise`\<`void`\>
14
+
15
+ Adds authentication information to the request headers.
16
+
17
+ #### Parameters
18
+
19
+ ##### requestHeaders
20
+
21
+ `IHttpHeaders`
22
+
23
+ The request headers to add authentication information to.
24
+
25
+ ##### authData?
26
+
27
+ `unknown`
28
+
29
+ Optional authentication data passed from the request.
30
+
31
+ #### Returns
32
+
33
+ `Promise`\<`void`\>
34
+
35
+ A promise that resolves when the authentication information has been added.
@@ -41,3 +41,11 @@ Timeout for requests in ms.
41
41
  > `optional` **includeCredentials**: `boolean`
42
42
 
43
43
  Include credentials in the request, defaults to true.
44
+
45
+ ***
46
+
47
+ ### authenticationGeneratorType?
48
+
49
+ > `optional` **authenticationGeneratorType**: `string`
50
+
51
+ The type of authentication generator to use.
@@ -30,3 +30,11 @@ The path to use for routing.
30
30
  > `optional` **skipAuth**: `boolean`
31
31
 
32
32
  Skips the authentication for this route.
33
+
34
+ ***
35
+
36
+ ### processorFeatures?
37
+
38
+ > `optional` **processorFeatures**: `string`[]
39
+
40
+ The features supported by additional processors to run for this route.
@@ -1,4 +1,4 @@
1
- # Interface: IBaseRouteProcessor\<T\>
1
+ # Interface: IBaseRouteProcessor\<T, R\>
2
2
 
3
3
  The definition for a base processor for handling REST routes.
4
4
 
@@ -17,11 +17,31 @@ The definition for a base processor for handling REST routes.
17
17
 
18
18
  `T` = [`IBaseRoute`](IBaseRoute.md)
19
19
 
20
+ ### R
21
+
22
+ `R` = [`IHttpServerRequest`](IHttpServerRequest.md)
23
+
20
24
  ## Methods
21
25
 
26
+ ### features()?
27
+
28
+ > `optional` **features**(): `string`[]
29
+
30
+ Features supported by this processor.
31
+ If a route has any of these features listed, this processor will be run for that route.
32
+ If this is not implemented, the processor will run for all routes.
33
+
34
+ #### Returns
35
+
36
+ `string`[]
37
+
38
+ The features supported by this processor.
39
+
40
+ ***
41
+
22
42
  ### pre()?
23
43
 
24
- > `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
44
+ > `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `loggingComponentType?`): `Promise`\<`void`\>
25
45
 
26
46
  Pre process the REST request for the specified route.
27
47
 
@@ -29,7 +49,7 @@ Pre process the REST request for the specified route.
29
49
 
30
50
  ##### request
31
51
 
32
- [`IHttpServerRequest`](IHttpServerRequest.md)
52
+ `R`
33
53
 
34
54
  The request to handle.
35
55
 
@@ -55,6 +75,12 @@ The identity context for the request.
55
75
 
56
76
  The state handed through the processors.
57
77
 
78
+ ##### loggingComponentType?
79
+
80
+ `string`
81
+
82
+ The logging component type for the request.
83
+
58
84
  #### Returns
59
85
 
60
86
  `Promise`\<`void`\>
@@ -65,7 +91,7 @@ Promise that resolves when the request is processed.
65
91
 
66
92
  ### post()?
67
93
 
68
- > `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
94
+ > `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `loggingComponentType?`): `Promise`\<`void`\>
69
95
 
70
96
  Post process the REST request for the specified route.
71
97
 
@@ -73,7 +99,7 @@ Post process the REST request for the specified route.
73
99
 
74
100
  ##### request
75
101
 
76
- [`IHttpServerRequest`](IHttpServerRequest.md)
102
+ `R`
77
103
 
78
104
  The request to handle.
79
105
 
@@ -99,6 +125,12 @@ The identity context for the request.
99
125
 
100
126
  The state handed through the processors.
101
127
 
128
+ ##### loggingComponentType?
129
+
130
+ `string`
131
+
132
+ The logging component type for the request.
133
+
102
134
  #### Returns
103
135
 
104
136
  `Promise`\<`void`\>
@@ -18,7 +18,7 @@ Response status code.
18
18
 
19
19
  The body which contains the error.
20
20
 
21
- #### Type declaration
21
+ #### Type Declaration
22
22
 
23
23
  ##### conflicts
24
24
 
@@ -44,3 +44,11 @@ The query parameters.
44
44
  > `optional` **body**: `T`
45
45
 
46
46
  Data to return send as the body.
47
+
48
+ ***
49
+
50
+ ### authentication?
51
+
52
+ > `optional` **authentication**: `unknown`
53
+
54
+ Used to authenticate and will be passed to the configured authentication provider for the request.