kuzzle-device-manager-types 2.3.2 → 2.4.0-beta.1-2
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.
- package/dist/lib/modules/asset/AssetsController.d.ts +5 -4
- package/dist/lib/modules/asset/types/AssetApi.d.ts +13 -0
- package/dist/lib/modules/device/DevicesController.d.ts +5 -4
- package/dist/lib/modules/device/collections/deviceMappings.d.ts +3 -0
- package/dist/lib/modules/device/types/DeviceApi.d.ts +13 -0
- package/dist/lib/modules/measure/MeasureExporter.d.ts +23 -33
- package/dist/lib/modules/shared/index.d.ts +1 -0
- package/dist/lib/modules/shared/services/AbstractExporter.d.ts +53 -0
- package/dist/lib/modules/shared/services/DigitalTwinExporter.d.ts +14 -0
- package/dist/lib/modules/shared/services/index.d.ts +2 -0
- package/dist/lib/modules/shared/types/DigitalTwinContent.d.ts +1 -0
- package/dist/tests/helpers/payloads.d.ts +36 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ControllerDefinition,
|
|
1
|
+
import { ControllerDefinition, KuzzleRequest } from "kuzzle";
|
|
2
2
|
import { DeviceManagerPlugin } from "../plugin";
|
|
3
3
|
import { AssetService } from "./AssetService";
|
|
4
4
|
import { ApiAssetCreateResult, ApiAssetDeleteResult, ApiAssetGetMeasuresResult, ApiAssetGetResult, ApiAssetSearchResult, ApiAssetUpdateResult } from "./types/AssetApi";
|
|
@@ -6,6 +6,8 @@ export declare class AssetsController {
|
|
|
6
6
|
private plugin;
|
|
7
7
|
private assetService;
|
|
8
8
|
definition: ControllerDefinition;
|
|
9
|
+
private exporter;
|
|
10
|
+
private measureExporter;
|
|
9
11
|
constructor(plugin: DeviceManagerPlugin, assetService: AssetService);
|
|
10
12
|
get(request: KuzzleRequest): Promise<ApiAssetGetResult>;
|
|
11
13
|
update(request: KuzzleRequest): Promise<ApiAssetUpdateResult>;
|
|
@@ -13,7 +15,6 @@ export declare class AssetsController {
|
|
|
13
15
|
delete(request: KuzzleRequest): Promise<ApiAssetDeleteResult>;
|
|
14
16
|
search(request: KuzzleRequest): Promise<ApiAssetSearchResult>;
|
|
15
17
|
getMeasures(request: KuzzleRequest): Promise<ApiAssetGetMeasuresResult>;
|
|
16
|
-
exportMeasures(request: KuzzleRequest): Promise<
|
|
17
|
-
|
|
18
|
-
}>;
|
|
18
|
+
exportMeasures(request: KuzzleRequest): Promise<any>;
|
|
19
|
+
export(request: KuzzleRequest): Promise<any>;
|
|
19
20
|
}
|
|
@@ -54,6 +54,7 @@ export interface ApiAssetGetMeasuresRequest extends AssetsControllerRequest {
|
|
|
54
54
|
startAt?: string;
|
|
55
55
|
endAt?: string;
|
|
56
56
|
type?: string;
|
|
57
|
+
lang?: "koncorde" | "elasticsearch";
|
|
57
58
|
body?: {
|
|
58
59
|
query?: JSONObject;
|
|
59
60
|
sort?: JSONObject;
|
|
@@ -75,6 +76,7 @@ export interface ApiAssetExportMeasuresRequest extends AssetsControllerRequest {
|
|
|
75
76
|
startAt?: string;
|
|
76
77
|
endAt?: string;
|
|
77
78
|
type?: string;
|
|
79
|
+
lang?: "koncorde" | "elasticsearch";
|
|
78
80
|
body?: {
|
|
79
81
|
query?: JSONObject;
|
|
80
82
|
sort?: JSONObject;
|
|
@@ -83,4 +85,15 @@ export interface ApiAssetExportMeasuresRequest extends AssetsControllerRequest {
|
|
|
83
85
|
export type ApiAssetExportMeasuresResult = {
|
|
84
86
|
link: string;
|
|
85
87
|
};
|
|
88
|
+
export interface ApiAssetExportRequest extends AssetsControllerRequest {
|
|
89
|
+
action: "export";
|
|
90
|
+
lang?: "koncorde" | "elasticsearch";
|
|
91
|
+
body?: {
|
|
92
|
+
query?: JSONObject;
|
|
93
|
+
sort?: JSONObject;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export type ApiAssetExportResult = {
|
|
97
|
+
link: string;
|
|
98
|
+
};
|
|
86
99
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ControllerDefinition,
|
|
1
|
+
import { ControllerDefinition, KuzzleRequest } from "kuzzle";
|
|
2
2
|
import { DeviceManagerPlugin } from "../plugin";
|
|
3
3
|
import { DeviceService } from "./DeviceService";
|
|
4
4
|
import { ApiDeviceAttachEngineResult, ApiDeviceCreateResult, ApiDeviceDeleteResult, ApiDeviceDetachEngineResult, ApiDeviceGetResult, ApiDeviceLinkAssetResult, ApiDeviceSearchResult, ApiDeviceUnlinkAssetResult, ApiDeviceUpdateResult, ApiDeviceGetMeasuresResult } from "./types/DeviceApi";
|
|
@@ -6,6 +6,8 @@ export declare class DevicesController {
|
|
|
6
6
|
private plugin;
|
|
7
7
|
private deviceService;
|
|
8
8
|
definition: ControllerDefinition;
|
|
9
|
+
private exporter;
|
|
10
|
+
private measureExporter;
|
|
9
11
|
constructor(plugin: DeviceManagerPlugin, deviceService: DeviceService);
|
|
10
12
|
get(request: KuzzleRequest): Promise<ApiDeviceGetResult>;
|
|
11
13
|
update(request: KuzzleRequest): Promise<ApiDeviceUpdateResult>;
|
|
@@ -32,8 +34,7 @@ export declare class DevicesController {
|
|
|
32
34
|
*/
|
|
33
35
|
unlinkAsset(request: KuzzleRequest): Promise<ApiDeviceUnlinkAssetResult>;
|
|
34
36
|
getMeasures(request: KuzzleRequest): Promise<ApiDeviceGetMeasuresResult>;
|
|
35
|
-
exportMeasures(request: KuzzleRequest): Promise<
|
|
36
|
-
link: string;
|
|
37
|
-
}>;
|
|
37
|
+
exportMeasures(request: KuzzleRequest): Promise<any>;
|
|
38
38
|
receiveMeasures(request: KuzzleRequest): Promise<void>;
|
|
39
|
+
export(request: KuzzleRequest): Promise<any>;
|
|
39
40
|
}
|
|
@@ -121,6 +121,7 @@ export interface ApiDeviceGetMeasuresRequest extends DevicesControllerRequest {
|
|
|
121
121
|
startAt?: string;
|
|
122
122
|
endAt?: string;
|
|
123
123
|
type?: string;
|
|
124
|
+
lang?: "koncorde" | "elasticsearch";
|
|
124
125
|
body?: {
|
|
125
126
|
query?: JSONObject;
|
|
126
127
|
sort?: JSONObject;
|
|
@@ -142,6 +143,7 @@ export interface ApiDeviceExportMeasuresRequest extends DevicesControllerRequest
|
|
|
142
143
|
startAt?: string;
|
|
143
144
|
endAt?: string;
|
|
144
145
|
type?: string;
|
|
146
|
+
lang?: "koncorde" | "elasticsearch";
|
|
145
147
|
body?: {
|
|
146
148
|
query?: JSONObject;
|
|
147
149
|
sort?: JSONObject;
|
|
@@ -164,4 +166,15 @@ export interface ApiDeviceReceiveMeasuresRequest<TMeasureValues extends JSONObje
|
|
|
164
166
|
};
|
|
165
167
|
}
|
|
166
168
|
export type ApiDeviceReceiveMeasuresResult = void;
|
|
169
|
+
export interface ApiDeviceExportRequest extends DevicesControllerRequest {
|
|
170
|
+
action: "export";
|
|
171
|
+
lang?: "koncorde" | "elasticsearch";
|
|
172
|
+
body?: {
|
|
173
|
+
query?: JSONObject;
|
|
174
|
+
sort?: JSONObject;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
export type ApiDeviceExportResult = {
|
|
178
|
+
link: string;
|
|
179
|
+
};
|
|
167
180
|
export {};
|
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { UUID } from "node:crypto";
|
|
4
|
+
import { KHit, User } from "kuzzle";
|
|
5
|
+
import { AbstractExporter, Column, ExportParams } from "../shared";
|
|
5
6
|
import { MeasureContent } from "./exports";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
from?: number;
|
|
10
|
-
size?: number;
|
|
7
|
+
interface MeasureSearchParams extends ExportParams {
|
|
8
|
+
id: string;
|
|
9
|
+
type?: string;
|
|
11
10
|
startAt?: string;
|
|
12
11
|
endAt?: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
sort: JSONObject;
|
|
12
|
+
}
|
|
13
|
+
interface MeasuresSearchOptions {
|
|
14
|
+
from?: number;
|
|
15
|
+
size?: number;
|
|
16
|
+
}
|
|
17
|
+
interface MeasureExportParams extends ExportParams {
|
|
20
18
|
id: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
private get sdk();
|
|
27
|
-
constructor(plugin: DeviceManagerPlugin, engineId: string, { target }?: {
|
|
28
|
-
target?: "asset" | "device";
|
|
29
|
-
});
|
|
19
|
+
model: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class MeasureExporter extends AbstractExporter<MeasureExportParams> {
|
|
22
|
+
protected exportRedisKey(engineId: string, exportId: string): string;
|
|
23
|
+
protected getLink(engineId: string, exportId: UUID, params: MeasureExportParams): string;
|
|
30
24
|
/**
|
|
31
25
|
* Searches for measures and return them in a standard JSON
|
|
32
26
|
*/
|
|
33
|
-
search(
|
|
34
|
-
measures:
|
|
27
|
+
search(engineId: string, params: MeasureSearchParams, options?: MeasuresSearchOptions): Promise<{
|
|
28
|
+
measures: KHit<MeasureContent<any, any>>[];
|
|
35
29
|
total: number;
|
|
36
30
|
}>;
|
|
37
31
|
/**
|
|
@@ -43,20 +37,16 @@ export declare class MeasureExporter {
|
|
|
43
37
|
*
|
|
44
38
|
* Never return a rejected promise and write potential error on the stream
|
|
45
39
|
*/
|
|
46
|
-
prepareExport(
|
|
47
|
-
|
|
48
|
-
}>;
|
|
40
|
+
prepareExport(engineId: string, user: User, params: MeasureSearchParams): Promise<string>;
|
|
41
|
+
protected formatHit(columns: Column[], hit: KHit<MeasureContent>): any[];
|
|
49
42
|
/**
|
|
50
43
|
* Retrieve a prepared export and write each document as a CSV in the stream
|
|
51
44
|
*
|
|
52
45
|
* This method never returns a rejected promise, but write potential error in
|
|
53
46
|
* the stream.
|
|
54
47
|
*/
|
|
55
|
-
sendExport(
|
|
48
|
+
sendExport(engineId: string, exportId: string): Promise<import("stream").PassThrough>;
|
|
56
49
|
private generateMeasureColumns;
|
|
57
|
-
getExport(exportId: string): Promise<ExportParams>;
|
|
58
|
-
private exportRedisKey;
|
|
59
50
|
private prepareMeasureSearch;
|
|
60
|
-
private getEngine;
|
|
61
51
|
}
|
|
62
52
|
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { UUID } from "node:crypto";
|
|
4
|
+
import { PassThrough, Readable } from "node:stream";
|
|
5
|
+
import { JSONObject, KDocumentContentGeneric, KHit, SearchResult, User } from "kuzzle";
|
|
6
|
+
import { EngineContent } from "kuzzle-plugin-commons";
|
|
7
|
+
import { DeviceManagerPlugin, InternalCollection } from "../../plugin";
|
|
8
|
+
export interface ExporterOption {
|
|
9
|
+
/**
|
|
10
|
+
* Expiration time of export in seconds before being invalid
|
|
11
|
+
*/
|
|
12
|
+
expireTime: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ExportParams {
|
|
15
|
+
query: JSONObject;
|
|
16
|
+
sort?: JSONObject;
|
|
17
|
+
lang?: "elasticsearch" | "koncorde";
|
|
18
|
+
}
|
|
19
|
+
export interface Column {
|
|
20
|
+
header: string;
|
|
21
|
+
path: string;
|
|
22
|
+
isMeasure?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare abstract class AbstractExporter<P extends ExportParams = ExportParams> {
|
|
25
|
+
protected plugin: DeviceManagerPlugin;
|
|
26
|
+
protected target: InternalCollection;
|
|
27
|
+
protected config: ExporterOption;
|
|
28
|
+
constructor(plugin: DeviceManagerPlugin, target: InternalCollection, config?: Partial<ExporterOption>);
|
|
29
|
+
protected get sdk(): import("kuzzle").EmbeddedSDK;
|
|
30
|
+
protected get ms(): any;
|
|
31
|
+
protected get log(): {
|
|
32
|
+
debug: (message: any) => void;
|
|
33
|
+
error: (message: any) => void;
|
|
34
|
+
info: (message: any) => void;
|
|
35
|
+
silly: (message: any) => void;
|
|
36
|
+
verbose: (message: any) => void;
|
|
37
|
+
warn: (message: any) => void;
|
|
38
|
+
};
|
|
39
|
+
protected getEngine(engineId: string): Promise<EngineContent>;
|
|
40
|
+
protected abstract exportRedisKey(engineId: string, exportId: string): string;
|
|
41
|
+
protected abstract getLink(engineId: string, exportId: UUID, params: P): string;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieve a prepared export and write each document as a CSV in the stream
|
|
44
|
+
*
|
|
45
|
+
* This method never returns a rejected promise, but write potential error in
|
|
46
|
+
* the stream.
|
|
47
|
+
*/
|
|
48
|
+
abstract sendExport(engineId: string, exportId: string): Promise<Readable>;
|
|
49
|
+
prepareExport(engineId: string, user: User, params: P): Promise<string>;
|
|
50
|
+
protected formatHit(columns: Column[], hit: KHit<KDocumentContentGeneric>): string[];
|
|
51
|
+
getExport(engineId: string, exportId: string): Promise<P>;
|
|
52
|
+
getExportStream(request: SearchResult<KHit<KDocumentContentGeneric>>, columns: Column[]): Promise<PassThrough>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { UUID } from "node:crypto";
|
|
4
|
+
import { AbstractExporter } from "./AbstractExporter";
|
|
5
|
+
export declare class DigitalTwinExporter extends AbstractExporter {
|
|
6
|
+
protected exportRedisKey(engineId: string, exportId: string): string;
|
|
7
|
+
protected getLink(engineId: string, exportId: UUID): string;
|
|
8
|
+
sendExport(engineId: string, exportId: string): Promise<import("stream").PassThrough>;
|
|
9
|
+
/**
|
|
10
|
+
* Get the deduplicated Named Measures get from models
|
|
11
|
+
*/
|
|
12
|
+
private getNamedMeasures;
|
|
13
|
+
private generateMeasureColumns;
|
|
14
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { JSONObject, Kuzzle } from "kuzzle-sdk";
|
|
2
|
+
type MeasureDated<T> = {
|
|
3
|
+
value: T;
|
|
4
|
+
measuredAt: number;
|
|
5
|
+
};
|
|
6
|
+
export type MeasureValue<T> = T | MeasureDated<T>;
|
|
7
|
+
export declare function isMeasureDated<T>(measure: MeasureValue<T>): measure is MeasureDated<T>;
|
|
8
|
+
export interface Location {
|
|
9
|
+
lat: number;
|
|
10
|
+
lon: number;
|
|
11
|
+
accuracy?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface Acceleration {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
z: number;
|
|
17
|
+
accuracy: number;
|
|
18
|
+
}
|
|
19
|
+
export type DummyTempSimplePayload = {
|
|
20
|
+
deviceEUI: string;
|
|
21
|
+
temperature: MeasureValue<number>;
|
|
22
|
+
measuredAt?: number;
|
|
23
|
+
battery?: MeasureValue<number>;
|
|
24
|
+
acceleration?: MeasureValue<Acceleration>;
|
|
25
|
+
metadata?: JSONObject;
|
|
26
|
+
};
|
|
27
|
+
export type DummyTempPayload = DummyTempSimplePayload | {
|
|
28
|
+
measurements: DummyTempSimplePayload[];
|
|
29
|
+
};
|
|
30
|
+
export type DummyTempPositionPayload = DummyTempPayload & {
|
|
31
|
+
location: MeasureValue<Location>;
|
|
32
|
+
};
|
|
33
|
+
export declare function sendDummyTempPayloads(sdk: Kuzzle, payloads: DummyTempPayload[]): Promise<void>;
|
|
34
|
+
export declare function sendDummyTempPositionPayloads(sdk: Kuzzle, payloads: DummyTempPositionPayload[]): Promise<void>;
|
|
35
|
+
export declare function sendPayloads(sdk: Kuzzle, action: string, payloads: JSONObject[]): Promise<any>;
|
|
36
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle-device-manager-types",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-beta.1-2",
|
|
4
4
|
"description": "Shared types for Kuzzle Device Manager",
|
|
5
5
|
"author": "The Kuzzle Team (support@kuzzle.io)",
|
|
6
6
|
"main": "index.js",
|
|
@@ -17,4 +17,4 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist/**/*.d.ts"
|
|
19
19
|
]
|
|
20
|
-
}
|
|
20
|
+
}
|