@dronedeploy/rocos-js-sdk 3.0.1-alpha.9 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +59 -29
- package/cjs/IRocosSDK.d.ts +4 -3
- package/cjs/RocosSDK.d.ts +19 -7
- package/cjs/RocosSDK.js +31 -10
- package/cjs/api/streams/caller/CallerStream.js +5 -2
- package/cjs/api/streams/caller/CallerStreamNode.js +2 -1
- package/cjs/api/streams/command/CommandStream.js +5 -2
- package/cjs/api/streams/command/CommandStreamNode.js +2 -1
- package/cjs/api/streams/control/ControlStream.js +5 -2
- package/cjs/api/streams/control/ControlStreamAbstract.d.ts +1 -1
- package/cjs/api/streams/control/ControlStreamNode.js +2 -1
- package/cjs/api/streams/fileAccessor/FileAccessorStream.js +4 -1
- package/cjs/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
- package/cjs/api/streams/search/SearchStream.js +5 -2
- package/cjs/api/streams/search/SearchStreamNode.js +2 -1
- package/cjs/api/streams/telemetry/TelemetryStream.js +4 -1
- package/cjs/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
- package/cjs/api/streams/telemetry/TelemetryStreamNode.js +2 -1
- package/cjs/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
- package/cjs/constants/api.d.ts +31 -15
- package/cjs/constants/api.js +35 -18
- package/cjs/helpers/cleanObject.js +4 -1
- package/cjs/helpers/getUniqueConfigKey.d.ts +6 -2
- package/cjs/helpers/getUniqueConfigKey.js +7 -2
- package/cjs/helpers/index.d.ts +1 -0
- package/cjs/helpers/index.js +1 -0
- package/cjs/helpers/kscript/Context.d.ts +34 -0
- package/cjs/helpers/kscript/Context.js +52 -0
- package/cjs/helpers/kscript/index.d.ts +1 -0
- package/cjs/helpers/kscript/index.js +27 -0
- package/cjs/helpers/kscript/kscript.d.ts +6 -0
- package/cjs/helpers/kscript/kscript.js +115 -0
- package/cjs/helpers/kscript/nodes/Identifier.d.ts +12 -0
- package/cjs/helpers/kscript/nodes/Identifier.js +20 -0
- package/cjs/helpers/kscript/nodes/Literal.d.ts +11 -0
- package/cjs/helpers/kscript/nodes/Literal.js +22 -0
- package/cjs/helpers/kscript/nodes/Node.d.ts +9 -0
- package/cjs/helpers/kscript/nodes/Node.js +15 -0
- package/cjs/helpers/kscript/nodes/Program.d.ts +11 -0
- package/cjs/helpers/kscript/nodes/Program.js +24 -0
- package/cjs/helpers/kscript/nodes/TemplateLiteral.d.ts +23 -0
- package/cjs/helpers/kscript/nodes/TemplateLiteral.js +35 -0
- package/cjs/helpers/kscript/nodes/expressions/ArrayExpression.d.ts +7 -0
- package/cjs/helpers/kscript/nodes/expressions/ArrayExpression.js +31 -0
- package/cjs/helpers/kscript/nodes/expressions/ArrowFunctionExpression.d.ts +14 -0
- package/cjs/helpers/kscript/nodes/expressions/ArrowFunctionExpression.js +40 -0
- package/cjs/helpers/kscript/nodes/expressions/BinaryExpression.d.ts +16 -0
- package/cjs/helpers/kscript/nodes/expressions/BinaryExpression.js +104 -0
- package/cjs/helpers/kscript/nodes/expressions/CallExpression.d.ts +8 -0
- package/cjs/helpers/kscript/nodes/expressions/CallExpression.js +38 -0
- package/cjs/helpers/kscript/nodes/expressions/ChainExpression.d.ts +16 -0
- package/cjs/helpers/kscript/nodes/expressions/ChainExpression.js +25 -0
- package/cjs/helpers/kscript/nodes/expressions/ConditionalExpression.d.ts +14 -0
- package/cjs/helpers/kscript/nodes/expressions/ConditionalExpression.js +30 -0
- package/cjs/helpers/kscript/nodes/expressions/ExpressionStatement.d.ts +7 -0
- package/cjs/helpers/kscript/nodes/expressions/ExpressionStatement.js +18 -0
- package/cjs/helpers/kscript/nodes/expressions/LogicalExpression.d.ts +10 -0
- package/cjs/helpers/kscript/nodes/expressions/LogicalExpression.js +47 -0
- package/cjs/helpers/kscript/nodes/expressions/MemberExpression.d.ts +44 -0
- package/cjs/helpers/kscript/nodes/expressions/MemberExpression.js +98 -0
- package/cjs/helpers/kscript/nodes/expressions/ObjectExpression.d.ts +11 -0
- package/cjs/helpers/kscript/nodes/expressions/ObjectExpression.js +59 -0
- package/cjs/helpers/kscript/nodes/expressions/UnaryExpression.d.ts +12 -0
- package/cjs/helpers/kscript/nodes/expressions/UnaryExpression.js +44 -0
- package/cjs/helpers/kscript/nodes/expressions/index.d.ts +11 -0
- package/cjs/helpers/kscript/nodes/expressions/index.js +28 -0
- package/cjs/helpers/kscript/nodes/index.d.ts +4 -0
- package/cjs/helpers/kscript/nodes/index.js +10 -0
- package/cjs/helpers/kscript/nodes/nodeTypes.d.ts +33 -0
- package/cjs/helpers/kscript/nodes/nodeTypes.js +29 -0
- package/cjs/helpers/kscript/utils.d.ts +4 -0
- package/cjs/helpers/kscript/utils.js +15 -0
- package/cjs/helpers/websandbox/connection.d.ts +2 -1
- package/cjs/helpers/websandbox/connection.js +6 -5
- package/cjs/helpers/websandbox/frame/frame.js +4 -1
- package/cjs/helpers/websandbox/frame/frame.source.js +1 -1
- package/cjs/helpers/websandbox/frame/worker/manager.d.ts +8 -4
- package/cjs/helpers/websandbox/frame/worker/manager.js +32 -14
- package/cjs/helpers/websandbox/frame/worker/worker.source.js +1 -1
- package/cjs/helpers/websandbox/sandbox.d.ts +1 -1
- package/cjs/helpers/websandbox/sandbox.js +7 -7
- package/cjs/models/IConnectedCallsign.d.ts +10 -0
- package/cjs/models/IConnectedCallsign.js +8 -0
- package/cjs/models/RocosError.d.ts +3 -0
- package/cjs/models/RocosError.js +3 -0
- package/cjs/models/ServiceEnum.d.ts +20 -17
- package/cjs/models/ServiceEnum.js +20 -17
- package/cjs/models/TelemetryStatus.d.ts +12 -0
- package/cjs/models/TelemetryStatus.js +17 -0
- package/cjs/models/Token.d.ts +2 -2
- package/cjs/models/Token.js +5 -5
- package/cjs/models/asset-storage/{AssetModelItem.d.ts → AssetItem.d.ts} +2 -0
- package/cjs/models/device-credentials/DeviceCredentials.d.ts +61 -0
- package/cjs/models/device-credentials/DeviceCredentials.js +2 -0
- package/cjs/models/graph/Position.d.ts +6 -0
- package/cjs/models/graph/Position.js +2 -0
- package/cjs/models/graph/Quaternion.d.ts +6 -0
- package/cjs/models/graph/Quaternion.js +2 -0
- package/cjs/models/graph/Vector3.d.ts +5 -0
- package/cjs/models/graph/Vector3.js +2 -0
- package/cjs/models/graph/index.d.ts +3 -0
- package/cjs/models/graph/index.js +19 -0
- package/cjs/models/index.d.ts +9 -2
- package/cjs/models/index.js +9 -2
- package/cjs/models/integrations/Location.d.ts +24 -0
- package/cjs/models/integrations/Location.js +2 -0
- package/cjs/models/integrations/PaginatedResults.d.ts +4 -0
- package/cjs/models/integrations/PaginatedResults.js +2 -0
- package/cjs/models/maps/Panorama.d.ts +12 -21
- package/cjs/models/projects/ExternalProject.d.ts +10 -0
- package/cjs/models/projects/ExternalProject.js +2 -0
- package/cjs/models/projects/NewProjectRequest.d.ts +8 -0
- package/cjs/models/projects/NewProjectRequest.js +2 -0
- package/cjs/models/target/Target.d.ts +30 -0
- package/cjs/models/target/Target.js +15 -0
- package/cjs/node/RocosSDKNode.d.ts +1 -5
- package/cjs/node/RocosSDKNode.js +9 -9
- package/cjs/services/AssetStorageService.d.ts +9 -1
- package/cjs/services/AssetStorageService.js +12 -1
- package/cjs/services/AuthService.d.ts +12 -1
- package/cjs/services/AuthService.js +25 -1
- package/cjs/services/DeviceCredentialsService.d.ts +15 -0
- package/cjs/services/DeviceCredentialsService.js +56 -0
- package/cjs/services/EnvironmentService.d.ts +28 -0
- package/cjs/services/EnvironmentService.js +48 -0
- package/cjs/services/EvaluatorService.js +1 -1
- package/cjs/services/IntegrationService.d.ts +7 -1
- package/cjs/services/IntegrationService.js +8 -0
- package/cjs/services/MapService.d.ts +18 -8
- package/cjs/services/MapService.js +37 -19
- package/cjs/services/ProfileService.d.ts +24 -0
- package/cjs/services/ProfileService.js +34 -0
- package/cjs/services/ProjectService.d.ts +7 -2
- package/cjs/services/ProjectService.js +7 -3
- package/cjs/services/RTPWebRTCService.d.ts +6 -1
- package/cjs/services/RTPWebRTCService.js +10 -2
- package/cjs/services/RobotService.d.ts +3 -1
- package/cjs/services/RobotService.js +6 -0
- package/cjs/services/SpotProvisioningService.d.ts +1 -1
- package/cjs/services/SpotProvisioningServiceNode.d.ts +1 -1
- package/cjs/services/TargetService.d.ts +16 -0
- package/cjs/services/TargetService.js +58 -0
- package/cjs/services/TelemetryService.d.ts +10 -1
- package/cjs/services/TelemetryService.js +27 -5
- package/cjs/services/WorkflowService.d.ts +18 -8
- package/cjs/services/WorkflowService.js +37 -11
- package/cjs/services/index.d.ts +11 -9
- package/cjs/services/index.js +11 -9
- package/cjs/store/RocosStore.d.ts +1 -2
- package/esm/IRocosSDK.d.ts +4 -3
- package/esm/RocosSDK.d.ts +19 -7
- package/esm/RocosSDK.js +32 -11
- package/esm/api/streams/caller/CallerStream.js +5 -2
- package/esm/api/streams/caller/CallerStreamNode.js +2 -1
- package/esm/api/streams/command/CommandStream.js +5 -2
- package/esm/api/streams/command/CommandStreamNode.js +2 -1
- package/esm/api/streams/control/ControlStream.js +5 -2
- package/esm/api/streams/control/ControlStreamAbstract.d.ts +1 -1
- package/esm/api/streams/control/ControlStreamNode.js +2 -1
- package/esm/api/streams/fileAccessor/FileAccessorStream.js +4 -1
- package/esm/api/streams/fileAccessor/FileAccessorStreamNode.js +3 -1
- package/esm/api/streams/search/SearchStream.js +5 -2
- package/esm/api/streams/search/SearchStreamNode.js +2 -1
- package/esm/api/streams/telemetry/TelemetryStream.js +4 -1
- package/esm/api/streams/telemetry/TelemetryStreamAbstract.d.ts +1 -1
- package/esm/api/streams/telemetry/TelemetryStreamNode.js +2 -1
- package/esm/api/streams/webRTCSignalling/WebRTCSignallingStream.js +5 -2
- package/esm/constants/api.d.ts +31 -15
- package/esm/constants/api.js +31 -15
- package/esm/helpers/cleanObject.js +4 -1
- package/esm/helpers/getUniqueConfigKey.d.ts +6 -2
- package/esm/helpers/getUniqueConfigKey.js +7 -2
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.js +1 -0
- package/esm/helpers/kscript/Context.d.ts +34 -0
- package/esm/helpers/kscript/Context.js +49 -0
- package/esm/helpers/kscript/index.d.ts +1 -0
- package/esm/helpers/kscript/index.js +1 -0
- package/esm/helpers/kscript/kscript.d.ts +6 -0
- package/esm/helpers/kscript/kscript.js +107 -0
- package/esm/helpers/kscript/nodes/Identifier.d.ts +12 -0
- package/esm/helpers/kscript/nodes/Identifier.js +14 -0
- package/esm/helpers/kscript/nodes/Literal.d.ts +11 -0
- package/esm/helpers/kscript/nodes/Literal.js +16 -0
- package/esm/helpers/kscript/nodes/Node.d.ts +9 -0
- package/esm/helpers/kscript/nodes/Node.js +12 -0
- package/esm/helpers/kscript/nodes/Program.d.ts +11 -0
- package/esm/helpers/kscript/nodes/Program.js +18 -0
- package/esm/helpers/kscript/nodes/TemplateLiteral.d.ts +23 -0
- package/esm/helpers/kscript/nodes/TemplateLiteral.js +29 -0
- package/esm/helpers/kscript/nodes/expressions/ArrayExpression.d.ts +7 -0
- package/esm/helpers/kscript/nodes/expressions/ArrayExpression.js +25 -0
- package/esm/helpers/kscript/nodes/expressions/ArrowFunctionExpression.d.ts +14 -0
- package/esm/helpers/kscript/nodes/expressions/ArrowFunctionExpression.js +34 -0
- package/esm/helpers/kscript/nodes/expressions/BinaryExpression.d.ts +16 -0
- package/esm/helpers/kscript/nodes/expressions/BinaryExpression.js +98 -0
- package/esm/helpers/kscript/nodes/expressions/CallExpression.d.ts +8 -0
- package/esm/helpers/kscript/nodes/expressions/CallExpression.js +32 -0
- package/esm/helpers/kscript/nodes/expressions/ChainExpression.d.ts +16 -0
- package/esm/helpers/kscript/nodes/expressions/ChainExpression.js +19 -0
- package/esm/helpers/kscript/nodes/expressions/ConditionalExpression.d.ts +14 -0
- package/esm/helpers/kscript/nodes/expressions/ConditionalExpression.js +24 -0
- package/esm/helpers/kscript/nodes/expressions/ExpressionStatement.d.ts +7 -0
- package/esm/helpers/kscript/nodes/expressions/ExpressionStatement.js +12 -0
- package/esm/helpers/kscript/nodes/expressions/LogicalExpression.d.ts +10 -0
- package/esm/helpers/kscript/nodes/expressions/LogicalExpression.js +41 -0
- package/esm/helpers/kscript/nodes/expressions/MemberExpression.d.ts +44 -0
- package/esm/helpers/kscript/nodes/expressions/MemberExpression.js +92 -0
- package/esm/helpers/kscript/nodes/expressions/ObjectExpression.d.ts +11 -0
- package/esm/helpers/kscript/nodes/expressions/ObjectExpression.js +53 -0
- package/esm/helpers/kscript/nodes/expressions/UnaryExpression.d.ts +12 -0
- package/esm/helpers/kscript/nodes/expressions/UnaryExpression.js +38 -0
- package/esm/helpers/kscript/nodes/expressions/index.d.ts +11 -0
- package/esm/helpers/kscript/nodes/expressions/index.js +11 -0
- package/esm/helpers/kscript/nodes/index.d.ts +4 -0
- package/esm/helpers/kscript/nodes/index.js +3 -0
- package/esm/helpers/kscript/nodes/nodeTypes.d.ts +33 -0
- package/esm/helpers/kscript/nodes/nodeTypes.js +24 -0
- package/esm/helpers/kscript/utils.d.ts +4 -0
- package/esm/helpers/kscript/utils.js +11 -0
- package/esm/helpers/websandbox/connection.d.ts +2 -1
- package/esm/helpers/websandbox/connection.js +6 -5
- package/esm/helpers/websandbox/frame/frame.js +4 -1
- package/esm/helpers/websandbox/frame/frame.source.js +1 -1
- package/esm/helpers/websandbox/frame/worker/manager.d.ts +8 -4
- package/esm/helpers/websandbox/frame/worker/manager.js +32 -14
- package/esm/helpers/websandbox/frame/worker/worker.source.js +1 -1
- package/esm/helpers/websandbox/sandbox.d.ts +1 -1
- package/esm/helpers/websandbox/sandbox.js +7 -7
- package/esm/models/IConnectedCallsign.d.ts +10 -0
- package/esm/models/IConnectedCallsign.js +5 -0
- package/esm/models/RocosError.d.ts +3 -0
- package/esm/models/RocosError.js +3 -0
- package/esm/models/ServiceEnum.d.ts +20 -17
- package/esm/models/ServiceEnum.js +20 -17
- package/esm/models/TelemetryStatus.d.ts +12 -0
- package/esm/models/TelemetryStatus.js +14 -0
- package/esm/models/Token.d.ts +2 -2
- package/esm/models/Token.js +5 -5
- package/esm/models/asset-storage/{AssetModelItem.d.ts → AssetItem.d.ts} +2 -0
- package/esm/models/device-credentials/DeviceCredentials.d.ts +61 -0
- package/esm/models/graph/Position.d.ts +6 -0
- package/esm/models/graph/Quaternion.d.ts +6 -0
- package/esm/models/graph/Vector3.d.ts +5 -0
- package/esm/models/graph/index.d.ts +3 -0
- package/esm/models/graph/index.js +3 -0
- package/esm/models/index.d.ts +9 -2
- package/esm/models/index.js +9 -2
- package/esm/models/integrations/Location.d.ts +24 -0
- package/esm/models/integrations/PaginatedResults.d.ts +4 -0
- package/esm/models/maps/Panorama.d.ts +12 -21
- package/esm/models/projects/ExternalProject.d.ts +10 -0
- package/esm/models/projects/NewProjectRequest.d.ts +8 -0
- package/esm/models/target/Target.d.ts +30 -0
- package/esm/models/target/Target.js +9 -0
- package/esm/node/RocosSDKNode.d.ts +1 -5
- package/esm/node/RocosSDKNode.js +10 -10
- package/esm/services/AssetStorageService.d.ts +9 -1
- package/esm/services/AssetStorageService.js +13 -2
- package/esm/services/AuthService.d.ts +12 -1
- package/esm/services/AuthService.js +25 -1
- package/esm/services/BaseServiceAbstract.js +1 -1
- package/esm/services/DeviceCredentialsService.d.ts +15 -0
- package/esm/services/DeviceCredentialsService.js +52 -0
- package/esm/services/EnvironmentService.d.ts +28 -0
- package/esm/services/EnvironmentService.js +44 -0
- package/esm/services/EvaluatorService.js +1 -1
- package/esm/services/IntegrationService.d.ts +7 -1
- package/esm/services/IntegrationService.js +10 -2
- package/esm/services/MapService.d.ts +18 -8
- package/esm/services/MapService.js +38 -20
- package/esm/services/ProfileService.d.ts +24 -0
- package/esm/services/ProfileService.js +35 -1
- package/esm/services/ProjectService.d.ts +7 -2
- package/esm/services/ProjectService.js +9 -5
- package/esm/services/RTPWebRTCService.d.ts +6 -1
- package/esm/services/RTPWebRTCService.js +10 -2
- package/esm/services/RobotService.d.ts +3 -1
- package/esm/services/RobotService.js +8 -2
- package/esm/services/SpotProvisioningService.d.ts +1 -1
- package/esm/services/SpotProvisioningServiceNode.d.ts +1 -1
- package/esm/services/TargetService.d.ts +16 -0
- package/esm/services/TargetService.js +54 -0
- package/esm/services/TelemetryService.d.ts +10 -1
- package/esm/services/TelemetryService.js +28 -6
- package/esm/services/WorkflowService.d.ts +18 -8
- package/esm/services/WorkflowService.js +38 -12
- package/esm/services/index.d.ts +11 -9
- package/esm/services/index.js +11 -9
- package/esm/store/RocosStore.d.ts +1 -2
- package/package.json +2 -2
- package/cjs/helpers/cleanObject.spec.js +0 -55
- package/cjs/helpers/flattenObject.spec.js +0 -31
- package/cjs/helpers/flattenOneOf.spec.js +0 -159
- package/cjs/helpers/formatServiceUrl.spec.js +0 -18
- package/cjs/helpers/getSha256Hex.spec.js +0 -19
- package/cjs/helpers/getSha256HexNode.spec.js +0 -10
- package/cjs/helpers/getURLSearchParams.spec.js +0 -21
- package/cjs/helpers/nanosecondToMillisecond.spec.js +0 -22
- package/cjs/helpers/splitRobotTopic.spec.js +0 -53
- package/cjs/helpers/standardDeviation.spec.d.ts +0 -1
- package/cjs/helpers/standardDeviation.spec.js +0 -13
- package/cjs/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
- package/cjs/helpers/websandbox/frame/worker/manager.spec.js +0 -132
- package/cjs/models/CallsignStatus.d.ts +0 -6
- package/cjs/models/CallsignStatus.js +0 -10
- package/cjs/models/ExternalProject.d.ts +0 -6
- package/cjs/models/ExternalProject.js +0 -6
- package/cjs/models/Token.spec.d.ts +0 -1
- package/cjs/models/Token.spec.js +0 -110
- package/cjs/services/AuthService.spec.d.ts +0 -1
- package/cjs/services/AuthService.spec.js +0 -165
- package/cjs/services/CallerService.spec.d.ts +0 -1
- package/cjs/services/CallerService.spec.js +0 -229
- package/cjs/services/FunctionService.d.ts +0 -68
- package/cjs/services/FunctionService.js +0 -103
- package/cjs/services/PlatformTimeService.spec.d.ts +0 -1
- package/cjs/services/PlatformTimeService.spec.js +0 -182
- package/cjs/services/RTPWebRTCService.spec.d.ts +0 -4
- package/cjs/services/RTPWebRTCService.spec.js +0 -171
- package/cjs/services/TelemetryService.spec.d.ts +0 -1
- package/cjs/services/TelemetryService.spec.js +0 -39
- package/esm/helpers/cleanObject.spec.d.ts +0 -1
- package/esm/helpers/cleanObject.spec.js +0 -53
- package/esm/helpers/flattenObject.spec.d.ts +0 -1
- package/esm/helpers/flattenObject.spec.js +0 -29
- package/esm/helpers/flattenOneOf.spec.d.ts +0 -1
- package/esm/helpers/flattenOneOf.spec.js +0 -157
- package/esm/helpers/formatServiceUrl.spec.d.ts +0 -1
- package/esm/helpers/formatServiceUrl.spec.js +0 -16
- package/esm/helpers/getSha256Hex.spec.d.ts +0 -1
- package/esm/helpers/getSha256Hex.spec.js +0 -14
- package/esm/helpers/getSha256HexNode.spec.d.ts +0 -1
- package/esm/helpers/getSha256HexNode.spec.js +0 -8
- package/esm/helpers/getURLSearchParams.spec.d.ts +0 -1
- package/esm/helpers/getURLSearchParams.spec.js +0 -19
- package/esm/helpers/nanosecondToMillisecond.spec.d.ts +0 -1
- package/esm/helpers/nanosecondToMillisecond.spec.js +0 -20
- package/esm/helpers/splitRobotTopic.spec.d.ts +0 -1
- package/esm/helpers/splitRobotTopic.spec.js +0 -51
- package/esm/helpers/standardDeviation.spec.d.ts +0 -1
- package/esm/helpers/standardDeviation.spec.js +0 -11
- package/esm/helpers/websandbox/frame/worker/manager.spec.d.ts +0 -4
- package/esm/helpers/websandbox/frame/worker/manager.spec.js +0 -127
- package/esm/models/CallsignStatus.d.ts +0 -6
- package/esm/models/CallsignStatus.js +0 -7
- package/esm/models/ExternalProject.d.ts +0 -6
- package/esm/models/ExternalProject.js +0 -2
- package/esm/models/Token.spec.d.ts +0 -1
- package/esm/models/Token.spec.js +0 -108
- package/esm/models/asset-storage/AssetModelItem.js +0 -1
- package/esm/services/AuthService.spec.d.ts +0 -1
- package/esm/services/AuthService.spec.js +0 -163
- package/esm/services/CallerService.spec.d.ts +0 -1
- package/esm/services/CallerService.spec.js +0 -227
- package/esm/services/FunctionService.d.ts +0 -68
- package/esm/services/FunctionService.js +0 -99
- package/esm/services/PlatformTimeService.spec.d.ts +0 -1
- package/esm/services/PlatformTimeService.spec.js +0 -180
- package/esm/services/RTPWebRTCService.spec.d.ts +0 -4
- package/esm/services/RTPWebRTCService.spec.js +0 -169
- package/esm/services/TelemetryService.spec.d.ts +0 -1
- package/esm/services/TelemetryService.spec.js +0 -37
- /package/cjs/models/asset-storage/{AssetModelItem.js → AssetItem.js} +0 -0
- /package/{cjs/helpers/cleanObject.spec.d.ts → esm/models/asset-storage/AssetItem.js} +0 -0
- /package/{cjs/helpers/flattenObject.spec.d.ts → esm/models/device-credentials/DeviceCredentials.js} +0 -0
- /package/{cjs/helpers/flattenOneOf.spec.d.ts → esm/models/graph/Position.js} +0 -0
- /package/{cjs/helpers/formatServiceUrl.spec.d.ts → esm/models/graph/Quaternion.js} +0 -0
- /package/{cjs/helpers/getSha256Hex.spec.d.ts → esm/models/graph/Vector3.js} +0 -0
- /package/{cjs/helpers/getSha256HexNode.spec.d.ts → esm/models/integrations/Location.js} +0 -0
- /package/{cjs/helpers/getURLSearchParams.spec.d.ts → esm/models/integrations/PaginatedResults.js} +0 -0
- /package/{cjs/helpers/nanosecondToMillisecond.spec.d.ts → esm/models/projects/ExternalProject.js} +0 -0
- /package/{cjs/helpers/splitRobotTopic.spec.d.ts → esm/models/projects/NewProjectRequest.js} +0 -0
@@ -1,229 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const models_1 = require("../models");
|
4
|
-
const rxjs_1 = require("rxjs");
|
5
|
-
const CallerService_1 = require("./CallerService");
|
6
|
-
const testing_1 = require("rxjs/testing");
|
7
|
-
const makeCallerMessage = (responses) => ({
|
8
|
-
responses: {
|
9
|
-
responses: responses ?? [],
|
10
|
-
},
|
11
|
-
});
|
12
|
-
const makeCallerChunkedMessage = (responses) => {
|
13
|
-
return responses.map((response, index) => {
|
14
|
-
if ('return' in response) {
|
15
|
-
throw new Error('Cannot create chunked message with return');
|
16
|
-
}
|
17
|
-
const chunk = response;
|
18
|
-
chunk.chunkIndex = index;
|
19
|
-
chunk.chunkCount = responses.length;
|
20
|
-
chunk.header = {
|
21
|
-
created: '0',
|
22
|
-
meta: {},
|
23
|
-
};
|
24
|
-
return {
|
25
|
-
chunks: {
|
26
|
-
chunks: [chunk],
|
27
|
-
},
|
28
|
-
};
|
29
|
-
});
|
30
|
-
};
|
31
|
-
const uid = {
|
32
|
-
hash: 'hash',
|
33
|
-
version: models_1.UIDVersion.HEADER_HASH_RAND,
|
34
|
-
};
|
35
|
-
const ack = (id) => ({
|
36
|
-
uid,
|
37
|
-
ack: {
|
38
|
-
status: models_1.AckStatus.PROGRESS,
|
39
|
-
message: id,
|
40
|
-
stage: models_1.Stage.AGENT,
|
41
|
-
},
|
42
|
-
});
|
43
|
-
const ret = (id) => {
|
44
|
-
const encoder = new TextEncoder();
|
45
|
-
const payload = encoder.encode(JSON.stringify({ id }));
|
46
|
-
return {
|
47
|
-
uid,
|
48
|
-
return: {
|
49
|
-
payload,
|
50
|
-
},
|
51
|
-
};
|
52
|
-
};
|
53
|
-
const chunkRet = (payload) => {
|
54
|
-
const array = new TextEncoder().encode(payload);
|
55
|
-
return {
|
56
|
-
uid,
|
57
|
-
payload: array,
|
58
|
-
chunkIndex: 0,
|
59
|
-
chunkCount: 1,
|
60
|
-
header: {
|
61
|
-
created: '0',
|
62
|
-
meta: {},
|
63
|
-
},
|
64
|
-
};
|
65
|
-
};
|
66
|
-
const res = (ok) => ({
|
67
|
-
uid,
|
68
|
-
result: {
|
69
|
-
status: ok ? models_1.ResultStatus.COMPLETE_SUCCESS : models_1.ResultStatus.FATAL,
|
70
|
-
message: ok ? 'everything is fine' : 'nothing is fine',
|
71
|
-
},
|
72
|
-
});
|
73
|
-
let testScheduler;
|
74
|
-
let service;
|
75
|
-
describe('CallerService', () => {
|
76
|
-
beforeEach(() => {
|
77
|
-
service = new CallerService_1.CallerService({
|
78
|
-
url: 'http://localhost:8080',
|
79
|
-
token: 'token',
|
80
|
-
});
|
81
|
-
testScheduler = new testing_1.TestScheduler((actual, expected) => {
|
82
|
-
expect(actual).toEqual(expected);
|
83
|
-
});
|
84
|
-
});
|
85
|
-
describe('callRaw', () => {
|
86
|
-
it('should handle a successful call', () => {
|
87
|
-
// Arrange
|
88
|
-
jest.spyOn(service, 'invokeRequest').mockImplementation(() => {
|
89
|
-
return (0, rxjs_1.from)([
|
90
|
-
makeCallerMessage([ack('a')]),
|
91
|
-
makeCallerMessage([ack('b')]),
|
92
|
-
makeCallerMessage([ack('c'), ret(1)]),
|
93
|
-
makeCallerMessage([ret(2)]),
|
94
|
-
makeCallerMessage([ret(3), ret(4)]),
|
95
|
-
makeCallerMessage([ack('d')]),
|
96
|
-
makeCallerMessage([ack('e')]),
|
97
|
-
makeCallerMessage([ack('f')]),
|
98
|
-
makeCallerMessage([ack('g'), res(true)]),
|
99
|
-
makeCallerMessage([ack('h')]),
|
100
|
-
]).pipe((0, rxjs_1.concatMap)((item) => (0, rxjs_1.of)(item).pipe((0, rxjs_1.delay)(1))));
|
101
|
-
});
|
102
|
-
testScheduler.run(({ expectObservable }) => {
|
103
|
-
// Act
|
104
|
-
const call = service.call({
|
105
|
-
callsign: 'callsign',
|
106
|
-
projectId: 'project',
|
107
|
-
source: '/test',
|
108
|
-
});
|
109
|
-
// Assert
|
110
|
-
const expectedAckMarbles = '-abc--def|';
|
111
|
-
const expectedRetMarbles = '---ab(cd)|';
|
112
|
-
const expectedResMarbles = '---------(a|)';
|
113
|
-
const expectedAckValues = {
|
114
|
-
a: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'a' },
|
115
|
-
b: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'b' },
|
116
|
-
c: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'c' },
|
117
|
-
d: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'd' },
|
118
|
-
e: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'e' },
|
119
|
-
f: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'f' },
|
120
|
-
};
|
121
|
-
const expectedReturnValues = {
|
122
|
-
a: { id: 1 },
|
123
|
-
b: { id: 2 },
|
124
|
-
c: { id: 3 },
|
125
|
-
d: { id: 4 },
|
126
|
-
};
|
127
|
-
const expectedResultValues = {
|
128
|
-
a: { status: models_1.ResultStatus.COMPLETE_SUCCESS, message: 'everything is fine' },
|
129
|
-
};
|
130
|
-
expectObservable(call.ack$).toBe(expectedAckMarbles, expectedAckValues);
|
131
|
-
expectObservable(call.return$).toBe(expectedRetMarbles, expectedReturnValues);
|
132
|
-
expectObservable(call.result$).toBe(expectedResMarbles, expectedResultValues);
|
133
|
-
});
|
134
|
-
});
|
135
|
-
it('should handle a failed call', () => {
|
136
|
-
// Arrange
|
137
|
-
jest.spyOn(service, 'invokeRequest').mockImplementation(() => {
|
138
|
-
return (0, rxjs_1.from)([
|
139
|
-
makeCallerMessage([ack('a')]),
|
140
|
-
makeCallerMessage([ack('b')]),
|
141
|
-
makeCallerMessage([ack('c'), ret(1)]),
|
142
|
-
makeCallerMessage([ret(2)]),
|
143
|
-
makeCallerMessage([ret(3), ret(4)]),
|
144
|
-
makeCallerMessage([ack('d')]),
|
145
|
-
makeCallerMessage([ack('e')]),
|
146
|
-
makeCallerMessage([ack('f')]),
|
147
|
-
makeCallerMessage([ack('g'), res(false)]),
|
148
|
-
makeCallerMessage([ack('h')]),
|
149
|
-
]).pipe((0, rxjs_1.concatMap)((item) => (0, rxjs_1.of)(item).pipe((0, rxjs_1.delay)(1))));
|
150
|
-
});
|
151
|
-
testScheduler.run(({ expectObservable }) => {
|
152
|
-
// Act
|
153
|
-
const call = service.call({
|
154
|
-
callsign: 'callsign',
|
155
|
-
projectId: 'project',
|
156
|
-
source: '/test',
|
157
|
-
});
|
158
|
-
// Assert
|
159
|
-
const expectedAckMarbles = '-abc--def#';
|
160
|
-
const expectedRetMarbles = '---ab(cd)#';
|
161
|
-
const expectedResMarbles = '---------(a|)';
|
162
|
-
const expectedAckValues = {
|
163
|
-
a: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'a' },
|
164
|
-
b: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'b' },
|
165
|
-
c: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'c' },
|
166
|
-
d: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'd' },
|
167
|
-
e: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'e' },
|
168
|
-
f: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'f' },
|
169
|
-
};
|
170
|
-
const expectedReturnValues = {
|
171
|
-
a: { id: 1 },
|
172
|
-
b: { id: 2 },
|
173
|
-
c: { id: 3 },
|
174
|
-
d: { id: 4 },
|
175
|
-
};
|
176
|
-
const expectedResultValues = {
|
177
|
-
a: { status: models_1.ResultStatus.FATAL, message: 'nothing is fine' },
|
178
|
-
};
|
179
|
-
expectObservable(call.ack$).toBe(expectedAckMarbles, expectedAckValues, res(false).result);
|
180
|
-
expectObservable(call.return$).toBe(expectedRetMarbles, expectedReturnValues, res(false).result);
|
181
|
-
expectObservable(call.result$).toBe(expectedResMarbles, expectedResultValues);
|
182
|
-
});
|
183
|
-
});
|
184
|
-
it('should handle a successful chunked call', () => {
|
185
|
-
// Arrange
|
186
|
-
jest.spyOn(service, 'invokeRequest').mockImplementation(() => {
|
187
|
-
return (0, rxjs_1.from)([
|
188
|
-
...makeCallerChunkedMessage([
|
189
|
-
chunkRet('[{"'),
|
190
|
-
chunkRet('id":1},'),
|
191
|
-
ack('a'),
|
192
|
-
chunkRet('{"id":2}'),
|
193
|
-
ack('b'),
|
194
|
-
chunkRet(']'),
|
195
|
-
]),
|
196
|
-
makeCallerMessage([ack('c'), ret(3)]),
|
197
|
-
makeCallerMessage([res(true)]),
|
198
|
-
]).pipe((0, rxjs_1.concatMap)((item) => (0, rxjs_1.of)(item).pipe((0, rxjs_1.delay)(1))));
|
199
|
-
});
|
200
|
-
testScheduler.run(({ expectObservable }) => {
|
201
|
-
// Act
|
202
|
-
const call = service.call({
|
203
|
-
callsign: 'callsign',
|
204
|
-
projectId: 'project',
|
205
|
-
source: '/test',
|
206
|
-
});
|
207
|
-
// Assert
|
208
|
-
const expectedAckMarbles = '---a-b-c|';
|
209
|
-
const expectedRetMarbles = '------ab|';
|
210
|
-
const expectedResMarbles = '--------(a|)';
|
211
|
-
const expectedAckValues = {
|
212
|
-
a: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'a' },
|
213
|
-
b: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'b' },
|
214
|
-
c: { stage: models_1.Stage.AGENT, status: models_1.AckStatus.PROGRESS, message: 'c' },
|
215
|
-
};
|
216
|
-
const expectedReturnValues = {
|
217
|
-
a: [{ id: 1 }, { id: 2 }],
|
218
|
-
b: { id: 3 },
|
219
|
-
};
|
220
|
-
const expectedResultValues = {
|
221
|
-
a: { status: models_1.ResultStatus.COMPLETE_SUCCESS, message: 'everything is fine' },
|
222
|
-
};
|
223
|
-
expectObservable(call.ack$).toBe(expectedAckMarbles, expectedAckValues);
|
224
|
-
expectObservable(call.return$).toBe(expectedRetMarbles, expectedReturnValues);
|
225
|
-
expectObservable(call.result$).toBe(expectedResMarbles, expectedResultValues);
|
226
|
-
});
|
227
|
-
});
|
228
|
-
});
|
229
|
-
});
|
@@ -1,68 +0,0 @@
|
|
1
|
-
import { RocosError } from '../models/RocosError';
|
2
|
-
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
3
|
-
import { IBaseService } from '../models/IBaseService';
|
4
|
-
import { IExportDataQuery } from '../models/IExportDataQuery';
|
5
|
-
import { IFunctionConfig } from '../models/IFunctionConfig';
|
6
|
-
import { IRocosSDKConfig } from '../models/IRocosSDKConfig';
|
7
|
-
export declare class FunctionService extends BaseServiceAbstract implements IBaseService {
|
8
|
-
constructor(config: IRocosSDKConfig);
|
9
|
-
protected getError(e: Error): RocosError;
|
10
|
-
getStatus(): boolean;
|
11
|
-
/**
|
12
|
-
* Export data
|
13
|
-
*
|
14
|
-
* @param projectId - Project Id
|
15
|
-
* @param query - Payload {@link IExportDataQuery}
|
16
|
-
*/
|
17
|
-
exportJobs(projectId: string, query: IExportDataQuery): Promise<any>;
|
18
|
-
/**
|
19
|
-
* Create a function
|
20
|
-
*
|
21
|
-
* @param projectId - Project Id
|
22
|
-
* @param model - Payload {@link IFunctionConfig}
|
23
|
-
*/
|
24
|
-
create(projectId: string, model: IFunctionConfig): Promise<any>;
|
25
|
-
/**
|
26
|
-
* Get a functions
|
27
|
-
*
|
28
|
-
* @param projectId - Project Id
|
29
|
-
*/
|
30
|
-
list(projectId: string): Promise<any>;
|
31
|
-
/**
|
32
|
-
* Update a function
|
33
|
-
*
|
34
|
-
* @param projectId - Project Id
|
35
|
-
* @param functionId - Function Id
|
36
|
-
* @param model - Payload {@link IFunctionConfig}
|
37
|
-
*/
|
38
|
-
update(projectId: string, functionId: string, model: IFunctionConfig): Promise<any>;
|
39
|
-
/**
|
40
|
-
* Get function
|
41
|
-
*
|
42
|
-
* @param projectId - Project Id
|
43
|
-
* @param functionId - Function Id
|
44
|
-
*/
|
45
|
-
info(projectId: string, functionId: string): Promise<any>;
|
46
|
-
/**
|
47
|
-
* Delete function
|
48
|
-
*
|
49
|
-
* @param projectId - Project Id
|
50
|
-
* @param functionId - Function Id
|
51
|
-
*/
|
52
|
-
delete(projectId: string, functionId: string): Promise<any>;
|
53
|
-
/**
|
54
|
-
* Run a function
|
55
|
-
*
|
56
|
-
* @param projectId - Project Id
|
57
|
-
* @param functionId - Function Id
|
58
|
-
* @param body - Payload
|
59
|
-
*/
|
60
|
-
run(projectId: string, functionId: string, body?: any): Promise<any>;
|
61
|
-
/**
|
62
|
-
* Get function pods
|
63
|
-
*
|
64
|
-
* @param projectId - Project Id
|
65
|
-
* @param functionId - Function Id
|
66
|
-
*/
|
67
|
-
pods(projectId: string, functionId: string): Promise<any>;
|
68
|
-
}
|
@@ -1,103 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.FunctionService = void 0;
|
4
|
-
const api_1 = require("../constants/api");
|
5
|
-
const RocosError_1 = require("../models/RocosError");
|
6
|
-
const BaseServiceAbstract_1 = require("./BaseServiceAbstract");
|
7
|
-
const ExportDataQuery_1 = require("../models/ExportDataQuery");
|
8
|
-
const RocosLogger_1 = require("../logger/RocosLogger");
|
9
|
-
const formatServiceUrl_1 = require("../helpers/formatServiceUrl");
|
10
|
-
class FunctionService extends BaseServiceAbstract_1.BaseServiceAbstract {
|
11
|
-
constructor(config) {
|
12
|
-
super(config);
|
13
|
-
this.logger = RocosLogger_1.RocosLogger.getInstance(`FunctionService(${this.config.url})`);
|
14
|
-
}
|
15
|
-
getError(e) {
|
16
|
-
return new RocosError_1.RocosError(e, RocosError_1.errorCodes.FUNCTION_SERVICE_ERROR);
|
17
|
-
}
|
18
|
-
getStatus() {
|
19
|
-
return true;
|
20
|
-
}
|
21
|
-
/**
|
22
|
-
* Export data
|
23
|
-
*
|
24
|
-
* @param projectId - Project Id
|
25
|
-
* @param query - Payload {@link IExportDataQuery}
|
26
|
-
*/
|
27
|
-
// TODO: map the response object
|
28
|
-
async exportJobs(projectId, query) {
|
29
|
-
return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_EXPORT_URL, { url: this.config.url, projectId }, this.config.insecure), new ExportDataQuery_1.ExportDataQuery(query).toJSON(), `Failed to export data for ${projectId}.`);
|
30
|
-
}
|
31
|
-
/**
|
32
|
-
* Create a function
|
33
|
-
*
|
34
|
-
* @param projectId - Project Id
|
35
|
-
* @param model - Payload {@link IFunctionConfig}
|
36
|
-
*/
|
37
|
-
// TODO: map the response object
|
38
|
-
async create(projectId, model) {
|
39
|
-
return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_URL, { url: this.config.url, projectId }, this.config.insecure), model, `Failed to create function for ${projectId}.`);
|
40
|
-
}
|
41
|
-
/**
|
42
|
-
* Get a functions
|
43
|
-
*
|
44
|
-
* @param projectId - Project Id
|
45
|
-
*/
|
46
|
-
// TODO: map the response object
|
47
|
-
async list(projectId) {
|
48
|
-
return this.callGet((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_URL, { url: this.config.url, projectId }, this.config.insecure), `Failed to get functions for ${projectId}.`);
|
49
|
-
}
|
50
|
-
/**
|
51
|
-
* Update a function
|
52
|
-
*
|
53
|
-
* @param projectId - Project Id
|
54
|
-
* @param functionId - Function Id
|
55
|
-
* @param model - Payload {@link IFunctionConfig}
|
56
|
-
*/
|
57
|
-
// TODO: map the response object
|
58
|
-
async update(projectId, functionId, model) {
|
59
|
-
return this.callPut((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_ID_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), model, `Failed to update function for ${projectId}, functionId ${functionId}.`);
|
60
|
-
}
|
61
|
-
/**
|
62
|
-
* Get function
|
63
|
-
*
|
64
|
-
* @param projectId - Project Id
|
65
|
-
* @param functionId - Function Id
|
66
|
-
*/
|
67
|
-
// TODO: map the response object
|
68
|
-
async info(projectId, functionId) {
|
69
|
-
return this.callGet((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_ID_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), `Failed to get function for ${projectId}, functionId ${functionId}.`);
|
70
|
-
}
|
71
|
-
/**
|
72
|
-
* Delete function
|
73
|
-
*
|
74
|
-
* @param projectId - Project Id
|
75
|
-
* @param functionId - Function Id
|
76
|
-
*/
|
77
|
-
// TODO: map the response object
|
78
|
-
async delete(projectId, functionId) {
|
79
|
-
return this.callDelete((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_ID_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), `Failed to delete function for ${projectId}, functionId ${functionId}.`);
|
80
|
-
}
|
81
|
-
/**
|
82
|
-
* Run a function
|
83
|
-
*
|
84
|
-
* @param projectId - Project Id
|
85
|
-
* @param functionId - Function Id
|
86
|
-
* @param body - Payload
|
87
|
-
*/
|
88
|
-
// TODO: map the response object
|
89
|
-
async run(projectId, functionId, body = null) {
|
90
|
-
return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_RUN_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), body, `Failed to run function for ${projectId}, functionId ${functionId}.`);
|
91
|
-
}
|
92
|
-
/**
|
93
|
-
* Get function pods
|
94
|
-
*
|
95
|
-
* @param projectId - Project Id
|
96
|
-
* @param functionId - Function Id
|
97
|
-
*/
|
98
|
-
// TODO: map the response object
|
99
|
-
async pods(projectId, functionId) {
|
100
|
-
return this.callGet((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_POD_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), `Failed to ged function pods for ${projectId}, functionId ${functionId}.`);
|
101
|
-
}
|
102
|
-
}
|
103
|
-
exports.FunctionService = FunctionService;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,182 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const PlatformTimeService_1 = require("./PlatformTimeService");
|
4
|
-
const TimeSyncerService_1 = require("./TimeSyncerService");
|
5
|
-
const helpers_1 = require("../helpers");
|
6
|
-
// Subclass PlatformTimeService so that we can test the protected methods
|
7
|
-
class PlatformtimeServicePublic extends PlatformTimeService_1.PlatFormTimeService {
|
8
|
-
constructor(timeSyncerService) {
|
9
|
-
super(timeSyncerService);
|
10
|
-
}
|
11
|
-
isReliableServerTime(platformTimeMeasurement) {
|
12
|
-
return super.isReliableServerTime(platformTimeMeasurement);
|
13
|
-
}
|
14
|
-
calculateOffset(platformTimeMeasurement) {
|
15
|
-
return super.calculateOffset(platformTimeMeasurement);
|
16
|
-
}
|
17
|
-
removeLongestAndShortest(platformTimeMeasurement) {
|
18
|
-
return super.removeLongestAndShortest(platformTimeMeasurement);
|
19
|
-
}
|
20
|
-
static getInstance(timeSyncerService) {
|
21
|
-
const instance = super.getInstance(timeSyncerService);
|
22
|
-
return instance;
|
23
|
-
}
|
24
|
-
}
|
25
|
-
describe('platformTimeService', () => {
|
26
|
-
it('should calculate standard deviation correctly', () => {
|
27
|
-
let numbers = [10, 12, 23, 23, 16, 23, 21, 16];
|
28
|
-
let stdDev = (0, helpers_1.standardDeviation)(numbers);
|
29
|
-
expect(Math.abs(stdDev - 4.8989794855664)).toBeLessThan(0.000001);
|
30
|
-
numbers = [100, 12, 23, 23, 116, 23, 21, 162];
|
31
|
-
stdDev = (0, helpers_1.standardDeviation)(numbers);
|
32
|
-
expect(Math.abs(stdDev - 53.702886328394)).toBeLessThan(0.000001);
|
33
|
-
});
|
34
|
-
it('should be able to tell reliable server time response', () => {
|
35
|
-
jest.useFakeTimers();
|
36
|
-
const p = PlatformtimeServicePublic.getInstance(new TimeSyncerService_1.TimeSyncerService({}));
|
37
|
-
const mock = {
|
38
|
-
clientTimeStampEnd: 100,
|
39
|
-
clientTimeStampStart: 20,
|
40
|
-
serverTime: {
|
41
|
-
now: 0,
|
42
|
-
duration: 0,
|
43
|
-
},
|
44
|
-
};
|
45
|
-
const mocks = [];
|
46
|
-
mocks.push(mock);
|
47
|
-
let isReliableServerTime = p.isReliableServerTime(mocks);
|
48
|
-
expect(isReliableServerTime).toBeTruthy();
|
49
|
-
for (let i = 0; i < 4; i++) {
|
50
|
-
mocks.push({ ...mock });
|
51
|
-
isReliableServerTime = p.isReliableServerTime(mocks);
|
52
|
-
expect(isReliableServerTime).toBeTruthy();
|
53
|
-
}
|
54
|
-
});
|
55
|
-
it('should be able to tell unreliable server time response', () => {
|
56
|
-
jest.useFakeTimers();
|
57
|
-
const p = PlatformtimeServicePublic.getInstance(new TimeSyncerService_1.TimeSyncerService({}));
|
58
|
-
const mock = {
|
59
|
-
clientTimeStampEnd: 100,
|
60
|
-
clientTimeStampStart: 0,
|
61
|
-
serverTime: {
|
62
|
-
now: 0,
|
63
|
-
duration: 0,
|
64
|
-
},
|
65
|
-
};
|
66
|
-
const mocks = [];
|
67
|
-
let isReliableServerTime = false;
|
68
|
-
for (let i = 0; i < 5; i++) {
|
69
|
-
const mockClone = { ...mock };
|
70
|
-
mockClone.clientTimeStampEnd += i * 60;
|
71
|
-
mocks.push(mockClone);
|
72
|
-
}
|
73
|
-
isReliableServerTime = p.isReliableServerTime(mocks);
|
74
|
-
expect(isReliableServerTime).toBeTruthy();
|
75
|
-
for (let i = 0; i < 5; i++) {
|
76
|
-
const mockClone = { ...mock };
|
77
|
-
mockClone.clientTimeStampEnd += i * 70;
|
78
|
-
mocks.push(mockClone);
|
79
|
-
}
|
80
|
-
isReliableServerTime = p.isReliableServerTime(mocks);
|
81
|
-
expect(isReliableServerTime).toBeTruthy();
|
82
|
-
for (let i = 0; i < 5; i++) {
|
83
|
-
const mockClone = { ...mock };
|
84
|
-
mockClone.clientTimeStampEnd += i * 80;
|
85
|
-
mocks.push(mockClone);
|
86
|
-
}
|
87
|
-
isReliableServerTime = p.isReliableServerTime(mocks);
|
88
|
-
// std dev = 113.13708498985
|
89
|
-
expect(isReliableServerTime).toBeFalsy();
|
90
|
-
for (let i = 0; i < 5; i++) {
|
91
|
-
const mockClone = { ...mock };
|
92
|
-
mockClone.clientTimeStampEnd += i * 100;
|
93
|
-
mocks.push(mockClone);
|
94
|
-
}
|
95
|
-
isReliableServerTime = p.isReliableServerTime(mocks);
|
96
|
-
expect(isReliableServerTime).toBeFalsy();
|
97
|
-
});
|
98
|
-
it('should be able to remove shortest and longest correctly', () => {
|
99
|
-
jest.useFakeTimers();
|
100
|
-
const p = PlatformtimeServicePublic.getInstance(new TimeSyncerService_1.TimeSyncerService({}));
|
101
|
-
const mock = {
|
102
|
-
clientTimeStampEnd: 100,
|
103
|
-
clientTimeStampStart: 0,
|
104
|
-
serverTime: {
|
105
|
-
now: 0,
|
106
|
-
duration: 0,
|
107
|
-
},
|
108
|
-
};
|
109
|
-
const mocks = [];
|
110
|
-
let mockClone = { ...mock };
|
111
|
-
mockClone.clientTimeStampEnd = 100;
|
112
|
-
mocks.push(mockClone);
|
113
|
-
mockClone = { ...mock };
|
114
|
-
mockClone.clientTimeStampEnd = 200;
|
115
|
-
mocks.push(mockClone);
|
116
|
-
mockClone = { ...mock };
|
117
|
-
mockClone.clientTimeStampEnd = 500;
|
118
|
-
mocks.push(mockClone);
|
119
|
-
mockClone = { ...mock };
|
120
|
-
mockClone.clientTimeStampEnd = 400;
|
121
|
-
mocks.push(mockClone);
|
122
|
-
mockClone = { ...mock };
|
123
|
-
mockClone.clientTimeStampEnd = 300;
|
124
|
-
mocks.push(mockClone);
|
125
|
-
const platformTimeMeasurement = p.removeLongestAndShortest(mocks);
|
126
|
-
platformTimeMeasurement.forEach((p) => {
|
127
|
-
expect(p.clientTimeStampEnd).not.toEqual(100);
|
128
|
-
expect(p.clientTimeStampEnd).not.toEqual(500);
|
129
|
-
});
|
130
|
-
});
|
131
|
-
it('should be able to calculate the offset correctly', () => {
|
132
|
-
jest.useFakeTimers();
|
133
|
-
const p = PlatformtimeServicePublic.getInstance(new TimeSyncerService_1.TimeSyncerService({}));
|
134
|
-
const mock = {
|
135
|
-
clientTimeStampEnd: 100,
|
136
|
-
clientTimeStampStart: 0,
|
137
|
-
serverTime: {
|
138
|
-
now: 0,
|
139
|
-
duration: 0,
|
140
|
-
},
|
141
|
-
};
|
142
|
-
const mocks = [];
|
143
|
-
let mockClone = { ...mock };
|
144
|
-
mockClone.clientTimeStampEnd = 200;
|
145
|
-
mocks.push(mockClone);
|
146
|
-
mockClone = { ...mock };
|
147
|
-
mockClone.clientTimeStampEnd = 500;
|
148
|
-
mocks.push(mockClone);
|
149
|
-
mockClone = { ...mock };
|
150
|
-
mockClone.clientTimeStampEnd = 400;
|
151
|
-
mocks.push(mockClone);
|
152
|
-
const offset = p.calculateOffset(mocks);
|
153
|
-
// (200-(200)/2 + 500 - (500)/2 + 400 - (400)/2)/3 = 183.333333333, round to 183
|
154
|
-
expect(offset).toEqual(183);
|
155
|
-
});
|
156
|
-
it('should be able to filter where service time is not provided', () => {
|
157
|
-
jest.useFakeTimers();
|
158
|
-
const p = PlatformtimeServicePublic.getInstance(new TimeSyncerService_1.TimeSyncerService({}));
|
159
|
-
const mock = {
|
160
|
-
clientTimeStampEnd: 100,
|
161
|
-
clientTimeStampStart: 0,
|
162
|
-
serverTime: {
|
163
|
-
now: 0,
|
164
|
-
duration: 0,
|
165
|
-
},
|
166
|
-
};
|
167
|
-
const mocks = [];
|
168
|
-
let mockClone = { ...mock };
|
169
|
-
mockClone.clientTimeStampEnd = 200;
|
170
|
-
mockClone.serverTime = undefined;
|
171
|
-
mocks.push(mockClone);
|
172
|
-
mockClone = { ...mock };
|
173
|
-
mockClone.clientTimeStampEnd = 500;
|
174
|
-
mocks.push(mockClone);
|
175
|
-
mockClone = { ...mock };
|
176
|
-
mockClone.clientTimeStampEnd = 400;
|
177
|
-
mocks.push(mockClone);
|
178
|
-
const offset = p.calculateOffset(mocks);
|
179
|
-
// (500 - (500)/2 + 400 - (400)/2)/2 = 225
|
180
|
-
expect(offset).toEqual(225);
|
181
|
-
});
|
182
|
-
});
|