@dronedeploy/rocos-js-sdk 3.0.1-alpha.9 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (373) hide show
  1. package/README.md +59 -29
  2. package/cjs/IRocosSDK.d.ts +4 -3
  3. package/cjs/RocosSDK.d.ts +19 -7
  4. package/cjs/RocosSDK.js +31 -10
  5. package/cjs/api/streams/caller/CallerStream.js +5 -2
  6. package/cjs/api/streams/caller/CallerStreamNode.js +2 -1
  7. package/cjs/api/streams/command/CommandStream.js +5 -2
  8. package/cjs/api/streams/command/CommandStreamNode.js +2 -1
  9. package/cjs/api/streams/control/ControlStream.js +5 -2
  10. package/cjs/api/streams/control/ControlStreamAbstract.d.ts +1 -1
  11. package/cjs/api/streams/control/ControlStreamNode.js +2 -1
  12. package/cjs/api/streams/fileAccessor/FileAccessorStream.js +4 -1
  13. package/cjs/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
  14. package/cjs/api/streams/search/SearchStream.js +5 -2
  15. package/cjs/api/streams/search/SearchStreamNode.js +2 -1
  16. package/cjs/api/streams/telemetry/TelemetryStream.js +4 -1
  17. package/cjs/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
  18. package/cjs/api/streams/telemetry/TelemetryStreamNode.js +2 -1
  19. package/cjs/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
  20. package/cjs/constants/api.d.ts +31 -15
  21. package/cjs/constants/api.js +35 -18
  22. package/cjs/helpers/cleanObject.js +4 -1
  23. package/cjs/helpers/getUniqueConfigKey.d.ts +6 -2
  24. package/cjs/helpers/getUniqueConfigKey.js +7 -2
  25. package/cjs/helpers/index.d.ts +1 -0
  26. package/cjs/helpers/index.js +1 -0
  27. package/cjs/helpers/kscript/Context.d.ts +34 -0
  28. package/cjs/helpers/kscript/Context.js +52 -0
  29. package/cjs/helpers/kscript/index.d.ts +1 -0
  30. package/cjs/helpers/kscript/index.js +27 -0
  31. package/cjs/helpers/kscript/kscript.d.ts +6 -0
  32. package/cjs/helpers/kscript/kscript.js +115 -0
  33. package/cjs/helpers/kscript/nodes/Identifier.d.ts +12 -0
  34. package/cjs/helpers/kscript/nodes/Identifier.js +20 -0
  35. package/cjs/helpers/kscript/nodes/Literal.d.ts +11 -0
  36. package/cjs/helpers/kscript/nodes/Literal.js +22 -0
  37. package/cjs/helpers/kscript/nodes/Node.d.ts +9 -0
  38. package/cjs/helpers/kscript/nodes/Node.js +15 -0
  39. package/cjs/helpers/kscript/nodes/Program.d.ts +11 -0
  40. package/cjs/helpers/kscript/nodes/Program.js +24 -0
  41. package/cjs/helpers/kscript/nodes/TemplateLiteral.d.ts +23 -0
  42. package/cjs/helpers/kscript/nodes/TemplateLiteral.js +35 -0
  43. package/cjs/helpers/kscript/nodes/expressions/ArrayExpression.d.ts +7 -0
  44. package/cjs/helpers/kscript/nodes/expressions/ArrayExpression.js +31 -0
  45. package/cjs/helpers/kscript/nodes/expressions/ArrowFunctionExpression.d.ts +14 -0
  46. package/cjs/helpers/kscript/nodes/expressions/ArrowFunctionExpression.js +40 -0
  47. package/cjs/helpers/kscript/nodes/expressions/BinaryExpression.d.ts +16 -0
  48. package/cjs/helpers/kscript/nodes/expressions/BinaryExpression.js +104 -0
  49. package/cjs/helpers/kscript/nodes/expressions/CallExpression.d.ts +8 -0
  50. package/cjs/helpers/kscript/nodes/expressions/CallExpression.js +38 -0
  51. package/cjs/helpers/kscript/nodes/expressions/ChainExpression.d.ts +16 -0
  52. package/cjs/helpers/kscript/nodes/expressions/ChainExpression.js +25 -0
  53. package/cjs/helpers/kscript/nodes/expressions/ConditionalExpression.d.ts +14 -0
  54. package/cjs/helpers/kscript/nodes/expressions/ConditionalExpression.js +30 -0
  55. package/cjs/helpers/kscript/nodes/expressions/ExpressionStatement.d.ts +7 -0
  56. package/cjs/helpers/kscript/nodes/expressions/ExpressionStatement.js +18 -0
  57. package/cjs/helpers/kscript/nodes/expressions/LogicalExpression.d.ts +10 -0
  58. package/cjs/helpers/kscript/nodes/expressions/LogicalExpression.js +47 -0
  59. package/cjs/helpers/kscript/nodes/expressions/MemberExpression.d.ts +44 -0
  60. package/cjs/helpers/kscript/nodes/expressions/MemberExpression.js +98 -0
  61. package/cjs/helpers/kscript/nodes/expressions/ObjectExpression.d.ts +11 -0
  62. package/cjs/helpers/kscript/nodes/expressions/ObjectExpression.js +59 -0
  63. package/cjs/helpers/kscript/nodes/expressions/UnaryExpression.d.ts +12 -0
  64. package/cjs/helpers/kscript/nodes/expressions/UnaryExpression.js +44 -0
  65. package/cjs/helpers/kscript/nodes/expressions/index.d.ts +11 -0
  66. package/cjs/helpers/kscript/nodes/expressions/index.js +28 -0
  67. package/cjs/helpers/kscript/nodes/index.d.ts +4 -0
  68. package/cjs/helpers/kscript/nodes/index.js +10 -0
  69. package/cjs/helpers/kscript/nodes/nodeTypes.d.ts +33 -0
  70. package/cjs/helpers/kscript/nodes/nodeTypes.js +29 -0
  71. package/cjs/helpers/kscript/utils.d.ts +4 -0
  72. package/cjs/helpers/kscript/utils.js +15 -0
  73. package/cjs/helpers/websandbox/connection.d.ts +2 -1
  74. package/cjs/helpers/websandbox/connection.js +6 -5
  75. package/cjs/helpers/websandbox/frame/frame.js +4 -1
  76. package/cjs/helpers/websandbox/frame/frame.source.js +1 -1
  77. package/cjs/helpers/websandbox/frame/worker/manager.d.ts +8 -4
  78. package/cjs/helpers/websandbox/frame/worker/manager.js +32 -14
  79. package/cjs/helpers/websandbox/frame/worker/worker.source.js +1 -1
  80. package/cjs/helpers/websandbox/sandbox.d.ts +1 -1
  81. package/cjs/helpers/websandbox/sandbox.js +7 -7
  82. package/cjs/models/IConnectedCallsign.d.ts +10 -0
  83. package/cjs/models/IConnectedCallsign.js +8 -0
  84. package/cjs/models/RocosError.d.ts +3 -0
  85. package/cjs/models/RocosError.js +3 -0
  86. package/cjs/models/ServiceEnum.d.ts +20 -17
  87. package/cjs/models/ServiceEnum.js +20 -17
  88. package/cjs/models/TelemetryStatus.d.ts +12 -0
  89. package/cjs/models/TelemetryStatus.js +17 -0
  90. package/cjs/models/Token.d.ts +2 -2
  91. package/cjs/models/Token.js +5 -5
  92. package/cjs/models/asset-storage/{AssetModelItem.d.ts → AssetItem.d.ts} +2 -0
  93. package/cjs/models/device-credentials/DeviceCredentials.d.ts +61 -0
  94. package/cjs/models/device-credentials/DeviceCredentials.js +2 -0
  95. package/cjs/models/graph/Position.d.ts +6 -0
  96. package/cjs/models/graph/Position.js +2 -0
  97. package/cjs/models/graph/Quaternion.d.ts +6 -0
  98. package/cjs/models/graph/Quaternion.js +2 -0
  99. package/cjs/models/graph/Vector3.d.ts +5 -0
  100. package/cjs/models/graph/Vector3.js +2 -0
  101. package/cjs/models/graph/index.d.ts +3 -0
  102. package/cjs/models/graph/index.js +19 -0
  103. package/cjs/models/index.d.ts +9 -2
  104. package/cjs/models/index.js +9 -2
  105. package/cjs/models/integrations/Location.d.ts +24 -0
  106. package/cjs/models/integrations/Location.js +2 -0
  107. package/cjs/models/integrations/PaginatedResults.d.ts +4 -0
  108. package/cjs/models/integrations/PaginatedResults.js +2 -0
  109. package/cjs/models/maps/Panorama.d.ts +12 -21
  110. package/cjs/models/projects/ExternalProject.d.ts +10 -0
  111. package/cjs/models/projects/ExternalProject.js +2 -0
  112. package/cjs/models/projects/NewProjectRequest.d.ts +8 -0
  113. package/cjs/models/projects/NewProjectRequest.js +2 -0
  114. package/cjs/models/target/Target.d.ts +30 -0
  115. package/cjs/models/target/Target.js +15 -0
  116. package/cjs/node/RocosSDKNode.d.ts +1 -5
  117. package/cjs/node/RocosSDKNode.js +9 -9
  118. package/cjs/services/AssetStorageService.d.ts +9 -1
  119. package/cjs/services/AssetStorageService.js +12 -1
  120. package/cjs/services/AuthService.d.ts +12 -1
  121. package/cjs/services/AuthService.js +25 -1
  122. package/cjs/services/DeviceCredentialsService.d.ts +15 -0
  123. package/cjs/services/DeviceCredentialsService.js +56 -0
  124. package/cjs/services/EnvironmentService.d.ts +34 -0
  125. package/cjs/services/EnvironmentService.js +56 -0
  126. package/cjs/services/EvaluatorService.js +1 -1
  127. package/cjs/services/IntegrationService.d.ts +7 -1
  128. package/cjs/services/IntegrationService.js +8 -0
  129. package/cjs/services/MapService.d.ts +18 -8
  130. package/cjs/services/MapService.js +37 -19
  131. package/cjs/services/ProfileService.d.ts +24 -0
  132. package/cjs/services/ProfileService.js +34 -0
  133. package/cjs/services/ProjectService.d.ts +7 -2
  134. package/cjs/services/ProjectService.js +7 -3
  135. package/cjs/services/RTPWebRTCService.d.ts +6 -1
  136. package/cjs/services/RTPWebRTCService.js +10 -2
  137. package/cjs/services/RobotService.d.ts +3 -1
  138. package/cjs/services/RobotService.js +6 -0
  139. package/cjs/services/SpotProvisioningService.d.ts +1 -1
  140. package/cjs/services/SpotProvisioningServiceNode.d.ts +1 -1
  141. package/cjs/services/TargetService.d.ts +17 -0
  142. package/cjs/services/TargetService.js +66 -0
  143. package/cjs/services/TelemetryService.d.ts +10 -1
  144. package/cjs/services/TelemetryService.js +27 -5
  145. package/cjs/services/WorkflowService.d.ts +18 -8
  146. package/cjs/services/WorkflowService.js +37 -11
  147. package/cjs/services/index.d.ts +11 -9
  148. package/cjs/services/index.js +11 -9
  149. package/cjs/store/RocosStore.d.ts +1 -2
  150. package/esm/IRocosSDK.d.ts +4 -3
  151. package/esm/RocosSDK.d.ts +19 -7
  152. package/esm/RocosSDK.js +32 -11
  153. package/esm/api/streams/caller/CallerStream.js +5 -2
  154. package/esm/api/streams/caller/CallerStreamNode.js +2 -1
  155. package/esm/api/streams/command/CommandStream.js +5 -2
  156. package/esm/api/streams/command/CommandStreamNode.js +2 -1
  157. package/esm/api/streams/control/ControlStream.js +5 -2
  158. package/esm/api/streams/control/ControlStreamAbstract.d.ts +1 -1
  159. package/esm/api/streams/control/ControlStreamNode.js +2 -1
  160. package/esm/api/streams/fileAccessor/FileAccessorStream.js +4 -1
  161. package/esm/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
  162. package/esm/api/streams/search/SearchStream.js +5 -2
  163. package/esm/api/streams/search/SearchStreamNode.js +2 -1
  164. package/esm/api/streams/telemetry/TelemetryStream.js +4 -1
  165. package/esm/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
  166. package/esm/api/streams/telemetry/TelemetryStreamNode.js +2 -1
  167. package/esm/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
  168. package/esm/constants/api.d.ts +31 -15
  169. package/esm/constants/api.js +31 -15
  170. package/esm/helpers/cleanObject.js +4 -1
  171. package/esm/helpers/getUniqueConfigKey.d.ts +6 -2
  172. package/esm/helpers/getUniqueConfigKey.js +7 -2
  173. package/esm/helpers/index.d.ts +1 -0
  174. package/esm/helpers/index.js +1 -0
  175. package/esm/helpers/kscript/Context.d.ts +34 -0
  176. package/esm/helpers/kscript/Context.js +49 -0
  177. package/esm/helpers/kscript/index.d.ts +1 -0
  178. package/esm/helpers/kscript/index.js +1 -0
  179. package/esm/helpers/kscript/kscript.d.ts +6 -0
  180. package/esm/helpers/kscript/kscript.js +107 -0
  181. package/esm/helpers/kscript/nodes/Identifier.d.ts +12 -0
  182. package/esm/helpers/kscript/nodes/Identifier.js +14 -0
  183. package/esm/helpers/kscript/nodes/Literal.d.ts +11 -0
  184. package/esm/helpers/kscript/nodes/Literal.js +16 -0
  185. package/esm/helpers/kscript/nodes/Node.d.ts +9 -0
  186. package/esm/helpers/kscript/nodes/Node.js +12 -0
  187. package/esm/helpers/kscript/nodes/Program.d.ts +11 -0
  188. package/esm/helpers/kscript/nodes/Program.js +18 -0
  189. package/esm/helpers/kscript/nodes/TemplateLiteral.d.ts +23 -0
  190. package/esm/helpers/kscript/nodes/TemplateLiteral.js +29 -0
  191. package/esm/helpers/kscript/nodes/expressions/ArrayExpression.d.ts +7 -0
  192. package/esm/helpers/kscript/nodes/expressions/ArrayExpression.js +25 -0
  193. package/esm/helpers/kscript/nodes/expressions/ArrowFunctionExpression.d.ts +14 -0
  194. package/esm/helpers/kscript/nodes/expressions/ArrowFunctionExpression.js +34 -0
  195. package/esm/helpers/kscript/nodes/expressions/BinaryExpression.d.ts +16 -0
  196. package/esm/helpers/kscript/nodes/expressions/BinaryExpression.js +98 -0
  197. package/esm/helpers/kscript/nodes/expressions/CallExpression.d.ts +8 -0
  198. package/esm/helpers/kscript/nodes/expressions/CallExpression.js +32 -0
  199. package/esm/helpers/kscript/nodes/expressions/ChainExpression.d.ts +16 -0
  200. package/esm/helpers/kscript/nodes/expressions/ChainExpression.js +19 -0
  201. package/esm/helpers/kscript/nodes/expressions/ConditionalExpression.d.ts +14 -0
  202. package/esm/helpers/kscript/nodes/expressions/ConditionalExpression.js +24 -0
  203. package/esm/helpers/kscript/nodes/expressions/ExpressionStatement.d.ts +7 -0
  204. package/esm/helpers/kscript/nodes/expressions/ExpressionStatement.js +12 -0
  205. package/esm/helpers/kscript/nodes/expressions/LogicalExpression.d.ts +10 -0
  206. package/esm/helpers/kscript/nodes/expressions/LogicalExpression.js +41 -0
  207. package/esm/helpers/kscript/nodes/expressions/MemberExpression.d.ts +44 -0
  208. package/esm/helpers/kscript/nodes/expressions/MemberExpression.js +92 -0
  209. package/esm/helpers/kscript/nodes/expressions/ObjectExpression.d.ts +11 -0
  210. package/esm/helpers/kscript/nodes/expressions/ObjectExpression.js +53 -0
  211. package/esm/helpers/kscript/nodes/expressions/UnaryExpression.d.ts +12 -0
  212. package/esm/helpers/kscript/nodes/expressions/UnaryExpression.js +38 -0
  213. package/esm/helpers/kscript/nodes/expressions/index.d.ts +11 -0
  214. package/esm/helpers/kscript/nodes/expressions/index.js +11 -0
  215. package/esm/helpers/kscript/nodes/index.d.ts +4 -0
  216. package/esm/helpers/kscript/nodes/index.js +3 -0
  217. package/esm/helpers/kscript/nodes/nodeTypes.d.ts +33 -0
  218. package/esm/helpers/kscript/nodes/nodeTypes.js +24 -0
  219. package/esm/helpers/kscript/utils.d.ts +4 -0
  220. package/esm/helpers/kscript/utils.js +11 -0
  221. package/esm/helpers/websandbox/connection.d.ts +2 -1
  222. package/esm/helpers/websandbox/connection.js +6 -5
  223. package/esm/helpers/websandbox/frame/frame.js +4 -1
  224. package/esm/helpers/websandbox/frame/frame.source.js +1 -1
  225. package/esm/helpers/websandbox/frame/worker/manager.d.ts +8 -4
  226. package/esm/helpers/websandbox/frame/worker/manager.js +32 -14
  227. package/esm/helpers/websandbox/frame/worker/worker.source.js +1 -1
  228. package/esm/helpers/websandbox/sandbox.d.ts +1 -1
  229. package/esm/helpers/websandbox/sandbox.js +7 -7
  230. package/esm/models/IConnectedCallsign.d.ts +10 -0
  231. package/esm/models/IConnectedCallsign.js +5 -0
  232. package/esm/models/RocosError.d.ts +3 -0
  233. package/esm/models/RocosError.js +3 -0
  234. package/esm/models/ServiceEnum.d.ts +20 -17
  235. package/esm/models/ServiceEnum.js +20 -17
  236. package/esm/models/TelemetryStatus.d.ts +12 -0
  237. package/esm/models/TelemetryStatus.js +14 -0
  238. package/esm/models/Token.d.ts +2 -2
  239. package/esm/models/Token.js +5 -5
  240. package/esm/models/asset-storage/{AssetModelItem.d.ts → AssetItem.d.ts} +2 -0
  241. package/esm/models/device-credentials/DeviceCredentials.d.ts +61 -0
  242. package/esm/models/graph/Position.d.ts +6 -0
  243. package/esm/models/graph/Quaternion.d.ts +6 -0
  244. package/esm/models/graph/Vector3.d.ts +5 -0
  245. package/esm/models/graph/index.d.ts +3 -0
  246. package/esm/models/graph/index.js +3 -0
  247. package/esm/models/index.d.ts +9 -2
  248. package/esm/models/index.js +9 -2
  249. package/esm/models/integrations/Location.d.ts +24 -0
  250. package/esm/models/integrations/PaginatedResults.d.ts +4 -0
  251. package/esm/models/maps/Panorama.d.ts +12 -21
  252. package/esm/models/projects/ExternalProject.d.ts +10 -0
  253. package/esm/models/projects/NewProjectRequest.d.ts +8 -0
  254. package/esm/models/target/Target.d.ts +30 -0
  255. package/esm/models/target/Target.js +9 -0
  256. package/esm/node/RocosSDKNode.d.ts +1 -5
  257. package/esm/node/RocosSDKNode.js +10 -10
  258. package/esm/services/AssetStorageService.d.ts +9 -1
  259. package/esm/services/AssetStorageService.js +13 -2
  260. package/esm/services/AuthService.d.ts +12 -1
  261. package/esm/services/AuthService.js +25 -1
  262. package/esm/services/BaseServiceAbstract.js +1 -1
  263. package/esm/services/DeviceCredentialsService.d.ts +15 -0
  264. package/esm/services/DeviceCredentialsService.js +52 -0
  265. package/esm/services/EnvironmentService.d.ts +34 -0
  266. package/esm/services/EnvironmentService.js +52 -0
  267. package/esm/services/EvaluatorService.js +1 -1
  268. package/esm/services/IntegrationService.d.ts +7 -1
  269. package/esm/services/IntegrationService.js +10 -2
  270. package/esm/services/MapService.d.ts +18 -8
  271. package/esm/services/MapService.js +38 -20
  272. package/esm/services/ProfileService.d.ts +24 -0
  273. package/esm/services/ProfileService.js +35 -1
  274. package/esm/services/ProjectService.d.ts +7 -2
  275. package/esm/services/ProjectService.js +9 -5
  276. package/esm/services/RTPWebRTCService.d.ts +6 -1
  277. package/esm/services/RTPWebRTCService.js +10 -2
  278. package/esm/services/RobotService.d.ts +3 -1
  279. package/esm/services/RobotService.js +8 -2
  280. package/esm/services/SpotProvisioningService.d.ts +1 -1
  281. package/esm/services/SpotProvisioningServiceNode.d.ts +1 -1
  282. package/esm/services/TargetService.d.ts +17 -0
  283. package/esm/services/TargetService.js +62 -0
  284. package/esm/services/TelemetryService.d.ts +10 -1
  285. package/esm/services/TelemetryService.js +28 -6
  286. package/esm/services/WorkflowService.d.ts +18 -8
  287. package/esm/services/WorkflowService.js +38 -12
  288. package/esm/services/index.d.ts +11 -9
  289. package/esm/services/index.js +11 -9
  290. package/esm/store/RocosStore.d.ts +1 -2
  291. package/package.json +2 -2
  292. package/cjs/helpers/cleanObject.spec.js +0 -55
  293. package/cjs/helpers/flattenObject.spec.js +0 -31
  294. package/cjs/helpers/flattenOneOf.spec.js +0 -159
  295. package/cjs/helpers/formatServiceUrl.spec.js +0 -18
  296. package/cjs/helpers/getSha256Hex.spec.js +0 -19
  297. package/cjs/helpers/getSha256HexNode.spec.js +0 -10
  298. package/cjs/helpers/getURLSearchParams.spec.js +0 -21
  299. package/cjs/helpers/nanosecondToMillisecond.spec.js +0 -22
  300. package/cjs/helpers/splitRobotTopic.spec.js +0 -53
  301. package/cjs/helpers/standardDeviation.spec.d.ts +0 -1
  302. package/cjs/helpers/standardDeviation.spec.js +0 -13
  303. package/cjs/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
  304. package/cjs/helpers/websandbox/frame/worker/manager.spec.js +0 -132
  305. package/cjs/models/CallsignStatus.d.ts +0 -6
  306. package/cjs/models/CallsignStatus.js +0 -10
  307. package/cjs/models/ExternalProject.d.ts +0 -6
  308. package/cjs/models/ExternalProject.js +0 -6
  309. package/cjs/models/Token.spec.d.ts +0 -1
  310. package/cjs/models/Token.spec.js +0 -110
  311. package/cjs/services/AuthService.spec.d.ts +0 -1
  312. package/cjs/services/AuthService.spec.js +0 -165
  313. package/cjs/services/CallerService.spec.d.ts +0 -1
  314. package/cjs/services/CallerService.spec.js +0 -229
  315. package/cjs/services/FunctionService.d.ts +0 -68
  316. package/cjs/services/FunctionService.js +0 -103
  317. package/cjs/services/PlatformTimeService.spec.d.ts +0 -1
  318. package/cjs/services/PlatformTimeService.spec.js +0 -182
  319. package/cjs/services/RTPWebRTCService.spec.d.ts +0 -4
  320. package/cjs/services/RTPWebRTCService.spec.js +0 -171
  321. package/cjs/services/TelemetryService.spec.d.ts +0 -1
  322. package/cjs/services/TelemetryService.spec.js +0 -39
  323. package/esm/helpers/cleanObject.spec.d.ts +0 -1
  324. package/esm/helpers/cleanObject.spec.js +0 -53
  325. package/esm/helpers/flattenObject.spec.d.ts +0 -1
  326. package/esm/helpers/flattenObject.spec.js +0 -29
  327. package/esm/helpers/flattenOneOf.spec.d.ts +0 -1
  328. package/esm/helpers/flattenOneOf.spec.js +0 -157
  329. package/esm/helpers/formatServiceUrl.spec.d.ts +0 -1
  330. package/esm/helpers/formatServiceUrl.spec.js +0 -16
  331. package/esm/helpers/getSha256Hex.spec.d.ts +0 -1
  332. package/esm/helpers/getSha256Hex.spec.js +0 -14
  333. package/esm/helpers/getSha256HexNode.spec.d.ts +0 -1
  334. package/esm/helpers/getSha256HexNode.spec.js +0 -8
  335. package/esm/helpers/getURLSearchParams.spec.d.ts +0 -1
  336. package/esm/helpers/getURLSearchParams.spec.js +0 -19
  337. package/esm/helpers/nanosecondToMillisecond.spec.d.ts +0 -1
  338. package/esm/helpers/nanosecondToMillisecond.spec.js +0 -20
  339. package/esm/helpers/splitRobotTopic.spec.d.ts +0 -1
  340. package/esm/helpers/splitRobotTopic.spec.js +0 -51
  341. package/esm/helpers/standardDeviation.spec.d.ts +0 -1
  342. package/esm/helpers/standardDeviation.spec.js +0 -11
  343. package/esm/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
  344. package/esm/helpers/websandbox/frame/worker/manager.spec.js +0 -127
  345. package/esm/models/CallsignStatus.d.ts +0 -6
  346. package/esm/models/CallsignStatus.js +0 -7
  347. package/esm/models/ExternalProject.d.ts +0 -6
  348. package/esm/models/ExternalProject.js +0 -2
  349. package/esm/models/Token.spec.d.ts +0 -1
  350. package/esm/models/Token.spec.js +0 -108
  351. package/esm/models/asset-storage/AssetModelItem.js +0 -1
  352. package/esm/services/AuthService.spec.d.ts +0 -1
  353. package/esm/services/AuthService.spec.js +0 -163
  354. package/esm/services/CallerService.spec.d.ts +0 -1
  355. package/esm/services/CallerService.spec.js +0 -227
  356. package/esm/services/FunctionService.d.ts +0 -68
  357. package/esm/services/FunctionService.js +0 -99
  358. package/esm/services/PlatformTimeService.spec.d.ts +0 -1
  359. package/esm/services/PlatformTimeService.spec.js +0 -180
  360. package/esm/services/RTPWebRTCService.spec.d.ts +0 -4
  361. package/esm/services/RTPWebRTCService.spec.js +0 -169
  362. package/esm/services/TelemetryService.spec.d.ts +0 -1
  363. package/esm/services/TelemetryService.spec.js +0 -37
  364. /package/cjs/models/asset-storage/{AssetModelItem.js → AssetItem.js} +0 -0
  365. /package/{cjs/helpers/cleanObject.spec.d.ts → esm/models/asset-storage/AssetItem.js} +0 -0
  366. /package/{cjs/helpers/flattenObject.spec.d.ts → esm/models/device-credentials/DeviceCredentials.js} +0 -0
  367. /package/{cjs/helpers/flattenOneOf.spec.d.ts → esm/models/graph/Position.js} +0 -0
  368. /package/{cjs/helpers/formatServiceUrl.spec.d.ts → esm/models/graph/Quaternion.js} +0 -0
  369. /package/{cjs/helpers/getSha256Hex.spec.d.ts → esm/models/graph/Vector3.js} +0 -0
  370. /package/{cjs/helpers/getSha256HexNode.spec.d.ts → esm/models/integrations/Location.js} +0 -0
  371. /package/{cjs/helpers/getURLSearchParams.spec.d.ts → esm/models/integrations/PaginatedResults.js} +0 -0
  372. /package/{cjs/helpers/nanosecondToMillisecond.spec.d.ts → esm/models/projects/ExternalProject.js} +0 -0
  373. /package/{cjs/helpers/splitRobotTopic.spec.d.ts → esm/models/projects/NewProjectRequest.js} +0 -0
@@ -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
  }
@@ -1,3 +1,4 @@
1
+ import { Observation } from '../maps/Panorama';
1
2
  export interface AssetItemModel {
2
3
  metadata?: {
3
4
  [key: string]: string;
@@ -11,4 +12,5 @@ export interface AssetItemModel {
11
12
  }
12
13
  export interface AssetItemWithObservationsModel extends AssetItemModel {
13
14
  observationCount?: number;
15
+ observations?: Observation[];
14
16
  }
@@ -0,0 +1,61 @@
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
+ secret?: 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
+ * Access control list for the credentials
35
+ */
36
+ acl?: DeviceCredentialACLItem[];
37
+ }
38
+ export interface DeviceCredentialACLItem {
39
+ /**
40
+ * The resource the ACL item is for e.g. /sys/product/{device_sn}/*
41
+ */
42
+ resource: string;
43
+ /**
44
+ * The action the ACL item is for e.g. allow, deny, ignore
45
+ */
46
+ action: DeviceCredentialAuthAction;
47
+ }
48
+ export type DeviceCredentialAuthAction = 'allow' | 'deny' | 'ignore';
49
+ export interface DeviceCredentialAuth extends DeviceCredential {
50
+ /**
51
+ * The agent component the credentials are for e.g. dji, spot, etc.
52
+ */
53
+ component: string;
54
+ /**
55
+ * The system the credentials are for e.g. mqtt, rtmp, etc.
56
+ */
57
+ system: string;
58
+ }
59
+ export interface DeviceCredentialAuthResult {
60
+ result: 'allow' | 'deny';
61
+ }
@@ -0,0 +1,6 @@
1
+ export interface Position {
2
+ pitch: number;
3
+ yaw: number;
4
+ x?: number;
5
+ y?: number;
6
+ }
@@ -0,0 +1,6 @@
1
+ export interface Quaternion {
2
+ x: number;
3
+ y: number;
4
+ z: number;
5
+ w: number;
6
+ }
@@ -0,0 +1,5 @@
1
+ export interface Vector3 {
2
+ x: number;
3
+ y: number;
4
+ z: number;
5
+ }
@@ -0,0 +1,3 @@
1
+ export * from './Position';
2
+ export * from './Quaternion';
3
+ export * from './Vector3';
@@ -0,0 +1,3 @@
1
+ export * from './Position';
2
+ export * from './Quaternion';
3
+ export * from './Vector3';
@@ -1,4 +1,4 @@
1
- export * from './asset-storage/AssetModelItem';
1
+ export * from './asset-storage/AssetItem';
2
2
  export * from './asset-storage/SyncIntegrations';
3
3
  export * from './schedule/IScheduleInfo';
4
4
  export * from './schedule/IScheduleAction';
@@ -30,13 +30,19 @@ export * from './stream/ITelemetryStream';
30
30
  export * from './stream/IWebRTCSignallingStream';
31
31
  export * from './integrations/Overlay';
32
32
  export * from './integrations/Plan';
33
+ export * from './integrations/Location';
34
+ export * from './integrations/PaginatedResults';
33
35
  export * from './maps/Map';
36
+ export * from './maps/Panorama';
34
37
  export * from './projects/ProjectUser';
35
- export * from './CallsignStatus';
38
+ export * from './projects/ExternalProject';
39
+ export * from './projects/NewProjectRequest';
40
+ export * from './target/Target';
36
41
  export * from './ExportDataQuery';
37
42
  export * from './HttpError';
38
43
  export * from './IBaseService';
39
44
  export * from './IConfigGroup';
45
+ export * from './IConnectedCallsign';
40
46
  export * from './IDebugLevel';
41
47
  export * from './IExportDataQuery';
42
48
  export * from './IFunctionConfig';
@@ -72,6 +78,7 @@ export * from './Stream';
72
78
  export * from './StreamOptions';
73
79
  export * from './StreamSource';
74
80
  export * from './SubscriberStatusEnum';
81
+ export * from './TelemetryStatus';
75
82
  export * from './Token';
76
83
  export * from './types';
77
84
  export * from './Widget';
@@ -1,4 +1,4 @@
1
- export * from './asset-storage/AssetModelItem';
1
+ export * from './asset-storage/AssetItem';
2
2
  export * from './asset-storage/SyncIntegrations';
3
3
  export * from './schedule/IScheduleInfo';
4
4
  export * from './schedule/IScheduleAction';
@@ -30,13 +30,19 @@ export * from './stream/ITelemetryStream';
30
30
  export * from './stream/IWebRTCSignallingStream';
31
31
  export * from './integrations/Overlay';
32
32
  export * from './integrations/Plan';
33
+ export * from './integrations/Location';
34
+ export * from './integrations/PaginatedResults';
33
35
  export * from './maps/Map';
36
+ export * from './maps/Panorama';
34
37
  export * from './projects/ProjectUser';
35
- export * from './CallsignStatus';
38
+ export * from './projects/ExternalProject';
39
+ export * from './projects/NewProjectRequest';
40
+ export * from './target/Target';
36
41
  export * from './ExportDataQuery';
37
42
  export * from './HttpError';
38
43
  export * from './IBaseService';
39
44
  export * from './IConfigGroup';
45
+ export * from './IConnectedCallsign';
40
46
  export * from './IDebugLevel';
41
47
  export * from './IExportDataQuery';
42
48
  export * from './IFunctionConfig';
@@ -72,6 +78,7 @@ export * from './Stream';
72
78
  export * from './StreamOptions';
73
79
  export * from './StreamSource';
74
80
  export * from './SubscriberStatusEnum';
81
+ export * from './TelemetryStatus';
75
82
  export * from './Token';
76
83
  export * from './types';
77
84
  export * from './Widget';
@@ -0,0 +1,24 @@
1
+ export interface Location {
2
+ id: string;
3
+ name: string;
4
+ level?: {
5
+ id: string;
6
+ };
7
+ locationType?: {
8
+ id: string;
9
+ name: string;
10
+ };
11
+ shape: {
12
+ coordinates: Array<{
13
+ lat: number;
14
+ lng: number;
15
+ }>;
16
+ radiusMeters?: number;
17
+ shapeType: string;
18
+ };
19
+ shapeStyle: {
20
+ fillColor: string;
21
+ strokeColor: string;
22
+ fillOpacity: number;
23
+ };
24
+ }
@@ -0,0 +1,4 @@
1
+ export interface PaginatedResults<T> {
2
+ results: T[];
3
+ next?: string;
4
+ }
@@ -1,28 +1,18 @@
1
- export interface Position {
2
- pitch: number;
3
- yaw: number;
4
- x?: number;
5
- y?: number;
6
- }
7
- export interface Quaternion {
8
- x: number;
9
- y: number;
10
- z: number;
11
- w: number;
12
- }
13
- export interface Vector3 {
14
- x: number;
15
- y: number;
16
- z: number;
17
- }
18
- export interface Observation {
1
+ import { Position, Quaternion, Vector3 } from '../graph';
2
+ interface ObservationBase {
3
+ name: string;
19
4
  panoramaID: string;
20
- id?: string;
21
- name?: string;
5
+ assetID?: string;
6
+ type?: 'asset' | 'target';
22
7
  data?: Record<string, string>;
23
- geometry: Position[];
8
+ geometry?: Position[];
24
9
  center?: Position;
25
10
  }
11
+ export interface Observation extends ObservationBase {
12
+ id: string;
13
+ }
14
+ export interface CreateObservation extends ObservationBase {
15
+ }
26
16
  export interface Panorama {
27
17
  transform: {
28
18
  parent: string;
@@ -34,3 +24,4 @@ export interface Panorama {
34
24
  path: string;
35
25
  };
36
26
  }
27
+ export {};
@@ -0,0 +1,10 @@
1
+ export interface ExternalProject {
2
+ id: string;
3
+ name: string;
4
+ isLinked: boolean;
5
+ createdAt?: number;
6
+ location?: {
7
+ lng: number;
8
+ lat: number;
9
+ };
10
+ }
@@ -0,0 +1,8 @@
1
+ export interface NewProjectRequest {
2
+ accountId: string;
3
+ projectName: string;
4
+ description?: string;
5
+ linkedProjectId?: string;
6
+ lat?: number;
7
+ lng?: number;
8
+ }
@@ -0,0 +1,30 @@
1
+ import { Quaternion } from '../graph/Quaternion';
2
+ import { Vector3 } from '../graph/Vector3';
3
+ export interface TargetBase {
4
+ id: string;
5
+ name: string;
6
+ data?: Record<string, string>;
7
+ translation?: Vector3;
8
+ rotation?: Quaternion;
9
+ media?: TargetMedia[];
10
+ position?: TargetWgs84 | Vector3;
11
+ frame?: string;
12
+ }
13
+ export interface TargetMedia {
14
+ id: string;
15
+ data: Record<string, string>;
16
+ }
17
+ export interface TargetWgs84 {
18
+ lat: number;
19
+ lon: number;
20
+ alt?: number;
21
+ }
22
+ export declare const isTargetWgs84: (position: TargetWgs84 | Vector3) => position is TargetWgs84;
23
+ export interface Target extends TargetBase {
24
+ type: 'TARGET';
25
+ }
26
+ export declare const isTarget: (target: Target | Asset) => target is Target;
27
+ export interface Asset extends TargetBase {
28
+ type: 'ASSET';
29
+ }
30
+ export declare const isAsset: (target: Target | Asset) => target is Asset;
@@ -0,0 +1,9 @@
1
+ export const isTargetWgs84 = (position) => {
2
+ return Boolean(position) && 'lat' in position && 'lon' in position;
3
+ };
4
+ export const isTarget = (target) => {
5
+ return target.type === 'TARGET';
6
+ };
7
+ export const isAsset = (target) => {
8
+ return target.type === 'ASSET';
9
+ };
@@ -1,4 +1,4 @@
1
- import { EvaluatorService, ScheduleService } from '../services';
1
+ import { EvaluatorService } from '../services';
2
2
  import { IBaseService, ServiceEnum } from '../models';
3
3
  import { CallerServiceNode } from '../services/CallerServiceNode';
4
4
  import { CommandServiceNode } from '../services/CommandServiceNode';
@@ -13,10 +13,6 @@ export declare class RocosSDKNode extends RocosSDK {
13
13
  * Gets the telemetry service.
14
14
  */
15
15
  getTelemetryService(): TelemetryServiceNode;
16
- /**
17
- * Gets the scheduler service.
18
- */
19
- getSchedulerService(): ScheduleService;
20
16
  /**
21
17
  * Gets the service call service.
22
18
  */
@@ -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, EnvironmentService, EventService, IntegrationService, MapService, ProfileService, ProjectService, RobotService, ScheduleService, SpotProvisioningServiceNode, StreamService, TargetService, UserService, } from '../services';
2
2
  import { ServiceEnum } from '../models';
3
3
  import { CallerServiceNode } from '../services/CallerServiceNode';
4
4
  import { CommandServiceNode } from '../services/CommandServiceNode';
@@ -24,6 +24,9 @@ export class RocosSDKNode extends RocosSDK {
24
24
  case ServiceEnum.ROBOT:
25
25
  this.services[name] = new RobotService(config);
26
26
  break;
27
+ case ServiceEnum.ENVIRONMENT:
28
+ this.services[name] = new EnvironmentService(config);
29
+ break;
27
30
  case ServiceEnum.EVENT:
28
31
  this.services[name] = new EventService(config);
29
32
  break;
@@ -48,9 +51,6 @@ export class RocosSDKNode extends RocosSDK {
48
51
  case ServiceEnum.DASHBOARD:
49
52
  this.services[name] = new DashboardService(config);
50
53
  break;
51
- case ServiceEnum.FUNCTION:
52
- this.services[name] = new FunctionService(config);
53
- break;
54
54
  case ServiceEnum.STREAM:
55
55
  this.services[name] = new StreamService(config);
56
56
  break;
@@ -81,6 +81,12 @@ export class RocosSDKNode extends RocosSDK {
81
81
  case ServiceEnum.MAP:
82
82
  this.services[name] = new MapService(config);
83
83
  break;
84
+ case ServiceEnum.DEVICE_CREDENTIALS:
85
+ this.services[name] = new DeviceCredentialsService(config);
86
+ break;
87
+ case ServiceEnum.TARGET:
88
+ this.services[name] = new TargetService(config);
89
+ break;
84
90
  }
85
91
  }
86
92
  this.logger.debug(`Found service ${name}.`);
@@ -92,12 +98,6 @@ export class RocosSDKNode extends RocosSDK {
92
98
  getTelemetryService() {
93
99
  return this.getService(ServiceEnum.TELEMETRY);
94
100
  }
95
- /**
96
- * Gets the scheduler service.
97
- */
98
- getSchedulerService() {
99
- return this.getService(ServiceEnum.SCHEDULE);
100
- }
101
101
  /**
102
102
  * Gets the service call service.
103
103
  */
@@ -75,8 +75,16 @@ export declare class AssetStorageService extends BaseServiceAbstract implements
75
75
  * @param projectId
76
76
  * @param start Start date for the query (optional)
77
77
  * @param end End date for the query (optional)
78
+ * @param includeObservations If observations should be included in the response (optional)
78
79
  */
79
- listMappedAssets(projectId: string, start?: Date, end?: Date): Promise<AssetItemWithObservationsModel[]>;
80
+ listMappedAssets(projectId: string, start?: Date, end?: Date, includeObservations?: boolean): Promise<AssetItemWithObservationsModel[]>;
81
+ /**
82
+ * Get mapped asset
83
+ *
84
+ * @param projectId
85
+ * @param assetId
86
+ */
87
+ getMappedAsset(projectId: string, assetId: string): Promise<AssetItemWithObservationsModel>;
80
88
  /**
81
89
  * Set Robot Sync Definitions
82
90
  * @param projectId
@@ -1,4 +1,4 @@
1
- import { API_PROJECT_ASSET_INTEGRATIONS_PATH_URL, API_PROJECT_ASSET_INTEGRATION_PATH_URL, API_PROJECT_ASSET_INTEGRATION_PROVIDERS_PATH_URL, API_PROJECT_ASSET_PATH_URL, API_PROJECT_ASSET_PROFILES_SYNC_DEFINITION_PATH_URL, API_PROJECT_ASSET_ROBOTS_SYNC_DEFINITION_PATH_URL, API_PROJECT_ASSET_URL, API_PROJECT_FLOW_ASSET_PATH_URL, API_PROJECT_MAPPED_ASSETS_PATH_URL, API_PROJECT_MISSION_ASSETS_PATH_URL, API_PROJECT_MISSION_ASSET_PATH_URL, API_PROJECT_ROBOT_ASSET_PATH_URL, } from '../constants/api';
1
+ import { API_PROJECT_ASSET_INTEGRATIONS_PATH_URL, API_PROJECT_ASSET_INTEGRATION_PATH_URL, API_PROJECT_ASSET_INTEGRATION_PROVIDERS_PATH_URL, API_PROJECT_ASSET_PATH_URL, API_PROJECT_ASSET_PROFILES_SYNC_DEFINITION_PATH_URL, API_PROJECT_ASSET_ROBOTS_SYNC_DEFINITION_PATH_URL, API_PROJECT_ASSET_URL, API_PROJECT_FLOW_ASSET_PATH_URL, API_PROJECT_MAPPED_ASSETS_PATH_URL, API_PROJECT_MAPPED_ASSET_PATH_URL, API_PROJECT_MISSION_ASSETS_PATH_URL, API_PROJECT_MISSION_ASSET_PATH_URL, API_PROJECT_ROBOT_ASSET_PATH_URL, } from '../constants/api';
2
2
  import { RocosError, errorCodes, } from '../models';
3
3
  import { BaseServiceAbstract } from './BaseServiceAbstract';
4
4
  import { RocosLogger } from '../logger/RocosLogger';
@@ -124,13 +124,24 @@ export class AssetStorageService extends BaseServiceAbstract {
124
124
  * @param projectId
125
125
  * @param start Start date for the query (optional)
126
126
  * @param end End date for the query (optional)
127
+ * @param includeObservations If observations should be included in the response (optional)
127
128
  */
128
- async listMappedAssets(projectId, start, end) {
129
+ async listMappedAssets(projectId, start, end, includeObservations) {
129
130
  return this.callGet(formatServiceUrl(API_PROJECT_MAPPED_ASSETS_PATH_URL, { url: this.config.url, projectId }, this.config.insecure), `Failed to list mapped assets for ${projectId}.`, {
130
131
  start: start?.toISOString() ?? '',
131
132
  end: end?.toISOString() ?? '',
133
+ includeObservations: includeObservations ? 'true' : 'false',
132
134
  });
133
135
  }
136
+ /**
137
+ * Get mapped asset
138
+ *
139
+ * @param projectId
140
+ * @param assetId
141
+ */
142
+ async getMappedAsset(projectId, assetId) {
143
+ return this.callGet(formatServiceUrl(API_PROJECT_MAPPED_ASSET_PATH_URL, { url: this.config.url, projectId, assetId }, this.config.insecure), `Failed to get mapped asset for ${projectId} and id: ${assetId}.`);
144
+ }
134
145
  /**
135
146
  * Set Robot Sync Definitions
136
147
  * @param projectId
@@ -1,10 +1,20 @@
1
+ import { Observable } from 'rxjs';
1
2
  import { IBaseService, IRocosSDKConfig, RocosError, Token } from '../models';
2
3
  import { BaseServiceAbstract } from './BaseServiceAbstract';
3
4
  export declare class AuthService extends BaseServiceAbstract implements IBaseService {
4
5
  protected config: IRocosSDKConfig;
5
6
  private token?;
6
7
  private tokenRefreshTimeoutId?;
8
+ private tokenSubject$;
7
9
  constructor(config: IRocosSDKConfig);
10
+ /** Observable for token updates
11
+ *
12
+ * This is useful for getting notified when the token changes.
13
+ * i.e. when the token is refreshed from the token refresh checker.
14
+ *
15
+ * It will emit the current token when you subscribe and then emit new tokens when they are set.
16
+ */
17
+ get token$(): Observable<Token>;
8
18
  getStatus(): boolean;
9
19
  teardown(): void;
10
20
  protected getError(e: RocosError): RocosError;
@@ -62,9 +72,10 @@ export declare class AuthService extends BaseServiceAbstract implements IBaseSer
62
72
  * If you want to refresh the token regardless of the expiry time, use `refreshToken`.
63
73
  *
64
74
  * @param minutes the number of minutes before the token expires to refresh the token
75
+ * @returns true if the token was refreshed
65
76
  * @see refreshToken
66
77
  */
67
- refreshTokenIfExpired(minutes: number): Promise<void>;
78
+ refreshTokenIfExpired(minutes: number): Promise<boolean>;
68
79
  /** Start a 5-minute loop to check if the token needs to be refreshed
69
80
  *
70
81
  * This is useful when you are using GRPC services (i.e. telemetry) which does not automatically refresh the token.
@@ -1,19 +1,35 @@
1
1
  import { API_APPLICATION_AUTH_URL, API_OTP_AUTH_URL, API_OTP_URL, API_USER_TOKEN_URL } from '../constants/api';
2
+ import { BehaviorSubject } from 'rxjs';
2
3
  import { RocosError, Token, errorCodes } from '../models';
3
4
  import { BaseServiceAbstract } from './BaseServiceAbstract';
4
5
  import { RocosLogger } from '../logger/RocosLogger';
5
6
  import { RocosStore } from '../store/RocosStore';
7
+ import { filter } from 'rxjs/operators';
6
8
  import { formatServiceUrl } from '../helpers/formatServiceUrl';
7
9
  import { issuer } from '../constants/auth';
8
10
  export class AuthService extends BaseServiceAbstract {
9
11
  constructor(config) {
10
12
  super(config);
11
13
  this.config = config;
14
+ this.tokenSubject$ = new BehaviorSubject(null);
12
15
  this.config = config;
13
16
  this.logger = RocosLogger.getInstance(`AuthService(${this.config.url})`);
14
17
  if (this.config.token) {
15
18
  this.setToken(this.config.token);
16
19
  }
20
+ this.token$.subscribe((token) => {
21
+ RocosStore.getChangeSubject().next({ type: 'token', url: this.config.url, data: token.value });
22
+ });
23
+ }
24
+ /** Observable for token updates
25
+ *
26
+ * This is useful for getting notified when the token changes.
27
+ * i.e. when the token is refreshed from the token refresh checker.
28
+ *
29
+ * It will emit the current token when you subscribe and then emit new tokens when they are set.
30
+ */
31
+ get token$() {
32
+ return this.tokenSubject$.asObservable().pipe(filter(Boolean));
17
33
  }
18
34
  getStatus() {
19
35
  return true;
@@ -39,7 +55,12 @@ export class AuthService extends BaseServiceAbstract {
39
55
  }
40
56
  this.config.token = this.token.value;
41
57
  // output a message for token change
42
- RocosStore.getChangeSubject().next({ type: 'token', url: this.config.url, data: this.token.value });
58
+ if (this.isTokenValid(this.token)) {
59
+ this.tokenSubject$.next(this.token);
60
+ }
61
+ else {
62
+ void this.getToken();
63
+ }
43
64
  }
44
65
  /**
45
66
  * Clear token
@@ -163,6 +184,7 @@ export class AuthService extends BaseServiceAbstract {
163
184
  * If you want to refresh the token regardless of the expiry time, use `refreshToken`.
164
185
  *
165
186
  * @param minutes the number of minutes before the token expires to refresh the token
187
+ * @returns true if the token was refreshed
166
188
  * @see refreshToken
167
189
  */
168
190
  async refreshTokenIfExpired(minutes) {
@@ -170,7 +192,9 @@ export class AuthService extends BaseServiceAbstract {
170
192
  this.logger.info('Token expires in 15 minutes. Refreshing.');
171
193
  const newToken = await this.refreshToken();
172
194
  this.setToken(newToken);
195
+ return true;
173
196
  }
197
+ return false;
174
198
  }
175
199
  /** Start a 5-minute loop to check if the token needs to be refreshed
176
200
  *
@@ -1,4 +1,4 @@
1
- import { RocosError, HttpError } from '../models';
1
+ import { HttpError, RocosError } from '../models';
2
2
  import { getURLSearchParams } from '../helpers';
3
3
  import { RocosStore } from '../store/RocosStore';
4
4
  export class BaseServiceAbstract {
@@ -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, disableValidation?: boolean): Promise<DeviceCredentialCreate>;
13
+ delete(projectId: string, callsign: string, component: string, system: string): Promise<void>;
14
+ auth(credentials: DeviceCredentialAuth): Promise<DeviceCredentialAuthResult>;
15
+ }