@dronedeploy/rocos-js-sdk 1.0.0-alpha-2 → 3.0.0-alpha.19
Sign up to get free protection for your applications and to get access to all the features.
- package/IRocosSDK.d.ts +3 -26
- package/RocosSDK.d.ts +6 -1
- package/RocosSDK.js +11 -1
- package/api/streams/caller/CallerStreamAbstract.js +1 -1
- package/api/streams/command/CommandStreamAbstract.js +1 -1
- package/api/streams/search/SearchStreamAbstract.js +2 -2
- package/constants/api.d.ts +9 -5
- package/constants/api.js +9 -5
- package/grpc/conker_pb.grpc-client.js +1 -1
- package/grpc/conker_pb.js +1 -1
- package/grpc/filagree_pb.d.ts +5 -5
- package/grpc/filagree_pb.grpc-client.js +1 -1
- package/grpc/filagree_pb.js +6 -6
- package/grpc/google/protobuf/descriptor_pb.d.ts +2 -2
- package/grpc/google/protobuf/descriptor_pb.js +4 -4
- package/grpc/google/protobuf/empty_pb.js +1 -1
- package/grpc/pigeon_pb.grpc-client.js +1 -1
- package/grpc/pigeon_pb.js +1 -1
- package/grpc/rambo.uri.v1_pb.js +1 -1
- package/grpc/rambo.v1_pb.d.ts +1 -1
- package/grpc/rambo.v1_pb.grpc-client.js +1 -1
- package/grpc/rambo.v1_pb.js +2 -2
- package/grpc/serviette.uri.v1_pb.js +1 -1
- package/grpc/serviette.v1_pb.d.ts +2 -2
- package/grpc/serviette.v1_pb.grpc-client.js +1 -1
- package/grpc/serviette.v1_pb.js +3 -3
- package/grpc/slowlane_pb.d.ts +4 -4
- package/grpc/slowlane_pb.grpc-client.js +1 -1
- package/grpc/slowlane_pb.js +5 -5
- package/grpc/teletubby_pb.d.ts +2 -2
- package/grpc/teletubby_pb.grpc-client.js +1 -1
- package/grpc/teletubby_pb.js +8 -8
- package/helpers/getURLSearchParams.d.ts +2 -0
- package/helpers/getURLSearchParams.js +9 -0
- package/helpers/getURLSearchParams.spec.d.ts +1 -0
- package/helpers/getURLSearchParams.spec.js +19 -0
- package/helpers/index.d.ts +2 -0
- package/helpers/index.js +2 -0
- package/helpers/nanosecondToMillisecond.d.ts +1 -1
- package/helpers/nanosecondToMillisecond.js +10 -4
- package/helpers/nanosecondToMillisecond.spec.d.ts +1 -0
- package/helpers/nanosecondToMillisecond.spec.js +20 -0
- package/helpers/websandbox/connection.d.ts +67 -0
- package/helpers/websandbox/connection.js +133 -0
- package/helpers/websandbox/frame/frame.d.ts +12 -0
- package/helpers/websandbox/frame/frame.js +22 -0
- package/helpers/websandbox/frame/frame.source.d.ts +2 -0
- package/helpers/websandbox/frame/frame.source.js +5 -0
- package/helpers/websandbox/frame/index.d.ts +2 -0
- package/helpers/websandbox/frame/index.js +2 -0
- package/helpers/websandbox/frame/worker/index.d.ts +2 -0
- package/helpers/websandbox/frame/worker/index.js +2 -0
- package/helpers/websandbox/frame/worker/manager.d.ts +11 -0
- package/helpers/websandbox/frame/worker/manager.js +67 -0
- package/helpers/websandbox/frame/worker/manager.spec.d.ts +4 -0
- package/helpers/websandbox/frame/worker/manager.spec.js +127 -0
- package/helpers/websandbox/frame/worker/types.d.ts +11 -0
- package/helpers/websandbox/frame/worker/types.js +1 -0
- package/helpers/websandbox/frame/worker/worker.d.ts +1 -0
- package/helpers/websandbox/frame/worker/worker.js +74 -0
- package/helpers/websandbox/frame/worker/worker.source.d.ts +2 -0
- package/helpers/websandbox/frame/worker/worker.source.js +4 -0
- package/helpers/websandbox/index.d.ts +2 -0
- package/helpers/websandbox/index.js +2 -0
- package/helpers/websandbox/sandbox.d.ts +57 -0
- package/helpers/websandbox/sandbox.js +175 -0
- package/helpers/websandbox/types.d.ts +13 -0
- package/helpers/websandbox/types.js +1 -0
- package/models/RocosError.d.ts +1 -0
- package/models/RocosError.js +1 -0
- package/models/ServiceEnum.d.ts +2 -1
- package/models/ServiceEnum.js +1 -0
- package/models/asset-storage/AssetModelItem.d.ts +3 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +1 -0
- package/models/maps/Map.d.ts +1 -3
- package/models/maps/Panorama.d.ts +36 -0
- package/models/maps/Panorama.js +1 -0
- package/models/workflow/Workflow.d.ts +36 -0
- package/models/workflow/Workflow.js +1 -0
- package/node/RocosSDKNode.d.ts +6 -1
- package/node/RocosSDKNode.js +7 -0
- package/package.json +5 -3
- package/services/AssetStorageService.d.ts +18 -3
- package/services/AssetStorageService.js +28 -4
- package/services/BaseServiceAbstract.d.ts +1 -1
- package/services/BaseServiceAbstract.js +2 -6
- package/services/BaseStreamService.js +1 -1
- package/services/EvaluatorService.d.ts +11 -0
- package/services/EvaluatorService.js +28 -0
- package/services/MapService.d.ts +36 -3
- package/services/MapService.js +47 -4
- package/services/TelemetryService.d.ts +1 -0
- package/services/TelemetryService.js +13 -1
- package/services/TelemetryService.spec.js +2 -2
- package/services/WorkflowService.d.ts +25 -29
- package/services/WorkflowService.js +30 -62
- package/services/index.d.ts +1 -0
- package/services/index.js +1 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
import { IBaseService, IRocosSDKConfig, RocosError } from '../models';
|
2
|
+
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
3
|
+
import { RunCodeOptions } from '../helpers/websandbox/sandbox';
|
4
|
+
export declare class EvaluatorService extends BaseServiceAbstract implements IBaseService {
|
5
|
+
private readonly sandbox;
|
6
|
+
constructor(config: IRocosSDKConfig);
|
7
|
+
protected getError(e: Error): RocosError;
|
8
|
+
getStatus(): boolean;
|
9
|
+
teardown(): Promise<void>;
|
10
|
+
execute<T = unknown>(code: string | (() => T), context?: unknown, options?: RunCodeOptions): Promise<T>;
|
11
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { RocosError, errorCodes } from '../models';
|
2
|
+
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
3
|
+
import { RocosLogger } from '../logger/RocosLogger';
|
4
|
+
import { WebSandbox } from '../helpers';
|
5
|
+
export class EvaluatorService extends BaseServiceAbstract {
|
6
|
+
constructor(config) {
|
7
|
+
super(config);
|
8
|
+
this.logger = RocosLogger.getInstance(`EvaluatorService(${this.config.url})`);
|
9
|
+
this.sandbox = WebSandbox.new().catch((e) => {
|
10
|
+
this.logger.error('Failed to create WebSandbox', e);
|
11
|
+
throw e;
|
12
|
+
});
|
13
|
+
}
|
14
|
+
getError(e) {
|
15
|
+
return new RocosError(e, errorCodes.EVALUATOR_SERVICE_ERROR);
|
16
|
+
}
|
17
|
+
getStatus() {
|
18
|
+
return true;
|
19
|
+
}
|
20
|
+
async teardown() {
|
21
|
+
const sandbox = await this.sandbox;
|
22
|
+
sandbox.destroy();
|
23
|
+
}
|
24
|
+
async execute(code, context, options) {
|
25
|
+
const sandbox = await this.sandbox;
|
26
|
+
return sandbox.run(code, context, options);
|
27
|
+
}
|
28
|
+
}
|
package/services/MapService.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { IBaseService, IRocosSDKConfig, Map, RocosError } from '../models';
|
2
2
|
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
3
|
+
import { Observation } from '../models/maps/Panorama';
|
3
4
|
/**
|
4
5
|
* Integrations to retrieve data from the linked project in DroneDeploy
|
5
6
|
*/
|
@@ -52,7 +53,6 @@ export declare class MapService extends BaseServiceAbstract implements IBaseServ
|
|
52
53
|
* @param options New metadata
|
53
54
|
*/
|
54
55
|
update(projectId: string, mapId: string, options: {
|
55
|
-
name: string;
|
56
56
|
description?: string;
|
57
57
|
callsign?: string;
|
58
58
|
}): Promise<void>;
|
@@ -90,7 +90,6 @@ export declare class MapService extends BaseServiceAbstract implements IBaseServ
|
|
90
90
|
* @param options Options to create the new map
|
91
91
|
*/
|
92
92
|
copy(projectId: string, mapId: string, options: {
|
93
|
-
name: string;
|
94
93
|
description?: string;
|
95
94
|
}): Promise<void>;
|
96
95
|
/** Deploy a map from the cloud to a robot
|
@@ -104,6 +103,40 @@ export declare class MapService extends BaseServiceAbstract implements IBaseServ
|
|
104
103
|
*
|
105
104
|
* @param projectId Project ID
|
106
105
|
* @param mapId Map ID
|
106
|
+
* @param frameId Frame ID (optional)
|
107
|
+
*/
|
108
|
+
getGeoJSON(projectId: string, mapId: string, frameId?: string): Promise<unknown>;
|
109
|
+
/**
|
110
|
+
* Returns a Promise that resolves to an array of Observation objects for the given panorama ID.
|
111
|
+
*
|
112
|
+
* @param projectId The ID of the project the panorama belongs to.
|
113
|
+
* @param panoramaId The ID of the panorama to retrieve observations for.
|
114
|
+
* @returns A Promise that resolves to an array of Observation objects.
|
115
|
+
*/
|
116
|
+
listObservations(projectId: string, panoramaId: string): Promise<Observation[]>;
|
117
|
+
/**
|
118
|
+
* Creates new observations on a panorama.
|
119
|
+
*
|
120
|
+
* @param projectId The ID of the project the panorama belongs to.
|
121
|
+
* @param panoramaId The ID of the panorama to create observations for.
|
122
|
+
* @param observations An array of Observation objects to create.
|
123
|
+
* @returns A Promise that resolves when the observations have been created.
|
124
|
+
*/
|
125
|
+
createObservations(projectId: string, panoramaId: string, observations: Observation[]): Promise<void>;
|
126
|
+
/**
|
127
|
+
* Gets observations for a project.
|
128
|
+
*
|
129
|
+
* @param projectId The ID of the project the observations belongs to.
|
130
|
+
* @param key (optional) Filters on a key defined on the observation
|
131
|
+
* @param frameID (optional) Transforms on a seed frame
|
132
|
+
* @returns A list of observations
|
133
|
+
*/
|
134
|
+
getObservations(projectId: string, key?: string, frameID?: string): Promise<Observation[]>;
|
135
|
+
/**
|
136
|
+
* Lists available keys for all observations in a project.
|
137
|
+
*
|
138
|
+
* @param projectId The ID of the project the observations belongs to.
|
139
|
+
* @returns A list of observations
|
107
140
|
*/
|
108
|
-
|
141
|
+
getObservationsKeys(projectId: string): Promise<string[]>;
|
109
142
|
}
|
package/services/MapService.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { API_MAPS_COPY_URL, API_MAPS_DEPLOYED_URL, API_MAPS_DEPLOY_URL, API_MAPS_GEOJSON_URL, API_MAPS_MERGE_URL, API_MAPS_URL, API_MAP_ID_URL, } from '../constants/api';
|
1
|
+
import { API_MAPS_COPY_URL, API_MAPS_DEPLOYED_URL, API_MAPS_DEPLOY_URL, API_MAPS_GEOJSON_URL, API_MAPS_MERGE_URL, API_MAPS_PANORAMA_OBSERVATIONS_URL, API_MAPS_URL, API_MAP_ID_URL, API_OBSERVATIONS_URL, API_OBSERVATION_KEYS_URL, } from '../constants/api';
|
2
2
|
import { RocosError, errorCodes } from '../models';
|
3
3
|
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
4
4
|
import { RocosLogger } from '../logger/RocosLogger';
|
@@ -138,12 +138,55 @@ export class MapService extends BaseServiceAbstract {
|
|
138
138
|
*
|
139
139
|
* @param projectId Project ID
|
140
140
|
* @param mapId Map ID
|
141
|
+
* @param frameId Frame ID (optional)
|
141
142
|
*/
|
142
|
-
async getGeoJSON(projectId, mapId) {
|
143
|
-
|
143
|
+
async getGeoJSON(projectId, mapId, frameId) {
|
144
|
+
const params = {
|
144
145
|
url: this.config.url,
|
145
146
|
projectId,
|
146
147
|
mapId,
|
147
|
-
}
|
148
|
+
};
|
149
|
+
return this.callGet(formatServiceUrl(API_MAPS_GEOJSON_URL, params, this.config.insecure), 'Failed to get map GeoJSON.', frameId ? { frameID: frameId } : undefined);
|
150
|
+
}
|
151
|
+
/**
|
152
|
+
* Returns a Promise that resolves to an array of Observation objects for the given panorama ID.
|
153
|
+
*
|
154
|
+
* @param projectId The ID of the project the panorama belongs to.
|
155
|
+
* @param panoramaId The ID of the panorama to retrieve observations for.
|
156
|
+
* @returns A Promise that resolves to an array of Observation objects.
|
157
|
+
*/
|
158
|
+
listObservations(projectId, panoramaId) {
|
159
|
+
return this.callGet(formatServiceUrl(API_MAPS_PANORAMA_OBSERVATIONS_URL, { url: this.config.url, projectId, panoramaId }, this.config.insecure), 'Failed to list observations.');
|
160
|
+
}
|
161
|
+
/**
|
162
|
+
* Creates new observations on a panorama.
|
163
|
+
*
|
164
|
+
* @param projectId The ID of the project the panorama belongs to.
|
165
|
+
* @param panoramaId The ID of the panorama to create observations for.
|
166
|
+
* @param observations An array of Observation objects to create.
|
167
|
+
* @returns A Promise that resolves when the observations have been created.
|
168
|
+
*/
|
169
|
+
createObservations(projectId, panoramaId, observations) {
|
170
|
+
return this.callPut(formatServiceUrl(API_MAPS_PANORAMA_OBSERVATIONS_URL, { url: this.config.url, projectId, panoramaId }, this.config.insecure), observations, 'Failed to update observations.');
|
171
|
+
}
|
172
|
+
/**
|
173
|
+
* Gets observations for a project.
|
174
|
+
*
|
175
|
+
* @param projectId The ID of the project the observations belongs to.
|
176
|
+
* @param key (optional) Filters on a key defined on the observation
|
177
|
+
* @param frameID (optional) Transforms on a seed frame
|
178
|
+
* @returns A list of observations
|
179
|
+
*/
|
180
|
+
getObservations(projectId, key = '', frameID = '') {
|
181
|
+
return this.callGet(formatServiceUrl(API_OBSERVATIONS_URL, { url: this.config.url, projectId }, this.config.insecure), 'Failed to get observations.', { key, frameID });
|
182
|
+
}
|
183
|
+
/**
|
184
|
+
* Lists available keys for all observations in a project.
|
185
|
+
*
|
186
|
+
* @param projectId The ID of the project the observations belongs to.
|
187
|
+
* @returns A list of observations
|
188
|
+
*/
|
189
|
+
getObservationsKeys(projectId) {
|
190
|
+
return this.callGet(formatServiceUrl(API_OBSERVATION_KEYS_URL, { url: this.config.url, projectId }, this.config.insecure), 'Failed to get observation keys.');
|
148
191
|
}
|
149
192
|
}
|
@@ -35,6 +35,7 @@ export declare class TelemetryService extends BaseStreamService<ITelemetryStream
|
|
35
35
|
*/
|
36
36
|
getRobotStatusChanges(projectId: string, callsign: string, heartbeatTimeoutMs?: number, intervalMs?: number): Observable<CallsignStatus>;
|
37
37
|
protected initStream(stream: ITelemetryStream): Promise<void>;
|
38
|
+
private buildScope;
|
38
39
|
private createStream;
|
39
40
|
protected getStream(config: ITelemetryStreamConfig): ITelemetryStream;
|
40
41
|
}
|
@@ -7,6 +7,7 @@ import { RocosStore } from '../store/RocosStore';
|
|
7
7
|
import { TelemetryStream } from '../api/streams/telemetry/TelemetryStream';
|
8
8
|
import { arrayUnique } from '../helpers/arrayUnique';
|
9
9
|
import { getUniqueId } from '../helpers/getUniqueId';
|
10
|
+
import { flattenCallsignsLookup } from '../helpers/flattenCallsignsLookup';
|
10
11
|
const HEARTBEAT_SOURCE = '/rocos/agent/telemetry/heartbeat';
|
11
12
|
const HEARTBEAT_TIMEOUT = 5000; // if no heartbeat within 5 seconds then the robot is considered dead
|
12
13
|
export class TelemetryService extends BaseStreamService {
|
@@ -47,7 +48,9 @@ export class TelemetryService extends BaseStreamService {
|
|
47
48
|
this.logger.info('subscribe with query', params);
|
48
49
|
callsignsLookup = new CallsignsLookup(params.query);
|
49
50
|
}
|
50
|
-
|
51
|
+
// scope is used as a key to generate unique streams
|
52
|
+
// ideally there should be just one concurrent stream opened
|
53
|
+
const scope = this.buildScope(params, callsignsLookup);
|
51
54
|
const callsigns = callsignsLookup.lookupValue;
|
52
55
|
const subscriptionParams = {
|
53
56
|
uniqueId: getUniqueId(params.projectId, callsignsLookup, sources, scope),
|
@@ -114,6 +117,15 @@ export class TelemetryService extends BaseStreamService {
|
|
114
117
|
await super.initStream(stream);
|
115
118
|
stream.init();
|
116
119
|
}
|
120
|
+
buildScope(params, callsignsLookup) {
|
121
|
+
// prefix with project id to avoid stream instance to be shared across projects
|
122
|
+
if (params.scope)
|
123
|
+
return `${params.projectId}-${params.scope}`;
|
124
|
+
this.logger.debug(`No scope is set, generating default`);
|
125
|
+
if (callsignsLookup)
|
126
|
+
return `${params.projectId}-default-${flattenCallsignsLookup(callsignsLookup).join()}`;
|
127
|
+
return `${params.projectId}-default`;
|
128
|
+
}
|
117
129
|
async createStream(projectId, callsignsLookup, sources, scope) {
|
118
130
|
const newStream = await this.createStreamFromConfig(IDENTIFIER_NAME_TELEMETRY, {
|
119
131
|
url: this.config.url,
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { TelemetryService } from './TelemetryService';
|
2
|
-
import { delay, from, lastValueFrom, NEVER, take, throwError } from 'rxjs';
|
3
1
|
import { CallsignStatus } from '../models';
|
2
|
+
import { NEVER, delay, from, lastValueFrom, take, throwError } from 'rxjs';
|
3
|
+
import { TelemetryService } from './TelemetryService';
|
4
4
|
describe('TelemetryService', () => {
|
5
5
|
describe('getRobotStatusChanges', () => {
|
6
6
|
it('should emit unknown to begin with', async () => {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { RocosError } from '../models/RocosError';
|
2
|
+
import type { Workflow, WorkflowBase } from '../models/workflow/Workflow';
|
2
3
|
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
3
4
|
import { IBaseService } from '../models/IBaseService';
|
4
5
|
import { IRocosSDKConfig } from '../models/IRocosSDKConfig';
|
@@ -7,65 +8,60 @@ export declare class WorkflowService extends BaseServiceAbstract implements IBas
|
|
7
8
|
protected getError(e: Error): RocosError;
|
8
9
|
getStatus(): boolean;
|
9
10
|
/**
|
10
|
-
*
|
11
|
+
* Get workflows for project
|
11
12
|
*
|
12
13
|
* @param projectId - Project Id
|
13
|
-
* @param model - Payload
|
14
14
|
*/
|
15
|
-
|
15
|
+
list(projectId: string): Promise<Workflow[]>;
|
16
16
|
/**
|
17
|
-
*
|
17
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
18
|
+
* Use list instead.
|
19
|
+
*/
|
20
|
+
getAll: (projectId: string) => Promise<Workflow[]>;
|
21
|
+
/**
|
22
|
+
* Create a workflow
|
18
23
|
*
|
19
24
|
* @param projectId - Project Id
|
20
|
-
* @param
|
21
|
-
* @param includeStats - Include stats
|
22
|
-
* @param opsId - Ops Id
|
23
|
-
* @param workflowIds - Workflow Id's
|
25
|
+
* @param model - Workflow
|
24
26
|
*/
|
25
|
-
|
27
|
+
create(projectId: string, model: WorkflowBase): Promise<Workflow>;
|
26
28
|
/**
|
27
29
|
* Get a workflow
|
28
30
|
*
|
29
31
|
* @param projectId - Project Id
|
30
32
|
* @param workflowId - Workflow Id
|
31
|
-
* @param includeInstances - Include instances
|
32
33
|
*/
|
33
|
-
|
34
|
+
get(projectId: string, workflowId: string): Promise<Workflow>;
|
35
|
+
/**
|
36
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
37
|
+
* Use get instead.
|
38
|
+
*/
|
39
|
+
getOne: (projectId: string, workflowId: string) => Promise<Workflow>;
|
34
40
|
/**
|
35
41
|
* Update a workflow
|
36
42
|
*
|
37
43
|
* @param projectId - Project Id
|
38
44
|
* @param workflowId - Workflow Id
|
39
|
-
* @param model -
|
45
|
+
* @param model - Workflow
|
40
46
|
*/
|
41
|
-
|
47
|
+
update(projectId: string, workflowId: string, model: Workflow): Promise<Workflow>;
|
42
48
|
/**
|
43
49
|
* Delete a workflow
|
44
50
|
*
|
45
51
|
* @param projectId - Project Id
|
46
52
|
* @param workflowId - Workflow Id
|
47
53
|
*/
|
48
|
-
|
49
|
-
/**
|
50
|
-
* Get all workflows for a robot
|
51
|
-
*
|
52
|
-
* @param projectId - Project Id
|
53
|
-
* @param callsign - Robot callsign
|
54
|
-
*/
|
55
|
-
getAllOfRobot(projectId: string, callsign: string): Promise<any>;
|
54
|
+
delete(projectId: string, workflowId: string): Promise<void>;
|
56
55
|
/**
|
57
|
-
*
|
56
|
+
* Get deployed workflows on robot
|
58
57
|
*
|
59
58
|
* @param projectId - Project Id
|
60
59
|
* @param callsign - Robot callsign
|
61
|
-
* @param model - Payload
|
62
60
|
*/
|
63
|
-
|
61
|
+
getDeployedWorkflows(projectId: string, callsign: string): Promise<Workflow[]>;
|
64
62
|
/**
|
65
|
-
*
|
66
|
-
*
|
67
|
-
* @param projectId - Project Id
|
68
|
-
* @param callsign - Robot callsign
|
63
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
64
|
+
* Use getDeployedWorkflow instead.
|
69
65
|
*/
|
70
|
-
getDeployedOnRobot(projectId: string, callsign: string)
|
66
|
+
getDeployedOnRobot: (projectId: string, callsign: string) => Promise<Workflow[]>;
|
71
67
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { API_PROJECT_DEPLOYED_WORKFLOW_URL, API_PROJECT_WORKFLOW_ID_URL, API_PROJECT_WORKFLOW_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';
|
@@ -6,6 +6,21 @@ import { formatServiceUrl } from '../helpers/formatServiceUrl';
|
|
6
6
|
export class WorkflowService extends BaseServiceAbstract {
|
7
7
|
constructor(config) {
|
8
8
|
super(config);
|
9
|
+
/**
|
10
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
11
|
+
* Use list instead.
|
12
|
+
*/
|
13
|
+
this.getAll = this.list;
|
14
|
+
/**
|
15
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
16
|
+
* Use get instead.
|
17
|
+
*/
|
18
|
+
this.getOne = this.get;
|
19
|
+
/**
|
20
|
+
* @deprecated This method is deprecated and will be removed in a future version.
|
21
|
+
* Use getDeployedWorkflow instead.
|
22
|
+
*/
|
23
|
+
this.getDeployedOnRobot = this.getDeployedWorkflows;
|
9
24
|
this.logger = RocosLogger.getInstance(`WorkflowService(${this.config.url})`);
|
10
25
|
}
|
11
26
|
getError(e) {
|
@@ -15,62 +30,39 @@ export class WorkflowService extends BaseServiceAbstract {
|
|
15
30
|
return true;
|
16
31
|
}
|
17
32
|
/**
|
18
|
-
*
|
33
|
+
* Get workflows for project
|
19
34
|
*
|
20
35
|
* @param projectId - Project Id
|
21
|
-
* @param model - Payload
|
22
36
|
*/
|
23
|
-
|
24
|
-
|
25
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
26
|
-
async createOne(projectId, model) {
|
27
|
-
return this.callPut(formatServiceUrl(API_PROJECT_WORKFLOW_URL, { url: this.config.url, projectId }, this.config.insecure), model, `Failed to create workflow for ${projectId}.`);
|
37
|
+
async list(projectId) {
|
38
|
+
return this.callGet(formatServiceUrl(API_PROJECT_WORKFLOW_URL, { url: this.config.url, projectId }, this.config.insecure), `Failed to get workflows for ${projectId}.`);
|
28
39
|
}
|
29
40
|
/**
|
30
|
-
*
|
41
|
+
* Create a workflow
|
31
42
|
*
|
32
43
|
* @param projectId - Project Id
|
33
|
-
* @param
|
34
|
-
* @param includeStats - Include stats
|
35
|
-
* @param opsId - Ops Id
|
36
|
-
* @param workflowIds - Workflow Id's
|
44
|
+
* @param model - Workflow
|
37
45
|
*/
|
38
|
-
|
39
|
-
|
40
|
-
const params = {
|
41
|
-
includeRocosGraph: includeRocosGraph ? 1 : 0,
|
42
|
-
includeStats: includeStats ? 1 : 0,
|
43
|
-
};
|
44
|
-
if (opsId) {
|
45
|
-
params.opsId = opsId;
|
46
|
-
}
|
47
|
-
if (workflowIds) {
|
48
|
-
params.workflowIds = workflowIds.join(',');
|
49
|
-
}
|
50
|
-
return this.callGet(formatServiceUrl(API_PROJECT_WORKFLOW_URL, { url: this.config.url, projectId }, this.config.insecure), `Failed to get workflows for ${projectId}.`, params);
|
46
|
+
async create(projectId, model) {
|
47
|
+
return this.callPut(formatServiceUrl(API_PROJECT_WORKFLOW_URL, { url: this.config.url, projectId }, this.config.insecure), model, `Failed to create workflow for ${projectId}.`);
|
51
48
|
}
|
52
49
|
/**
|
53
50
|
* Get a workflow
|
54
51
|
*
|
55
52
|
* @param projectId - Project Id
|
56
53
|
* @param workflowId - Workflow Id
|
57
|
-
* @param includeInstances - Include instances
|
58
54
|
*/
|
59
|
-
|
60
|
-
|
61
|
-
return this.callGet(formatServiceUrl(API_PROJECT_WORKFLOW_ID_URL, { url: this.config.url, projectId, workflowId }, this.config.insecure), `Failed to get workflow for ${projectId}, workflowId ${workflowId}.`, { includeInstances: includeInstances ? 1 : 0 });
|
55
|
+
async get(projectId, workflowId) {
|
56
|
+
return this.callGet(formatServiceUrl(API_PROJECT_WORKFLOW_ID_URL, { url: this.config.url, projectId, workflowId }, this.config.insecure), `Failed to get workflow for ${projectId}, workflowId ${workflowId}.`);
|
62
57
|
}
|
63
58
|
/**
|
64
59
|
* Update a workflow
|
65
60
|
*
|
66
61
|
* @param projectId - Project Id
|
67
62
|
* @param workflowId - Workflow Id
|
68
|
-
* @param model -
|
63
|
+
* @param model - Workflow
|
69
64
|
*/
|
70
|
-
|
71
|
-
// TODO: map the response object
|
72
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
73
|
-
async updateOne(projectId, workflowId, model) {
|
65
|
+
async update(projectId, workflowId, model) {
|
74
66
|
return this.callPut(formatServiceUrl(API_PROJECT_WORKFLOW_ID_URL, { url: this.config.url, projectId, workflowId }, this.config.insecure), model, `Failed to update workflow for ${projectId}, workflowId ${workflowId}.`);
|
75
67
|
}
|
76
68
|
/**
|
@@ -79,40 +71,16 @@ export class WorkflowService extends BaseServiceAbstract {
|
|
79
71
|
* @param projectId - Project Id
|
80
72
|
* @param workflowId - Workflow Id
|
81
73
|
*/
|
82
|
-
|
83
|
-
async deleteOne(projectId, workflowId) {
|
74
|
+
async delete(projectId, workflowId) {
|
84
75
|
return this.callDelete(formatServiceUrl(API_PROJECT_WORKFLOW_ID_URL, { url: this.config.url, projectId, workflowId }, this.config.insecure), `Failed to delete workflow for ${projectId}, workflowId ${workflowId}.`);
|
85
76
|
}
|
86
|
-
/**
|
87
|
-
* Get all workflows for a robot
|
88
|
-
*
|
89
|
-
* @param projectId - Project Id
|
90
|
-
* @param callsign - Robot callsign
|
91
|
-
*/
|
92
|
-
// TODO: map the response object
|
93
|
-
async getAllOfRobot(projectId, callsign) {
|
94
|
-
return this.callGet(formatServiceUrl(API_PROJECT_CALLSIGN_WORKFLOW_URL, { url: this.config.url, projectId, callsign }, this.config.insecure), `Failed to get workflows for ${projectId}, callsign ${callsign}.`);
|
95
|
-
}
|
96
|
-
/**
|
97
|
-
* Update workflows for a robot
|
98
|
-
*
|
99
|
-
* @param projectId - Project Id
|
100
|
-
* @param callsign - Robot callsign
|
101
|
-
* @param model - Payload
|
102
|
-
*/
|
103
|
-
// TODO: map the request model
|
104
|
-
// TODO: map the response object
|
105
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
106
|
-
async updateAllForRobot(projectId, callsign, model) {
|
107
|
-
return this.callPut(formatServiceUrl(API_PROJECT_CALLSIGN_WORKFLOW_URL, { url: this.config.url, projectId, callsign }, this.config.insecure), model, `Failed to update workflows for ${projectId}, callsign ${callsign}.`);
|
108
|
-
}
|
109
77
|
/**
|
110
78
|
* Get deployed workflows on robot
|
111
79
|
*
|
112
80
|
* @param projectId - Project Id
|
113
81
|
* @param callsign - Robot callsign
|
114
82
|
*/
|
115
|
-
async
|
116
|
-
return this.callGet(formatServiceUrl(
|
83
|
+
async getDeployedWorkflows(projectId, callsign) {
|
84
|
+
return this.callGet(formatServiceUrl(API_PROJECT_DEPLOYED_WORKFLOW_URL, { url: this.config.url, projectId, callsign }, this.config.insecure), `Failed to update workflows for ${projectId}, callsign ${callsign}.`);
|
117
85
|
}
|
118
86
|
}
|
package/services/index.d.ts
CHANGED
package/services/index.js
CHANGED