@c8y/client 1018.505.8 → 1018.509.6
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/lib/bundles/client.umd.js +5 -152
- package/lib/bundles/client.umd.js.map +1 -1
- package/lib/bundles/client.umd.min.js +1 -1
- package/lib/bundles/client.umd.min.js.map +1 -1
- package/lib/cjs/src/smart-groups/SmartGroupsService.d.ts +2 -80
- package/lib/cjs/src/smart-groups/SmartGroupsService.js +5 -136
- package/lib/cjs/src/smart-groups/SmartGroupsService.js.map +1 -1
- package/lib/esm2015/src/smart-groups/SmartGroupsService.d.ts +2 -80
- package/lib/esm2015/src/smart-groups/SmartGroupsService.js +5 -153
- package/lib/esm2015/src/smart-groups/SmartGroupsService.js.map +1 -1
- package/lib/src/smart-groups/SmartGroupsService.d.ts +2 -80
- package/package.json +1 -1
|
@@ -10849,17 +10849,6 @@
|
|
|
10849
10849
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10850
10850
|
});
|
|
10851
10851
|
};
|
|
10852
|
-
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
10853
|
-
var t = {};
|
|
10854
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
10855
|
-
t[p] = s[p];
|
|
10856
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
10857
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
10858
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
10859
|
-
t[p[i]] = s[p[i]];
|
|
10860
|
-
}
|
|
10861
|
-
return t;
|
|
10862
|
-
};
|
|
10863
10852
|
class SmartGroupsService extends Service {
|
|
10864
10853
|
constructor(client) {
|
|
10865
10854
|
super(client);
|
|
@@ -10867,16 +10856,9 @@
|
|
|
10867
10856
|
this.listUrl = 'managedObjects';
|
|
10868
10857
|
this.SMART_GROUP_TYPE = 'c8y_DynamicGroup';
|
|
10869
10858
|
this.SMART_GROUP_FRAGMENT_TYPE = 'c8y_IsDynamicGroup';
|
|
10870
|
-
this.DEVICE_GROUP_FRAGMENT_TYPE = 'c8y_IsDeviceGroup';
|
|
10871
|
-
this.DEVICE_GROUP_TYPE = 'c8y_DeviceGroup';
|
|
10872
|
-
this.DEVICE_SUBGROUP_TYPE = 'c8y_DeviceSubgroup';
|
|
10873
10859
|
this.COLUMNS_CONFIG_FRAGMENT = 'c8y_DeviceColumnsConfig';
|
|
10874
10860
|
this.FILTER_CONFIG_FRAGMENT = 'c8y_DeviceFilterConfig';
|
|
10875
10861
|
this.QUERY_STRING_FRAGMENT = 'c8y_DeviceQueryString';
|
|
10876
|
-
this.SMART_GROUPS_V2_MICROSERVICE_APP_NAME = 'smartgroup';
|
|
10877
|
-
this.SMART_GROUPS_V2_MICROSERVICE_BASE_PATH = 'service/smartgroup';
|
|
10878
|
-
this.SMART_GROUPS_V2_MICROSERVICE_ENDPOINT_PATH = `${this.SMART_GROUPS_V2_MICROSERVICE_BASE_PATH}/smartgroups`;
|
|
10879
|
-
this.applicationService = new ApplicationService(client);
|
|
10880
10862
|
}
|
|
10881
10863
|
/**
|
|
10882
10864
|
* Gets the details of managed object
|
|
@@ -10941,16 +10923,14 @@
|
|
|
10941
10923
|
create: { get: () => super.create }
|
|
10942
10924
|
});
|
|
10943
10925
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
10944
|
-
const { data: isInstalled } = yield this.isSmartGroupsV2MicroserviceInstalled();
|
|
10945
10926
|
const entity = Object.assign(Object.assign(Object.assign({}, obj.smartGroup), { [this.QUERY_STRING_FRAGMENT]: obj.deviceQueryString, [this.COLUMNS_CONFIG_FRAGMENT]: obj.configurableColumns }), (obj.filterConfig && { [this.FILTER_CONFIG_FRAGMENT]: obj.filterConfig }));
|
|
10946
|
-
return
|
|
10927
|
+
return _super.create.call(this, entity);
|
|
10947
10928
|
});
|
|
10948
10929
|
}
|
|
10949
10930
|
/**
|
|
10950
10931
|
* Updates smart group managed object with given id.
|
|
10951
10932
|
*
|
|
10952
10933
|
* @param {Partial<IManagedObject>} mo Partial managed object of the smart group.
|
|
10953
|
-
* @param {object} filter Filter object.
|
|
10954
10934
|
*
|
|
10955
10935
|
* @returns Response wrapped in [[IResult]]
|
|
10956
10936
|
*
|
|
@@ -10964,47 +10944,12 @@
|
|
|
10964
10944
|
* })();
|
|
10965
10945
|
* ```
|
|
10966
10946
|
*/
|
|
10967
|
-
update(mo
|
|
10947
|
+
update(mo) {
|
|
10968
10948
|
const _super = Object.create(null, {
|
|
10969
10949
|
update: { get: () => super.update }
|
|
10970
10950
|
});
|
|
10971
10951
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
10972
|
-
|
|
10973
|
-
const { data: isInstalled } = yield this.isSmartGroupsV2MicroserviceInstalled();
|
|
10974
|
-
const { data: groupMo } = yield this.detail(id, { withChildren: false });
|
|
10975
|
-
return isInstalled && this.isSmartGroupV2(groupMo)
|
|
10976
|
-
? this.updateSmartGroupV2(mo, filter)
|
|
10977
|
-
: _super.update.call(this, mo);
|
|
10978
|
-
});
|
|
10979
|
-
}
|
|
10980
|
-
/**
|
|
10981
|
-
* Updates smart group v2 managed object with given id.
|
|
10982
|
-
*
|
|
10983
|
-
* @param {Partial<IManagedObject>} mo Partial managed object of the smart group v2.
|
|
10984
|
-
* @param {object} filter Filter object.
|
|
10985
|
-
*
|
|
10986
|
-
* @returns Response wrapped in [[IResult]]
|
|
10987
|
-
*
|
|
10988
|
-
* @example
|
|
10989
|
-
* ```typescript
|
|
10990
|
-
*
|
|
10991
|
-
* const smartGroupV2 = { id: '1', name: 'newName' };
|
|
10992
|
-
*
|
|
10993
|
-
* (async () => {
|
|
10994
|
-
* await smartGroupsService.updateSmartGroupV2(smartGroupV2);
|
|
10995
|
-
* })();
|
|
10996
|
-
* ```
|
|
10997
|
-
*/
|
|
10998
|
-
updateSmartGroupV2(mo, filter = {}) {
|
|
10999
|
-
return __awaiter$2(this, void 0, void 0, function* () {
|
|
11000
|
-
const { id } = mo, partialMo = __rest(mo, ["id"]);
|
|
11001
|
-
const method = 'PUT';
|
|
11002
|
-
const body = JSON.stringify(this.onBeforeUpdate(partialMo));
|
|
11003
|
-
const headers = { 'content-type': 'application/json', accept: 'application/json' };
|
|
11004
|
-
const url = `${this.SMART_GROUPS_V2_MICROSERVICE_ENDPOINT_PATH}/${id}`;
|
|
11005
|
-
const res = yield this.fetch(url, { method, body, headers, params: Object.assign({}, filter) });
|
|
11006
|
-
const data = yield res.json();
|
|
11007
|
-
return { res, data };
|
|
10952
|
+
return _super.update.call(this, mo);
|
|
11008
10953
|
});
|
|
11009
10954
|
}
|
|
11010
10955
|
/**
|
|
@@ -11033,29 +10978,8 @@
|
|
|
11033
10978
|
delete: { get: () => super.delete }
|
|
11034
10979
|
});
|
|
11035
10980
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
11036
|
-
const { data: isInstalled } = yield this.isSmartGroupsV2MicroserviceInstalled();
|
|
11037
10981
|
const data = (yield this.detail(entityOrId, { withChildren: false })).data;
|
|
11038
|
-
return
|
|
11039
|
-
? yield this.removeSmartGroupV2(data)
|
|
11040
|
-
: yield _super.delete.call(this, data, params);
|
|
11041
|
-
});
|
|
11042
|
-
}
|
|
11043
|
-
/**
|
|
11044
|
-
* Checks if the smart groups v2 microservice is installed.
|
|
11045
|
-
*
|
|
11046
|
-
* @returns Response wrapped in [[IResult]]
|
|
11047
|
-
*
|
|
11048
|
-
* @example
|
|
11049
|
-
* ```typescript
|
|
11050
|
-
*
|
|
11051
|
-
* (async () => {
|
|
11052
|
-
* const {data, res} = await smartGroupsService.isSmartGroupsV2MicroserviceInstalled();
|
|
11053
|
-
* })();
|
|
11054
|
-
* ```
|
|
11055
|
-
*/
|
|
11056
|
-
isSmartGroupsV2MicroserviceInstalled() {
|
|
11057
|
-
return this.applicationService.isAvailable({
|
|
11058
|
-
name: this.SMART_GROUPS_V2_MICROSERVICE_APP_NAME
|
|
10982
|
+
return yield _super.delete.call(this, data, params);
|
|
11059
10983
|
});
|
|
11060
10984
|
}
|
|
11061
10985
|
/**
|
|
@@ -11080,81 +11004,10 @@
|
|
|
11080
11004
|
const isSmartGroupType = mo && mo.type === this.SMART_GROUP_TYPE;
|
|
11081
11005
|
return hasSmartGroupFragmentType || isSmartGroupType;
|
|
11082
11006
|
}
|
|
11083
|
-
/**
|
|
11084
|
-
* Checks whether a given managed object is a smart group v2
|
|
11085
|
-
*
|
|
11086
|
-
* @param {IManagedObject} mo Managed object to check.
|
|
11087
|
-
*
|
|
11088
|
-
* @returns boolean
|
|
11089
|
-
*
|
|
11090
|
-
* @example
|
|
11091
|
-
* ```typescript
|
|
11092
|
-
*
|
|
11093
|
-
* const mo: IManagedObject = {id: 1, type: "c8y_DeviceGroup", c8y_IsDeviceGroup: {}} as IManagedObject;
|
|
11094
|
-
*
|
|
11095
|
-
* (() => {
|
|
11096
|
-
* const isSmartGroup = smartGroupsService.isSmartGroupV2(mo);
|
|
11097
|
-
* })();
|
|
11098
|
-
* ```
|
|
11099
|
-
*/
|
|
11100
|
-
isSmartGroupV2(mo) {
|
|
11101
|
-
const hasSmartGroupFragmentType = mo.hasOwnProperty(this.SMART_GROUP_FRAGMENT_TYPE);
|
|
11102
|
-
const hasDeviceGroupFragmentType = mo.hasOwnProperty(this.DEVICE_GROUP_FRAGMENT_TYPE);
|
|
11103
|
-
const isGroupOrSubgroup = (mo && mo.type === this.DEVICE_GROUP_TYPE) || mo.type === this.DEVICE_SUBGROUP_TYPE;
|
|
11104
|
-
return hasSmartGroupFragmentType && hasDeviceGroupFragmentType && isGroupOrSubgroup;
|
|
11105
|
-
}
|
|
11106
|
-
/**
|
|
11107
|
-
* Removes smart group v2 managed object with given id.
|
|
11108
|
-
*
|
|
11109
|
-
* @param {IdReference} entityOrId entity or Id of the ManagedObject.
|
|
11110
|
-
*
|
|
11111
|
-
* @returns Response wrapped in [[IResult]]
|
|
11112
|
-
*
|
|
11113
|
-
* @example
|
|
11114
|
-
* ```typescript
|
|
11115
|
-
*
|
|
11116
|
-
* const id: string = '1';
|
|
11117
|
-
*
|
|
11118
|
-
* (async () => {
|
|
11119
|
-
* await smartGroupsService.removeSmartGroupV2(id);
|
|
11120
|
-
* })();
|
|
11121
|
-
* ```
|
|
11122
|
-
*/
|
|
11123
|
-
removeSmartGroupV2(entityOrId) {
|
|
11124
|
-
return __awaiter$2(this, void 0, void 0, function* () {
|
|
11125
|
-
let id;
|
|
11126
|
-
if (typeof entityOrId === 'object' && entityOrId.id) {
|
|
11127
|
-
id = entityOrId.id;
|
|
11128
|
-
}
|
|
11129
|
-
else {
|
|
11130
|
-
id = entityOrId;
|
|
11131
|
-
}
|
|
11132
|
-
const method = 'DELETE';
|
|
11133
|
-
const url = `${this.SMART_GROUPS_V2_MICROSERVICE_ENDPOINT_PATH}/${id}`;
|
|
11134
|
-
const res = yield this.client.fetch(url, { method });
|
|
11135
|
-
return { res, data: null };
|
|
11136
|
-
});
|
|
11137
|
-
}
|
|
11138
11007
|
getUrl(url = '') {
|
|
11139
11008
|
const partialUrl = url.replace(/^\/+/, '');
|
|
11140
11009
|
const baseUrl = this.baseUrl.replace(/\/+$/, '');
|
|
11141
|
-
|
|
11142
|
-
return partialUrl;
|
|
11143
|
-
}
|
|
11144
|
-
else {
|
|
11145
|
-
return `${baseUrl}/${partialUrl}`;
|
|
11146
|
-
}
|
|
11147
|
-
}
|
|
11148
|
-
createSmartGroupV2(entity) {
|
|
11149
|
-
return __awaiter$2(this, void 0, void 0, function* () {
|
|
11150
|
-
const method = 'POST';
|
|
11151
|
-
const body = JSON.stringify(entity);
|
|
11152
|
-
const headers = { 'content-type': 'application/json', accept: 'application/json' };
|
|
11153
|
-
const url = this.SMART_GROUPS_V2_MICROSERVICE_ENDPOINT_PATH;
|
|
11154
|
-
const res = yield this.fetch(url, { method, body, headers });
|
|
11155
|
-
const data = yield res.json();
|
|
11156
|
-
return { res, data };
|
|
11157
|
-
});
|
|
11010
|
+
return `${baseUrl}/${partialUrl}`;
|
|
11158
11011
|
}
|
|
11159
11012
|
}
|
|
11160
11013
|
|