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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. package/cjs/RocosSDK.d.ts +3 -1
  2. package/cjs/RocosSDK.js +1 -0
  3. package/cjs/api/streams/caller/CallerStream.js +5 -2
  4. package/cjs/api/streams/caller/CallerStreamNode.js +2 -1
  5. package/cjs/api/streams/command/CommandStream.js +5 -2
  6. package/cjs/api/streams/command/CommandStreamNode.js +2 -1
  7. package/cjs/api/streams/control/ControlStream.js +5 -2
  8. package/cjs/api/streams/control/ControlStreamAbstract.d.ts +1 -1
  9. package/cjs/api/streams/control/ControlStreamNode.js +2 -1
  10. package/cjs/api/streams/fileAccessor/FileAccessorStream.js +4 -1
  11. package/cjs/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
  12. package/cjs/api/streams/search/SearchStream.js +5 -2
  13. package/cjs/api/streams/search/SearchStreamNode.js +2 -1
  14. package/cjs/api/streams/telemetry/TelemetryStream.js +4 -1
  15. package/cjs/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
  16. package/cjs/api/streams/telemetry/TelemetryStreamNode.js +2 -1
  17. package/cjs/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
  18. package/cjs/constants/api.d.ts +2 -0
  19. package/cjs/constants/api.js +4 -2
  20. package/cjs/helpers/getUniqueConfigKey.d.ts +6 -2
  21. package/cjs/helpers/getUniqueConfigKey.js +7 -2
  22. package/cjs/services/ProfileService.d.ts +23 -0
  23. package/cjs/services/ProfileService.js +28 -0
  24. package/cjs/services/RTPWebRTCService.d.ts +1 -1
  25. package/cjs/services/RTPWebRTCService.js +4 -2
  26. package/cjs/store/RocosStore.d.ts +1 -2
  27. package/esm/RocosSDK.d.ts +3 -1
  28. package/esm/RocosSDK.js +1 -0
  29. package/esm/api/streams/caller/CallerStream.js +5 -2
  30. package/esm/api/streams/caller/CallerStreamNode.js +2 -1
  31. package/esm/api/streams/command/CommandStream.js +5 -2
  32. package/esm/api/streams/command/CommandStreamNode.js +2 -1
  33. package/esm/api/streams/control/ControlStream.js +5 -2
  34. package/esm/api/streams/control/ControlStreamAbstract.d.ts +1 -1
  35. package/esm/api/streams/control/ControlStreamNode.js +2 -1
  36. package/esm/api/streams/fileAccessor/FileAccessorStream.js +4 -1
  37. package/esm/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
  38. package/esm/api/streams/search/SearchStream.js +5 -2
  39. package/esm/api/streams/search/SearchStreamNode.js +2 -1
  40. package/esm/api/streams/telemetry/TelemetryStream.js +4 -1
  41. package/esm/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
  42. package/esm/api/streams/telemetry/TelemetryStreamNode.js +2 -1
  43. package/esm/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
  44. package/esm/constants/api.d.ts +2 -0
  45. package/esm/constants/api.js +2 -0
  46. package/esm/helpers/getUniqueConfigKey.d.ts +6 -2
  47. package/esm/helpers/getUniqueConfigKey.js +7 -2
  48. package/esm/services/ProfileService.d.ts +23 -0
  49. package/esm/services/ProfileService.js +29 -1
  50. package/esm/services/RTPWebRTCService.d.ts +1 -1
  51. package/esm/services/RTPWebRTCService.js +4 -2
  52. package/esm/store/RocosStore.d.ts +1 -2
  53. package/package.json +1 -1
  54. package/cjs/helpers/cleanObject.spec.d.ts +0 -1
  55. package/cjs/helpers/cleanObject.spec.js +0 -55
  56. package/cjs/helpers/flattenObject.spec.d.ts +0 -1
  57. package/cjs/helpers/flattenObject.spec.js +0 -31
  58. package/cjs/helpers/flattenOneOf.spec.d.ts +0 -1
  59. package/cjs/helpers/flattenOneOf.spec.js +0 -159
  60. package/cjs/helpers/formatServiceUrl.spec.d.ts +0 -1
  61. package/cjs/helpers/formatServiceUrl.spec.js +0 -18
  62. package/cjs/helpers/getSha256Hex.spec.d.ts +0 -1
  63. package/cjs/helpers/getSha256Hex.spec.js +0 -19
  64. package/cjs/helpers/getSha256HexNode.spec.d.ts +0 -1
  65. package/cjs/helpers/getSha256HexNode.spec.js +0 -10
  66. package/cjs/helpers/getURLSearchParams.spec.d.ts +0 -1
  67. package/cjs/helpers/getURLSearchParams.spec.js +0 -21
  68. package/cjs/helpers/nanosecondToMillisecond.spec.d.ts +0 -1
  69. package/cjs/helpers/nanosecondToMillisecond.spec.js +0 -22
  70. package/cjs/helpers/splitRobotTopic.spec.d.ts +0 -1
  71. package/cjs/helpers/splitRobotTopic.spec.js +0 -53
  72. package/cjs/helpers/standardDeviation.spec.d.ts +0 -1
  73. package/cjs/helpers/standardDeviation.spec.js +0 -13
  74. package/cjs/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
  75. package/cjs/helpers/websandbox/frame/worker/manager.spec.js +0 -132
  76. package/cjs/models/Token.spec.d.ts +0 -1
  77. package/cjs/models/Token.spec.js +0 -110
  78. package/cjs/services/AuthService.spec.d.ts +0 -1
  79. package/cjs/services/AuthService.spec.js +0 -165
  80. package/cjs/services/CallerService.spec.d.ts +0 -1
  81. package/cjs/services/CallerService.spec.js +0 -229
  82. package/cjs/services/PlatformTimeService.spec.d.ts +0 -1
  83. package/cjs/services/PlatformTimeService.spec.js +0 -182
  84. package/cjs/services/RTPWebRTCService.spec.d.ts +0 -4
  85. package/cjs/services/RTPWebRTCService.spec.js +0 -171
  86. package/cjs/services/TelemetryService.spec.d.ts +0 -1
  87. package/cjs/services/TelemetryService.spec.js +0 -39
  88. package/esm/helpers/cleanObject.spec.d.ts +0 -1
  89. package/esm/helpers/cleanObject.spec.js +0 -53
  90. package/esm/helpers/flattenObject.spec.d.ts +0 -1
  91. package/esm/helpers/flattenObject.spec.js +0 -29
  92. package/esm/helpers/flattenOneOf.spec.d.ts +0 -1
  93. package/esm/helpers/flattenOneOf.spec.js +0 -157
  94. package/esm/helpers/formatServiceUrl.spec.d.ts +0 -1
  95. package/esm/helpers/formatServiceUrl.spec.js +0 -16
  96. package/esm/helpers/getSha256Hex.spec.d.ts +0 -1
  97. package/esm/helpers/getSha256Hex.spec.js +0 -14
  98. package/esm/helpers/getSha256HexNode.spec.d.ts +0 -1
  99. package/esm/helpers/getSha256HexNode.spec.js +0 -8
  100. package/esm/helpers/getURLSearchParams.spec.d.ts +0 -1
  101. package/esm/helpers/getURLSearchParams.spec.js +0 -19
  102. package/esm/helpers/nanosecondToMillisecond.spec.d.ts +0 -1
  103. package/esm/helpers/nanosecondToMillisecond.spec.js +0 -20
  104. package/esm/helpers/splitRobotTopic.spec.d.ts +0 -1
  105. package/esm/helpers/splitRobotTopic.spec.js +0 -51
  106. package/esm/helpers/standardDeviation.spec.d.ts +0 -1
  107. package/esm/helpers/standardDeviation.spec.js +0 -11
  108. package/esm/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
  109. package/esm/helpers/websandbox/frame/worker/manager.spec.js +0 -127
  110. package/esm/models/Token.spec.d.ts +0 -1
  111. package/esm/models/Token.spec.js +0 -108
  112. package/esm/services/AuthService.spec.d.ts +0 -1
  113. package/esm/services/AuthService.spec.js +0 -163
  114. package/esm/services/CallerService.spec.d.ts +0 -1
  115. package/esm/services/CallerService.spec.js +0 -227
  116. package/esm/services/PlatformTimeService.spec.d.ts +0 -1
  117. package/esm/services/PlatformTimeService.spec.js +0 -180
  118. package/esm/services/RTPWebRTCService.spec.d.ts +0 -4
  119. package/esm/services/RTPWebRTCService.spec.js +0 -169
  120. package/esm/services/TelemetryService.spec.d.ts +0 -1
  121. package/esm/services/TelemetryService.spec.js +0 -37
package/cjs/RocosSDK.d.ts CHANGED
@@ -145,5 +145,7 @@ 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
+ protected overrideConfig(service: ServiceEnum): AuthorisedConfig & {
149
+ _parentConfig?: IRocosSDKConfig;
150
+ };
149
151
  }
package/cjs/RocosSDK.js CHANGED
@@ -322,6 +322,7 @@ class RocosSDK {
322
322
  return {
323
323
  ...config,
324
324
  ...this.config.overrides?.[service],
325
+ _parentConfig: this.config,
325
326
  };
326
327
  }
327
328
  }
@@ -71,12 +71,15 @@ class CallerStream extends CallerStreamAbstract_1.CallerStreamAbstract {
71
71
  return (0, stringToUint8Array_1.stringToUint8Array)(payload);
72
72
  }
73
73
  getMetadata(projectId, callsign, subsystem) {
74
- return {
75
- 'authorization': this.token,
74
+ const meta = {
76
75
  'r-p': projectId,
77
76
  'r-cs': callsign,
78
77
  'r-s': subsystem ?? '',
79
78
  };
79
+ if (this.token) {
80
+ meta.authorization = this.token;
81
+ }
82
+ return meta;
80
83
  }
81
84
  }
82
85
  exports.CallerStream = CallerStream;
@@ -135,7 +135,8 @@ class CallerStreamNode extends CallerStreamAbstract_1.CallerStreamAbstract {
135
135
  meta.add('r-p', projectId);
136
136
  meta.add('r-cs', callsign);
137
137
  meta.add('r-s', subsystem ?? '');
138
- meta.add('authorization', this.token);
138
+ if (this.token)
139
+ meta.add('authorization', this.token);
139
140
  return meta;
140
141
  }
141
142
  }
@@ -61,11 +61,14 @@ class CommandStream extends CommandStreamAbstract_1.CommandStreamAbstract {
61
61
  });
62
62
  }
63
63
  getMetadata(projectId, callsign) {
64
- return {
65
- 'authorization': this.token,
64
+ const meta = {
66
65
  'r-p': projectId,
67
66
  'r-cs': callsign,
68
67
  };
68
+ if (this.token) {
69
+ meta.authorization = this.token;
70
+ }
71
+ return meta;
69
72
  }
70
73
  }
71
74
  exports.CommandStream = CommandStream;
@@ -84,12 +84,13 @@ class CommandStreamNode extends CommandStreamAbstract_1.CommandStreamAbstract {
84
84
  }
85
85
  getMetadata(projectId, callsign, subsystem) {
86
86
  const meta = new grpc.Metadata();
87
- meta.add('authorization', this.token);
88
87
  meta.add('r-p', projectId);
89
88
  meta.add('r-cs', callsign);
90
89
  if (subsystem) {
91
90
  meta.add('r-s', subsystem);
92
91
  }
92
+ if (this.token)
93
+ meta.add('authorization', this.token);
93
94
  return meta;
94
95
  }
95
96
  }
@@ -70,11 +70,14 @@ class ControlStream extends ControlStreamAbstract_1.ControlStreamAbstract {
70
70
  return (0, stringToUint8Array_1.stringToUint8Array)(payload);
71
71
  }
72
72
  getMetadata(projectId, callsign) {
73
- return {
74
- 'authorization': this.token,
73
+ const meta = {
75
74
  'r-p': projectId,
76
75
  'r-cs': callsign,
77
76
  };
77
+ if (this.token) {
78
+ meta.authorization = this.token;
79
+ }
80
+ return meta;
78
81
  }
79
82
  }
80
83
  exports.ControlStream = ControlStream;
@@ -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;
@@ -91,9 +91,10 @@ class ControlStreamNode extends ControlStreamAbstract_1.ControlStreamAbstract {
91
91
  }
92
92
  getMetadata(projectId, callsign) {
93
93
  const meta = new grpc.Metadata();
94
- meta.add('authorization', this.token);
95
94
  meta.add('r-p', projectId);
96
95
  meta.add('r-cs', callsign);
96
+ if (this.token)
97
+ meta.add('authorization', this.token);
97
98
  return meta;
98
99
  }
99
100
  }
@@ -51,7 +51,10 @@ class FileAccessorStream extends FileAccessorStreamAbstract_1.FileAccessorStream
51
51
  throw new Error('Error in serverReqOp call');
52
52
  }
53
53
  getMetadata(projectId, callsign) {
54
- const result = { authorization: this.token };
54
+ const result = {};
55
+ if (this.token) {
56
+ result.authorization = this.token;
57
+ }
55
58
  if (projectId) {
56
59
  result['r-p'] = projectId;
57
60
  }
@@ -80,7 +80,9 @@ class FileAccessorStreamNode extends FileAccessorStreamAbstract_1.FileAccessorSt
80
80
  }
81
81
  getMetadata(projectId, callsign) {
82
82
  const meta = new grpc.Metadata();
83
- meta.add('authorization', this.token);
83
+ if (this.token) {
84
+ meta.add('authorization', this.token);
85
+ }
84
86
  if (projectId) {
85
87
  meta.add('r-p', projectId);
86
88
  }
@@ -92,10 +92,13 @@ class SearchStream extends SearchStreamAbstract_1.SearchStreamAbstract {
92
92
  return response;
93
93
  }
94
94
  getMetadata(projectId) {
95
- return {
96
- 'authorization': this.token,
95
+ const meta = {
97
96
  'r-p': projectId,
98
97
  };
98
+ if (this.token) {
99
+ meta.authorization = this.token;
100
+ }
101
+ return meta;
99
102
  }
100
103
  }
101
104
  exports.SearchStream = SearchStream;
@@ -137,8 +137,9 @@ class SearchStreamNode extends SearchStreamAbstract_1.SearchStreamAbstract {
137
137
  }
138
138
  getMetadata(projectId) {
139
139
  const meta = new grpc.Metadata();
140
- meta.add('authorization', this.token);
141
140
  meta.add('r-p', projectId);
141
+ if (this.token)
142
+ meta.add('authorization', this.token);
142
143
  return meta;
143
144
  }
144
145
  }
@@ -65,7 +65,10 @@ class TelemetryStream extends TelemetryStreamAbstract_1.TelemetryStreamAbstract
65
65
  }
66
66
  }
67
67
  getMetadata(projectId) {
68
- const result = { authorization: this.token };
68
+ const result = {};
69
+ if (this.token) {
70
+ result.authorization = this.token;
71
+ }
69
72
  if (projectId) {
70
73
  result['r-p'] = projectId;
71
74
  }
@@ -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;
@@ -129,10 +129,11 @@ class TelemetryStreamNode extends TelemetryStreamAbstract_1.TelemetryStreamAbstr
129
129
  }
130
130
  getMetaData() {
131
131
  const meta = new grpc.Metadata();
132
- meta.add('authorization', this.token);
133
132
  meta.add('r-p', this.projectId);
134
133
  meta.add('r-tid', (0, uuid_1.v4)());
135
134
  meta.add('r-cs', 'rocos-js-sdk-agent');
135
+ if (this.token)
136
+ meta.add('authorization', this.token);
136
137
  return meta;
137
138
  }
138
139
  requestTelemetry(req) {
@@ -80,10 +80,13 @@ class WebRTCSignallingStream extends WebRTCSignallingStreamAbstract_1.WebRTCSign
80
80
  return this.webRTCOperatorclient.addIceCandidate(request, { meta: metadata }).response;
81
81
  }
82
82
  getMetadata(projectId) {
83
- return {
84
- 'authorization': this.token,
83
+ const meta = {
85
84
  'r-p': projectId,
86
85
  };
86
+ if (this.token) {
87
+ meta.authorization = this.token;
88
+ }
89
+ return meta;
87
90
  }
88
91
  }
89
92
  exports.WebRTCSignallingStream = WebRTCSignallingStream;
@@ -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";
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.API_PROJECT_ROBOT_REGISTER_URL = exports.API_PROJECT_ROBOT_DEFINITION_URL = exports.API_PROJECT_ROBOT_ATTRIBUTES_URL = exports.API_PROJECT_ROBOT_ID_URL = exports.API_PROJECT_ROBOT_URL = exports.API_PROJECT_MAPPED_ASSETS_PATH_URL = exports.API_PROJECT_MISSION_ASSET_PATH_URL = exports.API_PROJECT_MISSION_ASSETS_PATH_URL = exports.API_PROJECT_FLOW_ASSET_PATH_URL = exports.API_PROJECT_ROBOT_ASSET_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATION_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATIONS_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATION_PROVIDERS_PATH_URL = exports.API_PROJECT_ASSET_PROFILES_SYNC_DEFINITION_PATH_URL = exports.API_PROJECT_ASSET_ROBOTS_SYNC_DEFINITION_PATH_URL = exports.API_PROJECT_ASSET_PATH_URL = exports.API_PROJECT_ASSET_URL = exports.API_PROJECT_USERS_URL = exports.API_PROJECT_ID_URL = exports.API_PROJECT_URL = exports.API_ACCOUNT_PROJECT_APPLICATION_ID_URL = exports.API_ACCOUNT_PROJECT_APPLICATION_URL = exports.API_ACCOUNT_PROJECT_USER_ID_URL = exports.API_ACCOUNT_PROJECT_USER_URL = exports.API_ACCOUNT_PROJECT_ID_URL = exports.API_ACCOUNT_PROJECT_URL = exports.API_SERVER_TIME_URL = exports.API_ACCOUNT_INTEGRATION_TYPE_URL = exports.API_ACCOUNT_INTEGRATION_URL = exports.API_ACCOUNT_SETTINGS_URL = exports.API_AUTH_USER_ACCOUNT_USER_ID_URL = exports.API_AUTH_USER_ACCOUNT_USER_URL = exports.API_ACCOUNT_ACTIVATE_URL = exports.API_ACCOUNT_ID_URL = exports.API_ACCOUNT_URL = exports.API_USER_PAT_TOKEN_URL = exports.API_USER_PAT_URL = exports.API_USER_VERIFY_EMAIL_URL = exports.API_USER_INVITATION_CHECK_URL = exports.API_USER_INVITATION_ACCEPT_URL = exports.API_USER_INVITATION_URL = exports.API_USER_PASSWORD_FORGOT_URL = exports.API_USER_PASSWORD_RESET_URL = exports.API_OTP_AUTH_URL = exports.API_OTP_URL = exports.API_USER_TOKEN_URL = exports.API_USER_AUTH_URL = exports.API_USER_URL = exports.API_ADMIN_USER_INVITATION_URL = exports.API_APPLICATION_AUTH_URL = void 0;
4
- exports.API_PROJECT_STREAM_CALLSIGN_URL = exports.API_PROJECT_STREAM_DATA_URL = exports.API_PROJECT_STREAM_ID_URL = exports.API_PROJECT_STREAM_URL = exports.API_PROJECT_EXPORT_URL = exports.API_PROJECT_FUNCTION_POD_URL = exports.API_PROJECT_FUNCTION_RUN_URL = exports.API_PROJECT_FUNCTION_ID_URL = exports.API_PROJECT_FUNCTION_URL = exports.API_PROJECT_GROUP_TYPE_OWNER_OVERRIDE_URL = exports.API_PROJECT_GROUP_TYPE_OWNER_ID_URL = exports.API_PROJECT_GROUP_TYPE_VERSION_URL = exports.API_PROJECT_GROUP_TYPE_CONFIG_URL = exports.API_PROJECT_GROUP_TYPE_PUBLISH_URL = exports.API_PROJECT_GROUP_TYPE_ID_URL = exports.API_PROJECT_GROUP_TYPE_URL = exports.API_PROJECT_DEFINITION_GAMEPAD_URL = exports.API_PROJECT_DEFINITION_TRIGGER_URL = exports.API_PROJECT_DEFINITION_BUTTON_URL = exports.API_PROJECT_DEFINITION_ACTION_URL = exports.API_PROJECT_DEFINITION_EVENT_URL = exports.API_PROJECT_DEFINITION_COMMAND2_URL = exports.API_PROJECT_DEFINITION_COMMAND_URL = exports.API_PROJECT_DEFINITION_AGENT_URL = exports.API_PROJECT_DEFINITION_SETTING_URL = exports.API_PROJECT_DEFINITION_BLOB_URL = exports.API_PROJECT_DEFINITION_DASHBOARD_URL = exports.API_PROJECT_DEFINITION_COPY_URL = exports.API_PROJECT_DEFINITION_STREAM_URL = exports.API_PROJECT_DEFINITION_ID_URL = exports.API_PROJECT_DEFINITION_URL = exports.API_PROJECT_VROBOT_DEPLOY_URL = exports.API_PROJECT_VROBOT_DETAILS_URL = exports.API_PROJECT_COLLECTION_DOCS_URL = exports.API_PROJECT_COLLECTION_ID_URL = exports.API_PROJECT_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_DASHBOARD_WIDGET_URL = exports.API_PROJECT_DASHBOARD_ID_URL = exports.API_PROJECT_DASHBOARD_URL = exports.API_PROJECT_OPERATION_ID_URL = exports.API_PROJECT_OPERATION_URL = exports.API_PROJECT_ROBOT_GAMEPAD_URL = exports.API_PROJECT_ROBOT_TRIGGER_URL = exports.API_PROJECT_ROBOT_BUTTON_URL = exports.API_PROJECT_ROBOT_COMMAND2_URL = exports.API_PROJECT_ROBOT_COMMAND_URL = exports.API_PROJECT_ROBOT_AGENT_URL = exports.API_PROJECT_ROBOT_SETTING_URL = exports.API_PROJECT_ROBOT_EVENT_HISTORY_URL = exports.API_PROJECT_ROBOT_EVENT_URL = void 0;
5
- exports.API_LINKED_PROJECT_URL = exports.API_PROJECT_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_WORKFLOW_ASSET_URL = exports.API_PROJECT_WORKFLOW_ID_URL = exports.API_PROJECT_WORKFLOW_URL = exports.API_OBSERVATION_KEYS_URL = exports.API_OBSERVATIONS_URL = exports.API_MAPS_PANORAMA_OBSERVATIONS_URL = exports.API_MAPS_GEOJSON_URL = exports.API_MAPS_DEPLOY_URL = exports.API_MAPS_COPY_URL = exports.API_MAP_ID_URL = exports.API_MAPS_MERGE_URL = exports.API_MAPS_DEPLOYED_URL = exports.API_MAPS_URL = exports.API_DD_INTEGRATION_ISSUES_URL = exports.API_DD_INTEGRATION_OVERLAYS_URL = exports.API_DD_INTEGRATION_PLAN_BY_ID_URL = exports.API_DD_INTEGRATION_PLANS_URL = exports.API_SPOTTY_URL = exports.API_PROJECT_SCHEDULES_URL = exports.API_SOURCE_ID_URL = exports.API_SOURCE_URL = exports.API_SOURCE_SCHEMA_URL = exports.API_TEMPLATE_EXPORTER_URL = exports.API_TEMPLATE_PROVISION_ID_URL = exports.API_TEMPLATE_PROVISION_URL = exports.API_TEMPLATE_DEPLOY_URL = exports.API_PROJECT_PROFILE_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_PROFILE_DASHBOARD_ID_URL = exports.API_PROJECT_PROFILE_DASHBOARD_URL = exports.API_PROJECT_CALLSIGN_STREAM_URL = exports.API_PROJECT_ROBOT_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_ROBOT_DASHBOARD_ID_URL = exports.API_PROJECT_ROBOT_DASHBOARD_URL = void 0;
4
+ exports.API_PROJECT_STREAM_ID_URL = exports.API_PROJECT_STREAM_URL = exports.API_PROJECT_EXPORT_URL = exports.API_PROJECT_FUNCTION_POD_URL = exports.API_PROJECT_FUNCTION_RUN_URL = exports.API_PROJECT_FUNCTION_ID_URL = exports.API_PROJECT_FUNCTION_URL = exports.API_PROJECT_GROUP_TYPE_OWNER_OVERRIDE_URL = exports.API_PROJECT_GROUP_TYPE_OWNER_ID_URL = exports.API_PROJECT_GROUP_TYPE_VERSION_URL = exports.API_PROJECT_GROUP_TYPE_CONFIG_URL = exports.API_PROJECT_GROUP_TYPE_PUBLISH_URL = exports.API_PROJECT_GROUP_TYPE_ID_URL = exports.API_PROJECT_GROUP_TYPE_URL = exports.API_PROJECT_DEFINITION_IMPORT = exports.API_PROJECT_DEFINITION_EXPORT = exports.API_PROJECT_DEFINITION_GAMEPAD_URL = exports.API_PROJECT_DEFINITION_TRIGGER_URL = exports.API_PROJECT_DEFINITION_BUTTON_URL = exports.API_PROJECT_DEFINITION_ACTION_URL = exports.API_PROJECT_DEFINITION_EVENT_URL = exports.API_PROJECT_DEFINITION_COMMAND2_URL = exports.API_PROJECT_DEFINITION_COMMAND_URL = exports.API_PROJECT_DEFINITION_AGENT_URL = exports.API_PROJECT_DEFINITION_SETTING_URL = exports.API_PROJECT_DEFINITION_BLOB_URL = exports.API_PROJECT_DEFINITION_DASHBOARD_URL = exports.API_PROJECT_DEFINITION_COPY_URL = exports.API_PROJECT_DEFINITION_STREAM_URL = exports.API_PROJECT_DEFINITION_ID_URL = exports.API_PROJECT_DEFINITION_URL = exports.API_PROJECT_VROBOT_DEPLOY_URL = exports.API_PROJECT_VROBOT_DETAILS_URL = exports.API_PROJECT_COLLECTION_DOCS_URL = exports.API_PROJECT_COLLECTION_ID_URL = exports.API_PROJECT_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_DASHBOARD_WIDGET_URL = exports.API_PROJECT_DASHBOARD_ID_URL = exports.API_PROJECT_DASHBOARD_URL = exports.API_PROJECT_OPERATION_ID_URL = exports.API_PROJECT_OPERATION_URL = exports.API_PROJECT_ROBOT_GAMEPAD_URL = exports.API_PROJECT_ROBOT_TRIGGER_URL = exports.API_PROJECT_ROBOT_BUTTON_URL = exports.API_PROJECT_ROBOT_COMMAND2_URL = exports.API_PROJECT_ROBOT_COMMAND_URL = exports.API_PROJECT_ROBOT_AGENT_URL = exports.API_PROJECT_ROBOT_SETTING_URL = exports.API_PROJECT_ROBOT_EVENT_HISTORY_URL = exports.API_PROJECT_ROBOT_EVENT_URL = void 0;
5
+ exports.API_LINKED_PROJECT_URL = exports.API_PROJECT_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_WORKFLOW_ASSET_URL = exports.API_PROJECT_WORKFLOW_ID_URL = exports.API_PROJECT_WORKFLOW_URL = exports.API_OBSERVATION_KEYS_URL = exports.API_OBSERVATIONS_URL = exports.API_MAPS_PANORAMA_OBSERVATIONS_URL = exports.API_MAPS_GEOJSON_URL = exports.API_MAPS_DEPLOY_URL = exports.API_MAPS_COPY_URL = exports.API_MAP_ID_URL = exports.API_MAPS_MERGE_URL = exports.API_MAPS_DEPLOYED_URL = exports.API_MAPS_URL = exports.API_DD_INTEGRATION_ISSUES_URL = exports.API_DD_INTEGRATION_OVERLAYS_URL = exports.API_DD_INTEGRATION_PLAN_BY_ID_URL = exports.API_DD_INTEGRATION_PLANS_URL = exports.API_SPOTTY_URL = exports.API_PROJECT_SCHEDULES_URL = exports.API_SOURCE_ID_URL = exports.API_SOURCE_URL = exports.API_SOURCE_SCHEMA_URL = exports.API_TEMPLATE_EXPORTER_URL = exports.API_TEMPLATE_PROVISION_ID_URL = exports.API_TEMPLATE_PROVISION_URL = exports.API_TEMPLATE_DEPLOY_URL = exports.API_PROJECT_PROFILE_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_PROFILE_DASHBOARD_ID_URL = exports.API_PROJECT_PROFILE_DASHBOARD_URL = exports.API_PROJECT_CALLSIGN_STREAM_URL = exports.API_PROJECT_ROBOT_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_ROBOT_DASHBOARD_ID_URL = exports.API_PROJECT_ROBOT_DASHBOARD_URL = exports.API_PROJECT_STREAM_CALLSIGN_URL = exports.API_PROJECT_STREAM_DATA_URL = void 0;
6
6
  exports.API_APPLICATION_AUTH_URL = 'https://{url}/applications/auth';
7
7
  exports.API_ADMIN_USER_INVITATION_URL = 'https://{url}/admin/users/invitations';
8
8
  exports.API_USER_URL = 'https://{url}/users';
@@ -87,6 +87,8 @@ exports.API_PROJECT_DEFINITION_ACTION_URL = 'https://{url}/projects/{projectId}/
87
87
  exports.API_PROJECT_DEFINITION_BUTTON_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/buttons';
88
88
  exports.API_PROJECT_DEFINITION_TRIGGER_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/triggers';
89
89
  exports.API_PROJECT_DEFINITION_GAMEPAD_URL = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/gamepads';
90
+ exports.API_PROJECT_DEFINITION_EXPORT = 'https://{url}/projects/{projectId}/robot-definitions/{definitionId}/export';
91
+ exports.API_PROJECT_DEFINITION_IMPORT = 'https://{url}/projects/{projectId}/robot-definitions/import';
90
92
  exports.API_PROJECT_GROUP_TYPE_URL = 'https://{url}/projects/{projectId}/config-groups/{type}';
91
93
  exports.API_PROJECT_GROUP_TYPE_ID_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}';
92
94
  exports.API_PROJECT_GROUP_TYPE_PUBLISH_URL = 'https://{url}/projects/{projectId}/config-groups/{type}/{configGroupId}/publish';
@@ -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 {};
@@ -7,10 +7,15 @@ exports.getUniqueConfigKey = void 0;
7
7
  * @param config - SDK config {@link IRocosSDKConfig}
8
8
  */
9
9
  const getUniqueConfigKey = (config) => {
10
- return Object.keys(config)
10
+ let rootConfig = config;
11
+ if (rootConfig._parentConfig) {
12
+ // assume there is only one level of nesting
13
+ rootConfig = rootConfig._parentConfig;
14
+ }
15
+ return Object.keys(rootConfig)
11
16
  .sort()
12
17
  .map((item) => {
13
- return item !== 'token' ? `${item}:${config[item]}` : false;
18
+ return item !== 'token' ? `${item}:${rootConfig[item]}` : false;
14
19
  })
15
20
  .filter(Boolean)
16
21
  .join();
@@ -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
  *
@@ -348,6 +348,34 @@ class ProfileService extends BaseServiceAbstract_1.BaseServiceAbstract {
348
348
  async getGamepads(projectId, definitionId) {
349
349
  return this.callGet((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_DEFINITION_GAMEPAD_URL, { url: this.config.url, projectId, definitionId }, this.config.insecure), `Failed to get gamepads for ${projectId}, definitionId ${definitionId}.`);
350
350
  }
351
+ /** Export robot definition into JSON format
352
+ *
353
+ * Can be used to import robot definition into another project
354
+ *
355
+ * @param projectId - Project Id
356
+ * @param definitionId - Robot definition Id
357
+ *
358
+ * @see import
359
+ */
360
+ async export(projectId, definitionId) {
361
+ return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_DEFINITION_EXPORT, { url: this.config.url, projectId, definitionId }, this.config.insecure), undefined, `Failed to export robot definition for ${projectId}, definitionId ${definitionId}.`);
362
+ }
363
+ /** Import robot definition from JSON format
364
+ *
365
+ * Accepts a previously exported robot definition
366
+ *
367
+ * @param projectId - Project Id
368
+ * @param profileData - Robot definition data
369
+ * @param newName - Optional new name for the robot definition. If not provided, the name from the imported definition will be used.
370
+ *
371
+ * @see export
372
+ */
373
+ async import(projectId, profileData, newName) {
374
+ if (newName) {
375
+ profileData.name = newName;
376
+ }
377
+ return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_DEFINITION_IMPORT, { url: this.config.url, projectId }, this.config.insecure), profileData, `Failed to import robot definition for ${projectId}.`);
378
+ }
351
379
  /**
352
380
  * Update gamepads for a robot definition
353
381
  *
@@ -54,7 +54,7 @@ export declare class RTPWebRTCService extends BaseServiceAbstract implements IBa
54
54
  *
55
55
  * If `logLevel` is set to trace, the connection will emit all messages as events
56
56
  */
57
- createPeerConnection(params: PeerConnectionParams): WebRTCConnection;
57
+ createPeerConnection(params: PeerConnectionParams): Promise<WebRTCConnection>;
58
58
  }
59
59
  export declare class WebRTCConnection {
60
60
  private pc?;
@@ -4,6 +4,7 @@ exports.WebRTCConnection = exports.RTPWebRTCService = exports.WebRTCEventType =
4
4
  const models_1 = require("../models");
5
5
  const rxjs_1 = require("rxjs");
6
6
  const BaseServiceAbstract_1 = require("./BaseServiceAbstract");
7
+ const RocosStore_1 = require("../store/RocosStore");
7
8
  const splitRobotTopic_1 = require("../helpers/splitRobotTopic");
8
9
  var WebRTCEventType;
9
10
  (function (WebRTCEventType) {
@@ -36,16 +37,17 @@ class RTPWebRTCService extends BaseServiceAbstract_1.BaseServiceAbstract {
36
37
  *
37
38
  * If `logLevel` is set to trace, the connection will emit all messages as events
38
39
  */
39
- createPeerConnection(params) {
40
+ async createPeerConnection(params) {
40
41
  const isInsecure = this.config.insecure ?? false;
41
42
  const port = this.config.port ?? (isInsecure ? 80 : 443);
43
+ const token = (await RocosStore_1.RocosStore.getSDKInstance(this.config).getAuthService().getToken()).value;
42
44
  return new WebRTCConnection({
43
45
  endpoint: {
44
46
  host: this.config.url,
45
47
  port,
46
48
  insecure: isInsecure,
47
49
  },
48
- token: this.config.token,
50
+ token,
49
51
  projectId: params.projectId,
50
52
  callsign: params.callsign,
51
53
  logLevel: params.logLevel,
@@ -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$?;
package/esm/RocosSDK.d.ts CHANGED
@@ -145,5 +145,7 @@ 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
+ protected overrideConfig(service: ServiceEnum): AuthorisedConfig & {
149
+ _parentConfig?: IRocosSDKConfig;
150
+ };
149
151
  }
package/esm/RocosSDK.js CHANGED
@@ -319,6 +319,7 @@ export class RocosSDK {
319
319
  return {
320
320
  ...config,
321
321
  ...this.config.overrides?.[service],
322
+ _parentConfig: this.config,
322
323
  };
323
324
  }
324
325
  }
@@ -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) {