@twin.org/logging-rest-client 0.0.3-next.1 → 0.0.3-next.3
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/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggingRestClient.js","sourceRoot":"","sources":["../../src/loggingRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAWhD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAAc;IACpD;;OAEG;IACI,MAAM,CAAU,UAAU,uBAAuC;IAExE;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,CAAC,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IACxD,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,iBAAiB,CAAC,UAAU,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,GAAG,CAAC,QAAmB;QACnC,MAAM,CAAC,MAAM,CAAY,iBAAiB,CAAC,UAAU,cAAoB,QAAQ,CAAC,CAAC;QAEnF,MAAM,IAAI,CAAC,KAAK,CAAqC,GAAG,EAAE,MAAM,EAAE;YACjE,IAAI,EAAE,QAAQ;SACd,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACI,KAAK,CAAC,KAAK,CACjB,KAAgB,EAChB,MAAe,EACf,SAAkB,EAClB,OAAgB,EAChB,MAAe,EACf,KAAc;QAWd,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAA4C,GAAG,EAAE,KAAK,EAAE;YACxF,KAAK,EAAE;gBACN,KAAK;gBACL,MAAM;gBACN,SAAS;
|
|
1
|
+
{"version":3,"file":"loggingRestClient.js","sourceRoot":"","sources":["../../src/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// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig, IOkResponse } from \"@twin.org/api-models\";\nimport { Coerce, Guards } from \"@twin.org/core\";\nimport type {\n\tILogEntry,\n\tILoggingComponent,\n\tILoggingCreateRequest,\n\tILoggingListRequest,\n\tILoggingListResponse,\n\tLogLevel\n} from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Client for performing logging through to REST endpoints.\n */\nexport class LoggingRestClient extends BaseRestClient implements ILoggingComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<LoggingRestClient>();\n\n\t/**\n\t * Create a new instance of LoggingRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(LoggingRestClient.CLASS_NAME, config, \"logging\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn LoggingRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Log an entry to the connector.\n\t * @param logEntry The entry to log.\n\t * @returns Nothing.\n\t */\n\tpublic async log(logEntry: ILogEntry): Promise<void> {\n\t\tGuards.object<ILogEntry>(LoggingRestClient.CLASS_NAME, nameof(logEntry), logEntry);\n\n\t\tawait this.fetch<ILoggingCreateRequest, IOkResponse>(\"/\", \"POST\", {\n\t\t\tbody: logEntry\n\t\t});\n\t}\n\n\t/**\n\t * Query the log entries.\n\t * @param level The level of the log entries.\n\t * @param source The source of the log entries.\n\t * @param timeStart The inclusive time as the start of the log entries.\n\t * @param timeEnd The inclusive time as the end of the log entries.\n\t * @param cursor The cursor to request the next chunk of entities.\n\t * @param limit Limit the number of entities to return.\n\t * @returns All the entities for the storage matching the conditions,\n\t * and a cursor which can be used to request more entities.\n\t */\n\tpublic async query(\n\t\tlevel?: LogLevel,\n\t\tsource?: string,\n\t\ttimeStart?: number,\n\t\ttimeEnd?: number,\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The entities, which can be partial if a limited keys list was provided.\n\t\t */\n\t\tentities: ILogEntry[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\tconst response = await this.fetch<ILoggingListRequest, ILoggingListResponse>(\"/\", \"GET\", {\n\t\t\tquery: {\n\t\t\t\tlevel,\n\t\t\t\tsource,\n\t\t\t\ttimeStart: Coerce.string(timeStart),\n\t\t\t\ttimeEnd: Coerce.string(timeEnd),\n\t\t\t\tcursor,\n\t\t\t\tlimit: Coerce.string(limit)\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n}\n"]}
|
package/docs/changelog.md
CHANGED
|
@@ -1,16 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.0.3-next.
|
|
3
|
+
## [0.0.3-next.3](https://github.com/iotaledger/twin-logging/compare/logging-rest-client-v0.0.3-next.2...logging-rest-client-v0.0.3-next.3) (2026-05-11)
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
### Features
|
|
7
7
|
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
8
|
+
* typescript 6 update ([cb28b05](https://github.com/iotaledger/twin-logging/commit/cb28b0557595d5ba9b25fab2d9f1222590787f5a))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/logging-models bumped from 0.0.3-next.2 to 0.0.3-next.3
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.2](https://github.com/iotaledger/twin-logging/compare/logging-rest-client-v0.0.3-next.1...logging-rest-client-v0.0.3-next.2) (2026-03-02)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* api data types ([8d37cab](https://github.com/iotaledger/twin-logging/commit/8d37cab7ec759f079b6480bcc27d739357dbc392))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/logging-models bumped from 0.0.3-next.1 to 0.0.3-next.2
|
|
30
|
+
|
|
31
|
+
## [0.0.3-next.1](https://github.com/iotaledger/twin-logging/compare/logging-rest-client-v0.0.3-next.0...logging-rest-client-v0.0.3-next.1) (2025-11-10)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* add context id features ([#33](https://github.com/iotaledger/twin-logging/issues/33)) ([38e982c](https://github.com/iotaledger/twin-logging/commit/38e982c9f009019fc02b67d919444b52657c9021))
|
|
37
|
+
* add validate-locales ([df53f13](https://github.com/iotaledger/twin-logging/commit/df53f1331394f2f9333e91e4995a88dded90e484))
|
|
38
|
+
* eslint migration to flat config ([1f9fdde](https://github.com/iotaledger/twin-logging/commit/1f9fddedfdcce9942afed431d9460a0f22092744))
|
|
39
|
+
* update dependencies ([976fc06](https://github.com/iotaledger/twin-logging/commit/976fc06976c4899769486b7cb2e827c407d7fc89))
|
|
40
|
+
* update framework core ([aac823c](https://github.com/iotaledger/twin-logging/commit/aac823c2ead88843618b8a82b308d5a793411764))
|
|
41
|
+
* use shared store mechanism ([#20](https://github.com/iotaledger/twin-logging/issues/20)) ([bbacd31](https://github.com/iotaledger/twin-logging/commit/bbacd31af991d82d84294ad432a40830692880ca))
|
|
14
42
|
|
|
15
43
|
|
|
16
44
|
### Dependencies
|
|
@@ -19,12 +47,12 @@
|
|
|
19
47
|
* dependencies
|
|
20
48
|
* @twin.org/logging-models bumped from 0.0.3-next.0 to 0.0.3-next.1
|
|
21
49
|
|
|
22
|
-
## [0.0.2-next.3](https://github.com/
|
|
50
|
+
## [0.0.2-next.3](https://github.com/iotaledger/twin-logging/compare/logging-rest-client-v0.0.2-next.2...logging-rest-client-v0.0.2-next.3) (2025-10-09)
|
|
23
51
|
|
|
24
52
|
|
|
25
53
|
### Features
|
|
26
54
|
|
|
27
|
-
* add validate-locales ([df53f13](https://github.com/
|
|
55
|
+
* add validate-locales ([df53f13](https://github.com/iotaledger/twin-logging/commit/df53f1331394f2f9333e91e4995a88dded90e484))
|
|
28
56
|
|
|
29
57
|
|
|
30
58
|
### Dependencies
|
|
@@ -33,12 +61,12 @@
|
|
|
33
61
|
* dependencies
|
|
34
62
|
* @twin.org/logging-models bumped from 0.0.2-next.2 to 0.0.2-next.3
|
|
35
63
|
|
|
36
|
-
## [0.0.2-next.2](https://github.com/
|
|
64
|
+
## [0.0.2-next.2](https://github.com/iotaledger/twin-logging/compare/logging-rest-client-v0.0.2-next.1...logging-rest-client-v0.0.2-next.2) (2025-08-29)
|
|
37
65
|
|
|
38
66
|
|
|
39
67
|
### Features
|
|
40
68
|
|
|
41
|
-
* eslint migration to flat config ([1f9fdde](https://github.com/
|
|
69
|
+
* eslint migration to flat config ([1f9fdde](https://github.com/iotaledger/twin-logging/commit/1f9fddedfdcce9942afed431d9460a0f22092744))
|
|
42
70
|
|
|
43
71
|
|
|
44
72
|
### Dependencies
|
|
@@ -47,14 +75,14 @@
|
|
|
47
75
|
* dependencies
|
|
48
76
|
* @twin.org/logging-models bumped from 0.0.2-next.1 to 0.0.2-next.2
|
|
49
77
|
|
|
50
|
-
## [0.0.2-next.1](https://github.com/
|
|
78
|
+
## [0.0.2-next.1](https://github.com/iotaledger/twin-logging/compare/logging-rest-client-v0.0.2-next.0...logging-rest-client-v0.0.2-next.1) (2025-08-19)
|
|
51
79
|
|
|
52
80
|
|
|
53
81
|
### Features
|
|
54
82
|
|
|
55
|
-
* update dependencies ([976fc06](https://github.com/
|
|
56
|
-
* update framework core ([aac823c](https://github.com/
|
|
57
|
-
* use shared store mechanism ([#20](https://github.com/
|
|
83
|
+
* update dependencies ([976fc06](https://github.com/iotaledger/twin-logging/commit/976fc06976c4899769486b7cb2e827c407d7fc89))
|
|
84
|
+
* update framework core ([aac823c](https://github.com/iotaledger/twin-logging/commit/aac823c2ead88843618b8a82b308d5a793411764))
|
|
85
|
+
* use shared store mechanism ([#20](https://github.com/iotaledger/twin-logging/issues/20)) ([bbacd31](https://github.com/iotaledger/twin-logging/commit/bbacd31af991d82d84294ad432a40830692880ca))
|
|
58
86
|
|
|
59
87
|
|
|
60
88
|
### Dependencies
|
|
@@ -68,7 +96,7 @@
|
|
|
68
96
|
|
|
69
97
|
### Features
|
|
70
98
|
|
|
71
|
-
* release to production ([3458161](https://github.com/
|
|
99
|
+
* release to production ([3458161](https://github.com/iotaledger/twin-logging/commit/3458161b4bb530f86e4d1fe06123d885cdcb114d))
|
|
72
100
|
|
|
73
101
|
|
|
74
102
|
### Dependencies
|
|
@@ -77,7 +105,7 @@
|
|
|
77
105
|
* dependencies
|
|
78
106
|
* @twin.org/logging-models bumped from ^0.0.0 to ^0.0.1
|
|
79
107
|
|
|
80
|
-
## [0.0.1-next.16](https://github.com/
|
|
108
|
+
## [0.0.1-next.16](https://github.com/iotaledger/twin-logging/compare/logging-rest-client-v0.0.1-next.15...logging-rest-client-v0.0.1-next.16) (2025-06-20)
|
|
81
109
|
|
|
82
110
|
|
|
83
111
|
### Miscellaneous Chores
|
|
@@ -91,12 +119,12 @@
|
|
|
91
119
|
* dependencies
|
|
92
120
|
* @twin.org/logging-models bumped from 0.0.1-next.15 to 0.0.1-next.16
|
|
93
121
|
|
|
94
|
-
## [0.0.1-next.15](https://github.com/
|
|
122
|
+
## [0.0.1-next.15](https://github.com/iotaledger/twin-logging/compare/logging-rest-client-v0.0.1-next.14...logging-rest-client-v0.0.1-next.15) (2025-06-12)
|
|
95
123
|
|
|
96
124
|
|
|
97
125
|
### Features
|
|
98
126
|
|
|
99
|
-
* update dependencies ([976fc06](https://github.com/
|
|
127
|
+
* update dependencies ([976fc06](https://github.com/iotaledger/twin-logging/commit/976fc06976c4899769486b7cb2e827c407d7fc89))
|
|
100
128
|
|
|
101
129
|
|
|
102
130
|
### Dependencies
|
|
@@ -105,12 +133,12 @@
|
|
|
105
133
|
* dependencies
|
|
106
134
|
* @twin.org/logging-models bumped from 0.0.1-next.14 to 0.0.1-next.15
|
|
107
135
|
|
|
108
|
-
## [0.0.1-next.14](https://github.com/
|
|
136
|
+
## [0.0.1-next.14](https://github.com/iotaledger/twin-logging/compare/logging-rest-client-v0.0.1-next.13...logging-rest-client-v0.0.1-next.14) (2025-04-17)
|
|
109
137
|
|
|
110
138
|
|
|
111
139
|
### Features
|
|
112
140
|
|
|
113
|
-
* use shared store mechanism ([#20](https://github.com/
|
|
141
|
+
* use shared store mechanism ([#20](https://github.com/iotaledger/twin-logging/issues/20)) ([bbacd31](https://github.com/iotaledger/twin-logging/commit/bbacd31af991d82d84294ad432a40830692880ca))
|
|
114
142
|
|
|
115
143
|
|
|
116
144
|
### Dependencies
|
|
@@ -119,7 +147,7 @@
|
|
|
119
147
|
* dependencies
|
|
120
148
|
* @twin.org/logging-models bumped from 0.0.1-next.13 to 0.0.1-next.14
|
|
121
149
|
|
|
122
|
-
## [0.0.1-next.13](https://github.com/
|
|
150
|
+
## [0.0.1-next.13](https://github.com/iotaledger/twin-logging/compare/logging-rest-client-v0.0.1-next.12...logging-rest-client-v0.0.1-next.13) (2025-03-28)
|
|
123
151
|
|
|
124
152
|
|
|
125
153
|
### Miscellaneous Chores
|
package/docs/examples.md
CHANGED
|
@@ -1 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Logging Rest Client Examples
|
|
2
|
+
|
|
3
|
+
These snippets show how to send entries to an HTTP endpoint and query filtered log data for operational dashboards.
|
|
4
|
+
|
|
5
|
+
## LoggingRestClient
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { LoggingRestClient } from '@twin.org/logging-rest-client';
|
|
9
|
+
|
|
10
|
+
const client = new LoggingRestClient({
|
|
11
|
+
endpoint: 'https://api.example.com'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const className = client.className();
|
|
15
|
+
|
|
16
|
+
await client.log({
|
|
17
|
+
level: 'info',
|
|
18
|
+
source: 'payment-service',
|
|
19
|
+
message: 'authorisationAccepted',
|
|
20
|
+
data: {
|
|
21
|
+
paymentId: 'pay-1024',
|
|
22
|
+
amount: 1999,
|
|
23
|
+
currency: 'GBP'
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { LoggingRestClient } from '@twin.org/logging-rest-client';
|
|
30
|
+
|
|
31
|
+
const client = new LoggingRestClient({
|
|
32
|
+
endpoint: 'https://api.example.com'
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const queryResult = await client.query(
|
|
36
|
+
'error',
|
|
37
|
+
'payment-service',
|
|
38
|
+
Date.now() - 60 * 60 * 1000,
|
|
39
|
+
Date.now(),
|
|
40
|
+
'cursor-13',
|
|
41
|
+
50
|
|
42
|
+
);
|
|
43
|
+
```
|
|
@@ -36,7 +36,7 @@ The configuration for the client.
|
|
|
36
36
|
|
|
37
37
|
## Properties
|
|
38
38
|
|
|
39
|
-
### CLASS\_NAME
|
|
39
|
+
### CLASS\_NAME {#class_name}
|
|
40
40
|
|
|
41
41
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ Runtime name for the class.
|
|
|
44
44
|
|
|
45
45
|
## Methods
|
|
46
46
|
|
|
47
|
-
### className()
|
|
47
|
+
### className() {#classname}
|
|
48
48
|
|
|
49
49
|
> **className**(): `string`
|
|
50
50
|
|
|
@@ -62,7 +62,7 @@ The class name of the component.
|
|
|
62
62
|
|
|
63
63
|
***
|
|
64
64
|
|
|
65
|
-
### log()
|
|
65
|
+
### log() {#log}
|
|
66
66
|
|
|
67
67
|
> **log**(`logEntry`): `Promise`\<`void`\>
|
|
68
68
|
|
|
@@ -88,7 +88,7 @@ Nothing.
|
|
|
88
88
|
|
|
89
89
|
***
|
|
90
90
|
|
|
91
|
-
### query()
|
|
91
|
+
### query() {#query}
|
|
92
92
|
|
|
93
93
|
> **query**(`level?`, `source?`, `timeStart?`, `timeEnd?`, `cursor?`, `limit?`): `Promise`\<\{ `entities`: `ILogEntry`[]; `cursor?`: `string`; \}\>
|
|
94
94
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/logging-rest-client",
|
|
3
|
-
"version": "0.0.3-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3-next.3",
|
|
4
|
+
"description": "Provides a client for interacting with logging service endpoints from applications and services.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/iotaledger/logging.git",
|
|
8
8
|
"directory": "packages/logging-rest-client"
|
|
9
9
|
},
|
|
10
10
|
"author": "martyn.janes@iota.org",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@twin.org/api-models": "next",
|
|
19
19
|
"@twin.org/core": "next",
|
|
20
20
|
"@twin.org/entity": "next",
|
|
21
|
-
"@twin.org/logging-models": "0.0.3-next.
|
|
21
|
+
"@twin.org/logging-models": "0.0.3-next.3",
|
|
22
22
|
"@twin.org/nameof": "next"
|
|
23
23
|
},
|
|
24
24
|
"main": "./dist/es/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"logging"
|
|
47
47
|
],
|
|
48
48
|
"bugs": {
|
|
49
|
-
"url": "git+https://github.com/
|
|
49
|
+
"url": "git+https://github.com/iotaledger/logging/issues"
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://twindev.org"
|
|
52
52
|
}
|