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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cjs/index.cjs +68 -0
  2. package/dist/esm/index.mjs +66 -2
  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/HttpParameterHelper.md +109 -0
  24. package/docs/reference/index.md +14 -2
  25. package/docs/reference/interfaces/IBaseRouteEntryPoint.md +49 -0
  26. package/docs/reference/interfaces/IBaseRouteProcessor.md +88 -0
  27. package/docs/reference/interfaces/IBaseSocketClientConfig.md +8 -0
  28. package/docs/reference/interfaces/ICreatedResponse.md +2 -2
  29. package/docs/reference/interfaces/IMimeTypeProcessor.md +41 -0
  30. package/docs/reference/interfaces/IRestRoute.md +1 -1
  31. package/docs/reference/interfaces/IRestRouteExample.md +24 -0
  32. package/docs/reference/interfaces/{IHttpRestRouteProcessor.md → IRestRouteProcessor.md} +16 -8
  33. package/docs/reference/interfaces/IRestRouteRequestExample.md +43 -0
  34. package/docs/reference/interfaces/IRestRouteResponseExample.md +43 -0
  35. package/docs/reference/interfaces/ISocketRoute.md +12 -10
  36. package/docs/reference/interfaces/ISocketRouteProcessor.md +183 -0
  37. package/docs/reference/interfaces/IWebServer.md +12 -4
  38. package/docs/reference/type-aliases/IRestRouteEntryPoint.md +5 -0
  39. package/docs/reference/type-aliases/ISocketRouteEntryPoint.md +5 -0
  40. package/docs/reference/variables/MimeTypeProcessorFactory.md +5 -0
  41. package/docs/reference/variables/RestRouteProcessorFactory.md +5 -0
  42. package/docs/reference/variables/SocketRouteProcessorFactory.md +5 -0
  43. package/package.json +1 -28
  44. package/docs/reference/interfaces/IRestRouteEntryPoint.md +0 -45
@@ -0,0 +1,109 @@
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?**: `string`
30
+
31
+ The values query string.
32
+
33
+ #### Returns
34
+
35
+ `undefined` \| `T`[]
36
+
37
+ The array of values.
38
+
39
+ ***
40
+
41
+ ### arrayToString()
42
+
43
+ > `static` **arrayToString**\<`T`\>(`values`?): `undefined` \| `string`
44
+
45
+ Convert array of values to query string.
46
+
47
+ #### Type Parameters
48
+
49
+ • **T** = `string`
50
+
51
+ #### Parameters
52
+
53
+ • **values?**: `T`[]
54
+
55
+ The values to combine string.
56
+
57
+ #### Returns
58
+
59
+ `undefined` \| `string`
60
+
61
+ The combined.
62
+
63
+ ***
64
+
65
+ ### objectFromString()
66
+
67
+ > `static` **objectFromString**\<`T`\>(`value`?): `undefined` \| `T`
68
+
69
+ Convert object string to object.
70
+
71
+ #### Type Parameters
72
+
73
+ • **T** = `unknown`
74
+
75
+ #### Parameters
76
+
77
+ • **value?**: `string`
78
+
79
+ The value query string.
80
+
81
+ #### Returns
82
+
83
+ `undefined` \| `T`
84
+
85
+ The object.
86
+
87
+ ***
88
+
89
+ ### objectToString()
90
+
91
+ > `static` **objectToString**\<`T`\>(`value`?): `undefined` \| `string`
92
+
93
+ Convert object to query string.
94
+
95
+ #### Type Parameters
96
+
97
+ • **T** = `unknown`
98
+
99
+ #### Parameters
100
+
101
+ • **value?**: `T`
102
+
103
+ The value to convert to a string.
104
+
105
+ #### Returns
106
+
107
+ `undefined` \| `string`
108
+
109
+ 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,49 @@
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**: `string`
44
+
45
+ • **componentName**: `string`
46
+
47
+ #### Returns
48
+
49
+ `T`[]
@@ -0,0 +1,88 @@
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**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
29
+
30
+ The request to handle.
31
+
32
+ • **response**: [`IHttpResponse`](IHttpResponse.md)\<`any`\>
33
+
34
+ The response data to send if any.
35
+
36
+ • **route**: `undefined` \| `T`
37
+
38
+ The route being requested, if a matching one was found.
39
+
40
+ • **requestIdentity**: [`IHttpRequestIdentity`](IHttpRequestIdentity.md)
41
+
42
+ The identity context for the request.
43
+
44
+ • **processorState**
45
+
46
+ The state handed through the processors.
47
+
48
+ #### Returns
49
+
50
+ `Promise`\<`void`\>
51
+
52
+ Promise that resolves when the request is processed.
53
+
54
+ ***
55
+
56
+ ### post()?
57
+
58
+ > `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
59
+
60
+ Post process the REST request for the specified route.
61
+
62
+ #### Parameters
63
+
64
+ • **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
65
+
66
+ The request to handle.
67
+
68
+ • **response**: [`IHttpResponse`](IHttpResponse.md)\<`any`\>
69
+
70
+ The response data to send if any.
71
+
72
+ • **route**: `undefined` \| `T`
73
+
74
+ The route being requested, if a matching one was found.
75
+
76
+ • **requestIdentity**: [`IHttpRequestIdentity`](IHttpRequestIdentity.md)
77
+
78
+ The identity context for the request.
79
+
80
+ • **processorState**
81
+
82
+ The state handed through the processors.
83
+
84
+ #### Returns
85
+
86
+ `Promise`\<`void`\>
87
+
88
+ 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.
@@ -0,0 +1,41 @@
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**: `Uint8Array`
34
+
35
+ The body to process.
36
+
37
+ #### Returns
38
+
39
+ `Promise`\<`unknown`\>
40
+
41
+ The processed body.
@@ -116,7 +116,7 @@ The mime type of the request, defaults to "application/json" if there is a body.
116
116
 
117
117
  #### examples?
118
118
 
119
- > `optional` **examples**: `object`[]
119
+ > `optional` **examples**: [`IRestRouteRequestExample`](IRestRouteRequestExample.md)\<`T`\>[]
120
120
 
121
121
  Example objects for the request.
122
122
 
@@ -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.
@@ -1,10 +1,10 @@
1
- # Interface: IHttpRestRouteProcessor
1
+ # Interface: IRestRouteProcessor
2
2
 
3
3
  The definition for a processor for handling REST routes.
4
4
 
5
5
  ## Extends
6
6
 
7
- - `IComponent`
7
+ - [`IBaseRouteProcessor`](IBaseRouteProcessor.md)\<[`IRestRoute`](IRestRoute.md)\>
8
8
 
9
9
  ## Methods
10
10
 
@@ -42,13 +42,17 @@ The state handed through the processors.
42
42
 
43
43
  Promise that resolves when the request is processed.
44
44
 
45
+ #### Inherited from
46
+
47
+ [`IBaseRouteProcessor`](IBaseRouteProcessor.md).[`pre`](IBaseRouteProcessor.md#pre)
48
+
45
49
  ***
46
50
 
47
- ### process()?
51
+ ### post()?
48
52
 
49
- > `optional` **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
53
+ > `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
50
54
 
51
- Process the REST request for the specified route.
55
+ Post process the REST request for the specified route.
52
56
 
53
57
  #### Parameters
54
58
 
@@ -78,13 +82,17 @@ The state handed through the processors.
78
82
 
79
83
  Promise that resolves when the request is processed.
80
84
 
85
+ #### Inherited from
86
+
87
+ [`IBaseRouteProcessor`](IBaseRouteProcessor.md).[`post`](IBaseRouteProcessor.md#post)
88
+
81
89
  ***
82
90
 
83
- ### post()?
91
+ ### process()?
84
92
 
85
- > `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
93
+ > `optional` **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
86
94
 
87
- Post process the REST request for the specified route.
95
+ Process the REST request for the specified route.
88
96
 
89
97
  #### Parameters
90
98
 
@@ -0,0 +1,43 @@
1
+ # Interface: IRestRouteRequestExample\<T\>
2
+
3
+ Interface which defines a REST route request example.
4
+
5
+ ## Extends
6
+
7
+ - [`IRestRouteExample`](IRestRouteExample.md)
8
+
9
+ ## Type Parameters
10
+
11
+ • **T**
12
+
13
+ ## Properties
14
+
15
+ ### id
16
+
17
+ > **id**: `string`
18
+
19
+ Example objects for the request.
20
+
21
+ #### Inherited from
22
+
23
+ [`IRestRouteExample`](IRestRouteExample.md).[`id`](IRestRouteExample.md#id)
24
+
25
+ ***
26
+
27
+ ### description?
28
+
29
+ > `optional` **description**: `string`
30
+
31
+ Description of the example.
32
+
33
+ #### Inherited from
34
+
35
+ [`IRestRouteExample`](IRestRouteExample.md).[`description`](IRestRouteExample.md#description)
36
+
37
+ ***
38
+
39
+ ### request
40
+
41
+ > **request**: `T`
42
+
43
+ The example request object.
@@ -0,0 +1,43 @@
1
+ # Interface: IRestRouteResponseExample\<T\>
2
+
3
+ Interface which defines a REST route response example.
4
+
5
+ ## Extends
6
+
7
+ - [`IRestRouteExample`](IRestRouteExample.md)
8
+
9
+ ## Type Parameters
10
+
11
+ • **T**
12
+
13
+ ## Properties
14
+
15
+ ### id
16
+
17
+ > **id**: `string`
18
+
19
+ Example objects for the request.
20
+
21
+ #### Inherited from
22
+
23
+ [`IRestRouteExample`](IRestRouteExample.md).[`id`](IRestRouteExample.md#id)
24
+
25
+ ***
26
+
27
+ ### description?
28
+
29
+ > `optional` **description**: `string`
30
+
31
+ Description of the example.
32
+
33
+ #### Inherited from
34
+
35
+ [`IRestRouteExample`](IRestRouteExample.md).[`description`](IRestRouteExample.md#description)
36
+
37
+ ***
38
+
39
+ ### response
40
+
41
+ > **response**: `T`
42
+
43
+ The example response object.
@@ -1,4 +1,4 @@
1
- # Interface: ISocketRoute
1
+ # Interface: ISocketRoute\<T, U\>
2
2
 
3
3
  Interface which defines a socket route.
4
4
 
@@ -6,6 +6,12 @@ Interface which defines a socket route.
6
6
 
7
7
  - [`IBaseRoute`](IBaseRoute.md)
8
8
 
9
+ ## Type Parameters
10
+
11
+ • **T** *extends* [`IHttpRequest`](IHttpRequest.md) = `any`
12
+
13
+ • **U** *extends* [`IHttpResponse`](IHttpResponse.md) = `any`
14
+
9
15
  ## Properties
10
16
 
11
17
  ### operationId
@@ -46,7 +52,7 @@ Skips the authentication for this route.
46
52
 
47
53
  ### handler()
48
54
 
49
- > **handler**: (`httpRequestContext`, `socketId`, `request`, `emitter`) => `Promise`\<`void`\>
55
+ > **handler**: (`httpRequestContext`, `request`, `emit`) => `void`
50
56
 
51
57
  The handler module.
52
58
 
@@ -56,18 +62,14 @@ The handler module.
56
62
 
57
63
  The request context.
58
64
 
59
- • **socketId**: `string`
60
-
61
- The id of the socket the request is arriving on.
62
-
63
- • **request**: `unknown`
65
+ • **request**: `T`
64
66
 
65
67
  The request object.
66
68
 
67
- • **emitter**
69
+ • **emit**
68
70
 
69
- Method to emit data on the socket.
71
+ The function to emit a message.
70
72
 
71
73
  #### Returns
72
74
 
73
- `Promise`\<`void`\>
75
+ `void`