@twin.org/logging-models 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.
Files changed (34) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/cjs/index.cjs +159 -0
  4. package/dist/esm/index.mjs +154 -0
  5. package/dist/types/connectors/multiLoggingConnector.d.ts +57 -0
  6. package/dist/types/connectors/silentLoggingConnector.d.ts +46 -0
  7. package/dist/types/factories/loggingConnectorFactory.d.ts +6 -0
  8. package/dist/types/helpers/logEntryHelper.d.ts +12 -0
  9. package/dist/types/index.d.ts +12 -0
  10. package/dist/types/models/ILogEntry.d.ts +33 -0
  11. package/dist/types/models/ILoggingComponent.d.ts +36 -0
  12. package/dist/types/models/ILoggingConnector.d.ts +38 -0
  13. package/dist/types/models/ILoggingLevelsConfig.d.ts +10 -0
  14. package/dist/types/models/api/ILoggingCreateRequest.d.ts +10 -0
  15. package/dist/types/models/api/ILoggingListRequest.d.ts +35 -0
  16. package/dist/types/models/api/ILoggingListResponse.d.ts +19 -0
  17. package/dist/types/models/logLevel.d.ts +4 -0
  18. package/docs/changelog.md +5 -0
  19. package/docs/examples.md +1 -0
  20. package/docs/reference/classes/LogEntryHelper.md +33 -0
  21. package/docs/reference/classes/MultiLoggingConnector.md +134 -0
  22. package/docs/reference/classes/SilentLoggingConnector.md +118 -0
  23. package/docs/reference/index.md +25 -0
  24. package/docs/reference/interfaces/ILogEntry.md +55 -0
  25. package/docs/reference/interfaces/ILoggingComponent.md +84 -0
  26. package/docs/reference/interfaces/ILoggingConnector.md +80 -0
  27. package/docs/reference/interfaces/ILoggingCreateRequest.md +11 -0
  28. package/docs/reference/interfaces/ILoggingLevelsConfig.md +11 -0
  29. package/docs/reference/interfaces/ILoggingListRequest.md +47 -0
  30. package/docs/reference/interfaces/ILoggingListResponse.md +23 -0
  31. package/docs/reference/type-aliases/LogLevel.md +5 -0
  32. package/docs/reference/variables/LoggingConnectorFactory.md +5 -0
  33. package/locales/en.json +3 -0
  34. package/package.json +65 -0
@@ -0,0 +1,80 @@
1
+ # Interface: ILoggingConnector
2
+
3
+ Interface describing a logging connector.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Methods
10
+
11
+ ### log()
12
+
13
+ > **log**(`logEntry`): `Promise`\<`void`\>
14
+
15
+ Log an entry to the connector.
16
+
17
+ #### Parameters
18
+
19
+ • **logEntry**: [`ILogEntry`](ILogEntry.md)
20
+
21
+ The entry to log.
22
+
23
+ #### Returns
24
+
25
+ `Promise`\<`void`\>
26
+
27
+ Nothing.
28
+
29
+ ***
30
+
31
+ ### query()
32
+
33
+ > **query**(`conditions`?, `sortProperties`?, `properties`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
34
+
35
+ Query the log entries.
36
+
37
+ #### Parameters
38
+
39
+ • **conditions?**: `EntityCondition`\<[`ILogEntry`](ILogEntry.md)\>
40
+
41
+ The conditions to match for the entities.
42
+
43
+ • **sortProperties?**: `object`[]
44
+
45
+ The optional sort order.
46
+
47
+ • **properties?**: keyof [`ILogEntry`](ILogEntry.md)[]
48
+
49
+ The optional keys to return, defaults to all.
50
+
51
+ • **cursor?**: `string`
52
+
53
+ The cursor to request the next page of entities.
54
+
55
+ • **pageSize?**: `number`
56
+
57
+ The maximum number of entities in a page.
58
+
59
+ #### Returns
60
+
61
+ `Promise`\<`object`\>
62
+
63
+ All the entities for the storage matching the conditions,
64
+ and a cursor which can be used to request more entities.
65
+
66
+ ##### entities
67
+
68
+ > **entities**: `Partial`\<[`ILogEntry`](ILogEntry.md)\>[]
69
+
70
+ The entities, which can be partial if a limited keys list was provided.
71
+
72
+ ##### cursor?
73
+
74
+ > `optional` **cursor**: `string`
75
+
76
+ An optional cursor, when defined can be used to call find to get more entities.
77
+
78
+ #### Throws
79
+
80
+ NotImplementedError if the implementation does not support retrieval.
@@ -0,0 +1,11 @@
1
+ # Interface: ILoggingCreateRequest
2
+
3
+ Create a new log entry.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: [`ILogEntry`](ILogEntry.md)
10
+
11
+ The data to be used in the create.
@@ -0,0 +1,11 @@
1
+ # Interface: ILoggingLevelsConfig
2
+
3
+ Configuration for the logging connectors to specify the levels to display.
4
+
5
+ ## Properties
6
+
7
+ ### levels?
8
+
9
+ > `optional` **levels**: [`LogLevel`](../type-aliases/LogLevel.md)[]
10
+
11
+ The log levels to display, will default to all.
@@ -0,0 +1,47 @@
1
+ # Interface: ILoggingListRequest
2
+
3
+ Get the a list of the log entries.
4
+
5
+ ## Properties
6
+
7
+ ### query
8
+
9
+ > **query**: `object`
10
+
11
+ The query parameters.
12
+
13
+ #### level?
14
+
15
+ > `optional` **level**: [`LogLevel`](../type-aliases/LogLevel.md)
16
+
17
+ The level of the log entries to retrieve.
18
+
19
+ #### source?
20
+
21
+ > `optional` **source**: `string`
22
+
23
+ The source of the log entries to retrieve.
24
+
25
+ #### timeStart?
26
+
27
+ > `optional` **timeStart**: `number`
28
+
29
+ The start time of the metrics to retrieve as a timestamp in ms.
30
+
31
+ #### timeEnd?
32
+
33
+ > `optional` **timeEnd**: `number`
34
+
35
+ The end time of the metrics to retrieve as a timestamp in ms.
36
+
37
+ #### cursor?
38
+
39
+ > `optional` **cursor**: `string`
40
+
41
+ The optional cursor to get next chunk.
42
+
43
+ #### pageSize?
44
+
45
+ > `optional` **pageSize**: `number`
46
+
47
+ The maximum number of entities in a page.
@@ -0,0 +1,23 @@
1
+ # Interface: ILoggingListResponse
2
+
3
+ Response for log entry list request.
4
+
5
+ ## Properties
6
+
7
+ ### body
8
+
9
+ > **body**: `object`
10
+
11
+ The response payload.
12
+
13
+ #### entities
14
+
15
+ > **entities**: [`ILogEntry`](ILogEntry.md)[]
16
+
17
+ The entities, which can be partial if a limited keys list was provided.
18
+
19
+ #### cursor?
20
+
21
+ > `optional` **cursor**: `string`
22
+
23
+ An optional cursor, when defined can be used to call find to get more entities.
@@ -0,0 +1,5 @@
1
+ # Type Alias: LogLevel
2
+
3
+ > **LogLevel**: `"info"` \| `"error"` \| `"warn"` \| `"trace"` \| `"debug"`
4
+
5
+ Log level.
@@ -0,0 +1,5 @@
1
+ # Variable: LoggingConnectorFactory
2
+
3
+ > `const` **LoggingConnectorFactory**: `Factory`\<[`ILoggingConnector`](../interfaces/ILoggingConnector.md)\>
4
+
5
+ Factory for creating logging connectors.
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": {}
3
+ }
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@twin.org/logging-models",
3
+ "version": "0.0.1-next.2",
4
+ "description": "Models which define the structure of the logging connectors and services",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/logging.git",
8
+ "directory": "packages/logging-models"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "scripts": {
17
+ "clean": "rimraf dist coverage docs/reference",
18
+ "build": "tspc",
19
+ "test": "vitest --run --config ./vitest.config.ts --no-cache",
20
+ "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
21
+ "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
22
+ "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
23
+ "bundle": "npm run bundle:esm && npm run bundle:cjs",
24
+ "docs:clean": "rimraf docs/reference",
25
+ "docs:generate": "typedoc",
26
+ "docs": "npm run docs:clean && npm run docs:generate",
27
+ "dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
28
+ },
29
+ "dependencies": {
30
+ "@twin.org/core": "next",
31
+ "@twin.org/entity": "next",
32
+ "@twin.org/nameof": "next"
33
+ },
34
+ "devDependencies": {
35
+ "@twin.org/nameof-transformer": "next",
36
+ "@vitest/coverage-v8": "2.1.1",
37
+ "copyfiles": "2.4.1",
38
+ "rimraf": "6.0.1",
39
+ "rollup": "4.21.3",
40
+ "rollup-plugin-typescript2": "0.36.0",
41
+ "ts-patch": "3.2.1",
42
+ "typedoc": "0.26.7",
43
+ "typedoc-plugin-markdown": "4.2.7",
44
+ "typescript": "5.6.2",
45
+ "vitest": "2.1.1"
46
+ },
47
+ "main": "./dist/cjs/index.cjs",
48
+ "module": "./dist/esm/index.mjs",
49
+ "types": "./dist/types/index.d.ts",
50
+ "exports": {
51
+ ".": {
52
+ "require": "./dist/cjs/index.cjs",
53
+ "import": "./dist/esm/index.mjs",
54
+ "types": "./dist/types/index.d.ts"
55
+ },
56
+ "./locales": "./locales"
57
+ },
58
+ "files": [
59
+ "dist/cjs",
60
+ "dist/esm",
61
+ "dist/types",
62
+ "locales",
63
+ "docs"
64
+ ]
65
+ }