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

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": "Global Trade and Supply Chain - Test Endpoints",
5
+ "description": "REST API for Global Trade and Supply Chain - 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,126 @@
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
+ The options for the connector.
22
+
23
+ • **options.loggingConnectorType?**: `string`
24
+
25
+ The type of the logging connector to use, defaults to "logging".
26
+
27
+ #### Returns
28
+
29
+ [`LoggingService`](LoggingService.md)
30
+
31
+ ## Properties
32
+
33
+ ### CLASS\_NAME
34
+
35
+ > `readonly` **CLASS\_NAME**: `string`
36
+
37
+ Runtime name for the class.
38
+
39
+ #### Implementation of
40
+
41
+ `ILoggingComponent.CLASS_NAME`
42
+
43
+ ## Methods
44
+
45
+ ### log()
46
+
47
+ > **log**(`logEntry`): `Promise`\<`void`\>
48
+
49
+ Log an entry to the connector.
50
+
51
+ #### Parameters
52
+
53
+ • **logEntry**: `ILogEntry`
54
+
55
+ The entry to log.
56
+
57
+ #### Returns
58
+
59
+ `Promise`\<`void`\>
60
+
61
+ Nothing.
62
+
63
+ #### Implementation of
64
+
65
+ `ILoggingComponent.log`
66
+
67
+ ***
68
+
69
+ ### query()
70
+
71
+ > **query**(`level`?, `source`?, `timeStart`?, `timeEnd`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
72
+
73
+ Query the log entries.
74
+
75
+ #### Parameters
76
+
77
+ • **level?**: `LogLevel`
78
+
79
+ The level of the log entries.
80
+
81
+ • **source?**: `string`
82
+
83
+ The source of the log entries.
84
+
85
+ • **timeStart?**: `number`
86
+
87
+ The inclusive time as the start of the log entries.
88
+
89
+ • **timeEnd?**: `number`
90
+
91
+ The inclusive time as the end of the log entries.
92
+
93
+ • **cursor?**: `string`
94
+
95
+ The cursor to request the next page of entities.
96
+
97
+ • **pageSize?**: `number`
98
+
99
+ The maximum number of entities in a page.
100
+
101
+ #### Returns
102
+
103
+ `Promise`\<`object`\>
104
+
105
+ All the entities for the storage matching the conditions,
106
+ and a cursor which can be used to request more entities.
107
+
108
+ ##### entities
109
+
110
+ > **entities**: `ILogEntry`[]
111
+
112
+ The entities, which can be partial if a limited keys list was provided.
113
+
114
+ ##### cursor?
115
+
116
+ > `optional` **cursor**: `string`
117
+
118
+ An optional cursor, when defined can be used to call find to get more entities.
119
+
120
+ #### Throws
121
+
122
+ NotImplementedError if the implementation does not support retrieval.
123
+
124
+ #### Implementation of
125
+
126
+ `ILoggingComponent.query`
@@ -0,0 +1,21 @@
1
+ # Function: generateRestRoutesLogging()
2
+
3
+ > **generateRestRoutesLogging**(`baseRouteName`, `componentName`): `IRestRoute`[]
4
+
5
+ The REST routes for logging.
6
+
7
+ ## Parameters
8
+
9
+ • **baseRouteName**: `string`
10
+
11
+ Prefix to prepend to the paths.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes stored in the ComponentFactory.
16
+
17
+ ## Returns
18
+
19
+ `IRestRoute`[]
20
+
21
+ The generated routes.
@@ -0,0 +1,25 @@
1
+ # Function: loggingCreate()
2
+
3
+ > **loggingCreate**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ Create a new log entry.
6
+
7
+ ## Parameters
8
+
9
+ • **httpRequestContext**: `IHttpRequestContext`
10
+
11
+ The request context for the API.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes.
16
+
17
+ • **request**: `ILoggingCreateRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`INoContentResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
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**: `IHttpRequestContext`
10
+
11
+ The request context for the API.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes.
16
+
17
+ • **request**: `ILoggingListRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`ILoggingListResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,16 @@
1
+ # @twin.org/logging-service
2
+
3
+ ## Classes
4
+
5
+ - [LoggingService](classes/LoggingService.md)
6
+
7
+ ## Variables
8
+
9
+ - [tagsLogging](variables/tagsLogging.md)
10
+ - [restEntryPoints](variables/restEntryPoints.md)
11
+
12
+ ## Functions
13
+
14
+ - [generateRestRoutesLogging](functions/generateRestRoutesLogging.md)
15
+ - [loggingCreate](functions/loggingCreate.md)
16
+ - [loggingList](functions/loggingList.md)
@@ -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
+ {}