@dronedeploy/rocos-js-sdk 3.0.1-alpha.11 → 3.0.1-alpha.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. package/cjs/IRocosSDK.d.ts +1 -2
  2. package/cjs/RocosSDK.d.ts +4 -6
  3. package/cjs/RocosSDK.js +1 -9
  4. package/cjs/api/streams/caller/CallerStream.js +5 -2
  5. package/cjs/api/streams/caller/CallerStreamNode.js +2 -1
  6. package/cjs/api/streams/command/CommandStream.js +5 -2
  7. package/cjs/api/streams/command/CommandStreamNode.js +2 -1
  8. package/cjs/api/streams/control/ControlStream.js +5 -2
  9. package/cjs/api/streams/control/ControlStreamAbstract.d.ts +1 -1
  10. package/cjs/api/streams/control/ControlStreamNode.js +2 -1
  11. package/cjs/api/streams/fileAccessor/FileAccessorStream.js +4 -1
  12. package/cjs/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
  13. package/cjs/api/streams/search/SearchStream.js +5 -2
  14. package/cjs/api/streams/search/SearchStreamNode.js +2 -1
  15. package/cjs/api/streams/telemetry/TelemetryStream.js +4 -1
  16. package/cjs/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
  17. package/cjs/api/streams/telemetry/TelemetryStreamNode.js +2 -1
  18. package/cjs/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
  19. package/cjs/constants/api.d.ts +2 -4
  20. package/cjs/constants/api.js +4 -6
  21. package/cjs/helpers/getUniqueConfigKey.d.ts +6 -2
  22. package/cjs/helpers/getUniqueConfigKey.js +7 -2
  23. package/cjs/models/TelemetryStatus.d.ts +12 -0
  24. package/cjs/models/TelemetryStatus.js +17 -0
  25. package/cjs/models/Token.d.ts +2 -2
  26. package/cjs/models/Token.js +5 -5
  27. package/cjs/models/index.d.ts +1 -1
  28. package/cjs/models/index.js +1 -1
  29. package/cjs/node/RocosSDKNode.js +0 -3
  30. package/cjs/services/ProfileService.d.ts +23 -0
  31. package/cjs/services/ProfileService.js +28 -0
  32. package/cjs/services/RTPWebRTCService.d.ts +1 -1
  33. package/cjs/services/RTPWebRTCService.js +4 -2
  34. package/cjs/services/TelemetryService.d.ts +10 -1
  35. package/cjs/services/TelemetryService.js +27 -5
  36. package/cjs/services/index.d.ts +0 -1
  37. package/cjs/services/index.js +0 -1
  38. package/cjs/store/RocosStore.d.ts +1 -2
  39. package/esm/IRocosSDK.d.ts +1 -2
  40. package/esm/RocosSDK.d.ts +4 -6
  41. package/esm/RocosSDK.js +2 -10
  42. package/esm/api/streams/caller/CallerStream.js +5 -2
  43. package/esm/api/streams/caller/CallerStreamNode.js +2 -1
  44. package/esm/api/streams/command/CommandStream.js +5 -2
  45. package/esm/api/streams/command/CommandStreamNode.js +2 -1
  46. package/esm/api/streams/control/ControlStream.js +5 -2
  47. package/esm/api/streams/control/ControlStreamAbstract.d.ts +1 -1
  48. package/esm/api/streams/control/ControlStreamNode.js +2 -1
  49. package/esm/api/streams/fileAccessor/FileAccessorStream.js +4 -1
  50. package/esm/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
  51. package/esm/api/streams/search/SearchStream.js +5 -2
  52. package/esm/api/streams/search/SearchStreamNode.js +2 -1
  53. package/esm/api/streams/telemetry/TelemetryStream.js +4 -1
  54. package/esm/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
  55. package/esm/api/streams/telemetry/TelemetryStreamNode.js +2 -1
  56. package/esm/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
  57. package/esm/constants/api.d.ts +2 -4
  58. package/esm/constants/api.js +2 -4
  59. package/esm/helpers/getUniqueConfigKey.d.ts +6 -2
  60. package/esm/helpers/getUniqueConfigKey.js +7 -2
  61. package/esm/models/TelemetryStatus.d.ts +12 -0
  62. package/esm/models/TelemetryStatus.js +14 -0
  63. package/esm/models/Token.d.ts +2 -2
  64. package/esm/models/Token.js +5 -5
  65. package/esm/models/index.d.ts +1 -1
  66. package/esm/models/index.js +1 -1
  67. package/esm/node/RocosSDKNode.js +1 -4
  68. package/esm/services/ProfileService.d.ts +23 -0
  69. package/esm/services/ProfileService.js +29 -1
  70. package/esm/services/RTPWebRTCService.d.ts +1 -1
  71. package/esm/services/RTPWebRTCService.js +4 -2
  72. package/esm/services/TelemetryService.d.ts +10 -1
  73. package/esm/services/TelemetryService.js +28 -6
  74. package/esm/services/index.d.ts +0 -1
  75. package/esm/services/index.js +0 -1
  76. package/esm/store/RocosStore.d.ts +1 -2
  77. package/package.json +1 -2
  78. package/cjs/helpers/cleanObject.spec.d.ts +0 -1
  79. package/cjs/helpers/cleanObject.spec.js +0 -55
  80. package/cjs/helpers/flattenObject.spec.d.ts +0 -1
  81. package/cjs/helpers/flattenObject.spec.js +0 -31
  82. package/cjs/helpers/flattenOneOf.spec.d.ts +0 -1
  83. package/cjs/helpers/flattenOneOf.spec.js +0 -159
  84. package/cjs/helpers/formatServiceUrl.spec.d.ts +0 -1
  85. package/cjs/helpers/formatServiceUrl.spec.js +0 -18
  86. package/cjs/helpers/getSha256Hex.spec.d.ts +0 -1
  87. package/cjs/helpers/getSha256Hex.spec.js +0 -19
  88. package/cjs/helpers/getSha256HexNode.spec.d.ts +0 -1
  89. package/cjs/helpers/getSha256HexNode.spec.js +0 -10
  90. package/cjs/helpers/getURLSearchParams.spec.d.ts +0 -1
  91. package/cjs/helpers/getURLSearchParams.spec.js +0 -21
  92. package/cjs/helpers/nanosecondToMillisecond.spec.d.ts +0 -1
  93. package/cjs/helpers/nanosecondToMillisecond.spec.js +0 -22
  94. package/cjs/helpers/splitRobotTopic.spec.d.ts +0 -1
  95. package/cjs/helpers/splitRobotTopic.spec.js +0 -53
  96. package/cjs/helpers/standardDeviation.spec.d.ts +0 -1
  97. package/cjs/helpers/standardDeviation.spec.js +0 -13
  98. package/cjs/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
  99. package/cjs/helpers/websandbox/frame/worker/manager.spec.js +0 -132
  100. package/cjs/models/CallsignStatus.d.ts +0 -6
  101. package/cjs/models/CallsignStatus.js +0 -10
  102. package/cjs/models/Token.spec.d.ts +0 -1
  103. package/cjs/models/Token.spec.js +0 -110
  104. package/cjs/services/AuthService.spec.d.ts +0 -1
  105. package/cjs/services/AuthService.spec.js +0 -165
  106. package/cjs/services/CallerService.spec.d.ts +0 -1
  107. package/cjs/services/CallerService.spec.js +0 -229
  108. package/cjs/services/FunctionService.d.ts +0 -68
  109. package/cjs/services/FunctionService.js +0 -103
  110. package/cjs/services/PlatformTimeService.spec.d.ts +0 -1
  111. package/cjs/services/PlatformTimeService.spec.js +0 -182
  112. package/cjs/services/RTPWebRTCService.spec.d.ts +0 -4
  113. package/cjs/services/RTPWebRTCService.spec.js +0 -171
  114. package/cjs/services/TelemetryService.spec.d.ts +0 -1
  115. package/cjs/services/TelemetryService.spec.js +0 -39
  116. package/esm/helpers/cleanObject.spec.d.ts +0 -1
  117. package/esm/helpers/cleanObject.spec.js +0 -53
  118. package/esm/helpers/flattenObject.spec.d.ts +0 -1
  119. package/esm/helpers/flattenObject.spec.js +0 -29
  120. package/esm/helpers/flattenOneOf.spec.d.ts +0 -1
  121. package/esm/helpers/flattenOneOf.spec.js +0 -157
  122. package/esm/helpers/formatServiceUrl.spec.d.ts +0 -1
  123. package/esm/helpers/formatServiceUrl.spec.js +0 -16
  124. package/esm/helpers/getSha256Hex.spec.d.ts +0 -1
  125. package/esm/helpers/getSha256Hex.spec.js +0 -14
  126. package/esm/helpers/getSha256HexNode.spec.d.ts +0 -1
  127. package/esm/helpers/getSha256HexNode.spec.js +0 -8
  128. package/esm/helpers/getURLSearchParams.spec.d.ts +0 -1
  129. package/esm/helpers/getURLSearchParams.spec.js +0 -19
  130. package/esm/helpers/nanosecondToMillisecond.spec.d.ts +0 -1
  131. package/esm/helpers/nanosecondToMillisecond.spec.js +0 -20
  132. package/esm/helpers/splitRobotTopic.spec.d.ts +0 -1
  133. package/esm/helpers/splitRobotTopic.spec.js +0 -51
  134. package/esm/helpers/standardDeviation.spec.d.ts +0 -1
  135. package/esm/helpers/standardDeviation.spec.js +0 -11
  136. package/esm/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
  137. package/esm/helpers/websandbox/frame/worker/manager.spec.js +0 -127
  138. package/esm/models/CallsignStatus.d.ts +0 -6
  139. package/esm/models/CallsignStatus.js +0 -7
  140. package/esm/models/Token.spec.d.ts +0 -1
  141. package/esm/models/Token.spec.js +0 -108
  142. package/esm/services/AuthService.spec.d.ts +0 -1
  143. package/esm/services/AuthService.spec.js +0 -163
  144. package/esm/services/CallerService.spec.d.ts +0 -1
  145. package/esm/services/CallerService.spec.js +0 -227
  146. package/esm/services/FunctionService.d.ts +0 -68
  147. package/esm/services/FunctionService.js +0 -99
  148. package/esm/services/PlatformTimeService.spec.d.ts +0 -1
  149. package/esm/services/PlatformTimeService.spec.js +0 -180
  150. package/esm/services/RTPWebRTCService.spec.d.ts +0 -4
  151. package/esm/services/RTPWebRTCService.spec.js +0 -169
  152. package/esm/services/TelemetryService.spec.d.ts +0 -1
  153. package/esm/services/TelemetryService.spec.js +0 -37
@@ -1,5 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
- import { CallsignStatus, IRocosSDKConfig, IRocosTelemetryMessage, IStreamStatusMessage, ITelemetryStream, ITelemetryStreamConfig, ITelemetrySubscriptionParams, ITelemetrySubscriptions } from '../models';
2
+ import { CallsignStatus, IRocosSDKConfig, IRocosTelemetryMessage, IStreamStatusMessage, ITelemetryStream, ITelemetryStreamConfig, ITelemetrySubscriptionParams, ITelemetrySubscriptions, TelemetryMonitorStatus } from '../models';
3
3
  import { BaseStreamService } from './BaseStreamService';
4
4
  export declare class TelemetryService extends BaseStreamService<ITelemetryStream, ITelemetryStreamConfig> {
5
5
  private statusSubscription;
@@ -34,6 +34,15 @@ export declare class TelemetryService extends BaseStreamService<ITelemetryStream
34
34
  * @param intervalMs optionally override the interval to check for heartbeats (in ms). Default 2000ms
35
35
  */
36
36
  getRobotStatusChanges(projectId: string, callsign: string, heartbeatTimeoutMs?: number, intervalMs?: number): Observable<CallsignStatus>;
37
+ /**
38
+ * Subscribes to the given telemetry and checks we receive one at least emission every `heartbeatTimeoutMs` (default 5s)
39
+ * @param projectId
40
+ * @param callsign
41
+ * @param source the telemetry source to monitor
42
+ * @param heartbeatTimeoutMs optionally override the deadline for telemetry emissions (in ms). Default 5000ms
43
+ * @param intervalMs optionally override the interval to check for telemetry emissions (in ms). Default 2000ms
44
+ */
45
+ monitorTelemetryWithTimeout(projectId: string, callsign: string, source: string, heartbeatTimeoutMs?: number, intervalMs?: number): Observable<TelemetryMonitorStatus>;
37
46
  protected initStream(stream: ITelemetryStream): Promise<void>;
38
47
  private buildScope;
39
48
  private createStream;
@@ -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);
@@ -7,7 +7,6 @@ export * from './ControlService';
7
7
  export * from './DashboardService';
8
8
  export * from './EventService';
9
9
  export * from './FileAccessorService';
10
- export * from './FunctionService';
11
10
  export * from './IntegrationService';
12
11
  export * from './ProfileService';
13
12
  export * from './ProjectService';
@@ -23,7 +23,6 @@ __exportStar(require("./ControlService"), exports);
23
23
  __exportStar(require("./DashboardService"), exports);
24
24
  __exportStar(require("./EventService"), exports);
25
25
  __exportStar(require("./FileAccessorService"), exports);
26
- __exportStar(require("./FunctionService"), exports);
27
26
  __exportStar(require("./IntegrationService"), exports);
28
27
  __exportStar(require("./ProfileService"), exports);
29
28
  __exportStar(require("./ProjectService"), exports);
@@ -1,6 +1,5 @@
1
- import { IRocosChangeMessage } from '../models/message/IRocosChangeMessage';
1
+ import { IRocosChangeMessage, IRocosSDKConfig } from '../models';
2
2
  import { IRocosSDK } from '../IRocosSDK';
3
- import { IRocosSDKConfig } from '../models/IRocosSDKConfig';
4
3
  import { Subject } from 'rxjs';
5
4
  export declare class RocosStore {
6
5
  private static changeSubject$?;
@@ -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, 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;
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, 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';
@@ -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
  */
@@ -145,5 +141,7 @@ export declare class RocosSDK implements IRocosSDK {
145
141
  */
146
142
  enableDebugMode(on: boolean): void;
147
143
  setDebugLevel(level: IDebugLevel): void;
148
- protected overrideConfig(service: ServiceEnum): AuthorisedConfig;
144
+ protected overrideConfig(service: ServiceEnum): AuthorisedConfig & {
145
+ _parentConfig?: IRocosSDKConfig;
146
+ };
149
147
  }
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, 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;
@@ -175,12 +172,6 @@ export class RocosSDK {
175
172
  getDashboardService() {
176
173
  return this.getService(ServiceEnum.DASHBOARD);
177
174
  }
178
- /**
179
- * Gets the function service
180
- */
181
- getFunctionService() {
182
- return this.getService(ServiceEnum.FUNCTION);
183
- }
184
175
  /**
185
176
  * Gets the stream service
186
177
  */
@@ -319,6 +310,7 @@ export class RocosSDK {
319
310
  return {
320
311
  ...config,
321
312
  ...this.config.overrides?.[service],
313
+ _parentConfig: this.config,
322
314
  };
323
315
  }
324
316
  }
@@ -68,11 +68,14 @@ export class CallerStream extends CallerStreamAbstract {
68
68
  return stringToUint8Array(payload);
69
69
  }
70
70
  getMetadata(projectId, callsign, subsystem) {
71
- return {
72
- 'authorization': this.token,
71
+ const meta = {
73
72
  'r-p': projectId,
74
73
  'r-cs': callsign,
75
74
  'r-s': subsystem ?? '',
76
75
  };
76
+ if (this.token) {
77
+ meta.authorization = this.token;
78
+ }
79
+ return meta;
77
80
  }
78
81
  }
@@ -109,7 +109,8 @@ export class CallerStreamNode extends CallerStreamAbstract {
109
109
  meta.add('r-p', projectId);
110
110
  meta.add('r-cs', callsign);
111
111
  meta.add('r-s', subsystem ?? '');
112
- meta.add('authorization', this.token);
112
+ if (this.token)
113
+ meta.add('authorization', this.token);
113
114
  return meta;
114
115
  }
115
116
  }
@@ -58,10 +58,13 @@ export class CommandStream extends CommandStreamAbstract {
58
58
  });
59
59
  }
60
60
  getMetadata(projectId, callsign) {
61
- return {
62
- 'authorization': this.token,
61
+ const meta = {
63
62
  'r-p': projectId,
64
63
  'r-cs': callsign,
65
64
  };
65
+ if (this.token) {
66
+ meta.authorization = this.token;
67
+ }
68
+ return meta;
66
69
  }
67
70
  }
@@ -58,12 +58,13 @@ export class CommandStreamNode extends CommandStreamAbstract {
58
58
  }
59
59
  getMetadata(projectId, callsign, subsystem) {
60
60
  const meta = new grpc.Metadata();
61
- meta.add('authorization', this.token);
62
61
  meta.add('r-p', projectId);
63
62
  meta.add('r-cs', callsign);
64
63
  if (subsystem) {
65
64
  meta.add('r-s', subsystem);
66
65
  }
66
+ if (this.token)
67
+ meta.add('authorization', this.token);
67
68
  return meta;
68
69
  }
69
70
  }
@@ -67,10 +67,13 @@ export class ControlStream extends ControlStreamAbstract {
67
67
  return stringToUint8Array(payload);
68
68
  }
69
69
  getMetadata(projectId, callsign) {
70
- return {
71
- 'authorization': this.token,
70
+ const meta = {
72
71
  'r-p': projectId,
73
72
  'r-cs': callsign,
74
73
  };
74
+ if (this.token) {
75
+ meta.authorization = this.token;
76
+ }
77
+ return meta;
75
78
  }
76
79
  }
@@ -5,7 +5,7 @@ import { Logger } from 'loglevel';
5
5
  export declare abstract class ControlStreamAbstract implements IControlStream {
6
6
  identifier: string;
7
7
  statusStream$: BehaviorSubject<SubscriberStatusEnum>;
8
- protected token: string;
8
+ protected token?: string;
9
9
  private readonly scope;
10
10
  protected url: string;
11
11
  protected subscriberStatus: SubscriberStatusEnum;
@@ -65,9 +65,10 @@ export class ControlStreamNode extends ControlStreamAbstract {
65
65
  }
66
66
  getMetadata(projectId, callsign) {
67
67
  const meta = new grpc.Metadata();
68
- meta.add('authorization', this.token);
69
68
  meta.add('r-p', projectId);
70
69
  meta.add('r-cs', callsign);
70
+ if (this.token)
71
+ meta.add('authorization', this.token);
71
72
  return meta;
72
73
  }
73
74
  }
@@ -48,7 +48,10 @@ export class FileAccessorStream extends FileAccessorStreamAbstract {
48
48
  throw new Error('Error in serverReqOp call');
49
49
  }
50
50
  getMetadata(projectId, callsign) {
51
- const result = { authorization: this.token };
51
+ const result = {};
52
+ if (this.token) {
53
+ result.authorization = this.token;
54
+ }
52
55
  if (projectId) {
53
56
  result['r-p'] = projectId;
54
57
  }
@@ -54,7 +54,9 @@ export class FileAccessorStreamNode extends FileAccessorStreamAbstract {
54
54
  }
55
55
  getMetadata(projectId, callsign) {
56
56
  const meta = new grpc.Metadata();
57
- meta.add('authorization', this.token);
57
+ if (this.token) {
58
+ meta.add('authorization', this.token);
59
+ }
58
60
  if (projectId) {
59
61
  meta.add('r-p', projectId);
60
62
  }
@@ -89,9 +89,12 @@ export class SearchStream extends SearchStreamAbstract {
89
89
  return response;
90
90
  }
91
91
  getMetadata(projectId) {
92
- return {
93
- 'authorization': this.token,
92
+ const meta = {
94
93
  'r-p': projectId,
95
94
  };
95
+ if (this.token) {
96
+ meta.authorization = this.token;
97
+ }
98
+ return meta;
96
99
  }
97
100
  }
@@ -111,8 +111,9 @@ export class SearchStreamNode extends SearchStreamAbstract {
111
111
  }
112
112
  getMetadata(projectId) {
113
113
  const meta = new grpc.Metadata();
114
- meta.add('authorization', this.token);
115
114
  meta.add('r-p', projectId);
115
+ if (this.token)
116
+ meta.add('authorization', this.token);
116
117
  return meta;
117
118
  }
118
119
  }
@@ -62,7 +62,10 @@ export class TelemetryStream extends TelemetryStreamAbstract {
62
62
  }
63
63
  }
64
64
  getMetadata(projectId) {
65
- const result = { authorization: this.token };
65
+ const result = {};
66
+ if (this.token) {
67
+ result.authorization = this.token;
68
+ }
66
69
  if (projectId) {
67
70
  result['r-p'] = projectId;
68
71
  }
@@ -11,7 +11,7 @@ export declare abstract class TelemetryStreamAbstract implements ITelemetryStrea
11
11
  protected projectId: string;
12
12
  private callsignsLookup;
13
13
  private sources;
14
- protected token: string;
14
+ protected token?: string;
15
15
  private scope;
16
16
  protected url: string;
17
17
  private timerIntervalInSec;
@@ -103,10 +103,11 @@ export class TelemetryStreamNode extends TelemetryStreamAbstract {
103
103
  }
104
104
  getMetaData() {
105
105
  const meta = new grpc.Metadata();
106
- meta.add('authorization', this.token);
107
106
  meta.add('r-p', this.projectId);
108
107
  meta.add('r-tid', uuid4());
109
108
  meta.add('r-cs', 'rocos-js-sdk-agent');
109
+ if (this.token)
110
+ meta.add('authorization', this.token);
110
111
  return meta;
111
112
  }
112
113
  requestTelemetry(req) {
@@ -77,9 +77,12 @@ export class WebRTCSignallingStream extends WebRTCSignallingStreamAbstract {
77
77
  return this.webRTCOperatorclient.addIceCandidate(request, { meta: metadata }).response;
78
78
  }
79
79
  getMetadata(projectId) {
80
- return {
81
- 'authorization': this.token,
80
+ const meta = {
82
81
  'r-p': projectId,
83
82
  };
83
+ if (this.token) {
84
+ meta.authorization = this.token;
85
+ }
86
+ return meta;
84
87
  }
85
88
  }
@@ -82,6 +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
87
  export declare const API_PROJECT_GROUP_TYPE_URL = "https://{url}/projects/{projectId}/config-groups/{type}";
86
88
  export declare const API_PROJECT_GROUP_TYPE_ID_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}";
87
89
  export declare const API_PROJECT_GROUP_TYPE_PUBLISH_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/publish";
@@ -89,10 +91,6 @@ export declare const API_PROJECT_GROUP_TYPE_CONFIG_URL = "https://{url}/projects
89
91
  export declare const API_PROJECT_GROUP_TYPE_VERSION_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/{version}";
90
92
  export declare const API_PROJECT_GROUP_TYPE_OWNER_ID_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/owner/{ownerId}";
91
93
  export declare const API_PROJECT_GROUP_TYPE_OWNER_OVERRIDE_URL = "https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/{ownerId}/override";
92
- export declare const API_PROJECT_FUNCTION_URL = "https://{url}/projects/{projectId}/functions";
93
- export declare const API_PROJECT_FUNCTION_ID_URL = "https://{url}/projects/{projectId}/functions/{functionId}";
94
- export declare const API_PROJECT_FUNCTION_RUN_URL = "https://{url}/projects/{projectId}/functions/{functionId}/run";
95
- export declare const API_PROJECT_FUNCTION_POD_URL = "https://{url}/projects/{projectId}/functions/{functionId}/pods";
96
94
  export declare const API_PROJECT_EXPORT_URL = "https://{url}/projects/{projectId}/export-jobs";
97
95
  export declare const API_PROJECT_STREAM_URL = "https://{url}/projects/{projectId}/streams";
98
96
  export declare const API_PROJECT_STREAM_ID_URL = "https://{url}/projects/{projectId}/streams/{streamId}";
@@ -82,6 +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
87
  export const API_PROJECT_GROUP_TYPE_URL = 'https://{url}/projects/{projectId}/config-groups/{type}';
86
88
  export const API_PROJECT_GROUP_TYPE_ID_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}';
87
89
  export const API_PROJECT_GROUP_TYPE_PUBLISH_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/publish';
@@ -89,10 +91,6 @@ export const API_PROJECT_GROUP_TYPE_CONFIG_URL = 'https://{url}/projects/{projec
89
91
  export const API_PROJECT_GROUP_TYPE_VERSION_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/{version}';
90
92
  export const API_PROJECT_GROUP_TYPE_OWNER_ID_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/owner/{ownerId}';
91
93
  export const API_PROJECT_GROUP_TYPE_OWNER_OVERRIDE_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/{ownerId}/override';
92
- export const API_PROJECT_FUNCTION_URL = 'https://{url}/projects/{projectId}/functions';
93
- export const API_PROJECT_FUNCTION_ID_URL = 'https://{url}/projects/{projectId}/functions/{functionId}';
94
- export const API_PROJECT_FUNCTION_RUN_URL = 'https://{url}/projects/{projectId}/functions/{functionId}/run';
95
- export const API_PROJECT_FUNCTION_POD_URL = 'https://{url}/projects/{projectId}/functions/{functionId}/pods';
96
94
  export const API_PROJECT_EXPORT_URL = 'https://{url}/projects/{projectId}/export-jobs';
97
95
  export const API_PROJECT_STREAM_URL = 'https://{url}/projects/{projectId}/streams';
98
96
  export const API_PROJECT_STREAM_ID_URL = 'https://{url}/projects/{projectId}/streams/{streamId}';
@@ -1,7 +1,11 @@
1
- import { IRocosSDKConfig } from '../models/IRocosSDKConfig';
1
+ import { IRocosSDKConfig } from '../models';
2
+ type ConfigWithParent = IRocosSDKConfig & {
3
+ _parentConfig?: ConfigWithParent;
4
+ };
2
5
  /**
3
6
  * Flattens and orders the sdk config props to make a unique key
4
7
  *
5
8
  * @param config - SDK config {@link IRocosSDKConfig}
6
9
  */
7
- export declare const getUniqueConfigKey: (config: IRocosSDKConfig) => string;
10
+ export declare const getUniqueConfigKey: (config: ConfigWithParent) => string;
11
+ export {};
@@ -4,10 +4,15 @@
4
4
  * @param config - SDK config {@link IRocosSDKConfig}
5
5
  */
6
6
  export const getUniqueConfigKey = (config) => {
7
- return Object.keys(config)
7
+ let rootConfig = config;
8
+ if (rootConfig._parentConfig) {
9
+ // assume there is only one level of nesting
10
+ rootConfig = rootConfig._parentConfig;
11
+ }
12
+ return Object.keys(rootConfig)
8
13
  .sort()
9
14
  .map((item) => {
10
- return item !== 'token' ? `${item}:${config[item]}` : false;
15
+ return item !== 'token' ? `${item}:${rootConfig[item]}` : false;
11
16
  })
12
17
  .filter(Boolean)
13
18
  .join();
@@ -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
  }
@@ -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 { AssetStorageService, AuthService, ConfigGroupService, DashboardService, EventService, FunctionService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, ScheduleService, SpotProvisioningServiceNode, StreamService, UserService, } from '../services';
1
+ import { AssetStorageService, AuthService, ConfigGroupService, DashboardService, 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;
@@ -232,6 +232,29 @@ export declare class ProfileService extends BaseServiceAbstract implements IBase
232
232
  * @description - Renamed from robotDefGetGamepads
233
233
  */
234
234
  getGamepads(projectId: string, definitionId: string): Promise<any>;
235
+ /** Export robot definition into JSON format
236
+ *
237
+ * Can be used to import robot definition into another project
238
+ *
239
+ * @param projectId - Project Id
240
+ * @param definitionId - Robot definition Id
241
+ *
242
+ * @see import
243
+ */
244
+ export(projectId: string, definitionId: string): Promise<Record<string, unknown>>;
245
+ /** Import robot definition from JSON format
246
+ *
247
+ * Accepts a previously exported robot definition
248
+ *
249
+ * @param projectId - Project Id
250
+ * @param profileData - Robot definition data
251
+ * @param newName - Optional new name for the robot definition. If not provided, the name from the imported definition will be used.
252
+ *
253
+ * @see export
254
+ */
255
+ import(projectId: string, profileData: Record<string, unknown>, newName?: string): Promise<{
256
+ profileId: string;
257
+ }>;
235
258
  /**
236
259
  * Update gamepads for a robot definition
237
260
  *