kuzzle-device-manager 2.2.8 → 2.3.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.
- package/dist/lib/modules/asset/AssetModule.d.ts +1 -0
- package/dist/lib/modules/asset/AssetModule.js +10 -0
- package/dist/lib/modules/asset/AssetModule.js.map +1 -1
- package/dist/lib/modules/asset/AssetsGroupsController.d.ts +20 -0
- package/dist/lib/modules/asset/AssetsGroupsController.js +302 -0
- package/dist/lib/modules/asset/AssetsGroupsController.js.map +1 -0
- package/dist/lib/modules/asset/collections/assetsGroupsMapping.d.ts +2 -0
- package/dist/lib/modules/asset/collections/assetsGroupsMapping.js +36 -0
- package/dist/lib/modules/asset/collections/assetsGroupsMapping.js.map +1 -0
- package/dist/lib/modules/asset/collections/assetsMappings.d.ts +2 -47
- package/dist/lib/modules/asset/collections/assetsMappings.js +9 -0
- package/dist/lib/modules/asset/collections/assetsMappings.js.map +1 -1
- package/dist/lib/modules/asset/exports.d.ts +4 -0
- package/dist/lib/modules/asset/exports.js +4 -0
- package/dist/lib/modules/asset/exports.js.map +1 -1
- package/dist/lib/modules/asset/index.d.ts +3 -0
- package/dist/lib/modules/asset/index.js +3 -0
- package/dist/lib/modules/asset/index.js.map +1 -1
- package/dist/lib/modules/asset/roles/RoleAssetsGroupsAdmin.d.ts +24 -0
- package/dist/lib/modules/asset/roles/RoleAssetsGroupsAdmin.js +38 -0
- package/dist/lib/modules/asset/roles/RoleAssetsGroupsAdmin.js.map +1 -0
- package/dist/lib/modules/asset/roles/RoleAssetsGroupsReader.d.ts +24 -0
- package/dist/lib/modules/asset/roles/RoleAssetsGroupsReader.js +39 -0
- package/dist/lib/modules/asset/roles/RoleAssetsGroupsReader.js.map +1 -0
- package/dist/lib/modules/asset/types/AssetContent.d.ts +7 -0
- package/dist/lib/modules/asset/types/AssetGroupContent.d.ts +8 -0
- package/dist/lib/modules/asset/types/AssetGroupContent.js +3 -0
- package/dist/lib/modules/asset/types/AssetGroupContent.js.map +1 -0
- package/dist/lib/modules/asset/types/AssetGroupsApi.d.ts +59 -0
- package/dist/lib/modules/asset/types/AssetGroupsApi.js +3 -0
- package/dist/lib/modules/asset/types/AssetGroupsApi.js.map +1 -0
- package/dist/lib/modules/decoder/DecodingState.js +1 -1
- package/dist/lib/modules/decoder/DecodingState.js.map +1 -1
- package/dist/lib/modules/measure/MeasureExporter.d.ts +1 -0
- package/dist/lib/modules/measure/MeasureExporter.js +48 -7
- package/dist/lib/modules/measure/MeasureExporter.js.map +1 -1
- package/dist/lib/modules/measure/measures/PositionMeasure.js +1 -1
- package/dist/lib/modules/measure/measures/PositionMeasure.js.map +1 -1
- package/dist/lib/modules/model/ModelService.js +4 -0
- package/dist/lib/modules/model/ModelService.js.map +1 -1
- package/dist/lib/modules/model/types/ModelEvents.d.ts +8 -1
- package/dist/lib/modules/plugin/DeviceManagerEngine.d.ts +1 -0
- package/dist/lib/modules/plugin/DeviceManagerEngine.js +19 -12
- package/dist/lib/modules/plugin/DeviceManagerEngine.js.map +1 -1
- package/dist/lib/modules/plugin/types/InternalCollection.d.ts +1 -0
- package/dist/lib/modules/plugin/types/InternalCollection.js +2 -1
- package/dist/lib/modules/plugin/types/InternalCollection.js.map +1 -1
- package/package.json +15 -4
|
@@ -5,18 +5,28 @@ const Module_1 = require("../shared/Module");
|
|
|
5
5
|
const AssetHistoryService_1 = require("./AssetHistoryService");
|
|
6
6
|
const AssetsController_1 = require("./AssetsController");
|
|
7
7
|
const AssetService_1 = require("./AssetService");
|
|
8
|
+
const AssetsGroupsController_1 = require("./AssetsGroupsController");
|
|
8
9
|
const RoleAssetsAdmin_1 = require("./roles/RoleAssetsAdmin");
|
|
9
10
|
const RoleAssetsReader_1 = require("./roles/RoleAssetsReader");
|
|
11
|
+
const RoleAssetsGroupsAdmin_1 = require("./roles/RoleAssetsGroupsAdmin");
|
|
12
|
+
const RoleAssetsGroupsReader_1 = require("./roles/RoleAssetsGroupsReader");
|
|
10
13
|
class AssetModule extends Module_1.Module {
|
|
11
14
|
async init() {
|
|
12
15
|
this.assetHistoryService = new AssetHistoryService_1.AssetHistoryService(this.plugin);
|
|
13
16
|
this.assetService = new AssetService_1.AssetService(this.plugin, this.assetHistoryService);
|
|
14
17
|
this.assetController = new AssetsController_1.AssetsController(this.plugin, this.assetService);
|
|
18
|
+
this.assetGroupsController = new AssetsGroupsController_1.AssetsGroupsController(this.plugin);
|
|
19
|
+
this.plugin.api["device-manager/assetsGroup"] =
|
|
20
|
+
this.assetGroupsController.definition;
|
|
15
21
|
this.plugin.api["device-manager/assets"] = this.assetController.definition;
|
|
16
22
|
this.plugin.imports.roles[RoleAssetsAdmin_1.RoleAssetsAdmin.name] =
|
|
17
23
|
RoleAssetsAdmin_1.RoleAssetsAdmin.definition;
|
|
18
24
|
this.plugin.imports.roles[RoleAssetsReader_1.RoleAssetsReader.name] =
|
|
19
25
|
RoleAssetsReader_1.RoleAssetsReader.definition;
|
|
26
|
+
this.plugin.imports.roles[RoleAssetsGroupsAdmin_1.RoleAssetsGroupsAdmin.name] =
|
|
27
|
+
RoleAssetsGroupsAdmin_1.RoleAssetsGroupsAdmin.definition;
|
|
28
|
+
this.plugin.imports.roles[RoleAssetsGroupsReader_1.RoleAssetsGroupsReader.name] =
|
|
29
|
+
RoleAssetsGroupsReader_1.RoleAssetsGroupsReader.definition;
|
|
20
30
|
}
|
|
21
31
|
}
|
|
22
32
|
exports.AssetModule = AssetModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetModule.js","sourceRoot":"","sources":["../../../../lib/modules/asset/AssetModule.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAE1C,+DAA4D;AAC5D,yDAAsD;AACtD,iDAA8C;AAC9C,6DAA0D;AAC1D,+DAA4D;
|
|
1
|
+
{"version":3,"file":"AssetModule.js","sourceRoot":"","sources":["../../../../lib/modules/asset/AssetModule.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAE1C,+DAA4D;AAC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
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ControllerDefinition, KuzzleRequest } from "kuzzle";
|
|
2
|
+
import { DeviceManagerPlugin } from "../plugin";
|
|
3
|
+
import { ApiGroupAddAssetsResult, ApiGroupCreateResult, ApiGroupDeleteResult, ApiGroupGetResult, ApiGroupRemoveAssetsResult, ApiGroupSearchResult, ApiGroupUpdateResult, AssetsGroupsBodyRequest } from "./types/AssetGroupsApi";
|
|
4
|
+
export declare class AssetsGroupsController {
|
|
5
|
+
private plugin;
|
|
6
|
+
definition: ControllerDefinition;
|
|
7
|
+
constructor(plugin: DeviceManagerPlugin);
|
|
8
|
+
private get sdk();
|
|
9
|
+
private get as();
|
|
10
|
+
checkParent(engineId: string, parent: AssetsGroupsBodyRequest["parent"]): Promise<void>;
|
|
11
|
+
checkChildren(engineId: string, children: AssetsGroupsBodyRequest["children"]): Promise<void>;
|
|
12
|
+
checkGroupName(engineId: string, name: AssetsGroupsBodyRequest["name"], assetId?: string): Promise<void>;
|
|
13
|
+
create(request: KuzzleRequest): Promise<ApiGroupCreateResult>;
|
|
14
|
+
get(request: KuzzleRequest): Promise<ApiGroupGetResult>;
|
|
15
|
+
update(request: KuzzleRequest): Promise<ApiGroupUpdateResult>;
|
|
16
|
+
delete(request: KuzzleRequest): Promise<ApiGroupDeleteResult>;
|
|
17
|
+
search(request: KuzzleRequest): Promise<ApiGroupSearchResult>;
|
|
18
|
+
addAsset(request: KuzzleRequest): Promise<ApiGroupAddAssetsResult>;
|
|
19
|
+
removeAsset(request: KuzzleRequest): Promise<ApiGroupRemoveAssetsResult>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssetsGroupsController = void 0;
|
|
4
|
+
const kuzzle_1 = require("kuzzle");
|
|
5
|
+
const plugin_1 = require("../plugin");
|
|
6
|
+
class AssetsGroupsController {
|
|
7
|
+
constructor(plugin) {
|
|
8
|
+
this.plugin = plugin;
|
|
9
|
+
/* eslint-disable sort-keys */
|
|
10
|
+
this.definition = {
|
|
11
|
+
actions: {
|
|
12
|
+
create: {
|
|
13
|
+
handler: this.create.bind(this),
|
|
14
|
+
http: [
|
|
15
|
+
{
|
|
16
|
+
path: "device-manager/:engineId/assetsGroups/:_id",
|
|
17
|
+
verb: "post",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
get: {
|
|
22
|
+
handler: this.get.bind(this),
|
|
23
|
+
http: [
|
|
24
|
+
{ path: "device-manager/:engineId/assetsGroups/:_id", verb: "get" },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
update: {
|
|
28
|
+
handler: this.update.bind(this),
|
|
29
|
+
http: [
|
|
30
|
+
{ path: "device-manager/:engineId/assetsGroups/:_id", verb: "put" },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
delete: {
|
|
34
|
+
handler: this.delete.bind(this),
|
|
35
|
+
http: [
|
|
36
|
+
{
|
|
37
|
+
path: "device-manager/:engineId/assetsGroups/:_id",
|
|
38
|
+
verb: "delete",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
search: {
|
|
43
|
+
handler: this.search.bind(this),
|
|
44
|
+
http: [
|
|
45
|
+
{
|
|
46
|
+
path: "device-manager/:engineId/assetsGroups/_search",
|
|
47
|
+
verb: "get",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
path: "device-manager/:engineId/assetsGroups/_search",
|
|
51
|
+
verb: "post",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
addAsset: {
|
|
56
|
+
handler: this.addAsset.bind(this),
|
|
57
|
+
http: [
|
|
58
|
+
{
|
|
59
|
+
path: "device-manager/:engineId/assetsGroups/:_id/addAsset",
|
|
60
|
+
verb: "post",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
removeAsset: {
|
|
65
|
+
handler: this.removeAsset.bind(this),
|
|
66
|
+
http: [
|
|
67
|
+
{
|
|
68
|
+
path: "device-manager/:engineId/assetsGroups/:_id/removeAsset",
|
|
69
|
+
verb: "post",
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
/* eslint-enable sort-keys */
|
|
76
|
+
}
|
|
77
|
+
get sdk() {
|
|
78
|
+
return this.plugin.context.accessors.sdk;
|
|
79
|
+
}
|
|
80
|
+
get as() {
|
|
81
|
+
return (user) => {
|
|
82
|
+
if (user?._id) {
|
|
83
|
+
return this.sdk.as(user, { checkRights: true });
|
|
84
|
+
}
|
|
85
|
+
return this.sdk;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
async checkParent(engineId, parent) {
|
|
89
|
+
if (typeof parent !== "string") {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const assetGroup = await this.sdk.document.get(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, parent);
|
|
94
|
+
if (assetGroup._source.parent !== null) {
|
|
95
|
+
throw new kuzzle_1.BadRequestError(`Can't create asset group with more than one nesting level`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (error.status === 404) {
|
|
100
|
+
throw new kuzzle_1.BadRequestError(`The parent group "${parent}" does not exist`);
|
|
101
|
+
}
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async checkChildren(engineId, children) {
|
|
106
|
+
if (!Array.isArray(children)) {
|
|
107
|
+
throw new kuzzle_1.BadRequestError("The Children property should be an array");
|
|
108
|
+
}
|
|
109
|
+
if (children.length === 0) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const { result } = await this.sdk.query({
|
|
113
|
+
action: "mExists",
|
|
114
|
+
body: {
|
|
115
|
+
ids: children,
|
|
116
|
+
},
|
|
117
|
+
collection: plugin_1.InternalCollection.ASSETS_GROUPS,
|
|
118
|
+
controller: "document",
|
|
119
|
+
index: engineId,
|
|
120
|
+
});
|
|
121
|
+
if (Array.isArray(result.errors) && result.errors.length > 0) {
|
|
122
|
+
throw new kuzzle_1.BadRequestError(`The children group "${result.errors.join(",")}" does not exist`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async checkGroupName(engineId, name, assetId) {
|
|
126
|
+
if (typeof name !== "string") {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const groupsCount = await this.sdk.document.count(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, {
|
|
130
|
+
query: {
|
|
131
|
+
bool: {
|
|
132
|
+
must: [
|
|
133
|
+
{
|
|
134
|
+
regexp: {
|
|
135
|
+
name: {
|
|
136
|
+
case_insensitive: true,
|
|
137
|
+
value: name,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
must_not: [
|
|
143
|
+
{
|
|
144
|
+
terms: {
|
|
145
|
+
_id: typeof assetId === "string" ? [assetId] : [],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
if (groupsCount > 0) {
|
|
153
|
+
throw new kuzzle_1.BadRequestError(`A group with name "${name}" already exist`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async create(request) {
|
|
157
|
+
const engineId = request.getString("engineId");
|
|
158
|
+
const _id = request.getId({
|
|
159
|
+
generator: () => kuzzle_1.NameGenerator.generateRandomName({ prefix: "group" }),
|
|
160
|
+
ifMissing: "generate",
|
|
161
|
+
});
|
|
162
|
+
const body = request.getBody();
|
|
163
|
+
await this.checkParent(engineId, body.parent);
|
|
164
|
+
await this.checkGroupName(engineId, body.name);
|
|
165
|
+
if (typeof body.name !== "string") {
|
|
166
|
+
throw new kuzzle_1.BadRequestError(`A group must have a name`);
|
|
167
|
+
}
|
|
168
|
+
if (typeof body.parent === "string") {
|
|
169
|
+
const parentGroup = await this.sdk.document.get(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, body.parent);
|
|
170
|
+
const children = parentGroup._source.children ?? [];
|
|
171
|
+
children.push(_id);
|
|
172
|
+
await this.sdk.document.update(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, body.parent, {
|
|
173
|
+
children,
|
|
174
|
+
lastUpdate: Date.now(),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return this.as(request.getUser()).document.create(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, {
|
|
178
|
+
children: [],
|
|
179
|
+
lastUpdate: Date.now(),
|
|
180
|
+
name: body.name,
|
|
181
|
+
parent: body.parent ?? null,
|
|
182
|
+
}, _id);
|
|
183
|
+
}
|
|
184
|
+
async get(request) {
|
|
185
|
+
const engineId = request.getString("engineId");
|
|
186
|
+
const _id = request.getId();
|
|
187
|
+
return this.as(request.getUser()).document.get(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, _id);
|
|
188
|
+
}
|
|
189
|
+
async update(request) {
|
|
190
|
+
const engineId = request.getString("engineId");
|
|
191
|
+
const _id = request.getId();
|
|
192
|
+
const body = request.getBody();
|
|
193
|
+
await this.checkParent(engineId, body.parent);
|
|
194
|
+
await this.checkChildren(engineId, body.children);
|
|
195
|
+
await this.checkGroupName(engineId, body.name, _id);
|
|
196
|
+
return this.as(request.getUser()).document.update(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, _id, {
|
|
197
|
+
parent: null,
|
|
198
|
+
...body,
|
|
199
|
+
lastUpdate: Date.now(),
|
|
200
|
+
}, { source: true });
|
|
201
|
+
}
|
|
202
|
+
async delete(request) {
|
|
203
|
+
const engineId = request.getString("engineId");
|
|
204
|
+
const _id = request.getId();
|
|
205
|
+
const { _source: assetGroup } = await this.sdk.document.get(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, _id);
|
|
206
|
+
if (assetGroup.parent !== null) {
|
|
207
|
+
const { _source: parentGroup } = await this.sdk.document.get(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, assetGroup.parent);
|
|
208
|
+
await this.sdk.document.update(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, assetGroup.parent, {
|
|
209
|
+
children: parentGroup.children.filter((children) => children !== _id),
|
|
210
|
+
lastUpdate: Date.now(),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
await this.sdk.document.mUpdate(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, assetGroup.children.map((childrenId) => ({
|
|
214
|
+
_id: childrenId,
|
|
215
|
+
body: {
|
|
216
|
+
lastUpdate: Date.now(),
|
|
217
|
+
parent: null,
|
|
218
|
+
},
|
|
219
|
+
})), { strict: true });
|
|
220
|
+
const { hits: assets } = await this.sdk.document.search(engineId, plugin_1.InternalCollection.ASSETS, { query: { equals: { "groups.id": _id } } }, { lang: "koncorde" });
|
|
221
|
+
await this.sdk.document.mUpdate(engineId, plugin_1.InternalCollection.ASSETS, assets.map((asset) => ({
|
|
222
|
+
_id: asset._id,
|
|
223
|
+
body: {
|
|
224
|
+
groups: asset._source.groups.filter(({ id: groupId }) => groupId !== _id),
|
|
225
|
+
},
|
|
226
|
+
})), { strict: true });
|
|
227
|
+
await this.as(request.getUser()).document.delete(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, _id);
|
|
228
|
+
}
|
|
229
|
+
async search(request) {
|
|
230
|
+
const engineId = request.getString("engineId");
|
|
231
|
+
const { searchBody, from, size, scrollTTL: scroll, } = request.getSearchParams();
|
|
232
|
+
const lang = request.getLangParam();
|
|
233
|
+
return this.as(request.getUser()).document.search(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, searchBody, { from, lang, scroll, size });
|
|
234
|
+
}
|
|
235
|
+
async addAsset(request) {
|
|
236
|
+
const engineId = request.getString("engineId");
|
|
237
|
+
const _id = request.getId();
|
|
238
|
+
const body = request.getBody();
|
|
239
|
+
// ? Get document to check if really exists, even if not indexed
|
|
240
|
+
const assetGroup = await this.sdk.document.get(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, _id);
|
|
241
|
+
const assets = [];
|
|
242
|
+
for (const assetId of body.assetIds) {
|
|
243
|
+
const assetContent = (await this.sdk.document.get(engineId, plugin_1.InternalCollection.ASSETS, assetId))._source;
|
|
244
|
+
if (!Array.isArray(assetContent.groups)) {
|
|
245
|
+
assetContent.groups = [];
|
|
246
|
+
}
|
|
247
|
+
if (assetGroup._source.parent !== null) {
|
|
248
|
+
assetContent.groups.push({
|
|
249
|
+
date: Date.now(),
|
|
250
|
+
id: assetGroup._source.parent,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
assetContent.groups.push({
|
|
254
|
+
date: Date.now(),
|
|
255
|
+
id: _id,
|
|
256
|
+
});
|
|
257
|
+
assets.push({
|
|
258
|
+
_id: assetId,
|
|
259
|
+
body: assetContent,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
const assetsGroupsUpdate = await this.as(request.getUser()).document.update(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, _id, {
|
|
263
|
+
lastUpdate: Date.now(),
|
|
264
|
+
}, { source: true });
|
|
265
|
+
const update = await this.sdk.document.mReplace(engineId, plugin_1.InternalCollection.ASSETS, assets);
|
|
266
|
+
return {
|
|
267
|
+
...update,
|
|
268
|
+
assetsGroups: assetsGroupsUpdate,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
async removeAsset(request) {
|
|
272
|
+
const engineId = request.getString("engineId");
|
|
273
|
+
const _id = request.getId();
|
|
274
|
+
const body = request.getBody();
|
|
275
|
+
// ? Get document to check if really exists, even if not indexed
|
|
276
|
+
const { _source: AssetGroupContent } = await this.sdk.document.get(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, _id);
|
|
277
|
+
const removedGroups = AssetGroupContent.children;
|
|
278
|
+
removedGroups.push(_id);
|
|
279
|
+
const assets = [];
|
|
280
|
+
for (const assetId of body.assetIds) {
|
|
281
|
+
const assetContent = (await this.sdk.document.get(engineId, plugin_1.InternalCollection.ASSETS, assetId))._source;
|
|
282
|
+
if (!Array.isArray(assetContent.groups)) {
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
assetContent.groups = assetContent.groups.filter(({ id: groupId }) => !removedGroups.includes(groupId));
|
|
286
|
+
assets.push({
|
|
287
|
+
_id: assetId,
|
|
288
|
+
body: assetContent,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
const assetsGroupsUpdate = await this.as(request.getUser()).document.update(engineId, plugin_1.InternalCollection.ASSETS_GROUPS, _id, {
|
|
292
|
+
lastUpdate: Date.now(),
|
|
293
|
+
}, { source: true });
|
|
294
|
+
const update = await this.sdk.document.mReplace(engineId, plugin_1.InternalCollection.ASSETS, assets);
|
|
295
|
+
return {
|
|
296
|
+
...update,
|
|
297
|
+
assetsGroups: assetsGroupsUpdate,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
exports.AssetsGroupsController = AssetsGroupsController;
|
|
302
|
+
//# sourceMappingURL=AssetsGroupsController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssetsGroupsController.js","sourceRoot":"","sources":["../../../../lib/modules/asset/AssetsGroupsController.ts"],"names":[],"mappings":";;;AAAA,mCAOgB;AAEhB,sCAAoE;AAmBpE,MAAa,sBAAsB;IAGjC,YAAoB,MAA2B;QAA3B,WAAM,GAAN,MAAM,CAAqB;QAC7C,8BAA8B;QAC9B,IAAI,CAAC,UAAU,GAAG;YAChB,OAAO,EAAE;gBACP,MAAM,EAAE;oBACN,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;oBAC/B,IAAI,EAAE;wBACJ;4BACE,IAAI,EAAE,4CAA4C;4BAClD,IAAI,EAAE,MAAM;yBACb;qBACF;iBACF;gBACD,GAAG,EAAE;oBACH,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI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CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;gBACvC,SAAS;aACV;YAED,YAAY,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,CAC9C,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CACtD,CAAC;YAEF,MAAM,CAAC,IAAI,CAAC;gBACV,GAAG,EAAE,OAAO;gBACZ,IAAI,EAAE,YAAY;aACnB,CAAC,CAAC;SACJ;QAED,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,EAAE,CACtC,OAAO,CAAC,OAAO,EAAE,CAClB,CAAC,QAAQ,CAAC,MAAM,CACf,QAAQ,EACR,2BAAkB,CAAC,aAAa,EAChC,GAAG,EACH;YACE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;SACvB,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAC7C,QAAQ,EACR,2BAAkB,CAAC,MAAM,EACzB,MAAM,CACP,CAAC;QAEF,OAAO;YACL,GAAG,MAAM;YACT,YAAY,EAAE,kBAAkB;SACjC,CAAC;IACJ,CAAC;CACF;AA1eD,wDA0eC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assetGroupsMappings = void 0;
|
|
4
|
+
exports.assetGroupsMappings = {
|
|
5
|
+
dynamic: "strict",
|
|
6
|
+
properties: {
|
|
7
|
+
children: {
|
|
8
|
+
fields: {
|
|
9
|
+
text: {
|
|
10
|
+
type: "text",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
type: "keyword",
|
|
14
|
+
},
|
|
15
|
+
name: {
|
|
16
|
+
fields: {
|
|
17
|
+
text: {
|
|
18
|
+
type: "text",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
type: "keyword",
|
|
22
|
+
},
|
|
23
|
+
parent: {
|
|
24
|
+
fields: {
|
|
25
|
+
text: {
|
|
26
|
+
type: "text",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
type: "keyword",
|
|
30
|
+
},
|
|
31
|
+
lastUpdate: {
|
|
32
|
+
type: "date",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=assetsGroupsMapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assetsGroupsMapping.js","sourceRoot":"","sources":["../../../../../lib/modules/asset/collections/assetsGroupsMapping.ts"],"names":[],"mappings":";;;AAEa,QAAA,mBAAmB,GAAuB;IACrD,OAAO,EAAE,QAAQ;IACjB,UAAU,EAAE;QACV,QAAQ,EAAE;YACR,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;iBACb;aACF;YACD,IAAI,EAAE,SAAS;SAChB;QACD,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;iBACb;aACF;YACD,IAAI,EAAE,SAAS;SAChB;QACD,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;iBACb;aACF;YACD,IAAI,EAAE,SAAS;SAChB;QACD,UAAU,EAAE;YACV,IAAI,EAAE,MAAM;SACb;KACF;CACF,CAAC"}
|
|
@@ -1,52 +1,7 @@
|
|
|
1
|
+
import { CollectionMappings } from "kuzzle";
|
|
1
2
|
/**
|
|
2
3
|
* Base mappings for the "assets" collection.
|
|
3
4
|
*
|
|
4
5
|
* Those mappings does not contains the `measures` and `metadata` mappings.
|
|
5
6
|
*/
|
|
6
|
-
export declare const assetsMappings:
|
|
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
|
-
metadata: {
|
|
26
|
-
properties: {};
|
|
27
|
-
};
|
|
28
|
-
measures: {
|
|
29
|
-
properties: {};
|
|
30
|
-
};
|
|
31
|
-
linkedDevices: {
|
|
32
|
-
properties: {
|
|
33
|
-
_id: {
|
|
34
|
-
type: string;
|
|
35
|
-
};
|
|
36
|
-
measureNames: {
|
|
37
|
-
properties: {
|
|
38
|
-
asset: {
|
|
39
|
-
type: string;
|
|
40
|
-
};
|
|
41
|
-
device: {
|
|
42
|
-
type: string;
|
|
43
|
-
};
|
|
44
|
-
type: {
|
|
45
|
-
type: string;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
};
|
|
7
|
+
export declare const assetsMappings: CollectionMappings;
|
|
@@ -17,6 +17,15 @@ exports.assetsMappings = {
|
|
|
17
17
|
type: "keyword",
|
|
18
18
|
fields: { text: { type: "text" } },
|
|
19
19
|
},
|
|
20
|
+
groups: {
|
|
21
|
+
properties: {
|
|
22
|
+
id: {
|
|
23
|
+
type: "keyword",
|
|
24
|
+
fields: { text: { type: "text" } },
|
|
25
|
+
},
|
|
26
|
+
date: { type: "date" },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
20
29
|
metadata: {
|
|
21
30
|
properties: {
|
|
22
31
|
// populated with asset models
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetsMappings.js","sourceRoot":"","sources":["../../../../../lib/modules/asset/collections/assetsMappings.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"assetsMappings.js","sourceRoot":"","sources":["../../../../../lib/modules/asset/collections/assetsMappings.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACU,QAAA,cAAc,GAAuB;IAChD,OAAO,EAAE,QAAQ;IACjB,UAAU,EAAE;QACV,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;SACnC;QACD,SAAS,EAAE;YACT,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;SACnC;QACD,MAAM,EAAE;YACN,UAAU,EAAE;gBACV,EAAE,EAAE;oBACF,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;iBACnC;gBACD,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;aACvB;SACF;QAED,QAAQ,EAAE;YACR,UAAU,EAAE;YACV,8BAA8B;aAC/B;SACF;QAED,QAAQ,EAAE;YACR,UAAU,EAAE;YACV,8BAA8B;aAC/B;SACF;QAED,aAAa,EAAE;YACb,UAAU,EAAE;gBACV,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;gBACxB,YAAY,EAAE;oBACZ,UAAU,EAAE;wBACV,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;wBAC1B,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;wBAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;qBAC1B;iBACF;aACF;SACF;KACF;CACF,CAAC"}
|
|
@@ -2,7 +2,11 @@ export * from "./types/AssetContent";
|
|
|
2
2
|
export * from "./types/AssetHistoryContent";
|
|
3
3
|
export * from "./types/AssetEvents";
|
|
4
4
|
export * from "./types/AssetApi";
|
|
5
|
+
export * from "./types/AssetGroupContent";
|
|
6
|
+
export * from "./types/AssetGroupsApi";
|
|
5
7
|
export * from "./roles/RoleAssetsAdmin";
|
|
6
8
|
export * from "./roles/RoleAssetsReader";
|
|
9
|
+
export * from "./roles/RoleAssetsGroupsAdmin";
|
|
10
|
+
export * from "./roles/RoleAssetsGroupsReader";
|
|
7
11
|
export * from "./collections/assetsMappings";
|
|
8
12
|
export * from "./collections/assetsHistoryMappings";
|
|
@@ -18,8 +18,12 @@ __exportStar(require("./types/AssetContent"), exports);
|
|
|
18
18
|
__exportStar(require("./types/AssetHistoryContent"), exports);
|
|
19
19
|
__exportStar(require("./types/AssetEvents"), exports);
|
|
20
20
|
__exportStar(require("./types/AssetApi"), exports);
|
|
21
|
+
__exportStar(require("./types/AssetGroupContent"), exports);
|
|
22
|
+
__exportStar(require("./types/AssetGroupsApi"), exports);
|
|
21
23
|
__exportStar(require("./roles/RoleAssetsAdmin"), exports);
|
|
22
24
|
__exportStar(require("./roles/RoleAssetsReader"), exports);
|
|
25
|
+
__exportStar(require("./roles/RoleAssetsGroupsAdmin"), exports);
|
|
26
|
+
__exportStar(require("./roles/RoleAssetsGroupsReader"), exports);
|
|
23
27
|
__exportStar(require("./collections/assetsMappings"), exports);
|
|
24
28
|
__exportStar(require("./collections/assetsHistoryMappings"), exports);
|
|
25
29
|
//# sourceMappingURL=exports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../../lib/modules/asset/exports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,8DAA4C;AAC5C,sDAAoC;AACpC,mDAAiC;AACjC,0DAAwC;AACxC,2DAAyC;AACzC,+DAA6C;AAC7C,sEAAoD"}
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../../lib/modules/asset/exports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,8DAA4C;AAC5C,sDAAoC;AACpC,mDAAiC;AACjC,4DAA0C;AAC1C,yDAAuC;AACvC,0DAAwC;AACxC,2DAAyC;AACzC,gEAA8C;AAC9C,iEAA+C;AAC/C,+DAA6C;AAC7C,sEAAoD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./collections/assetsMappings";
|
|
2
2
|
export * from "./collections/assetsHistoryMappings";
|
|
3
|
+
export * from "./collections/assetsGroupsMapping";
|
|
3
4
|
export * from "./types/AssetContent";
|
|
4
5
|
export * from "./types/AssetHistoryContent";
|
|
5
6
|
export * from "./types/AssetEvents";
|
|
@@ -8,3 +9,5 @@ export * from "./model/AssetSerializer";
|
|
|
8
9
|
export * from "./AssetModule";
|
|
9
10
|
export * from "./roles/RoleAssetsAdmin";
|
|
10
11
|
export * from "./roles/RoleAssetsReader";
|
|
12
|
+
export * from "./roles/RoleAssetsGroupsAdmin";
|
|
13
|
+
export * from "./roles/RoleAssetsGroupsReader";
|
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./collections/assetsMappings"), exports);
|
|
18
18
|
__exportStar(require("./collections/assetsHistoryMappings"), exports);
|
|
19
|
+
__exportStar(require("./collections/assetsGroupsMapping"), exports);
|
|
19
20
|
__exportStar(require("./types/AssetContent"), exports);
|
|
20
21
|
__exportStar(require("./types/AssetHistoryContent"), exports);
|
|
21
22
|
__exportStar(require("./types/AssetEvents"), exports);
|
|
@@ -24,4 +25,6 @@ __exportStar(require("./model/AssetSerializer"), exports);
|
|
|
24
25
|
__exportStar(require("./AssetModule"), exports);
|
|
25
26
|
__exportStar(require("./roles/RoleAssetsAdmin"), exports);
|
|
26
27
|
__exportStar(require("./roles/RoleAssetsReader"), exports);
|
|
28
|
+
__exportStar(require("./roles/RoleAssetsGroupsAdmin"), exports);
|
|
29
|
+
__exportStar(require("./roles/RoleAssetsGroupsReader"), exports);
|
|
27
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/modules/asset/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C;AAC7C,sEAAoD;AACpD,uDAAqC;AACrC,8DAA4C;AAC5C,sDAAoC;AACpC,mDAAiC;AACjC,0DAAwC;AACxC,gDAA8B;AAC9B,0DAAwC;AACxC,2DAAyC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/modules/asset/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C;AAC7C,sEAAoD;AACpD,oEAAkD;AAClD,uDAAqC;AACrC,8DAA4C;AAC5C,sDAAoC;AACpC,mDAAiC;AACjC,0DAAwC;AACxC,gDAA8B;AAC9B,0DAAwC;AACxC,2DAAyC;AACzC,gEAA8C;AAC9C,iEAA+C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { KuzzleRole } from "../../shared/types/KuzzleRole";
|
|
2
|
+
/**
|
|
3
|
+
* This role allows to manage assets and their models.
|
|
4
|
+
*
|
|
5
|
+
* It's a tenant role.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
"device-manager/assets": {
|
|
10
|
+
actions: {
|
|
11
|
+
"*": true,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
"device-manager/models": {
|
|
15
|
+
actions: {
|
|
16
|
+
deleteAsset: true,
|
|
17
|
+
listAssets: true,
|
|
18
|
+
getAsset: true,
|
|
19
|
+
writeAsset: true,
|
|
20
|
+
listMeasures: true,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
*/
|
|
24
|
+
export declare const RoleAssetsGroupsAdmin: KuzzleRole;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RoleAssetsGroupsAdmin = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This role allows to manage assets and their models.
|
|
6
|
+
*
|
|
7
|
+
* It's a tenant role.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
"device-manager/assets": {
|
|
12
|
+
actions: {
|
|
13
|
+
"*": true,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
"device-manager/models": {
|
|
17
|
+
actions: {
|
|
18
|
+
deleteAsset: true,
|
|
19
|
+
listAssets: true,
|
|
20
|
+
getAsset: true,
|
|
21
|
+
writeAsset: true,
|
|
22
|
+
listMeasures: true,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
*/
|
|
26
|
+
exports.RoleAssetsGroupsAdmin = {
|
|
27
|
+
name: "assetsGroup.admin",
|
|
28
|
+
definition: {
|
|
29
|
+
controllers: {
|
|
30
|
+
"device-manager/assetsGroup": {
|
|
31
|
+
actions: {
|
|
32
|
+
"*": true,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=RoleAssetsGroupsAdmin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoleAssetsGroupsAdmin.js","sourceRoot":"","sources":["../../../../../lib/modules/asset/roles/RoleAssetsGroupsAdmin.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACU,QAAA,qBAAqB,GAAe;IAC/C,IAAI,EAAE,mBAAmB;IACzB,UAAU,EAAE;QACV,WAAW,EAAE;YACX,4BAA4B,EAAE;gBAC5B,OAAO,EAAE;oBACP,GAAG,EAAE,IAAI;iBACV;aACF;SACF;KACF;CACF,CAAC"}
|