@robotbas/robotcloud-client 0.2.22 → 0.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/helpers/index.d.mts +1 -1
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/index.js +209 -20
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/index.mjs +209 -20
- package/dist/helpers/index.mjs.map +1 -1
- package/dist/{index-BQ8vrXpV.d.mts → index-9RfDay_a.d.mts} +295 -99
- package/dist/{index-BQ8vrXpV.d.ts → index-9RfDay_a.d.ts} +295 -99
- package/dist/index.d.mts +351 -164
- package/dist/index.d.ts +351 -164
- package/dist/index.js +545 -178
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +539 -178
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ProjectClassifer.d.ts +11 -1
- package/types/ProjectLocation.d.ts +24 -0
- package/types/ProjectSubsystem.d.ts +4 -0
- package/types/ProjectTag.d.ts +8 -1
- package/types/RobotCloudClient.d.ts +195 -9
- package/types/ServiceInstance.d.ts +27 -5
- package/types/Token.d.ts +15 -7
- package/types/alerts.d.ts +88 -0
- package/types/services-configuration.d.ts +35 -26
- package/types/services-data.d.ts +38 -38
package/dist/index.mjs
CHANGED
|
@@ -76,74 +76,233 @@ __export(robotCloudToken_exports, {
|
|
|
76
76
|
renewToken: () => renewToken,
|
|
77
77
|
validateToken: () => validateToken
|
|
78
78
|
});
|
|
79
|
+
import axios3 from "axios";
|
|
80
|
+
|
|
81
|
+
// src/client/login.ts
|
|
79
82
|
import axios2 from "axios";
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
var LoginClientImpl = class {
|
|
84
|
+
constructor(robotcloudApi2) {
|
|
85
|
+
this.logger = useLogger("LoginClientImpl");
|
|
86
|
+
this.robotcloudApi = robotcloudApi2;
|
|
84
87
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
async login(username, password, apiKey) {
|
|
89
|
+
try {
|
|
90
|
+
const encoded = btoa(`${username}:${password}`);
|
|
91
|
+
const basicString = `Basic ${encoded}`;
|
|
92
|
+
const cloudUrl = this.robotcloudApi.defaults.baseURL;
|
|
93
|
+
return await axios2.get(cloudUrl + "login", {
|
|
94
|
+
headers: {
|
|
95
|
+
Authorization: basicString,
|
|
96
|
+
"x-api-key": apiKey
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
} catch (error) {
|
|
100
|
+
this.logger.error("Error logging in", error);
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
91
103
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const expirationDate = new Date(payload.exp * 1e3);
|
|
104
|
-
const currentDate = /* @__PURE__ */ new Date();
|
|
105
|
-
return currentDate >= expirationDate;
|
|
106
|
-
};
|
|
107
|
-
var renewToken = async (renew_token) => {
|
|
108
|
-
logger2.debug("Renewing token ...");
|
|
109
|
-
const cloudUrl = robotCloudApi_default.defaults.baseURL;
|
|
110
|
-
const { data } = await axios2.get(cloudUrl + "login/renew", {
|
|
111
|
-
headers: {
|
|
112
|
-
Authorization: `Bearer ${renew_token}`
|
|
104
|
+
async renewToken(token) {
|
|
105
|
+
try {
|
|
106
|
+
const cloudUrl = this.robotcloudApi.defaults.baseURL;
|
|
107
|
+
return await axios2.get(cloudUrl + "login/renew", {
|
|
108
|
+
headers: {
|
|
109
|
+
Authorization: `Bearer ${token}`
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
} catch (error) {
|
|
113
|
+
this.logger.error("Error renewing token", error);
|
|
114
|
+
throw error;
|
|
113
115
|
}
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
renewed: true,
|
|
117
|
-
access: data["access"]["token"],
|
|
118
|
-
renew: data["renew"]["token"]
|
|
119
|
-
};
|
|
116
|
+
}
|
|
120
117
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
118
|
+
|
|
119
|
+
// src/client/alerts.ts
|
|
120
|
+
var ALERTS_BY_SERVICE_TYPE = {
|
|
121
|
+
"RoomBLEPairing_1": [],
|
|
122
|
+
"RoomClime_1": [
|
|
123
|
+
"high_temperature",
|
|
124
|
+
"low_temperature",
|
|
125
|
+
"high_humidity",
|
|
126
|
+
"fancoil_on_overtime"
|
|
127
|
+
],
|
|
128
|
+
"RoomConsumes_1": [
|
|
129
|
+
"high_daily_energy_electric",
|
|
130
|
+
"high_daily_energy_thermal",
|
|
131
|
+
"high_daily_hot_water",
|
|
132
|
+
"high_daily_cold_water"
|
|
133
|
+
],
|
|
134
|
+
"RoomDiagnostics_1": [
|
|
135
|
+
"low_peripheral_num"
|
|
136
|
+
],
|
|
137
|
+
"RoomGrouping_1": [],
|
|
138
|
+
"RoomGuestStatus_1": [
|
|
139
|
+
"door_open_overtime",
|
|
140
|
+
"window_open_overtime",
|
|
141
|
+
"medical_alarm"
|
|
142
|
+
]
|
|
143
|
+
};
|
|
144
|
+
var AlertsClientImpl = class {
|
|
145
|
+
constructor(robotcloudApi2) {
|
|
146
|
+
this.logger = useLogger("AlertsClientImpl");
|
|
147
|
+
this.robotcloudApi = robotcloudApi2;
|
|
127
148
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
149
|
+
getProjectStats(projectId, params) {
|
|
150
|
+
return this.robotcloudApi.get(
|
|
151
|
+
`projects/${projectId}/alerts/stats`,
|
|
152
|
+
{ params: params != null ? params : {} }
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
getProjectLog(projectId, params) {
|
|
156
|
+
return this.robotcloudApi.get(
|
|
157
|
+
`projects/${projectId}/alerts/log`,
|
|
132
158
|
{
|
|
133
|
-
|
|
134
|
-
Authorization: `Bearer ${access_token}`
|
|
135
|
-
}
|
|
159
|
+
params
|
|
136
160
|
}
|
|
137
161
|
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
162
|
+
}
|
|
163
|
+
acknowledge(projectId, data) {
|
|
164
|
+
this.logger.debug("Sending put data: ", data);
|
|
165
|
+
return this.robotcloudApi.put(
|
|
166
|
+
`projects/${projectId}/alerts/log`,
|
|
167
|
+
data
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
getAggregatedLogs(projectId, params) {
|
|
171
|
+
return this.robotcloudApi.get(
|
|
172
|
+
`projects/${projectId}/alerts/aggregate`,
|
|
173
|
+
{ params }
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
async getAvailableAlerts(projectId, params) {
|
|
177
|
+
const { data } = await this.robotcloudApi.get(
|
|
178
|
+
`projects/${projectId}/services`,
|
|
179
|
+
{ params: params != null ? params : {} }
|
|
180
|
+
);
|
|
181
|
+
let alerts = [];
|
|
182
|
+
for (const service of data) {
|
|
183
|
+
if (!(service.name in ALERTS_BY_SERVICE_TYPE)) {
|
|
184
|
+
this.logger.warn(`Service ${service.name} not found in ALERTS_BY_SERVICE_TYPE`);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
alerts.push(...ALERTS_BY_SERVICE_TYPE[service.name]);
|
|
143
188
|
}
|
|
144
|
-
return
|
|
189
|
+
return {
|
|
190
|
+
data: alerts
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
getServiceTypeAlertKeys(serviceType) {
|
|
194
|
+
return ALERTS_BY_SERVICE_TYPE[serviceType];
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// src/client/organizations.ts
|
|
199
|
+
var OrganizationsClient = class {
|
|
200
|
+
constructor(robotcloudApi2) {
|
|
201
|
+
this.logger = useLogger("OrganizationsClient");
|
|
202
|
+
this.getOrganizations = () => {
|
|
203
|
+
return this.robotcloudApi.get(`organizations`);
|
|
204
|
+
};
|
|
205
|
+
this.postOrganizations = () => {
|
|
206
|
+
return this.robotcloudApi.post(`organizations`);
|
|
207
|
+
};
|
|
208
|
+
this.getOrganization = (organizationId) => {
|
|
209
|
+
return this.robotcloudApi.get(
|
|
210
|
+
`organizations/${organizationId}`
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
this.putOrganization = (organizationId) => {
|
|
214
|
+
return this.robotcloudApi.put(
|
|
215
|
+
`organizations/${organizationId}`
|
|
216
|
+
);
|
|
217
|
+
};
|
|
218
|
+
this.deleteOrganization = (organizationId) => {
|
|
219
|
+
return this.robotcloudApi.delete(
|
|
220
|
+
`organizations/${organizationId}`
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
this.robotcloudApi = robotcloudApi2;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// src/client/users.ts
|
|
228
|
+
var UsersClient = class {
|
|
229
|
+
constructor(robotcloudApi2) {
|
|
230
|
+
this.logger = useLogger("UsersClient");
|
|
231
|
+
this.getOrganizationUsers = (organizationId) => {
|
|
232
|
+
return this.robotcloudApi.get(
|
|
233
|
+
`organizations/${organizationId}/users`
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
this.postOrganizationUsers = (organizationId) => {
|
|
237
|
+
return this.robotcloudApi.post(
|
|
238
|
+
`organizations/${organizationId}/users`
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
this.getUsers = () => {
|
|
242
|
+
return this.robotcloudApi.get(`users`);
|
|
243
|
+
};
|
|
244
|
+
this.getUser = (username) => {
|
|
245
|
+
return this.robotcloudApi.get(`users/${username}`);
|
|
246
|
+
};
|
|
247
|
+
this.putUser = (username) => {
|
|
248
|
+
return this.robotcloudApi.put(`users/${username}`);
|
|
249
|
+
};
|
|
250
|
+
this.deleteUser = (username) => {
|
|
251
|
+
return this.robotcloudApi.delete(`users/${username}`);
|
|
252
|
+
};
|
|
253
|
+
this.getUserOrganizations = (username) => {
|
|
254
|
+
return this.robotcloudApi.get(`users/${username}/organizations`);
|
|
255
|
+
};
|
|
256
|
+
this.getUserProjects = (username) => {
|
|
257
|
+
return this.robotcloudApi.get(
|
|
258
|
+
`users/${username}/projects`
|
|
259
|
+
);
|
|
260
|
+
};
|
|
261
|
+
this.postUserProjects = (username) => {
|
|
262
|
+
return this.robotcloudApi.post(
|
|
263
|
+
`users/${username}/projects`
|
|
264
|
+
);
|
|
265
|
+
};
|
|
266
|
+
this.getProjectToUser = (username, projectId) => {
|
|
267
|
+
return this.robotcloudApi.get(
|
|
268
|
+
`users/${username}/projects/${projectId}`
|
|
269
|
+
);
|
|
270
|
+
};
|
|
271
|
+
this.putProjectToUser = (username, projectId) => {
|
|
272
|
+
return this.robotcloudApi.put(
|
|
273
|
+
`users/${username}/projects/${projectId}`
|
|
274
|
+
);
|
|
275
|
+
};
|
|
276
|
+
this.deleteProjectToUser = (username, projectId) => {
|
|
277
|
+
return this.robotcloudApi.delete(
|
|
278
|
+
`users/${username}/projects/${projectId}`
|
|
279
|
+
);
|
|
280
|
+
};
|
|
281
|
+
this.robotcloudApi = robotcloudApi2;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// src/client/applications.ts
|
|
286
|
+
var ApplicationsClient = class {
|
|
287
|
+
constructor(robotcloudApi2) {
|
|
288
|
+
this.logger = useLogger("ApplicationsClient");
|
|
289
|
+
this.getApplications = () => {
|
|
290
|
+
return this.robotcloudApi.get(`application/register`);
|
|
291
|
+
};
|
|
292
|
+
this.postOrganizations = () => {
|
|
293
|
+
return this.robotcloudApi.post(`application/register`);
|
|
294
|
+
};
|
|
295
|
+
this.getApplication = (applicationId) => {
|
|
296
|
+
return this.robotcloudApi.get(`application/register/${applicationId}`);
|
|
297
|
+
};
|
|
298
|
+
this.putApplication = (applicationId) => {
|
|
299
|
+
return this.robotcloudApi.put(`application/register/${applicationId}`);
|
|
300
|
+
};
|
|
301
|
+
this.deleteApplication = (applicationId) => {
|
|
302
|
+
return this.robotcloudApi.delete(`application/register/${applicationId}`);
|
|
303
|
+
};
|
|
304
|
+
this.robotcloudApi = robotcloudApi2;
|
|
145
305
|
}
|
|
146
|
-
return true;
|
|
147
306
|
};
|
|
148
307
|
|
|
149
308
|
// src/client/services/generics.ts
|
|
@@ -435,33 +594,113 @@ var RoomConsumesClient = class {
|
|
|
435
594
|
};
|
|
436
595
|
var roomConsumesClient = new RoomConsumesClient();
|
|
437
596
|
|
|
597
|
+
// src/client/services/room-grouping-1.ts
|
|
598
|
+
var RoomGroupingConfigClient = class extends GenericInstanceConfigClient {
|
|
599
|
+
constructor() {
|
|
600
|
+
super("RoomGrouping_1");
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
var RoomGroupingClient = class {
|
|
604
|
+
constructor() {
|
|
605
|
+
this.getInstanceData = (prjId, instanceId, params) => {
|
|
606
|
+
return robotCloudApi_default.get(
|
|
607
|
+
`/projects/${prjId}/services/RoomConsumes_1/instances/${instanceId}/data`,
|
|
608
|
+
{
|
|
609
|
+
params,
|
|
610
|
+
headers: {
|
|
611
|
+
Accept: "application/json"
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
);
|
|
615
|
+
};
|
|
616
|
+
this._configurationClient = new RoomGroupingConfigClient();
|
|
617
|
+
}
|
|
618
|
+
get configuration() {
|
|
619
|
+
return this._configurationClient;
|
|
620
|
+
}
|
|
621
|
+
getAlerts(prjId, params) {
|
|
622
|
+
throw Error("Not implemented method");
|
|
623
|
+
}
|
|
624
|
+
getData(prjId, params) {
|
|
625
|
+
return robotCloudApi_default.get(`/projects/${prjId}/services/RoomGrouping_1/data`, {
|
|
626
|
+
params,
|
|
627
|
+
headers: {
|
|
628
|
+
Accept: "application/json"
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
getInstanceHistoric(prjId, instanceId, startTime, endTime, params) {
|
|
633
|
+
throw Error("Not implemented method");
|
|
634
|
+
}
|
|
635
|
+
getInstanceHistoricAggregate(prjId, instanceId, startTime, endTime, aggFunction, periode, params) {
|
|
636
|
+
throw Error("Not implemented method");
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
var roomGroupingClient = new RoomGroupingClient();
|
|
640
|
+
|
|
438
641
|
// src/client/projects/classifiers.ts
|
|
439
|
-
var
|
|
642
|
+
var logger2 = useLogger("classifiers-client");
|
|
440
643
|
var ClassifiersClient = class {
|
|
441
644
|
constructor() {
|
|
442
645
|
this.getProjectClassifiers = (prjId, params) => {
|
|
443
|
-
|
|
646
|
+
logger2.info(`Get project ${prjId} classifiers`);
|
|
444
647
|
return robotCloudApi_default.get(`projects/${prjId}/classifiers`, {
|
|
445
648
|
params
|
|
446
649
|
});
|
|
447
650
|
};
|
|
448
651
|
this.getClassifier = (classifierId) => {
|
|
449
|
-
return robotCloudApi_default.get(
|
|
652
|
+
return robotCloudApi_default.get(
|
|
653
|
+
`classifiers/${classifierId}`,
|
|
654
|
+
{}
|
|
655
|
+
);
|
|
656
|
+
};
|
|
657
|
+
this.putClassifier = (classifierId) => {
|
|
658
|
+
return robotCloudApi_default.put(
|
|
659
|
+
`classifiers/${classifierId}`,
|
|
660
|
+
{}
|
|
661
|
+
);
|
|
662
|
+
};
|
|
663
|
+
this.postClassifier = (classifierId) => {
|
|
664
|
+
return robotCloudApi_default.post(
|
|
665
|
+
`classifiers/${classifierId}`,
|
|
666
|
+
{}
|
|
667
|
+
);
|
|
668
|
+
};
|
|
669
|
+
this.deleteClassifier = (classifierId) => {
|
|
670
|
+
return robotCloudApi_default.delete(
|
|
671
|
+
`classifiers/${classifierId}`,
|
|
672
|
+
{}
|
|
673
|
+
);
|
|
450
674
|
};
|
|
451
675
|
}
|
|
452
676
|
};
|
|
453
677
|
var classifiersClient = new ClassifiersClient();
|
|
454
678
|
|
|
455
679
|
// src/client/projects/devices.ts
|
|
456
|
-
var
|
|
680
|
+
var logger3 = useLogger("devices-client");
|
|
457
681
|
var DevicesClient = class {
|
|
458
682
|
constructor() {
|
|
459
683
|
this.getProjectDevices = (projectId) => {
|
|
460
684
|
return robotCloudApi_default.get(`projects/${projectId}/devices`);
|
|
461
685
|
};
|
|
686
|
+
this.getProjectDevicesLocation = (locationId) => {
|
|
687
|
+
return robotCloudApi_default.get(`locations/${locationId}/devices`);
|
|
688
|
+
};
|
|
689
|
+
this.postProjectDeviceLocation = (locationId) => {
|
|
690
|
+
return robotCloudApi_default.post(`locations/${locationId}/devices`);
|
|
691
|
+
};
|
|
462
692
|
this.getDeviceDetails = (deviceId) => {
|
|
463
693
|
return robotCloudApi_default.get(`devices/${deviceId}`);
|
|
464
694
|
};
|
|
695
|
+
this.putDeviceDetails = (deviceId) => {
|
|
696
|
+
return robotCloudApi_default.put(`devices/${deviceId}`);
|
|
697
|
+
};
|
|
698
|
+
this.deleteDevice = (deviceId) => {
|
|
699
|
+
return robotCloudApi_default.delete(`devices/${deviceId}`);
|
|
700
|
+
};
|
|
701
|
+
this.getDeviceConfiguration = (deviceId) => {
|
|
702
|
+
return robotCloudApi_default.get(`devices/${deviceId}/compatibleconfigurationtypes`);
|
|
703
|
+
};
|
|
465
704
|
}
|
|
466
705
|
};
|
|
467
706
|
var devicesClient = new DevicesClient();
|
|
@@ -469,16 +708,16 @@ var devicesClient = new DevicesClient();
|
|
|
469
708
|
// src/client/projects/locations.ts
|
|
470
709
|
var LocationsClient = class {
|
|
471
710
|
constructor() {
|
|
472
|
-
this.
|
|
711
|
+
this.getLocations = (prjId, params) => {
|
|
473
712
|
return robotCloudApi_default.get(
|
|
474
|
-
`projects/${prjId}/locations
|
|
713
|
+
`projects/${prjId}/locations`,
|
|
475
714
|
{
|
|
476
715
|
params
|
|
477
716
|
}
|
|
478
717
|
);
|
|
479
718
|
};
|
|
480
|
-
this.
|
|
481
|
-
return robotCloudApi_default.
|
|
719
|
+
this.postLocations = (prjId, params) => {
|
|
720
|
+
return robotCloudApi_default.post(
|
|
482
721
|
`projects/${prjId}/locations`,
|
|
483
722
|
{
|
|
484
723
|
params
|
|
@@ -491,6 +730,18 @@ var LocationsClient = class {
|
|
|
491
730
|
{}
|
|
492
731
|
);
|
|
493
732
|
};
|
|
733
|
+
this.putLocation = (locationId) => {
|
|
734
|
+
return robotCloudApi_default.put(
|
|
735
|
+
`locations/${locationId}`,
|
|
736
|
+
{}
|
|
737
|
+
);
|
|
738
|
+
};
|
|
739
|
+
this.deleteLocation = (locationId) => {
|
|
740
|
+
return robotCloudApi_default.delete(
|
|
741
|
+
`locations/${locationId}`,
|
|
742
|
+
{}
|
|
743
|
+
);
|
|
744
|
+
};
|
|
494
745
|
}
|
|
495
746
|
};
|
|
496
747
|
var locationsClient = new LocationsClient();
|
|
@@ -498,6 +749,16 @@ var locationsClient = new LocationsClient();
|
|
|
498
749
|
// src/client/projects/projects.ts
|
|
499
750
|
var ProjectsClient = class {
|
|
500
751
|
constructor() {
|
|
752
|
+
this.getOrganizationProjects = (organizationId) => {
|
|
753
|
+
return robotCloudApi_default.get(
|
|
754
|
+
`organizations/${organizationId}/projects`
|
|
755
|
+
);
|
|
756
|
+
};
|
|
757
|
+
this.postOrganizationProjects = (organizationId) => {
|
|
758
|
+
return robotCloudApi_default.post(
|
|
759
|
+
`organizations/${organizationId}/projects`
|
|
760
|
+
);
|
|
761
|
+
};
|
|
501
762
|
this.getProjects = (params) => {
|
|
502
763
|
return robotCloudApi_default.get("projects", {
|
|
503
764
|
params
|
|
@@ -508,12 +769,36 @@ var ProjectsClient = class {
|
|
|
508
769
|
params
|
|
509
770
|
});
|
|
510
771
|
};
|
|
511
|
-
this.
|
|
772
|
+
this.putProjectDetails = (prjId, params) => {
|
|
773
|
+
return robotCloudApi_default.put(`projects/${prjId}`, {
|
|
774
|
+
params
|
|
775
|
+
});
|
|
776
|
+
};
|
|
777
|
+
this.deleteProject = (prjId, params) => {
|
|
778
|
+
return robotCloudApi_default.delete(`projects/${prjId}`, {
|
|
779
|
+
params
|
|
780
|
+
});
|
|
781
|
+
};
|
|
782
|
+
this.getProjectUsers = (prjId, params) => {
|
|
783
|
+
return robotCloudApi_default.get(`projects/${prjId}/users`, {
|
|
784
|
+
params
|
|
785
|
+
});
|
|
786
|
+
};
|
|
787
|
+
this.getProjectApplications = (prjId, params) => {
|
|
788
|
+
return robotCloudApi_default.get(`projects/${prjId}/applications`, {
|
|
789
|
+
params
|
|
790
|
+
});
|
|
791
|
+
};
|
|
792
|
+
this.getProjectApplication = (prjId, appId) => {
|
|
512
793
|
return robotCloudApi_default.get(
|
|
513
|
-
`projects/${prjId}/
|
|
514
|
-
{
|
|
515
|
-
|
|
516
|
-
|
|
794
|
+
`projects/${prjId}/applications/${appId}`,
|
|
795
|
+
{}
|
|
796
|
+
);
|
|
797
|
+
};
|
|
798
|
+
this.putProjectApplication = (prjId, appId) => {
|
|
799
|
+
return robotCloudApi_default.put(
|
|
800
|
+
`projects/${prjId}/applications/${appId}`,
|
|
801
|
+
{}
|
|
517
802
|
);
|
|
518
803
|
};
|
|
519
804
|
}
|
|
@@ -521,7 +806,7 @@ var ProjectsClient = class {
|
|
|
521
806
|
var projectsClient = new ProjectsClient();
|
|
522
807
|
|
|
523
808
|
// src/client/projects/service-instances.ts
|
|
524
|
-
var
|
|
809
|
+
var logger4 = useLogger("service-instances-client");
|
|
525
810
|
var ServiceInstancesClient = class {
|
|
526
811
|
constructor() {
|
|
527
812
|
this.getAll = (prjId, params) => {
|
|
@@ -540,39 +825,134 @@ var ServiceInstancesClient = class {
|
|
|
540
825
|
}
|
|
541
826
|
);
|
|
542
827
|
};
|
|
543
|
-
this.
|
|
828
|
+
this.getProjectServiceTypes = (prjId, params) => {
|
|
829
|
+
return robotCloudApi_default.get(
|
|
830
|
+
`projects/${prjId}/services`,
|
|
831
|
+
{
|
|
832
|
+
params
|
|
833
|
+
}
|
|
834
|
+
);
|
|
835
|
+
};
|
|
836
|
+
this.getLocationServiceInstances = (prjId, locId, service_type, params) => {
|
|
837
|
+
return robotCloudApi_default.get(
|
|
838
|
+
`projects/${prjId}/locations/${locId}/services/${service_type}/instances`,
|
|
839
|
+
{
|
|
840
|
+
params
|
|
841
|
+
}
|
|
842
|
+
);
|
|
843
|
+
};
|
|
844
|
+
this.postLocationServiceInstances = (prjId, locId, service_type, params) => {
|
|
845
|
+
return robotCloudApi_default.post(
|
|
846
|
+
`projects/${prjId}/locations/${locId}/services/${service_type}/instances`,
|
|
847
|
+
{
|
|
848
|
+
params
|
|
849
|
+
}
|
|
850
|
+
);
|
|
851
|
+
};
|
|
852
|
+
this.getServiceInstance = (prjId, service_type, instance_id) => {
|
|
544
853
|
return robotCloudApi_default.get(
|
|
545
|
-
`projects/${prjId}/services/${service_type}/instances/${
|
|
854
|
+
`projects/${prjId}/services/${service_type}/instances/${instance_id}`
|
|
855
|
+
);
|
|
856
|
+
};
|
|
857
|
+
this.putServiceInstance = (prjId, service_type, instance_id) => {
|
|
858
|
+
return robotCloudApi_default.put(
|
|
859
|
+
`projects/${prjId}/services/${service_type}/instances/${instance_id}`
|
|
860
|
+
);
|
|
861
|
+
};
|
|
862
|
+
this.deleteServiceInstance = (prjId, service_type, instance_id) => {
|
|
863
|
+
return robotCloudApi_default.delete(
|
|
864
|
+
`projects/${prjId}/services/${service_type}/instances/${instance_id}`
|
|
546
865
|
);
|
|
547
866
|
};
|
|
548
|
-
this.getServiceInstanceDevicesInfo = (prjId, service_type,
|
|
549
|
-
return robotCloudApi_default.get(`projects/${prjId}/services/${service_type}/instances/${
|
|
867
|
+
this.getServiceInstanceDevicesInfo = (prjId, service_type, instance_id) => {
|
|
868
|
+
return robotCloudApi_default.get(`projects/${prjId}/services/${service_type}/instances/${instance_id}/deviceconf`);
|
|
869
|
+
};
|
|
870
|
+
this.putServiceInstanceDevicesInfo = (prjId, service_type, instance_id) => {
|
|
871
|
+
return robotCloudApi_default.put(`projects/${prjId}/services/${service_type}/instances/${instance_id}/deviceconf`);
|
|
550
872
|
};
|
|
551
873
|
}
|
|
552
874
|
getServiceAllInstancesData(prjId, service_type) {
|
|
553
875
|
return robotCloudApi_default.get(`projects/${prjId}/services/${service_type}/data`);
|
|
554
876
|
}
|
|
877
|
+
getServiceInstancesData(prjId, service_type, instance_id) {
|
|
878
|
+
return robotCloudApi_default.get(`projects/${prjId}/services/${service_type}/instances/${instance_id}/data`);
|
|
879
|
+
}
|
|
555
880
|
getServiceAllInstancesAlerts(prjId, service_type) {
|
|
556
881
|
return robotCloudApi_default.get(
|
|
557
882
|
`projects/${prjId}/services/${service_type}/alert`
|
|
558
883
|
);
|
|
559
884
|
}
|
|
885
|
+
getServiceInstancesAlerts(prjId, service_type, instance_id) {
|
|
886
|
+
return robotCloudApi_default.get(`projects/${prjId}/services/${service_type}/instances/${instance_id}/alert`);
|
|
887
|
+
}
|
|
888
|
+
getServiceInstancesConfiguration(prjId, service_type, instance_id) {
|
|
889
|
+
return robotCloudApi_default.get(`projects/${prjId}/services/${service_type}/instances/${instance_id}/configuration`);
|
|
890
|
+
}
|
|
891
|
+
putServiceInstancesConfiguration(prjId, service_type, instance_id) {
|
|
892
|
+
return robotCloudApi_default.put(`projects/${prjId}/services/${service_type}/instances/${instance_id}/configuration`);
|
|
893
|
+
}
|
|
894
|
+
getServiceInstancesHistoricData(prjId, service_type, instance_id) {
|
|
895
|
+
return robotCloudApi_default.get(`projects/${prjId}/services/${service_type}/instances/${instance_id}/historic/data`);
|
|
896
|
+
}
|
|
897
|
+
getServiceInstancesHistoricDataAggregate(prjId, service_type, instance_id) {
|
|
898
|
+
return robotCloudApi_default.get(`projects/${prjId}/services/${service_type}/instances/${instance_id}/historic/data/aggregate`);
|
|
899
|
+
}
|
|
900
|
+
getServiceLocation(prjId, locationId) {
|
|
901
|
+
return robotCloudApi_default.get(
|
|
902
|
+
`projects/${prjId}/locations/${locationId}/services`
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
getSizeProjectInstances(prjId) {
|
|
906
|
+
return robotCloudApi_default.get(
|
|
907
|
+
`size/projects/${prjId}/instances`
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
getSizeProjectServicesInstances(prjId, service_type) {
|
|
911
|
+
return robotCloudApi_default.get(
|
|
912
|
+
`size/projects/${prjId}/services/${service_type}/instances`
|
|
913
|
+
);
|
|
914
|
+
}
|
|
560
915
|
};
|
|
561
916
|
var serviceInstancesClient = new ServiceInstancesClient();
|
|
562
917
|
|
|
563
918
|
// src/client/projects/subsystems.ts
|
|
919
|
+
var logger5 = useLogger("service-instances-client");
|
|
564
920
|
var SubsystemsClient = class {
|
|
565
921
|
constructor() {
|
|
566
922
|
this.getProjectSubsystems = (prjId) => {
|
|
923
|
+
logger5.info(`Get project ${prjId} subsystems`);
|
|
567
924
|
return robotCloudApi_default.get(
|
|
568
925
|
`projects/${prjId}/subsystems`
|
|
569
926
|
);
|
|
570
927
|
};
|
|
571
928
|
this.getProjectSubsystem = (prjId, subsysId) => {
|
|
929
|
+
logger5.info(`Get subsystem ${subsysId} from project ${prjId}`);
|
|
572
930
|
return robotCloudApi_default.get(
|
|
573
931
|
`projects/${prjId}/subsystems/${subsysId}`
|
|
574
932
|
);
|
|
575
933
|
};
|
|
934
|
+
this.postProjectSubsystem = (prjId) => {
|
|
935
|
+
logger5.info(`Create subsystem in project ${prjId}`);
|
|
936
|
+
return robotCloudApi_default.post(
|
|
937
|
+
`projects/${prjId}/subsystems`
|
|
938
|
+
);
|
|
939
|
+
};
|
|
940
|
+
this.putProjectSubsystem = (prjId, subsysId) => {
|
|
941
|
+
logger5.info(`Update subsystem ${subsysId} in project ${prjId}`);
|
|
942
|
+
return robotCloudApi_default.put(
|
|
943
|
+
`projects/${prjId}/subsystems/${subsysId}`
|
|
944
|
+
);
|
|
945
|
+
};
|
|
946
|
+
this.deleteSubsystem = (prjId, subsysId) => {
|
|
947
|
+
logger5.info(`Delete subsystem ${subsysId} in project ${prjId}`);
|
|
948
|
+
return robotCloudApi_default.delete(`projects/${prjId}/subsystems/${subsysId}`);
|
|
949
|
+
};
|
|
950
|
+
this.getProjectSubsystemLocations = (prjId, subsysId) => {
|
|
951
|
+
logger5.info(`Get subsystems locations ${subsysId} in project ${prjId}`);
|
|
952
|
+
return robotCloudApi_default.get(
|
|
953
|
+
`projects/${prjId}/subsystems/${subsysId}/locations`
|
|
954
|
+
);
|
|
955
|
+
};
|
|
576
956
|
}
|
|
577
957
|
};
|
|
578
958
|
var subsystemsClient = new SubsystemsClient();
|
|
@@ -591,125 +971,100 @@ var TagsClient = class {
|
|
|
591
971
|
logger6.info(`Get project ${prjId} tag ${tagId}`);
|
|
592
972
|
return robotCloudApi_default.get(`tags/${tagId}`);
|
|
593
973
|
};
|
|
974
|
+
this.postTag = (prjId) => {
|
|
975
|
+
logger6.info(`Create tag for project ${prjId}`);
|
|
976
|
+
return robotCloudApi_default.post(`projects/${prjId}/tags`);
|
|
977
|
+
};
|
|
978
|
+
this.putTag = (prjId, tagId) => {
|
|
979
|
+
logger6.info(`Modify project ${prjId} tag ${tagId}`);
|
|
980
|
+
return robotCloudApi_default.put(`tags/${tagId}`);
|
|
981
|
+
};
|
|
982
|
+
this.deleteTag = (prjId, tagId) => {
|
|
983
|
+
logger6.info(`Delete project ${prjId} tag ${tagId}`);
|
|
984
|
+
return robotCloudApi_default.delete(`tags/${tagId}`);
|
|
985
|
+
};
|
|
594
986
|
}
|
|
595
987
|
};
|
|
596
988
|
var tagsClient = new TagsClient();
|
|
597
989
|
|
|
598
|
-
// src/client/
|
|
599
|
-
var
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
"high_daily_hot_water",
|
|
611
|
-
"high_daily_cold_water"
|
|
612
|
-
],
|
|
613
|
-
"RoomDiagnostics_1": [
|
|
614
|
-
"low_peripheral_num"
|
|
615
|
-
],
|
|
616
|
-
"RoomGrouping_1": [],
|
|
617
|
-
"RoomGuestStatus_1": [
|
|
618
|
-
"door_open_overtime",
|
|
619
|
-
"window_open_overtime",
|
|
620
|
-
"medical_alarm"
|
|
621
|
-
]
|
|
622
|
-
};
|
|
623
|
-
var AlertsClientImpl = class {
|
|
624
|
-
constructor(robotcloudApi2) {
|
|
625
|
-
this.logger = useLogger("AlertsClientImpl");
|
|
626
|
-
this.robotcloudApi = robotcloudApi2;
|
|
990
|
+
// src/client/index.ts
|
|
991
|
+
var applicationsClient = new ApplicationsClient(robotCloudApi_default);
|
|
992
|
+
var loginClient = new LoginClientImpl(robotCloudApi_default);
|
|
993
|
+
var alertsClient = new AlertsClientImpl(robotCloudApi_default);
|
|
994
|
+
var organizationsClient = new OrganizationsClient(robotCloudApi_default);
|
|
995
|
+
var usersClient = new UsersClient(robotCloudApi_default);
|
|
996
|
+
|
|
997
|
+
// src/helpers/robotCloudToken.ts
|
|
998
|
+
var logger7 = useLogger("robotcloud-token");
|
|
999
|
+
function parseJwt(token) {
|
|
1000
|
+
if (!token) {
|
|
1001
|
+
return;
|
|
627
1002
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
1003
|
+
return JSON.parse(atob(token.split(".")[1]));
|
|
1004
|
+
}
|
|
1005
|
+
var decodeToken = (token) => {
|
|
1006
|
+
const payload = parseJwt(token);
|
|
1007
|
+
if (!payload) {
|
|
1008
|
+
return void 0;
|
|
633
1009
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
1010
|
+
return payload;
|
|
1011
|
+
};
|
|
1012
|
+
var needRenew = (payload) => {
|
|
1013
|
+
const expirationDate = new Date(payload.exp * 1e3);
|
|
1014
|
+
expirationDate.setMinutes(
|
|
1015
|
+
expirationDate.getMinutes() - config_default.tokenMinutesBeforeExpirationRenew
|
|
1016
|
+
);
|
|
1017
|
+
const currentDate = /* @__PURE__ */ new Date();
|
|
1018
|
+
return currentDate >= expirationDate;
|
|
1019
|
+
};
|
|
1020
|
+
var isExpired = (payload) => {
|
|
1021
|
+
const expirationDate = new Date(payload.exp * 1e3);
|
|
1022
|
+
const currentDate = /* @__PURE__ */ new Date();
|
|
1023
|
+
return currentDate >= expirationDate;
|
|
1024
|
+
};
|
|
1025
|
+
var renewToken = async (renew_token) => {
|
|
1026
|
+
logger7.debug("Renewing token ...");
|
|
1027
|
+
const { data } = await loginClient.renewToken(renew_token);
|
|
1028
|
+
return {
|
|
1029
|
+
renewed: true,
|
|
1030
|
+
access: data["access"]["token"],
|
|
1031
|
+
renew: data["renew"]["token"]
|
|
1032
|
+
};
|
|
1033
|
+
};
|
|
1034
|
+
var validateToken = async (access_token) => {
|
|
1035
|
+
var _a, _b, _c;
|
|
1036
|
+
logger7.debug("Validate token ...");
|
|
1037
|
+
const payload = decodeToken(access_token);
|
|
1038
|
+
if (!payload) {
|
|
1039
|
+
return false;
|
|
1040
|
+
}
|
|
1041
|
+
const cloudUrl = robotCloudApi_default.defaults.baseURL;
|
|
1042
|
+
try {
|
|
1043
|
+
const { data } = await axios3.get(
|
|
1044
|
+
cloudUrl + `users/${payload.sub}`,
|
|
637
1045
|
{
|
|
638
|
-
|
|
1046
|
+
headers: {
|
|
1047
|
+
Authorization: `Bearer ${access_token}`
|
|
1048
|
+
}
|
|
639
1049
|
}
|
|
640
1050
|
);
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
data
|
|
647
|
-
);
|
|
648
|
-
}
|
|
649
|
-
getAggregatedLogs(projectId, params) {
|
|
650
|
-
return this.robotcloudApi.get(
|
|
651
|
-
`projects/${projectId}/alerts/aggregate`,
|
|
652
|
-
{ params }
|
|
653
|
-
);
|
|
654
|
-
}
|
|
655
|
-
async getAvailableAlerts(projectId, params) {
|
|
656
|
-
const { data } = await this.robotcloudApi.get(
|
|
657
|
-
`projects/${projectId}/services`,
|
|
658
|
-
{ params: params != null ? params : {} }
|
|
659
|
-
);
|
|
660
|
-
let alerts = [];
|
|
661
|
-
for (const service of data) {
|
|
662
|
-
if (!(service.name in ALERTS_BY_SERVICE_TYPE)) {
|
|
663
|
-
this.logger.warn(`Service ${service.name} not found in ALERTS_BY_SERVICE_TYPE`);
|
|
664
|
-
continue;
|
|
665
|
-
}
|
|
666
|
-
alerts.push(...ALERTS_BY_SERVICE_TYPE[service.name]);
|
|
1051
|
+
} catch (error) {
|
|
1052
|
+
if (axios3.isAxiosError(error)) {
|
|
1053
|
+
logger7.warn(`${error.message}: ${(_c = (_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) != null ? _c : ""}`);
|
|
1054
|
+
} else {
|
|
1055
|
+
logger7.warn(error);
|
|
667
1056
|
}
|
|
668
|
-
return
|
|
669
|
-
data: alerts
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
};
|
|
673
|
-
var alertsClient = new AlertsClientImpl(robotCloudApi_default);
|
|
674
|
-
|
|
675
|
-
// src/client/organizations.ts
|
|
676
|
-
var OrganizationsClient = class {
|
|
677
|
-
constructor() {
|
|
678
|
-
this.getOrganization = (organizationId) => {
|
|
679
|
-
return robotCloudApi_default.get(
|
|
680
|
-
`organizations/${organizationId}`
|
|
681
|
-
);
|
|
682
|
-
};
|
|
683
|
-
this.getOrganizationProjects = (organizationId) => {
|
|
684
|
-
return robotCloudApi_default.get(
|
|
685
|
-
`organizations/${organizationId}/projects`
|
|
686
|
-
);
|
|
687
|
-
};
|
|
688
|
-
}
|
|
689
|
-
};
|
|
690
|
-
var organizationsClient = new OrganizationsClient();
|
|
691
|
-
|
|
692
|
-
// src/client/users.ts
|
|
693
|
-
var UsersClient = class {
|
|
694
|
-
constructor() {
|
|
695
|
-
this.getUser = (username) => {
|
|
696
|
-
return robotCloudApi_default.get(`users/${username}`);
|
|
697
|
-
};
|
|
698
|
-
this.getUserProjects = (username) => {
|
|
699
|
-
return robotCloudApi_default.get(
|
|
700
|
-
`users/${username}/projects`
|
|
701
|
-
);
|
|
702
|
-
};
|
|
1057
|
+
return false;
|
|
703
1058
|
}
|
|
1059
|
+
return true;
|
|
704
1060
|
};
|
|
705
|
-
var usersClient = new UsersClient();
|
|
706
1061
|
|
|
707
1062
|
// src/helpers/tags.ts
|
|
708
|
-
var
|
|
1063
|
+
var logger8 = useLogger("tags-helper");
|
|
709
1064
|
var TagsHelper = class {
|
|
710
1065
|
constructor(tagsClient2) {
|
|
711
1066
|
this.getTagsTree = async (prjId, maxDepth = 2, params) => {
|
|
712
|
-
|
|
1067
|
+
logger8.info(`Get project ${prjId} tags tree`);
|
|
713
1068
|
if (!params) {
|
|
714
1069
|
params = {};
|
|
715
1070
|
}
|
|
@@ -724,7 +1079,7 @@ var TagsHelper = class {
|
|
|
724
1079
|
return { root: tags };
|
|
725
1080
|
};
|
|
726
1081
|
this.getTagsChildren = async (prjId, level = 0, parent_id, params, maxDepth) => {
|
|
727
|
-
|
|
1082
|
+
logger8.debug(`Get project ${prjId} tags children: ${parent_id}`);
|
|
728
1083
|
if (!params) {
|
|
729
1084
|
params = {};
|
|
730
1085
|
}
|
|
@@ -803,14 +1158,19 @@ var robotCloudPermissionsHelper = new RobotCloudPermissionsHelperImpl();
|
|
|
803
1158
|
// src/helpers/index.ts
|
|
804
1159
|
var tagsHelper = new TagsHelper(tagsClient);
|
|
805
1160
|
export {
|
|
1161
|
+
ApplicationsClient,
|
|
1162
|
+
OrganizationsClient,
|
|
806
1163
|
RobotCloudClientConfig,
|
|
807
1164
|
RoomClimeClient,
|
|
1165
|
+
UsersClient,
|
|
808
1166
|
airQualityClient,
|
|
809
1167
|
alertsClient,
|
|
1168
|
+
applicationsClient,
|
|
810
1169
|
classifiersClient,
|
|
811
1170
|
config_default as clientConfig,
|
|
812
1171
|
devicesClient,
|
|
813
1172
|
locationsClient,
|
|
1173
|
+
loginClient,
|
|
814
1174
|
organizationsClient,
|
|
815
1175
|
projectsClient,
|
|
816
1176
|
robotCloudPermissionsHelper,
|
|
@@ -818,6 +1178,7 @@ export {
|
|
|
818
1178
|
robotCloudApi_default as robotcloudApi,
|
|
819
1179
|
roomClimeClient,
|
|
820
1180
|
roomConsumesClient,
|
|
1181
|
+
roomGroupingClient,
|
|
821
1182
|
roomGuestStatusClient,
|
|
822
1183
|
serviceInstancesClient,
|
|
823
1184
|
subsystemsClient,
|