@3sixty/api-processors 0.0.0-stage → 0.20.0-next.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.
Files changed (74) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +24 -2
  3. package/dist/es/data/restRouteProcessor.js +118 -0
  4. package/dist/es/data/restRouteProcessor.js.map +1 -0
  5. package/dist/es/data/socketRouteProcessor.js +131 -0
  6. package/dist/es/data/socketRouteProcessor.js.map +1 -0
  7. package/dist/es/identity/contextIdProcessor.js +69 -0
  8. package/dist/es/identity/contextIdProcessor.js.map +1 -0
  9. package/dist/es/identity/staticContextIdProcessor.js +60 -0
  10. package/dist/es/identity/staticContextIdProcessor.js.map +1 -0
  11. package/dist/es/index.js +19 -0
  12. package/dist/es/index.js.map +1 -0
  13. package/dist/es/logging/loggingProcessor.js +217 -0
  14. package/dist/es/logging/loggingProcessor.js.map +1 -0
  15. package/dist/es/mimeType/jsonLdMimeTypeProcessor.js +38 -0
  16. package/dist/es/mimeType/jsonLdMimeTypeProcessor.js.map +1 -0
  17. package/dist/es/mimeType/jwtMimeTypeProcessor.js +34 -0
  18. package/dist/es/mimeType/jwtMimeTypeProcessor.js.map +1 -0
  19. package/dist/es/models/IContextIdProcessorConfig.js +4 -0
  20. package/dist/es/models/IContextIdProcessorConfig.js.map +1 -0
  21. package/dist/es/models/IContextIdProcessorConstructorOptions.js +2 -0
  22. package/dist/es/models/IContextIdProcessorConstructorOptions.js.map +1 -0
  23. package/dist/es/models/ILoggingProcessorConfig.js +4 -0
  24. package/dist/es/models/ILoggingProcessorConfig.js.map +1 -0
  25. package/dist/es/models/ILoggingProcessorConstructorOptions.js +2 -0
  26. package/dist/es/models/ILoggingProcessorConstructorOptions.js.map +1 -0
  27. package/dist/es/models/IRestRouteProcessorConstructorOptions.js +2 -0
  28. package/dist/es/models/IRestRouteProcessorConstructorOptions.js.map +1 -0
  29. package/dist/es/models/IRouteProcessorConfig.js +4 -0
  30. package/dist/es/models/IRouteProcessorConfig.js.map +1 -0
  31. package/dist/es/models/ISocketRouteProcessorConstructorOptions.js +2 -0
  32. package/dist/es/models/ISocketRouteProcessorConstructorOptions.js.map +1 -0
  33. package/dist/es/models/IStaticContextIdProcessorConfig.js +4 -0
  34. package/dist/es/models/IStaticContextIdProcessorConfig.js.map +1 -0
  35. package/dist/es/models/IStaticContextIdProcessorConstructorOptions.js +2 -0
  36. package/dist/es/models/IStaticContextIdProcessorConstructorOptions.js.map +1 -0
  37. package/dist/types/data/restRouteProcessor.d.ts +36 -0
  38. package/dist/types/data/socketRouteProcessor.d.ts +50 -0
  39. package/dist/types/identity/contextIdProcessor.d.ts +40 -0
  40. package/dist/types/identity/staticContextIdProcessor.d.ts +34 -0
  41. package/dist/types/index.d.ts +16 -0
  42. package/dist/types/logging/loggingProcessor.d.ts +46 -0
  43. package/dist/types/mimeType/jsonLdMimeTypeProcessor.d.ts +26 -0
  44. package/dist/types/mimeType/jwtMimeTypeProcessor.d.ts +26 -0
  45. package/dist/types/models/IContextIdProcessorConfig.d.ts +13 -0
  46. package/dist/types/models/IContextIdProcessorConstructorOptions.d.ts +10 -0
  47. package/dist/types/models/ILoggingProcessorConfig.d.ts +22 -0
  48. package/dist/types/models/ILoggingProcessorConstructorOptions.d.ts +14 -0
  49. package/dist/types/models/IRestRouteProcessorConstructorOptions.d.ts +10 -0
  50. package/dist/types/models/IRouteProcessorConfig.d.ts +9 -0
  51. package/dist/types/models/ISocketRouteProcessorConstructorOptions.d.ts +10 -0
  52. package/dist/types/models/IStaticContextIdProcessorConfig.d.ts +17 -0
  53. package/dist/types/models/IStaticContextIdProcessorConstructorOptions.d.ts +10 -0
  54. package/docs/changelog.md +16 -0
  55. package/docs/examples.md +189 -0
  56. package/docs/reference/classes/ContextIdProcessor.md +129 -0
  57. package/docs/reference/classes/JsonLdMimeTypeProcessor.md +87 -0
  58. package/docs/reference/classes/JwtMimeTypeProcessor.md +87 -0
  59. package/docs/reference/classes/LoggingProcessor.md +153 -0
  60. package/docs/reference/classes/RestRouteProcessor.md +107 -0
  61. package/docs/reference/classes/SocketRouteProcessor.md +185 -0
  62. package/docs/reference/classes/StaticContextIdProcessor.md +103 -0
  63. package/docs/reference/index.md +23 -0
  64. package/docs/reference/interfaces/IContextIdProcessorConfig.md +19 -0
  65. package/docs/reference/interfaces/IContextIdProcessorConstructorOptions.md +11 -0
  66. package/docs/reference/interfaces/ILoggingProcessorConfig.md +36 -0
  67. package/docs/reference/interfaces/ILoggingProcessorConstructorOptions.md +19 -0
  68. package/docs/reference/interfaces/IRestRouteProcessorConstructorOptions.md +11 -0
  69. package/docs/reference/interfaces/IRouteProcessorConfig.md +11 -0
  70. package/docs/reference/interfaces/ISocketRouteProcessorConstructorOptions.md +11 -0
  71. package/docs/reference/interfaces/IStaticContextIdProcessorConfig.md +27 -0
  72. package/docs/reference/interfaces/IStaticContextIdProcessorConstructorOptions.md +11 -0
  73. package/locales/en.json +22 -0
  74. package/package.json +50 -5
@@ -0,0 +1,87 @@
1
+ # Class: JsonLdMimeTypeProcessor
2
+
3
+ Process the JSON-LD mime type.
4
+
5
+ ## Implements
6
+
7
+ - `IMimeTypeProcessor`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new JsonLdMimeTypeProcessor**(): `JsonLdMimeTypeProcessor`
14
+
15
+ #### Returns
16
+
17
+ `JsonLdMimeTypeProcessor`
18
+
19
+ ## Properties
20
+
21
+ ### CLASS\_NAME {#class_name}
22
+
23
+ > `readonly` `static` **CLASS\_NAME**: `string`
24
+
25
+ Runtime name for the class.
26
+
27
+ ## Methods
28
+
29
+ ### className() {#classname}
30
+
31
+ > **className**(): `string`
32
+
33
+ Returns the class name of the component.
34
+
35
+ #### Returns
36
+
37
+ `string`
38
+
39
+ The class name of the component.
40
+
41
+ #### Implementation of
42
+
43
+ `IMimeTypeProcessor.className`
44
+
45
+ ***
46
+
47
+ ### getTypes() {#gettypes}
48
+
49
+ > **getTypes**(): `string`[]
50
+
51
+ Get the MIME types that this handler can handle.
52
+
53
+ #### Returns
54
+
55
+ `string`[]
56
+
57
+ The MIME types that this handler can handle.
58
+
59
+ #### Implementation of
60
+
61
+ `IMimeTypeProcessor.getTypes`
62
+
63
+ ***
64
+
65
+ ### handle() {#handle}
66
+
67
+ > **handle**(`body`): `Promise`\<`unknown`\>
68
+
69
+ Handle content.
70
+
71
+ #### Parameters
72
+
73
+ ##### body
74
+
75
+ `Uint8Array`
76
+
77
+ The body to process.
78
+
79
+ #### Returns
80
+
81
+ `Promise`\<`unknown`\>
82
+
83
+ The processed body.
84
+
85
+ #### Implementation of
86
+
87
+ `IMimeTypeProcessor.handle`
@@ -0,0 +1,87 @@
1
+ # Class: JwtMimeTypeProcessor
2
+
3
+ Process the JWT mime type.
4
+
5
+ ## Implements
6
+
7
+ - `IMimeTypeProcessor`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new JwtMimeTypeProcessor**(): `JwtMimeTypeProcessor`
14
+
15
+ #### Returns
16
+
17
+ `JwtMimeTypeProcessor`
18
+
19
+ ## Properties
20
+
21
+ ### CLASS\_NAME {#class_name}
22
+
23
+ > `readonly` `static` **CLASS\_NAME**: `string`
24
+
25
+ Runtime name for the class.
26
+
27
+ ## Methods
28
+
29
+ ### className() {#classname}
30
+
31
+ > **className**(): `string`
32
+
33
+ Returns the class name of the component.
34
+
35
+ #### Returns
36
+
37
+ `string`
38
+
39
+ The class name of the component.
40
+
41
+ #### Implementation of
42
+
43
+ `IMimeTypeProcessor.className`
44
+
45
+ ***
46
+
47
+ ### getTypes() {#gettypes}
48
+
49
+ > **getTypes**(): `string`[]
50
+
51
+ Get the MIME types that this handler can handle.
52
+
53
+ #### Returns
54
+
55
+ `string`[]
56
+
57
+ The MIME types that this handler can handle.
58
+
59
+ #### Implementation of
60
+
61
+ `IMimeTypeProcessor.getTypes`
62
+
63
+ ***
64
+
65
+ ### handle() {#handle}
66
+
67
+ > **handle**(`body`): `Promise`\<`unknown`\>
68
+
69
+ Handle content.
70
+
71
+ #### Parameters
72
+
73
+ ##### body
74
+
75
+ `Uint8Array`
76
+
77
+ The body to process.
78
+
79
+ #### Returns
80
+
81
+ `Promise`\<`unknown`\>
82
+
83
+ The processed body.
84
+
85
+ #### Implementation of
86
+
87
+ `IMimeTypeProcessor.handle`
@@ -0,0 +1,153 @@
1
+ # Class: LoggingProcessor
2
+
3
+ Process the REST request and log its information.
4
+
5
+ ## Implements
6
+
7
+ - `IBaseRouteProcessor`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new LoggingProcessor**(`options?`): `LoggingProcessor`
14
+
15
+ Create a new instance of LoggingProcessor.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`ILoggingProcessorConstructorOptions`](../interfaces/ILoggingProcessorConstructorOptions.md)
22
+
23
+ Options for the processor.
24
+
25
+ #### Returns
26
+
27
+ `LoggingProcessor`
28
+
29
+ ## Properties
30
+
31
+ ### CLASS\_NAME {#class_name}
32
+
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
+
35
+ Runtime name for the class.
36
+
37
+ ## Methods
38
+
39
+ ### className() {#classname}
40
+
41
+ > **className**(): `string`
42
+
43
+ Returns the class name of the component.
44
+
45
+ #### Returns
46
+
47
+ `string`
48
+
49
+ The class name of the component.
50
+
51
+ #### Implementation of
52
+
53
+ `IBaseRouteProcessor.className`
54
+
55
+ ***
56
+
57
+ ### pre() {#pre}
58
+
59
+ > **pre**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
60
+
61
+ Pre process the REST request for the specified route.
62
+
63
+ #### Parameters
64
+
65
+ ##### request
66
+
67
+ `IHttpServerRequest`
68
+
69
+ The incoming request.
70
+
71
+ ##### response
72
+
73
+ `IHttpResponse`
74
+
75
+ The outgoing response.
76
+
77
+ ##### route
78
+
79
+ `IBaseRoute` \| `undefined`
80
+
81
+ The route to process.
82
+
83
+ ##### contextIds
84
+
85
+ `IContextIds`
86
+
87
+ The context IDs of the request.
88
+
89
+ ##### processorState
90
+
91
+ \{\[`id`: `string`\]: `unknown`; \}
92
+
93
+ The state handed through the processors.
94
+
95
+ #### Returns
96
+
97
+ `Promise`\<`void`\>
98
+
99
+ A promise that resolves when the pre-processing log entry has been written.
100
+
101
+ #### Implementation of
102
+
103
+ `IBaseRouteProcessor.pre`
104
+
105
+ ***
106
+
107
+ ### post() {#post}
108
+
109
+ > **post**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
110
+
111
+ Post process the REST request for the specified route.
112
+
113
+ #### Parameters
114
+
115
+ ##### request
116
+
117
+ `IHttpServerRequest`
118
+
119
+ The incoming request.
120
+
121
+ ##### response
122
+
123
+ `IHttpResponse`
124
+
125
+ The outgoing response.
126
+
127
+ ##### route
128
+
129
+ `IBaseRoute` \| `undefined`
130
+
131
+ The route to process.
132
+
133
+ ##### contextIds
134
+
135
+ `IContextIds`
136
+
137
+ The context IDs of the request.
138
+
139
+ ##### processorState
140
+
141
+ \{\[`id`: `string`\]: `unknown`; \}
142
+
143
+ The state handed through the processors.
144
+
145
+ #### Returns
146
+
147
+ `Promise`\<`void`\>
148
+
149
+ A promise that resolves when the post-processing log entry has been written.
150
+
151
+ #### Implementation of
152
+
153
+ `IBaseRouteProcessor.post`
@@ -0,0 +1,107 @@
1
+ # Class: RestRouteProcessor
2
+
3
+ Process the REST request and hands it on to the route handler.
4
+
5
+ ## Implements
6
+
7
+ - `IRestRouteProcessor`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new RestRouteProcessor**(`options?`): `RestRouteProcessor`
14
+
15
+ Create a new instance of RouteProcessor.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`IRestRouteProcessorConstructorOptions`](../interfaces/IRestRouteProcessorConstructorOptions.md)
22
+
23
+ Options for the processor.
24
+
25
+ #### Returns
26
+
27
+ `RestRouteProcessor`
28
+
29
+ ## Properties
30
+
31
+ ### CLASS\_NAME {#class_name}
32
+
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
+
35
+ Runtime name for the class.
36
+
37
+ ## Methods
38
+
39
+ ### className() {#classname}
40
+
41
+ > **className**(): `string`
42
+
43
+ Returns the class name of the component.
44
+
45
+ #### Returns
46
+
47
+ `string`
48
+
49
+ The class name of the component.
50
+
51
+ #### Implementation of
52
+
53
+ `IRestRouteProcessor.className`
54
+
55
+ ***
56
+
57
+ ### process() {#process}
58
+
59
+ > **process**(`request`, `response`, `route`, `processorState`, `componentTypes?`): `Promise`\<`void`\>
60
+
61
+ Process the REST request for the specified route.
62
+
63
+ #### Parameters
64
+
65
+ ##### request
66
+
67
+ `IHttpServerRequest`
68
+
69
+ The incoming request.
70
+
71
+ ##### response
72
+
73
+ `IHttpResponse`
74
+
75
+ The outgoing response.
76
+
77
+ ##### route
78
+
79
+ `IRestRoute`\<`any`, `any`\> \| `undefined`
80
+
81
+ The route to process.
82
+
83
+ ##### processorState
84
+
85
+ \{\[`id`: `string`\]: `unknown`; \}
86
+
87
+ The state handed through the processors.
88
+
89
+ ##### componentTypes?
90
+
91
+ The component types for the request.
92
+
93
+ ###### loggingComponentType?
94
+
95
+ `string`
96
+
97
+ The logging component type.
98
+
99
+ #### Returns
100
+
101
+ `Promise`\<`void`\>
102
+
103
+ A promise that resolves when the request has been processed and the response populated.
104
+
105
+ #### Implementation of
106
+
107
+ `IRestRouteProcessor.process`
@@ -0,0 +1,185 @@
1
+ # Class: SocketRouteProcessor
2
+
3
+ Process the socket request and hands it on to the route handler.
4
+
5
+ ## Implements
6
+
7
+ - `ISocketRouteProcessor`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new SocketRouteProcessor**(`options?`): `SocketRouteProcessor`
14
+
15
+ Create a new instance of SocketRouteProcessor.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`ISocketRouteProcessorConstructorOptions`](../interfaces/ISocketRouteProcessorConstructorOptions.md)
22
+
23
+ Options for the processor.
24
+
25
+ #### Returns
26
+
27
+ `SocketRouteProcessor`
28
+
29
+ ## Properties
30
+
31
+ ### CLASS\_NAME {#class_name}
32
+
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
+
35
+ Runtime name for the class.
36
+
37
+ ## Methods
38
+
39
+ ### className() {#classname}
40
+
41
+ > **className**(): `string`
42
+
43
+ Returns the class name of the component.
44
+
45
+ #### Returns
46
+
47
+ `string`
48
+
49
+ The class name of the component.
50
+
51
+ #### Implementation of
52
+
53
+ `ISocketRouteProcessor.className`
54
+
55
+ ***
56
+
57
+ ### connected() {#connected}
58
+
59
+ > **connected**(`request`, `route`, `loggingComponentType?`): `Promise`\<`void`\>
60
+
61
+ Process the connected event.
62
+
63
+ #### Parameters
64
+
65
+ ##### request
66
+
67
+ `ISocketServerRequest`
68
+
69
+ The server request object containing the socket id and other parameters.
70
+
71
+ ##### route
72
+
73
+ `ISocketRoute`\<`any`, `any`\> \| `undefined`
74
+
75
+ The route being requested, if a matching one was found.
76
+
77
+ ##### loggingComponentType?
78
+
79
+ `string`
80
+
81
+ The logging component type for the request.
82
+
83
+ #### Returns
84
+
85
+ `Promise`\<`void`\>
86
+
87
+ Promise that resolves when the request is processed.
88
+
89
+ #### Implementation of
90
+
91
+ `ISocketRouteProcessor.connected`
92
+
93
+ ***
94
+
95
+ ### disconnected() {#disconnected}
96
+
97
+ > **disconnected**(`request`, `route`, `loggingComponentType?`): `Promise`\<`void`\>
98
+
99
+ Process the disconnected event.
100
+
101
+ #### Parameters
102
+
103
+ ##### request
104
+
105
+ `ISocketServerRequest`
106
+
107
+ The server request object containing the socket id and other parameters.
108
+
109
+ ##### route
110
+
111
+ `ISocketRoute`\<`any`, `any`\> \| `undefined`
112
+
113
+ The route being requested, if a matching one was found.
114
+
115
+ ##### loggingComponentType?
116
+
117
+ `string`
118
+
119
+ The logging component type for the request.
120
+
121
+ #### Returns
122
+
123
+ `Promise`\<`void`\>
124
+
125
+ Promise that resolves when the request is processed.
126
+
127
+ #### Implementation of
128
+
129
+ `ISocketRouteProcessor.disconnected`
130
+
131
+ ***
132
+
133
+ ### process() {#process}
134
+
135
+ > **process**(`request`, `response`, `route`, `processorState`, `responseEmitter`, `loggingComponentType?`): `Promise`\<`void`\>
136
+
137
+ Process the socket request for the specified route.
138
+
139
+ #### Parameters
140
+
141
+ ##### request
142
+
143
+ `ISocketServerRequest`
144
+
145
+ The incoming request.
146
+
147
+ ##### response
148
+
149
+ `IHttpResponse`
150
+
151
+ The outgoing response.
152
+
153
+ ##### route
154
+
155
+ `ISocketRoute`\<`any`, `any`\> \| `undefined`
156
+
157
+ The route to process.
158
+
159
+ ##### processorState
160
+
161
+ \{\[`id`: `string`\]: `unknown`; \}
162
+
163
+ The state handed through the processors.
164
+
165
+ ##### responseEmitter
166
+
167
+ (`topic`, `response`) => `Promise`\<`void`\>
168
+
169
+ The function to emit a response.
170
+
171
+ ##### loggingComponentType?
172
+
173
+ `string`
174
+
175
+ The logging component type for the request.
176
+
177
+ #### Returns
178
+
179
+ `Promise`\<`void`\>
180
+
181
+ A promise that resolves when the request has been processed and the response emitted.
182
+
183
+ #### Implementation of
184
+
185
+ `ISocketRouteProcessor.process`
@@ -0,0 +1,103 @@
1
+ # Class: StaticContextIdProcessor
2
+
3
+ Adds a static context id to the request context.
4
+
5
+ ## Implements
6
+
7
+ - `IBaseRouteProcessor`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new StaticContextIdProcessor**(`options`): `StaticContextIdProcessor`
14
+
15
+ Create a new instance of StaticContextIdProcessor.
16
+
17
+ #### Parameters
18
+
19
+ ##### options
20
+
21
+ [`IStaticContextIdProcessorConstructorOptions`](../interfaces/IStaticContextIdProcessorConstructorOptions.md)
22
+
23
+ Options for the processor.
24
+
25
+ #### Returns
26
+
27
+ `StaticContextIdProcessor`
28
+
29
+ ## Properties
30
+
31
+ ### CLASS\_NAME {#class_name}
32
+
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
+
35
+ Runtime name for the class.
36
+
37
+ ## Methods
38
+
39
+ ### className() {#classname}
40
+
41
+ > **className**(): `string`
42
+
43
+ Returns the class name of the component.
44
+
45
+ #### Returns
46
+
47
+ `string`
48
+
49
+ The class name of the component.
50
+
51
+ #### Implementation of
52
+
53
+ `IBaseRouteProcessor.className`
54
+
55
+ ***
56
+
57
+ ### pre() {#pre}
58
+
59
+ > **pre**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
60
+
61
+ Pre process the REST request for the specified route.
62
+
63
+ #### Parameters
64
+
65
+ ##### request
66
+
67
+ `IHttpServerRequest`
68
+
69
+ The incoming request.
70
+
71
+ ##### response
72
+
73
+ `IHttpResponse`
74
+
75
+ The outgoing response.
76
+
77
+ ##### route
78
+
79
+ `IBaseRoute` \| `undefined`
80
+
81
+ The route to process.
82
+
83
+ ##### contextIds
84
+
85
+ `IContextIds`
86
+
87
+ The context IDs of the request.
88
+
89
+ ##### processorState
90
+
91
+ \{\[`id`: `string`\]: `unknown`; \}
92
+
93
+ The state handed through the processors.
94
+
95
+ #### Returns
96
+
97
+ `Promise`\<`void`\>
98
+
99
+ A promise that resolves when the static context ID has been injected into the request.
100
+
101
+ #### Implementation of
102
+
103
+ `IBaseRouteProcessor.pre`