@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
@@ -1,127 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- import WorkerManager from './manager';
5
- const WorkerMocks = {
6
- postMessage: jest.fn(),
7
- terminate: jest.fn(),
8
- addEventListener: jest.fn(),
9
- removeEventListener: jest.fn(),
10
- onerror: jest.fn(),
11
- onmessage: jest.fn(),
12
- onmessageerror: jest.fn(),
13
- dispatchEvent: jest.fn(),
14
- clearAllMocks() {
15
- this.postMessage.mockClear();
16
- this.terminate.mockClear();
17
- this.addEventListener.mockClear();
18
- this.removeEventListener.mockClear();
19
- this.onerror.mockClear();
20
- this.onmessage.mockClear();
21
- this.onmessageerror.mockClear();
22
- this.dispatchEvent.mockClear();
23
- },
24
- };
25
- class MockWorkerClass {
26
- constructor() {
27
- this.postMessage = WorkerMocks.postMessage;
28
- this.terminate = WorkerMocks.terminate;
29
- this.addEventListener = WorkerMocks.addEventListener;
30
- this.removeEventListener = WorkerMocks.removeEventListener;
31
- this.onerror = WorkerMocks.onerror;
32
- this.onmessage = WorkerMocks.onmessage;
33
- this.onmessageerror = WorkerMocks.onmessageerror;
34
- this.dispatchEvent = WorkerMocks.dispatchEvent;
35
- }
36
- }
37
- Object.defineProperty(window, 'Worker', {
38
- value: MockWorkerClass,
39
- writable: true,
40
- });
41
- Object.defineProperty(window, 'URL', {
42
- value: {
43
- createObjectURL: jest.fn(),
44
- },
45
- });
46
- // add mock to AbortSignal.timeout
47
- Object.defineProperty(AbortSignal, 'timeout', {
48
- value: jest.fn().mockImplementation((timeout) => {
49
- return new AbortController().signal;
50
- }),
51
- });
52
- const task = {
53
- id: 'test',
54
- code: '1',
55
- timeout: 1000,
56
- };
57
- const response = {
58
- data: {
59
- id: 'test',
60
- success: true,
61
- result: 'test',
62
- },
63
- };
64
- describe('WorkerManager', () => {
65
- beforeEach(() => {
66
- WorkerMocks.clearAllMocks();
67
- });
68
- it('should send a task to the worker', async () => {
69
- const listeners = [];
70
- WorkerMocks.addEventListener.mockImplementation((_, listener) => {
71
- listeners.push(listener);
72
- });
73
- WorkerMocks.postMessage.mockImplementation((msg) => {
74
- listeners.forEach((listener) => {
75
- listener(response);
76
- });
77
- });
78
- const manager = new WorkerManager();
79
- const result = await manager.execute(task);
80
- expect(result).toEqual('test');
81
- });
82
- it('should handle listener for a single task', async () => {
83
- const listeners = [];
84
- WorkerMocks.addEventListener.mockImplementation((_, listener) => {
85
- listeners.push(listener);
86
- });
87
- WorkerMocks.removeEventListener.mockImplementation((_, listener) => {
88
- const index = listeners.indexOf(listener);
89
- listeners.splice(index, 1);
90
- });
91
- const manager = new WorkerManager();
92
- expect(listeners.length).toEqual(0);
93
- const result = manager.execute(task);
94
- expect(listeners.length).toEqual(1);
95
- listeners[0](response);
96
- await result;
97
- expect(listeners.length).toEqual(0);
98
- });
99
- it('should handle listener for multiple simultaneous task', async () => {
100
- const listeners = [];
101
- WorkerMocks.addEventListener.mockImplementation((_, listener) => {
102
- listeners.push(listener);
103
- });
104
- WorkerMocks.removeEventListener.mockImplementation((_, listener) => {
105
- const index = listeners.indexOf(listener);
106
- listeners.splice(index, 1);
107
- });
108
- const manager = new WorkerManager();
109
- expect(listeners.length).toEqual(0);
110
- const result1 = manager.execute(task);
111
- const result2 = manager.execute(task);
112
- expect(listeners.length).toEqual(2);
113
- const result3 = manager.execute(task);
114
- expect(listeners.length).toEqual(3);
115
- const [listener1, listener2, listener3] = listeners;
116
- listener1(response);
117
- await result1;
118
- expect(listeners.length).toEqual(2);
119
- listener3(response);
120
- await result3;
121
- expect(listeners.length).toEqual(1);
122
- listener2(response);
123
- await result2;
124
- expect(listeners.length).toEqual(0);
125
- expect(WorkerMocks.removeEventListener).toHaveBeenCalledTimes(3);
126
- });
127
- });
@@ -1,6 +0,0 @@
1
- export declare enum CallsignStatus {
2
- UNKNOWN = "unknown",
3
- ONLINE = "online",
4
- OFFLINE = "offline",
5
- ERROR = "error"
6
- }
@@ -1,7 +0,0 @@
1
- export var CallsignStatus;
2
- (function (CallsignStatus) {
3
- CallsignStatus["UNKNOWN"] = "unknown";
4
- CallsignStatus["ONLINE"] = "online";
5
- CallsignStatus["OFFLINE"] = "offline";
6
- CallsignStatus["ERROR"] = "error";
7
- })(CallsignStatus || (CallsignStatus = {}));
@@ -1,6 +0,0 @@
1
- export declare class ExternalProject {
2
- id?: string;
3
- name?: string;
4
- createdAt?: number;
5
- isLinked?: boolean;
6
- }
@@ -1,2 +0,0 @@
1
- export class ExternalProject {
2
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,108 +0,0 @@
1
- import { Token } from './Token';
2
- const generateToken = (config) => {
3
- const defaultPayload = {
4
- iat: 1234567890,
5
- exp: 9876543210,
6
- iss: 'myissuer',
7
- aud: 'myaudience',
8
- sub: 'mysubject',
9
- };
10
- const encodedHeader = Buffer.from(JSON.stringify(config?.header ?? { alg: 'HS256', typ: 'JWT' })).toString('base64');
11
- const encodedPayload = Buffer.from(JSON.stringify(config?.payload ?? defaultPayload)).toString('base64');
12
- if (config?.signature === null) {
13
- return `${encodedHeader}.${encodedPayload}`;
14
- }
15
- return `${encodedHeader}.${encodedPayload}.${config?.signature ?? 'signature'}`;
16
- };
17
- describe('Token', () => {
18
- describe('constructor', () => {
19
- it('can get information from a valid token', () => {
20
- const token = new Token(generateToken());
21
- expect(token.issuedAt).toEqual(new Date(1234567890000));
22
- expect(token.expires).toEqual(new Date(9876543210000));
23
- expect(token.issuer).toEqual('myissuer');
24
- expect(token.audience).toEqual('myaudience');
25
- expect(token.subject).toEqual('mysubject');
26
- });
27
- it('should throw an error for a non-jwt', () => {
28
- // completely invalid string
29
- expect(() => new Token('not a jwt')).toThrowError('Invalid token');
30
- // invalid header
31
- expect(() => {
32
- new Token(generateToken({
33
- header: {
34
- alg: 'HS256',
35
- typ: 'Not-a-JWT',
36
- },
37
- }));
38
- }).toThrowError('Invalid token');
39
- // too many parts
40
- expect(() => {
41
- new Token('a.b.c.d');
42
- }).toThrowError('Invalid token');
43
- });
44
- it('should allow a token with no signature', () => {
45
- const token = new Token(generateToken({ signature: null }));
46
- expect(token.issuedAt).toEqual(new Date(1234567890000));
47
- expect(token.expires).toEqual(new Date(9876543210000));
48
- expect(token.issuer).toEqual('myissuer');
49
- expect(token.audience).toEqual('myaudience');
50
- expect(token.subject).toEqual('mysubject');
51
- });
52
- });
53
- describe('isExpired', () => {
54
- const baseDate = new Date(2021, 0, 1, 0, 0, 0, 0);
55
- beforeEach(() => {
56
- jest.useFakeTimers();
57
- jest.setSystemTime(baseDate);
58
- });
59
- afterEach(() => {
60
- jest.useRealTimers();
61
- });
62
- const expiredDate = (baseDate.getTime() - 1000 * 60 * 5) / 1000; // 5 minutes ago
63
- const notExpiredDate = (baseDate.getTime() + 1000 * 60 * 60 * 24) / 1000; // 1 day from now
64
- it('should return true if the token is expired', () => {
65
- const token = new Token(generateToken({ payload: { exp: expiredDate } }));
66
- expect(token.isExpired()).toEqual(true);
67
- });
68
- it('should return false if the token is not expired', () => {
69
- const token = new Token(generateToken({ payload: { exp: notExpiredDate } }));
70
- expect(token.isExpired()).toEqual(false);
71
- });
72
- });
73
- describe('isExpiredIn', () => {
74
- const baseDate = new Date(2021, 0, 1, 0, 0, 0, 0);
75
- beforeEach(() => {
76
- jest.useFakeTimers();
77
- jest.setSystemTime(baseDate);
78
- });
79
- afterEach(() => {
80
- jest.useRealTimers();
81
- });
82
- const expiredDate = (baseDate.getTime() - 1000 * 60 * 5) / 1000; // 5 minutes ago
83
- const expiredIn5MinsDate = (baseDate.getTime() + 1000 * 60 * 5) / 1000; // 5 minutes from now
84
- const expiredIn25MinsDate = (baseDate.getTime() + 1000 * 60 * 25) / 1000; // 25 minutes from now
85
- const expiredIn2HoursDate = (baseDate.getTime() + 1000 * 60 * 60 * 2) / 1000; // 2 hours from now
86
- it('should return true if the token is expired in the given time', () => {
87
- const token = new Token(generateToken({ payload: { exp: expiredIn5MinsDate } }));
88
- expect(token.isExpiredIn(5, 'minutes')).toEqual(true);
89
- expect(token.isExpiredIn(25, 'minutes')).toEqual(true);
90
- expect(token.isExpiredIn(2, 'hours')).toEqual(true);
91
- const token2 = new Token(generateToken({ payload: { exp: expiredIn25MinsDate } }));
92
- expect(token2.isExpiredIn(25, 'minutes')).toEqual(true);
93
- expect(token2.isExpiredIn(2, 'hours')).toEqual(true);
94
- const token3 = new Token(generateToken({ payload: { exp: expiredDate } }));
95
- expect(token3.isExpiredIn(5, 'minutes')).toEqual(true);
96
- expect(token3.isExpiredIn(25, 'minutes')).toEqual(true);
97
- expect(token3.isExpiredIn(2, 'hours')).toEqual(true);
98
- });
99
- it('should return false if the token is not expired in the given time', () => {
100
- const token = new Token(generateToken({ payload: { exp: expiredIn5MinsDate } }));
101
- expect(token.isExpiredIn(4, 'minutes')).toEqual(false);
102
- const token2 = new Token(generateToken({ payload: { exp: expiredIn25MinsDate } }));
103
- expect(token2.isExpiredIn(24, 'minutes')).toEqual(false);
104
- const token3 = new Token(generateToken({ payload: { exp: expiredIn2HoursDate } }));
105
- expect(token3.isExpiredIn(1, 'hours')).toEqual(false);
106
- });
107
- });
108
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,163 +0,0 @@
1
- import { issuer } from '../constants/auth';
2
- import { AuthService } from './AuthService';
3
- import { Token } from '../models';
4
- describe('authService', () => {
5
- const baseDate = new Date(2021, 0, 1, 0, 0, 0, 0);
6
- beforeEach(() => {
7
- jest.useFakeTimers();
8
- jest.setSystemTime(baseDate);
9
- });
10
- const expiredDate = new Date(baseDate.getTime() - 1000 * 60 * 5); // 5 minutes ago
11
- const almostExpiredDate = new Date(baseDate.getTime() + 1000 * 60 * 5); // 5 minutes from now
12
- const almostAlmostExpiredDate = new Date(baseDate.getTime() + 1000 * 60 * 25); // 35 minutes from now
13
- const notExpiredDate = new Date(baseDate.getTime() + 1000 * 60 * 60 * 24); // 1 day from now
14
- const getToken = (config) => {
15
- const header = {
16
- alg: 'HS256',
17
- typ: 'JWT',
18
- };
19
- const payload = {
20
- iat: Math.floor((config.iat ?? expiredDate).getTime() / 1000),
21
- exp: Math.floor((config.exp ?? notExpiredDate).getTime() / 1000),
22
- iss: config.iss ?? issuer,
23
- aud: config.aud ?? 'myaudience',
24
- sub: config.sub ?? 'mysubject',
25
- };
26
- const encodedHeader = Buffer.from(JSON.stringify(header)).toString('base64');
27
- const encodedPayload = Buffer.from(JSON.stringify(payload)).toString('base64');
28
- if (config.signature === false) {
29
- return `${encodedHeader}.${encodedPayload}`;
30
- }
31
- return `${encodedHeader}.${encodedPayload}.signature`;
32
- };
33
- afterAll(() => jest.useRealTimers());
34
- describe('getToken', () => {
35
- it('should return the current token if it is not expired', async () => {
36
- // Arrange
37
- const token = getToken({ exp: notExpiredDate });
38
- const service = new AuthService({
39
- token,
40
- url: 'http://localhost:0',
41
- });
42
- service.setToken(token);
43
- // Act
44
- const newToken = await service.getToken();
45
- // Assert
46
- expect(newToken.value).toEqual(token);
47
- });
48
- it('should refresh the token if it is about to expire', async () => {
49
- // Arrange
50
- const token = getToken({ exp: almostExpiredDate });
51
- const service = new AuthService({
52
- token,
53
- url: 'http://localhost:0',
54
- });
55
- service.setToken(token);
56
- const expected = getToken({ signature: false });
57
- jest.spyOn(AuthService.prototype, 'refreshToken').mockResolvedValue(new Token(expected));
58
- // Act
59
- const newToken = await service.getToken();
60
- // Assert
61
- expect(newToken.value).not.toEqual(token);
62
- expect(newToken.value).toEqual(expected);
63
- expect(AuthService.prototype.refreshToken).toHaveBeenCalled();
64
- });
65
- it('should get a new token if there is no current token', async () => {
66
- // Arrange
67
- const token = getToken({ signature: false });
68
- const service = new AuthService({
69
- url: 'http://localhost:0',
70
- token,
71
- });
72
- service.clearToken();
73
- const expected = getToken({ signature: false });
74
- jest.spyOn(AuthService.prototype, 'getNewUserToken').mockResolvedValue(new Token(expected));
75
- // Act
76
- const newToken = await service.getToken();
77
- // Assert
78
- expect(newToken.value).toEqual(expected);
79
- expect(AuthService.prototype.getNewUserToken).toHaveBeenCalled();
80
- });
81
- });
82
- describe('tokenRefreshLoop', () => {
83
- jest.spyOn(AuthService.prototype, 'refreshTokenIfExpired').mockImplementation(() => {
84
- // make sure the promise is resolved synchronously
85
- return {
86
- catch: () => {
87
- return {
88
- finally(onfinally) {
89
- onfinally?.();
90
- return Promise.resolve();
91
- },
92
- };
93
- },
94
- };
95
- });
96
- beforeEach(() => {
97
- jest.clearAllTimers();
98
- jest.clearAllMocks();
99
- jest.useFakeTimers();
100
- jest.setSystemTime(baseDate);
101
- });
102
- it('should check the token every 10 minutes', async () => {
103
- // Arrange
104
- const token = getToken({ exp: almostAlmostExpiredDate });
105
- const service = new AuthService({
106
- token,
107
- url: 'http://localhost:0',
108
- });
109
- service.setToken(token);
110
- // Act
111
- service.startTokenRefreshChecker();
112
- expect(AuthService.prototype.refreshTokenIfExpired).toHaveBeenCalledTimes(1);
113
- jest.advanceTimersByTime(1000 * 60 * 10); // 10 minutes
114
- expect(AuthService.prototype.refreshTokenIfExpired).toHaveBeenCalledTimes(2);
115
- jest.advanceTimersByTime(1000 * 60); // 1 minutes - 24 minutes left
116
- expect(AuthService.prototype.refreshTokenIfExpired).toHaveBeenCalledTimes(3);
117
- jest.advanceTimersByTime(1000 * 60 * 10); // 10 minutes - 14 minutes left
118
- jest.runOnlyPendingTimers(); // wait for the next timer to run
119
- service.stopTokenRefreshChecker();
120
- });
121
- it('should not run again when cancelled', () => {
122
- // Arrange
123
- const token = getToken({ exp: notExpiredDate });
124
- const service = new AuthService({
125
- token,
126
- url: 'http://localhost:0',
127
- });
128
- service.setToken(token);
129
- // Act
130
- service.startTokenRefreshChecker();
131
- expect(AuthService.prototype.refreshTokenIfExpired).toHaveBeenCalledTimes(1);
132
- service.stopTokenRefreshChecker();
133
- jest.runOnlyPendingTimers();
134
- expect(AuthService.prototype.refreshTokenIfExpired).toHaveBeenCalledTimes(1);
135
- });
136
- it('should correctly report running status', () => {
137
- const token = getToken({ exp: notExpiredDate });
138
- const service = new AuthService({
139
- token,
140
- url: 'http://localhost:0',
141
- });
142
- service.setToken(token);
143
- expect(service.isTokenRefreshCheckerRunning()).toBe(false);
144
- service.startTokenRefreshChecker();
145
- expect(service.isTokenRefreshCheckerRunning()).toBe(true);
146
- service.stopTokenRefreshChecker();
147
- expect(service.isTokenRefreshCheckerRunning()).toBe(false);
148
- });
149
- it('should correctly report running status', () => {
150
- const token = getToken({ exp: notExpiredDate });
151
- const service = new AuthService({
152
- token,
153
- url: 'http://localhost:0',
154
- });
155
- service.setToken(token);
156
- expect(service.isTokenRefreshCheckerRunning()).toBe(false);
157
- service.startTokenRefreshChecker();
158
- expect(service.isTokenRefreshCheckerRunning()).toBe(true);
159
- service.stopTokenRefreshChecker();
160
- expect(service.isTokenRefreshCheckerRunning()).toBe(false);
161
- });
162
- });
163
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,227 +0,0 @@
1
- import { AckStatus, ResultStatus, Stage, UIDVersion, } from '../models';
2
- import { concatMap, delay, from, of } from 'rxjs';
3
- import { CallerService } from './CallerService';
4
- import { TestScheduler } from 'rxjs/testing';
5
- const makeCallerMessage = (responses) => ({
6
- responses: {
7
- responses: responses ?? [],
8
- },
9
- });
10
- const makeCallerChunkedMessage = (responses) => {
11
- return responses.map((response, index) => {
12
- if ('return' in response) {
13
- throw new Error('Cannot create chunked message with return');
14
- }
15
- const chunk = response;
16
- chunk.chunkIndex = index;
17
- chunk.chunkCount = responses.length;
18
- chunk.header = {
19
- created: '0',
20
- meta: {},
21
- };
22
- return {
23
- chunks: {
24
- chunks: [chunk],
25
- },
26
- };
27
- });
28
- };
29
- const uid = {
30
- hash: 'hash',
31
- version: UIDVersion.HEADER_HASH_RAND,
32
- };
33
- const ack = (id) => ({
34
- uid,
35
- ack: {
36
- status: AckStatus.PROGRESS,
37
- message: id,
38
- stage: Stage.AGENT,
39
- },
40
- });
41
- const ret = (id) => {
42
- const encoder = new TextEncoder();
43
- const payload = encoder.encode(JSON.stringify({ id }));
44
- return {
45
- uid,
46
- return: {
47
- payload,
48
- },
49
- };
50
- };
51
- const chunkRet = (payload) => {
52
- const array = new TextEncoder().encode(payload);
53
- return {
54
- uid,
55
- payload: array,
56
- chunkIndex: 0,
57
- chunkCount: 1,
58
- header: {
59
- created: '0',
60
- meta: {},
61
- },
62
- };
63
- };
64
- const res = (ok) => ({
65
- uid,
66
- result: {
67
- status: ok ? ResultStatus.COMPLETE_SUCCESS : ResultStatus.FATAL,
68
- message: ok ? 'everything is fine' : 'nothing is fine',
69
- },
70
- });
71
- let testScheduler;
72
- let service;
73
- describe('CallerService', () => {
74
- beforeEach(() => {
75
- service = new CallerService({
76
- url: 'http://localhost:8080',
77
- token: 'token',
78
- });
79
- testScheduler = new TestScheduler((actual, expected) => {
80
- expect(actual).toEqual(expected);
81
- });
82
- });
83
- describe('callRaw', () => {
84
- it('should handle a successful call', () => {
85
- // Arrange
86
- jest.spyOn(service, 'invokeRequest').mockImplementation(() => {
87
- return from([
88
- makeCallerMessage([ack('a')]),
89
- makeCallerMessage([ack('b')]),
90
- makeCallerMessage([ack('c'), ret(1)]),
91
- makeCallerMessage([ret(2)]),
92
- makeCallerMessage([ret(3), ret(4)]),
93
- makeCallerMessage([ack('d')]),
94
- makeCallerMessage([ack('e')]),
95
- makeCallerMessage([ack('f')]),
96
- makeCallerMessage([ack('g'), res(true)]),
97
- makeCallerMessage([ack('h')]),
98
- ]).pipe(concatMap((item) => of(item).pipe(delay(1))));
99
- });
100
- testScheduler.run(({ expectObservable }) => {
101
- // Act
102
- const call = service.call({
103
- callsign: 'callsign',
104
- projectId: 'project',
105
- source: '/test',
106
- });
107
- // Assert
108
- const expectedAckMarbles = '-abc--def|';
109
- const expectedRetMarbles = '---ab(cd)|';
110
- const expectedResMarbles = '---------(a|)';
111
- const expectedAckValues = {
112
- a: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'a' },
113
- b: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'b' },
114
- c: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'c' },
115
- d: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'd' },
116
- e: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'e' },
117
- f: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'f' },
118
- };
119
- const expectedReturnValues = {
120
- a: { id: 1 },
121
- b: { id: 2 },
122
- c: { id: 3 },
123
- d: { id: 4 },
124
- };
125
- const expectedResultValues = {
126
- a: { status: ResultStatus.COMPLETE_SUCCESS, message: 'everything is fine' },
127
- };
128
- expectObservable(call.ack$).toBe(expectedAckMarbles, expectedAckValues);
129
- expectObservable(call.return$).toBe(expectedRetMarbles, expectedReturnValues);
130
- expectObservable(call.result$).toBe(expectedResMarbles, expectedResultValues);
131
- });
132
- });
133
- it('should handle a failed call', () => {
134
- // Arrange
135
- jest.spyOn(service, 'invokeRequest').mockImplementation(() => {
136
- return from([
137
- makeCallerMessage([ack('a')]),
138
- makeCallerMessage([ack('b')]),
139
- makeCallerMessage([ack('c'), ret(1)]),
140
- makeCallerMessage([ret(2)]),
141
- makeCallerMessage([ret(3), ret(4)]),
142
- makeCallerMessage([ack('d')]),
143
- makeCallerMessage([ack('e')]),
144
- makeCallerMessage([ack('f')]),
145
- makeCallerMessage([ack('g'), res(false)]),
146
- makeCallerMessage([ack('h')]),
147
- ]).pipe(concatMap((item) => of(item).pipe(delay(1))));
148
- });
149
- testScheduler.run(({ expectObservable }) => {
150
- // Act
151
- const call = service.call({
152
- callsign: 'callsign',
153
- projectId: 'project',
154
- source: '/test',
155
- });
156
- // Assert
157
- const expectedAckMarbles = '-abc--def#';
158
- const expectedRetMarbles = '---ab(cd)#';
159
- const expectedResMarbles = '---------(a|)';
160
- const expectedAckValues = {
161
- a: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'a' },
162
- b: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'b' },
163
- c: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'c' },
164
- d: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'd' },
165
- e: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'e' },
166
- f: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'f' },
167
- };
168
- const expectedReturnValues = {
169
- a: { id: 1 },
170
- b: { id: 2 },
171
- c: { id: 3 },
172
- d: { id: 4 },
173
- };
174
- const expectedResultValues = {
175
- a: { status: ResultStatus.FATAL, message: 'nothing is fine' },
176
- };
177
- expectObservable(call.ack$).toBe(expectedAckMarbles, expectedAckValues, res(false).result);
178
- expectObservable(call.return$).toBe(expectedRetMarbles, expectedReturnValues, res(false).result);
179
- expectObservable(call.result$).toBe(expectedResMarbles, expectedResultValues);
180
- });
181
- });
182
- it('should handle a successful chunked call', () => {
183
- // Arrange
184
- jest.spyOn(service, 'invokeRequest').mockImplementation(() => {
185
- return from([
186
- ...makeCallerChunkedMessage([
187
- chunkRet('[{"'),
188
- chunkRet('id":1},'),
189
- ack('a'),
190
- chunkRet('{"id":2}'),
191
- ack('b'),
192
- chunkRet(']'),
193
- ]),
194
- makeCallerMessage([ack('c'), ret(3)]),
195
- makeCallerMessage([res(true)]),
196
- ]).pipe(concatMap((item) => of(item).pipe(delay(1))));
197
- });
198
- testScheduler.run(({ expectObservable }) => {
199
- // Act
200
- const call = service.call({
201
- callsign: 'callsign',
202
- projectId: 'project',
203
- source: '/test',
204
- });
205
- // Assert
206
- const expectedAckMarbles = '---a-b-c|';
207
- const expectedRetMarbles = '------ab|';
208
- const expectedResMarbles = '--------(a|)';
209
- const expectedAckValues = {
210
- a: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'a' },
211
- b: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'b' },
212
- c: { stage: Stage.AGENT, status: AckStatus.PROGRESS, message: 'c' },
213
- };
214
- const expectedReturnValues = {
215
- a: [{ id: 1 }, { id: 2 }],
216
- b: { id: 3 },
217
- };
218
- const expectedResultValues = {
219
- a: { status: ResultStatus.COMPLETE_SUCCESS, message: 'everything is fine' },
220
- };
221
- expectObservable(call.ack$).toBe(expectedAckMarbles, expectedAckValues);
222
- expectObservable(call.return$).toBe(expectedRetMarbles, expectedReturnValues);
223
- expectObservable(call.result$).toBe(expectedResMarbles, expectedResultValues);
224
- });
225
- });
226
- });
227
- });