@twin.org/api-processors 0.0.2-next.2 → 0.0.2-next.5

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.
@@ -3,7 +3,6 @@
3
3
  var apiModels = require('@twin.org/api-models');
4
4
  var core = require('@twin.org/core');
5
5
  var web = require('@twin.org/web');
6
- var loggingModels = require('@twin.org/logging-models');
7
6
 
8
7
  // Copyright 2024 IOTA Stiftung.
9
8
  // SPDX-License-Identifier: Apache-2.0.
@@ -11,10 +10,6 @@ var loggingModels = require('@twin.org/logging-models');
11
10
  * Process the REST request and hands it on to the route handler.
12
11
  */
13
12
  class RestRouteProcessor {
14
- /**
15
- * The namespace supported by the processor.
16
- */
17
- static NAMESPACE = "rest-route";
18
13
  /**
19
14
  * Runtime name for the class.
20
15
  */
@@ -38,8 +33,9 @@ class RestRouteProcessor {
38
33
  * @param route The route to process.
39
34
  * @param requestIdentity The identity context for the request.
40
35
  * @param processorState The state handed through the processors.
36
+ * @param loggingComponentType The logging component type for the request.
41
37
  */
42
- async process(request, response, route, requestIdentity, processorState) {
38
+ async process(request, response, route, requestIdentity, processorState, loggingComponentType) {
43
39
  // Don't handle the route if another processor has already set the response
44
40
  // status code e.g. from an auth processor
45
41
  if (core.Is.empty(response.statusCode)) {
@@ -62,7 +58,8 @@ class RestRouteProcessor {
62
58
  const restRouteResponse = await route.handler({
63
59
  ...requestIdentity,
64
60
  serverRequest: request,
65
- processorState
61
+ processorState,
62
+ loggingComponentType
66
63
  }, req);
67
64
  let statusCode = restRouteResponse.statusCode ?? response.statusCode ?? web.HttpStatusCode.ok;
68
65
  const headers = restRouteResponse?.headers ?? {};
@@ -120,10 +117,6 @@ class RestRouteProcessor {
120
117
  * Process the socket request and hands it on to the route handler.
121
118
  */
122
119
  class SocketRouteProcessor {
123
- /**
124
- * The namespace supported by the processor.
125
- */
126
- static NAMESPACE = "socket-route";
127
120
  /**
128
121
  * Runtime name for the class.
129
122
  */
@@ -140,6 +133,48 @@ class SocketRouteProcessor {
140
133
  constructor(options) {
141
134
  this._includeErrorStack = options?.config?.includeErrorStack ?? false;
142
135
  }
136
+ /**
137
+ * Process the connected event.
138
+ * @param request The server request object containing the socket id and other parameters.
139
+ * @param route The route being requested, if a matching one was found.
140
+ * @param loggingComponentType The logging component type for the request.
141
+ * @returns Promise that resolves when the request is processed.
142
+ */
143
+ async connected(request, route, loggingComponentType) {
144
+ if (route?.connected) {
145
+ try {
146
+ const socketRequestContext = {
147
+ socketId: request.socketId,
148
+ serverRequest: request,
149
+ processorState: {},
150
+ loggingComponentType
151
+ };
152
+ await route.connected(socketRequestContext);
153
+ }
154
+ catch { }
155
+ }
156
+ }
157
+ /**
158
+ * Process the disconnected event.
159
+ * @param request The server request object containing the socket id and other parameters.
160
+ * @param route The route being requested, if a matching one was found.
161
+ * @param loggingComponentType The logging component type for the request.
162
+ * @returns Promise that resolves when the request is processed.
163
+ */
164
+ async disconnected(request, route, loggingComponentType) {
165
+ if (route?.disconnected) {
166
+ try {
167
+ const socketRequestContext = {
168
+ socketId: request.socketId,
169
+ serverRequest: request,
170
+ processorState: {},
171
+ loggingComponentType
172
+ };
173
+ await route.disconnected(socketRequestContext);
174
+ }
175
+ catch { }
176
+ }
177
+ }
143
178
  /**
144
179
  * Process the REST request for the specified route.
145
180
  * @param request The incoming request.
@@ -148,8 +183,9 @@ class SocketRouteProcessor {
148
183
  * @param requestIdentity The identity context for the request.
149
184
  * @param processorState The state handed through the processors.
150
185
  * @param responseEmitter The function to emit a response.
186
+ * @param loggingComponentType The logging component type for the request.
151
187
  */
152
- async process(request, response, route, requestIdentity, processorState, responseEmitter) {
188
+ async process(request, response, route, requestIdentity, processorState, responseEmitter, loggingComponentType) {
153
189
  // Don't handle the route if another processor has already set the response
154
190
  // status code e.g. from an auth processor
155
191
  if (core.Is.empty(response.statusCode)) {
@@ -169,11 +205,14 @@ class SocketRouteProcessor {
169
205
  query: request.query,
170
206
  body: request.body
171
207
  };
172
- await route.handler({
208
+ const socketRequestContext = {
173
209
  ...requestIdentity,
210
+ socketId: request.socketId,
174
211
  serverRequest: request,
175
- processorState
176
- }, req, async (topic, restRouteResponse) => {
212
+ processorState,
213
+ loggingComponentType
214
+ };
215
+ await route.handler(socketRequestContext, req, async (topic, restRouteResponse) => {
177
216
  response.headers = restRouteResponse?.headers;
178
217
  response.body = restRouteResponse?.body;
179
218
  response.statusCode =
@@ -194,10 +233,6 @@ class SocketRouteProcessor {
194
233
  * Adds a node identity to the request identity.
195
234
  */
196
235
  class NodeIdentityProcessor {
197
- /**
198
- * The namespace supported by the processor.
199
- */
200
- static NAMESPACE = "node-identity";
201
236
  /**
202
237
  * Runtime name for the class.
203
238
  */
@@ -234,10 +269,6 @@ class NodeIdentityProcessor {
234
269
  * Adds a static user identity to the request context.
235
270
  */
236
271
  class StaticUserIdentityProcessor {
237
- /**
238
- * The namespace supported by the processor.
239
- */
240
- static NAMESPACE = "static-user-identity";
241
272
  /**
242
273
  * Runtime name for the class.
243
274
  */
@@ -276,19 +307,15 @@ class StaticUserIdentityProcessor {
276
307
  * Process the REST request and log its information.
277
308
  */
278
309
  class LoggingProcessor {
279
- /**
280
- * The namespace supported by the processor.
281
- */
282
- static NAMESPACE = "logging";
283
310
  /**
284
311
  * Runtime name for the class.
285
312
  */
286
313
  CLASS_NAME = "LoggingProcessor";
287
314
  /**
288
- * The connector for logging the information.
315
+ * The component for logging the information.
289
316
  * @internal
290
317
  */
291
- _loggingConnector;
318
+ _loggingComponent;
292
319
  /**
293
320
  * Include the body objects when logging the information.
294
321
  * @internal
@@ -309,7 +336,7 @@ class LoggingProcessor {
309
336
  * @param options Options for the processor.
310
337
  */
311
338
  constructor(options) {
312
- this._loggingConnector = loggingModels.LoggingConnectorFactory.get(options?.loggingConnectorType ?? "logging");
339
+ this._loggingComponent = core.ComponentFactory.get(options?.loggingComponentType ?? "logging");
313
340
  this._includeBody = options?.config?.includeBody ?? false;
314
341
  this._fullBase64 = options?.config?.fullBase64 ?? false;
315
342
  this._obfuscateProperties = options?.config?.obfuscateProperties ?? ["password"];
@@ -339,7 +366,7 @@ class LoggingProcessor {
339
366
  requestUrl = request.url;
340
367
  }
341
368
  }
342
- await this._loggingConnector.log({
369
+ await this._loggingComponent.log({
343
370
  level: "info",
344
371
  source: this.CLASS_NAME,
345
372
  ts: Date.now(),
@@ -399,7 +426,7 @@ class LoggingProcessor {
399
426
  requestUrl = request.url;
400
427
  }
401
428
  }
402
- await this._loggingConnector.log({
429
+ await this._loggingComponent.log({
403
430
  level: core.Is.number(response.statusCode) && response.statusCode >= web.HttpStatusCode.badRequest
404
431
  ? "error"
405
432
  : "info",
@@ -441,10 +468,6 @@ class LoggingProcessor {
441
468
  * Process the JSON-LD mime type.
442
469
  */
443
470
  class JsonLdMimeTypeProcessor {
444
- /**
445
- * The namespace supported by the processor.
446
- */
447
- static NAMESPACE = "json-ld";
448
471
  /**
449
472
  * Runtime name for the class.
450
473
  */
@@ -474,10 +497,6 @@ class JsonLdMimeTypeProcessor {
474
497
  * Process the JWT mime type.
475
498
  */
476
499
  class JwtMimeTypeProcessor {
477
- /**
478
- * The namespace supported by the processor.
479
- */
480
- static NAMESPACE = "jwt";
481
500
  /**
482
501
  * Runtime name for the class.
483
502
  */
@@ -1,7 +1,6 @@
1
1
  import { HttpErrorHelper } from '@twin.org/api-models';
2
- import { Is, NotFoundError, Guards, ObjectHelper, Coerce, GeneralError, Converter } from '@twin.org/core';
2
+ import { Is, NotFoundError, Guards, ComponentFactory, ObjectHelper, Coerce, GeneralError, Converter } from '@twin.org/core';
3
3
  import { HttpStatusCode, HeaderTypes, MimeTypes } from '@twin.org/web';
4
- import { LoggingConnectorFactory } from '@twin.org/logging-models';
5
4
 
6
5
  // Copyright 2024 IOTA Stiftung.
7
6
  // SPDX-License-Identifier: Apache-2.0.
@@ -9,10 +8,6 @@ import { LoggingConnectorFactory } from '@twin.org/logging-models';
9
8
  * Process the REST request and hands it on to the route handler.
10
9
  */
11
10
  class RestRouteProcessor {
12
- /**
13
- * The namespace supported by the processor.
14
- */
15
- static NAMESPACE = "rest-route";
16
11
  /**
17
12
  * Runtime name for the class.
18
13
  */
@@ -36,8 +31,9 @@ class RestRouteProcessor {
36
31
  * @param route The route to process.
37
32
  * @param requestIdentity The identity context for the request.
38
33
  * @param processorState The state handed through the processors.
34
+ * @param loggingComponentType The logging component type for the request.
39
35
  */
40
- async process(request, response, route, requestIdentity, processorState) {
36
+ async process(request, response, route, requestIdentity, processorState, loggingComponentType) {
41
37
  // Don't handle the route if another processor has already set the response
42
38
  // status code e.g. from an auth processor
43
39
  if (Is.empty(response.statusCode)) {
@@ -60,7 +56,8 @@ class RestRouteProcessor {
60
56
  const restRouteResponse = await route.handler({
61
57
  ...requestIdentity,
62
58
  serverRequest: request,
63
- processorState
59
+ processorState,
60
+ loggingComponentType
64
61
  }, req);
65
62
  let statusCode = restRouteResponse.statusCode ?? response.statusCode ?? HttpStatusCode.ok;
66
63
  const headers = restRouteResponse?.headers ?? {};
@@ -118,10 +115,6 @@ class RestRouteProcessor {
118
115
  * Process the socket request and hands it on to the route handler.
119
116
  */
120
117
  class SocketRouteProcessor {
121
- /**
122
- * The namespace supported by the processor.
123
- */
124
- static NAMESPACE = "socket-route";
125
118
  /**
126
119
  * Runtime name for the class.
127
120
  */
@@ -138,6 +131,48 @@ class SocketRouteProcessor {
138
131
  constructor(options) {
139
132
  this._includeErrorStack = options?.config?.includeErrorStack ?? false;
140
133
  }
134
+ /**
135
+ * Process the connected event.
136
+ * @param request The server request object containing the socket id and other parameters.
137
+ * @param route The route being requested, if a matching one was found.
138
+ * @param loggingComponentType The logging component type for the request.
139
+ * @returns Promise that resolves when the request is processed.
140
+ */
141
+ async connected(request, route, loggingComponentType) {
142
+ if (route?.connected) {
143
+ try {
144
+ const socketRequestContext = {
145
+ socketId: request.socketId,
146
+ serverRequest: request,
147
+ processorState: {},
148
+ loggingComponentType
149
+ };
150
+ await route.connected(socketRequestContext);
151
+ }
152
+ catch { }
153
+ }
154
+ }
155
+ /**
156
+ * Process the disconnected event.
157
+ * @param request The server request object containing the socket id and other parameters.
158
+ * @param route The route being requested, if a matching one was found.
159
+ * @param loggingComponentType The logging component type for the request.
160
+ * @returns Promise that resolves when the request is processed.
161
+ */
162
+ async disconnected(request, route, loggingComponentType) {
163
+ if (route?.disconnected) {
164
+ try {
165
+ const socketRequestContext = {
166
+ socketId: request.socketId,
167
+ serverRequest: request,
168
+ processorState: {},
169
+ loggingComponentType
170
+ };
171
+ await route.disconnected(socketRequestContext);
172
+ }
173
+ catch { }
174
+ }
175
+ }
141
176
  /**
142
177
  * Process the REST request for the specified route.
143
178
  * @param request The incoming request.
@@ -146,8 +181,9 @@ class SocketRouteProcessor {
146
181
  * @param requestIdentity The identity context for the request.
147
182
  * @param processorState The state handed through the processors.
148
183
  * @param responseEmitter The function to emit a response.
184
+ * @param loggingComponentType The logging component type for the request.
149
185
  */
150
- async process(request, response, route, requestIdentity, processorState, responseEmitter) {
186
+ async process(request, response, route, requestIdentity, processorState, responseEmitter, loggingComponentType) {
151
187
  // Don't handle the route if another processor has already set the response
152
188
  // status code e.g. from an auth processor
153
189
  if (Is.empty(response.statusCode)) {
@@ -167,11 +203,14 @@ class SocketRouteProcessor {
167
203
  query: request.query,
168
204
  body: request.body
169
205
  };
170
- await route.handler({
206
+ const socketRequestContext = {
171
207
  ...requestIdentity,
208
+ socketId: request.socketId,
172
209
  serverRequest: request,
173
- processorState
174
- }, req, async (topic, restRouteResponse) => {
210
+ processorState,
211
+ loggingComponentType
212
+ };
213
+ await route.handler(socketRequestContext, req, async (topic, restRouteResponse) => {
175
214
  response.headers = restRouteResponse?.headers;
176
215
  response.body = restRouteResponse?.body;
177
216
  response.statusCode =
@@ -192,10 +231,6 @@ class SocketRouteProcessor {
192
231
  * Adds a node identity to the request identity.
193
232
  */
194
233
  class NodeIdentityProcessor {
195
- /**
196
- * The namespace supported by the processor.
197
- */
198
- static NAMESPACE = "node-identity";
199
234
  /**
200
235
  * Runtime name for the class.
201
236
  */
@@ -232,10 +267,6 @@ class NodeIdentityProcessor {
232
267
  * Adds a static user identity to the request context.
233
268
  */
234
269
  class StaticUserIdentityProcessor {
235
- /**
236
- * The namespace supported by the processor.
237
- */
238
- static NAMESPACE = "static-user-identity";
239
270
  /**
240
271
  * Runtime name for the class.
241
272
  */
@@ -274,19 +305,15 @@ class StaticUserIdentityProcessor {
274
305
  * Process the REST request and log its information.
275
306
  */
276
307
  class LoggingProcessor {
277
- /**
278
- * The namespace supported by the processor.
279
- */
280
- static NAMESPACE = "logging";
281
308
  /**
282
309
  * Runtime name for the class.
283
310
  */
284
311
  CLASS_NAME = "LoggingProcessor";
285
312
  /**
286
- * The connector for logging the information.
313
+ * The component for logging the information.
287
314
  * @internal
288
315
  */
289
- _loggingConnector;
316
+ _loggingComponent;
290
317
  /**
291
318
  * Include the body objects when logging the information.
292
319
  * @internal
@@ -307,7 +334,7 @@ class LoggingProcessor {
307
334
  * @param options Options for the processor.
308
335
  */
309
336
  constructor(options) {
310
- this._loggingConnector = LoggingConnectorFactory.get(options?.loggingConnectorType ?? "logging");
337
+ this._loggingComponent = ComponentFactory.get(options?.loggingComponentType ?? "logging");
311
338
  this._includeBody = options?.config?.includeBody ?? false;
312
339
  this._fullBase64 = options?.config?.fullBase64 ?? false;
313
340
  this._obfuscateProperties = options?.config?.obfuscateProperties ?? ["password"];
@@ -337,7 +364,7 @@ class LoggingProcessor {
337
364
  requestUrl = request.url;
338
365
  }
339
366
  }
340
- await this._loggingConnector.log({
367
+ await this._loggingComponent.log({
341
368
  level: "info",
342
369
  source: this.CLASS_NAME,
343
370
  ts: Date.now(),
@@ -397,7 +424,7 @@ class LoggingProcessor {
397
424
  requestUrl = request.url;
398
425
  }
399
426
  }
400
- await this._loggingConnector.log({
427
+ await this._loggingComponent.log({
401
428
  level: Is.number(response.statusCode) && response.statusCode >= HttpStatusCode.badRequest
402
429
  ? "error"
403
430
  : "info",
@@ -439,10 +466,6 @@ class LoggingProcessor {
439
466
  * Process the JSON-LD mime type.
440
467
  */
441
468
  class JsonLdMimeTypeProcessor {
442
- /**
443
- * The namespace supported by the processor.
444
- */
445
- static NAMESPACE = "json-ld";
446
469
  /**
447
470
  * Runtime name for the class.
448
471
  */
@@ -472,10 +495,6 @@ class JsonLdMimeTypeProcessor {
472
495
  * Process the JWT mime type.
473
496
  */
474
497
  class JwtMimeTypeProcessor {
475
- /**
476
- * The namespace supported by the processor.
477
- */
478
- static NAMESPACE = "jwt";
479
498
  /**
480
499
  * Runtime name for the class.
481
500
  */
@@ -4,10 +4,6 @@ import type { IRestRouteProcessorConstructorOptions } from "../models/IRestRoute
4
4
  * Process the REST request and hands it on to the route handler.
5
5
  */
6
6
  export declare class RestRouteProcessor implements IRestRouteProcessor {
7
- /**
8
- * The namespace supported by the processor.
9
- */
10
- static readonly NAMESPACE: string;
11
7
  /**
12
8
  * Runtime name for the class.
13
9
  */
@@ -24,8 +20,9 @@ export declare class RestRouteProcessor implements IRestRouteProcessor {
24
20
  * @param route The route to process.
25
21
  * @param requestIdentity The identity context for the request.
26
22
  * @param processorState The state handed through the processors.
23
+ * @param loggingComponentType The logging component type for the request.
27
24
  */
28
25
  process(request: IHttpServerRequest, response: IHttpResponse, route: IRestRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
29
26
  [id: string]: unknown;
30
- }): Promise<void>;
27
+ }, loggingComponentType?: string): Promise<void>;
31
28
  }
@@ -1,13 +1,9 @@
1
- import { type IHttpRequestIdentity, type IHttpResponse, type IHttpServerRequest, type ISocketRoute, type ISocketRouteProcessor } from "@twin.org/api-models";
1
+ import { type IHttpRequestIdentity, type IHttpResponse, type ISocketRoute, type ISocketRouteProcessor, type ISocketServerRequest } from "@twin.org/api-models";
2
2
  import type { ISocketRouteProcessorConstructorOptions } from "../models/ISocketRouteProcessorConstructorOptions";
3
3
  /**
4
4
  * Process the socket request and hands it on to the route handler.
5
5
  */
6
6
  export declare class SocketRouteProcessor implements ISocketRouteProcessor {
7
- /**
8
- * The namespace supported by the processor.
9
- */
10
- static readonly NAMESPACE: string;
11
7
  /**
12
8
  * Runtime name for the class.
13
9
  */
@@ -17,6 +13,22 @@ export declare class SocketRouteProcessor implements ISocketRouteProcessor {
17
13
  * @param options Options for the processor.
18
14
  */
19
15
  constructor(options?: ISocketRouteProcessorConstructorOptions);
16
+ /**
17
+ * Process the connected event.
18
+ * @param request The server request object containing the socket id and other parameters.
19
+ * @param route The route being requested, if a matching one was found.
20
+ * @param loggingComponentType The logging component type for the request.
21
+ * @returns Promise that resolves when the request is processed.
22
+ */
23
+ connected(request: ISocketServerRequest, route: ISocketRoute | undefined, loggingComponentType?: string): Promise<void>;
24
+ /**
25
+ * Process the disconnected event.
26
+ * @param request The server request object containing the socket id and other parameters.
27
+ * @param route The route being requested, if a matching one was found.
28
+ * @param loggingComponentType The logging component type for the request.
29
+ * @returns Promise that resolves when the request is processed.
30
+ */
31
+ disconnected(request: ISocketServerRequest, route: ISocketRoute | undefined, loggingComponentType?: string): Promise<void>;
20
32
  /**
21
33
  * Process the REST request for the specified route.
22
34
  * @param request The incoming request.
@@ -25,8 +37,9 @@ export declare class SocketRouteProcessor implements ISocketRouteProcessor {
25
37
  * @param requestIdentity The identity context for the request.
26
38
  * @param processorState The state handed through the processors.
27
39
  * @param responseEmitter The function to emit a response.
40
+ * @param loggingComponentType The logging component type for the request.
28
41
  */
29
- process(request: IHttpServerRequest, response: IHttpResponse, route: ISocketRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
42
+ process(request: ISocketServerRequest, response: IHttpResponse, route: ISocketRoute | undefined, requestIdentity: IHttpRequestIdentity, processorState: {
30
43
  [id: string]: unknown;
31
- }, responseEmitter: (topic: string, response: IHttpResponse) => Promise<void>): Promise<void>;
44
+ }, responseEmitter: (topic: string, response: IHttpResponse) => Promise<void>, loggingComponentType?: string): Promise<void>;
32
45
  }
@@ -3,10 +3,6 @@ import type { IBaseRoute, IBaseRouteProcessor, IHttpRequestIdentity, IHttpRespon
3
3
  * Adds a node identity to the request identity.
4
4
  */
5
5
  export declare class NodeIdentityProcessor implements IBaseRouteProcessor {
6
- /**
7
- * The namespace supported by the processor.
8
- */
9
- static readonly NAMESPACE: string;
10
6
  /**
11
7
  * Runtime name for the class.
12
8
  */
@@ -4,10 +4,6 @@ import type { IStaticUserIdentityProcessorConstructorOptions } from "../models/I
4
4
  * Adds a static user identity to the request context.
5
5
  */
6
6
  export declare class StaticUserIdentityProcessor implements IBaseRouteProcessor {
7
- /**
8
- * The namespace supported by the processor.
9
- */
10
- static readonly NAMESPACE: string;
11
7
  /**
12
8
  * Runtime name for the class.
13
9
  */
@@ -4,10 +4,6 @@ import type { ILoggingProcessorConstructorOptions } from "../models/ILoggingProc
4
4
  * Process the REST request and log its information.
5
5
  */
6
6
  export declare class LoggingProcessor implements IBaseRouteProcessor {
7
- /**
8
- * The namespace supported by the processor.
9
- */
10
- static readonly NAMESPACE: string;
11
7
  /**
12
8
  * Runtime name for the class.
13
9
  */
@@ -3,10 +3,6 @@ import type { IMimeTypeProcessor } from "@twin.org/api-models";
3
3
  * Process the JSON-LD mime type.
4
4
  */
5
5
  export declare class JsonLdMimeTypeProcessor implements IMimeTypeProcessor {
6
- /**
7
- * The namespace supported by the processor.
8
- */
9
- static readonly NAMESPACE: string;
10
6
  /**
11
7
  * Runtime name for the class.
12
8
  */
@@ -3,10 +3,6 @@ import type { IMimeTypeProcessor } from "@twin.org/api-models";
3
3
  * Process the JWT mime type.
4
4
  */
5
5
  export declare class JwtMimeTypeProcessor implements IMimeTypeProcessor {
6
- /**
7
- * The namespace supported by the processor.
8
- */
9
- static readonly NAMESPACE: string;
10
6
  /**
11
7
  * Runtime name for the class.
12
8
  */
@@ -4,12 +4,11 @@ import type { ILoggingProcessorConfig } from "./ILoggingProcessorConfig";
4
4
  */
5
5
  export interface ILoggingProcessorConstructorOptions {
6
6
  /**
7
- * The type for the logging connector.
8
- * @default logging
7
+ * The type for the logging component.
9
8
  */
10
- loggingConnectorType?: string;
9
+ loggingComponentType?: string;
11
10
  /**
12
- *
11
+ * The configuration for the logging processor.
13
12
  */
14
13
  config?: ILoggingProcessorConfig;
15
14
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # @twin.org/api-processors - Changelog
2
2
 
3
+ ## [0.0.2-next.5](https://github.com/twinfoundation/api/compare/api-processors-v0.0.2-next.4...api-processors-v0.0.2-next.5) (2025-07-25)
4
+
5
+
6
+ ### Features
7
+
8
+ * add json-ld mime type processor and auth admin component ([8861791](https://github.com/twinfoundation/api/commit/88617916e23bfbca023dbae1976fe421983a02ff))
9
+ * add logging component type to request contexts ([210de1b](https://github.com/twinfoundation/api/commit/210de1b9e1c91079b59a2b90ddd57569668d647d))
10
+ * add socket id, connect and disconnect ([20b0d0e](https://github.com/twinfoundation/api/commit/20b0d0ec279cab46141fee09de2c4a7087cdce16))
11
+ * remove unused namespace ([08478f2](https://github.com/twinfoundation/api/commit/08478f27efda9beb0271fdb22f6972e918361965))
12
+ * update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
13
+ * use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @twin.org/api-models bumped from 0.0.2-next.4 to 0.0.2-next.5
21
+
22
+ ## [0.0.2-next.4](https://github.com/twinfoundation/api/compare/api-processors-v0.0.2-next.3...api-processors-v0.0.2-next.4) (2025-07-25)
23
+
24
+
25
+ ### Features
26
+
27
+ * add logging component type to request contexts ([210de1b](https://github.com/twinfoundation/api/commit/210de1b9e1c91079b59a2b90ddd57569668d647d))
28
+
29
+
30
+ ### Dependencies
31
+
32
+ * The following workspace dependencies were updated
33
+ * dependencies
34
+ * @twin.org/api-models bumped from 0.0.2-next.3 to 0.0.2-next.4
35
+
36
+ ## [0.0.2-next.3](https://github.com/twinfoundation/api/compare/api-processors-v0.0.2-next.2...api-processors-v0.0.2-next.3) (2025-07-24)
37
+
38
+
39
+ ### Features
40
+
41
+ * add socket id, connect and disconnect ([20b0d0e](https://github.com/twinfoundation/api/commit/20b0d0ec279cab46141fee09de2c4a7087cdce16))
42
+ * remove unused namespace ([08478f2](https://github.com/twinfoundation/api/commit/08478f27efda9beb0271fdb22f6972e918361965))
43
+
44
+
45
+ ### Dependencies
46
+
47
+ * The following workspace dependencies were updated
48
+ * dependencies
49
+ * @twin.org/api-models bumped from 0.0.2-next.2 to 0.0.2-next.3
50
+
3
51
  ## [0.0.2-next.2](https://github.com/twinfoundation/api/compare/api-processors-v0.0.2-next.1...api-processors-v0.0.2-next.2) (2025-07-17)
4
52
 
5
53
 
@@ -18,14 +18,6 @@ Process the JSON-LD mime type.
18
18
 
19
19
  ## Properties
20
20
 
21
- ### NAMESPACE
22
-
23
- > `readonly` `static` **NAMESPACE**: `string` = `"json-ld"`
24
-
25
- The namespace supported by the processor.
26
-
27
- ***
28
-
29
21
  ### CLASS\_NAME
30
22
 
31
23
  > `readonly` **CLASS\_NAME**: `string`
@@ -18,14 +18,6 @@ Process the JWT mime type.
18
18
 
19
19
  ## Properties
20
20
 
21
- ### NAMESPACE
22
-
23
- > `readonly` `static` **NAMESPACE**: `string` = `"jwt"`
24
-
25
- The namespace supported by the processor.
26
-
27
- ***
28
-
29
21
  ### CLASS\_NAME
30
22
 
31
23
  > `readonly` **CLASS\_NAME**: `string`
@@ -28,14 +28,6 @@ Options for the processor.
28
28
 
29
29
  ## Properties
30
30
 
31
- ### NAMESPACE
32
-
33
- > `readonly` `static` **NAMESPACE**: `string` = `"logging"`
34
-
35
- The namespace supported by the processor.
36
-
37
- ***
38
-
39
31
  ### CLASS\_NAME
40
32
 
41
33
  > `readonly` **CLASS\_NAME**: `string`
@@ -18,14 +18,6 @@ Adds a node identity to the request identity.
18
18
 
19
19
  ## Properties
20
20
 
21
- ### NAMESPACE
22
-
23
- > `readonly` `static` **NAMESPACE**: `string` = `"node-identity"`
24
-
25
- The namespace supported by the processor.
26
-
27
- ***
28
-
29
21
  ### CLASS\_NAME
30
22
 
31
23
  > `readonly` **CLASS\_NAME**: `string`
@@ -28,14 +28,6 @@ Options for the processor.
28
28
 
29
29
  ## Properties
30
30
 
31
- ### NAMESPACE
32
-
33
- > `readonly` `static` **NAMESPACE**: `string` = `"rest-route"`
34
-
35
- The namespace supported by the processor.
36
-
37
- ***
38
-
39
31
  ### CLASS\_NAME
40
32
 
41
33
  > `readonly` **CLASS\_NAME**: `string`
@@ -50,7 +42,7 @@ Runtime name for the class.
50
42
 
51
43
  ### process()
52
44
 
53
- > **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
45
+ > **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `loggingComponentType?`): `Promise`\<`void`\>
54
46
 
55
47
  Process the REST request for the specified route.
56
48
 
@@ -84,6 +76,12 @@ The identity context for the request.
84
76
 
85
77
  The state handed through the processors.
86
78
 
79
+ ##### loggingComponentType?
80
+
81
+ `string`
82
+
83
+ The logging component type for the request.
84
+
87
85
  #### Returns
88
86
 
89
87
  `Promise`\<`void`\>
@@ -28,14 +28,6 @@ Options for the processor.
28
28
 
29
29
  ## Properties
30
30
 
31
- ### NAMESPACE
32
-
33
- > `readonly` `static` **NAMESPACE**: `string` = `"socket-route"`
34
-
35
- The namespace supported by the processor.
36
-
37
- ***
38
-
39
31
  ### CLASS\_NAME
40
32
 
41
33
  > `readonly` **CLASS\_NAME**: `string`
@@ -48,9 +40,85 @@ Runtime name for the class.
48
40
 
49
41
  ## Methods
50
42
 
43
+ ### connected()
44
+
45
+ > **connected**(`request`, `route`, `loggingComponentType?`): `Promise`\<`void`\>
46
+
47
+ Process the connected event.
48
+
49
+ #### Parameters
50
+
51
+ ##### request
52
+
53
+ `ISocketServerRequest`
54
+
55
+ The server request object containing the socket id and other parameters.
56
+
57
+ ##### route
58
+
59
+ The route being requested, if a matching one was found.
60
+
61
+ `undefined` | `ISocketRoute`\<`any`, `any`\>
62
+
63
+ ##### loggingComponentType?
64
+
65
+ `string`
66
+
67
+ The logging component type for the request.
68
+
69
+ #### Returns
70
+
71
+ `Promise`\<`void`\>
72
+
73
+ Promise that resolves when the request is processed.
74
+
75
+ #### Implementation of
76
+
77
+ `ISocketRouteProcessor.connected`
78
+
79
+ ***
80
+
81
+ ### disconnected()
82
+
83
+ > **disconnected**(`request`, `route`, `loggingComponentType?`): `Promise`\<`void`\>
84
+
85
+ Process the disconnected event.
86
+
87
+ #### Parameters
88
+
89
+ ##### request
90
+
91
+ `ISocketServerRequest`
92
+
93
+ The server request object containing the socket id and other parameters.
94
+
95
+ ##### route
96
+
97
+ The route being requested, if a matching one was found.
98
+
99
+ `undefined` | `ISocketRoute`\<`any`, `any`\>
100
+
101
+ ##### loggingComponentType?
102
+
103
+ `string`
104
+
105
+ The logging component type for the request.
106
+
107
+ #### Returns
108
+
109
+ `Promise`\<`void`\>
110
+
111
+ Promise that resolves when the request is processed.
112
+
113
+ #### Implementation of
114
+
115
+ `ISocketRouteProcessor.disconnected`
116
+
117
+ ***
118
+
51
119
  ### process()
52
120
 
53
- > **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `responseEmitter`): `Promise`\<`void`\>
121
+ > **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`, `responseEmitter`, `loggingComponentType?`): `Promise`\<`void`\>
54
122
 
55
123
  Process the REST request for the specified route.
56
124
 
@@ -58,7 +126,7 @@ Process the REST request for the specified route.
58
126
 
59
127
  ##### request
60
128
 
61
- `IHttpServerRequest`
129
+ `ISocketServerRequest`
62
130
 
63
131
  The incoming request.
64
132
 
@@ -90,6 +158,12 @@ The state handed through the processors.
90
158
 
91
159
  The function to emit a response.
92
160
 
161
+ ##### loggingComponentType?
162
+
163
+ `string`
164
+
165
+ The logging component type for the request.
166
+
93
167
  #### Returns
94
168
 
95
169
  `Promise`\<`void`\>
@@ -28,14 +28,6 @@ Options for the processor.
28
28
 
29
29
  ## Properties
30
30
 
31
- ### NAMESPACE
32
-
33
- > `readonly` `static` **NAMESPACE**: `string` = `"static-user-identity"`
34
-
35
- The namespace supported by the processor.
36
-
37
- ***
38
-
39
31
  ### CLASS\_NAME
40
32
 
41
33
  > `readonly` **CLASS\_NAME**: `string`
@@ -4,20 +4,16 @@ Options for the LoggingProcessor constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### loggingConnectorType?
7
+ ### loggingComponentType?
8
8
 
9
- > `optional` **loggingConnectorType**: `string`
9
+ > `optional` **loggingComponentType**: `string`
10
10
 
11
- The type for the logging connector.
12
-
13
- #### Default
14
-
15
- ```ts
16
- logging
17
- ```
11
+ The type for the logging component.
18
12
 
19
13
  ***
20
14
 
21
15
  ### config?
22
16
 
23
17
  > `optional` **config**: [`ILoggingProcessorConfig`](ILoggingProcessorConfig.md)
18
+
19
+ The configuration for the logging processor.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-processors",
3
- "version": "0.0.2-next.2",
3
+ "version": "0.0.2-next.5",
4
4
  "description": "Route processors for use with API servers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-models": "0.0.2-next.2",
17
+ "@twin.org/api-models": "0.0.2-next.5",
18
18
  "@twin.org/core": "next",
19
19
  "@twin.org/logging-models": "next",
20
20
  "@twin.org/nameof": "next",