kuzzle-device-manager-types 2.4.0-beta.1-1 → 2.4.0-beta.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.
@@ -1,9 +1,7 @@
1
1
  import { DeviceManagerPlugin } from "../plugin";
2
+ import { BaseService } from "../shared";
2
3
  import { AssetHistoryContent, AssetHistoryEvent } from "./types/AssetHistoryContent";
3
- export declare class AssetHistoryService {
4
- private context;
5
- private config;
6
- private get sdk();
4
+ export declare class AssetHistoryService extends BaseService {
7
5
  constructor(plugin: DeviceManagerPlugin);
8
6
  add<TAssetHistoryEvent extends AssetHistoryEvent>(engineId: string, histories: AssetHistoryContent[]): Promise<void>;
9
7
  }
@@ -1,38 +1,33 @@
1
- import { User } from "kuzzle";
1
+ import { KuzzleRequest, User } from "kuzzle";
2
2
  import { JSONObject, KDocument, KHit, SearchResult, mReplaceResponse } from "kuzzle-sdk";
3
3
  import { DeviceManagerPlugin } from "../plugin";
4
- import { Metadata } from "../shared";
4
+ import { Metadata, BaseService, SearchParams } from "../shared";
5
5
  import { AssetHistoryService } from "./AssetHistoryService";
6
6
  import { AssetContent } from "./types/AssetContent";
7
- export declare class AssetService {
8
- private context;
9
- private config;
7
+ import { ApiAssetMigrateTenantResult } from "./types/AssetApi";
8
+ export declare class AssetService extends BaseService {
10
9
  private assetHistoryService;
11
- private get sdk();
12
- private get app();
13
- private get impersonatedSdk();
14
10
  constructor(plugin: DeviceManagerPlugin, assetHistoryService: AssetHistoryService);
15
11
  registerAskEvents(): void;
16
- get(engineId: string, assetId: string): Promise<KDocument<AssetContent>>;
12
+ get(engineId: string, assetId: string, request: KuzzleRequest): Promise<KDocument<AssetContent>>;
17
13
  /**
18
- * Updates an asset metadata
14
+ * Update an asset metadata
19
15
  */
20
- update(user: User, engineId: string, assetId: string, metadata: Metadata, { refresh }: {
21
- refresh: any;
22
- }): Promise<KDocument<AssetContent>>;
23
- create(user: User, engineId: string, model: string, reference: string, metadata: JSONObject, { refresh }: {
24
- refresh: any;
25
- }): Promise<KDocument<AssetContent>>;
26
- delete(user: User, engineId: string, assetId: string, { refresh, strict }: {
27
- refresh: any;
28
- strict: boolean;
29
- }): Promise<void>;
30
- search(engineId: string, searchBody: JSONObject, { from, size, scroll, lang, }: {
31
- from?: number;
32
- size?: number;
33
- scroll?: string;
34
- lang?: string;
35
- }): Promise<SearchResult<KHit<AssetContent>>>;
16
+ update(engineId: string, assetId: string, metadata: Metadata, request: KuzzleRequest): Promise<KDocument<AssetContent>>;
17
+ /**
18
+ * Update or Create an asset metadata
19
+ */
20
+ upsert(engineId: string, assetId: string, model: string, reference: string, metadata: Metadata, request: KuzzleRequest): Promise<KDocument<AssetContent>>;
21
+ /**
22
+ * Create an asset metadata
23
+ */
24
+ create(engineId: string, model: string, reference: string, metadata: JSONObject, request: KuzzleRequest): Promise<KDocument<AssetContent>>;
25
+ /**
26
+ * Delete an asset metadata
27
+ */
28
+ delete(engineId: string, assetId: string, request: KuzzleRequest): Promise<void>;
29
+ search(engineId: string, searchParams: SearchParams, request: KuzzleRequest): Promise<SearchResult<KHit<AssetContent>>>;
30
+ migrateTenant(user: User, assetsList: string[], engineId: string, newEngineId: string): Promise<ApiAssetMigrateTenantResult>;
36
31
  /**
37
32
  * Replace an asset metadata
38
33
  */
@@ -1,7 +1,7 @@
1
- import { ControllerDefinition, HttpStream, KuzzleRequest } from "kuzzle";
1
+ import { ControllerDefinition, KuzzleRequest } from "kuzzle";
2
2
  import { DeviceManagerPlugin } from "../plugin";
3
3
  import { AssetService } from "./AssetService";
4
- import { ApiAssetCreateResult, ApiAssetDeleteResult, ApiAssetGetMeasuresResult, ApiAssetGetResult, ApiAssetSearchResult, ApiAssetUpdateResult } from "./types/AssetApi";
4
+ import { ApiAssetCreateResult, ApiAssetUpsertResult, ApiAssetDeleteResult, ApiAssetGetMeasuresResult, ApiAssetGetResult, ApiAssetSearchResult, ApiAssetUpdateResult, ApiAssetMigrateTenantResult } from "./types/AssetApi";
5
5
  export declare class AssetsController {
6
6
  private plugin;
7
7
  private assetService;
@@ -10,15 +10,13 @@ export declare class AssetsController {
10
10
  private measureExporter;
11
11
  constructor(plugin: DeviceManagerPlugin, assetService: AssetService);
12
12
  get(request: KuzzleRequest): Promise<ApiAssetGetResult>;
13
+ upsert(request: KuzzleRequest): Promise<ApiAssetUpsertResult>;
13
14
  update(request: KuzzleRequest): Promise<ApiAssetUpdateResult>;
14
15
  create(request: KuzzleRequest): Promise<ApiAssetCreateResult>;
15
16
  delete(request: KuzzleRequest): Promise<ApiAssetDeleteResult>;
16
17
  search(request: KuzzleRequest): Promise<ApiAssetSearchResult>;
17
18
  getMeasures(request: KuzzleRequest): Promise<ApiAssetGetMeasuresResult>;
18
- exportMeasures(request: KuzzleRequest): Promise<HttpStream | {
19
- link: string;
20
- }>;
21
- export(request: KuzzleRequest): Promise<HttpStream | {
22
- link: string;
23
- }>;
19
+ exportMeasures(request: KuzzleRequest): Promise<any>;
20
+ export(request: KuzzleRequest): Promise<any>;
21
+ migrateTenant(request: KuzzleRequest): Promise<ApiAssetMigrateTenantResult>;
24
22
  }
@@ -20,6 +20,17 @@ export interface ApiAssetUpdateRequest extends AssetsControllerRequest {
20
20
  };
21
21
  }
22
22
  export type ApiAssetUpdateResult = KDocument<AssetContent>;
23
+ export interface ApiAssetUpsertRequest extends AssetsControllerRequest {
24
+ action: "upsert";
25
+ _id: string;
26
+ refresh?: string;
27
+ body: {
28
+ model: string;
29
+ reference: string;
30
+ metadata: Metadata;
31
+ };
32
+ }
33
+ export type ApiAssetUpsertResult = KDocument<AssetContent>;
23
34
  export interface ApiAssetCreateRequest extends AssetsControllerRequest {
24
35
  action: "create";
25
36
  refresh?: string;
@@ -54,6 +65,7 @@ export interface ApiAssetGetMeasuresRequest extends AssetsControllerRequest {
54
65
  startAt?: string;
55
66
  endAt?: string;
56
67
  type?: string;
68
+ lang?: "koncorde" | "elasticsearch";
57
69
  body?: {
58
70
  query?: JSONObject;
59
71
  sort?: JSONObject;
@@ -75,6 +87,7 @@ export interface ApiAssetExportMeasuresRequest extends AssetsControllerRequest {
75
87
  startAt?: string;
76
88
  endAt?: string;
77
89
  type?: string;
90
+ lang?: "koncorde" | "elasticsearch";
78
91
  body?: {
79
92
  query?: JSONObject;
80
93
  sort?: JSONObject;
@@ -85,6 +98,7 @@ export type ApiAssetExportMeasuresResult = {
85
98
  };
86
99
  export interface ApiAssetExportRequest extends AssetsControllerRequest {
87
100
  action: "export";
101
+ lang?: "koncorde" | "elasticsearch";
88
102
  body?: {
89
103
  query?: JSONObject;
90
104
  sort?: JSONObject;
@@ -93,4 +107,16 @@ export interface ApiAssetExportRequest extends AssetsControllerRequest {
93
107
  export type ApiAssetExportResult = {
94
108
  link: string;
95
109
  };
110
+ export interface ApiAssetMigrateTenantRequest extends AssetsControllerRequest {
111
+ action: "migrateTenant";
112
+ engineId: string;
113
+ body: {
114
+ assetsList: string[];
115
+ newEngineId: string;
116
+ };
117
+ }
118
+ export type ApiAssetMigrateTenantResult = {
119
+ errors: string[];
120
+ successes: string[];
121
+ };
96
122
  export {};
@@ -49,4 +49,4 @@ export type AssetMeasureContext<TMetadata extends Metadata = Metadata> = {
49
49
  * Name of the measure for the Asset
50
50
  */
51
51
  measureName: string;
52
- } & Pick<AssetContent<JSONObject, TMetadata>, "model" | "reference" | "metadata">;
52
+ } & Pick<AssetContent<JSONObject, TMetadata>, "model" | "reference" | "metadata" | "groups">;
@@ -3,12 +3,9 @@ import { JSONObject, KDocument } from "kuzzle-sdk";
3
3
  import { DeviceManagerPlugin } from "../plugin";
4
4
  import { DeviceContent } from "../device";
5
5
  import { DecodedMeasurement } from "../measure";
6
+ import { BaseService } from "../shared";
6
7
  import { Decoder } from "./Decoder";
7
- export declare class PayloadService {
8
- private config;
9
- private context;
10
- private get sdk();
11
- private get app();
8
+ export declare class PayloadService extends BaseService {
12
9
  constructor(plugin: DeviceManagerPlugin);
13
10
  /**
14
11
  * Process a payload by validating and decode it with the `decoder` associated
@@ -1,17 +1,14 @@
1
- import { Plugin, User } from "kuzzle";
1
+ import { KuzzleRequest } from "kuzzle";
2
2
  import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle-sdk";
3
3
  import { AssetContent } from "./../asset";
4
- import { Metadata } from "../shared";
4
+ import { DeviceManagerPlugin } from "../plugin";
5
+ import { Metadata, BaseService, SearchParams } from "../shared";
5
6
  import { DecodedMeasurement } from "../measure";
6
7
  import { DeviceContent } from "./types/DeviceContent";
7
8
  import { ApiDeviceLinkAssetRequest } from "./types/DeviceApi";
8
- export declare class DeviceService {
9
- private config;
10
- private context;
11
- private get sdk();
12
- private get app();
13
- private get impersonatedSdk();
14
- constructor(plugin: Plugin);
9
+ export declare class DeviceService extends BaseService {
10
+ constructor(plugin: DeviceManagerPlugin);
11
+ registerAskEvents(): void;
15
12
  /**
16
13
  * Create a new device.
17
14
  *
@@ -19,23 +16,12 @@ export declare class DeviceService {
19
16
  * method since in this case "engineId" is not really an engine ID but still
20
17
  * required as an argument (in part to check the tenant rights)
21
18
  */
22
- create(user: User, model: string, reference: string, metadata: JSONObject, { engineId, refresh, }?: {
23
- engineId?: string;
24
- refresh?: any;
25
- }): Promise<KDocument<DeviceContent>>;
26
- get(index: string, deviceId: string): Promise<KDocument<DeviceContent>>;
27
- update(user: User, engineId: string, deviceId: string, metadata: Metadata, { refresh }: {
28
- refresh: any;
29
- }): Promise<KDocument<DeviceContent>>;
30
- delete(user: User, engineId: string, deviceId: string, { refresh }: {
31
- refresh: any;
32
- }): Promise<void>;
33
- search(engineId: string, searchBody: JSONObject, { from, size, scroll, lang, }: {
34
- from?: number;
35
- size?: number;
36
- scroll?: string;
37
- lang?: string;
38
- }): Promise<SearchResult<KHit<DeviceContent>>>;
19
+ create(model: string, reference: string, metadata: JSONObject, request: KuzzleRequest): Promise<KDocument<DeviceContent>>;
20
+ get(engineId: string, deviceId: string, request: KuzzleRequest): Promise<KDocument<DeviceContent>>;
21
+ private getInternalDevices;
22
+ update(engineId: string, deviceId: string, metadata: Metadata, request: KuzzleRequest): Promise<KDocument<DeviceContent>>;
23
+ delete(engineId: string, deviceId: string, request: KuzzleRequest): Promise<void>;
24
+ search(engineId: string, searchParams: SearchParams, request: KuzzleRequest): Promise<SearchResult<KHit<DeviceContent>>>;
39
25
  /**
40
26
  * Attach the device to an engine
41
27
  *
@@ -44,29 +30,22 @@ export declare class DeviceService {
44
30
  * @param options.refresh Wait for ES indexation
45
31
  * @param options.strict If true, throw if an operation isn't possible
46
32
  */
47
- attachEngine(user: User, engineId: string, deviceId: string, { refresh }?: {
48
- refresh?: any;
49
- }): Promise<KDocument<DeviceContent>>;
33
+ attachEngine(engineId: string, deviceId: string, request: KuzzleRequest): Promise<KDocument<DeviceContent>>;
50
34
  /**
51
35
  * Detach a device from its attached engine
52
36
  *
53
- * @param deviceId Device id
54
- * @param options.refresh Wait for ES indexation
37
+ * @param {string} deviceId Id of the device
38
+ * @param {KuzzleRequest} request kuzzle request
55
39
  */
56
- detachEngine(user: User, deviceId: string, { refresh }?: {
57
- refresh?: any;
58
- }): Promise<KDocument<DeviceContent>>;
40
+ detachEngine(deviceId: string, request: KuzzleRequest): Promise<KDocument<DeviceContent>>;
59
41
  /**
60
42
  * Link a device to an asset.
61
43
  */
62
- linkAsset(user: User, engineId: string, deviceId: string, assetId: string, measureNames: ApiDeviceLinkAssetRequest["body"]["measureNames"], { refresh, implicitMeasuresLinking, }?: {
63
- refresh?: any;
64
- implicitMeasuresLinking?: boolean;
65
- }): Promise<{
44
+ linkAsset(engineId: string, deviceId: string, assetId: string, measureNames: ApiDeviceLinkAssetRequest["body"]["measureNames"], implicitMeasuresLinking: boolean, request: KuzzleRequest): Promise<{
66
45
  asset: KDocument<AssetContent>;
67
46
  device: KDocument<DeviceContent>;
68
47
  }>;
69
- receiveMeasures(engineId: string, deviceId: string, measures: DecodedMeasurement[], payloadUuids: string[]): Promise<void>;
48
+ receiveMeasures(engineId: string, deviceId: string, measures: DecodedMeasurement[], payloadUuids: string[], request: KuzzleRequest): Promise<void>;
70
49
  /**
71
50
  * Checks if the asset does not already have a linked device using one of the
72
51
  * requested measure names.
@@ -82,12 +61,10 @@ export declare class DeviceService {
82
61
  /**
83
62
  * Unlink a device of an asset
84
63
  *
85
- * @param deviceId Id of the device
86
- * @param options.refresh Wait for ES indexation
64
+ * @param {string} deviceId Id of the device
65
+ * @param {KuzzleRequest} request kuzzle request
87
66
  */
88
- unlinkAsset(user: User, deviceId: string, { refresh }?: {
89
- refresh?: any;
90
- }): Promise<{
67
+ unlinkAsset(deviceId: string, request: KuzzleRequest): Promise<{
91
68
  asset: KDocument<AssetContent>;
92
69
  device: KDocument<DeviceContent>;
93
70
  }>;
@@ -1,4 +1,4 @@
1
- import { ControllerDefinition, HttpStream, KuzzleRequest } from "kuzzle";
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";
@@ -34,11 +34,7 @@ export declare class DevicesController {
34
34
  */
35
35
  unlinkAsset(request: KuzzleRequest): Promise<ApiDeviceUnlinkAssetResult>;
36
36
  getMeasures(request: KuzzleRequest): Promise<ApiDeviceGetMeasuresResult>;
37
- exportMeasures(request: KuzzleRequest): Promise<HttpStream | {
38
- link: string;
39
- }>;
37
+ exportMeasures(request: KuzzleRequest): Promise<any>;
40
38
  receiveMeasures(request: KuzzleRequest): Promise<void>;
41
- export(request: KuzzleRequest): Promise<HttpStream | {
42
- link: string;
43
- }>;
39
+ export(request: KuzzleRequest): Promise<any>;
44
40
  }
@@ -1,51 +1,7 @@
1
+ import { CollectionMappings } from "kuzzle";
1
2
  /**
2
3
  * Base mappings for the "devices" collection.
3
4
  *
4
5
  * Those mappings does not contains the `measures` and `metadata` mappings.
5
6
  */
6
- export declare const devicesMappings: {
7
- dynamic: string;
8
- properties: {
9
- model: {
10
- type: string;
11
- fields: {
12
- text: {
13
- type: string;
14
- };
15
- };
16
- };
17
- reference: {
18
- type: string;
19
- fields: {
20
- text: {
21
- type: string;
22
- };
23
- };
24
- };
25
- assetId: {
26
- type: string;
27
- fields: {
28
- text: {
29
- type: string;
30
- };
31
- };
32
- };
33
- engineId: {
34
- type: string;
35
- fields: {
36
- text: {
37
- type: string;
38
- };
39
- };
40
- };
41
- metadata: {
42
- properties: {};
43
- };
44
- measures: {
45
- properties: {};
46
- };
47
- lastMeasuredAt: {
48
- type: string;
49
- };
50
- };
51
- };
7
+ export declare const devicesMappings: CollectionMappings;
@@ -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;
@@ -166,6 +168,7 @@ export interface ApiDeviceReceiveMeasuresRequest<TMeasureValues extends JSONObje
166
168
  export type ApiDeviceReceiveMeasuresResult = void;
167
169
  export interface ApiDeviceExportRequest extends DevicesControllerRequest {
168
170
  action: "export";
171
+ lang?: "koncorde" | "elasticsearch";
169
172
  body?: {
170
173
  query?: JSONObject;
171
174
  sort?: JSONObject;
@@ -2,6 +2,7 @@ import { User } from "kuzzle";
2
2
  import { KDocument } from "kuzzle-sdk";
3
3
  import { Metadata } from "../../../modules/shared";
4
4
  import { DeviceContent } from "./DeviceContent";
5
+ import { ApiDeviceLinkAssetRequest } from "./DeviceApi";
5
6
  export type EventDeviceUpdateBefore = {
6
7
  name: "device-manager:device:update:before";
7
8
  args: [{
@@ -19,6 +20,17 @@ export type EventDeviceUpdateAfter = {
19
20
  /**
20
21
  * @internal
21
22
  */
23
+ export type AskDeviceLinkAsset = {
24
+ name: "ask:device-manager:device:link-asset";
25
+ payload: {
26
+ engineId: string;
27
+ assetId: string;
28
+ deviceId: string;
29
+ user: User;
30
+ measureNames: ApiDeviceLinkAssetRequest["body"]["measureNames"];
31
+ };
32
+ result: void;
33
+ };
22
34
  export type AskDeviceUnlinkAsset = {
23
35
  name: "ask:device-manager:device:unlink-asset";
24
36
  payload: {
@@ -27,3 +39,20 @@ export type AskDeviceUnlinkAsset = {
27
39
  };
28
40
  result: void;
29
41
  };
42
+ export type AskDeviceDetachEngine = {
43
+ name: "ask:device-manager:device:detach-engine";
44
+ payload: {
45
+ deviceId: string;
46
+ user: User;
47
+ };
48
+ result: void;
49
+ };
50
+ export type AskDeviceAttachEngine = {
51
+ name: "ask:device-manager:device:attach-engine";
52
+ payload: {
53
+ engineId: string;
54
+ deviceId: string;
55
+ user: User;
56
+ };
57
+ result: void;
58
+ };
@@ -1,13 +1,9 @@
1
1
  import { JSONObject, KDocument } from "kuzzle";
2
2
  import { DeviceContent } from "../device";
3
3
  import { DeviceManagerPlugin } from "../plugin";
4
- import { Metadata } from "../shared";
4
+ import { BaseService, Metadata } from "../shared";
5
5
  import { DecodedMeasurement } from "./types/MeasureContent";
6
- export declare class MeasureService {
7
- private config;
8
- private context;
9
- private get sdk();
10
- private get app();
6
+ export declare class MeasureService extends BaseService {
11
7
  constructor(plugin: DeviceManagerPlugin);
12
8
  /**
13
9
  * Register new measures from a device, updates :
@@ -35,6 +35,21 @@ export declare const measuresMappings: {
35
35
  metadata: {
36
36
  properties: {};
37
37
  };
38
+ groups: {
39
+ properties: {
40
+ id: {
41
+ type: string;
42
+ fields: {
43
+ text: {
44
+ type: string;
45
+ };
46
+ };
47
+ };
48
+ date: {
49
+ type: string;
50
+ };
51
+ };
52
+ };
38
53
  };
39
54
  };
40
55
  /**
@@ -1,10 +1,8 @@
1
1
  import { JSONObject, KDocument } from "kuzzle-sdk";
2
2
  import { DeviceManagerPlugin } from "../plugin";
3
+ import { BaseService } from "../shared";
3
4
  import { AssetModelContent, DeviceModelContent, MeasureModelContent } from "./types/ModelContent";
4
- export declare class ModelService {
5
- private config;
6
- private context;
7
- private get sdk();
5
+ export declare class ModelService extends BaseService {
8
6
  constructor(plugin: DeviceManagerPlugin);
9
7
  registerAskEvents(): void;
10
8
  writeAsset(engineGroup: string, model: string, metadataMappings: JSONObject, defaultMetadata: JSONObject, measures: AssetModelContent["asset"]["measures"]): Promise<KDocument<AssetModelContent>>;
@@ -1,2 +1,2 @@
1
- export * from "./types/DeviceManagerConfiguration";
1
+ export * from "./types/exports";
2
2
  export * from "./DeviceManagerPlugin";
@@ -1,4 +1,3 @@
1
- export * from "./types/DeviceManagerConfiguration";
1
+ export * from "./types";
2
2
  export * from "./DeviceManagerEngine";
3
3
  export * from "./DeviceManagerPlugin";
4
- export * from "./types/InternalCollection";
@@ -1,4 +1,4 @@
1
- import { JSONObject } from "kuzzle-sdk";
1
+ import { CollectionMappings, JSONObject } from "kuzzle-sdk";
2
2
  export type DeviceManagerConfiguration = {
3
3
  /**
4
4
  * Ignore errors at startup such as wrong mappings update.
@@ -45,5 +45,13 @@ export type DeviceManagerConfiguration = {
45
45
  mappings: JSONObject;
46
46
  settings: JSONObject;
47
47
  };
48
+ asset: {
49
+ name: string;
50
+ mappings: CollectionMappings;
51
+ };
52
+ device: {
53
+ name: string;
54
+ mappings: CollectionMappings;
55
+ };
48
56
  };
49
57
  };
@@ -0,0 +1,17 @@
1
+ import { JSONObject, KDocumentContent, KHit, KuzzleRequest } from "kuzzle";
2
+ export interface SearchQueryResult<T extends KDocumentContent> {
3
+ aggregations?: JSONObject;
4
+ hits: Array<KHit<T>>;
5
+ remaining: unknown;
6
+ scrollId: string;
7
+ suggest: JSONObject;
8
+ total: number;
9
+ }
10
+ export type EventGenericDocumentBeforeSearch = {
11
+ name: `generic:document:beforeSearch`;
12
+ args: [JSONObject, KuzzleRequest];
13
+ };
14
+ export type EventGenericDocumentAfterSearch<T extends KDocumentContent = KDocumentContent> = {
15
+ name: `generic:document:afterSearch`;
16
+ args: [SearchQueryResult<T>, KuzzleRequest];
17
+ };
@@ -0,0 +1 @@
1
+ export * from "./DeviceManagerConfiguration";
@@ -0,0 +1,3 @@
1
+ export * from "./DeviceManagerConfiguration";
2
+ export * from "./InternalCollection";
3
+ export * from "./Pipes";
@@ -14,6 +14,7 @@ export interface ExporterOption {
14
14
  export interface ExportParams {
15
15
  query: JSONObject;
16
16
  sort?: JSONObject;
17
+ lang?: "elasticsearch" | "koncorde";
17
18
  }
18
19
  export interface Column {
19
20
  header: string;
@@ -0,0 +1,69 @@
1
+ import { ArgsDocumentControllerCreate, ArgsDocumentControllerDelete, ArgsDocumentControllerUpdate, Backend, EmbeddedSDK, KDocument, KDocumentContent, KHit, KuzzleRequest, SearchResult, User } from "kuzzle";
2
+ import { DeviceManagerPlugin, DeviceManagerConfiguration, InternalCollection } from "../../plugin";
3
+ interface PayloadRequest {
4
+ collection: InternalCollection;
5
+ engineId: string;
6
+ }
7
+ export type SearchParams = ReturnType<KuzzleRequest["getSearchParams"]>;
8
+ export declare abstract class BaseService {
9
+ private plugin;
10
+ constructor(plugin: DeviceManagerPlugin);
11
+ protected get app(): Backend;
12
+ protected get sdk(): EmbeddedSDK;
13
+ protected get config(): DeviceManagerConfiguration;
14
+ protected get impersonatedSdk(): (user: User) => EmbeddedSDK;
15
+ protected normalizeKuzzleRequest(request: KuzzleRequest, { collection, engineId }: PayloadRequest): KuzzleRequest;
16
+ /**
17
+ * Wrapper to SDK create method with trigger generic:document events
18
+ *
19
+ * @param {KuzzleRequest} request
20
+ * @param {KDocument} documentId
21
+ * @param {PayloadRequest} payload
22
+ * @param {ArgsDocumentControllerCreate} [options]
23
+ * @returns {Promise<KDocument>}
24
+ */
25
+ protected getDocument<T extends KDocumentContent = KDocumentContent>(request: KuzzleRequest, documentId: string, { collection, engineId }: PayloadRequest, options?: ArgsDocumentControllerCreate): Promise<KDocument<T>>;
26
+ /**
27
+ * Wrapper to SDK create method with trigger generic:document events
28
+ *
29
+ * @param {KuzzleRequest} request
30
+ * @param {KDocument} document
31
+ * @param {PayloadRequest} payload
32
+ * @param {ArgsDocumentControllerCreate} [options]
33
+ * @returns {Promise<KDocument>}
34
+ */
35
+ protected createDocument<T extends KDocumentContent = KDocumentContent>(request: KuzzleRequest, document: KDocument<T>, { collection, engineId }: PayloadRequest, options?: ArgsDocumentControllerCreate): Promise<KDocument<T>>;
36
+ /**
37
+ * Wrapper to SDK update method with trigger generic:document events
38
+ *
39
+ * @param {KuzzleRequest} request
40
+ * @param {KDocument} document
41
+ * @param {PayloadRequest} payload
42
+ * @param {ArgsDocumentControllerUpdate} [options]
43
+ * @returns {Promise<KDocument>}
44
+ */
45
+ protected updateDocument<T extends KDocumentContent = KDocumentContent>(request: KuzzleRequest, document: KDocument<Partial<T>>, { collection, engineId }: PayloadRequest, options?: ArgsDocumentControllerUpdate): Promise<KDocument<T>>;
46
+ /**
47
+ * Wrapper to SDK delete method with trigger generic:document events
48
+ *
49
+ * @param {KuzzleRequest} request
50
+ * @param {string} documentId
51
+ * @param {PayloadRequest} payload
52
+ * @param {ArgsDocumentControllerUpdate} [options]
53
+ * @returns {Promise<{ _id: string }>}
54
+ */
55
+ protected deleteDocument(request: KuzzleRequest, documentId: string, { collection, engineId }: PayloadRequest, options?: ArgsDocumentControllerDelete): Promise<{
56
+ _id: string;
57
+ }>;
58
+ /**
59
+ * Wrapper to SDK search method with trigger generic:document events
60
+ * ! Caution the pipes are not applied on next()
61
+ *
62
+ * @param {KuzzleRequest} request
63
+ * @param {ArgsDocumentControllerUpdate} [options]
64
+ * @param {PayloadRequest} payload
65
+ * @returns {Promise<SearchResult<KHit>>}
66
+ */
67
+ protected searchDocument<T extends KDocumentContent = KDocumentContent>(request: KuzzleRequest, { from, size, scrollTTL: scroll }: SearchParams, { collection, engineId }: PayloadRequest): Promise<SearchResult<KHit<T>>>;
68
+ }
69
+ export {};
@@ -1,2 +1,3 @@
1
1
  export * from "./AbstractExporter";
2
+ export * from "./BaseService";
2
3
  export * from "./DigitalTwinExporter";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kuzzle-device-manager-types",
3
- "version": "2.4.0-beta.1-1",
3
+ "version": "2.4.0-beta.10",
4
4
  "description": "Shared types for Kuzzle Device Manager",
5
5
  "author": "The Kuzzle Team (support@kuzzle.io)",
6
6
  "main": "index.js",