@dronedeploy/rocos-js-sdk 3.0.1-alpha.14 → 3.0.1-alpha.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/cjs/IRocosSDK.d.ts +2 -2
  2. package/cjs/RocosSDK.d.ts +7 -6
  3. package/cjs/RocosSDK.js +11 -10
  4. package/cjs/constants/api.d.ts +4 -6
  5. package/cjs/constants/api.js +6 -8
  6. package/cjs/models/RocosError.d.ts +1 -0
  7. package/cjs/models/RocosError.js +1 -0
  8. package/cjs/models/ServiceEnum.d.ts +2 -1
  9. package/cjs/models/ServiceEnum.js +1 -0
  10. package/cjs/models/TelemetryStatus.d.ts +12 -0
  11. package/cjs/models/TelemetryStatus.js +17 -0
  12. package/cjs/models/Token.d.ts +2 -2
  13. package/cjs/models/Token.js +5 -5
  14. package/cjs/models/device-credentials/DeviceCredentials.d.ts +46 -0
  15. package/cjs/models/device-credentials/DeviceCredentials.js +2 -0
  16. package/cjs/models/index.d.ts +1 -1
  17. package/cjs/models/index.js +1 -1
  18. package/cjs/node/RocosSDKNode.d.ts +2 -1
  19. package/cjs/node/RocosSDKNode.js +6 -3
  20. package/cjs/services/DeviceCredentialsService.d.ts +15 -0
  21. package/cjs/services/DeviceCredentialsService.js +50 -0
  22. package/cjs/services/MapService.d.ts +1 -1
  23. package/cjs/services/MapService.js +1 -1
  24. package/cjs/services/ProfileService.d.ts +2 -1
  25. package/cjs/services/ProfileService.js +9 -3
  26. package/cjs/services/TelemetryService.d.ts +10 -1
  27. package/cjs/services/TelemetryService.js +27 -5
  28. package/cjs/services/index.d.ts +1 -1
  29. package/cjs/services/index.js +1 -1
  30. package/esm/IRocosSDK.d.ts +2 -2
  31. package/esm/RocosSDK.d.ts +7 -6
  32. package/esm/RocosSDK.js +12 -11
  33. package/esm/constants/api.d.ts +4 -6
  34. package/esm/constants/api.js +4 -6
  35. package/esm/models/RocosError.d.ts +1 -0
  36. package/esm/models/RocosError.js +1 -0
  37. package/esm/models/ServiceEnum.d.ts +2 -1
  38. package/esm/models/ServiceEnum.js +1 -0
  39. package/esm/models/TelemetryStatus.d.ts +12 -0
  40. package/esm/models/TelemetryStatus.js +14 -0
  41. package/esm/models/Token.d.ts +2 -2
  42. package/esm/models/Token.js +5 -5
  43. package/esm/models/device-credentials/DeviceCredentials.d.ts +46 -0
  44. package/esm/models/device-credentials/DeviceCredentials.js +1 -0
  45. package/esm/models/index.d.ts +1 -1
  46. package/esm/models/index.js +1 -1
  47. package/esm/node/RocosSDKNode.d.ts +2 -1
  48. package/esm/node/RocosSDKNode.js +7 -4
  49. package/esm/services/DeviceCredentialsService.d.ts +15 -0
  50. package/esm/services/DeviceCredentialsService.js +46 -0
  51. package/esm/services/MapService.d.ts +1 -1
  52. package/esm/services/MapService.js +1 -1
  53. package/esm/services/ProfileService.d.ts +2 -1
  54. package/esm/services/ProfileService.js +9 -3
  55. package/esm/services/TelemetryService.d.ts +10 -1
  56. package/esm/services/TelemetryService.js +28 -6
  57. package/esm/services/index.d.ts +1 -1
  58. package/esm/services/index.js +1 -1
  59. package/package.json +1 -2
  60. package/cjs/models/CallsignStatus.d.ts +0 -6
  61. package/cjs/models/CallsignStatus.js +0 -10
  62. package/cjs/services/FunctionService.d.ts +0 -68
  63. package/cjs/services/FunctionService.js +0 -103
  64. package/esm/models/CallsignStatus.d.ts +0 -6
  65. package/esm/models/CallsignStatus.js +0 -7
  66. package/esm/services/FunctionService.d.ts +0 -68
  67. package/esm/services/FunctionService.js +0 -99
@@ -98,23 +98,45 @@ class TelemetryService extends BaseStreamService_1.BaseStreamService {
98
98
  * @param intervalMs optionally override the interval to check for heartbeats (in ms). Default 2000ms
99
99
  */
100
100
  getRobotStatusChanges(projectId, callsign, heartbeatTimeoutMs = HEARTBEAT_TIMEOUT, intervalMs = 2000) {
101
+ return this.monitorTelemetryWithTimeout(projectId, callsign, HEARTBEAT_SOURCE, heartbeatTimeoutMs, intervalMs).pipe((0, rxjs_1.map)((status) => {
102
+ switch (status) {
103
+ case models_1.TelemetryMonitorStatus.CONNECTED:
104
+ return models_1.CallsignStatus.ONLINE;
105
+ case models_1.TelemetryMonitorStatus.DISCONNECTED:
106
+ return models_1.CallsignStatus.OFFLINE;
107
+ case models_1.TelemetryMonitorStatus.ERROR:
108
+ return models_1.CallsignStatus.ERROR;
109
+ default:
110
+ return models_1.CallsignStatus.UNKNOWN;
111
+ }
112
+ }));
113
+ }
114
+ /**
115
+ * Subscribes to the given telemetry and checks we receive one at least emission every `heartbeatTimeoutMs` (default 5s)
116
+ * @param projectId
117
+ * @param callsign
118
+ * @param source the telemetry source to monitor
119
+ * @param heartbeatTimeoutMs optionally override the deadline for telemetry emissions (in ms). Default 5000ms
120
+ * @param intervalMs optionally override the interval to check for telemetry emissions (in ms). Default 2000ms
121
+ */
122
+ monitorTelemetryWithTimeout(projectId, callsign, source, heartbeatTimeoutMs = HEARTBEAT_TIMEOUT, intervalMs = 2000) {
101
123
  const startedAt = Date.now();
102
124
  const heartbeatTime$ = this.subscribe({
103
125
  projectId,
104
- sources: [HEARTBEAT_SOURCE],
126
+ sources: [source],
105
127
  callsigns: [callsign],
106
128
  }).pipe((0, rxjs_1.map)(() => Date.now()));
107
129
  return (0, rxjs_1.combineLatest)([heartbeatTime$.pipe((0, rxjs_1.startWith)(startedAt)), (0, rxjs_1.interval)(intervalMs)]).pipe((0, rxjs_1.map)(([lastHeartbeat, _]) => {
108
130
  const now = Date.now();
109
131
  // If we haven't received a heartbeat, but we've only just started
110
132
  if (lastHeartbeat === startedAt && now - startedAt <= heartbeatTimeoutMs) {
111
- return models_1.CallsignStatus.UNKNOWN;
133
+ return models_1.TelemetryMonitorStatus.UNKNOWN;
112
134
  }
113
135
  if (now - lastHeartbeat > heartbeatTimeoutMs) {
114
- return models_1.CallsignStatus.OFFLINE;
136
+ return models_1.TelemetryMonitorStatus.DISCONNECTED;
115
137
  }
116
- return models_1.CallsignStatus.ONLINE;
117
- }), (0, rxjs_1.startWith)(models_1.CallsignStatus.UNKNOWN), (0, rxjs_1.distinctUntilChanged)(), (0, rxjs_1.catchError)(() => (0, rxjs_1.of)(models_1.CallsignStatus.ERROR)));
138
+ return models_1.TelemetryMonitorStatus.CONNECTED;
139
+ }), (0, rxjs_1.startWith)(models_1.TelemetryMonitorStatus.UNKNOWN), (0, rxjs_1.distinctUntilChanged)(), (0, rxjs_1.catchError)(() => (0, rxjs_1.of)(models_1.TelemetryMonitorStatus.ERROR)));
118
140
  }
119
141
  async initStream(stream) {
120
142
  await super.initStream(stream);
@@ -5,9 +5,9 @@ export * from './CommandService';
5
5
  export * from './ConfigGroupService';
6
6
  export * from './ControlService';
7
7
  export * from './DashboardService';
8
+ export * from './DeviceCredentialsService';
8
9
  export * from './EventService';
9
10
  export * from './FileAccessorService';
10
- export * from './FunctionService';
11
11
  export * from './IntegrationService';
12
12
  export * from './ProfileService';
13
13
  export * from './ProjectService';
@@ -21,9 +21,9 @@ __exportStar(require("./CommandService"), exports);
21
21
  __exportStar(require("./ConfigGroupService"), exports);
22
22
  __exportStar(require("./ControlService"), exports);
23
23
  __exportStar(require("./DashboardService"), exports);
24
+ __exportStar(require("./DeviceCredentialsService"), exports);
24
25
  __exportStar(require("./EventService"), exports);
25
26
  __exportStar(require("./FileAccessorService"), exports);
26
- __exportStar(require("./FunctionService"), exports);
27
27
  __exportStar(require("./IntegrationService"), exports);
28
28
  __exportStar(require("./ProfileService"), exports);
29
29
  __exportStar(require("./ProjectService"), exports);
@@ -1,4 +1,4 @@
1
- import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, EvaluatorService, EventService, FileAccessorService, FunctionService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, SearchService, SpotProvisioningService, SpotProvisioningServiceNode, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
1
+ import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, DeviceCredentialsService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, SearchService, SpotProvisioningService, SpotProvisioningServiceNode, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
2
2
  import { IBaseService, IDebugLevel, ServiceEnum } from './models';
3
3
  import { RTPWebRTCService } from './services/RTPWebRTCService';
4
4
  export declare abstract class IRocosSDK {
@@ -14,7 +14,6 @@ export declare abstract class IRocosSDK {
14
14
  abstract getSearchService(): SearchService;
15
15
  abstract getConfigGroupService(): ConfigGroupService;
16
16
  abstract getDashboardService(): DashboardService;
17
- abstract getFunctionService(): FunctionService;
18
17
  abstract getStreamService(): StreamService;
19
18
  abstract getUserService(): UserService;
20
19
  abstract getMapService(): MapService;
@@ -28,6 +27,7 @@ export declare abstract class IRocosSDK {
28
27
  abstract getSpotProvisionerService(): SpotProvisioningService | SpotProvisioningServiceNode;
29
28
  abstract getIntegrationService(): IntegrationService;
30
29
  abstract getEvaluatorService(): EvaluatorService;
30
+ abstract getDeviceCredentialsService(): DeviceCredentialsService;
31
31
  abstract cleanup(): Promise<boolean>;
32
32
  abstract enableDebugMode(on: boolean): void;
33
33
  abstract setDebugLevel(level: IDebugLevel): void;
package/esm/RocosSDK.d.ts CHANGED
@@ -1,4 +1,4 @@
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';
1
+ import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, DeviceCredentialsService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, ProfileService, ProjectService, RTPWebRTCService, RobotService, ScheduleService, SearchService, SpotProvisioningService, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService } from './services';
2
2
  import { AuthorisedConfig, IBaseService, IDebugLevel, IRocosSDKConfig, ServiceEnum } from './models';
3
3
  import { IRocosSDK } from './IRocosSDK';
4
4
  import { Logger } from 'loglevel';
@@ -19,7 +19,7 @@ export declare class RocosSDK implements IRocosSDK {
19
19
  */
20
20
  getService<T extends IBaseService>(name: ServiceEnum): T;
21
21
  /**
22
- * GEts the authentication service.
22
+ * Gets the authentication service.
23
23
  */
24
24
  getAuthService(): AuthService;
25
25
  /**
@@ -62,10 +62,6 @@ export declare class RocosSDK implements IRocosSDK {
62
62
  * Gets the dashboard service
63
63
  */
64
64
  getDashboardService(): DashboardService;
65
- /**
66
- * Gets the function service
67
- */
68
- getFunctionService(): FunctionService;
69
65
  /**
70
66
  * Gets the stream service
71
67
  */
@@ -130,6 +126,11 @@ export declare class RocosSDK implements IRocosSDK {
130
126
  * @returns EvaluatorService
131
127
  */
132
128
  getEvaluatorService(): EvaluatorService;
129
+ /**
130
+ * Gets the device credentials service.
131
+ * @returns DeviceCredentialsService
132
+ */
133
+ getDeviceCredentialsService(): DeviceCredentialsService;
133
134
  get platformTimeOffset(): number;
134
135
  get platformTime(): number;
135
136
  /**
package/esm/RocosSDK.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, EvaluatorService, EventService, FileAccessorService, FunctionService, IntegrationService, MapService, PlatFormTimeService, ProfileService, ProjectService, RTPWebRTCService, RobotService, ScheduleService, SearchService, SpotProvisioningService, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService, } from './services';
1
+ import { AssetStorageService, AuthService, CallerService, CommandService, ConfigGroupService, ControlService, DashboardService, DeviceCredentialsService, EvaluatorService, EventService, FileAccessorService, IntegrationService, MapService, PlatFormTimeService, ProfileService, ProjectService, RTPWebRTCService, RobotService, ScheduleService, SearchService, SpotProvisioningService, StreamService, TelemetryService, TimeSyncerService, UserService, WebRTCSignallingService, WorkflowService, } from './services';
2
2
  import { ServiceEnum } from './models';
3
3
  import { RocosLogger } from './logger/RocosLogger';
4
4
  import { RocosStore } from './store/RocosStore';
@@ -59,9 +59,6 @@ export class RocosSDK {
59
59
  case ServiceEnum.DASHBOARD:
60
60
  this.services[name] = new DashboardService(config);
61
61
  break;
62
- case ServiceEnum.FUNCTION:
63
- this.services[name] = new FunctionService(config);
64
- break;
65
62
  case ServiceEnum.STREAM:
66
63
  this.services[name] = new StreamService(config);
67
64
  break;
@@ -104,13 +101,16 @@ export class RocosSDK {
104
101
  case ServiceEnum.EVALUATOR:
105
102
  this.services[name] = new EvaluatorService(config);
106
103
  break;
104
+ case ServiceEnum.DEVICE_CREDENTIALS:
105
+ this.services[name] = new DeviceCredentialsService(config);
106
+ break;
107
107
  }
108
108
  }
109
109
  this.logger.debug(`Found service ${name}.`);
110
110
  return this.services[name];
111
111
  }
112
112
  /**
113
- * GEts the authentication service.
113
+ * Gets the authentication service.
114
114
  */
115
115
  getAuthService() {
116
116
  return this.getService(ServiceEnum.AUTH);
@@ -175,12 +175,6 @@ export class RocosSDK {
175
175
  getDashboardService() {
176
176
  return this.getService(ServiceEnum.DASHBOARD);
177
177
  }
178
- /**
179
- * Gets the function service
180
- */
181
- getFunctionService() {
182
- return this.getService(ServiceEnum.FUNCTION);
183
- }
184
178
  /**
185
179
  * Gets the stream service
186
180
  */
@@ -273,6 +267,13 @@ export class RocosSDK {
273
267
  getEvaluatorService() {
274
268
  return this.getService(ServiceEnum.EVALUATOR);
275
269
  }
270
+ /**
271
+ * Gets the device credentials service.
272
+ * @returns DeviceCredentialsService
273
+ */
274
+ getDeviceCredentialsService() {
275
+ return this.getService(ServiceEnum.DEVICE_CREDENTIALS);
276
+ }
276
277
  get platformTimeOffset() {
277
278
  return PlatFormTimeService.getInstance(this.getTimeSyncerService())?.platformTimeOffset;
278
279
  }
@@ -82,8 +82,8 @@ export declare const API_PROJECT_DEFINITION_ACTION_URL = "https://{url}/projects
82
82
  export declare const API_PROJECT_DEFINITION_BUTTON_URL = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/buttons";
83
83
  export declare const API_PROJECT_DEFINITION_TRIGGER_URL = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/triggers";
84
84
  export declare const API_PROJECT_DEFINITION_GAMEPAD_URL = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/gamepads";
85
- export declare const API_PROJECT_DEFINITION_EXPORT = "https://{url}/projects/{projectId}/robot-definitions/{definitionId}/export";
86
- export declare const API_PROJECT_DEFINITION_IMPORT = "https://{url}/projects/{projectId}/robot-definitions/import";
85
+ export declare const API_PROJECT_DEFINITION_EXPORT = "https://{url}/import-export/projects/{projectId}/robot-definitions/{definitionId}/export";
86
+ export declare const API_PROJECT_DEFINITION_IMPORT = "https://{url}/import-export/projects/{projectId}/robot-definitions/import";
87
87
  export declare const API_PROJECT_GROUP_TYPE_URL = "https://{url}/projects/{projectId}/config-groups/{type}";
88
88
  export declare const API_PROJECT_GROUP_TYPE_ID_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}";
89
89
  export declare const API_PROJECT_GROUP_TYPE_PUBLISH_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/publish";
@@ -91,10 +91,6 @@ export declare const API_PROJECT_GROUP_TYPE_CONFIG_URL = "https://{url}/projects
91
91
  export declare const API_PROJECT_GROUP_TYPE_VERSION_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/{version}";
92
92
  export declare const API_PROJECT_GROUP_TYPE_OWNER_ID_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/owner/{ownerId}";
93
93
  export declare const API_PROJECT_GROUP_TYPE_OWNER_OVERRIDE_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/{ownerId}/override";
94
- export declare const API_PROJECT_FUNCTION_URL = "https://{url}/projects/{projectId}/functions";
95
- export declare const API_PROJECT_FUNCTION_ID_URL = "https://{url}/projects/{projectId}/functions/{functionId}";
96
- export declare const API_PROJECT_FUNCTION_RUN_URL = "https://{url}/projects/{projectId}/functions/{functionId}/run";
97
- export declare const API_PROJECT_FUNCTION_POD_URL = "https://{url}/projects/{projectId}/functions/{functionId}/pods";
98
94
  export declare const API_PROJECT_EXPORT_URL = "https://{url}/projects/{projectId}/export-jobs";
99
95
  export declare const API_PROJECT_STREAM_URL = "https://{url}/projects/{projectId}/streams";
100
96
  export declare const API_PROJECT_STREAM_ID_URL = "https://{url}/projects/{projectId}/streams/{streamId}";
@@ -135,3 +131,5 @@ export declare const API_PROJECT_WORKFLOW_ID_URL = "https://{url}/projects/{proj
135
131
  export declare const API_PROJECT_WORKFLOW_ASSET_URL = "https://{url}/projects/{projectId}/automate/flows/{workflowId}/assets";
136
132
  export declare const API_PROJECT_DEPLOYED_WORKFLOW_URL = "https://{url}/projects/{projectId}/robots/{callsign}/automate/flows/deployments";
137
133
  export declare const API_LINKED_PROJECT_URL = "https://{url}/linked-projects/{linkedProjectId}";
134
+ export declare const API_DEVICE_CREDENTIALS_URL = "https://{url}/projects/{projectId}/callsigns/{callsign}/device-credentials";
135
+ export declare const API_DEVICE_CREDENTIALS_AUTH_URL = "https://{url}/device-credentials/auth";
@@ -82,8 +82,8 @@ export const API_PROJECT_DEFINITION_ACTION_URL = 'https://{url}/projects/{projec
82
82
  export const API_PROJECT_DEFINITION_BUTTON_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/buttons';
83
83
  export const API_PROJECT_DEFINITION_TRIGGER_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/triggers';
84
84
  export const API_PROJECT_DEFINITION_GAMEPAD_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/gamepads';
85
- export const API_PROJECT_DEFINITION_EXPORT = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/export';
86
- export const API_PROJECT_DEFINITION_IMPORT = 'https://{url}/projects/{projectId}/robot-definitions/import';
85
+ export const API_PROJECT_DEFINITION_EXPORT = 'https://{url}/import-export/projects/{projectId}/robot-definitions/{definitionId}/export';
86
+ export const API_PROJECT_DEFINITION_IMPORT = 'https://{url}/import-export/projects/{projectId}/robot-definitions/import';
87
87
  export const API_PROJECT_GROUP_TYPE_URL = 'https://{url}/projects/{projectId}/config-groups/{type}';
88
88
  export const API_PROJECT_GROUP_TYPE_ID_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}';
89
89
  export const API_PROJECT_GROUP_TYPE_PUBLISH_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/publish';
@@ -91,10 +91,6 @@ export const API_PROJECT_GROUP_TYPE_CONFIG_URL = 'https://{url}/projects/{projec
91
91
  export const API_PROJECT_GROUP_TYPE_VERSION_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/{version}';
92
92
  export const API_PROJECT_GROUP_TYPE_OWNER_ID_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/owner/{ownerId}';
93
93
  export const API_PROJECT_GROUP_TYPE_OWNER_OVERRIDE_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/{ownerId}/override';
94
- export const API_PROJECT_FUNCTION_URL = 'https://{url}/projects/{projectId}/functions';
95
- export const API_PROJECT_FUNCTION_ID_URL = 'https://{url}/projects/{projectId}/functions/{functionId}';
96
- export const API_PROJECT_FUNCTION_RUN_URL = 'https://{url}/projects/{projectId}/functions/{functionId}/run';
97
- export const API_PROJECT_FUNCTION_POD_URL = 'https://{url}/projects/{projectId}/functions/{functionId}/pods';
98
94
  export const API_PROJECT_EXPORT_URL = 'https://{url}/projects/{projectId}/export-jobs';
99
95
  export const API_PROJECT_STREAM_URL = 'https://{url}/projects/{projectId}/streams';
100
96
  export const API_PROJECT_STREAM_ID_URL = 'https://{url}/projects/{projectId}/streams/{streamId}';
@@ -135,3 +131,5 @@ export const API_PROJECT_WORKFLOW_ID_URL = 'https://{url}/projects/{projectId}/a
135
131
  export const API_PROJECT_WORKFLOW_ASSET_URL = 'https://{url}/projects/{projectId}/automate/flows/{workflowId}/assets';
136
132
  export const API_PROJECT_DEPLOYED_WORKFLOW_URL = 'https://{url}/projects/{projectId}/robots/{callsign}/automate/flows/deployments';
137
133
  export const API_LINKED_PROJECT_URL = 'https://{url}/linked-projects/{linkedProjectId}';
134
+ export const API_DEVICE_CREDENTIALS_URL = 'https://{url}/projects/{projectId}/callsigns/{callsign}/device-credentials';
135
+ export const API_DEVICE_CREDENTIALS_AUTH_URL = 'https://{url}/device-credentials/auth';
@@ -24,6 +24,7 @@ export declare const errorCodes: {
24
24
  MAPS_SERVICE_ERROR: string;
25
25
  EVALUATOR_SERVICE_ERROR: string;
26
26
  WEBRTC_SERVICE_ERROR: string;
27
+ DEVICE_CREDENTIALS_SERVICE_ERROR: string;
27
28
  };
28
29
  export declare class RocosError extends Error {
29
30
  code?: string;
@@ -24,6 +24,7 @@ export const errorCodes = {
24
24
  MAPS_SERVICE_ERROR: 'MAPS_SERVICE_ERROR',
25
25
  EVALUATOR_SERVICE_ERROR: 'EVALUATOR_SERVICE_ERROR',
26
26
  WEBRTC_SERVICE_ERROR: 'WEBRTC_SERVICE_ERROR',
27
+ DEVICE_CREDENTIALS_SERVICE_ERROR: 'DEVICE_CREDENTIALS_SERVICE_ERROR',
27
28
  };
28
29
  export class RocosError extends Error {
29
30
  constructor(err, code, statusCode) {
@@ -24,5 +24,6 @@ export declare enum ServiceEnum {
24
24
  INTEGRATION = "integration",
25
25
  MAP = "map",
26
26
  EVALUATOR = "evaluator",
27
- RTP_WEBRTC = "rtp_webrtc"
27
+ RTP_WEBRTC = "rtp_webrtc",
28
+ DEVICE_CREDENTIALS = "device_credentials"
28
29
  }
@@ -26,4 +26,5 @@ export var ServiceEnum;
26
26
  ServiceEnum["MAP"] = "map";
27
27
  ServiceEnum["EVALUATOR"] = "evaluator";
28
28
  ServiceEnum["RTP_WEBRTC"] = "rtp_webrtc";
29
+ ServiceEnum["DEVICE_CREDENTIALS"] = "device_credentials";
29
30
  })(ServiceEnum || (ServiceEnum = {}));
@@ -0,0 +1,12 @@
1
+ export declare enum TelemetryMonitorStatus {
2
+ UNKNOWN = "unknown",
3
+ CONNECTED = "connected",
4
+ DISCONNECTED = "disconnected",
5
+ ERROR = "error"
6
+ }
7
+ export declare enum CallsignStatus {
8
+ UNKNOWN = "unknown",
9
+ ONLINE = "online",
10
+ OFFLINE = "offline",
11
+ ERROR = "error"
12
+ }
@@ -0,0 +1,14 @@
1
+ export var TelemetryMonitorStatus;
2
+ (function (TelemetryMonitorStatus) {
3
+ TelemetryMonitorStatus["UNKNOWN"] = "unknown";
4
+ TelemetryMonitorStatus["CONNECTED"] = "connected";
5
+ TelemetryMonitorStatus["DISCONNECTED"] = "disconnected";
6
+ TelemetryMonitorStatus["ERROR"] = "error";
7
+ })(TelemetryMonitorStatus || (TelemetryMonitorStatus = {}));
8
+ export var CallsignStatus;
9
+ (function (CallsignStatus) {
10
+ CallsignStatus["UNKNOWN"] = "unknown";
11
+ CallsignStatus["ONLINE"] = "online";
12
+ CallsignStatus["OFFLINE"] = "offline";
13
+ CallsignStatus["ERROR"] = "error";
14
+ })(CallsignStatus || (CallsignStatus = {}));
@@ -31,10 +31,10 @@ export declare class Token implements IToken {
31
31
  isExpiredIn(threshold?: number, unit?: 'minutes' | 'seconds' | 'hours'): boolean;
32
32
  isExpired(): boolean;
33
33
  private getJWTPayload;
34
- /** Decode a base64 string.
34
+ /** Decode a base64url string.
35
35
  *
36
36
  * Supports both Node.js and browser environments.
37
37
  * @private
38
38
  */
39
- private decodeBase64;
39
+ private decodeBase64URL;
40
40
  }
@@ -51,7 +51,7 @@ export class Token {
51
51
  throw new Error('Invalid token, too many parts');
52
52
  }
53
53
  const [header, payload] = parts.slice(0, 2).map((part) => {
54
- return JSON.parse(this.decodeBase64(part));
54
+ return JSON.parse(this.decodeBase64URL(part));
55
55
  });
56
56
  if (typeof payload !== 'object') {
57
57
  throw new Error('Invalid token, payload must be an object');
@@ -64,15 +64,15 @@ export class Token {
64
64
  }
65
65
  return payload;
66
66
  }
67
- /** Decode a base64 string.
67
+ /** Decode a base64url string.
68
68
  *
69
69
  * Supports both Node.js and browser environments.
70
70
  * @private
71
71
  */
72
- decodeBase64(base64String) {
72
+ decodeBase64URL(base64String) {
73
73
  if (isNode) {
74
- return Buffer.from(base64String, 'base64').toString('utf-8');
74
+ return Buffer.from(base64String, 'base64url').toString('utf-8');
75
75
  }
76
- return atob(base64String);
76
+ return atob(base64String.replace(/-/g, '+').replace(/_/g, '/'));
77
77
  }
78
78
  }
@@ -0,0 +1,46 @@
1
+ export interface DeviceCredentials {
2
+ [component: string]: {
3
+ [system: string]: DeviceCredential;
4
+ };
5
+ }
6
+ export interface DeviceCredential {
7
+ /**
8
+ * Device ID or username
9
+ */
10
+ id: string;
11
+ /**
12
+ * Device secret or password
13
+ */
14
+ key: string;
15
+ }
16
+ export interface DeviceCredentialCreate {
17
+ /**
18
+ * Will automatically be generated if not provided
19
+ */
20
+ id?: string;
21
+ /**
22
+ * Will automatically be generated if not provided
23
+ */
24
+ key?: string;
25
+ /**
26
+ * The agent component the credentials are for e.g. dji, spot, etc.
27
+ */
28
+ component: string;
29
+ /**
30
+ * The system the credentials are for e.g. mqtt, rtmp, etc.
31
+ */
32
+ system: string;
33
+ }
34
+ export interface DeviceCredentialAuth extends DeviceCredential {
35
+ /**
36
+ * The agent component the credentials are for e.g. dji, spot, etc.
37
+ */
38
+ component: string;
39
+ /**
40
+ * The system the credentials are for e.g. mqtt, rtmp, etc.
41
+ */
42
+ system: string;
43
+ }
44
+ export interface DeviceCredentialAuthResult {
45
+ result: 'allow' | 'deny';
46
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -33,7 +33,6 @@ export * from './integrations/Plan';
33
33
  export * from './maps/Map';
34
34
  export * from './maps/Panorama';
35
35
  export * from './projects/ProjectUser';
36
- export * from './CallsignStatus';
37
36
  export * from './ExportDataQuery';
38
37
  export * from './HttpError';
39
38
  export * from './IBaseService';
@@ -73,6 +72,7 @@ export * from './Stream';
73
72
  export * from './StreamOptions';
74
73
  export * from './StreamSource';
75
74
  export * from './SubscriberStatusEnum';
75
+ export * from './TelemetryStatus';
76
76
  export * from './Token';
77
77
  export * from './types';
78
78
  export * from './Widget';
@@ -33,7 +33,6 @@ export * from './integrations/Plan';
33
33
  export * from './maps/Map';
34
34
  export * from './maps/Panorama';
35
35
  export * from './projects/ProjectUser';
36
- export * from './CallsignStatus';
37
36
  export * from './ExportDataQuery';
38
37
  export * from './HttpError';
39
38
  export * from './IBaseService';
@@ -73,6 +72,7 @@ export * from './Stream';
73
72
  export * from './StreamOptions';
74
73
  export * from './StreamSource';
75
74
  export * from './SubscriberStatusEnum';
75
+ export * from './TelemetryStatus';
76
76
  export * from './Token';
77
77
  export * from './types';
78
78
  export * from './Widget';
@@ -1,4 +1,4 @@
1
- import { EvaluatorService, ScheduleService } from '../services';
1
+ import { DeviceCredentialsService, EvaluatorService, ScheduleService } from '../services';
2
2
  import { IBaseService, ServiceEnum } from '../models';
3
3
  import { CallerServiceNode } from '../services/CallerServiceNode';
4
4
  import { CommandServiceNode } from '../services/CommandServiceNode';
@@ -48,4 +48,5 @@ export declare class RocosSDKNode extends RocosSDK {
48
48
  * @deprecated Not supported in Node.js
49
49
  */
50
50
  getRTPWebRTCService(): never;
51
+ getDeviceCredentialsService(): DeviceCredentialsService;
51
52
  }
@@ -1,4 +1,4 @@
1
- import { AssetStorageService, AuthService, ConfigGroupService, DashboardService, EventService, FunctionService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, ScheduleService, SpotProvisioningServiceNode, StreamService, UserService, } from '../services';
1
+ import { AssetStorageService, AuthService, ConfigGroupService, DashboardService, DeviceCredentialsService, EventService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, ScheduleService, SpotProvisioningServiceNode, StreamService, UserService, } from '../services';
2
2
  import { ServiceEnum } from '../models';
3
3
  import { CallerServiceNode } from '../services/CallerServiceNode';
4
4
  import { CommandServiceNode } from '../services/CommandServiceNode';
@@ -48,9 +48,6 @@ export class RocosSDKNode extends RocosSDK {
48
48
  case ServiceEnum.DASHBOARD:
49
49
  this.services[name] = new DashboardService(config);
50
50
  break;
51
- case ServiceEnum.FUNCTION:
52
- this.services[name] = new FunctionService(config);
53
- break;
54
51
  case ServiceEnum.STREAM:
55
52
  this.services[name] = new StreamService(config);
56
53
  break;
@@ -81,6 +78,9 @@ export class RocosSDKNode extends RocosSDK {
81
78
  case ServiceEnum.MAP:
82
79
  this.services[name] = new MapService(config);
83
80
  break;
81
+ case ServiceEnum.DEVICE_CREDENTIALS:
82
+ this.services[name] = new DeviceCredentialsService(config);
83
+ break;
84
84
  }
85
85
  }
86
86
  this.logger.debug(`Found service ${name}.`);
@@ -143,4 +143,7 @@ export class RocosSDKNode extends RocosSDK {
143
143
  getRTPWebRTCService() {
144
144
  throw new Error('WebRTC service is not supported in NodeJS');
145
145
  }
146
+ getDeviceCredentialsService() {
147
+ return this.getService(ServiceEnum.DEVICE_CREDENTIALS);
148
+ }
146
149
  }
@@ -0,0 +1,15 @@
1
+ import { DeviceCredentialAuth, DeviceCredentialAuthResult, DeviceCredentialCreate, DeviceCredentials } from '../models/device-credentials/DeviceCredentials';
2
+ import { IBaseService, IRocosSDKConfig, RocosError } from '../models';
3
+ import { BaseServiceAbstract } from './BaseServiceAbstract';
4
+ /**
5
+ * Manage external devices authenticating with the platform
6
+ */
7
+ export declare class DeviceCredentialsService extends BaseServiceAbstract implements IBaseService {
8
+ constructor(config: IRocosSDKConfig);
9
+ getStatus(): boolean;
10
+ protected getError(e: Error): RocosError;
11
+ list(projectId: string, callsign: string): Promise<DeviceCredentials>;
12
+ create(projectId: string, callsign: string, credentials: DeviceCredentialCreate): Promise<DeviceCredentialCreate>;
13
+ delete(projectId: string, callsign: string, component: string, system: string): Promise<void>;
14
+ auth(credentials: DeviceCredentialAuth): Promise<DeviceCredentialAuthResult>;
15
+ }
@@ -0,0 +1,46 @@
1
+ import { API_DEVICE_CREDENTIALS_AUTH_URL, API_DEVICE_CREDENTIALS_URL } from '../constants/api';
2
+ import { RocosError, errorCodes } from '../models';
3
+ import { BaseServiceAbstract } from './BaseServiceAbstract';
4
+ import { RocosLogger } from '../logger/RocosLogger';
5
+ import { formatServiceUrl } from '../helpers/formatServiceUrl';
6
+ /**
7
+ * Manage external devices authenticating with the platform
8
+ */
9
+ export class DeviceCredentialsService extends BaseServiceAbstract {
10
+ constructor(config) {
11
+ super(config);
12
+ this.logger = RocosLogger.getInstance(`DeviceCredentials(${this.config.url})`);
13
+ }
14
+ getStatus() {
15
+ return true;
16
+ }
17
+ getError(e) {
18
+ return new RocosError(e, errorCodes.DEVICE_CREDENTIALS_SERVICE_ERROR);
19
+ }
20
+ list(projectId, callsign) {
21
+ return this.callGet(formatServiceUrl(API_DEVICE_CREDENTIALS_URL, {
22
+ url: this.config.url,
23
+ projectId,
24
+ callsign,
25
+ }, this.config.insecure), 'Failed to get device credentials.');
26
+ }
27
+ create(projectId, callsign, credentials) {
28
+ return this.callPost(formatServiceUrl(API_DEVICE_CREDENTIALS_URL, {
29
+ url: this.config.url,
30
+ projectId,
31
+ callsign,
32
+ }, this.config.insecure), credentials, 'Failed to create device credentials.');
33
+ }
34
+ delete(projectId, callsign, component, system) {
35
+ return this.callDelete(formatServiceUrl(API_DEVICE_CREDENTIALS_URL, {
36
+ url: this.config.url,
37
+ projectId,
38
+ callsign,
39
+ }, this.config.insecure), 'Failed to delete device credentials.', { component, system });
40
+ }
41
+ auth(credentials) {
42
+ return this.callPost(formatServiceUrl(API_DEVICE_CREDENTIALS_AUTH_URL, {
43
+ url: this.config.url,
44
+ }, this.config.insecure), credentials, 'Failed to delete device credentials.');
45
+ }
46
+ }
@@ -2,7 +2,7 @@ import { IBaseService, IRocosSDKConfig, Map, RocosError } from '../models';
2
2
  import { BaseServiceAbstract } from './BaseServiceAbstract';
3
3
  import { Observation } from '../models/maps/Panorama';
4
4
  /**
5
- * Integrations to retrieve data from the linked project in DroneDeploy
5
+ * Maps service for managing robot maps in the cloud and on robots
6
6
  */
7
7
  export declare class MapService extends BaseServiceAbstract implements IBaseService {
8
8
  constructor(config: IRocosSDKConfig);
@@ -4,7 +4,7 @@ import { BaseServiceAbstract } from './BaseServiceAbstract';
4
4
  import { RocosLogger } from '../logger/RocosLogger';
5
5
  import { formatServiceUrl } from '../helpers/formatServiceUrl';
6
6
  /**
7
- * Integrations to retrieve data from the linked project in DroneDeploy
7
+ * Maps service for managing robot maps in the cloud and on robots
8
8
  */
9
9
  export class MapService extends BaseServiceAbstract {
10
10
  constructor(config) {
@@ -249,10 +249,11 @@ export declare class ProfileService extends BaseServiceAbstract implements IBase
249
249
  * @param projectId - Project Id
250
250
  * @param profileData - Robot definition data
251
251
  * @param newName - Optional new name for the robot definition. If not provided, the name from the imported definition will be used.
252
+ * @param newDescription - Optional new description for the robot definition. If not provided, the description from the imported definition will be used.
252
253
  *
253
254
  * @see export
254
255
  */
255
- import(projectId: string, profileData: Record<string, unknown>, newName?: string): Promise<{
256
+ import(projectId: string, profileData: Blob | File, newName?: string, newDescription?: string): Promise<{
256
257
  profileId: string;
257
258
  }>;
258
259
  /**
@@ -364,14 +364,20 @@ export class ProfileService extends BaseServiceAbstract {
364
364
  * @param projectId - Project Id
365
365
  * @param profileData - Robot definition data
366
366
  * @param newName - Optional new name for the robot definition. If not provided, the name from the imported definition will be used.
367
+ * @param newDescription - Optional new description for the robot definition. If not provided, the description from the imported definition will be used.
367
368
  *
368
369
  * @see export
369
370
  */
370
- async import(projectId, profileData, newName) {
371
+ async import(projectId, profileData, newName, newDescription) {
372
+ const formData = new FormData();
371
373
  if (newName) {
372
- profileData.name = newName;
374
+ formData.append('name', newName);
373
375
  }
374
- return this.callPost(formatServiceUrl(API_PROJECT_DEFINITION_IMPORT, { url: this.config.url, projectId }, this.config.insecure), profileData, `Failed to import robot definition for ${projectId}.`);
376
+ if (newDescription) {
377
+ formData.append('description', newDescription);
378
+ }
379
+ formData.append('file', profileData);
380
+ return this.callPost(formatServiceUrl(API_PROJECT_DEFINITION_IMPORT, { url: this.config.url, projectId }, this.config.insecure), formData, `Failed to import robot definition for ${projectId}.`);
375
381
  }
376
382
  /**
377
383
  * Update gamepads for a robot definition