import { Plugin, PluginContext } from "kuzzle"; import { JSONObject } from "kuzzle-sdk"; import { MeasureDefinition } from "../measure"; import { AssetModelDefinition, DeviceModelDefinition, GroupModelDefinition } from "../model"; import { DeviceManagerConfiguration } from "./types/DeviceManagerConfiguration"; export declare class DeviceManagerPlugin extends Plugin { config: DeviceManagerConfiguration; private deviceManagerEngine; private adminConfigManager; private engineConfigManager; private engineController; private assetModule; private deviceModule; private decoderModule; private measureModule; private modelModule; private modelsRegister; private decodersRegister; private get sdk(); get models(): { /** * Register an asset model * * @param engineGroup Engine group name * @param model Name of the asset model. Must follow a naming convention in PascalCase. * @param definition Object containing the asset model definition, including: * - measures: Array describing measure names and their types. * - metadataMappings: Definition of metadata mappings, specifying types for each metadata field. * - defaultMetadata: Default values for metadata fields, applied when actual data is not provided. * - metadataDetails: Optional detailed descriptions for each metadata, including localizations, group association and definition. * - metadataGroups: Optional description of metadata groups, organizing metadata logically, with localizations for group names. * - tooltipModels: Optional tooltip model list, containing each labels and tooltip content to display. * * @example * ``` * deviceManager.models.registerAsset( * "logistic", * "Container", * { * measures: [ * { name: "temperatureExt", type: "temperature" }, * { name: "temperatureInt", type: "temperature" }, * { name: "position", type: "position" }, * ], * metadataMappings: { * weight: { type: "integer" }, * height: { type: "integer" }, * }, * defaultMetadata: { * height: 20 * }, * metadataDetails: { * "extTemp": { * "group": "environment", * "locales": { * "en": { * "friendlyName": "External Temperature", * "description": "The temperature outside the container" * }, * "fr": { * "friendlyName": "Température Externe", * "description": "La température à l'extérieur du conteneur" * } * } * } * }, * metadataGroups: { * "environment": { * "locales": { * "en": { * "groupFriendlyName": "Environment" * }, * "fr": { * "groupFriendlyName": "Environnement" * } * } * } * }, * tooltipModels: { * "defaultTooltipKey": { * "tooltipLabel": "Default Tooltip Model", * "content": [ * { * "category": "metadata", * "label": { * "locales": { * "en": { * "friendlyName": "Container position", * "description": "" * }, * "fr": { * "friendlyName": "Position du conteneur", * "description": "" * } * } * }, * "metadataPath": "geolocation" * }, * { * "category": "measure", * "label": { * "locales": { * "en": { * "friendlyName": "External temperature", * "description": "" * }, * "fr": { * "friendlyName": "Température extérieure", * "description": "" * } * } * }, * "measureSlot": "externalTemperature", * "measureValuePath": "externalTemperature", * "suffix": "°C" * } * ] * } * } * } * ); * ``` */ registerAsset: (engineGroup: string, model: string, definition: AssetModelDefinition) => void; /** * Register a device. * * @param model Name of the device model * @param definition Object containing the device model definition, including: * - decoder: Decoder used to decode payloads * - metadataMappings: Metadata mappings definition * - defaultMetadata: Default metadata values * - metadataDetails: Localizations, detailed metadata descriptions and definition * - metadataGroups: Groups for organizing metadata, with localizations * * @example * ``` * deviceManager.models.registerDevice( * "Abeeway", * { * decoder: new DummyTempPositionDecoder(), * metadataMappings: { * serial: { type: "keyword" }, * }, * defaultMetadata: { * company: "Acme Inc" * }, * metadataDetails: { * sensorVersion: { * group: "sensorSpecs", * locales: { * en: { * friendlyName: "Sensor version", * description: "Firmware version of the sensor" * }, * fr: { * friendlyName: "Version du capteur", * description: "Version du micrologiciel du capteur" * } * } * } * }, * metadataGroups: { * sensorSpecs: { * locales: { * en: { * groupFriendlyName: "Sensors specifications" * }, * fr: { * groupFriendlyName: "Spécifications des capteurs" * } * } * } * } * } * ); * ``` */ registerDevice: (model: string, definition: DeviceModelDefinition) => void; /** * Register a group. * * @param model Name of the group model * @param definition Object containing the group model definition, including: * - metadataMappings: Metadata mappings definition * - defaultMetadata: Default metadata values * - metadataDetails: Localizations, detailed metadata descriptions and definition * - metadataGroups: Groups for organizing metadata, with localizations * * @example * ``` * deviceManager.models.registerGroup( * "Parking", * { * metadataMappings: { * geolocation: { type: "geo_point" }, * }, * defaultMetadata: { * * }, * metadataDetails: { * geolocation: { * group: "access", * locales: { * en: { * friendlyName: "Parking location", * description: "GPS position of the parking" * }, * fr: { * friendlyName: "Emplacement du parking", * description: "Position GPS du parking" * } * } * } * }, * metadataGroups: { * access: { * locales: { * en: { * groupFriendlyName: "Parking access info" * }, * fr: { * groupFriendlyName: "Information d'accès au parking" * } * } * } * } * } * ); * ``` */ registerGroup: (engineGroup: string, model: string, definition: GroupModelDefinition) => void; /** * Register a new measure * * @param name Name of the measure * @param measureDefinition Values of the measure * * @example * ``` * deviceManager.models.registerMeasure("acceleration", { * x: { type: "float" }, * y: { type: "float" }, * z: { type: "float" }, * }); * ``` */ registerMeasure: (name: string, measureDefinition: MeasureDefinition) => void; }; constructor(); /** * Init the plugin */ init(config: JSONObject, context: PluginContext): Promise; /** * Initialize the administration index of the plugin */ private initDatabase; /** * Merge custom mappings defined in the Decoder into the "payloads" collection * mappings. * * Those custom mappings allow to search raw payloads more efficiently. */ private getPayloadsMappings; /** * Initialize the config document if it does not exists */ private initializeConfig; private pipeCheckEngine; }