@dronedeploy/rocos-js-sdk 3.0.18 → 3.0.20
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/cjs/constants/api.d.ts +2 -0
- package/cjs/constants/api.js +5 -3
- package/cjs/services/CallerService.d.ts +7 -1
- package/cjs/services/CallerService.js +28 -11
- package/cjs/services/ProfileService.d.ts +6 -0
- package/cjs/services/ProfileService.js +10 -0
- package/esm/constants/api.d.ts +2 -0
- package/esm/constants/api.js +2 -0
- package/esm/services/CallerService.d.ts +7 -1
- package/esm/services/CallerService.js +29 -12
- package/esm/services/ProfileService.d.ts +6 -0
- package/esm/services/ProfileService.js +11 -1
- package/package.json +1 -1
package/cjs/constants/api.d.ts
CHANGED
@@ -85,6 +85,8 @@ export declare const API_PROJECT_DEFINITION_TRIGGER_URL = "https://{url}/project
|
|
85
85
|
export declare const API_PROJECT_DEFINITION_GAMEPAD_URL = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/gamepads";
|
86
86
|
export declare const API_PROJECT_DEFINITION_EXPORT = "https://{url}/import-export/projects/{projectId}/robot-definitions/{definitionId}/export";
|
87
87
|
export declare const API_PROJECT_DEFINITION_IMPORT = "https://{url}/import-export/projects/{projectId}/robot-definitions/import";
|
88
|
+
export declare const API_PROJECT_DEFINITION_IMPORT_LIBRARY = "https://{url}/import-export/projects/{projectId}/robot-definitions/import/{profileId}";
|
89
|
+
export declare const API_PROJECT_DEFINITION_LIBRARY = "https://{url}/import-export/library";
|
88
90
|
export declare const API_PROJECT_ENVIRONMENT_URL = "https://{url}/graphs/projects/{projectId}/environments";
|
89
91
|
export declare const API_PROJECT_GROUP_TYPE_URL = "https://{url}/projects/{projectId}/config-groups/{type}";
|
90
92
|
export declare const API_PROJECT_GROUP_TYPE_ID_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}";
|
package/cjs/constants/api.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.API_PROJECT_ROBOT_EVENT_URL = exports.API_PROJECT_ROBOT_REGISTER_URL = exports.API_PROJECT_ROBOT_DEFINITION_URL = exports.API_PROJECT_ROBOT_ATTRIBUTES_URL = exports.API_PROJECT_ROBOT_ID_URL = exports.API_ACCOUNT_ROBOT_URL = exports.API_PROJECT_ROBOT_URL = exports.API_PROJECT_MAPPED_ASSET_PATH_URL = exports.API_PROJECT_MAPPED_ASSETS_PATH_URL = exports.API_PROJECT_MISSION_ASSET_PATH_URL = exports.API_PROJECT_MISSION_ASSETS_PATH_URL = exports.API_PROJECT_FLOW_ASSET_PATH_URL = exports.API_PROJECT_ROBOT_ASSET_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATION_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATIONS_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATION_PROVIDERS_PATH_URL = exports.API_PROJECT_ASSET_PROFILES_SYNC_DEFINITION_PATH_URL = exports.API_PROJECT_ASSET_ROBOTS_SYNC_DEFINITION_PATH_URL = exports.API_PROJECT_ASSET_PATH_URL = exports.API_PROJECT_ASSET_URL = exports.API_PROJECT_USERS_URL = exports.API_PROJECT_ID_URL = exports.API_PROJECT_URL = exports.API_ACCOUNT_EXTERNAL_PROJECTS_URL = exports.API_ACCOUNT_PROJECT_APPLICATION_ID_URL = exports.API_ACCOUNT_PROJECT_APPLICATION_URL = exports.API_ACCOUNT_PROJECT_USER_ID_URL = exports.API_ACCOUNT_PROJECT_USER_URL = exports.API_ACCOUNT_PROJECT_ID_URL = exports.API_ACCOUNT_PROJECT_URL = exports.API_SERVER_TIME_URL = exports.API_ACCOUNT_SETTINGS_URL = exports.API_AUTH_USER_ACCOUNT_USER_ID_URL = exports.API_AUTH_USER_ACCOUNT_USER_URL = exports.API_ACCOUNT_ACTIVATE_URL = exports.API_ACCOUNT_ID_URL = exports.API_ACCOUNT_URL = exports.API_USER_PAT_TOKEN_URL = exports.API_USER_PAT_URL = exports.API_USER_VERIFY_EMAIL_URL = exports.API_USER_INVITATION_CHECK_URL = exports.API_USER_INVITATION_ACCEPT_URL = exports.API_USER_INVITATION_URL = exports.API_USER_PASSWORD_FORGOT_URL = exports.API_OTP_AUTH_URL = exports.API_OTP_URL = exports.API_USER_TOKEN_URL = exports.API_USER_URL = exports.API_ADMIN_USER_INVITATION_URL = exports.API_APPLICATION_AUTH_URL = void 0;
|
4
|
-
exports.
|
5
|
-
exports.
|
6
|
-
exports.API_PROJECT_ROBOT_TAG_URL = exports.API_PROJECT_PROFILE_TAG_URL = exports.API_PROJECT_PROFILE_TAGS_URL = exports.API_PROJECT_TAG_ROBOTS_URL = exports.API_PROJECT_ROBOT_TAGS_URL = void 0;
|
4
|
+
exports.API_PROJECT_STREAM_DATA_URL = exports.API_PROJECT_STREAM_ID_URL = exports.API_PROJECT_STREAM_URL = exports.API_PROJECT_GROUP_TYPE_OWNER_OVERRIDE_URL = exports.API_PROJECT_GROUP_TYPE_OWNER_ID_URL = exports.API_PROJECT_GROUP_TYPE_VERSION_URL = exports.API_PROJECT_GROUP_TYPE_CONFIG_URL = exports.API_PROJECT_GROUP_TYPE_PUBLISH_URL = exports.API_PROJECT_GROUP_TYPE_ID_URL = exports.API_PROJECT_GROUP_TYPE_URL = exports.API_PROJECT_ENVIRONMENT_URL = exports.API_PROJECT_DEFINITION_LIBRARY = exports.API_PROJECT_DEFINITION_IMPORT_LIBRARY = exports.API_PROJECT_DEFINITION_IMPORT = exports.API_PROJECT_DEFINITION_EXPORT = exports.API_PROJECT_DEFINITION_GAMEPAD_URL = exports.API_PROJECT_DEFINITION_TRIGGER_URL = exports.API_PROJECT_DEFINITION_BUTTON_URL = exports.API_PROJECT_DEFINITION_ACTION_URL = exports.API_PROJECT_DEFINITION_EVENT_URL = exports.API_PROJECT_DEFINITION_COMMAND2_URL = exports.API_PROJECT_DEFINITION_COMMAND_URL = exports.API_PROJECT_DEFINITION_AGENT_URL = exports.API_PROJECT_DEFINITION_SETTING_URL = exports.API_PROJECT_DEFINITION_BLOB_URL = exports.API_PROJECT_DEFINITION_DASHBOARD_URL = exports.API_PROJECT_DEFINITION_COPY_URL = exports.API_PROJECT_DEFINITION_STREAM_URL = exports.API_PROJECT_DEFINITION_ID_URL = exports.API_PROJECT_DEFINITION_URL = exports.API_PROJECT_VROBOT_DEPLOY_URL = exports.API_PROJECT_VROBOT_DETAILS_URL = exports.API_PROJECT_COLLECTION_DOCS_URL = exports.API_PROJECT_COLLECTION_ID_URL = exports.API_PROJECT_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_DASHBOARD_WIDGET_URL = exports.API_PROJECT_DASHBOARD_ID_URL = exports.API_PROJECT_DASHBOARD_URL = exports.API_PROJECT_OPERATION_ID_URL = exports.API_PROJECT_OPERATION_URL = exports.API_PROJECT_ROBOT_CONFIGS_CONNECTION_URL = exports.API_PROJECT_ROBOT_CONFIGS_CONNECTIONS_URL = exports.API_PROJECT_ROBOT_GAMEPAD_URL = exports.API_PROJECT_ROBOT_TRIGGER_URL = exports.API_PROJECT_ROBOT_BUTTON_URL = exports.API_PROJECT_ROBOT_COMMAND2_URL = exports.API_PROJECT_ROBOT_COMMAND_URL = exports.API_PROJECT_ROBOT_AGENT_URL = exports.API_PROJECT_ROBOT_SETTING_URL = exports.API_PROJECT_ROBOT_EVENT_HISTORY_URL = void 0;
|
5
|
+
exports.API_LINKED_PROJECT_URL = exports.API_PROJECT_WORKFLOW_IMPORT_URL = exports.API_PROJECT_WORKFLOW_EXPORT_URL = exports.API_PROJECT_WORKFLOW_AFFECTED_URL = exports.API_PROJECT_ROBOT_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_PROFILE_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_ROBOT_NO_PROFILE_DEPLOYMENTS_URL = exports.API_PROJECT_PROFILE_DEPLOYMENTS_URL = exports.API_PROJECT_ROBOT_DEPLOYMENTS_URL = exports.API_PROJECT_WORKFLOW_ASSET_ID_URL = exports.API_PROJECT_WORKFLOW_ASSET_URL = exports.API_PROJECT_WORKFLOW_ID_URL = exports.API_PROJECT_WORKFLOW_URL = exports.API_GRAPHS_ASSETS_URL = exports.API_GRAPHS_ASSETS_UPLOAD_URL = exports.API_GRAPHS_TARGETS_URL = exports.API_GRAPHS_TARGET_UPLOAD_URL = exports.API_GRAPHS_OBSERVATION_KEYS_URL = exports.API_GRAPHS_OBSERVATIONS_URL = exports.API_GRAPHS_PANORAMA_OBSERVATIONS_URL = exports.API_GRAPHS_PANORAMA = exports.API_GRAPHS_MAPS_GEOJSON_URL = exports.API_GRAPHS_MAPS_DEPLOY_URL = exports.API_GRAPHS_MAPS_COPY_URL = exports.API_GRAPHS_MAP_ID_URL = exports.API_GRAPHS_MAPS_MERGE_URL = exports.API_GRAPHS_MAPS_DEPLOYED_URL = exports.API_GRAPHS_MAPS_URL = exports.API_DD_INTEGRATION_LOCATIONS_URL = exports.API_DD_INTEGRATION_ISSUES_URL = exports.API_DD_INTEGRATION_OVERLAYS_URL = exports.API_DD_INTEGRATION_PLAN_BY_ID_URL = exports.API_DD_INTEGRATION_PLANS_URL = exports.API_SPOTTY_URL = exports.API_PROJECT_SCHEDULES_URL = exports.API_SOURCE_ID_URL = exports.API_SOURCE_URL = exports.API_SOURCE_SCHEMA_URL = exports.API_TEMPLATE_EXPORTER_URL = exports.API_TEMPLATE_PROVISION_ID_URL = exports.API_TEMPLATE_PROVISION_URL = exports.API_TEMPLATE_DEPLOY_URL = exports.API_PROJECT_PROFILE_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_PROFILE_DASHBOARD_ID_URL = exports.API_PROJECT_PROFILE_DASHBOARD_URL = exports.API_PROJECT_CALLSIGN_STREAM_URL = exports.API_PROJECT_ROBOT_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_ROBOT_DASHBOARD_ID_URL = exports.API_PROJECT_ROBOT_DASHBOARD_URL = exports.API_PROJECT_STREAM_CALLSIGN_URL = void 0;
|
6
|
+
exports.API_PROJECT_ROBOT_TAG_URL = exports.API_PROJECT_PROFILE_TAG_URL = exports.API_PROJECT_PROFILE_TAGS_URL = exports.API_PROJECT_TAG_ROBOTS_URL = exports.API_PROJECT_ROBOT_TAGS_URL = exports.API_DEVICE_CREDENTIALS_AUTH_URL = exports.API_DEVICE_CREDENTIALS_URL = void 0;
|
7
7
|
exports.API_APPLICATION_AUTH_URL = 'https://{url}/applications/auth';
|
8
8
|
exports.API_ADMIN_USER_INVITATION_URL = 'https://{url}/admin/users/invitations';
|
9
9
|
exports.API_USER_URL = 'https://{url}/users';
|
@@ -91,6 +91,8 @@ exports.API_PROJECT_DEFINITION_TRIGGER_URL = 'https://{url}/projects/{projectId}
|
|
91
91
|
exports.API_PROJECT_DEFINITION_GAMEPAD_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/gamepads';
|
92
92
|
exports.API_PROJECT_DEFINITION_EXPORT = 'https://{url}/import-export/projects/{projectId}/robot-definitions/{definitionId}/export';
|
93
93
|
exports.API_PROJECT_DEFINITION_IMPORT = 'https://{url}/import-export/projects/{projectId}/robot-definitions/import';
|
94
|
+
exports.API_PROJECT_DEFINITION_IMPORT_LIBRARY = 'https://{url}/import-export/projects/{projectId}/robot-definitions/import/{profileId}';
|
95
|
+
exports.API_PROJECT_DEFINITION_LIBRARY = 'https://{url}/import-export/library';
|
94
96
|
exports.API_PROJECT_ENVIRONMENT_URL = 'https://{url}/graphs/projects/{projectId}/environments';
|
95
97
|
exports.API_PROJECT_GROUP_TYPE_URL = 'https://{url}/projects/{projectId}/config-groups/{type}';
|
96
98
|
exports.API_PROJECT_GROUP_TYPE_ID_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ICallerCallParams, ICallerInvokeParams, ICallerParams, ICallerStream, IRocosCallerMessage, IRocosCallerMessageResponseAck, IRocosCallerMessageResponseResult, IRocosCallerMessageResponseReturn, IRocosSDKConfig, IStreamConfig } from '../models';
|
1
|
+
import { ICallerCallParams, ICallerInvokeParams, ICallerParams, ICallerStream, IRocosCallerMessage, IRocosCallerMessageResponse, IRocosCallerMessageResponseAck, IRocosCallerMessageResponseResult, IRocosCallerMessageResponseReturn, IRocosSDKConfig, IStreamConfig } from '../models';
|
2
2
|
import { Observable } from 'rxjs';
|
3
3
|
import { BaseStreamService } from './BaseStreamService';
|
4
4
|
export declare class CallerService extends BaseStreamService<ICallerStream> {
|
@@ -19,7 +19,9 @@ export declare class CallerService extends BaseStreamService<ICallerStream> {
|
|
19
19
|
return$: Observable<IRocosCallerMessageResponseReturn>;
|
20
20
|
result$: Observable<IRocosCallerMessageResponseResult>;
|
21
21
|
ack$: Observable<IRocosCallerMessageResponseAck>;
|
22
|
+
cancel$: Observable<IRocosCallerMessageResponse>;
|
22
23
|
};
|
24
|
+
private getCallerParams;
|
23
25
|
/** Call a service and return the response(s) as UTF-8 encoded JSON.
|
24
26
|
*
|
25
27
|
* It will complete once a result message is received with a `COMPLETE_SUCCESS` status,
|
@@ -28,6 +30,9 @@ export declare class CallerService extends BaseStreamService<ICallerStream> {
|
|
28
30
|
* This is a high level method that wraps the lower level `invokeRequest` method.
|
29
31
|
*
|
30
32
|
* Equivalent to calling `callRaw` and then parsing the return payload as UTF-8 encoded JSON.
|
33
|
+
* Also wraps the cancel functionality to return a promise. Await `cancel()` to cancel the call.
|
34
|
+
*
|
35
|
+
* When cancelled, `return$` will error and `result$` will complete
|
31
36
|
*
|
32
37
|
* @see callRaw
|
33
38
|
* @see invokeRequest
|
@@ -36,6 +41,7 @@ export declare class CallerService extends BaseStreamService<ICallerStream> {
|
|
36
41
|
return$: Observable<T>;
|
37
42
|
result$: Observable<IRocosCallerMessageResponseResult>;
|
38
43
|
ack$: Observable<IRocosCallerMessageResponseAck>;
|
44
|
+
cancel: () => Promise<void>;
|
39
45
|
};
|
40
46
|
protected createStream(): Promise<ICallerStream>;
|
41
47
|
protected getStream(config: IStreamConfig): ICallerStream;
|
@@ -41,13 +41,9 @@ class CallerService extends BaseStreamService_1.BaseStreamService {
|
|
41
41
|
const payloadString = params.options?.rawPayload
|
42
42
|
? String(params.payload ?? '')
|
43
43
|
: JSON.stringify(params.payload ?? {});
|
44
|
+
const callerParams = this.getCallerParams(params, component, topic);
|
44
45
|
const source$ = this.invokeRequest({
|
45
|
-
|
46
|
-
projectId: params.projectId,
|
47
|
-
callsign: params.callsign,
|
48
|
-
subSystem: '',
|
49
|
-
component,
|
50
|
-
topic,
|
46
|
+
...callerParams,
|
51
47
|
responseLevelNumber: models_1.RocosResponseLevel.ALL,
|
52
48
|
payload: payloadString,
|
53
49
|
query: params.options?.query,
|
@@ -60,10 +56,22 @@ class CallerService extends BaseStreamService_1.BaseStreamService {
|
|
60
56
|
}));
|
61
57
|
const return$ = source$.pipe((0, operators_1.filter)((x) => x.return !== undefined), (0, rxjs_1.map)((x) => x.return), (0, rxjs_1.takeUntil)(resultNotifier$));
|
62
58
|
const ack$ = source$.pipe((0, operators_1.filter)((x) => x.ack !== undefined), (0, rxjs_1.map)((x) => x.ack), (0, rxjs_1.takeUntil)(resultNotifier$));
|
59
|
+
const cancel$ = this.cancelRequest(callerParams).pipe((0, rxjs_1.mergeMap)(callerMessageHelpers_1.getResponses), (0, callerMessageHelpers_1.handleChunkedMessages)());
|
63
60
|
return {
|
64
61
|
return$,
|
65
62
|
result$,
|
66
63
|
ack$,
|
64
|
+
cancel$,
|
65
|
+
};
|
66
|
+
}
|
67
|
+
getCallerParams(params, component, topic) {
|
68
|
+
return {
|
69
|
+
uid: params.options?.uid ?? (0, uuid_1.v4)(),
|
70
|
+
projectId: params.projectId,
|
71
|
+
callsign: params.callsign,
|
72
|
+
subSystem: '',
|
73
|
+
component,
|
74
|
+
topic,
|
67
75
|
};
|
68
76
|
}
|
69
77
|
/** Call a service and return the response(s) as UTF-8 encoded JSON.
|
@@ -74,18 +82,27 @@ class CallerService extends BaseStreamService_1.BaseStreamService {
|
|
74
82
|
* This is a high level method that wraps the lower level `invokeRequest` method.
|
75
83
|
*
|
76
84
|
* Equivalent to calling `callRaw` and then parsing the return payload as UTF-8 encoded JSON.
|
85
|
+
* Also wraps the cancel functionality to return a promise. Await `cancel()` to cancel the call.
|
86
|
+
*
|
87
|
+
* When cancelled, `return$` will error and `result$` will complete
|
77
88
|
*
|
78
89
|
* @see callRaw
|
79
90
|
* @see invokeRequest
|
80
91
|
*/
|
81
92
|
call(params) {
|
82
93
|
const stream = this.callRaw(params);
|
94
|
+
const return$ = stream.return$.pipe((0, rxjs_1.map)((x) => {
|
95
|
+
const decoded = new TextDecoder().decode(x.payload);
|
96
|
+
return JSON.parse(decoded);
|
97
|
+
}));
|
98
|
+
const cancel = async () => {
|
99
|
+
await (0, rxjs_1.lastValueFrom)(stream.cancel$);
|
100
|
+
};
|
83
101
|
return {
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
})),
|
102
|
+
return$,
|
103
|
+
result$: stream.result$,
|
104
|
+
ack$: stream.ack$,
|
105
|
+
cancel,
|
89
106
|
};
|
90
107
|
}
|
91
108
|
async createStream() {
|
@@ -258,6 +258,12 @@ export declare class ProfileService extends BaseServiceAbstract implements IBase
|
|
258
258
|
import(projectId: string, profileData: Blob | File, newName?: string, newDescription?: string): Promise<{
|
259
259
|
profileId: string;
|
260
260
|
}>;
|
261
|
+
getLibraryProfiles(): Promise<(RobotProfile & {
|
262
|
+
last_modified: Date;
|
263
|
+
})[]>;
|
264
|
+
importFromLibrary(projectId: string, profileId: string, name?: string, description?: string): Promise<{
|
265
|
+
profileId: string;
|
266
|
+
}>;
|
261
267
|
/**
|
262
268
|
* Update gamepads for a robot definition
|
263
269
|
*
|
@@ -380,6 +380,16 @@ class ProfileService extends BaseServiceAbstract_1.BaseServiceAbstract {
|
|
380
380
|
formData.append('file', profileData);
|
381
381
|
return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_DEFINITION_IMPORT, { url: this.config.url, projectId }, this.config.insecure), formData, `Failed to import robot definition for ${projectId}.`);
|
382
382
|
}
|
383
|
+
async getLibraryProfiles() {
|
384
|
+
const profiles = await this.callGet((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_DEFINITION_LIBRARY, { url: this.config.url }, this.config.insecure), 'Failed to get library profiles.');
|
385
|
+
return profiles.map((profile) => ({
|
386
|
+
...profile,
|
387
|
+
last_modified: new Date(profile.last_modified),
|
388
|
+
}));
|
389
|
+
}
|
390
|
+
async importFromLibrary(projectId, profileId, name, description) {
|
391
|
+
return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_DEFINITION_IMPORT_LIBRARY, { url: this.config.url, projectId, profileId }, this.config.insecure), { name, description }, `Failed to import library profile ${profileId} into project ${projectId}.`);
|
392
|
+
}
|
383
393
|
/**
|
384
394
|
* Update gamepads for a robot definition
|
385
395
|
*
|
package/esm/constants/api.d.ts
CHANGED
@@ -85,6 +85,8 @@ export declare const API_PROJECT_DEFINITION_TRIGGER_URL = "https://{url}/project
|
|
85
85
|
export declare const API_PROJECT_DEFINITION_GAMEPAD_URL = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/gamepads";
|
86
86
|
export declare const API_PROJECT_DEFINITION_EXPORT = "https://{url}/import-export/projects/{projectId}/robot-definitions/{definitionId}/export";
|
87
87
|
export declare const API_PROJECT_DEFINITION_IMPORT = "https://{url}/import-export/projects/{projectId}/robot-definitions/import";
|
88
|
+
export declare const API_PROJECT_DEFINITION_IMPORT_LIBRARY = "https://{url}/import-export/projects/{projectId}/robot-definitions/import/{profileId}";
|
89
|
+
export declare const API_PROJECT_DEFINITION_LIBRARY = "https://{url}/import-export/library";
|
88
90
|
export declare const API_PROJECT_ENVIRONMENT_URL = "https://{url}/graphs/projects/{projectId}/environments";
|
89
91
|
export declare const API_PROJECT_GROUP_TYPE_URL = "https://{url}/projects/{projectId}/config-groups/{type}";
|
90
92
|
export declare const API_PROJECT_GROUP_TYPE_ID_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}";
|
package/esm/constants/api.js
CHANGED
@@ -85,6 +85,8 @@ export const API_PROJECT_DEFINITION_TRIGGER_URL = 'https://{url}/projects/{proje
|
|
85
85
|
export const API_PROJECT_DEFINITION_GAMEPAD_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/gamepads';
|
86
86
|
export const API_PROJECT_DEFINITION_EXPORT = 'https://{url}/import-export/projects/{projectId}/robot-definitions/{definitionId}/export';
|
87
87
|
export const API_PROJECT_DEFINITION_IMPORT = 'https://{url}/import-export/projects/{projectId}/robot-definitions/import';
|
88
|
+
export const API_PROJECT_DEFINITION_IMPORT_LIBRARY = 'https://{url}/import-export/projects/{projectId}/robot-definitions/import/{profileId}';
|
89
|
+
export const API_PROJECT_DEFINITION_LIBRARY = 'https://{url}/import-export/library';
|
88
90
|
export const API_PROJECT_ENVIRONMENT_URL = 'https://{url}/graphs/projects/{projectId}/environments';
|
89
91
|
export const API_PROJECT_GROUP_TYPE_URL = 'https://{url}/projects/{projectId}/config-groups/{type}';
|
90
92
|
export const API_PROJECT_GROUP_TYPE_ID_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ICallerCallParams, ICallerInvokeParams, ICallerParams, ICallerStream, IRocosCallerMessage, IRocosCallerMessageResponseAck, IRocosCallerMessageResponseResult, IRocosCallerMessageResponseReturn, IRocosSDKConfig, IStreamConfig } from '../models';
|
1
|
+
import { ICallerCallParams, ICallerInvokeParams, ICallerParams, ICallerStream, IRocosCallerMessage, IRocosCallerMessageResponse, IRocosCallerMessageResponseAck, IRocosCallerMessageResponseResult, IRocosCallerMessageResponseReturn, IRocosSDKConfig, IStreamConfig } from '../models';
|
2
2
|
import { Observable } from 'rxjs';
|
3
3
|
import { BaseStreamService } from './BaseStreamService';
|
4
4
|
export declare class CallerService extends BaseStreamService<ICallerStream> {
|
@@ -19,7 +19,9 @@ export declare class CallerService extends BaseStreamService<ICallerStream> {
|
|
19
19
|
return$: Observable<IRocosCallerMessageResponseReturn>;
|
20
20
|
result$: Observable<IRocosCallerMessageResponseResult>;
|
21
21
|
ack$: Observable<IRocosCallerMessageResponseAck>;
|
22
|
+
cancel$: Observable<IRocosCallerMessageResponse>;
|
22
23
|
};
|
24
|
+
private getCallerParams;
|
23
25
|
/** Call a service and return the response(s) as UTF-8 encoded JSON.
|
24
26
|
*
|
25
27
|
* It will complete once a result message is received with a `COMPLETE_SUCCESS` status,
|
@@ -28,6 +30,9 @@ export declare class CallerService extends BaseStreamService<ICallerStream> {
|
|
28
30
|
* This is a high level method that wraps the lower level `invokeRequest` method.
|
29
31
|
*
|
30
32
|
* Equivalent to calling `callRaw` and then parsing the return payload as UTF-8 encoded JSON.
|
33
|
+
* Also wraps the cancel functionality to return a promise. Await `cancel()` to cancel the call.
|
34
|
+
*
|
35
|
+
* When cancelled, `return$` will error and `result$` will complete
|
31
36
|
*
|
32
37
|
* @see callRaw
|
33
38
|
* @see invokeRequest
|
@@ -36,6 +41,7 @@ export declare class CallerService extends BaseStreamService<ICallerStream> {
|
|
36
41
|
return$: Observable<T>;
|
37
42
|
result$: Observable<IRocosCallerMessageResponseResult>;
|
38
43
|
ack$: Observable<IRocosCallerMessageResponseAck>;
|
44
|
+
cancel: () => Promise<void>;
|
39
45
|
};
|
40
46
|
protected createStream(): Promise<ICallerStream>;
|
41
47
|
protected getStream(config: IStreamConfig): ICallerStream;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ResultStatus, RocosResponseLevel, } from '../models';
|
2
|
-
import { from, map, mergeMap, share, switchMap, take, takeUntil, throwError } from 'rxjs';
|
2
|
+
import { from, lastValueFrom, map, mergeMap, share, switchMap, take, takeUntil, throwError } from 'rxjs';
|
3
3
|
import { catchError, filter } from 'rxjs/operators';
|
4
4
|
import { getResponses, handleChunkedMessages } from '../helpers/callerMessageHelpers';
|
5
5
|
import { BaseStreamService } from './BaseStreamService';
|
@@ -38,13 +38,9 @@ export class CallerService extends BaseStreamService {
|
|
38
38
|
const payloadString = params.options?.rawPayload
|
39
39
|
? String(params.payload ?? '')
|
40
40
|
: JSON.stringify(params.payload ?? {});
|
41
|
+
const callerParams = this.getCallerParams(params, component, topic);
|
41
42
|
const source$ = this.invokeRequest({
|
42
|
-
|
43
|
-
projectId: params.projectId,
|
44
|
-
callsign: params.callsign,
|
45
|
-
subSystem: '',
|
46
|
-
component,
|
47
|
-
topic,
|
43
|
+
...callerParams,
|
48
44
|
responseLevelNumber: RocosResponseLevel.ALL,
|
49
45
|
payload: payloadString,
|
50
46
|
query: params.options?.query,
|
@@ -57,10 +53,22 @@ export class CallerService extends BaseStreamService {
|
|
57
53
|
}));
|
58
54
|
const return$ = source$.pipe(filter((x) => x.return !== undefined), map((x) => x.return), takeUntil(resultNotifier$));
|
59
55
|
const ack$ = source$.pipe(filter((x) => x.ack !== undefined), map((x) => x.ack), takeUntil(resultNotifier$));
|
56
|
+
const cancel$ = this.cancelRequest(callerParams).pipe(mergeMap(getResponses), handleChunkedMessages());
|
60
57
|
return {
|
61
58
|
return$,
|
62
59
|
result$,
|
63
60
|
ack$,
|
61
|
+
cancel$,
|
62
|
+
};
|
63
|
+
}
|
64
|
+
getCallerParams(params, component, topic) {
|
65
|
+
return {
|
66
|
+
uid: params.options?.uid ?? v4(),
|
67
|
+
projectId: params.projectId,
|
68
|
+
callsign: params.callsign,
|
69
|
+
subSystem: '',
|
70
|
+
component,
|
71
|
+
topic,
|
64
72
|
};
|
65
73
|
}
|
66
74
|
/** Call a service and return the response(s) as UTF-8 encoded JSON.
|
@@ -71,18 +79,27 @@ export class CallerService extends BaseStreamService {
|
|
71
79
|
* This is a high level method that wraps the lower level `invokeRequest` method.
|
72
80
|
*
|
73
81
|
* Equivalent to calling `callRaw` and then parsing the return payload as UTF-8 encoded JSON.
|
82
|
+
* Also wraps the cancel functionality to return a promise. Await `cancel()` to cancel the call.
|
83
|
+
*
|
84
|
+
* When cancelled, `return$` will error and `result$` will complete
|
74
85
|
*
|
75
86
|
* @see callRaw
|
76
87
|
* @see invokeRequest
|
77
88
|
*/
|
78
89
|
call(params) {
|
79
90
|
const stream = this.callRaw(params);
|
91
|
+
const return$ = stream.return$.pipe(map((x) => {
|
92
|
+
const decoded = new TextDecoder().decode(x.payload);
|
93
|
+
return JSON.parse(decoded);
|
94
|
+
}));
|
95
|
+
const cancel = async () => {
|
96
|
+
await lastValueFrom(stream.cancel$);
|
97
|
+
};
|
80
98
|
return {
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
})),
|
99
|
+
return$,
|
100
|
+
result$: stream.result$,
|
101
|
+
ack$: stream.ack$,
|
102
|
+
cancel,
|
86
103
|
};
|
87
104
|
}
|
88
105
|
async createStream() {
|
@@ -258,6 +258,12 @@ export declare class ProfileService extends BaseServiceAbstract implements IBase
|
|
258
258
|
import(projectId: string, profileData: Blob | File, newName?: string, newDescription?: string): Promise<{
|
259
259
|
profileId: string;
|
260
260
|
}>;
|
261
|
+
getLibraryProfiles(): Promise<(RobotProfile & {
|
262
|
+
last_modified: Date;
|
263
|
+
})[]>;
|
264
|
+
importFromLibrary(projectId: string, profileId: string, name?: string, description?: string): Promise<{
|
265
|
+
profileId: string;
|
266
|
+
}>;
|
261
267
|
/**
|
262
268
|
* Update gamepads for a robot definition
|
263
269
|
*
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { API_PROJECT_DEFINITION_ACTION_URL, API_PROJECT_DEFINITION_AGENT_URL, API_PROJECT_DEFINITION_BLOB_URL, API_PROJECT_DEFINITION_BUTTON_URL, API_PROJECT_DEFINITION_COMMAND2_URL, API_PROJECT_DEFINITION_COMMAND_URL, API_PROJECT_DEFINITION_COPY_URL, API_PROJECT_DEFINITION_DASHBOARD_URL, API_PROJECT_DEFINITION_EXPORT, API_PROJECT_DEFINITION_GAMEPAD_URL, API_PROJECT_DEFINITION_ID_URL, API_PROJECT_DEFINITION_IMPORT, API_PROJECT_DEFINITION_SETTING_URL, API_PROJECT_DEFINITION_STREAM_URL, API_PROJECT_DEFINITION_TRIGGER_URL, API_PROJECT_DEFINITION_URL, API_PROJECT_PROFILE_DASHBOARD_URL, API_PROJECT_ROBOT_DEFINITION_URL, API_PROJECT_ROBOT_URL, } from '../constants/api';
|
1
|
+
import { API_PROJECT_DEFINITION_ACTION_URL, API_PROJECT_DEFINITION_AGENT_URL, API_PROJECT_DEFINITION_BLOB_URL, API_PROJECT_DEFINITION_BUTTON_URL, API_PROJECT_DEFINITION_COMMAND2_URL, API_PROJECT_DEFINITION_COMMAND_URL, API_PROJECT_DEFINITION_COPY_URL, API_PROJECT_DEFINITION_DASHBOARD_URL, API_PROJECT_DEFINITION_EXPORT, API_PROJECT_DEFINITION_GAMEPAD_URL, API_PROJECT_DEFINITION_ID_URL, API_PROJECT_DEFINITION_IMPORT, API_PROJECT_DEFINITION_IMPORT_LIBRARY, API_PROJECT_DEFINITION_LIBRARY, API_PROJECT_DEFINITION_SETTING_URL, API_PROJECT_DEFINITION_STREAM_URL, API_PROJECT_DEFINITION_TRIGGER_URL, API_PROJECT_DEFINITION_URL, API_PROJECT_PROFILE_DASHBOARD_URL, API_PROJECT_ROBOT_DEFINITION_URL, API_PROJECT_ROBOT_URL, } from '../constants/api';
|
2
2
|
import { RocosError, errorCodes } from '../models/RocosError';
|
3
3
|
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
4
4
|
import { RocosLogger } from '../logger/RocosLogger';
|
@@ -377,6 +377,16 @@ export class ProfileService extends BaseServiceAbstract {
|
|
377
377
|
formData.append('file', profileData);
|
378
378
|
return this.callPost(formatServiceUrl(API_PROJECT_DEFINITION_IMPORT, { url: this.config.url, projectId }, this.config.insecure), formData, `Failed to import robot definition for ${projectId}.`);
|
379
379
|
}
|
380
|
+
async getLibraryProfiles() {
|
381
|
+
const profiles = await this.callGet(formatServiceUrl(API_PROJECT_DEFINITION_LIBRARY, { url: this.config.url }, this.config.insecure), 'Failed to get library profiles.');
|
382
|
+
return profiles.map((profile) => ({
|
383
|
+
...profile,
|
384
|
+
last_modified: new Date(profile.last_modified),
|
385
|
+
}));
|
386
|
+
}
|
387
|
+
async importFromLibrary(projectId, profileId, name, description) {
|
388
|
+
return this.callPost(formatServiceUrl(API_PROJECT_DEFINITION_IMPORT_LIBRARY, { url: this.config.url, projectId, profileId }, this.config.insecure), { name, description }, `Failed to import library profile ${profileId} into project ${projectId}.`);
|
389
|
+
}
|
380
390
|
/**
|
381
391
|
* Update gamepads for a robot definition
|
382
392
|
*
|