@twin.org/logging-rest-client 0.0.2-next.3 → 0.0.3-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.
- package/dist/es/index.js +4 -0
- package/dist/es/index.js.map +1 -0
- package/dist/{esm/index.mjs → es/loggingRestClient.js} +14 -9
- package/dist/es/loggingRestClient.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/loggingRestClient.d.ts +6 -1
- package/docs/changelog.md +33 -0
- package/docs/reference/classes/LoggingRestClient.md +19 -1
- package/package.json +6 -8
- package/dist/cjs/index.cjs +0 -60
package/dist/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,wBAAwB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./loggingRestClient.js\";\n"]}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import { BaseRestClient } from '@twin.org/api-core';
|
|
2
|
-
import { Guards, Coerce } from '@twin.org/core';
|
|
3
|
-
|
|
4
1
|
// Copyright 2024 IOTA Stiftung.
|
|
5
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { BaseRestClient } from "@twin.org/api-core";
|
|
4
|
+
import { Coerce, Guards } from "@twin.org/core";
|
|
6
5
|
/**
|
|
7
6
|
* Client for performing logging through to REST endpoints.
|
|
8
7
|
*/
|
|
9
|
-
class LoggingRestClient extends BaseRestClient {
|
|
8
|
+
export class LoggingRestClient extends BaseRestClient {
|
|
10
9
|
/**
|
|
11
10
|
* Runtime name for the class.
|
|
12
11
|
*/
|
|
13
12
|
static CLASS_NAME = "LoggingRestClient";
|
|
14
13
|
/**
|
|
15
|
-
* Create a new instance of
|
|
14
|
+
* Create a new instance of LoggingRestClient.
|
|
16
15
|
* @param config The configuration for the client.
|
|
17
16
|
*/
|
|
18
17
|
constructor(config) {
|
|
19
18
|
super(LoggingRestClient.CLASS_NAME, config, "logging");
|
|
20
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns the class name of the component.
|
|
22
|
+
* @returns The class name of the component.
|
|
23
|
+
*/
|
|
24
|
+
className() {
|
|
25
|
+
return LoggingRestClient.CLASS_NAME;
|
|
26
|
+
}
|
|
21
27
|
/**
|
|
22
28
|
* Log an entry to the connector.
|
|
23
29
|
* @param logEntry The entry to log.
|
|
@@ -45,8 +51,8 @@ class LoggingRestClient extends BaseRestClient {
|
|
|
45
51
|
query: {
|
|
46
52
|
level,
|
|
47
53
|
source,
|
|
48
|
-
timeStart,
|
|
49
|
-
timeEnd,
|
|
54
|
+
timeStart: Coerce.string(timeStart),
|
|
55
|
+
timeEnd: Coerce.string(timeEnd),
|
|
50
56
|
cursor,
|
|
51
57
|
limit: Coerce.string(limit)
|
|
52
58
|
}
|
|
@@ -54,5 +60,4 @@ class LoggingRestClient extends BaseRestClient {
|
|
|
54
60
|
return response.body;
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
export { LoggingRestClient };
|
|
63
|
+
//# sourceMappingURL=loggingRestClient.js.map
|
|
@@ -0,0 +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,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;gBACnC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;gBAC/B,MAAM;gBACN,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;aAC3B;SACD,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// 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/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./loggingRestClient";
|
|
1
|
+
export * from "./loggingRestClient.js";
|
|
@@ -10,10 +10,15 @@ export declare class LoggingRestClient extends BaseRestClient implements ILoggin
|
|
|
10
10
|
*/
|
|
11
11
|
static readonly CLASS_NAME: string;
|
|
12
12
|
/**
|
|
13
|
-
* Create a new instance of
|
|
13
|
+
* Create a new instance of LoggingRestClient.
|
|
14
14
|
* @param config The configuration for the client.
|
|
15
15
|
*/
|
|
16
16
|
constructor(config: IBaseRestClientConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Returns the class name of the component.
|
|
19
|
+
* @returns The class name of the component.
|
|
20
|
+
*/
|
|
21
|
+
className(): string;
|
|
17
22
|
/**
|
|
18
23
|
* Log an entry to the connector.
|
|
19
24
|
* @param logEntry The entry to log.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @twin.org/logging-rest-client - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.2](https://github.com/twinfoundation/logging/compare/logging-rest-client-v0.0.3-next.1...logging-rest-client-v0.0.3-next.2) (2026-03-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* api data types ([8d37cab](https://github.com/twinfoundation/logging/commit/8d37cab7ec759f079b6480bcc27d739357dbc392))
|
|
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.1 to 0.0.3-next.2
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.1](https://github.com/twinfoundation/logging/compare/logging-rest-client-v0.0.3-next.0...logging-rest-client-v0.0.3-next.1) (2025-11-10)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add context id features ([#33](https://github.com/twinfoundation/logging/issues/33)) ([38e982c](https://github.com/twinfoundation/logging/commit/38e982c9f009019fc02b67d919444b52657c9021))
|
|
23
|
+
* add validate-locales ([df53f13](https://github.com/twinfoundation/logging/commit/df53f1331394f2f9333e91e4995a88dded90e484))
|
|
24
|
+
* eslint migration to flat config ([1f9fdde](https://github.com/twinfoundation/logging/commit/1f9fddedfdcce9942afed431d9460a0f22092744))
|
|
25
|
+
* update dependencies ([976fc06](https://github.com/twinfoundation/logging/commit/976fc06976c4899769486b7cb2e827c407d7fc89))
|
|
26
|
+
* update framework core ([aac823c](https://github.com/twinfoundation/logging/commit/aac823c2ead88843618b8a82b308d5a793411764))
|
|
27
|
+
* use shared store mechanism ([#20](https://github.com/twinfoundation/logging/issues/20)) ([bbacd31](https://github.com/twinfoundation/logging/commit/bbacd31af991d82d84294ad432a40830692880ca))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Dependencies
|
|
31
|
+
|
|
32
|
+
* The following workspace dependencies were updated
|
|
33
|
+
* dependencies
|
|
34
|
+
* @twin.org/logging-models bumped from 0.0.3-next.0 to 0.0.3-next.1
|
|
35
|
+
|
|
3
36
|
## [0.0.2-next.3](https://github.com/twinfoundation/logging/compare/logging-rest-client-v0.0.2-next.2...logging-rest-client-v0.0.2-next.3) (2025-10-09)
|
|
4
37
|
|
|
5
38
|
|
|
@@ -16,7 +16,7 @@ Client for performing logging through to REST endpoints.
|
|
|
16
16
|
|
|
17
17
|
> **new LoggingRestClient**(`config`): `LoggingRestClient`
|
|
18
18
|
|
|
19
|
-
Create a new instance of
|
|
19
|
+
Create a new instance of LoggingRestClient.
|
|
20
20
|
|
|
21
21
|
#### Parameters
|
|
22
22
|
|
|
@@ -44,6 +44,24 @@ Runtime name for the class.
|
|
|
44
44
|
|
|
45
45
|
## Methods
|
|
46
46
|
|
|
47
|
+
### className()
|
|
48
|
+
|
|
49
|
+
> **className**(): `string`
|
|
50
|
+
|
|
51
|
+
Returns the class name of the component.
|
|
52
|
+
|
|
53
|
+
#### Returns
|
|
54
|
+
|
|
55
|
+
`string`
|
|
56
|
+
|
|
57
|
+
The class name of the component.
|
|
58
|
+
|
|
59
|
+
#### Implementation of
|
|
60
|
+
|
|
61
|
+
`ILoggingComponent.className`
|
|
62
|
+
|
|
63
|
+
***
|
|
64
|
+
|
|
47
65
|
### log()
|
|
48
66
|
|
|
49
67
|
> **log**(`logEntry`): `Promise`\<`void`\>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/logging-rest-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3-next.2",
|
|
4
4
|
"description": "Logging contract implementation which can connect to REST endpoints",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,23 +18,21 @@
|
|
|
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.
|
|
21
|
+
"@twin.org/logging-models": "0.0.3-next.2",
|
|
22
22
|
"@twin.org/nameof": "next"
|
|
23
23
|
},
|
|
24
|
-
"main": "./dist/
|
|
25
|
-
"module": "./dist/esm/index.mjs",
|
|
24
|
+
"main": "./dist/es/index.js",
|
|
26
25
|
"types": "./dist/types/index.d.ts",
|
|
27
26
|
"exports": {
|
|
28
27
|
".": {
|
|
29
28
|
"types": "./dist/types/index.d.ts",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
29
|
+
"import": "./dist/es/index.js",
|
|
30
|
+
"default": "./dist/es/index.js"
|
|
32
31
|
},
|
|
33
32
|
"./locales/*.json": "./locales/*.json"
|
|
34
33
|
},
|
|
35
34
|
"files": [
|
|
36
|
-
"dist/
|
|
37
|
-
"dist/esm",
|
|
35
|
+
"dist/es",
|
|
38
36
|
"dist/types",
|
|
39
37
|
"locales",
|
|
40
38
|
"docs"
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var apiCore = require('@twin.org/api-core');
|
|
4
|
-
var core = require('@twin.org/core');
|
|
5
|
-
|
|
6
|
-
// Copyright 2024 IOTA Stiftung.
|
|
7
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
8
|
-
/**
|
|
9
|
-
* Client for performing logging through to REST endpoints.
|
|
10
|
-
*/
|
|
11
|
-
class LoggingRestClient extends apiCore.BaseRestClient {
|
|
12
|
-
/**
|
|
13
|
-
* Runtime name for the class.
|
|
14
|
-
*/
|
|
15
|
-
static CLASS_NAME = "LoggingRestClient";
|
|
16
|
-
/**
|
|
17
|
-
* Create a new instance of LoggingClient.
|
|
18
|
-
* @param config The configuration for the client.
|
|
19
|
-
*/
|
|
20
|
-
constructor(config) {
|
|
21
|
-
super(LoggingRestClient.CLASS_NAME, config, "logging");
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Log an entry to the connector.
|
|
25
|
-
* @param logEntry The entry to log.
|
|
26
|
-
* @returns Nothing.
|
|
27
|
-
*/
|
|
28
|
-
async log(logEntry) {
|
|
29
|
-
core.Guards.object(LoggingRestClient.CLASS_NAME, "logEntry", logEntry);
|
|
30
|
-
await this.fetch("/", "POST", {
|
|
31
|
-
body: logEntry
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Query the log entries.
|
|
36
|
-
* @param level The level of the log entries.
|
|
37
|
-
* @param source The source of the log entries.
|
|
38
|
-
* @param timeStart The inclusive time as the start of the log entries.
|
|
39
|
-
* @param timeEnd The inclusive time as the end of the log entries.
|
|
40
|
-
* @param cursor The cursor to request the next chunk of entities.
|
|
41
|
-
* @param limit Limit the number of entities to return.
|
|
42
|
-
* @returns All the entities for the storage matching the conditions,
|
|
43
|
-
* and a cursor which can be used to request more entities.
|
|
44
|
-
*/
|
|
45
|
-
async query(level, source, timeStart, timeEnd, cursor, limit) {
|
|
46
|
-
const response = await this.fetch("/", "GET", {
|
|
47
|
-
query: {
|
|
48
|
-
level,
|
|
49
|
-
source,
|
|
50
|
-
timeStart,
|
|
51
|
-
timeEnd,
|
|
52
|
-
cursor,
|
|
53
|
-
limit: core.Coerce.string(limit)
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return response.body;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
exports.LoggingRestClient = LoggingRestClient;
|