@dronedeploy/rocos-js-sdk 3.0.1-alpha.5 → 3.0.1-alpha.7
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/RocosSDK.d.ts +2 -1
- package/cjs/RocosSDK.js +38 -26
- package/cjs/api/streams/caller/CallerStream.js +2 -1
- package/cjs/api/streams/command/CommandStream.js +2 -1
- package/cjs/api/streams/control/ControlStream.js +2 -1
- package/cjs/api/streams/fileAccessor/FileAccessorStream.js +2 -1
- package/cjs/api/streams/search/SearchStream.js +2 -1
- package/cjs/api/streams/telemetry/TelemetryStream.js +2 -1
- package/cjs/api/streams/webRTCSignalling/WebRTCSignallingStream.js +2 -1
- package/cjs/constants/api.d.ts +1 -0
- package/cjs/constants/api.js +2 -1
- package/cjs/helpers/getSha256Hex.d.ts +1 -0
- package/cjs/helpers/getSha256Hex.js +9 -0
- package/cjs/helpers/getSha256Hex.spec.d.ts +1 -0
- package/cjs/helpers/getSha256Hex.spec.js +19 -0
- package/cjs/helpers/getSha256HexNode.d.ts +1 -0
- package/cjs/helpers/getSha256HexNode.js +13 -0
- package/cjs/helpers/getSha256HexNode.spec.d.ts +1 -0
- package/cjs/helpers/getSha256HexNode.spec.js +10 -0
- package/cjs/models/IRocosSDKConfig.d.ts +8 -4
- package/cjs/models/workflow/Workflow.d.ts +69 -11
- package/cjs/node/RocosSDKNode.d.ts +1 -2
- package/cjs/node/RocosSDKNode.js +54 -65
- package/cjs/services/AssetStorageService.js +1 -1
- package/cjs/services/BaseStreamService.js +2 -0
- package/cjs/services/WorkflowService.d.ts +11 -16
- package/cjs/services/WorkflowService.js +32 -15
- package/cjs/services/WorkflowServiceNode.d.ts +4 -0
- package/cjs/services/WorkflowServiceNode.js +12 -0
- package/esm/RocosSDK.d.ts +2 -1
- package/esm/RocosSDK.js +38 -26
- package/esm/api/streams/caller/CallerStream.js +2 -1
- package/esm/api/streams/command/CommandStream.js +2 -1
- package/esm/api/streams/control/ControlStream.js +2 -1
- package/esm/api/streams/fileAccessor/FileAccessorStream.js +2 -1
- package/esm/api/streams/search/SearchStream.js +2 -1
- package/esm/api/streams/telemetry/TelemetryStream.js +2 -1
- package/esm/api/streams/webRTCSignalling/WebRTCSignallingStream.js +2 -1
- package/esm/constants/api.d.ts +1 -0
- package/esm/constants/api.js +1 -0
- package/esm/helpers/getSha256Hex.d.ts +1 -0
- package/esm/helpers/getSha256Hex.js +5 -0
- package/esm/helpers/getSha256Hex.spec.d.ts +1 -0
- package/esm/helpers/getSha256Hex.spec.js +14 -0
- package/esm/helpers/getSha256HexNode.d.ts +1 -0
- package/esm/helpers/getSha256HexNode.js +6 -0
- package/esm/helpers/getSha256HexNode.spec.d.ts +1 -0
- package/esm/helpers/getSha256HexNode.spec.js +8 -0
- package/esm/models/IRocosSDKConfig.d.ts +8 -4
- package/esm/models/workflow/Workflow.d.ts +69 -11
- package/esm/node/RocosSDKNode.d.ts +1 -2
- package/esm/node/RocosSDKNode.js +26 -37
- package/esm/services/AssetStorageService.js +3 -3
- package/esm/services/BaseStreamService.js +2 -0
- package/esm/services/WorkflowService.d.ts +11 -16
- package/esm/services/WorkflowService.js +33 -16
- package/esm/services/WorkflowServiceNode.d.ts +4 -0
- package/esm/services/WorkflowServiceNode.js +8 -0
- package/package.json +1 -1
package/cjs/node/RocosSDKNode.js
CHANGED
@@ -2,98 +2,87 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.RocosSDKNode = void 0;
|
4
4
|
const services_1 = require("../services");
|
5
|
-
const
|
6
|
-
const AuthService_1 = require("../services/AuthService");
|
5
|
+
const models_1 = require("../models");
|
7
6
|
const CallerServiceNode_1 = require("../services/CallerServiceNode");
|
8
7
|
const CommandServiceNode_1 = require("../services/CommandServiceNode");
|
9
|
-
const ConfigGroupService_1 = require("../services/ConfigGroupService");
|
10
8
|
const ControlServiceNode_1 = require("../services/ControlServiceNode");
|
11
|
-
const DashboardService_1 = require("../services/DashboardService");
|
12
|
-
const EventService_1 = require("../services/EventService");
|
13
9
|
const FileAccessorServiceNode_1 = require("../services/FileAccessorServiceNode");
|
14
|
-
const FunctionService_1 = require("../services/FunctionService");
|
15
|
-
const IntegrationService_1 = require("../services/IntegrationService");
|
16
|
-
const ProfileService_1 = require("../services/ProfileService");
|
17
|
-
const ProjectService_1 = require("../services/ProjectService");
|
18
|
-
const RobotService_1 = require("../services/RobotService");
|
19
10
|
const RocosSDK_1 = require("../RocosSDK");
|
20
11
|
const SearchServiceNode_1 = require("../services/SearchServiceNode");
|
21
|
-
const ServiceEnum_1 = require("../models/ServiceEnum");
|
22
|
-
const StreamService_1 = require("../services/StreamService");
|
23
12
|
const TelemetryServiceNode_1 = require("../services/TelemetryServiceNode");
|
24
|
-
const
|
25
|
-
const WorkflowService_1 = require("../services/WorkflowService");
|
13
|
+
const WorkflowServiceNode_1 = require("../services/WorkflowServiceNode");
|
26
14
|
class RocosSDKNode extends RocosSDK_1.RocosSDK {
|
27
15
|
// eslint-disable-next-line max-lines-per-function
|
28
16
|
getService(name) {
|
29
17
|
if (!this.services?.[name]) {
|
30
18
|
this.logger.info(`Service ${name} does not exist, creating it now.`);
|
19
|
+
const config = this.overrideConfig(name);
|
31
20
|
switch (name) {
|
32
|
-
case
|
33
|
-
this.services[name] = new
|
21
|
+
case models_1.ServiceEnum.AUTH:
|
22
|
+
this.services[name] = new services_1.AuthService(config);
|
34
23
|
break;
|
35
|
-
case
|
36
|
-
this.services[name] = new TelemetryServiceNode_1.TelemetryServiceNode(
|
24
|
+
case models_1.ServiceEnum.TELEMETRY:
|
25
|
+
this.services[name] = new TelemetryServiceNode_1.TelemetryServiceNode(config);
|
37
26
|
break;
|
38
|
-
case
|
39
|
-
this.services[name] = new
|
27
|
+
case models_1.ServiceEnum.ROBOT:
|
28
|
+
this.services[name] = new services_1.RobotService(config);
|
40
29
|
break;
|
41
|
-
case
|
42
|
-
this.services[name] = new
|
30
|
+
case models_1.ServiceEnum.EVENT:
|
31
|
+
this.services[name] = new services_1.EventService(config);
|
43
32
|
break;
|
44
|
-
case
|
45
|
-
this.services[name] = new
|
33
|
+
case models_1.ServiceEnum.PROJECT:
|
34
|
+
this.services[name] = new services_1.ProjectService(config);
|
46
35
|
break;
|
47
|
-
case
|
48
|
-
this.services[name] = new CallerServiceNode_1.CallerServiceNode(
|
36
|
+
case models_1.ServiceEnum.CALLER:
|
37
|
+
this.services[name] = new CallerServiceNode_1.CallerServiceNode(config);
|
49
38
|
break;
|
50
|
-
case
|
51
|
-
this.services[name] = new CommandServiceNode_1.CommandServiceNode(
|
39
|
+
case models_1.ServiceEnum.COMMAND:
|
40
|
+
this.services[name] = new CommandServiceNode_1.CommandServiceNode(config);
|
52
41
|
break;
|
53
|
-
case
|
54
|
-
this.services[name] = new ControlServiceNode_1.ControlServiceNode(
|
42
|
+
case models_1.ServiceEnum.CONTROL:
|
43
|
+
this.services[name] = new ControlServiceNode_1.ControlServiceNode(config);
|
55
44
|
break;
|
56
|
-
case
|
57
|
-
this.services[name] = new SearchServiceNode_1.SearchServiceNode(
|
45
|
+
case models_1.ServiceEnum.SEARCH:
|
46
|
+
this.services[name] = new SearchServiceNode_1.SearchServiceNode(config);
|
58
47
|
break;
|
59
|
-
case
|
60
|
-
this.services[name] = new
|
48
|
+
case models_1.ServiceEnum.CONFIG_GROUP:
|
49
|
+
this.services[name] = new services_1.ConfigGroupService(config);
|
61
50
|
break;
|
62
|
-
case
|
63
|
-
this.services[name] = new
|
51
|
+
case models_1.ServiceEnum.DASHBOARD:
|
52
|
+
this.services[name] = new services_1.DashboardService(config);
|
64
53
|
break;
|
65
|
-
case
|
66
|
-
this.services[name] = new
|
54
|
+
case models_1.ServiceEnum.FUNCTION:
|
55
|
+
this.services[name] = new services_1.FunctionService(config);
|
67
56
|
break;
|
68
|
-
case
|
69
|
-
this.services[name] = new
|
57
|
+
case models_1.ServiceEnum.STREAM:
|
58
|
+
this.services[name] = new services_1.StreamService(config);
|
70
59
|
break;
|
71
|
-
case
|
72
|
-
this.services[name] = new
|
60
|
+
case models_1.ServiceEnum.USER:
|
61
|
+
this.services[name] = new services_1.UserService(config);
|
73
62
|
break;
|
74
|
-
case
|
75
|
-
this.services[name] = new
|
63
|
+
case models_1.ServiceEnum.WORKFLOW:
|
64
|
+
this.services[name] = new WorkflowServiceNode_1.WorkflowServiceNode(config);
|
76
65
|
break;
|
77
|
-
case
|
78
|
-
this.services[name] = new
|
66
|
+
case models_1.ServiceEnum.ASSET_STORAGE:
|
67
|
+
this.services[name] = new services_1.AssetStorageService(config);
|
79
68
|
break;
|
80
|
-
case
|
81
|
-
this.services[name] = new
|
69
|
+
case models_1.ServiceEnum.PROFILE:
|
70
|
+
this.services[name] = new services_1.ProfileService(config);
|
82
71
|
break;
|
83
|
-
case
|
84
|
-
this.services[name] = new FileAccessorServiceNode_1.FileAccessorServiceNode(
|
72
|
+
case models_1.ServiceEnum.FILE_ACCESSOR:
|
73
|
+
this.services[name] = new FileAccessorServiceNode_1.FileAccessorServiceNode(config);
|
85
74
|
break;
|
86
|
-
case
|
87
|
-
this.services[name] = new services_1.SpotProvisioningServiceNode(
|
75
|
+
case models_1.ServiceEnum.SPOT_PROVISIONER:
|
76
|
+
this.services[name] = new services_1.SpotProvisioningServiceNode(config);
|
88
77
|
break;
|
89
|
-
case
|
90
|
-
this.services[name] = new services_1.ScheduleService(
|
78
|
+
case models_1.ServiceEnum.SCHEDULE:
|
79
|
+
this.services[name] = new services_1.ScheduleService(config);
|
91
80
|
break;
|
92
|
-
case
|
93
|
-
this.services[name] = new
|
81
|
+
case models_1.ServiceEnum.INTEGRATION:
|
82
|
+
this.services[name] = new services_1.IntegrationService(config);
|
94
83
|
break;
|
95
|
-
case
|
96
|
-
this.services[name] = new services_1.MapService(
|
84
|
+
case models_1.ServiceEnum.MAP:
|
85
|
+
this.services[name] = new services_1.MapService(config);
|
97
86
|
break;
|
98
87
|
}
|
99
88
|
}
|
@@ -104,44 +93,44 @@ class RocosSDKNode extends RocosSDK_1.RocosSDK {
|
|
104
93
|
* Gets the telemetry service.
|
105
94
|
*/
|
106
95
|
getTelemetryService() {
|
107
|
-
return this.getService(
|
96
|
+
return this.getService(models_1.ServiceEnum.TELEMETRY);
|
108
97
|
}
|
109
98
|
/**
|
110
99
|
* Gets the scheduler service.
|
111
100
|
*/
|
112
101
|
getSchedulerService() {
|
113
|
-
return this.getService(
|
102
|
+
return this.getService(models_1.ServiceEnum.SCHEDULE);
|
114
103
|
}
|
115
104
|
/**
|
116
105
|
* Gets the service call service.
|
117
106
|
*/
|
118
107
|
getCallerService() {
|
119
|
-
return this.getService(
|
108
|
+
return this.getService(models_1.ServiceEnum.CALLER);
|
120
109
|
}
|
121
110
|
/**
|
122
111
|
* Gets the command service.
|
123
112
|
*/
|
124
113
|
getCommandService() {
|
125
|
-
return this.getService(
|
114
|
+
return this.getService(models_1.ServiceEnum.COMMAND);
|
126
115
|
}
|
127
116
|
/**
|
128
117
|
* Gets the robot control service.
|
129
118
|
*/
|
130
119
|
getControlService() {
|
131
|
-
return this.getService(
|
120
|
+
return this.getService(models_1.ServiceEnum.CONTROL);
|
132
121
|
}
|
133
122
|
/**
|
134
123
|
* Gets the search service.
|
135
124
|
*/
|
136
125
|
getSearchService() {
|
137
|
-
return this.getService(
|
126
|
+
return this.getService(models_1.ServiceEnum.SEARCH);
|
138
127
|
}
|
139
128
|
/**
|
140
129
|
* Gets the file accessor service
|
141
130
|
* @returns FileAccessorServiceNode
|
142
131
|
*/
|
143
132
|
getFileAccessorService() {
|
144
|
-
return this.getService(
|
133
|
+
return this.getService(models_1.ServiceEnum.FILE_ACCESSOR);
|
145
134
|
}
|
146
135
|
/**
|
147
136
|
* Gets the evaluator service
|
@@ -211,7 +211,7 @@ class AssetStorageService extends BaseServiceAbstract_1.BaseServiceAbstract {
|
|
211
211
|
* @param integration
|
212
212
|
*/
|
213
213
|
updateSyncIntegration(projectId, integrationId, integration) {
|
214
|
-
return this.callPut((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_ASSET_INTEGRATION_PATH_URL, { url: this.config.url, projectId, integrationId
|
214
|
+
return this.callPut((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_ASSET_INTEGRATION_PATH_URL, { url: this.config.url, projectId, integrationId }, this.config.insecure), integration, `Failed to update asset sync integrations for ${projectId}.`);
|
215
215
|
}
|
216
216
|
/**
|
217
217
|
* Delete a Sync Integration
|
@@ -17,6 +17,8 @@ class BaseStreamService {
|
|
17
17
|
return this.status;
|
18
18
|
}
|
19
19
|
async initStream(stream) {
|
20
|
+
if (this.config.insecure)
|
21
|
+
return; // no need to init auth for insecure connections
|
20
22
|
const authService = RocosStore_1.RocosStore.getSDKInstance(this.config).getAuthService();
|
21
23
|
if (!this.config.token || !authService.isTokenValid(new models_1.Token(this.config.token))) {
|
22
24
|
try {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { RocosError } from '../models/RocosError';
|
2
1
|
import type { Workflow, WorkflowBase } from '../models/workflow/Workflow';
|
2
|
+
import { RocosError } from '../models/RocosError';
|
3
3
|
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
4
4
|
import { IBaseService } from '../models/IBaseService';
|
5
5
|
import { IRocosSDKConfig } from '../models/IRocosSDKConfig';
|
@@ -13,11 +13,6 @@ export declare class WorkflowService extends BaseServiceAbstract implements IBas
|
|
13
13
|
* @param projectId - Project Id
|
14
14
|
*/
|
15
15
|
list(projectId: string): Promise<Workflow[]>;
|
16
|
-
/**
|
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
16
|
/**
|
22
17
|
* Create a workflow
|
23
18
|
*
|
@@ -32,11 +27,6 @@ export declare class WorkflowService extends BaseServiceAbstract implements IBas
|
|
32
27
|
* @param workflowId - Workflow Id
|
33
28
|
*/
|
34
29
|
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>;
|
40
30
|
/**
|
41
31
|
* Update a workflow
|
42
32
|
*
|
@@ -45,6 +35,16 @@ export declare class WorkflowService extends BaseServiceAbstract implements IBas
|
|
45
35
|
* @param model - Workflow
|
46
36
|
*/
|
47
37
|
update(projectId: string, workflowId: string, model: Workflow): Promise<Workflow>;
|
38
|
+
/**
|
39
|
+
* Upload workflow asset
|
40
|
+
*
|
41
|
+
* @param projectId - Project Id
|
42
|
+
* @param workflowId - Workflow Id
|
43
|
+
* @param fileName - Name of file including extension
|
44
|
+
* @param arrayBuffer - data to upload
|
45
|
+
*/
|
46
|
+
uploadAsset(projectId: string, workflowId: string, fileName: string, arrayBuffer: ArrayBuffer): Promise<void>;
|
47
|
+
protected uploadAssetWithHash(projectId: string, workflowId: string, fileName: string, arrayBuffer: ArrayBuffer, hash: string): Promise<void>;
|
48
48
|
/**
|
49
49
|
* Delete a workflow
|
50
50
|
*
|
@@ -59,9 +59,4 @@ export declare class WorkflowService extends BaseServiceAbstract implements IBas
|
|
59
59
|
* @param callsign - Robot callsign
|
60
60
|
*/
|
61
61
|
getDeployedWorkflows(projectId: string, callsign: string): Promise<Workflow[]>;
|
62
|
-
/**
|
63
|
-
* @deprecated This method is deprecated and will be removed in a future version.
|
64
|
-
* Use getDeployedWorkflow instead.
|
65
|
-
*/
|
66
|
-
getDeployedOnRobot: (projectId: string, callsign: string) => Promise<Workflow[]>;
|
67
62
|
}
|
@@ -6,24 +6,10 @@ const RocosError_1 = require("../models/RocosError");
|
|
6
6
|
const BaseServiceAbstract_1 = require("./BaseServiceAbstract");
|
7
7
|
const RocosLogger_1 = require("../logger/RocosLogger");
|
8
8
|
const formatServiceUrl_1 = require("../helpers/formatServiceUrl");
|
9
|
+
const getSha256Hex_1 = require("../helpers/getSha256Hex");
|
9
10
|
class WorkflowService extends BaseServiceAbstract_1.BaseServiceAbstract {
|
10
11
|
constructor(config) {
|
11
12
|
super(config);
|
12
|
-
/**
|
13
|
-
* @deprecated This method is deprecated and will be removed in a future version.
|
14
|
-
* Use list instead.
|
15
|
-
*/
|
16
|
-
this.getAll = this.list;
|
17
|
-
/**
|
18
|
-
* @deprecated This method is deprecated and will be removed in a future version.
|
19
|
-
* Use get instead.
|
20
|
-
*/
|
21
|
-
this.getOne = this.get;
|
22
|
-
/**
|
23
|
-
* @deprecated This method is deprecated and will be removed in a future version.
|
24
|
-
* Use getDeployedWorkflow instead.
|
25
|
-
*/
|
26
|
-
this.getDeployedOnRobot = this.getDeployedWorkflows;
|
27
13
|
this.logger = RocosLogger_1.RocosLogger.getInstance(`WorkflowService(${this.config.url})`);
|
28
14
|
}
|
29
15
|
getError(e) {
|
@@ -68,6 +54,37 @@ class WorkflowService extends BaseServiceAbstract_1.BaseServiceAbstract {
|
|
68
54
|
async update(projectId, workflowId, model) {
|
69
55
|
return this.callPut((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_WORKFLOW_ID_URL, { url: this.config.url, projectId, workflowId }, this.config.insecure), model, `Failed to update workflow for ${projectId}, workflowId ${workflowId}.`);
|
70
56
|
}
|
57
|
+
/**
|
58
|
+
* Upload workflow asset
|
59
|
+
*
|
60
|
+
* @param projectId - Project Id
|
61
|
+
* @param workflowId - Workflow Id
|
62
|
+
* @param fileName - Name of file including extension
|
63
|
+
* @param arrayBuffer - data to upload
|
64
|
+
*/
|
65
|
+
async uploadAsset(projectId, workflowId, fileName, arrayBuffer) {
|
66
|
+
const hash = await (0, getSha256Hex_1.getSha256Hex)(arrayBuffer);
|
67
|
+
return this.uploadAssetWithHash(projectId, workflowId, fileName, arrayBuffer, hash);
|
68
|
+
}
|
69
|
+
async uploadAssetWithHash(projectId, workflowId, fileName, arrayBuffer, hash) {
|
70
|
+
// Get asset upload link
|
71
|
+
const createAssetResponse = await this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_WORKFLOW_ASSET_URL, { url: this.config.url, projectId, workflowId }, this.config.insecure), { name: fileName, type: 'file', hash }, `Failed to create asset for ${projectId}, workflowId ${workflowId}.`);
|
72
|
+
const { postContentLink } = createAssetResponse;
|
73
|
+
if (!postContentLink)
|
74
|
+
throw new Error('postContentLink is undefined');
|
75
|
+
// Get Google upload location
|
76
|
+
const postFileResponse = await fetch(postContentLink, {
|
77
|
+
method: 'POST',
|
78
|
+
headers: { 'x-goog-resumable': 'start' },
|
79
|
+
});
|
80
|
+
const putLocation = postFileResponse.headers.get('location');
|
81
|
+
if (!putLocation)
|
82
|
+
throw new Error('putLocation is undefined');
|
83
|
+
// Upload file to Google
|
84
|
+
const uploadResponse = await fetch(putLocation, { method: 'PUT', body: arrayBuffer });
|
85
|
+
if (uploadResponse.status !== 200)
|
86
|
+
throw new Error(`Failed to upload file: ${uploadResponse.statusText}`);
|
87
|
+
}
|
71
88
|
/**
|
72
89
|
* Delete a workflow
|
73
90
|
*
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.WorkflowServiceNode = void 0;
|
4
|
+
const WorkflowService_1 = require("./WorkflowService");
|
5
|
+
const getSha256HexNode_1 = require("../helpers/getSha256HexNode");
|
6
|
+
class WorkflowServiceNode extends WorkflowService_1.WorkflowService {
|
7
|
+
async uploadAsset(projectId, workflowId, fileName, arrayBuffer) {
|
8
|
+
const hash = await (0, getSha256HexNode_1.getSha256HexNode)(arrayBuffer);
|
9
|
+
return this.uploadAssetWithHash(projectId, workflowId, fileName, arrayBuffer, hash);
|
10
|
+
}
|
11
|
+
}
|
12
|
+
exports.WorkflowServiceNode = WorkflowServiceNode;
|
package/esm/RocosSDK.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, EvaluatorService, EventService, FileAccessorService, FunctionService, IntegrationService, MapService, ProfileService, ProjectService, RTPWebRTCService, RobotService, ScheduleService, SearchService, SpotProvisioningService, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
|
2
|
-
import { IBaseService, IDebugLevel, IRocosSDKConfig, ServiceEnum } from './models';
|
2
|
+
import { AuthorisedConfig, IBaseService, IDebugLevel, IRocosSDKConfig, ServiceEnum } from './models';
|
3
3
|
import { IRocosSDK } from './IRocosSDK';
|
4
4
|
import { Logger } from 'loglevel';
|
5
5
|
export declare class RocosSDK implements IRocosSDK {
|
@@ -145,4 +145,5 @@ export declare class RocosSDK implements IRocosSDK {
|
|
145
145
|
*/
|
146
146
|
enableDebugMode(on: boolean): void;
|
147
147
|
setDebugLevel(level: IDebugLevel): void;
|
148
|
+
protected overrideConfig(service: ServiceEnum): AuthorisedConfig;
|
148
149
|
}
|
package/esm/RocosSDK.js
CHANGED
@@ -24,84 +24,85 @@ export class RocosSDK {
|
|
24
24
|
getService(name) {
|
25
25
|
if (!this.services?.[name]) {
|
26
26
|
this.logger.info(`Service ${name} does not exist, creating it now.`);
|
27
|
+
const config = this.overrideConfig(name);
|
27
28
|
switch (name) {
|
28
29
|
case ServiceEnum.AUTH:
|
29
|
-
this.services[name] = new AuthService(
|
30
|
+
this.services[name] = new AuthService(config);
|
30
31
|
break;
|
31
32
|
case ServiceEnum.TELEMETRY:
|
32
|
-
this.services[name] = new TelemetryService(
|
33
|
+
this.services[name] = new TelemetryService(config);
|
33
34
|
break;
|
34
35
|
case ServiceEnum.ROBOT:
|
35
|
-
this.services[name] = new RobotService(
|
36
|
+
this.services[name] = new RobotService(config);
|
36
37
|
break;
|
37
38
|
case ServiceEnum.EVENT:
|
38
|
-
this.services[name] = new EventService(
|
39
|
+
this.services[name] = new EventService(config);
|
39
40
|
break;
|
40
41
|
case ServiceEnum.PROJECT:
|
41
|
-
this.services[name] = new ProjectService(
|
42
|
+
this.services[name] = new ProjectService(config);
|
42
43
|
break;
|
43
44
|
case ServiceEnum.CALLER:
|
44
|
-
this.services[name] = new CallerService(
|
45
|
+
this.services[name] = new CallerService(config);
|
45
46
|
break;
|
46
47
|
case ServiceEnum.COMMAND:
|
47
|
-
this.services[name] = new CommandService(
|
48
|
+
this.services[name] = new CommandService(config);
|
48
49
|
break;
|
49
50
|
case ServiceEnum.CONTROL:
|
50
|
-
this.services[name] = new ControlService(
|
51
|
+
this.services[name] = new ControlService(config);
|
51
52
|
break;
|
52
53
|
case ServiceEnum.SEARCH:
|
53
|
-
this.services[name] = new SearchService(
|
54
|
+
this.services[name] = new SearchService(config);
|
54
55
|
break;
|
55
56
|
case ServiceEnum.CONFIG_GROUP:
|
56
|
-
this.services[name] = new ConfigGroupService(
|
57
|
+
this.services[name] = new ConfigGroupService(config);
|
57
58
|
break;
|
58
59
|
case ServiceEnum.DASHBOARD:
|
59
|
-
this.services[name] = new DashboardService(
|
60
|
+
this.services[name] = new DashboardService(config);
|
60
61
|
break;
|
61
62
|
case ServiceEnum.FUNCTION:
|
62
|
-
this.services[name] = new FunctionService(
|
63
|
+
this.services[name] = new FunctionService(config);
|
63
64
|
break;
|
64
65
|
case ServiceEnum.STREAM:
|
65
|
-
this.services[name] = new StreamService(
|
66
|
+
this.services[name] = new StreamService(config);
|
66
67
|
break;
|
67
68
|
case ServiceEnum.USER:
|
68
|
-
this.services[name] = new UserService(
|
69
|
+
this.services[name] = new UserService(config);
|
69
70
|
break;
|
70
71
|
case ServiceEnum.TIME_SYNCER:
|
71
|
-
this.services[name] = new TimeSyncerService(
|
72
|
+
this.services[name] = new TimeSyncerService(config);
|
72
73
|
break;
|
73
74
|
case ServiceEnum.WORKFLOW:
|
74
|
-
this.services[name] = new WorkflowService(
|
75
|
+
this.services[name] = new WorkflowService(config);
|
75
76
|
break;
|
76
77
|
case ServiceEnum.ASSET_STORAGE:
|
77
|
-
this.services[name] = new AssetStorageService(
|
78
|
+
this.services[name] = new AssetStorageService(config);
|
78
79
|
break;
|
79
80
|
case ServiceEnum.PROFILE:
|
80
|
-
this.services[name] = new ProfileService(
|
81
|
+
this.services[name] = new ProfileService(config);
|
81
82
|
break;
|
82
83
|
case ServiceEnum.RTP_WEBRTC:
|
83
|
-
this.services[name] = new RTPWebRTCService(
|
84
|
+
this.services[name] = new RTPWebRTCService(config);
|
84
85
|
break;
|
85
86
|
case ServiceEnum.WEBRTC_SIGNALLING:
|
86
|
-
this.services[name] = new WebRTCSignallingService(
|
87
|
+
this.services[name] = new WebRTCSignallingService(config);
|
87
88
|
break;
|
88
89
|
case ServiceEnum.FILE_ACCESSOR:
|
89
|
-
this.services[name] = new FileAccessorService(
|
90
|
+
this.services[name] = new FileAccessorService(config);
|
90
91
|
break;
|
91
92
|
case ServiceEnum.SCHEDULE:
|
92
|
-
this.services[name] = new ScheduleService(
|
93
|
+
this.services[name] = new ScheduleService(config);
|
93
94
|
break;
|
94
95
|
case ServiceEnum.SPOT_PROVISIONER:
|
95
|
-
this.services[name] = new SpotProvisioningService(
|
96
|
+
this.services[name] = new SpotProvisioningService(config);
|
96
97
|
break;
|
97
98
|
case ServiceEnum.INTEGRATION:
|
98
|
-
this.services[name] = new IntegrationService(
|
99
|
+
this.services[name] = new IntegrationService(config);
|
99
100
|
break;
|
100
101
|
case ServiceEnum.MAP:
|
101
|
-
this.services[name] = new MapService(
|
102
|
+
this.services[name] = new MapService(config);
|
102
103
|
break;
|
103
104
|
case ServiceEnum.EVALUATOR:
|
104
|
-
this.services[name] = new EvaluatorService(
|
105
|
+
this.services[name] = new EvaluatorService(config);
|
105
106
|
break;
|
106
107
|
}
|
107
108
|
}
|
@@ -309,4 +310,15 @@ export class RocosSDK {
|
|
309
310
|
setDebugLevel(level) {
|
310
311
|
RocosLogger.setLevel(level);
|
311
312
|
}
|
313
|
+
overrideConfig(service) {
|
314
|
+
const override = this.config.overrides?.[service];
|
315
|
+
if (!override)
|
316
|
+
return this.config;
|
317
|
+
// strip out the overrides from the config
|
318
|
+
const { overrides: _, ...config } = this.config;
|
319
|
+
return {
|
320
|
+
...config,
|
321
|
+
...this.config.overrides?.[service],
|
322
|
+
};
|
323
|
+
}
|
312
324
|
}
|
@@ -10,8 +10,9 @@ export class CallerStream extends CallerStreamAbstract {
|
|
10
10
|
super(config);
|
11
11
|
this.logger = RocosLogger.getInstance(`CallerStream(${this.identifier})`);
|
12
12
|
const protocol = config.insecure ? 'http' : 'https';
|
13
|
+
const port = config.port ? `:${config.port}` : '';
|
13
14
|
const transport = new GrpcWebFetchTransport({
|
14
|
-
baseUrl: `${protocol}://${this.url}`,
|
15
|
+
baseUrl: `${protocol}://${this.url}${port}`,
|
15
16
|
});
|
16
17
|
this.client = new WebServiceCallerClient(transport);
|
17
18
|
}
|
@@ -9,8 +9,9 @@ export class CommandStream extends CommandStreamAbstract {
|
|
9
9
|
super(config);
|
10
10
|
this.logger = RocosLogger.getInstance(`CommandStream(${this.identifier})`);
|
11
11
|
const protocol = config.insecure ? 'http' : 'https';
|
12
|
+
const port = config.port ? `:${config.port}` : '';
|
12
13
|
const transport = new GrpcWebFetchTransport({
|
13
|
-
baseUrl: `${protocol}://${this.url}`,
|
14
|
+
baseUrl: `${protocol}://${this.url}${port}`,
|
14
15
|
});
|
15
16
|
this.client = new CommandClient(transport);
|
16
17
|
}
|
@@ -10,8 +10,9 @@ export class ControlStream extends ControlStreamAbstract {
|
|
10
10
|
super(config);
|
11
11
|
this.logger = RocosLogger.getInstance(`ControlStream(${this.identifier})`);
|
12
12
|
const protocol = config.insecure ? 'http' : 'https';
|
13
|
+
const port = config.port ? `:${config.port}` : '';
|
13
14
|
const transport = new GrpcWebFetchTransport({
|
14
|
-
baseUrl: `${protocol}://${this.url}`,
|
15
|
+
baseUrl: `${protocol}://${this.url}${port}`,
|
15
16
|
});
|
16
17
|
this.client = new RobotControlClient(transport);
|
17
18
|
}
|
@@ -9,8 +9,9 @@ export class FileAccessorStream extends FileAccessorStreamAbstract {
|
|
9
9
|
super(config);
|
10
10
|
this.logger = RocosLogger.getInstance(`FileAccessorStream(${this.identifier})`);
|
11
11
|
const protocol = config.insecure ? 'http' : 'https';
|
12
|
+
const port = config.port ? `:${config.port}` : '';
|
12
13
|
const transport = new GrpcWebFetchTransport({
|
13
|
-
baseUrl: `${protocol}://${this.url}`,
|
14
|
+
baseUrl: `${protocol}://${this.url}${port}`,
|
14
15
|
});
|
15
16
|
this.client = new FilagreeClient(transport);
|
16
17
|
}
|
@@ -10,8 +10,9 @@ export class SearchStream extends SearchStreamAbstract {
|
|
10
10
|
super(config);
|
11
11
|
this.logger = RocosLogger.getInstance(`SearchStream(${this.identifier})`);
|
12
12
|
const protocol = config.insecure ? 'http' : 'https';
|
13
|
+
const port = config.port ? `:${config.port}` : '';
|
13
14
|
const transport = new GrpcWebFetchTransport({
|
14
|
-
baseUrl: `${protocol}://${this.url}`,
|
15
|
+
baseUrl: `${protocol}://${this.url}${port}`,
|
15
16
|
});
|
16
17
|
this.client = new streamClient(transport);
|
17
18
|
}
|
@@ -9,8 +9,9 @@ export class TelemetryStream extends TelemetryStreamAbstract {
|
|
9
9
|
super(config);
|
10
10
|
this.logger = RocosLogger.getInstance(`TelemetryStreamWeb(${this.identifier})`);
|
11
11
|
const protocol = config.insecure ? 'http' : 'https';
|
12
|
+
const port = config.port ? `:${config.port}` : '';
|
12
13
|
const transport = new GrpcWebFetchTransport({
|
13
|
-
baseUrl: `${protocol}://${this.url}`,
|
14
|
+
baseUrl: `${protocol}://${this.url}${port}`,
|
14
15
|
});
|
15
16
|
this.client = new TelemetryGatewayClient(transport);
|
16
17
|
}
|
@@ -10,8 +10,9 @@ export class WebRTCSignallingStream extends WebRTCSignallingStreamAbstract {
|
|
10
10
|
super(config);
|
11
11
|
this.logger = RocosLogger.getInstance(`WebRTCSignallingStream(${this.identifier})`);
|
12
12
|
const protocol = config.insecure ? 'http' : 'https';
|
13
|
+
const port = config.port ? `:${config.port}` : '';
|
13
14
|
const transport = new GrpcWebFetchTransport({
|
14
|
-
baseUrl: `${protocol}://${this.url}`,
|
15
|
+
baseUrl: `${protocol}://${this.url}${port}`,
|
15
16
|
});
|
16
17
|
this.webRTCOperatorclient = new operatorClient(transport);
|
17
18
|
}
|
package/esm/constants/api.d.ts
CHANGED
@@ -130,4 +130,5 @@ export declare const API_OBSERVATIONS_URL = "https://{url}/projects/{projectId}/
|
|
130
130
|
export declare const API_OBSERVATION_KEYS_URL = "https://{url}/projects/{projectId}/observations/keys";
|
131
131
|
export declare const API_PROJECT_WORKFLOW_URL = "https://{url}/projects/{projectId}/automate/flows";
|
132
132
|
export declare const API_PROJECT_WORKFLOW_ID_URL = "https://{url}/projects/{projectId}/automate/flows/{workflowId}";
|
133
|
+
export declare const API_PROJECT_WORKFLOW_ASSET_URL = "https://{url}/projects/{projectId}/automate/flows/{workflowId}/assets";
|
133
134
|
export declare const API_PROJECT_DEPLOYED_WORKFLOW_URL = "https://{url}/projects/{projectId}/robots/{callsign}/automate/flows/deployments";
|
package/esm/constants/api.js
CHANGED
@@ -130,4 +130,5 @@ export const API_OBSERVATIONS_URL = 'https://{url}/projects/{projectId}/observat
|
|
130
130
|
export const API_OBSERVATION_KEYS_URL = 'https://{url}/projects/{projectId}/observations/keys';
|
131
131
|
export const API_PROJECT_WORKFLOW_URL = 'https://{url}/projects/{projectId}/automate/flows';
|
132
132
|
export const API_PROJECT_WORKFLOW_ID_URL = 'https://{url}/projects/{projectId}/automate/flows/{workflowId}';
|
133
|
+
export const API_PROJECT_WORKFLOW_ASSET_URL = 'https://{url}/projects/{projectId}/automate/flows/{workflowId}/assets';
|
133
134
|
export const API_PROJECT_DEPLOYED_WORKFLOW_URL = 'https://{url}/projects/{projectId}/robots/{callsign}/automate/flows/deployments';
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getSha256Hex: (arrayBuffer: ArrayBuffer) => Promise<string>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import crypto from 'crypto';
|
2
|
+
import { getSha256Hex } from './getSha256Hex';
|
3
|
+
Object.defineProperty(globalThis, 'crypto', {
|
4
|
+
value: {
|
5
|
+
subtle: crypto.webcrypto.subtle,
|
6
|
+
},
|
7
|
+
});
|
8
|
+
describe('getSha256Hex', () => {
|
9
|
+
it('should return the correct SHA-256 hash', async () => {
|
10
|
+
const buffer = new TextEncoder().encode('Hello, World!');
|
11
|
+
const hash = await getSha256Hex(buffer);
|
12
|
+
expect(hash).toBe('dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f');
|
13
|
+
});
|
14
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getSha256HexNode: (arrayBuffer: ArrayBuffer) => Promise<string>;
|