kuzzle-device-manager-types 3.0.0-3-dev.17 → 3.0.0-3-dev.19

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.
@@ -51,5 +51,11 @@ export declare class AssetService extends DigitalTwinService {
51
51
  updateModelLocales(request: KuzzleRequest, model: string): Promise<ApiAssetUpdateModelLocales[]>;
52
52
  addMeasureSlot(assetId: string, measureSlot: AssetContent["measureSlots"][0], engineId: string, request: KuzzleRequest): Promise<KDocument<AssetContent>>;
53
53
  removeMeasureSlot(assetId: string, measureSlotName: string, engineId: string, request: KuzzleRequest): Promise<KDocument<AssetContent>>;
54
+ /**
55
+ * Update the display name of a measure slot on an asset
56
+ */
57
+ updateMeasureSlotDisplayName(assetId: string, measureSlotName: string, displayName: {
58
+ [locale: string]: string;
59
+ }, engineId: string, request: KuzzleRequest): Promise<KDocument<AssetContent>>;
54
60
  private refreshModel;
55
61
  }
@@ -3,7 +3,7 @@ import { MeasureExporter } from "../measure";
3
3
  import { DeviceManagerPlugin } from "../plugin";
4
4
  import { DigitalTwinExporter } from "../shared";
5
5
  import { AssetService } from "./AssetService";
6
- import { ApiAssetCreateResult, ApiAssetUpsertResult, ApiAssetDeleteResult, ApiAssetGetMeasuresResult, ApiAssetGetResult, ApiAssetSearchResult, ApiAssetUpdateResult, ApiAssetMigrateTenantResult, ApiAssetMetadataReplaceResult, ApiAssetGetLastMeasuresResult, ApiAssetMGetLastMeasuredAtResult, ApiAssetMGetLastMeasuresResult, ApiAssetGetLastMeasuredAtResult, ApiAssetUpdateModelLocales, ApiAssetLinkDevicesResult, ApiAssetUnlinkDevicesResult, ApiAssetAddMeasureSlotResult, ApiAssetRemoveMeasureSlotResult } from "./types/AssetApi";
6
+ import { ApiAssetCreateResult, ApiAssetUpsertResult, ApiAssetDeleteResult, ApiAssetGetMeasuresResult, ApiAssetGetResult, ApiAssetSearchResult, ApiAssetUpdateResult, ApiAssetMigrateTenantResult, ApiAssetMetadataReplaceResult, ApiAssetGetLastMeasuresResult, ApiAssetMGetLastMeasuredAtResult, ApiAssetMGetLastMeasuresResult, ApiAssetGetLastMeasuredAtResult, ApiAssetUpdateModelLocales, ApiAssetLinkDevicesResult, ApiAssetUnlinkDevicesResult, ApiAssetAddMeasureSlotResult, ApiAssetRemoveMeasureSlotResult, ApiAssetUpdateMeasureSlotDisplayNameResult } from "./types/AssetApi";
7
7
  import { KuzzleLogger } from "kuzzle-logger";
8
8
  export declare class AssetsController {
9
9
  readonly plugin: DeviceManagerPlugin;
@@ -62,4 +62,8 @@ export declare class AssetsController {
62
62
  * Remove a measure slot from an asset
63
63
  */
64
64
  removeMeasureSlot(request: KuzzleRequest): Promise<ApiAssetRemoveMeasureSlotResult>;
65
+ /**
66
+ * Update the display name of a measure slot on an asset
67
+ */
68
+ updateMeasureSlotDisplayName(request: KuzzleRequest): Promise<ApiAssetUpdateMeasureSlotDisplayNameResult>;
65
69
  }
@@ -256,17 +256,25 @@ export interface ApiAssetAddMeasureSlotRequest extends AssetsControllerRequest {
256
256
  _id: string;
257
257
  body: {
258
258
  /**
259
- * Measure slot containing the name of the slot and it's type of measurement
259
+ * Measure slot containing the name of the slot, its type of measurement
260
+ * and an optional per-locale display name.
260
261
  *
261
- * { name: string , type: string}
262
+ * { name: string, type: string, displayName?: { [locale: string]: string } }
262
263
  *
263
264
  * @example
264
265
  *
265
- * { name: "externalTemperature", type: "temperature" }
266
+ * {
267
+ * name: "externalTemperature",
268
+ * type: "temperature",
269
+ * displayName: { en: "External temperature", fr: "Température extérieure" }
270
+ * }
266
271
  */
267
272
  measureSlot: {
268
273
  name: string;
269
274
  type: string;
275
+ displayName?: {
276
+ [locale: string]: string;
277
+ };
270
278
  };
271
279
  };
272
280
  }
@@ -287,4 +295,29 @@ export interface ApiAssetRemoveMeasureSlotRequest extends AssetsControllerReques
287
295
  };
288
296
  }
289
297
  export type ApiAssetRemoveMeasureSlotResult = KDocument<AssetContent>;
298
+ export interface ApiAssetUpdateMeasureSlotDisplayNameRequest extends AssetsControllerRequest {
299
+ action: "updateMeasureSlotDisplayName";
300
+ _id: string;
301
+ body: {
302
+ /**
303
+ * Name of the measure slot to update.
304
+ *
305
+ * @example
306
+ *
307
+ * measureSlot: "externalTemperature",
308
+ */
309
+ measureSlot: string;
310
+ /**
311
+ * Per-locale display name for the measure slot.
312
+ *
313
+ * @example
314
+ *
315
+ * displayName: { en: "External temperature", fr: "Température extérieure" }
316
+ */
317
+ displayName: {
318
+ [locale: string]: string;
319
+ };
320
+ };
321
+ }
322
+ export type ApiAssetUpdateMeasureSlotDisplayNameResult = KDocument<AssetContent>;
290
323
  export {};
@@ -12,11 +12,40 @@ import { DecoderContent } from "./types/DecoderContent";
12
12
  export type NamedMeasures = Array<{
13
13
  name: string;
14
14
  type: string;
15
+ /**
16
+ * Per-locale display name for this measure slot, keyed by locale.
17
+ *
18
+ * @example
19
+ * { en: "External temperature", fr: "Température extérieure" }
20
+ */
21
+ displayName?: {
22
+ [locale: string]: string;
23
+ };
15
24
  }>;
25
+ /**
26
+ * Result of the payload validation made by a decoder.
27
+ *
28
+ * Stored alongside the raw payload in the "payloads" collection.
29
+ */
30
+ export type DecoderValidationResult = {
31
+ /**
32
+ * "valid": the payload will be decoded
33
+ * "invalid": the payload will be skipped (status 400)
34
+ */
35
+ status: "valid" | "invalid";
36
+ /**
37
+ * Why the payload has been rejected
38
+ */
39
+ reason?: string;
40
+ /**
41
+ * Custom data stored with the payload
42
+ */
43
+ customData?: JSONObject;
44
+ };
16
45
  /**
17
46
  * Base class to implement a decoder for a device model.
18
47
  * The device model must be passed to the parent constructor.
19
- * The abstract "decode" method must be implemented.
48
+ * The abstract "validate" and "decode" methods must be implemented.
20
49
  */
21
50
  export declare abstract class Decoder {
22
51
  private _http?;
@@ -76,16 +105,18 @@ export declare abstract class Decoder {
76
105
  * Validate the payload format before processing.
77
106
  *
78
107
  * If the method:
79
- * - return true: the payload will be processed (status 200)
80
- * - return false: the payload will be skipped (status 200)
108
+ * - return status "valid": the payload will be processed (status 200)
109
+ * - return status "invalid": the payload will be skipped (status 400)
81
110
  * - throw an error: the payload will be skipped (status 4** or 5**)
82
111
  *
112
+ * The returned `reason` and `customData` are stored in the "payloads" collection.
113
+ *
83
114
  * @param payload Raw payload received in the API action body
84
115
  * @param request Original request
85
116
  *
86
- * @return A boolean indicating if the payload is valid
117
+ * @return The validation result
87
118
  */
88
- validate(payload: JSONObject, request: KuzzleRequest): Promise<boolean> | never;
119
+ validate(payload: JSONObject, request: KuzzleRequest): Promise<DecoderValidationResult> | DecoderValidationResult;
89
120
  /**
90
121
  * Decode the payload:
91
122
  * - set "reference"
@@ -97,7 +128,7 @@ export declare abstract class Decoder {
97
128
  *
98
129
  * @returns DecodedPayload
99
130
  */
100
- abstract decode(decodedPayload: DecodedPayload<any>, payload: JSONObject, request: KuzzleRequest): Promise<DecodedPayload<any>>;
131
+ abstract decode(decodedPayload: DecodedPayload<any>, payload: JSONObject, request: KuzzleRequest): Promise<DecodedPayload<any>> | DecodedPayload<any>;
101
132
  /**
102
133
  * Checks if the provided properties are present in the payload
103
134
  *
@@ -17,7 +17,7 @@ export declare class PayloadService extends BaseService {
17
17
  * - redirect measurements to MeasureService
18
18
  */
19
19
  receive(request: KuzzleRequest, decoder: Decoder, { refresh }?: any): Promise<{
20
- valid: boolean;
20
+ valid: true;
21
21
  }>;
22
22
  receiveFormated(device: KDocument<DeviceContent>, measurements: DecodedMeasurement[], { payloadUuids }?: {
23
23
  payloadUuids?: string[];
@@ -23,5 +23,9 @@ export declare const payloadsMappings: {
23
23
  reason: {
24
24
  type: string;
25
25
  };
26
+ customData: {
27
+ dynamic: string;
28
+ properties: {};
29
+ };
26
30
  };
27
31
  };
@@ -22,6 +22,12 @@ export declare class DeviceService extends DigitalTwinService {
22
22
  * Replace a device metadata
23
23
  */
24
24
  replaceMetadata(engineId: string, deviceId: string, metadata: Metadata, request: KuzzleRequest): Promise<KDocument<DeviceContent>>;
25
+ /**
26
+ * Update the display name of a measure slot on a device
27
+ */
28
+ updateMeasureSlotDisplayName(engineId: string, deviceId: string, measureSlotName: string, displayName: {
29
+ [locale: string]: string;
30
+ }, request: KuzzleRequest): Promise<KDocument<DeviceContent>>;
25
31
  /**
26
32
  * Update or Create an device metadata
27
33
  */
@@ -1,7 +1,7 @@
1
1
  import { ControllerDefinition, KuzzleRequest } from "kuzzle";
2
2
  import { DeviceManagerPlugin } from "../plugin";
3
3
  import { DeviceService } from "./DeviceService";
4
- import { ApiDeviceAttachEngineResult, ApiDeviceCreateResult, ApiDeviceDeleteResult, ApiDeviceDetachEngineResult, ApiDeviceGetResult, ApiDeviceLinkAssetsResult, ApiDeviceSearchResult, ApiDeviceUnlinkAssetsResult, ApiDeviceUpdateResult, ApiDeviceGetMeasuresResult, ApiDeviceUpsertResult, ApiDeviceGetLastMeasuresResult, ApiDeviceMGetLastMeasuresResult, ApiDeviceGetLastMeasuredAtResult, ApiDeviceMGetLastMeasuredAtResult, ApiDeviceMetadataReplaceResult } from "./types/DeviceApi";
4
+ import { ApiDeviceAttachEngineResult, ApiDeviceCreateResult, ApiDeviceDeleteResult, ApiDeviceDetachEngineResult, ApiDeviceGetResult, ApiDeviceLinkAssetsResult, ApiDeviceSearchResult, ApiDeviceUnlinkAssetsResult, ApiDeviceUpdateResult, ApiDeviceGetMeasuresResult, ApiDeviceUpsertResult, ApiDeviceGetLastMeasuresResult, ApiDeviceMGetLastMeasuresResult, ApiDeviceGetLastMeasuredAtResult, ApiDeviceMGetLastMeasuredAtResult, ApiDeviceMetadataReplaceResult, ApiDeviceUpdateMeasureSlotDisplayNameResult } from "./types/DeviceApi";
5
5
  import { KuzzleLogger } from "kuzzle-logger";
6
6
  export declare class DevicesController {
7
7
  private plugin;
@@ -45,4 +45,8 @@ export declare class DevicesController {
45
45
  export(request: KuzzleRequest): Promise<any>;
46
46
  getLastMeasuredAt(request: KuzzleRequest): Promise<ApiDeviceGetLastMeasuredAtResult>;
47
47
  mGetLastMeasuredAt(request: KuzzleRequest): Promise<ApiDeviceMGetLastMeasuredAtResult>;
48
+ /**
49
+ * Update the display name of a measure slot on a device
50
+ */
51
+ updateMeasureSlotDisplayName(request: KuzzleRequest): Promise<ApiDeviceUpdateMeasureSlotDisplayNameResult>;
48
52
  }
@@ -23,6 +23,31 @@ export interface ApiDeviceUpdateRequest extends DevicesControllerRequest {
23
23
  }
24
24
  export type ApiDeviceUpdateResult = KDocument<DeviceContent>;
25
25
  export type ApiDeviceMetadataReplaceResult = KDocument<DeviceContent>;
26
+ export interface ApiDeviceUpdateMeasureSlotDisplayNameRequest extends DevicesControllerRequest {
27
+ action: "updateMeasureSlotDisplayName";
28
+ _id: string;
29
+ body: {
30
+ /**
31
+ * Name of the measure slot to update.
32
+ *
33
+ * @example
34
+ *
35
+ * measureSlot: "externalTemperature",
36
+ */
37
+ measureSlot: string;
38
+ /**
39
+ * Per-locale display name for the measure slot.
40
+ *
41
+ * @example
42
+ *
43
+ * displayName: { en: "External temperature", fr: "Température extérieure" }
44
+ */
45
+ displayName: {
46
+ [locale: string]: string;
47
+ };
48
+ };
49
+ }
50
+ export type ApiDeviceUpdateMeasureSlotDisplayNameResult = KDocument<DeviceContent>;
26
51
  export interface ApiDeviceUpsertRequest extends DevicesControllerRequest {
27
52
  action: "upsert";
28
53
  refresh?: string;
@@ -241,12 +241,16 @@ export interface AssetModelContent extends KDocumentContent {
241
241
  /**
242
242
  * List of accepted measures for this model
243
243
  *
244
- * Array<{ type: string, name: string }>
244
+ * Array<{ type: string, name: string, displayName?: { [locale: string]: string } }>
245
245
  *
246
246
  * @example
247
247
  *
248
248
  * [
249
- * { type: "temperature", name: "externalTemperature" }
249
+ * {
250
+ * type: "temperature",
251
+ * name: "externalTemperature",
252
+ * displayName: { en: "External temperature", fr: "Température extérieure" }
253
+ * }
250
254
  * ]
251
255
  */
252
256
  measures: NamedMeasures;
@@ -387,12 +391,16 @@ export interface DeviceModelContent extends KDocumentContent {
387
391
  /**
388
392
  * List of decoded measures for this model
389
393
  *
390
- * Array<{ type: string, name: string }>
394
+ * Array<{ type: string, name: string, displayName?: { [locale: string]: string } }>
391
395
  *
392
396
  * @example
393
397
  *
394
398
  * [
395
- * { type: "temperature", name: "externalTemperature" }
399
+ * {
400
+ * type: "temperature",
401
+ * name: "externalTemperature",
402
+ * displayName: { en: "External temperature", fr: "Température extérieure" }
403
+ * }
396
404
  * ]
397
405
  */
398
406
  measures: NamedMeasures;
@@ -1,5 +1,5 @@
1
1
  import { JSONObject } from "kuzzle-sdk";
2
- import { Decoder, DecodedPayload } from "../../../index";
2
+ import { Decoder, DecodedPayload, DecoderValidationResult } from "../../../index";
3
3
  export declare const dummyTempDeviceMeasures: readonly [{
4
4
  readonly name: "temperature";
5
5
  readonly type: "temperature";
@@ -22,7 +22,7 @@ export declare class DummyTempDecoder extends Decoder {
22
22
  readonly type: "battery";
23
23
  }];
24
24
  constructor();
25
- validate(rawPayload: JSONObject): Promise<boolean>;
25
+ validate(rawPayload: JSONObject): Promise<DecoderValidationResult>;
26
26
  decode(decodedPayload: DecodedPayload<DummyTempDecoder>, rawPayload: JSONObject): Promise<DecodedPayload<DummyTempDecoder>>;
27
27
  decodeSimplePayload(decodedPayload: DecodedPayload<DummyTempDecoder>, payload: JSONObject): void;
28
28
  }
@@ -22,6 +22,8 @@ export declare class DummyTempPositionDecoder extends Decoder {
22
22
  readonly type: "position";
23
23
  }];
24
24
  constructor();
25
- validate(payload: JSONObject): Promise<boolean>;
25
+ validate(payload: JSONObject): Promise<{
26
+ status: "valid";
27
+ }>;
26
28
  decode(decodedPayload: DecodedPayload<DummyTempPositionDecoder>, payload: JSONObject): Promise<DecodedPayload<DummyTempPositionDecoder>>;
27
29
  }
@@ -1,8 +1,8 @@
1
1
  import { JSONObject } from "kuzzle-sdk";
2
- import { Decoder, DecodedPayload } from "../../../index";
2
+ import { Decoder, DecodedPayload, DecoderValidationResult } from "../../../index";
3
3
  export declare class EmptyTempDecoder extends Decoder {
4
4
  measures: any[];
5
5
  constructor();
6
- validate(rawPayload: JSONObject): Promise<boolean>;
6
+ validate(rawPayload: JSONObject): Promise<DecoderValidationResult>;
7
7
  decode(decodedPayload: DecodedPayload<EmptyTempDecoder>, rawPayload: JSONObject): Promise<DecodedPayload<EmptyTempDecoder>>;
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kuzzle-device-manager-types",
3
- "version": "3.0.0-3-dev.17",
3
+ "version": "3.0.0-3-dev.19",
4
4
  "description": "Shared types for Kuzzle Device Manager",
5
5
  "author": "The Kuzzle Team (support@kuzzle.io)",
6
6
  "main": "index.js",
@@ -1,3 +0,0 @@
1
- export declare class SkipError extends Error {
2
- constructor(message: string);
3
- }