@robotbas/robotcloud-client 0.1.0 → 0.1.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 +30 -13
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/index.mjs +30 -13
- package/dist/helpers/index.mjs.map +1 -1
- package/dist/{index-X-E5BIKC.d.mts → index-xgxgpqYZ.d.mts} +1 -26
- package/dist/{index-X-E5BIKC.d.ts → index-xgxgpqYZ.d.ts} +1 -26
- package/dist/index.d.mts +91 -119
- package/dist/index.d.ts +91 -119
- package/dist/index.js +33 -164
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -163
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as axios from 'axios';
|
|
2
2
|
import { AxiosResponse } from 'axios';
|
|
3
|
-
import {
|
|
4
|
-
export { A as AppAccessLevel, F as FancoilSpeedState, O as OrganizationAccessLevel,
|
|
3
|
+
import { S as SubsystemRequestParams, a as ServiceInstanceDataRequestParams, R as RegimState, T as TemperatureUnit, b as RoomClime1AlertEventValue, c as RoomConsumes1AlertEventValue, P as PaginableRequestParams, d as RobotCloudNamedItem } from './index-xgxgpqYZ.js';
|
|
4
|
+
export { A as AppAccessLevel, F as FancoilSpeedState, L as LocationServiceInstancesRequestParams, O as OrganizationAccessLevel, f as ProjectAccessLevel, i as ProjectDetailsRequestParams, j as ProjectLocationsRequestParams, h as ProjectRequestParams, k as ProjectTagRequestParams, s as RobotCloudDeviceDetails, p as RobotCloudOrganizationDetails, e as RobotCloudPermissionsHelper, l as RobotCloudProject, q as RobotCloudProjectDetails, g as RobotCloudServiceType, t as RobotCloudServiceTypeDetails, m as RobotCloudUserAppAccess, n as RobotCloudUserDetails, o as RobotCloudUserProject, r as robotCloudPermissionsHelper } from './index-xgxgpqYZ.js';
|
|
5
5
|
|
|
6
6
|
declare const robotcloudApi: axios.AxiosInstance;
|
|
7
7
|
|
|
@@ -16,43 +16,35 @@ declare class RobotCloudClientConfig {
|
|
|
16
16
|
}
|
|
17
17
|
declare const clientConfig: RobotCloudClientConfig;
|
|
18
18
|
|
|
19
|
-
interface
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
description: string;
|
|
25
|
-
tags: string[];
|
|
26
|
-
subsystems: string[];
|
|
27
|
-
classifier: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
interface ProjectClassifiersRequestParams extends PaginableRequestParams {
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface Classifier {
|
|
35
|
-
id: string;
|
|
36
|
-
name: string;
|
|
37
|
-
description: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface ClassifierDetails extends Classifier {
|
|
19
|
+
interface CheckTokenResponse {
|
|
20
|
+
renewed: boolean;
|
|
21
|
+
invalid: boolean;
|
|
22
|
+
access: string;
|
|
23
|
+
renew: string;
|
|
41
24
|
}
|
|
42
25
|
|
|
43
|
-
interface
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
interface RobotCloudJWTPayload {
|
|
27
|
+
exp: number;
|
|
28
|
+
sub: string; // username
|
|
29
|
+
org: string; // organization
|
|
46
30
|
}
|
|
47
31
|
|
|
48
|
-
interface
|
|
49
|
-
|
|
32
|
+
interface RobotCloudNewTokenResponse {
|
|
33
|
+
access: string;
|
|
34
|
+
renew: string;
|
|
50
35
|
}
|
|
36
|
+
declare const decodeToken: (token: string) => RobotCloudJWTPayload | undefined;
|
|
37
|
+
declare const needRenew: (payload: RobotCloudJWTPayload) => boolean;
|
|
38
|
+
declare const renewToken: (renew_token: string) => Promise<CheckTokenResponse>;
|
|
39
|
+
declare const validateToken: (access_token: string) => Promise<boolean>;
|
|
51
40
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
type robotCloudToken_RobotCloudNewTokenResponse = RobotCloudNewTokenResponse;
|
|
42
|
+
declare const robotCloudToken_decodeToken: typeof decodeToken;
|
|
43
|
+
declare const robotCloudToken_needRenew: typeof needRenew;
|
|
44
|
+
declare const robotCloudToken_renewToken: typeof renewToken;
|
|
45
|
+
declare const robotCloudToken_validateToken: typeof validateToken;
|
|
46
|
+
declare namespace robotCloudToken {
|
|
47
|
+
export { type robotCloudToken_RobotCloudNewTokenResponse as RobotCloudNewTokenResponse, robotCloudToken_decodeToken as decodeToken, robotCloudToken_needRenew as needRenew, robotCloudToken_renewToken as renewToken, robotCloudToken_validateToken as validateToken };
|
|
56
48
|
}
|
|
57
49
|
|
|
58
50
|
interface ServiceInstanceRead<T> {
|
|
@@ -152,91 +144,6 @@ interface ServiceTypeClient<T_ALERTS, T_DATA, T_CONFIG> {
|
|
|
152
144
|
): Promise<AxiosResponse<ServiceDataMeasurement<T_DATA>[]>>;
|
|
153
145
|
}
|
|
154
146
|
|
|
155
|
-
interface RobotCloudLocationDetails {
|
|
156
|
-
id: string;
|
|
157
|
-
name: string;
|
|
158
|
-
description: string;
|
|
159
|
-
project: string;
|
|
160
|
-
tags: string[];
|
|
161
|
-
}
|
|
162
|
-
declare const getLocationServiceInstances: (prjId: string, locId: string, service_type: RobotCloudServiceType, params?: LocationServiceInstancesRequestParams) => Promise<AxiosResponse<RobotCloudServiceInstance[]>>;
|
|
163
|
-
declare const getUser: (username: string) => Promise<AxiosResponse<RobotCloudUserDetails>>;
|
|
164
|
-
declare const getUserProjects: (username: string) => Promise<AxiosResponse<RobotCloudUserProject[]>>;
|
|
165
|
-
declare const getOrganization: (organizationId: string) => Promise<AxiosResponse<RobotCloudOrganizationDetails>>;
|
|
166
|
-
declare const getOrganizationProjects: (organizationId: string) => Promise<AxiosResponse<RobotCloudProject[]>>;
|
|
167
|
-
declare const getProjects: (params?: ProjectRequestParams) => Promise<AxiosResponse<RobotCloudProject[]>>;
|
|
168
|
-
declare const getProjectDetails: (prjId: string, params?: ProjectDetailsRequestParams) => Promise<AxiosResponse<RobotCloudProjectDetails>>;
|
|
169
|
-
declare const getProjectSubsystem: (prjId: string, subsysId: string) => Promise<AxiosResponse<RobotCloudNamedItem, any>>;
|
|
170
|
-
declare const getLocations: (prjId: string, params?: ProjectLocationsRequestParams) => Promise<AxiosResponse<RobotCloudNamedItem[]>>;
|
|
171
|
-
declare const getLocation: (locationId: string) => Promise<AxiosResponse<RobotCloudLocationDetails>>;
|
|
172
|
-
declare const getServiceInstances: (prjId: string, service_type: string, params?: ServiceInstancesRequestParams) => Promise<AxiosResponse<RobotCloudServiceInstance[]>>;
|
|
173
|
-
declare const getServiceInstance: (prjId: string, service_type: string, service_id: string) => Promise<AxiosResponse<ServiceInstanceDetails, any>>;
|
|
174
|
-
declare const getProjectClassifiers: (prjId: string, params?: ProjectClassifiersRequestParams) => Promise<AxiosResponse<Classifier[]>>;
|
|
175
|
-
declare const getClassifier: (classifierId: string) => Promise<AxiosResponse<ClassifierDetails, any>>;
|
|
176
|
-
declare const getTags: (prjId: string, params?: ProjectTagRequestParams) => Promise<AxiosResponse<ProjectTag[]>>;
|
|
177
|
-
declare const getTagsTree: (prjId: string, maxDepth?: number, params?: ProjectTagRequestParams) => Promise<ProjectTagsTree>;
|
|
178
|
-
declare const getTagsChildren: (prjId: string, level?: number, parent_id?: string, params?: ProjectTagRequestParams, maxDepth?: number) => Promise<ProjectTagTreeNode[]>;
|
|
179
|
-
declare const getDeviceDetails: (deviceId: string) => Promise<AxiosResponse<RobotCloudDeviceDetails>>;
|
|
180
|
-
declare const getProjectServiceTypes: (prjId: string, params?: SubsystemRequestParams) => Promise<AxiosResponse<RobotCloudServiceTypeDetails[]>>;
|
|
181
|
-
declare const getRoomGrouping1ServiceData: (prjId: string, params?: ServiceDataRequestParams) => Promise<AxiosResponse<ServiceDataMeasurement<RoomGrouping1DataEventValue>[]>>;
|
|
182
|
-
declare const getRoomGrouping1InstanceDeviceConfig: (prjId: string, instanceId: string) => Promise<AxiosResponse<RoomGrouping1InstanceDeviceConfig>>;
|
|
183
|
-
|
|
184
|
-
declare const robotCloudClient_getClassifier: typeof getClassifier;
|
|
185
|
-
declare const robotCloudClient_getDeviceDetails: typeof getDeviceDetails;
|
|
186
|
-
declare const robotCloudClient_getLocation: typeof getLocation;
|
|
187
|
-
declare const robotCloudClient_getLocationServiceInstances: typeof getLocationServiceInstances;
|
|
188
|
-
declare const robotCloudClient_getLocations: typeof getLocations;
|
|
189
|
-
declare const robotCloudClient_getOrganization: typeof getOrganization;
|
|
190
|
-
declare const robotCloudClient_getOrganizationProjects: typeof getOrganizationProjects;
|
|
191
|
-
declare const robotCloudClient_getProjectClassifiers: typeof getProjectClassifiers;
|
|
192
|
-
declare const robotCloudClient_getProjectDetails: typeof getProjectDetails;
|
|
193
|
-
declare const robotCloudClient_getProjectServiceTypes: typeof getProjectServiceTypes;
|
|
194
|
-
declare const robotCloudClient_getProjectSubsystem: typeof getProjectSubsystem;
|
|
195
|
-
declare const robotCloudClient_getProjects: typeof getProjects;
|
|
196
|
-
declare const robotCloudClient_getRoomGrouping1InstanceDeviceConfig: typeof getRoomGrouping1InstanceDeviceConfig;
|
|
197
|
-
declare const robotCloudClient_getRoomGrouping1ServiceData: typeof getRoomGrouping1ServiceData;
|
|
198
|
-
declare const robotCloudClient_getServiceInstance: typeof getServiceInstance;
|
|
199
|
-
declare const robotCloudClient_getServiceInstances: typeof getServiceInstances;
|
|
200
|
-
declare const robotCloudClient_getTags: typeof getTags;
|
|
201
|
-
declare const robotCloudClient_getTagsChildren: typeof getTagsChildren;
|
|
202
|
-
declare const robotCloudClient_getTagsTree: typeof getTagsTree;
|
|
203
|
-
declare const robotCloudClient_getUser: typeof getUser;
|
|
204
|
-
declare const robotCloudClient_getUserProjects: typeof getUserProjects;
|
|
205
|
-
declare namespace robotCloudClient {
|
|
206
|
-
export { robotCloudClient_getClassifier as getClassifier, robotCloudClient_getDeviceDetails as getDeviceDetails, robotCloudClient_getLocation as getLocation, robotCloudClient_getLocationServiceInstances as getLocationServiceInstances, robotCloudClient_getLocations as getLocations, robotCloudClient_getOrganization as getOrganization, robotCloudClient_getOrganizationProjects as getOrganizationProjects, robotCloudClient_getProjectClassifiers as getProjectClassifiers, robotCloudClient_getProjectDetails as getProjectDetails, robotCloudClient_getProjectServiceTypes as getProjectServiceTypes, robotCloudClient_getProjectSubsystem as getProjectSubsystem, robotCloudClient_getProjects as getProjects, robotCloudClient_getRoomGrouping1InstanceDeviceConfig as getRoomGrouping1InstanceDeviceConfig, robotCloudClient_getRoomGrouping1ServiceData as getRoomGrouping1ServiceData, robotCloudClient_getServiceInstance as getServiceInstance, robotCloudClient_getServiceInstances as getServiceInstances, robotCloudClient_getTags as getTags, robotCloudClient_getTagsChildren as getTagsChildren, robotCloudClient_getTagsTree as getTagsTree, robotCloudClient_getUser as getUser, robotCloudClient_getUserProjects as getUserProjects };
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
interface CheckTokenResponse {
|
|
210
|
-
renewed: boolean;
|
|
211
|
-
invalid: boolean;
|
|
212
|
-
access: string;
|
|
213
|
-
renew: string;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
interface RobotCloudJWTPayload {
|
|
217
|
-
exp: number;
|
|
218
|
-
sub: string; // username
|
|
219
|
-
org: string; // organization
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
interface RobotCloudNewTokenResponse {
|
|
223
|
-
access: string;
|
|
224
|
-
renew: string;
|
|
225
|
-
}
|
|
226
|
-
declare const decodeToken: (token: string) => RobotCloudJWTPayload | undefined;
|
|
227
|
-
declare const isTokenExpired: (payload: RobotCloudJWTPayload) => boolean;
|
|
228
|
-
declare const renewToken: (renew_token: string) => Promise<CheckTokenResponse>;
|
|
229
|
-
declare const validateToken: (access_token: string) => Promise<boolean>;
|
|
230
|
-
|
|
231
|
-
type robotCloudToken_RobotCloudNewTokenResponse = RobotCloudNewTokenResponse;
|
|
232
|
-
declare const robotCloudToken_decodeToken: typeof decodeToken;
|
|
233
|
-
declare const robotCloudToken_isTokenExpired: typeof isTokenExpired;
|
|
234
|
-
declare const robotCloudToken_renewToken: typeof renewToken;
|
|
235
|
-
declare const robotCloudToken_validateToken: typeof validateToken;
|
|
236
|
-
declare namespace robotCloudToken {
|
|
237
|
-
export { type robotCloudToken_RobotCloudNewTokenResponse as RobotCloudNewTokenResponse, robotCloudToken_decodeToken as decodeToken, robotCloudToken_isTokenExpired as isTokenExpired, robotCloudToken_renewToken as renewToken, robotCloudToken_validateToken as validateToken };
|
|
238
|
-
}
|
|
239
|
-
|
|
240
147
|
interface RoomClime1Data {
|
|
241
148
|
demandRF: boolean;
|
|
242
149
|
eco_mode: "STANDBY"|"ECO"|"VIP";
|
|
@@ -287,6 +194,23 @@ interface RoomGuestStatus1Data {
|
|
|
287
194
|
medical_alarm: boolean;
|
|
288
195
|
}
|
|
289
196
|
|
|
197
|
+
interface ServiceInstanceDeviceConfig {
|
|
198
|
+
device: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
interface RoomGrouping1InstanceDeviceConfig {
|
|
202
|
+
Main: ServiceInstanceDeviceConfig;
|
|
203
|
+
Replica_1: ServiceInstanceDeviceConfig;
|
|
204
|
+
Replica_2: ServiceInstanceDeviceConfig;
|
|
205
|
+
Replica_3: ServiceInstanceDeviceConfig;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
interface RoomGrouping1DataEventValue {
|
|
209
|
+
replica_1_active: boolean;
|
|
210
|
+
replica_2_active: boolean;
|
|
211
|
+
replica_3_active: boolean;
|
|
212
|
+
}
|
|
213
|
+
|
|
290
214
|
interface RoomClimeConfigurationParams {
|
|
291
215
|
temperature_set_point?: number;
|
|
292
216
|
humidity_set_point?: number;
|
|
@@ -363,4 +287,52 @@ declare class RoomConsumesClient implements ServiceTypeClient<RoomConsumes1Alert
|
|
|
363
287
|
}
|
|
364
288
|
declare const roomConsumesClient: RoomConsumesClient;
|
|
365
289
|
|
|
366
|
-
|
|
290
|
+
interface ProjectClassifiersRequestParams extends PaginableRequestParams {
|
|
291
|
+
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
interface Classifier {
|
|
295
|
+
id: string;
|
|
296
|
+
name: string;
|
|
297
|
+
description: string;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
interface ClassifierDetails extends Classifier {
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
interface ProjectTagTreeNode {
|
|
304
|
+
tag: ProjectTag;
|
|
305
|
+
children: ProjectTagTreeNode[];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
interface ProjectTagsTree {
|
|
309
|
+
root: ProjectTagTreeNode[]
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
interface ProjectTag {
|
|
313
|
+
id: string;
|
|
314
|
+
name: string;
|
|
315
|
+
parent_id: string;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
interface RobotCloudServiceInstance extends RobotCloudNamedItem {
|
|
319
|
+
service: string;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
interface ServiceInstanceDetails extends RobotCloudServiceInstance {
|
|
323
|
+
description: string;
|
|
324
|
+
tags: string[];
|
|
325
|
+
subsystems: string[];
|
|
326
|
+
classifier: string;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
interface ServiceInstancesRequestParams extends SubsystemRequestParams,
|
|
330
|
+
PaginableRequestParams {
|
|
331
|
+
id?: string;
|
|
332
|
+
name?: string;
|
|
333
|
+
location_id?: string;
|
|
334
|
+
device_id?: string;
|
|
335
|
+
tag_id?: string[];
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export { type AirQuality1AlertEventValue, type AirQuality1DataEventValue, type CheckTokenResponse, type Classifier, type ClassifierDetails, type HistoricAggregateFunction, type MeasurementStatus, PaginableRequestParams, type ProjectClassifiersRequestParams, type ProjectTag, type ProjectTagTreeNode, type ProjectTagsTree, RegimState, RobotCloudClientConfig, type RobotCloudJWTPayload, RobotCloudNamedItem, type RobotCloudServiceInstance, RoomClime1AlertEventValue, type RoomClime1Data, type RoomClimeConfigurationParams, RoomConsumes1AlertEventValue, type RoomConsumes1Data, type RoomGrouping1DataEventValue, type RoomGrouping1InstanceDeviceConfig, type RoomGuestStatus1AlertEventValue, type RoomGuestStatus1Data, type RoomGuestStatusConfigurationParams, type ServiceDataMeasurement, type ServiceDataRequestParams, ServiceInstanceDataRequestParams, type ServiceInstanceDetails, type ServiceInstanceDeviceConfig, type ServiceInstanceHistoricAggregateParams, type ServiceInstanceHistoricParams, type ServiceInstanceRead, type ServiceInstancesRequestParams, type ServiceTypeClient, SubsystemRequestParams, TemperatureUnit, airQualityClient, clientConfig, robotCloudToken, robotcloudApi, roomClimeClient, roomConsumesClient, roomGuestStatusClient };
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,6 @@ __export(src_exports, {
|
|
|
36
36
|
robotCloudPermissionsHelper: () => robotCloudPermissionsHelper,
|
|
37
37
|
robotCloudToken: () => robotCloudToken_exports,
|
|
38
38
|
robotcloudApi: () => robotCloudApi_default,
|
|
39
|
-
robotcloudClient: () => robotCloudClient_exports,
|
|
40
39
|
roomClimeClient: () => roomClimeClient,
|
|
41
40
|
roomConsumesClient: () => roomConsumesClient,
|
|
42
41
|
roomGuestStatusClient: () => roomGuestStatusClient
|
|
@@ -106,170 +105,16 @@ robotcloudApi.interceptors.request.use(
|
|
|
106
105
|
);
|
|
107
106
|
var robotCloudApi_default = robotcloudApi;
|
|
108
107
|
|
|
109
|
-
// src/robotCloudClient.ts
|
|
110
|
-
var robotCloudClient_exports = {};
|
|
111
|
-
__export(robotCloudClient_exports, {
|
|
112
|
-
getClassifier: () => getClassifier,
|
|
113
|
-
getDeviceDetails: () => getDeviceDetails,
|
|
114
|
-
getLocation: () => getLocation,
|
|
115
|
-
getLocationServiceInstances: () => getLocationServiceInstances,
|
|
116
|
-
getLocations: () => getLocations,
|
|
117
|
-
getOrganization: () => getOrganization,
|
|
118
|
-
getOrganizationProjects: () => getOrganizationProjects,
|
|
119
|
-
getProjectClassifiers: () => getProjectClassifiers,
|
|
120
|
-
getProjectDetails: () => getProjectDetails,
|
|
121
|
-
getProjectServiceTypes: () => getProjectServiceTypes,
|
|
122
|
-
getProjectSubsystem: () => getProjectSubsystem,
|
|
123
|
-
getProjects: () => getProjects,
|
|
124
|
-
getRoomGrouping1InstanceDeviceConfig: () => getRoomGrouping1InstanceDeviceConfig,
|
|
125
|
-
getRoomGrouping1ServiceData: () => getRoomGrouping1ServiceData,
|
|
126
|
-
getServiceInstance: () => getServiceInstance,
|
|
127
|
-
getServiceInstances: () => getServiceInstances,
|
|
128
|
-
getTags: () => getTags,
|
|
129
|
-
getTagsChildren: () => getTagsChildren,
|
|
130
|
-
getTagsTree: () => getTagsTree,
|
|
131
|
-
getUser: () => getUser,
|
|
132
|
-
getUserProjects: () => getUserProjects
|
|
133
|
-
});
|
|
134
|
-
var logger2 = useLogger("robotcloud-client");
|
|
135
|
-
var getLocationServiceInstances = (prjId, locId, service_type, params) => {
|
|
136
|
-
return robotCloudApi_default.get(`projects/${prjId}/locations/${locId}/services/${service_type}/instances`, {
|
|
137
|
-
params
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
var getUser = (username) => {
|
|
141
|
-
return robotCloudApi_default.get(`users/${username}`);
|
|
142
|
-
};
|
|
143
|
-
var getUserProjects = (username) => {
|
|
144
|
-
return robotCloudApi_default.get(`users/${username}/projects`);
|
|
145
|
-
};
|
|
146
|
-
var getOrganization = (organizationId) => {
|
|
147
|
-
return robotCloudApi_default.get(`organizations/${organizationId}`);
|
|
148
|
-
};
|
|
149
|
-
var getOrganizationProjects = (organizationId) => {
|
|
150
|
-
return robotCloudApi_default.get(`organizations/${organizationId}/projects`);
|
|
151
|
-
};
|
|
152
|
-
var getProjects = (params) => {
|
|
153
|
-
return robotCloudApi_default.get("projects", {
|
|
154
|
-
params
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
var getProjectDetails = (prjId, params) => {
|
|
158
|
-
return robotCloudApi_default.get(`projects/${prjId}`, {
|
|
159
|
-
params
|
|
160
|
-
});
|
|
161
|
-
};
|
|
162
|
-
var getProjectSubsystem = (prjId, subsysId) => {
|
|
163
|
-
return robotCloudApi_default.get(`projects/${prjId}/subsystems/${subsysId}`);
|
|
164
|
-
};
|
|
165
|
-
var getLocations = (prjId, params) => {
|
|
166
|
-
return robotCloudApi_default.get(`projects/${prjId}/locations`, {
|
|
167
|
-
params
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
var getLocation = (locationId) => {
|
|
171
|
-
return robotCloudApi_default.get(`locations/${locationId}`, {});
|
|
172
|
-
};
|
|
173
|
-
var getServiceInstances = (prjId, service_type, params) => {
|
|
174
|
-
return robotCloudApi_default.get(`projects/${prjId}/services/${service_type}/instances`, {
|
|
175
|
-
params
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
var getServiceInstance = (prjId, service_type, service_id) => {
|
|
179
|
-
return robotCloudApi_default.get(`projects/${prjId}/services/${service_type}/instances/${service_id}`);
|
|
180
|
-
};
|
|
181
|
-
var getProjectClassifiers = (prjId, params) => {
|
|
182
|
-
logger2.info(`Get project ${prjId} classifiers`);
|
|
183
|
-
return robotCloudApi_default.get(`projects/${prjId}/classifiers`, {
|
|
184
|
-
params
|
|
185
|
-
});
|
|
186
|
-
};
|
|
187
|
-
var getClassifier = (classifierId) => {
|
|
188
|
-
return robotCloudApi_default.get(`classifiers/${classifierId}`);
|
|
189
|
-
};
|
|
190
|
-
var getTags = (prjId, params) => {
|
|
191
|
-
logger2.info(`Get project ${prjId} tags`);
|
|
192
|
-
return robotCloudApi_default.get(`projects/${prjId}/tags`, {
|
|
193
|
-
params
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
var getTagsTree = async (prjId, maxDepth = 2, params) => {
|
|
197
|
-
logger2.info(`Get project ${prjId} tags tree`);
|
|
198
|
-
if (!params) {
|
|
199
|
-
params = {};
|
|
200
|
-
}
|
|
201
|
-
params.no_parent = true;
|
|
202
|
-
const tags = await getTagsChildren(prjId, 0, void 0, void 0, maxDepth);
|
|
203
|
-
return { root: tags };
|
|
204
|
-
};
|
|
205
|
-
var getTagsChildren = async (prjId, level = 0, parent_id, params, maxDepth) => {
|
|
206
|
-
logger2.debug(`Get project ${prjId} tags children: ${parent_id}`);
|
|
207
|
-
if (!params) {
|
|
208
|
-
params = {};
|
|
209
|
-
}
|
|
210
|
-
params.no_parent = !parent_id;
|
|
211
|
-
params.parent_tag = parent_id;
|
|
212
|
-
const tags = await getTags(prjId, params);
|
|
213
|
-
if (tags.data.length == 0) {
|
|
214
|
-
return [];
|
|
215
|
-
}
|
|
216
|
-
const response = [];
|
|
217
|
-
const requests = [];
|
|
218
|
-
for (let i2 = 0; i2 < tags.data.length; i2++) {
|
|
219
|
-
const element = tags.data[i2];
|
|
220
|
-
const node = {
|
|
221
|
-
tag: element
|
|
222
|
-
};
|
|
223
|
-
response.push(node);
|
|
224
|
-
if (maxDepth && level < maxDepth) {
|
|
225
|
-
requests.push(
|
|
226
|
-
getTagsChildren(prjId, level + 1, element.id, params, maxDepth)
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
const responses = await Promise.all(requests);
|
|
231
|
-
let i = 0;
|
|
232
|
-
responses.forEach((element) => {
|
|
233
|
-
response[i].children = element;
|
|
234
|
-
i++;
|
|
235
|
-
});
|
|
236
|
-
return response;
|
|
237
|
-
};
|
|
238
|
-
var getDeviceDetails = (deviceId) => {
|
|
239
|
-
return robotCloudApi_default.get(`devices/${deviceId}`);
|
|
240
|
-
};
|
|
241
|
-
var getProjectServiceTypes = (prjId, params) => {
|
|
242
|
-
return robotCloudApi_default.get(`projects/${prjId}/services`, {
|
|
243
|
-
params
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
var getRoomGrouping1ServiceData = (prjId, params) => {
|
|
247
|
-
return robotCloudApi_default.get(
|
|
248
|
-
`/projects/${prjId}/services/RoomGrouping_1/data`,
|
|
249
|
-
{
|
|
250
|
-
params,
|
|
251
|
-
headers: {
|
|
252
|
-
"Accept": "application/json"
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
);
|
|
256
|
-
};
|
|
257
|
-
var getRoomGrouping1InstanceDeviceConfig = (prjId, instanceId) => {
|
|
258
|
-
return robotCloudApi_default.put(
|
|
259
|
-
`/projects/${prjId}/services/RoomGrouping_1/instances/${instanceId}/configuration`
|
|
260
|
-
);
|
|
261
|
-
};
|
|
262
|
-
|
|
263
108
|
// src/helpers/robotCloudToken.ts
|
|
264
109
|
var robotCloudToken_exports = {};
|
|
265
110
|
__export(robotCloudToken_exports, {
|
|
266
111
|
decodeToken: () => decodeToken,
|
|
267
|
-
|
|
112
|
+
needRenew: () => needRenew,
|
|
268
113
|
renewToken: () => renewToken,
|
|
269
114
|
validateToken: () => validateToken
|
|
270
115
|
});
|
|
271
116
|
var import_axios2 = __toESM(require("axios"));
|
|
272
|
-
var
|
|
117
|
+
var logger2 = useLogger("robotcloud-token");
|
|
273
118
|
function parseJwt(token) {
|
|
274
119
|
if (!token) {
|
|
275
120
|
return;
|
|
@@ -283,7 +128,7 @@ var decodeToken = (token) => {
|
|
|
283
128
|
}
|
|
284
129
|
return payload;
|
|
285
130
|
};
|
|
286
|
-
var
|
|
131
|
+
var needRenew = (payload) => {
|
|
287
132
|
const expirationDate = new Date(payload.exp * 1e3);
|
|
288
133
|
expirationDate.setMinutes(
|
|
289
134
|
expirationDate.getMinutes() - config_default.tokenMinutesBeforeExpirationRenew
|
|
@@ -292,7 +137,7 @@ var isTokenExpired = (payload) => {
|
|
|
292
137
|
return currentDate >= expirationDate;
|
|
293
138
|
};
|
|
294
139
|
var renewToken = async (renew_token) => {
|
|
295
|
-
|
|
140
|
+
logger2.debug("Renewing token ...");
|
|
296
141
|
const cloudUrl = robotCloudApi_default.defaults.baseURL;
|
|
297
142
|
const { data } = await import_axios2.default.get(cloudUrl + "login/renew", {
|
|
298
143
|
headers: {
|
|
@@ -307,7 +152,7 @@ var renewToken = async (renew_token) => {
|
|
|
307
152
|
};
|
|
308
153
|
var validateToken = async (access_token) => {
|
|
309
154
|
var _a, _b, _c;
|
|
310
|
-
|
|
155
|
+
logger2.debug("Validate token ...");
|
|
311
156
|
const payload = decodeToken(access_token);
|
|
312
157
|
if (!payload) {
|
|
313
158
|
return false;
|
|
@@ -324,9 +169,9 @@ var validateToken = async (access_token) => {
|
|
|
324
169
|
);
|
|
325
170
|
} catch (error) {
|
|
326
171
|
if (import_axios2.default.isAxiosError(error)) {
|
|
327
|
-
|
|
172
|
+
logger2.warn(`${error.message}: ${(_c = (_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) != null ? _c : ""}`);
|
|
328
173
|
} else {
|
|
329
|
-
|
|
174
|
+
logger2.warn(error);
|
|
330
175
|
}
|
|
331
176
|
return false;
|
|
332
177
|
}
|
|
@@ -613,10 +458,35 @@ var RoomConsumesClient = class {
|
|
|
613
458
|
};
|
|
614
459
|
var roomConsumesClient = new RoomConsumesClient();
|
|
615
460
|
|
|
461
|
+
// src/client/projects/index.ts
|
|
462
|
+
var ProjectsClient = class {
|
|
463
|
+
constructor() {
|
|
464
|
+
this.getProjects = (params) => {
|
|
465
|
+
return robotCloudApi_default.get("projects", {
|
|
466
|
+
params
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
this.getProjectDetails = (prjId, params) => {
|
|
470
|
+
return robotCloudApi_default.get(`projects/${prjId}`, {
|
|
471
|
+
params
|
|
472
|
+
});
|
|
473
|
+
};
|
|
474
|
+
this.getProjectServiceTypes = (prjId, params) => {
|
|
475
|
+
return robotCloudApi_default.get(
|
|
476
|
+
`projects/${prjId}/services`,
|
|
477
|
+
{
|
|
478
|
+
params
|
|
479
|
+
}
|
|
480
|
+
);
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
var projectsClient = new ProjectsClient();
|
|
485
|
+
|
|
616
486
|
// src/helpers/robotCloudPermissionsHelper.ts
|
|
617
487
|
var RobotCloudPermissionsHelperImpl = class {
|
|
618
488
|
async checkProjectAccess(prjId, required_project_access) {
|
|
619
|
-
const { data: project } = await getProjectDetails(prjId);
|
|
489
|
+
const { data: project } = await projectsClient.getProjectDetails(prjId);
|
|
620
490
|
if (project.access_level == required_project_access) {
|
|
621
491
|
return true;
|
|
622
492
|
}
|
|
@@ -660,7 +530,6 @@ var robotCloudPermissionsHelper = new RobotCloudPermissionsHelperImpl();
|
|
|
660
530
|
robotCloudPermissionsHelper,
|
|
661
531
|
robotCloudToken,
|
|
662
532
|
robotcloudApi,
|
|
663
|
-
robotcloudClient,
|
|
664
533
|
roomClimeClient,
|
|
665
534
|
roomConsumesClient,
|
|
666
535
|
roomGuestStatusClient
|