@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.
- package/dist/cjs/index.cjs +68 -0
- package/dist/esm/index.mjs +66 -2
- 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/helpers/httpParameterHelper.d.ts +29 -0
- package/dist/types/index.d.ts +13 -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/IRestRoute.d.ts +4 -10
- package/dist/types/models/routes/IRestRouteEntryPoint.d.ts +2 -19
- package/dist/types/models/routes/IRestRouteExample.d.ts +13 -0
- package/dist/types/models/routes/IRestRouteRequestExample.d.ts +10 -0
- package/dist/types/models/routes/IRestRouteResponseExample.d.ts +10 -0
- 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 +1 -1
- package/docs/reference/classes/HttpParameterHelper.md +109 -0
- package/docs/reference/index.md +14 -2
- package/docs/reference/interfaces/IBaseRouteEntryPoint.md +49 -0
- package/docs/reference/interfaces/IBaseRouteProcessor.md +88 -0
- package/docs/reference/interfaces/IBaseSocketClientConfig.md +8 -0
- package/docs/reference/interfaces/ICreatedResponse.md +2 -2
- package/docs/reference/interfaces/IMimeTypeProcessor.md +41 -0
- package/docs/reference/interfaces/IRestRoute.md +1 -1
- package/docs/reference/interfaces/IRestRouteExample.md +24 -0
- package/docs/reference/interfaces/{IHttpRestRouteProcessor.md → IRestRouteProcessor.md} +16 -8
- package/docs/reference/interfaces/IRestRouteRequestExample.md +43 -0
- package/docs/reference/interfaces/IRestRouteResponseExample.md +43 -0
- package/docs/reference/interfaces/ISocketRoute.md +12 -10
- package/docs/reference/interfaces/ISocketRouteProcessor.md +183 -0
- package/docs/reference/interfaces/IWebServer.md +12 -4
- 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 +1 -28
- package/docs/reference/interfaces/IRestRouteEntryPoint.md +0 -45
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Interface: ISocketRouteProcessor
|
|
2
|
+
|
|
3
|
+
The definition for a processor for handling socket routes.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- [`IBaseRouteProcessor`](IBaseRouteProcessor.md)\<[`ISocketRoute`](ISocketRoute.md)\>
|
|
8
|
+
|
|
9
|
+
## Methods
|
|
10
|
+
|
|
11
|
+
### pre()?
|
|
12
|
+
|
|
13
|
+
> `optional` **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
14
|
+
|
|
15
|
+
Pre process the REST request for the specified route.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
20
|
+
|
|
21
|
+
The request to handle.
|
|
22
|
+
|
|
23
|
+
• **response**: [`IHttpResponse`](IHttpResponse.md)\<`any`\>
|
|
24
|
+
|
|
25
|
+
The response data to send if any.
|
|
26
|
+
|
|
27
|
+
• **route**: `undefined` \| [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
28
|
+
|
|
29
|
+
The route being requested, if a matching one was found.
|
|
30
|
+
|
|
31
|
+
• **requestIdentity**: [`IHttpRequestIdentity`](IHttpRequestIdentity.md)
|
|
32
|
+
|
|
33
|
+
The identity context for the request.
|
|
34
|
+
|
|
35
|
+
• **processorState**
|
|
36
|
+
|
|
37
|
+
The state handed through the processors.
|
|
38
|
+
|
|
39
|
+
#### Returns
|
|
40
|
+
|
|
41
|
+
`Promise`\<`void`\>
|
|
42
|
+
|
|
43
|
+
Promise that resolves when the request is processed.
|
|
44
|
+
|
|
45
|
+
#### Inherited from
|
|
46
|
+
|
|
47
|
+
[`IBaseRouteProcessor`](IBaseRouteProcessor.md).[`pre`](IBaseRouteProcessor.md#pre)
|
|
48
|
+
|
|
49
|
+
***
|
|
50
|
+
|
|
51
|
+
### post()?
|
|
52
|
+
|
|
53
|
+
> `optional` **post**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
54
|
+
|
|
55
|
+
Post process the REST request for the specified route.
|
|
56
|
+
|
|
57
|
+
#### Parameters
|
|
58
|
+
|
|
59
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
60
|
+
|
|
61
|
+
The request to handle.
|
|
62
|
+
|
|
63
|
+
• **response**: [`IHttpResponse`](IHttpResponse.md)\<`any`\>
|
|
64
|
+
|
|
65
|
+
The response data to send if any.
|
|
66
|
+
|
|
67
|
+
• **route**: `undefined` \| [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
68
|
+
|
|
69
|
+
The route being requested, if a matching one was found.
|
|
70
|
+
|
|
71
|
+
• **requestIdentity**: [`IHttpRequestIdentity`](IHttpRequestIdentity.md)
|
|
72
|
+
|
|
73
|
+
The identity context for the request.
|
|
74
|
+
|
|
75
|
+
• **processorState**
|
|
76
|
+
|
|
77
|
+
The state handed through the processors.
|
|
78
|
+
|
|
79
|
+
#### Returns
|
|
80
|
+
|
|
81
|
+
`Promise`\<`void`\>
|
|
82
|
+
|
|
83
|
+
Promise that resolves when the request is processed.
|
|
84
|
+
|
|
85
|
+
#### Inherited from
|
|
86
|
+
|
|
87
|
+
[`IBaseRouteProcessor`](IBaseRouteProcessor.md).[`post`](IBaseRouteProcessor.md#post)
|
|
88
|
+
|
|
89
|
+
***
|
|
90
|
+
|
|
91
|
+
### connected()?
|
|
92
|
+
|
|
93
|
+
> `optional` **connected**(`request`, `route`, `processorState`): `Promise`\<`void`\>
|
|
94
|
+
|
|
95
|
+
Process the connected event.
|
|
96
|
+
|
|
97
|
+
#### Parameters
|
|
98
|
+
|
|
99
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
100
|
+
|
|
101
|
+
The request to handle.
|
|
102
|
+
|
|
103
|
+
• **route**: `undefined` \| [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
104
|
+
|
|
105
|
+
The route being requested, if a matching one was found.
|
|
106
|
+
|
|
107
|
+
• **processorState**
|
|
108
|
+
|
|
109
|
+
The state handed through the processors.
|
|
110
|
+
|
|
111
|
+
#### Returns
|
|
112
|
+
|
|
113
|
+
`Promise`\<`void`\>
|
|
114
|
+
|
|
115
|
+
Promise that resolves when the request is processed.
|
|
116
|
+
|
|
117
|
+
***
|
|
118
|
+
|
|
119
|
+
### disconnected()?
|
|
120
|
+
|
|
121
|
+
> `optional` **disconnected**(`request`, `route`, `processorState`): `Promise`\<`void`\>
|
|
122
|
+
|
|
123
|
+
Process the disconnected event.
|
|
124
|
+
|
|
125
|
+
#### Parameters
|
|
126
|
+
|
|
127
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
128
|
+
|
|
129
|
+
The request to handle.
|
|
130
|
+
|
|
131
|
+
• **route**: `undefined` \| [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
132
|
+
|
|
133
|
+
The route being requested, if a matching one was found.
|
|
134
|
+
|
|
135
|
+
• **processorState**
|
|
136
|
+
|
|
137
|
+
The state handed through the processors.
|
|
138
|
+
|
|
139
|
+
#### Returns
|
|
140
|
+
|
|
141
|
+
`Promise`\<`void`\>
|
|
142
|
+
|
|
143
|
+
Promise that resolves when the request is processed.
|
|
144
|
+
|
|
145
|
+
***
|
|
146
|
+
|
|
147
|
+
### process()?
|
|
148
|
+
|
|
149
|
+
> `optional` **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `responseEmitter`): `Promise`\<`void`\>
|
|
150
|
+
|
|
151
|
+
Process the REST request for the specified route.
|
|
152
|
+
|
|
153
|
+
#### Parameters
|
|
154
|
+
|
|
155
|
+
• **request**: [`IHttpServerRequest`](IHttpServerRequest.md)\<`any`\>
|
|
156
|
+
|
|
157
|
+
The request to handle.
|
|
158
|
+
|
|
159
|
+
• **response**: [`IHttpResponse`](IHttpResponse.md)\<`any`\>
|
|
160
|
+
|
|
161
|
+
The response data to send if any.
|
|
162
|
+
|
|
163
|
+
• **route**: `undefined` \| [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>
|
|
164
|
+
|
|
165
|
+
The route being requested, if a matching one was found.
|
|
166
|
+
|
|
167
|
+
• **requestIdentity**: [`IHttpRequestIdentity`](IHttpRequestIdentity.md)
|
|
168
|
+
|
|
169
|
+
The identity context for the request.
|
|
170
|
+
|
|
171
|
+
• **processorState**
|
|
172
|
+
|
|
173
|
+
The state handed through the processors.
|
|
174
|
+
|
|
175
|
+
• **responseEmitter**
|
|
176
|
+
|
|
177
|
+
The function to emit a response.
|
|
178
|
+
|
|
179
|
+
#### Returns
|
|
180
|
+
|
|
181
|
+
`Promise`\<`void`\>
|
|
182
|
+
|
|
183
|
+
Promise that resolves when the request is processed.
|
|
@@ -24,20 +24,28 @@ The web server instance.
|
|
|
24
24
|
|
|
25
25
|
### build()
|
|
26
26
|
|
|
27
|
-
> **build**(`restRouteProcessors
|
|
27
|
+
> **build**(`restRouteProcessors`?, `restRoutes`?, `socketRouteProcessors`?, `socketRoutes`?, `options`?): `Promise`\<`void`\>
|
|
28
28
|
|
|
29
29
|
Build the server.
|
|
30
30
|
|
|
31
31
|
#### Parameters
|
|
32
32
|
|
|
33
|
-
• **restRouteProcessors
|
|
33
|
+
• **restRouteProcessors?**: [`IRestRouteProcessor`](IRestRouteProcessor.md)[]
|
|
34
34
|
|
|
35
|
-
The
|
|
35
|
+
The processors for incoming requests over REST.
|
|
36
36
|
|
|
37
|
-
• **restRoutes
|
|
37
|
+
• **restRoutes?**: [`IRestRoute`](IRestRoute.md)\<`any`, `any`\>[]
|
|
38
38
|
|
|
39
39
|
The REST routes.
|
|
40
40
|
|
|
41
|
+
• **socketRouteProcessors?**: [`ISocketRouteProcessor`](ISocketRouteProcessor.md)[]
|
|
42
|
+
|
|
43
|
+
The processors for incoming requests over Sockets.
|
|
44
|
+
|
|
45
|
+
• **socketRoutes?**: [`ISocketRoute`](ISocketRoute.md)\<`any`, `any`\>[]
|
|
46
|
+
|
|
47
|
+
The socket routes.
|
|
48
|
+
|
|
41
49
|
• **options?**: [`IWebServerOptions`](IWebServerOptions.md)
|
|
42
50
|
|
|
43
51
|
Options for building the server.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/api-models",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.20",
|
|
4
4
|
"description": "Contains models and classes for use with APIs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,38 +13,11 @@
|
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"clean": "rimraf dist coverage",
|
|
18
|
-
"build": "tspc",
|
|
19
|
-
"test": "vitest --run --config ./vitest.config.ts --no-cache",
|
|
20
|
-
"coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
|
|
21
|
-
"bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
|
|
22
|
-
"bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
|
|
23
|
-
"bundle": "npm run bundle:esm && npm run bundle:cjs",
|
|
24
|
-
"docs:clean": "rimraf docs/reference",
|
|
25
|
-
"docs:generate": "typedoc",
|
|
26
|
-
"docs": "npm run docs:clean && npm run docs:generate",
|
|
27
|
-
"dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
|
|
28
|
-
},
|
|
29
16
|
"dependencies": {
|
|
30
17
|
"@twin.org/core": "next",
|
|
31
18
|
"@twin.org/nameof": "next",
|
|
32
19
|
"@twin.org/web": "next"
|
|
33
20
|
},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@twin.org/nameof-transformer": "next",
|
|
36
|
-
"@vitest/coverage-v8": "2.1.1",
|
|
37
|
-
"@types/node": "22.5.5",
|
|
38
|
-
"copyfiles": "2.4.1",
|
|
39
|
-
"rimraf": "6.0.1",
|
|
40
|
-
"rollup": "4.21.3",
|
|
41
|
-
"rollup-plugin-typescript2": "0.36.0",
|
|
42
|
-
"ts-patch": "3.2.1",
|
|
43
|
-
"typedoc": "0.26.7",
|
|
44
|
-
"typedoc-plugin-markdown": "4.2.7",
|
|
45
|
-
"typescript": "5.6.2",
|
|
46
|
-
"vitest": "2.1.1"
|
|
47
|
-
},
|
|
48
21
|
"main": "./dist/cjs/index.cjs",
|
|
49
22
|
"module": "./dist/esm/index.mjs",
|
|
50
23
|
"types": "./dist/types/index.d.ts",
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# Interface: IRestRouteEntryPoint
|
|
2
|
-
|
|
3
|
-
Route entry points are used for exposing the REST routes from a package.
|
|
4
|
-
|
|
5
|
-
## Properties
|
|
6
|
-
|
|
7
|
-
### name
|
|
8
|
-
|
|
9
|
-
> **name**: `string`
|
|
10
|
-
|
|
11
|
-
The name of the REST routes.
|
|
12
|
-
|
|
13
|
-
***
|
|
14
|
-
|
|
15
|
-
### defaultBaseRoute
|
|
16
|
-
|
|
17
|
-
> **defaultBaseRoute**: `string`
|
|
18
|
-
|
|
19
|
-
The default base route name for the REST routes.
|
|
20
|
-
|
|
21
|
-
***
|
|
22
|
-
|
|
23
|
-
### tags
|
|
24
|
-
|
|
25
|
-
> **tags**: [`ITag`](ITag.md)[]
|
|
26
|
-
|
|
27
|
-
The tags for the REST routes.
|
|
28
|
-
|
|
29
|
-
***
|
|
30
|
-
|
|
31
|
-
### generateRoutes()
|
|
32
|
-
|
|
33
|
-
> **generateRoutes**: (`baseRouteName`, `componentName`) => [`IRestRoute`](IRestRoute.md)\<`any`, `any`\>[]
|
|
34
|
-
|
|
35
|
-
The method to generate the REST routes.
|
|
36
|
-
|
|
37
|
-
#### Parameters
|
|
38
|
-
|
|
39
|
-
• **baseRouteName**: `string`
|
|
40
|
-
|
|
41
|
-
• **componentName**: `string`
|
|
42
|
-
|
|
43
|
-
#### Returns
|
|
44
|
-
|
|
45
|
-
[`IRestRoute`](IRestRoute.md)\<`any`, `any`\>[]
|