@twin.org/logging-service 0.0.1-next.10

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.
@@ -0,0 +1,403 @@
1
+ {
2
+ "openapi": "3.1.0",
3
+ "info": {
4
+ "title": "TWIN - Test Endpoints",
5
+ "description": "REST API for TWIN - Test Endpoints.",
6
+ "version": "1.0.0",
7
+ "license": {
8
+ "name": "Apache 2.0 License",
9
+ "url": "https://opensource.org/licenses/Apache-2.0"
10
+ }
11
+ },
12
+ "servers": [
13
+ {
14
+ "url": "https://localhost"
15
+ }
16
+ ],
17
+ "tags": [
18
+ {
19
+ "name": "Logging",
20
+ "description": "Endpoints which are modelled to access a logging contract."
21
+ }
22
+ ],
23
+ "paths": {
24
+ "/logging": {
25
+ "post": {
26
+ "operationId": "loggingEntryCreate",
27
+ "summary": "Create a log entry",
28
+ "tags": [
29
+ "Logging"
30
+ ],
31
+ "security": [
32
+ {
33
+ "jwtBearerAuthScheme": []
34
+ }
35
+ ],
36
+ "requestBody": {
37
+ "description": "Create a new log entry.",
38
+ "required": true,
39
+ "content": {
40
+ "application/json": {
41
+ "schema": {
42
+ "$ref": "#/components/schemas/LogEntry"
43
+ },
44
+ "examples": {
45
+ "loggingEntryCreateInfoExample": {
46
+ "value": {
47
+ "level": "info",
48
+ "message": "This is an information message",
49
+ "source": "source",
50
+ "ts": 1715252922273
51
+ }
52
+ },
53
+ "loggingEntryCreateErrorExample": {
54
+ "value": {
55
+ "level": "info",
56
+ "message": "This is an error message",
57
+ "source": "source",
58
+ "ts": 1715252922273,
59
+ "error": {
60
+ "name": "GeneralError",
61
+ "message": "component.error",
62
+ "properties": {
63
+ "foo": "bar"
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ },
72
+ "responses": {
73
+ "204": {
74
+ "description": "The rest request ended in success with no data."
75
+ },
76
+ "400": {
77
+ "description": "The server cannot process the request, see the content for more details.",
78
+ "content": {
79
+ "application/json": {
80
+ "schema": {
81
+ "$ref": "#/components/schemas/Error"
82
+ },
83
+ "examples": {
84
+ "exampleResponse": {
85
+ "value": {
86
+ "name": "GeneralError",
87
+ "message": "component.error",
88
+ "properties": {
89
+ "foo": "bar"
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ },
97
+ "401": {
98
+ "description": "You are not authorized to use the API or no credentials were supplied, see the content for more details.",
99
+ "content": {
100
+ "application/json": {
101
+ "schema": {
102
+ "$ref": "#/components/schemas/Error"
103
+ },
104
+ "examples": {
105
+ "exampleResponse": {
106
+ "value": {
107
+ "name": "UnauthorizedError",
108
+ "message": "component.error"
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ },
115
+ "500": {
116
+ "description": "The server has encountered a situation it does not know how to handle, see the content for more details.",
117
+ "content": {
118
+ "application/json": {
119
+ "schema": {
120
+ "$ref": "#/components/schemas/Error"
121
+ },
122
+ "examples": {
123
+ "exampleResponse": {
124
+ "value": {
125
+ "name": "InternalServerError",
126
+ "message": "component.error"
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ },
135
+ "get": {
136
+ "operationId": "loggingListEntries",
137
+ "summary": "Get a list of the log entries",
138
+ "tags": [
139
+ "Logging"
140
+ ],
141
+ "parameters": [
142
+ {
143
+ "name": "level",
144
+ "description": "The level of the log entries to retrieve.",
145
+ "in": "query",
146
+ "required": false,
147
+ "schema": {
148
+ "$ref": "#/components/schemas/LogLevel"
149
+ },
150
+ "example": "info"
151
+ },
152
+ {
153
+ "name": "source",
154
+ "description": "The source of the log entries to retrieve.",
155
+ "in": "query",
156
+ "required": false,
157
+ "schema": {
158
+ "type": "string"
159
+ }
160
+ },
161
+ {
162
+ "name": "timeStart",
163
+ "description": "The start time of the metrics to retrieve as a timestamp in ms.",
164
+ "in": "query",
165
+ "required": false,
166
+ "schema": {
167
+ "type": "number"
168
+ }
169
+ },
170
+ {
171
+ "name": "timeEnd",
172
+ "description": "The end time of the metrics to retrieve as a timestamp in ms.",
173
+ "in": "query",
174
+ "required": false,
175
+ "schema": {
176
+ "type": "number"
177
+ }
178
+ },
179
+ {
180
+ "name": "cursor",
181
+ "description": "The optional cursor to get next chunk.",
182
+ "in": "query",
183
+ "required": false,
184
+ "schema": {
185
+ "type": "string"
186
+ }
187
+ },
188
+ {
189
+ "name": "pageSize",
190
+ "description": "The maximum number of entities in a page.",
191
+ "in": "query",
192
+ "required": false,
193
+ "schema": {
194
+ "type": "number"
195
+ }
196
+ }
197
+ ],
198
+ "security": [
199
+ {
200
+ "jwtBearerAuthScheme": []
201
+ }
202
+ ],
203
+ "responses": {
204
+ "200": {
205
+ "description": "Response for log entry list request.",
206
+ "content": {
207
+ "application/json": {
208
+ "schema": {
209
+ "$ref": "#/components/schemas/LoggingListResponse"
210
+ },
211
+ "examples": {
212
+ "listResponseExample": {
213
+ "value": {
214
+ "entities": [
215
+ {
216
+ "level": "info",
217
+ "message": "This is an information message",
218
+ "source": "source",
219
+ "ts": 1715252922273
220
+ }
221
+ ],
222
+ "cursor": "1"
223
+ }
224
+ }
225
+ }
226
+ }
227
+ }
228
+ },
229
+ "400": {
230
+ "description": "The server cannot process the request, see the content for more details.",
231
+ "content": {
232
+ "application/json": {
233
+ "schema": {
234
+ "$ref": "#/components/schemas/Error"
235
+ },
236
+ "examples": {
237
+ "exampleResponse": {
238
+ "value": {
239
+ "name": "GeneralError",
240
+ "message": "component.error",
241
+ "properties": {
242
+ "foo": "bar"
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ }
249
+ },
250
+ "401": {
251
+ "description": "You are not authorized to use the API or no credentials were supplied, see the content for more details.",
252
+ "content": {
253
+ "application/json": {
254
+ "schema": {
255
+ "$ref": "#/components/schemas/Error"
256
+ },
257
+ "examples": {
258
+ "exampleResponse": {
259
+ "value": {
260
+ "name": "UnauthorizedError",
261
+ "message": "component.error"
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }
267
+ },
268
+ "500": {
269
+ "description": "The server has encountered a situation it does not know how to handle, see the content for more details.",
270
+ "content": {
271
+ "application/json": {
272
+ "schema": {
273
+ "$ref": "#/components/schemas/Error"
274
+ },
275
+ "examples": {
276
+ "exampleResponse": {
277
+ "value": {
278
+ "name": "InternalServerError",
279
+ "message": "component.error"
280
+ }
281
+ }
282
+ }
283
+ }
284
+ }
285
+ }
286
+ }
287
+ }
288
+ }
289
+ },
290
+ "components": {
291
+ "schemas": {
292
+ "Error": {
293
+ "type": "object",
294
+ "properties": {
295
+ "name": {
296
+ "type": "string",
297
+ "description": "The name for the error."
298
+ },
299
+ "message": {
300
+ "type": "string",
301
+ "description": "The message for the error."
302
+ },
303
+ "source": {
304
+ "type": "string",
305
+ "description": "The source of the error."
306
+ },
307
+ "properties": {
308
+ "type": "object",
309
+ "additionalProperties": {},
310
+ "description": "Any additional information for the error."
311
+ },
312
+ "stack": {
313
+ "type": "string",
314
+ "description": "The stack trace for the error."
315
+ },
316
+ "inner": {
317
+ "$ref": "#/components/schemas/Error"
318
+ }
319
+ },
320
+ "required": [
321
+ "name",
322
+ "message"
323
+ ],
324
+ "additionalProperties": false,
325
+ "description": "Model to describe serialized error."
326
+ },
327
+ "LogEntry": {
328
+ "type": "object",
329
+ "properties": {
330
+ "level": {
331
+ "$ref": "#/components/schemas/LogLevel"
332
+ },
333
+ "source": {
334
+ "type": "string",
335
+ "description": "The source of the log entry."
336
+ },
337
+ "ts": {
338
+ "type": "number",
339
+ "description": "The timestamp of the log entry, if left blank will be populated by the connector."
340
+ },
341
+ "message": {
342
+ "type": "string",
343
+ "description": "The message."
344
+ },
345
+ "error": {
346
+ "$ref": "#/components/schemas/Error"
347
+ },
348
+ "data": {
349
+ "type": "object",
350
+ "additionalProperties": {},
351
+ "description": "Optional data for the message."
352
+ }
353
+ },
354
+ "required": [
355
+ "level",
356
+ "source",
357
+ "message"
358
+ ],
359
+ "additionalProperties": false,
360
+ "description": "Interface describing a log entry."
361
+ },
362
+ "LogLevel": {
363
+ "type": "string",
364
+ "enum": [
365
+ "info",
366
+ "error",
367
+ "warn",
368
+ "trace",
369
+ "debug"
370
+ ],
371
+ "description": "Log level."
372
+ },
373
+ "LoggingListResponse": {
374
+ "type": "object",
375
+ "properties": {
376
+ "entities": {
377
+ "type": "array",
378
+ "items": {
379
+ "$ref": "#/components/schemas/LogEntry"
380
+ },
381
+ "description": "The entities, which can be partial if a limited keys list was provided."
382
+ },
383
+ "cursor": {
384
+ "type": "string",
385
+ "description": "An optional cursor, when defined can be used to call find to get more entities."
386
+ }
387
+ },
388
+ "required": [
389
+ "entities"
390
+ ],
391
+ "additionalProperties": false,
392
+ "description": "The response payload."
393
+ }
394
+ },
395
+ "securitySchemes": {
396
+ "jwtBearerAuthScheme": {
397
+ "type": "http",
398
+ "scheme": "bearer",
399
+ "bearerFormat": "JWT"
400
+ }
401
+ }
402
+ }
403
+ }
@@ -0,0 +1,134 @@
1
+ # Class: LoggingService
2
+
3
+ Service for performing logging operations to a connector.
4
+
5
+ ## Implements
6
+
7
+ - `ILoggingComponent`
8
+
9
+ ## Constructors
10
+
11
+ ### new LoggingService()
12
+
13
+ > **new LoggingService**(`options`?): [`LoggingService`](LoggingService.md)
14
+
15
+ Create a new instance of LoggingService.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`ILoggingServiceConstructorOptions`](../interfaces/ILoggingServiceConstructorOptions.md)
22
+
23
+ The options for the connector.
24
+
25
+ #### Returns
26
+
27
+ [`LoggingService`](LoggingService.md)
28
+
29
+ ## Properties
30
+
31
+ ### NAMESPACE
32
+
33
+ > `readonly` `static` **NAMESPACE**: `string` = `"logging"`
34
+
35
+ The namespace for the logging component.
36
+
37
+ ***
38
+
39
+ ### CLASS\_NAME
40
+
41
+ > `readonly` **CLASS\_NAME**: `string`
42
+
43
+ Runtime name for the class.
44
+
45
+ #### Implementation of
46
+
47
+ `ILoggingComponent.CLASS_NAME`
48
+
49
+ ## Methods
50
+
51
+ ### log()
52
+
53
+ > **log**(`logEntry`): `Promise`\<`void`\>
54
+
55
+ Log an entry to the connector.
56
+
57
+ #### Parameters
58
+
59
+ ##### logEntry
60
+
61
+ `ILogEntry`
62
+
63
+ The entry to log.
64
+
65
+ #### Returns
66
+
67
+ `Promise`\<`void`\>
68
+
69
+ Nothing.
70
+
71
+ #### Implementation of
72
+
73
+ `ILoggingComponent.log`
74
+
75
+ ***
76
+
77
+ ### query()
78
+
79
+ > **query**(`level`?, `source`?, `timeStart`?, `timeEnd`?, `cursor`?, `pageSize`?): `Promise`\<\{ `entities`: `ILogEntry`[]; `cursor`: `string`; \}\>
80
+
81
+ Query the log entries.
82
+
83
+ #### Parameters
84
+
85
+ ##### level?
86
+
87
+ `LogLevel`
88
+
89
+ The level of the log entries.
90
+
91
+ ##### source?
92
+
93
+ `string`
94
+
95
+ The source of the log entries.
96
+
97
+ ##### timeStart?
98
+
99
+ `number`
100
+
101
+ The inclusive time as the start of the log entries.
102
+
103
+ ##### timeEnd?
104
+
105
+ `number`
106
+
107
+ The inclusive time as the end of the log entries.
108
+
109
+ ##### cursor?
110
+
111
+ `string`
112
+
113
+ The cursor to request the next page of entities.
114
+
115
+ ##### pageSize?
116
+
117
+ `number`
118
+
119
+ The maximum number of entities in a page.
120
+
121
+ #### Returns
122
+
123
+ `Promise`\<\{ `entities`: `ILogEntry`[]; `cursor`: `string`; \}\>
124
+
125
+ All the entities for the storage matching the conditions,
126
+ and a cursor which can be used to request more entities.
127
+
128
+ #### Throws
129
+
130
+ NotImplementedError if the implementation does not support retrieval.
131
+
132
+ #### Implementation of
133
+
134
+ `ILoggingComponent.query`
@@ -0,0 +1,25 @@
1
+ # Function: generateRestRoutesLogging()
2
+
3
+ > **generateRestRoutesLogging**(`baseRouteName`, `componentName`): `IRestRoute`[]
4
+
5
+ The REST routes for logging.
6
+
7
+ ## Parameters
8
+
9
+ ### baseRouteName
10
+
11
+ `string`
12
+
13
+ Prefix to prepend to the paths.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes stored in the ComponentFactory.
20
+
21
+ ## Returns
22
+
23
+ `IRestRoute`[]
24
+
25
+ The generated routes.
@@ -0,0 +1,31 @@
1
+ # Function: loggingCreate()
2
+
3
+ > **loggingCreate**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ Create a new log entry.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `ILoggingCreateRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`INoContentResponse`\>
30
+
31
+ The response object with additional http response properties.
@@ -0,0 +1,31 @@
1
+ # Function: loggingList()
2
+
3
+ > **loggingList**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ILoggingListResponse`\>
4
+
5
+ Get a list of the logging entries.
6
+
7
+ ## Parameters
8
+
9
+ ### httpRequestContext
10
+
11
+ `IHttpRequestContext`
12
+
13
+ The request context for the API.
14
+
15
+ ### componentName
16
+
17
+ `string`
18
+
19
+ The name of the component to use in the routes.
20
+
21
+ ### request
22
+
23
+ `ILoggingListRequest`
24
+
25
+ The request.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`ILoggingListResponse`\>
30
+
31
+ The response object with additional http response properties.
@@ -0,0 +1,20 @@
1
+ # @twin.org/logging-service
2
+
3
+ ## Classes
4
+
5
+ - [LoggingService](classes/LoggingService.md)
6
+
7
+ ## Interfaces
8
+
9
+ - [ILoggingServiceConstructorOptions](interfaces/ILoggingServiceConstructorOptions.md)
10
+
11
+ ## Variables
12
+
13
+ - [tagsLogging](variables/tagsLogging.md)
14
+ - [restEntryPoints](variables/restEntryPoints.md)
15
+
16
+ ## Functions
17
+
18
+ - [generateRestRoutesLogging](functions/generateRestRoutesLogging.md)
19
+ - [loggingCreate](functions/loggingCreate.md)
20
+ - [loggingList](functions/loggingList.md)
@@ -0,0 +1,17 @@
1
+ # Interface: ILoggingServiceConstructorOptions
2
+
3
+ Options for the logging service constructor.
4
+
5
+ ## Properties
6
+
7
+ ### loggingConnectorType?
8
+
9
+ > `optional` **loggingConnectorType**: `string`
10
+
11
+ The type of the logging connector to use.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ logging
17
+ ```
@@ -0,0 +1,3 @@
1
+ # Variable: restEntryPoints
2
+
3
+ > `const` **restEntryPoints**: `IRestRouteEntryPoint`[]
@@ -0,0 +1,5 @@
1
+ # Variable: tagsLogging
2
+
3
+ > `const` **tagsLogging**: `ITag`[]
4
+
5
+ The tag to associate with the routes.
@@ -0,0 +1 @@
1
+ {}