@twin.org/telemetry-service 0.0.1-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.
@@ -0,0 +1,289 @@
1
+ # Class: TelemetryService
2
+
3
+ Service for performing telemetry operations to a connector.
4
+
5
+ ## Implements
6
+
7
+ - `ITelemetryComponent`
8
+
9
+ ## Constructors
10
+
11
+ ### new TelemetryService()
12
+
13
+ > **new TelemetryService**(`options`?): [`TelemetryService`](TelemetryService.md)
14
+
15
+ Create a new instance of TelemetryService.
16
+
17
+ #### Parameters
18
+
19
+ • **options?**
20
+
21
+ The options for the connector.
22
+
23
+ • **options.telemetryConnectorType?**: `string`
24
+
25
+ The type of the telemetry connector to use, defaults to "telemetry".
26
+
27
+ #### Returns
28
+
29
+ [`TelemetryService`](TelemetryService.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
+ `ITelemetryComponent.CLASS_NAME`
42
+
43
+ ## Methods
44
+
45
+ ### createMetric()
46
+
47
+ > **createMetric**(`metric`): `Promise`\<`void`\>
48
+
49
+ Create a new metric.
50
+
51
+ #### Parameters
52
+
53
+ • **metric**: `ITelemetryMetric`
54
+
55
+ The metric details.
56
+
57
+ #### Returns
58
+
59
+ `Promise`\<`void`\>
60
+
61
+ Nothing.
62
+
63
+ #### Implementation of
64
+
65
+ `ITelemetryComponent.createMetric`
66
+
67
+ ***
68
+
69
+ ### getMetric()
70
+
71
+ > **getMetric**(`id`): `Promise`\<`object`\>
72
+
73
+ Get the metric details and it's most recent value.
74
+
75
+ #### Parameters
76
+
77
+ • **id**: `string`
78
+
79
+ The metric id.
80
+
81
+ #### Returns
82
+
83
+ `Promise`\<`object`\>
84
+
85
+ The metric details and it's most recent value.
86
+
87
+ ##### metric
88
+
89
+ > **metric**: `ITelemetryMetric`
90
+
91
+ ##### value
92
+
93
+ > **value**: `ITelemetryMetricValue`
94
+
95
+ #### Implementation of
96
+
97
+ `ITelemetryComponent.getMetric`
98
+
99
+ ***
100
+
101
+ ### updateMetric()
102
+
103
+ > **updateMetric**(`metric`): `Promise`\<`void`\>
104
+
105
+ Update metric.
106
+
107
+ #### Parameters
108
+
109
+ • **metric**: `Omit`\<`ITelemetryMetric`, `"type"`\>
110
+
111
+ The metric details.
112
+
113
+ #### Returns
114
+
115
+ `Promise`\<`void`\>
116
+
117
+ Nothing.
118
+
119
+ #### Implementation of
120
+
121
+ `ITelemetryComponent.updateMetric`
122
+
123
+ ***
124
+
125
+ ### addMetricValue()
126
+
127
+ > **addMetricValue**(`id`, `value`, `customData`?): `Promise`\<`string`\>
128
+
129
+ Add a metric value.
130
+
131
+ #### Parameters
132
+
133
+ • **id**: `string`
134
+
135
+ The id of the metric.
136
+
137
+ • **value**: `number` \| `"inc"` \| `"dec"`
138
+
139
+ The value for the add operation.
140
+
141
+ • **customData?**
142
+
143
+ The custom data for the add operation.
144
+
145
+ #### Returns
146
+
147
+ `Promise`\<`string`\>
148
+
149
+ The created metric value id.
150
+
151
+ #### Implementation of
152
+
153
+ `ITelemetryComponent.addMetricValue`
154
+
155
+ ***
156
+
157
+ ### removeMetric()
158
+
159
+ > **removeMetric**(`id`): `Promise`\<`void`\>
160
+
161
+ Remove metric.
162
+
163
+ #### Parameters
164
+
165
+ • **id**: `string`
166
+
167
+ The id of the metric.
168
+
169
+ #### Returns
170
+
171
+ `Promise`\<`void`\>
172
+
173
+ Nothing.
174
+
175
+ #### Implementation of
176
+
177
+ `ITelemetryComponent.removeMetric`
178
+
179
+ ***
180
+
181
+ ### query()
182
+
183
+ > **query**(`type`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
184
+
185
+ Query the metrics.
186
+
187
+ #### Parameters
188
+
189
+ • **type?**: `MetricType`
190
+
191
+ The type of the metric.
192
+
193
+ • **cursor?**: `string`
194
+
195
+ The cursor to request the next page of entities.
196
+
197
+ • **pageSize?**: `number`
198
+
199
+ The maximum number of entities in a page.
200
+
201
+ #### Returns
202
+
203
+ `Promise`\<`object`\>
204
+
205
+ All the entities for the storage matching the conditions,
206
+ and a cursor which can be used to request more entities.
207
+
208
+ ##### entities
209
+
210
+ > **entities**: `ITelemetryMetric`[]
211
+
212
+ The metrics.
213
+
214
+ ##### cursor?
215
+
216
+ > `optional` **cursor**: `string`
217
+
218
+ An optional cursor, when defined can be used to call find to get more values.
219
+
220
+ #### Throws
221
+
222
+ NotImplementedError if the implementation does not support retrieval.
223
+
224
+ #### Implementation of
225
+
226
+ `ITelemetryComponent.query`
227
+
228
+ ***
229
+
230
+ ### queryValues()
231
+
232
+ > **queryValues**(`id`, `timeStart`?, `timeEnd`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
233
+
234
+ Query the metric values.
235
+
236
+ #### Parameters
237
+
238
+ • **id**: `string`
239
+
240
+ The id of the metric.
241
+
242
+ • **timeStart?**: `number`
243
+
244
+ The inclusive time as the start of the metric entries.
245
+
246
+ • **timeEnd?**: `number`
247
+
248
+ The inclusive time as the end of the metric entries.
249
+
250
+ • **cursor?**: `string`
251
+
252
+ The cursor to request the next page of entities.
253
+
254
+ • **pageSize?**: `number`
255
+
256
+ The maximum number of entities in a page.
257
+
258
+ #### Returns
259
+
260
+ `Promise`\<`object`\>
261
+
262
+ All the entities for the storage matching the conditions,
263
+ and a cursor which can be used to request more entities.
264
+
265
+ ##### metric
266
+
267
+ > **metric**: `ITelemetryMetric`
268
+
269
+ The metric details.
270
+
271
+ ##### entities
272
+
273
+ > **entities**: `ITelemetryMetricValue`[]
274
+
275
+ The values for the metric.
276
+
277
+ ##### cursor?
278
+
279
+ > `optional` **cursor**: `string`
280
+
281
+ An optional cursor, when defined can be used to call find to get more values.
282
+
283
+ #### Throws
284
+
285
+ NotImplementedError if the implementation does not support retrieval.
286
+
287
+ #### Implementation of
288
+
289
+ `ITelemetryComponent.queryValues`
@@ -0,0 +1,21 @@
1
+ # Function: generateRestRoutesTelemetry()
2
+
3
+ > **generateRestRoutesTelemetry**(`baseRouteName`, `componentName`): `IRestRoute`[]
4
+
5
+ The REST routes for telemetry.
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: telemetryAddMetricValue()
2
+
3
+ > **telemetryAddMetricValue**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ICreatedResponse`\>
4
+
5
+ Add a telemetry metric value.
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**: `ITelemetryAddMetricValueRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`ICreatedResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: telemetryCreateMetric()
2
+
3
+ > **telemetryCreateMetric**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ICreatedResponse`\>
4
+
5
+ Create a new telemetry metric.
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**: `ITelemetryCreateMetricRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`ICreatedResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: telemetryGetMetric()
2
+
3
+ > **telemetryGetMetric**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ITelemetryGetMetricResponse`\>
4
+
5
+ Gets a telemetry metric.
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**: `ITelemetryGetMetricRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`ITelemetryGetMetricResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: telemetryMetricList()
2
+
3
+ > **telemetryMetricList**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ITelemetryListResponse`\>
4
+
5
+ Get a list of the telemetry metrics.
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**: `ITelemetryListRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`ITelemetryListResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: telemetryMetricValueList()
2
+
3
+ > **telemetryMetricValueList**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ITelemetryValuesListResponse`\>
4
+
5
+ Get a list of the telemetry metric values.
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**: `ITelemetryValuesListRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`ITelemetryValuesListResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: telemetryRemoveMetric()
2
+
3
+ > **telemetryRemoveMetric**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ Removes a telemetry metric.
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**: `ITelemetryRemoveMetricRequest`
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: telemetryUpdateMetric()
2
+
3
+ > **telemetryUpdateMetric**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ Updates a telemetry metric.
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**: `ITelemetryUpdateMetricRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`INoContentResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,21 @@
1
+ # @twin.org/telemetry-service
2
+
3
+ ## Classes
4
+
5
+ - [TelemetryService](classes/TelemetryService.md)
6
+
7
+ ## Variables
8
+
9
+ - [restEntryPoints](variables/restEntryPoints.md)
10
+ - [tagsTelemetry](variables/tagsTelemetry.md)
11
+
12
+ ## Functions
13
+
14
+ - [generateRestRoutesTelemetry](functions/generateRestRoutesTelemetry.md)
15
+ - [telemetryCreateMetric](functions/telemetryCreateMetric.md)
16
+ - [telemetryGetMetric](functions/telemetryGetMetric.md)
17
+ - [telemetryUpdateMetric](functions/telemetryUpdateMetric.md)
18
+ - [telemetryAddMetricValue](functions/telemetryAddMetricValue.md)
19
+ - [telemetryRemoveMetric](functions/telemetryRemoveMetric.md)
20
+ - [telemetryMetricList](functions/telemetryMetricList.md)
21
+ - [telemetryMetricValueList](functions/telemetryMetricValueList.md)
@@ -0,0 +1,3 @@
1
+ # Variable: restEntryPoints
2
+
3
+ > `const` **restEntryPoints**: `IRestRouteEntryPoint`[]
@@ -0,0 +1,5 @@
1
+ # Variable: tagsTelemetry
2
+
3
+ > `const` **tagsTelemetry**: `ITag`[]
4
+
5
+ The tag to associate with the routes.
@@ -0,0 +1 @@
1
+ {}
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@twin.org/telemetry-service",
3
+ "version": "0.0.1-next.3",
4
+ "description": "Telemetry contract implementation and REST endpoint definitions",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/telemetry.git",
8
+ "directory": "packages/telemetry-service"
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:api": "ts-to-openapi ./ts-to-openapi.json ./docs/open-api/spec.json",
27
+ "docs": "npm run docs:clean && npm run docs:generate && npm run docs:api",
28
+ "dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
29
+ },
30
+ "dependencies": {
31
+ "@twin.org/api-models": "next",
32
+ "@twin.org/core": "next",
33
+ "@twin.org/entity": "next",
34
+ "@twin.org/nameof": "next",
35
+ "@twin.org/telemetry-models": "0.0.1-next.3",
36
+ "@twin.org/web": "next"
37
+ },
38
+ "devDependencies": {
39
+ "@twin.org/nameof-transformer": "next",
40
+ "@twin.org/ts-to-openapi": "next",
41
+ "@vitest/coverage-v8": "2.1.1",
42
+ "copyfiles": "2.4.1",
43
+ "rimraf": "6.0.1",
44
+ "rollup": "4.22.0",
45
+ "rollup-plugin-typescript2": "0.36.0",
46
+ "ts-patch": "3.2.1",
47
+ "typedoc": "0.26.7",
48
+ "typedoc-plugin-markdown": "4.2.7",
49
+ "typescript": "5.6.2",
50
+ "vitest": "2.1.1"
51
+ },
52
+ "main": "./dist/cjs/index.cjs",
53
+ "module": "./dist/esm/index.mjs",
54
+ "types": "./dist/types/index.d.ts",
55
+ "exports": {
56
+ ".": {
57
+ "require": "./dist/cjs/index.cjs",
58
+ "import": "./dist/esm/index.mjs",
59
+ "types": "./dist/types/index.d.ts"
60
+ },
61
+ "./locales": "./locales"
62
+ },
63
+ "files": [
64
+ "dist/cjs",
65
+ "dist/esm",
66
+ "dist/types",
67
+ "locales",
68
+ "docs"
69
+ ]
70
+ }