@twin.org/telemetry-service 0.0.1-next.10

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