kuzzle-device-manager-types 2.0.9 → 2.1.1

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 (39) hide show
  1. package/dist/features/fixtures/application/decoders/DummyTempDecoder.d.ts +1 -1
  2. package/dist/features/fixtures/application/decoders/DummyTempPositionDecoder.d.ts +1 -1
  3. package/dist/lib/core/DeviceManagerConfiguration.d.ts +1 -1
  4. package/dist/lib/core/DeviceManagerPlugin.d.ts +2 -4
  5. package/dist/lib/core/registers/DecodersRegister.d.ts +8 -8
  6. package/dist/lib/core/registers/ModelsRegister.d.ts +1 -1
  7. package/dist/lib/modules/asset/AssetHistoryService.d.ts +1 -1
  8. package/dist/lib/modules/asset/AssetService.d.ts +2 -1
  9. package/dist/lib/modules/asset/model/AssetSerializer.d.ts +1 -1
  10. package/dist/lib/modules/asset/types/AssetApi.d.ts +1 -1
  11. package/dist/lib/modules/asset/types/AssetContent.d.ts +1 -1
  12. package/dist/lib/modules/asset/types/AssetEvents.d.ts +1 -1
  13. package/dist/lib/modules/asset/types/AssetHistoryContent.d.ts +1 -1
  14. package/dist/lib/modules/decoder/DecodedPayload.d.ts +1 -1
  15. package/dist/lib/modules/decoder/Decoder.d.ts +2 -1
  16. package/dist/lib/modules/decoder/PayloadService.d.ts +8 -2
  17. package/dist/lib/modules/decoder/collections/payloadsMappings.d.ts +3 -0
  18. package/dist/lib/modules/decoder/types/PayloadApi.d.ts +1 -1
  19. package/dist/lib/modules/decoder/types/PayloadEvents.d.ts +15 -0
  20. package/dist/lib/modules/device/DeviceService.d.ts +6 -1
  21. package/dist/lib/modules/device/DevicesController.d.ts +1 -0
  22. package/dist/lib/modules/device/model/DeviceSerializer.d.ts +1 -1
  23. package/dist/lib/modules/device/types/DeviceApi.d.ts +16 -2
  24. package/dist/lib/modules/device/types/DeviceContent.d.ts +1 -1
  25. package/dist/lib/modules/device/types/DeviceEvents.d.ts +2 -1
  26. package/dist/lib/modules/measure/types/MeasureContent.d.ts +1 -1
  27. package/dist/lib/modules/measure/types/MeasureDefinition.d.ts +1 -1
  28. package/dist/lib/modules/measure/types/MeasureEvents.d.ts +9 -10
  29. package/dist/lib/modules/model/ModelService.d.ts +1 -1
  30. package/dist/lib/modules/model/types/ModelApi.d.ts +1 -1
  31. package/dist/lib/modules/model/types/ModelContent.d.ts +1 -1
  32. package/dist/lib/modules/model/types/ModelDefinition.d.ts +1 -1
  33. package/dist/lib/modules/shared/index.d.ts +0 -1
  34. package/dist/lib/modules/shared/types/DigitalTwinContent.d.ts +1 -1
  35. package/dist/lib/modules/shared/types/EmbeddedMeasure.d.ts +1 -1
  36. package/dist/lib/modules/shared/utils/ask.d.ts +1 -1
  37. package/dist/lib/modules/shared/utils/flattenObject.d.ts +1 -1
  38. package/package.json +1 -1
  39. package/dist/lib/modules/shared/utils/snakeCase.d.ts +0 -7
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  import { Decoder, DecodedPayload } from "../../../../index";
3
3
  export declare class DummyTempDecoder extends Decoder {
4
4
  measures: readonly [{
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  import { Decoder, DecodedPayload } from "../../../../index";
3
3
  export declare class DummyTempPositionDecoder extends Decoder {
4
4
  measures: readonly [{
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  export type DeviceManagerConfiguration = {
3
3
  /**
4
4
  * Ignore errors at startup such as wrong mappings update.
@@ -1,11 +1,10 @@
1
- import { Plugin, PluginContext, JSONObject } from "kuzzle";
1
+ import { Plugin, PluginContext } from "kuzzle";
2
+ import { JSONObject } from "kuzzle-sdk";
2
3
  import { MeasureDefinition } from "../modules/measure";
3
4
  import { AssetModelDefinition, DeviceModelDefinition } from "../modules/model";
4
- import { KuzzleRole } from "../modules/shared";
5
5
  import { DeviceManagerConfiguration } from "./DeviceManagerConfiguration";
6
6
  export declare class DeviceManagerPlugin extends Plugin {
7
7
  config: DeviceManagerConfiguration;
8
- roles: KuzzleRole[];
9
8
  private deviceManagerEngine;
10
9
  private adminConfigManager;
11
10
  private engineConfigManager;
@@ -95,7 +94,6 @@ export declare class DeviceManagerPlugin extends Plugin {
95
94
  * Init the plugin
96
95
  */
97
96
  init(config: JSONObject, context: PluginContext): Promise<void>;
98
- private createDefaultRoles;
99
97
  /**
100
98
  * Initialize the administration index of the plugin
101
99
  */
@@ -1,14 +1,16 @@
1
1
  import { PluginContext } from "kuzzle";
2
2
  import { Decoder, DecoderContent } from "../../modules/decoder";
3
+ import { DeviceManagerPlugin } from "..";
3
4
  export declare class DecodersRegister {
4
5
  private context;
6
+ private plugin;
5
7
  /**
6
8
  * Map<deviceModel, Decoder>
7
9
  */
8
10
  private _decoders;
9
11
  private get sdk();
10
12
  get decoders(): Decoder[];
11
- init(context: PluginContext): void;
13
+ init(plugin: DeviceManagerPlugin, context: PluginContext): void;
12
14
  get(deviceModel: string): Decoder;
13
15
  list(): DecoderContent[];
14
16
  /**
@@ -29,13 +31,11 @@ export declare class DecodersRegister {
29
31
  };
30
32
  printDecoders(): void;
31
33
  /**
32
- * Creates default roles, profiles and users associated to the generated actions
34
+ * Register default role, profile and user associated to the generated actions
33
35
  * in the Payload controller.
34
- *
35
- * This method never returns a rejected promise.
36
36
  */
37
- createDefaultRights(): Promise<void>;
38
- private createDefaultUsers;
39
- private createDefaultProfiles;
40
- private createDefaultRoles;
37
+ registerDefaultRights(): void;
38
+ private registerDefaultUser;
39
+ private registerDefaultProfile;
40
+ private registerDefaultRole;
41
41
  }
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  import { NamedMeasures } from "../../modules/decoder";
3
3
  import { MeasureDefinition } from "../../modules/measure";
4
4
  import { DeviceManagerPlugin } from "../DeviceManagerPlugin";
@@ -1,4 +1,4 @@
1
- import { KDocument } from "kuzzle";
1
+ import { KDocument } from "kuzzle-sdk";
2
2
  import { DeviceManagerPlugin } from "../../core";
3
3
  import { AssetHistoryEvent } from "./types/AssetHistoryContent";
4
4
  import { AssetContent } from "./types/AssetContent";
@@ -1,4 +1,5 @@
1
- import { JSONObject, KDocument, KHit, SearchResult, User } from "kuzzle";
1
+ import { User } from "kuzzle";
2
+ import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle-sdk";
2
3
  import { Metadata } from "../shared";
3
4
  import { DeviceManagerPlugin } from "../../core";
4
5
  import { AssetContent } from "./types/AssetContent";
@@ -1,4 +1,4 @@
1
- import { KDocument } from "kuzzle";
1
+ import { KDocument } from "kuzzle-sdk";
2
2
  import { AssetContent, AssetMeasureContext } from "../types/AssetContent";
3
3
  export declare class AssetSerializer {
4
4
  static id(model: string, reference: string): string;
@@ -1,4 +1,4 @@
1
- import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle";
1
+ import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle-sdk";
2
2
  import { MeasureContent } from "../../../modules/measure";
3
3
  import { Metadata } from "../../shared";
4
4
  import { AssetContent } from "./AssetContent";
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  import { DigitalTwinContent, Metadata } from "../../shared";
3
3
  /**
4
4
  * Asset document content
@@ -1,4 +1,4 @@
1
- import { KDocument } from "kuzzle";
1
+ import { KDocument } from "kuzzle-sdk";
2
2
  import { Metadata } from "../../../modules/shared";
3
3
  import { AssetContent } from "./AssetContent";
4
4
  import { AssetHistoryEvent } from "./AssetHistoryContent";
@@ -1,4 +1,4 @@
1
- import { JSONObject, KDocumentContent } from "kuzzle";
1
+ import { JSONObject, KDocumentContent } from "kuzzle-sdk";
2
2
  import { Metadata } from "../../shared";
3
3
  import { AssetContent } from "./AssetContent";
4
4
  export type AssetHistoryEventMeasure = {
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  import { DecodedMeasurement } from "../measure";
3
3
  import { Decoder } from "./Decoder";
4
4
  /**
@@ -1,4 +1,5 @@
1
- import { HttpRoute, JSONObject, KuzzleRequest } from "kuzzle";
1
+ import { HttpRoute, KuzzleRequest } from "kuzzle";
2
+ import { JSONObject } from "kuzzle-sdk";
2
3
  import { DecodedPayload } from "./DecodedPayload";
3
4
  import { DecoderContent } from "./types/DecoderContent";
4
5
  /**
@@ -1,5 +1,8 @@
1
- import { JSONObject, KuzzleRequest } from "kuzzle";
1
+ import { KuzzleRequest } from "kuzzle";
2
+ import { JSONObject, KDocument } from "kuzzle-sdk";
2
3
  import { DeviceManagerPlugin } from "../../core";
4
+ import { DeviceContent } from "../device";
5
+ import { DecodedMeasurement } from "../measure";
3
6
  import { Decoder } from "./Decoder";
4
7
  export declare class PayloadService {
5
8
  private config;
@@ -16,6 +19,9 @@ export declare class PayloadService {
16
19
  receive(request: KuzzleRequest, decoder: Decoder, { refresh }?: any): Promise<{
17
20
  valid: boolean;
18
21
  }>;
22
+ receiveFormated(device: KDocument<DeviceContent>, measurements: DecodedMeasurement[], { payloadUuids }?: {
23
+ payloadUuids?: string[];
24
+ }): Promise<void>;
19
25
  /**
20
26
  * Method used to save the payload and catch + log the error if any.
21
27
  *
@@ -30,5 +36,5 @@ export declare class PayloadService {
30
36
  prune(days: number, onlyValid: boolean, { deviceModel }?: {
31
37
  deviceModel?: string;
32
38
  }): Promise<number>;
33
- receiveUnknown(deviceModel: string, payload: JSONObject): Promise<void>;
39
+ receiveUnknown(deviceModel: string, payload: JSONObject, apiAction: string): Promise<void>;
34
40
  }
@@ -14,5 +14,8 @@ export declare const payloadsMappings: {
14
14
  valid: {
15
15
  type: string;
16
16
  };
17
+ apiAction: {
18
+ type: string;
19
+ };
17
20
  };
18
21
  };
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  interface PayloadsControllerRequest {
3
3
  controller: "device-manager/payloads";
4
4
  }
@@ -0,0 +1,15 @@
1
+ import { KDocument } from "kuzzle-sdk";
2
+ import { DeviceContent } from "../../device";
3
+ import { DecodedMeasurement } from "../../measure";
4
+ /**
5
+ * @internal
6
+ */
7
+ export type AskPayloadReceiveFormated = {
8
+ name: "ask:device-manager:payload:receive-formated";
9
+ payload: {
10
+ device: KDocument<DeviceContent>;
11
+ measures: DecodedMeasurement[];
12
+ payloadUuids: string[];
13
+ };
14
+ result: void;
15
+ };
@@ -1,6 +1,8 @@
1
- import { JSONObject, KDocument, KHit, Plugin, SearchResult, User } from "kuzzle";
1
+ import { Plugin, User } from "kuzzle";
2
+ import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle-sdk";
2
3
  import { AssetContent } from "./../asset";
3
4
  import { Metadata } from "../shared";
5
+ import { DecodedMeasurement } from "../measure";
4
6
  import { DeviceContent } from "./types/DeviceContent";
5
7
  import { ApiDeviceLinkAssetRequest, ApiDeviceGetMeasuresResult } from "./types/DeviceApi";
6
8
  export declare class DeviceService {
@@ -64,6 +66,7 @@ export declare class DeviceService {
64
66
  asset: KDocument<AssetContent>;
65
67
  device: KDocument<DeviceContent>;
66
68
  }>;
69
+ receiveMeasures(engineId: string, deviceId: string, measures: DecodedMeasurement[], payloadUuids: string[]): Promise<void>;
67
70
  /**
68
71
  * Checks if the asset does not already have a linked device using one of the
69
72
  * requested measure names.
@@ -100,4 +103,6 @@ export declare class DeviceService {
100
103
  private checkEngineExists;
101
104
  private checkAttachedToEngine;
102
105
  private getEngine;
106
+ private getDeviceModel;
107
+ private getAssetModel;
103
108
  }
@@ -30,4 +30,5 @@ export declare class DevicesController {
30
30
  */
31
31
  unlinkAsset(request: KuzzleRequest): Promise<ApiDeviceUnlinkAssetResult>;
32
32
  getMeasures(request: KuzzleRequest): Promise<ApiDeviceGetMeasuresResult>;
33
+ receiveMeasures(request: KuzzleRequest): Promise<void>;
33
34
  }
@@ -1,4 +1,4 @@
1
- import { KDocument } from "kuzzle";
1
+ import { KDocument } from "kuzzle-sdk";
2
2
  import { DeviceContent } from "../types/DeviceContent";
3
3
  export declare class DeviceSerializer {
4
4
  static id(model: string, reference: string): string;
@@ -1,5 +1,5 @@
1
- import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle";
2
- import { MeasureContent } from "../../measure";
1
+ import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle-sdk";
2
+ import { DecodedMeasurement, MeasureContent } from "../../measure";
3
3
  import { AssetContent } from "../../asset";
4
4
  import { Metadata } from "../../shared";
5
5
  import { DeviceContent } from "./DeviceContent";
@@ -130,4 +130,18 @@ export type ApiDeviceGetMeasuresResult = {
130
130
  measures: Array<KDocument<MeasureContent<JSONObject>>>;
131
131
  total: number;
132
132
  };
133
+ export interface ApiDeviceReceiveMeasuresRequest<TMeasureValues extends JSONObject = JSONObject> extends DevicesControllerRequest {
134
+ action: "receiveMeasures";
135
+ _id: string;
136
+ body: {
137
+ payloadUuids?: string[];
138
+ measures: Array<{
139
+ measureName: DecodedMeasurement<TMeasureValues>["measureName"];
140
+ measuredAt?: DecodedMeasurement<TMeasureValues>["measuredAt"];
141
+ type: DecodedMeasurement<TMeasureValues>["type"];
142
+ values: DecodedMeasurement<TMeasureValues>["values"];
143
+ }>;
144
+ };
145
+ }
146
+ export type ApiDeviceReceiveMeasuresResult = void;
133
147
  export {};
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  import { DigitalTwinContent, Metadata } from "../../shared";
3
3
  /**
4
4
  * Device document content
@@ -1,4 +1,5 @@
1
- import { KDocument, User } from "kuzzle";
1
+ import { User } from "kuzzle";
2
+ import { KDocument } from "kuzzle-sdk";
2
3
  import { Metadata } from "../../../modules/shared";
3
4
  import { DeviceContent } from "./DeviceContent";
4
5
  export type EventDeviceUpdateBefore = {
@@ -1,4 +1,4 @@
1
- import { JSONObject, KDocumentContent } from "kuzzle";
1
+ import { JSONObject, KDocumentContent } from "kuzzle-sdk";
2
2
  import { Metadata } from "../../../modules/shared";
3
3
  import { AssetMeasureContext } from "../../../modules/asset";
4
4
  export type MeasureOriginDevice = {
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  /**
3
3
  * Represents a measure definition registered by the Device Manager
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JSONObject, KDocument } from "kuzzle";
1
+ import { JSONObject, KDocument } from "kuzzle-sdk";
2
2
  import { DeviceContent } from "../../../modules/device";
3
3
  import { AssetContent } from "../../../modules/asset";
4
4
  import { Metadata } from "../../../modules/shared";
@@ -6,16 +6,15 @@ import { DecodedMeasurement, MeasureContent } from "./MeasureContent";
6
6
  /**
7
7
  * @internal
8
8
  */
9
- export type EventMeasureIngest = {
9
+ export type AskMeasureIngest = {
10
10
  name: "device-manager:measures:ingest";
11
- args: [
12
- {
13
- device: KDocument<DeviceContent>;
14
- measurements: DecodedMeasurement<JSONObject>[];
15
- metadata: Metadata;
16
- payloadUuids: string[];
17
- }
18
- ];
11
+ payload: {
12
+ device: KDocument<DeviceContent>;
13
+ measurements: DecodedMeasurement<JSONObject>[];
14
+ metadata: Metadata;
15
+ payloadUuids: string[];
16
+ };
17
+ result: void;
19
18
  };
20
19
  /**
21
20
  * Event before starting to process new measures.
@@ -1,4 +1,4 @@
1
- import { JSONObject, KDocument } from "kuzzle";
1
+ import { JSONObject, KDocument } from "kuzzle-sdk";
2
2
  import { DeviceManagerPlugin } from "../../core";
3
3
  import { AssetModelContent, DeviceModelContent, MeasureModelContent } from "./types/ModelContent";
4
4
  export declare class ModelService {
@@ -1,4 +1,4 @@
1
- import { JSONObject, KDocument } from "kuzzle";
1
+ import { JSONObject, KDocument } from "kuzzle-sdk";
2
2
  import { AssetModelContent, DeviceModelContent, MeasureModelContent } from "./ModelContent";
3
3
  interface ModelsControllerRequest {
4
4
  controller: "device-manager/models";
@@ -1,4 +1,4 @@
1
- import { JSONObject, KDocumentContent } from "kuzzle";
1
+ import { JSONObject, KDocumentContent } from "kuzzle-sdk";
2
2
  import { NamedMeasures } from "../../../modules/decoder";
3
3
  import { MeasureDefinition } from "../../measure";
4
4
  export interface MeasureModelContent extends KDocumentContent {
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  import { Decoder, NamedMeasures } from "../../../modules/decoder";
3
3
  /**
4
4
  * Define an asset model
@@ -5,5 +5,4 @@ export * from "./types/KuzzleRole";
5
5
  export * from "./utils/lock";
6
6
  export * from "./utils/flattenObject";
7
7
  export * from "./utils/ask";
8
- export * from "./utils/snakeCase";
9
8
  export * from "./Module";
@@ -1,4 +1,4 @@
1
- import { JSONObject, KDocumentContent } from "kuzzle";
1
+ import { JSONObject, KDocumentContent } from "kuzzle-sdk";
2
2
  import { EmbeddedMeasure } from "./EmbeddedMeasure";
3
3
  import { Metadata } from "./Metadata";
4
4
  export interface DigitalTwinContent<TMeasures extends JSONObject = JSONObject, TMetadata extends Metadata = Metadata> extends KDocumentContent {
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  export type EmbeddedMeasure<TMeasureValue extends JSONObject = JSONObject> = {
3
3
  /**
4
4
  * Payloads that created this measure.
@@ -4,5 +4,5 @@ export type AskEventDefinition = {
4
4
  result: any;
5
5
  };
6
6
  export type AskEventHandler<TAskEventDefinition extends AskEventDefinition = AskEventDefinition> = (payload?: TAskEventDefinition["payload"]) => Promise<TAskEventDefinition["result"]>;
7
- export declare function onAsk<TAskEventDefinition extends AskEventDefinition = AskEventDefinition>(event: TAskEventDefinition["name"], handler: AskEventHandler<TAskEventDefinition>): Promise<any>;
7
+ export declare function onAsk<TAskEventDefinition extends AskEventDefinition = AskEventDefinition>(event: TAskEventDefinition["name"], handler: AskEventHandler<TAskEventDefinition>): any;
8
8
  export declare function ask<TAskEventDefinition extends AskEventDefinition = AskEventDefinition>(event: TAskEventDefinition["name"], payload?: TAskEventDefinition["payload"]): Promise<TAskEventDefinition["result"]>;
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle";
1
+ import { JSONObject } from "kuzzle-sdk";
2
2
  /**
3
3
  * Flatten an object transform:
4
4
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kuzzle-device-manager-types",
3
- "version": "2.0.9",
3
+ "version": "2.1.1",
4
4
  "description": "Shared types for Kuzzle Device Manager",
5
5
  "author": "The Kuzzle Team (support@kuzzle.io)",
6
6
  "types": "dist/index.d.ts",
@@ -1,7 +0,0 @@
1
- /**
2
- * Convert a string to snake_case
3
- *
4
- * @todo use Inflector.snakeCase when
5
- * https://github.com/kuzzleio/kuzzle/pull/2415 is released
6
- */
7
- export declare function snakeCase(str: string): string;