@twin.org/api-models 0.0.1-next.3 → 0.0.1-next.31

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