kuzzle-device-manager-types 3.0.0-next.4 → 3.0.0-next.5

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.
@@ -30,7 +30,7 @@ export interface AssetContent<TMeasures extends JSONObject = any, TMetadata exte
30
30
  }>;
31
31
  }>;
32
32
  /**
33
- * Id's of asset groups
33
+ * Path's of asset groups
34
34
  */
35
35
  groups: Array<{
36
36
  path: string;
@@ -11,4 +11,11 @@ export interface DeviceContent<TMeasures extends JSONObject = any, TMetadata ext
11
11
  /**
12
12
  */
13
13
  engineId: string;
14
+ /**
15
+ * Path's of device's groups
16
+ */
17
+ groups: Array<{
18
+ path: string;
19
+ date: number;
20
+ }>;
14
21
  }
@@ -1,6 +1,6 @@
1
1
  import { ControllerDefinition, KuzzleRequest } from "kuzzle";
2
2
  import { DeviceManagerPlugin } from "../plugin";
3
- import { ApiGroupAddAssetsResult, ApiGroupCreateResult, ApiGroupDeleteResult, ApiGroupGetResult, ApiGroupRemoveAssetsResult, ApiGroupSearchResult, ApiGroupUpdateResult, GroupsBodyRequest } from "./types/GroupsApi";
3
+ import { ApiGroupAddAssetsResult, ApiGroupAddDevicesResult, ApiGroupCreateResult, ApiGroupDeleteResult, ApiGroupGetResult, ApiGroupListItemsResult, ApiGroupRemoveAssetsResult, ApiGroupRemoveDeviceResult, ApiGroupSearchResult, ApiGroupUpdateResult, GroupsBodyRequest } from "./types/GroupsApi";
4
4
  import { GroupsService } from "./GroupsService";
5
5
  export declare class GroupsController {
6
6
  private plugin;
@@ -23,6 +23,9 @@ export declare class GroupsController {
23
23
  update(request: KuzzleRequest): Promise<ApiGroupUpdateResult>;
24
24
  delete(request: KuzzleRequest): Promise<ApiGroupDeleteResult>;
25
25
  search(request: KuzzleRequest): Promise<ApiGroupSearchResult>;
26
+ listItems(request: KuzzleRequest): Promise<ApiGroupListItemsResult>;
26
27
  addAsset(request: KuzzleRequest): Promise<ApiGroupAddAssetsResult>;
27
28
  removeAsset(request: KuzzleRequest): Promise<ApiGroupRemoveAssetsResult>;
29
+ addDevice(request: KuzzleRequest): Promise<ApiGroupAddDevicesResult>;
30
+ removeDevice(request: KuzzleRequest): Promise<ApiGroupRemoveDeviceResult>;
28
31
  }
@@ -2,7 +2,9 @@ import { JSONObject, KDocument } from "kuzzle-sdk";
2
2
  import { DeviceManagerPlugin } from "../plugin";
3
3
  import { BaseService, SearchParams } from "../shared";
4
4
  import { KuzzleRequest } from "kuzzle";
5
+ import { AssetContent } from "../asset/types/AssetContent";
5
6
  import { GroupContent } from "./exports";
7
+ import { DeviceContent } from "../device";
6
8
  export declare class GroupsService extends BaseService {
7
9
  constructor(plugin: DeviceManagerPlugin);
8
10
  create(_id: string, engineId: string, metadata: JSONObject, model: string, name: string, path: string, request: KuzzleRequest): Promise<KDocument<GroupContent>>;
@@ -12,6 +14,19 @@ export declare class GroupsService extends BaseService {
12
14
  _id: string;
13
15
  }>;
14
16
  search(engineId: string, searchParams: SearchParams, request: KuzzleRequest): Promise<import("kuzzle-sdk").SearchResult<import("kuzzle-sdk").KHit<GroupContent>>>;
17
+ listItems(engineId: string, _id: string, includeChildren: boolean, options: {
18
+ from?: number;
19
+ size?: number;
20
+ }, request: KuzzleRequest): Promise<{
21
+ assets: {
22
+ hits: import("kuzzle-sdk").KHit<AssetContent<any, any>>[];
23
+ total: number;
24
+ };
25
+ devices: {
26
+ hits: import("kuzzle-sdk").KHit<DeviceContent<any, any>>[];
27
+ total: number;
28
+ };
29
+ }>;
15
30
  addAsset(engineId: string, path: string, assetIds: string[], request: KuzzleRequest): Promise<{
16
31
  group: KDocument<GroupContent>;
17
32
  successes: {
@@ -44,4 +59,36 @@ export declare class GroupsService extends BaseService {
44
59
  reason: string;
45
60
  }[];
46
61
  }>;
62
+ addDevice(engineId: string, path: string, deviceIds: string[], request: KuzzleRequest): Promise<{
63
+ group: KDocument<GroupContent>;
64
+ successes: {
65
+ _id: string;
66
+ _source: JSONObject;
67
+ _version: number;
68
+ }[];
69
+ errors: {
70
+ document: {
71
+ _id: string;
72
+ _source: JSONObject;
73
+ };
74
+ status: number;
75
+ reason: string;
76
+ }[];
77
+ }>;
78
+ removeDevice(engineId: string, path: string, deviceIds: string[], request: KuzzleRequest): Promise<{
79
+ group: KDocument<GroupContent>;
80
+ successes: {
81
+ _id: string;
82
+ _source: JSONObject;
83
+ _version: number;
84
+ }[];
85
+ errors: {
86
+ document: {
87
+ _id: string;
88
+ _source: JSONObject;
89
+ };
90
+ status: number;
91
+ reason: string;
92
+ }[];
93
+ }>;
47
94
  }
@@ -1,8 +1,10 @@
1
1
  import { JSONObject, KDocument, KHit, SearchResult, mUpdateResponse } from "kuzzle-sdk";
2
2
  import { GroupsBody, GroupContent } from "./GroupContent";
3
+ import { DeviceContent } from "lib/modules/device";
4
+ import { AssetContent } from "lib/modules/asset";
3
5
  type GroupsRequest = Omit<GroupsBody, "lastUpdate">;
4
6
  export type GroupsBodyRequest = Partial<GroupsRequest>;
5
- export type UpdateAssetLinkResponse = mUpdateResponse & {
7
+ export type UpdateLinkResponse = mUpdateResponse & {
6
8
  group: KDocument<GroupContent>;
7
9
  };
8
10
  interface GroupControllerRequest {
@@ -40,6 +42,25 @@ export interface ApiGroupSearchRequest extends GroupControllerRequest {
40
42
  body: JSONObject;
41
43
  }
42
44
  export type ApiGroupSearchResult = SearchResult<KHit<GroupContent>>;
45
+ export interface ApiGroupListItemsRequest extends GroupControllerRequest {
46
+ action: "listItems";
47
+ from?: number;
48
+ size?: number;
49
+ body: {
50
+ includeChildren?: boolean;
51
+ };
52
+ _id: string;
53
+ }
54
+ export type ApiGroupListItemsResult = {
55
+ assets: {
56
+ hits: Array<KHit<AssetContent>>;
57
+ total: number;
58
+ };
59
+ devices: {
60
+ hits: Array<KHit<DeviceContent>>;
61
+ total: number;
62
+ };
63
+ };
43
64
  export interface ApiGroupAddAssetsRequest extends GroupControllerRequest {
44
65
  action: "addAsset";
45
66
  body: {
@@ -47,7 +68,7 @@ export interface ApiGroupAddAssetsRequest extends GroupControllerRequest {
47
68
  assetIds: string[];
48
69
  };
49
70
  }
50
- export type ApiGroupAddAssetsResult = UpdateAssetLinkResponse;
71
+ export type ApiGroupAddAssetsResult = UpdateLinkResponse;
51
72
  export interface ApiGroupRemoveAssetsRequest extends GroupControllerRequest {
52
73
  action: "removeAsset";
53
74
  body: {
@@ -55,5 +76,21 @@ export interface ApiGroupRemoveAssetsRequest extends GroupControllerRequest {
55
76
  assetIds: string[];
56
77
  };
57
78
  }
58
- export type ApiGroupRemoveAssetsResult = UpdateAssetLinkResponse;
79
+ export type ApiGroupRemoveAssetsResult = UpdateLinkResponse;
80
+ export interface ApiGroupAddDeviceRequest extends GroupControllerRequest {
81
+ action: "addDevice";
82
+ body: {
83
+ path: string;
84
+ deviceIds: string[];
85
+ };
86
+ }
87
+ export type ApiGroupAddDevicesResult = UpdateLinkResponse;
88
+ export interface ApiGroupRemoveDeviceRequest extends GroupControllerRequest {
89
+ action: "removeDevice";
90
+ body: {
91
+ path: string;
92
+ deviceIds: string[];
93
+ };
94
+ }
95
+ export type ApiGroupRemoveDeviceResult = UpdateLinkResponse;
59
96
  export {};
@@ -10,12 +10,13 @@ export declare class ModelService extends BaseService {
10
10
  constructor(plugin: DeviceManagerPlugin);
11
11
  registerAskEvents(): void;
12
12
  private checkModelsConflicts;
13
+ private checkDefaultValues;
14
+ private checkGroupAffinity;
13
15
  writeAsset(engineGroup: string, model: string, metadataMappings: MetadataMappings, defaultMetadata: JSONObject, metadataDetails: MetadataDetails, metadataGroups: MetadataGroups, measures: NamedMeasures, tooltipModels: TooltipModels, locales: {
14
16
  [valueName: string]: LocaleDetails;
15
17
  }): Promise<KDocument<AssetModelContent>>;
16
- private checkDefaultValues;
17
18
  writeDevice(model: string, metadataMappings: MetadataMappings, defaultMetadata: JSONObject, metadataDetails: MetadataDetails, metadataGroups: MetadataGroups, measures: NamedMeasures): Promise<KDocument<DeviceModelContent>>;
18
- writeGroup(engineGroup: string, model: string, metadataMappings: MetadataMappings, defaultMetadata: JSONObject, metadataDetails: MetadataDetails, metadataGroups: MetadataGroups): Promise<KDocument<GroupModelContent>>;
19
+ writeGroup(engineGroup: string, model: string, affinity: JSONObject, metadataMappings: MetadataMappings, defaultMetadata: JSONObject, metadataDetails: MetadataDetails, metadataGroups: MetadataGroups): Promise<KDocument<GroupModelContent>>;
19
20
  writeMeasure(type: string, valuesMappings: JSONObject, validationSchema?: SchemaObject, valuesDetails?: MeasureValuesDetails, locales?: {
20
21
  [valueName: string]: LocaleDetails;
21
22
  }): Promise<KDocument<MeasureModelContent>>;
@@ -1,7 +1,7 @@
1
1
  import { DeviceManagerPlugin } from "../plugin";
2
2
  import { NamedMeasures } from "../decoder";
3
3
  import { MeasureDefinition } from "../measure";
4
- import { LocaleDetails, MetadataDetails, MetadataGroups, MetadataMappings, TooltipModels } from "./types/ModelContent";
4
+ import { GroupAffinity, LocaleDetails, MetadataDetails, MetadataGroups, MetadataMappings, TooltipModels } from "./types/ModelContent";
5
5
  import { JSONObject } from "kuzzle-sdk";
6
6
  export declare class ModelsRegister {
7
7
  private config;
@@ -47,13 +47,14 @@ export declare class ModelsRegister {
47
47
  *
48
48
  * @param engineGroup - The engine group name.
49
49
  * @param model - The name of the group model, which must be in PascalCase.
50
+ * @param affinity - The type of object accepted and their model affinity.
50
51
  * @param metadataMappings - The metadata mappings for the model, defaults to an empty object.
51
52
  * @param defaultMetadata - The default metadata values for the model, defaults to an empty object.
52
53
  * @param metadataDetails - Optional detailed metadata descriptions, localizations and definition.
53
54
  * @param metadataGroups - Optional groups for organizing metadata, with localizations.
54
55
  * @throws PluginImplementationError if the model name is not in PascalCase.
55
56
  */
56
- registerGroup(engineGroup: string, model: string, metadataMappings?: MetadataMappings, defaultMetadata?: JSONObject, metadataDetails?: MetadataDetails, metadataGroups?: MetadataGroups): void;
57
+ registerGroup(engineGroup: string, model: string, affinity: GroupAffinity, metadataMappings?: MetadataMappings, defaultMetadata?: JSONObject, metadataDetails?: MetadataDetails, metadataGroups?: MetadataGroups): void;
57
58
  registerMeasure(type: string, measureDefinition: MeasureDefinition): void;
58
59
  private load;
59
60
  }
@@ -1,5 +1,5 @@
1
1
  import { JSONObject, KDocument, KHit, SearchResult } from "kuzzle-sdk";
2
- import { AssetModelContent, DeviceModelContent, GroupModelContent, LocaleDetails, MeasureModelContent, MetadataDetails, MetadataGroups, MetadataMappings, TooltipModels } from "./ModelContent";
2
+ import { AssetModelContent, DeviceModelContent, GroupAffinity, GroupModelContent, LocaleDetails, MeasureModelContent, MetadataDetails, MetadataGroups, MetadataMappings, TooltipModels } from "./ModelContent";
3
3
  import { SchemaObject } from "ajv";
4
4
  import { MeasureValuesDetails } from "../../measure/types/MeasureDefinition";
5
5
  interface ModelsControllerRequest {
@@ -58,6 +58,7 @@ export type ApiModelWriteDeviceResult = KDocument<DeviceModelContent>;
58
58
  export interface ApiModelWriteGroupRequest extends ModelsControllerRequest {
59
59
  action: "writeGroup";
60
60
  body: {
61
+ affinity: GroupAffinity;
61
62
  engineGroup: string;
62
63
  model: string;
63
64
  metadataDetails?: MetadataDetails;
@@ -23,6 +23,23 @@ export interface MetadataObject {
23
23
  export interface MetadataMappings {
24
24
  [key: string]: MetadataProperty | MetadataObject;
25
25
  }
26
+ export interface GroupAffinity {
27
+ /**
28
+ * Type of elements accepted in the group
29
+ */
30
+ type: Array<"assets" | "devices">;
31
+ /**
32
+ * Models accepted in the group
33
+ */
34
+ models: {
35
+ assets?: string[];
36
+ devices?: string[];
37
+ };
38
+ /**
39
+ * Weather the affinities are a strict restriction or not
40
+ */
41
+ strict: boolean;
42
+ }
26
43
  export interface LocaleDetails {
27
44
  friendlyName: string;
28
45
  description: string;
@@ -370,6 +387,10 @@ export interface GroupModelContent extends KDocumentContent {
370
387
  * Name of the model
371
388
  */
372
389
  model: string;
390
+ /**
391
+ * Group types and model affinities
392
+ */
393
+ affinity: GroupAffinity;
373
394
  /**
374
395
  * Metadata mappings.
375
396
  *
@@ -1,6 +1,6 @@
1
1
  import { JSONObject } from "kuzzle-sdk";
2
2
  import { Decoder, NamedMeasures } from "../../../modules/decoder";
3
- import { LocaleDetails, MetadataDetails, MetadataGroups, MetadataMappings, TooltipModels } from "./ModelContent";
3
+ import { GroupAffinity, LocaleDetails, MetadataDetails, MetadataGroups, MetadataMappings, TooltipModels } from "./ModelContent";
4
4
  /**
5
5
  * Define an asset model
6
6
  *
@@ -279,6 +279,10 @@ export type DeviceModelDefinition = {
279
279
  *
280
280
  */
281
281
  export type GroupModelDefinition = {
282
+ /**
283
+ * Metadata mappings definition
284
+ */
285
+ affinity: GroupAffinity;
282
286
  /**
283
287
  * Metadata mappings definition
284
288
  */
@@ -0,0 +1,8 @@
1
+ import { GroupContent } from "lib/modules/group/exports";
2
+ import { GroupModel } from "lib/modules/shared";
3
+ declare const modelName = "AssetRestricted";
4
+ export interface AssetRestrictedContent extends GroupContent {
5
+ model: typeof modelName;
6
+ }
7
+ export declare const AssetRestricted: GroupModel;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ import { GroupContent } from "lib/modules/group/exports";
2
+ import { GroupModel } from "lib/modules/shared";
3
+ declare const modelName = "DeviceRestricted";
4
+ export interface DeviceRestrictedContent extends GroupContent {
5
+ model: typeof modelName;
6
+ }
7
+ export declare const DeviceRestricted: GroupModel;
8
+ export {};
@@ -1 +1,3 @@
1
1
  export * from "./Parking";
2
+ export * from "./AssetRestricted";
3
+ export * from "./DeviceRestricted";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kuzzle-device-manager-types",
3
- "version": "3.0.0-next.4",
3
+ "version": "3.0.0-next.5",
4
4
  "description": "Shared types for Kuzzle Device Manager",
5
5
  "author": "The Kuzzle Team (support@kuzzle.io)",
6
6
  "main": "index.js",