@twin.org/api-models 0.0.1-next.9 → 0.0.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/cjs/index.cjs +34 -11
- package/dist/esm/index.mjs +34 -14
- package/dist/types/factories/mimeTypeProcessorFactory.d.ts +6 -0
- package/dist/types/factories/restRouteProcessorFactory.d.ts +6 -0
- package/dist/types/factories/socketRouteProcessorFactory.d.ts +6 -0
- package/dist/types/index.d.ts +9 -1
- package/dist/types/models/config/IBaseSocketClientConfig.d.ts +4 -0
- package/dist/types/models/routes/IBaseRouteEntryPoint.d.ts +22 -0
- package/dist/types/models/routes/IRestRouteEntryPoint.d.ts +2 -19
- package/dist/types/models/routes/ISocketRoute.d.ts +6 -8
- package/dist/types/models/routes/ISocketRouteEntryPoint.d.ts +6 -0
- package/dist/types/models/server/IBaseRouteProcessor.d.ts +34 -0
- package/dist/types/models/server/IMimeTypeProcessor.d.ts +17 -0
- package/dist/types/models/server/IRestRouteProcessor.d.ts +22 -0
- package/dist/types/models/server/{IHttpRestRouteProcessor.d.ts → ISocketRouteProcessor.d.ts} +12 -15
- package/dist/types/models/server/IWebServer.d.ts +7 -3
- package/docs/changelog.md +43 -1
- package/docs/reference/classes/HttpErrorHelper.md +19 -9
- package/docs/reference/classes/HttpParameterHelper.md +31 -15
- package/docs/reference/index.md +10 -2
- package/docs/reference/interfaces/IBaseRouteEntryPoint.md +55 -0
- package/docs/reference/interfaces/IBaseRouteProcessor.md +106 -0
- package/docs/reference/interfaces/IBaseSocketClientConfig.md +8 -0
- package/docs/reference/interfaces/IHealthInfo.md +18 -0
- package/docs/reference/interfaces/IHttpRequest.md +3 -1
- package/docs/reference/interfaces/IHttpRequestContext.md +2 -2
- package/docs/reference/interfaces/IHttpRequestPathParams.md +1 -1
- package/docs/reference/interfaces/IHttpRequestQuery.md +1 -1
- package/docs/reference/interfaces/IHttpResponse.md +3 -1
- package/docs/reference/interfaces/IHttpServerRequest.md +3 -1
- package/docs/reference/interfaces/IInformationComponent.md +13 -5
- package/docs/reference/interfaces/IMimeTypeProcessor.md +43 -0
- package/docs/reference/interfaces/IRestRoute.md +30 -4
- package/docs/reference/interfaces/{IHttpRestRouteProcessor.md → IRestRouteProcessor.md} +55 -23
- package/docs/reference/interfaces/IRestRouteRequestExample.md +3 -1
- package/docs/reference/interfaces/IRestRouteResponseExample.md +3 -1
- package/docs/reference/interfaces/ISocketRoute.md +22 -10
- package/docs/reference/interfaces/ISocketRouteProcessor.md +217 -0
- package/docs/reference/interfaces/IWebServer.md +26 -6
- package/docs/reference/type-aliases/HealthStatus.md +1 -1
- package/docs/reference/type-aliases/IRestRouteEntryPoint.md +5 -0
- package/docs/reference/type-aliases/ISocketRouteEntryPoint.md +5 -0
- package/docs/reference/variables/MimeTypeProcessorFactory.md +5 -0
- package/docs/reference/variables/RestRouteProcessorFactory.md +5 -0
- package/docs/reference/variables/SocketRouteProcessorFactory.md +5 -0
- package/package.json +6 -6
- package/docs/reference/interfaces/IRestRouteEntryPoint.md +0 -45
|
@@ -4,29 +4,33 @@ Class to help with handling http parameters.
|
|
|
4
4
|
|
|
5
5
|
## Constructors
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Constructor
|
|
8
8
|
|
|
9
|
-
> **new HttpParameterHelper**():
|
|
9
|
+
> **new HttpParameterHelper**(): `HttpParameterHelper`
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`HttpParameterHelper`
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
17
17
|
### arrayFromString()
|
|
18
18
|
|
|
19
|
-
> `static` **arrayFromString**\<`T`\>(`values
|
|
19
|
+
> `static` **arrayFromString**\<`T`\>(`values?`): `undefined` \| `T`[]
|
|
20
20
|
|
|
21
21
|
Convert list query to array.
|
|
22
22
|
|
|
23
23
|
#### Type Parameters
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
##### T
|
|
26
|
+
|
|
27
|
+
`T` = `string`
|
|
26
28
|
|
|
27
29
|
#### Parameters
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
##### values?
|
|
32
|
+
|
|
33
|
+
`string`
|
|
30
34
|
|
|
31
35
|
The values query string.
|
|
32
36
|
|
|
@@ -40,17 +44,21 @@ The array of values.
|
|
|
40
44
|
|
|
41
45
|
### arrayToString()
|
|
42
46
|
|
|
43
|
-
> `static` **arrayToString**\<`T`\>(`values
|
|
47
|
+
> `static` **arrayToString**\<`T`\>(`values?`): `undefined` \| `string`
|
|
44
48
|
|
|
45
49
|
Convert array of values to query string.
|
|
46
50
|
|
|
47
51
|
#### Type Parameters
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
##### T
|
|
54
|
+
|
|
55
|
+
`T` = `string`
|
|
50
56
|
|
|
51
57
|
#### Parameters
|
|
52
58
|
|
|
53
|
-
|
|
59
|
+
##### values?
|
|
60
|
+
|
|
61
|
+
`T`[]
|
|
54
62
|
|
|
55
63
|
The values to combine string.
|
|
56
64
|
|
|
@@ -64,17 +72,21 @@ The combined.
|
|
|
64
72
|
|
|
65
73
|
### objectFromString()
|
|
66
74
|
|
|
67
|
-
> `static` **objectFromString**\<`T`\>(`value
|
|
75
|
+
> `static` **objectFromString**\<`T`\>(`value?`): `undefined` \| `T`
|
|
68
76
|
|
|
69
77
|
Convert object string to object.
|
|
70
78
|
|
|
71
79
|
#### Type Parameters
|
|
72
80
|
|
|
73
|
-
|
|
81
|
+
##### T
|
|
82
|
+
|
|
83
|
+
`T` = `unknown`
|
|
74
84
|
|
|
75
85
|
#### Parameters
|
|
76
86
|
|
|
77
|
-
|
|
87
|
+
##### value?
|
|
88
|
+
|
|
89
|
+
`string`
|
|
78
90
|
|
|
79
91
|
The value query string.
|
|
80
92
|
|
|
@@ -88,17 +100,21 @@ The object.
|
|
|
88
100
|
|
|
89
101
|
### objectToString()
|
|
90
102
|
|
|
91
|
-
> `static` **objectToString**\<`T`\>(`value
|
|
103
|
+
> `static` **objectToString**\<`T`\>(`value?`): `undefined` \| `string`
|
|
92
104
|
|
|
93
105
|
Convert object to query string.
|
|
94
106
|
|
|
95
107
|
#### Type Parameters
|
|
96
108
|
|
|
97
|
-
|
|
109
|
+
##### T
|
|
110
|
+
|
|
111
|
+
`T` = `unknown`
|
|
98
112
|
|
|
99
113
|
#### Parameters
|
|
100
114
|
|
|
101
|
-
|
|
115
|
+
##### value?
|
|
116
|
+
|
|
117
|
+
`T`
|
|
102
118
|
|
|
103
119
|
The value to convert to a string.
|
|
104
120
|
|
package/docs/reference/index.md
CHANGED
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
- [INoContentResponse](interfaces/INoContentResponse.md)
|
|
33
33
|
- [IOkResponse](interfaces/IOkResponse.md)
|
|
34
34
|
- [IBaseRoute](interfaces/IBaseRoute.md)
|
|
35
|
+
- [IBaseRouteEntryPoint](interfaces/IBaseRouteEntryPoint.md)
|
|
35
36
|
- [IRestRoute](interfaces/IRestRoute.md)
|
|
36
|
-
- [IRestRouteEntryPoint](interfaces/IRestRouteEntryPoint.md)
|
|
37
37
|
- [IRestRouteExample](interfaces/IRestRouteExample.md)
|
|
38
38
|
- [IRestRouteRequestExample](interfaces/IRestRouteRequestExample.md)
|
|
39
39
|
- [IRestRouteResponseAttachmentOptions](interfaces/IRestRouteResponseAttachmentOptions.md)
|
|
@@ -41,7 +41,10 @@
|
|
|
41
41
|
- [IRestRouteResponseOptions](interfaces/IRestRouteResponseOptions.md)
|
|
42
42
|
- [ISocketRoute](interfaces/ISocketRoute.md)
|
|
43
43
|
- [ITag](interfaces/ITag.md)
|
|
44
|
-
- [
|
|
44
|
+
- [IBaseRouteProcessor](interfaces/IBaseRouteProcessor.md)
|
|
45
|
+
- [IMimeTypeProcessor](interfaces/IMimeTypeProcessor.md)
|
|
46
|
+
- [IRestRouteProcessor](interfaces/IRestRouteProcessor.md)
|
|
47
|
+
- [ISocketRouteProcessor](interfaces/ISocketRouteProcessor.md)
|
|
45
48
|
- [IWebServer](interfaces/IWebServer.md)
|
|
46
49
|
- [IWebServerOptions](interfaces/IWebServerOptions.md)
|
|
47
50
|
- [IHealthInfo](interfaces/IHealthInfo.md)
|
|
@@ -50,8 +53,13 @@
|
|
|
50
53
|
|
|
51
54
|
## Type Aliases
|
|
52
55
|
|
|
56
|
+
- [IRestRouteEntryPoint](type-aliases/IRestRouteEntryPoint.md)
|
|
57
|
+
- [ISocketRouteEntryPoint](type-aliases/ISocketRouteEntryPoint.md)
|
|
53
58
|
- [HealthStatus](type-aliases/HealthStatus.md)
|
|
54
59
|
|
|
55
60
|
## Variables
|
|
56
61
|
|
|
62
|
+
- [MimeTypeProcessorFactory](variables/MimeTypeProcessorFactory.md)
|
|
63
|
+
- [RestRouteProcessorFactory](variables/RestRouteProcessorFactory.md)
|
|
64
|
+
- [SocketRouteProcessorFactory](variables/SocketRouteProcessorFactory.md)
|
|
57
65
|
- [HealthStatus](variables/HealthStatus.md)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Interface: IBaseRouteEntryPoint\<T\>
|
|
2
|
+
|
|
3
|
+
Route entry points are used for exposing the routes from a package.
|
|
4
|
+
|
|
5
|
+
## Type Parameters
|
|
6
|
+
|
|
7
|
+
### T
|
|
8
|
+
|
|
9
|
+
`T`
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### name
|
|
14
|
+
|
|
15
|
+
> **name**: `string`
|
|
16
|
+
|
|
17
|
+
The name of the routes.
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### defaultBaseRoute
|
|
22
|
+
|
|
23
|
+
> **defaultBaseRoute**: `string`
|
|
24
|
+
|
|
25
|
+
The default base route name for the routes.
|
|
26
|
+
|
|
27
|
+
***
|
|
28
|
+
|
|
29
|
+
### tags
|
|
30
|
+
|
|
31
|
+
> **tags**: [`ITag`](ITag.md)[]
|
|
32
|
+
|
|
33
|
+
The tags for the routes.
|
|
34
|
+
|
|
35
|
+
***
|
|
36
|
+
|
|
37
|
+
### generateRoutes()
|
|
38
|
+
|
|
39
|
+
> **generateRoutes**: (`baseRouteName`, `componentName`) => `T`[]
|
|
40
|
+
|
|
41
|
+
The method to generate the routes.
|
|
42
|
+
|
|
43
|
+
#### Parameters
|
|
44
|
+
|
|
45
|
+
##### baseRouteName
|
|
46
|
+
|
|
47
|
+
`string`
|
|
48
|
+
|
|
49
|
+
##### componentName
|
|
50
|
+
|
|
51
|
+
`string`
|
|
52
|
+
|
|
53
|
+
#### Returns
|
|
54
|
+
|
|
55
|
+
`T`[]
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Interface: IBaseRouteProcessor\<T\>
|
|
2
|
+
|
|
3
|
+
The definition for a base processor for handling REST routes.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- `IComponent`
|
|
8
|
+
|
|
9
|
+
## Extended by
|
|
10
|
+
|
|
11
|
+
- [`IRestRouteProcessor`](IRestRouteProcessor.md)
|
|
12
|
+
- [`ISocketRouteProcessor`](ISocketRouteProcessor.md)
|
|
13
|
+
|
|
14
|
+
## Type Parameters
|
|
15
|
+
|
|
16
|
+
### T
|
|
17
|
+
|
|
18
|
+
`T` = [`IBaseRoute`](IBaseRoute.md)
|
|
19
|
+
|
|
20
|
+
## Methods
|
|
21
|
+
|
|
22
|
+
### pre()?
|
|
23
|
+
|
|
24
|
+
> `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
25
|
+
|
|
26
|
+
Pre process the REST request for the specified route.
|
|
27
|
+
|
|
28
|
+
#### Parameters
|
|
29
|
+
|
|
30
|
+
##### request
|
|
31
|
+
|
|
32
|
+
[`IHttpServerRequest`](IHttpServerRequest.md)
|
|
33
|
+
|
|
34
|
+
The request to handle.
|
|
35
|
+
|
|
36
|
+
##### response
|
|
37
|
+
|
|
38
|
+
[`IHttpResponse`](IHttpResponse.md)
|
|
39
|
+
|
|
40
|
+
The response data to send if any.
|
|
41
|
+
|
|
42
|
+
##### route
|
|
43
|
+
|
|
44
|
+
The route being requested, if a matching one was found.
|
|
45
|
+
|
|
46
|
+
`undefined` | `T`
|
|
47
|
+
|
|
48
|
+
##### requestIdentity
|
|
49
|
+
|
|
50
|
+
[`IHttpRequestIdentity`](IHttpRequestIdentity.md)
|
|
51
|
+
|
|
52
|
+
The identity context for the request.
|
|
53
|
+
|
|
54
|
+
##### processorState
|
|
55
|
+
|
|
56
|
+
The state handed through the processors.
|
|
57
|
+
|
|
58
|
+
#### Returns
|
|
59
|
+
|
|
60
|
+
`Promise`\<`void`\>
|
|
61
|
+
|
|
62
|
+
Promise that resolves when the request is processed.
|
|
63
|
+
|
|
64
|
+
***
|
|
65
|
+
|
|
66
|
+
### post()?
|
|
67
|
+
|
|
68
|
+
> `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
69
|
+
|
|
70
|
+
Post process the REST request for the specified route.
|
|
71
|
+
|
|
72
|
+
#### Parameters
|
|
73
|
+
|
|
74
|
+
##### request
|
|
75
|
+
|
|
76
|
+
[`IHttpServerRequest`](IHttpServerRequest.md)
|
|
77
|
+
|
|
78
|
+
The request to handle.
|
|
79
|
+
|
|
80
|
+
##### response
|
|
81
|
+
|
|
82
|
+
[`IHttpResponse`](IHttpResponse.md)
|
|
83
|
+
|
|
84
|
+
The response data to send if any.
|
|
85
|
+
|
|
86
|
+
##### route
|
|
87
|
+
|
|
88
|
+
The route being requested, if a matching one was found.
|
|
89
|
+
|
|
90
|
+
`undefined` | `T`
|
|
91
|
+
|
|
92
|
+
##### requestIdentity
|
|
93
|
+
|
|
94
|
+
[`IHttpRequestIdentity`](IHttpRequestIdentity.md)
|
|
95
|
+
|
|
96
|
+
The identity context for the request.
|
|
97
|
+
|
|
98
|
+
##### processorState
|
|
99
|
+
|
|
100
|
+
The state handed through the processors.
|
|
101
|
+
|
|
102
|
+
#### Returns
|
|
103
|
+
|
|
104
|
+
`Promise`\<`void`\>
|
|
105
|
+
|
|
106
|
+
Promise that resolves when the request is processed.
|
|
@@ -17,3 +17,21 @@ The status.
|
|
|
17
17
|
> `optional` **components**: `object`[]
|
|
18
18
|
|
|
19
19
|
The status of the components.
|
|
20
|
+
|
|
21
|
+
#### name
|
|
22
|
+
|
|
23
|
+
> **name**: `string`
|
|
24
|
+
|
|
25
|
+
The name of the component.
|
|
26
|
+
|
|
27
|
+
#### status
|
|
28
|
+
|
|
29
|
+
> **status**: [`HealthStatus`](../type-aliases/HealthStatus.md)
|
|
30
|
+
|
|
31
|
+
The status of the component.
|
|
32
|
+
|
|
33
|
+
#### details?
|
|
34
|
+
|
|
35
|
+
> `optional` **details**: `string`
|
|
36
|
+
|
|
37
|
+
The details for the status.
|
|
@@ -10,7 +10,7 @@ Context data from the HTTP request.
|
|
|
10
10
|
|
|
11
11
|
### serverRequest
|
|
12
12
|
|
|
13
|
-
> **serverRequest**: [`IHttpServerRequest`](IHttpServerRequest.md)
|
|
13
|
+
> **serverRequest**: [`IHttpServerRequest`](IHttpServerRequest.md)
|
|
14
14
|
|
|
15
15
|
The raw HTTP request.
|
|
16
16
|
|
|
@@ -24,7 +24,7 @@ The state handed through the processors.
|
|
|
24
24
|
|
|
25
25
|
#### Index Signature
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
\[`id`: `string`\]: `unknown`
|
|
28
28
|
|
|
29
29
|
***
|
|
30
30
|
|
|
@@ -52,21 +52,27 @@ The service health.
|
|
|
52
52
|
|
|
53
53
|
### setComponentHealth()
|
|
54
54
|
|
|
55
|
-
> **setComponentHealth**(`name`, `status`, `details
|
|
55
|
+
> **setComponentHealth**(`name`, `status`, `details?`): `Promise`\<`void`\>
|
|
56
56
|
|
|
57
57
|
Set the status of a component.
|
|
58
58
|
|
|
59
59
|
#### Parameters
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
##### name
|
|
62
|
+
|
|
63
|
+
`string`
|
|
62
64
|
|
|
63
65
|
The component name.
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
##### status
|
|
68
|
+
|
|
69
|
+
[`HealthStatus`](../type-aliases/HealthStatus.md)
|
|
66
70
|
|
|
67
71
|
The status of the component.
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
##### details?
|
|
74
|
+
|
|
75
|
+
`string`
|
|
70
76
|
|
|
71
77
|
The details for the status.
|
|
72
78
|
|
|
@@ -86,7 +92,9 @@ Remove the status of a component.
|
|
|
86
92
|
|
|
87
93
|
#### Parameters
|
|
88
94
|
|
|
89
|
-
|
|
95
|
+
##### name
|
|
96
|
+
|
|
97
|
+
`string`
|
|
90
98
|
|
|
91
99
|
The component name.
|
|
92
100
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Interface: IMimeTypeProcessor
|
|
2
|
+
|
|
3
|
+
The definition for a handler for a specific MIME type.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- `IComponent`
|
|
8
|
+
|
|
9
|
+
## Methods
|
|
10
|
+
|
|
11
|
+
### getTypes()
|
|
12
|
+
|
|
13
|
+
> **getTypes**(): `string`[]
|
|
14
|
+
|
|
15
|
+
Get the MIME types that this handler can handle.
|
|
16
|
+
|
|
17
|
+
#### Returns
|
|
18
|
+
|
|
19
|
+
`string`[]
|
|
20
|
+
|
|
21
|
+
The MIME types that this handler can handle.
|
|
22
|
+
|
|
23
|
+
***
|
|
24
|
+
|
|
25
|
+
### handle()
|
|
26
|
+
|
|
27
|
+
> **handle**(`body`): `Promise`\<`unknown`\>
|
|
28
|
+
|
|
29
|
+
Handle content.
|
|
30
|
+
|
|
31
|
+
#### Parameters
|
|
32
|
+
|
|
33
|
+
##### body
|
|
34
|
+
|
|
35
|
+
`Uint8Array`
|
|
36
|
+
|
|
37
|
+
The body to process.
|
|
38
|
+
|
|
39
|
+
#### Returns
|
|
40
|
+
|
|
41
|
+
`Promise`\<`unknown`\>
|
|
42
|
+
|
|
43
|
+
The processed body.
|
|
@@ -8,9 +8,13 @@ Interface which defines a REST route.
|
|
|
8
8
|
|
|
9
9
|
## Type Parameters
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
### T
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`T` *extends* [`IHttpRequest`](IHttpRequest.md) = `any`
|
|
14
|
+
|
|
15
|
+
### U
|
|
16
|
+
|
|
17
|
+
`U` *extends* [`IHttpResponse`](IHttpResponse.md) & [`IRestRouteResponseOptions`](IRestRouteResponseOptions.md) = `any`
|
|
14
18
|
|
|
15
19
|
## Properties
|
|
16
20
|
|
|
@@ -82,11 +86,15 @@ The handler module.
|
|
|
82
86
|
|
|
83
87
|
#### Parameters
|
|
84
88
|
|
|
85
|
-
|
|
89
|
+
##### httpRequestContext
|
|
90
|
+
|
|
91
|
+
[`IHttpRequestContext`](IHttpRequestContext.md)
|
|
86
92
|
|
|
87
93
|
The http request context.
|
|
88
94
|
|
|
89
|
-
|
|
95
|
+
##### request
|
|
96
|
+
|
|
97
|
+
`T`
|
|
90
98
|
|
|
91
99
|
The request object, combined query param, path params and body.
|
|
92
100
|
|
|
@@ -128,6 +136,24 @@ Example objects for the request.
|
|
|
128
136
|
|
|
129
137
|
The type of the response object.
|
|
130
138
|
|
|
139
|
+
#### type
|
|
140
|
+
|
|
141
|
+
> **type**: `string`
|
|
142
|
+
|
|
143
|
+
The object type of the response.
|
|
144
|
+
|
|
145
|
+
#### mimeType?
|
|
146
|
+
|
|
147
|
+
> `optional` **mimeType**: `string`
|
|
148
|
+
|
|
149
|
+
The mime type of the response, defaults to "application/json" if there is a body.
|
|
150
|
+
|
|
151
|
+
#### examples?
|
|
152
|
+
|
|
153
|
+
> `optional` **examples**: [`IRestRouteResponseExample`](IRestRouteResponseExample.md)\<`U`\>[]
|
|
154
|
+
|
|
155
|
+
Example objects of the response.
|
|
156
|
+
|
|
131
157
|
***
|
|
132
158
|
|
|
133
159
|
### excludeFromSpec?
|