@ledgerhq/device-management-kit 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -28
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js +1 -1
- package/lib/cjs/src/api/DeviceManagementKit.js.map +2 -2
- package/lib/cjs/src/api/apdu/utils/ApduBuilder.js +1 -1
- package/lib/cjs/src/api/apdu/utils/ApduBuilder.js.map +3 -3
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.js +2 -0
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.js.map +7 -0
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.test.js +2 -0
- package/lib/cjs/src/api/command/os/GetBackgroundImageSizeCommand.test.js.map +7 -0
- package/lib/cjs/src/api/device-action/DeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/DeviceAction.js.map +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
- package/lib/cjs/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/cjs/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -1
- package/lib/cjs/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/GetDeviceStatus/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/GoToDashboard/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/GoToDashboard/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js.map +2 -2
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListApps/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListApps/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/ListAppsWithMetadata/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppDeviceAction/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js +1 -1
- package/lib/cjs/src/api/device-action/os/OpenAppWithDependencies/types.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -1
- package/lib/cjs/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +3 -3
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
- package/lib/cjs/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
- package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
- package/lib/cjs/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
- package/lib/cjs/src/api/index.js +1 -1
- package/lib/cjs/src/api/index.js.map +3 -3
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
- package/lib/cjs/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
- package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
- package/lib/cjs/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +2 -2
- package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
- package/lib/cjs/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js +1 -1
- package/lib/cjs/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +3 -3
- package/lib/cjs/src/api/transport/model/Errors.js +1 -1
- package/lib/cjs/src/api/transport/model/Errors.js.map +3 -3
- package/lib/cjs/src/api/types.js +1 -1
- package/lib/cjs/src/api/types.js.map +1 -1
- package/lib/cjs/src/api/utils/ApplicationChecker.js +2 -0
- package/lib/cjs/src/api/utils/ApplicationChecker.js.map +7 -0
- package/lib/cjs/src/api/utils/ApplicationChecker.test.js +2 -0
- package/lib/cjs/src/api/utils/ApplicationChecker.test.js.map +7 -0
- package/lib/cjs/src/api/utils/ApplicationResolver.js +2 -0
- package/lib/cjs/src/api/utils/ApplicationResolver.js.map +7 -0
- package/lib/cjs/src/api/utils/Base64String.js +1 -1
- package/lib/cjs/src/api/utils/Base64String.js.map +3 -3
- package/lib/cjs/src/api/utils/Base64String.test.js +1 -1
- package/lib/cjs/src/api/utils/Base64String.test.js.map +3 -3
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js +1 -1
- package/lib/cjs/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
- package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js +1 -1
- package/lib/cjs/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DevicePinger.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DevicePinger.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DevicePinger.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSession.test.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.js.map +3 -3
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js +1 -1
- package/lib/cjs/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +2 -2
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.js +2 -0
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.js.map +7 -0
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.test.js +2 -0
- package/lib/cjs/src/internal/device-session/service/IntentQueueService.test.js.map +7 -0
- package/lib/cjs/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js +2 -0
- package/lib/cjs/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js.map +7 -0
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/cjs/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
- package/lib/cjs/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
- package/lib/esm/package.json +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js +1 -1
- package/lib/esm/src/api/DeviceManagementKit.js.map +2 -2
- package/lib/esm/src/api/apdu/utils/ApduBuilder.js +1 -1
- package/lib/esm/src/api/apdu/utils/ApduBuilder.js.map +3 -3
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.js +2 -0
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.js.map +7 -0
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.test.js +2 -0
- package/lib/esm/src/api/command/os/GetBackgroundImageSizeCommand.test.js.map +7 -0
- package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js +1 -1
- package/lib/esm/src/api/device-action/__test-utils__/makeInternalApi.js.map +3 -3
- package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js +1 -1
- package/lib/esm/src/api/device-action/__test-utils__/setupTestMachine.js.map +3 -3
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js +1 -1
- package/lib/esm/src/api/device-action/model/UserInteractionRequired.js.map +2 -2
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js +1 -0
- package/lib/esm/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.js.map +4 -4
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/types.js +1 -0
- package/lib/esm/src/api/device-action/os/GetDeviceMetadata/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js +1 -0
- package/lib/esm/src/api/device-action/os/GetDeviceStatus/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/GoToDashboard/types.js +1 -0
- package/lib/esm/src/api/device-action/os/GoToDashboard/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -0
- package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/ListApps/ListAppsDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListApps/types.js +1 -0
- package/lib/esm/src/api/device-action/os/ListApps/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/types.js +1 -0
- package/lib/esm/src/api/device-action/os/ListAppsWithMetadata/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/types.js +1 -0
- package/lib/esm/src/api/device-action/os/OpenAppDeviceAction/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/types.js +1 -0
- package/lib/esm/src/api/device-action/os/OpenAppWithDependencies/types.js.map +4 -4
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.js.map +3 -3
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js +1 -1
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.js.map +3 -3
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js +1 -0
- package/lib/esm/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.js.map +4 -4
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js +1 -1
- package/lib/esm/src/api/device-action/task/GetFirmwareMetadataTask.js.map +3 -3
- package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js +1 -1
- package/lib/esm/src/api/device-action/xstate-utils/XStateDeviceAction.js.map +3 -3
- package/lib/esm/src/api/index.js +1 -1
- package/lib/esm/src/api/index.js.map +3 -3
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js +2 -0
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.js.map +7 -0
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js +2 -0
- package/lib/esm/src/api/logger-publisher/utils/noopLoggerFactory.test.js.map +7 -0
- package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js +1 -1
- package/lib/esm/src/api/logger-subscriber/service/WebLogsExporterLogger.test.js.map +3 -3
- package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js +1 -1
- package/lib/esm/src/api/secure-channel/task/ConnectToSecureChannelTask.js.map +3 -3
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js +1 -1
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.js.map +3 -3
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js +1 -1
- package/lib/esm/src/api/transport/model/DeviceConnectionStateMachine.test.js.map +3 -3
- package/lib/esm/src/api/transport/model/Errors.js +1 -1
- package/lib/esm/src/api/transport/model/Errors.js.map +3 -3
- package/lib/esm/src/api/utils/ApplicationChecker.js +2 -0
- package/lib/esm/src/api/utils/ApplicationChecker.js.map +7 -0
- package/lib/esm/src/api/utils/ApplicationChecker.test.js +2 -0
- package/lib/esm/src/api/utils/ApplicationChecker.test.js.map +7 -0
- package/lib/esm/src/api/utils/ApplicationResolver.js +1 -0
- package/lib/esm/src/api/utils/ApplicationResolver.js.map +7 -0
- package/lib/esm/src/api/utils/Base64String.js +1 -1
- package/lib/esm/src/api/utils/Base64String.js.map +3 -3
- package/lib/esm/src/api/utils/Base64String.test.js +1 -1
- package/lib/esm/src/api/utils/Base64String.test.js.map +3 -3
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.js +1 -1
- package/lib/esm/src/internal/device-session/di/deviceSessionModule.js.map +3 -3
- package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js +1 -1
- package/lib/esm/src/internal/device-session/di/deviceSessionTypes.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DevicePinger.js +1 -1
- package/lib/esm/src/internal/device-session/model/DevicePinger.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DevicePinger.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DevicePinger.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DeviceSession.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSession.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSession.test.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionEventDispatcher.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionRefresher.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.js.map +3 -3
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js +1 -1
- package/lib/esm/src/internal/device-session/model/DeviceSessionStateHandler.test.js.map +2 -2
- package/lib/esm/src/internal/device-session/service/IntentQueueService.js +2 -0
- package/lib/esm/src/internal/device-session/service/IntentQueueService.js.map +7 -0
- package/lib/esm/src/internal/device-session/service/IntentQueueService.test.js +2 -0
- package/lib/esm/src/internal/device-session/service/IntentQueueService.test.js.map +7 -0
- package/lib/esm/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js +2 -0
- package/lib/esm/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.js.map +7 -0
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js +1 -1
- package/lib/esm/src/internal/discovery/use-case/ConnectUseCase.test.js.map +3 -3
- package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js +1 -1
- package/lib/esm/src/internal/send/use-case/SendApduUseCase.test.js.map +3 -3
- package/lib/types/src/api/DeviceManagementKit.d.ts +10 -0
- package/lib/types/src/api/DeviceManagementKit.d.ts.map +1 -1
- package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts +7 -0
- package/lib/types/src/api/apdu/utils/ApduBuilder.d.ts.map +1 -1
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.d.ts +17 -0
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.d.ts.map +1 -0
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.test.d.ts +2 -0
- package/lib/types/src/api/command/os/GetBackgroundImageSizeCommand.test.d.ts.map +1 -0
- package/lib/types/src/api/device-action/DeviceAction.d.ts +2 -1
- package/lib/types/src/api/device-action/DeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
- package/lib/types/src/api/device-action/__test-utils__/setupTestMachine.d.ts.map +1 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts +4 -1
- package/lib/types/src/api/device-action/model/UserInteractionRequired.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts +9 -1
- package/lib/types/src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts +13 -2
- package/lib/types/src/api/device-action/os/GetDeviceMetadata/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceStatus/GetDeviceStatusDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts +6 -0
- package/lib/types/src/api/device-action/os/GetDeviceStatus/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts +1 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/GoToDashboardDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/types.d.ts +9 -1
- package/lib/types/src/api/device-action/os/GoToDashboard/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts +9 -1
- package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListApps/ListAppsDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListApps/types.d.ts +6 -0
- package/lib/types/src/api/device-action/os/ListApps/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/ListAppsWithMetadataDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/types.d.ts +8 -1
- package/lib/types/src/api/device-action/os/ListAppsWithMetadata/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts +12 -2
- package/lib/types/src/api/device-action/os/OpenAppDeviceAction/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts +8 -0
- package/lib/types/src/api/device-action/os/OpenAppWithDependencies/types.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts +9 -1
- package/lib/types/src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts +10 -1
- package/lib/types/src/api/device-action/xstate-utils/XStateDeviceAction.d.ts.map +1 -1
- package/lib/types/src/api/index.d.ts +11 -4
- package/lib/types/src/api/index.d.ts.map +1 -1
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts +12 -0
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.d.ts.map +1 -0
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts +2 -0
- package/lib/types/src/api/logger-publisher/utils/noopLoggerFactory.test.d.ts.map +1 -0
- package/lib/types/src/api/secure-channel/task/ConnectToSecureChannelTask.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts +1 -0
- package/lib/types/src/api/transport/model/DeviceConnectionStateMachine.d.ts.map +1 -1
- package/lib/types/src/api/transport/model/Errors.d.ts +5 -0
- package/lib/types/src/api/transport/model/Errors.d.ts.map +1 -1
- package/lib/types/src/api/types.d.ts +1 -0
- package/lib/types/src/api/types.d.ts.map +1 -1
- package/lib/types/src/api/utils/ApplicationChecker.d.ts +14 -0
- package/lib/types/src/api/utils/ApplicationChecker.d.ts.map +1 -0
- package/lib/types/src/api/utils/ApplicationChecker.test.d.ts +2 -0
- package/lib/types/src/api/utils/ApplicationChecker.test.d.ts.map +1 -0
- package/lib/types/src/api/utils/ApplicationResolver.d.ts +12 -0
- package/lib/types/src/api/utils/ApplicationResolver.d.ts.map +1 -0
- package/lib/types/src/api/utils/Base64String.d.ts +1 -0
- package/lib/types/src/api/utils/Base64String.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/di/deviceSessionModule.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts +1 -0
- package/lib/types/src/internal/device-session/di/deviceSessionTypes.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts +13 -2
- package/lib/types/src/internal/device-session/model/DeviceSession.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts +3 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionEventDispatcher.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts +0 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionRefresher.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts +1 -0
- package/lib/types/src/internal/device-session/model/DeviceSessionStateHandler.d.ts.map +1 -1
- package/lib/types/src/internal/device-session/service/IntentQueueService.d.ts +101 -0
- package/lib/types/src/internal/device-session/service/IntentQueueService.d.ts.map +1 -0
- package/lib/types/src/internal/device-session/service/IntentQueueService.test.d.ts +2 -0
- package/lib/types/src/internal/device-session/service/IntentQueueService.test.d.ts.map +1 -0
- package/lib/types/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.d.ts +19 -0
- package/lib/types/src/internal/device-session/use-case/UnsafeBypassIntentQueueUseCase.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js +0 -2
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.js.map +0 -7
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js +0 -2
- package/lib/cjs/src/api/command/os/GetCustomImageSizeCommand.test.js.map +0 -7
- package/lib/cjs/src/internal/device-session/service/MutexService.js +0 -2
- package/lib/cjs/src/internal/device-session/service/MutexService.js.map +0 -7
- package/lib/cjs/src/internal/device-session/service/MutexService.test.js +0 -2
- package/lib/cjs/src/internal/device-session/service/MutexService.test.js.map +0 -7
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js +0 -2
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.js.map +0 -7
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js +0 -2
- package/lib/esm/src/api/command/os/GetCustomImageSizeCommand.test.js.map +0 -7
- package/lib/esm/src/internal/device-session/service/MutexService.js +0 -2
- package/lib/esm/src/internal/device-session/service/MutexService.js.map +0 -7
- package/lib/esm/src/internal/device-session/service/MutexService.test.js +0 -2
- package/lib/esm/src/internal/device-session/service/MutexService.test.js.map +0 -7
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts +0 -17
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.d.ts.map +0 -1
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.test.d.ts +0 -2
- package/lib/types/src/api/command/os/GetCustomImageSizeCommand.test.d.ts.map +0 -1
- package/lib/types/src/internal/device-session/service/MutexService.d.ts +0 -6
- package/lib/types/src/internal/device-session/service/MutexService.d.ts.map +0 -1
- package/lib/types/src/internal/device-session/service/MutexService.test.d.ts +0 -2
- package/lib/types/src/internal/device-session/service/MutexService.test.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, setup } from \"xstate\";\n\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { UnsupportedFirmwareDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport type { GetDeviceMetadataDAOutput } from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nimport type { InstallOrUpdateAppsDAOutput } from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\n\nimport {\n type OpenAppWithDependenciesDAError,\n type OpenAppWithDependenciesDAInput,\n type OpenAppWithDependenciesDAIntermediateValue,\n type OpenAppWithDependenciesDAOutput,\n} from \"./types\";\n\ntype OpenAppWithDependenciesMachineInternalState = {\n readonly error: OpenAppWithDependenciesDAError | null;\n readonly deviceMetadata: GetDeviceMetadataDAOutput | null;\n readonly installResult: InstallOrUpdateAppsDAOutput | null;\n};\n\nexport class OpenAppWithDependenciesDeviceAction extends XStateDeviceAction<\n OpenAppWithDependenciesDAOutput,\n OpenAppWithDependenciesDAInput,\n OpenAppWithDependenciesDAError,\n OpenAppWithDependenciesDAIntermediateValue,\n OpenAppWithDependenciesMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n OpenAppWithDependenciesDAOutput,\n OpenAppWithDependenciesDAInput,\n OpenAppWithDependenciesDAError,\n OpenAppWithDependenciesDAIntermediateValue,\n OpenAppWithDependenciesMachineInternalState\n > {\n type types = StateMachineTypes<\n OpenAppWithDependenciesDAOutput,\n OpenAppWithDependenciesDAInput,\n OpenAppWithDependenciesDAError,\n OpenAppWithDependenciesDAIntermediateValue,\n OpenAppWithDependenciesMachineInternalState\n >;\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getMetadataMachine = new GetDeviceMetadataDeviceAction({\n input: {\n unlockTimeout,\n useSecureChannel: true,\n forceUpdate: false,\n },\n }).makeStateMachine(internalApi);\n\n const installAppsMachine = new InstallOrUpdateAppsDeviceAction({\n input: {\n unlockTimeout,\n applications: [...this.input.dependencies, this.input.application],\n allowMissingApplication: false,\n },\n }).makeStateMachine(internalApi);\n\n const openAppMachine = new OpenAppDeviceAction({\n input: {\n unlockTimeout,\n appName: this.input.application.name,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getMetadata: getMetadataMachine,\n installApps: installAppsMachine,\n openApp: openAppMachine,\n },\n guards: {\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"OpenAppWithDependenciesDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n application: _.input.application,\n dependencies: _.input.dependencies,\n requireLatestFirmware: _.input.requireLatestFirmware,\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n _internalState: {\n error: null,\n deviceMetadata: null,\n installResult: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: [\n {\n target: \"GetDeviceMetadata\",\n },\n ],\n },\n GetDeviceMetadata: {\n exit: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n invoke: {\n id: \"getMetadata\",\n src: \"getMetadata\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n useSecureChannel: true,\n forceUpdate: false,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n deviceId:\n _.event.snapshot.context.intermediateValue.deviceId ??\n _.context.intermediateValue.deviceId,\n }),\n }),\n },\n onDone: {\n target: \"GetDeviceMetadataCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<OpenAppWithDependenciesMachineInternalState>(\n {\n Right: (data) => {\n if (\n _.context.input.requireLatestFirmware &&\n data.firmwareUpdateContext.availableUpdate !==\n undefined\n ) {\n return {\n ..._.context._internalState,\n error: new UnsupportedFirmwareDAError(\n \"Firmware is not the latest version\",\n ),\n };\n } else {\n return {\n ..._.context._internalState,\n deviceMetadata: data,\n };\n }\n },\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetDeviceMetadataCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"InstallDependencies\",\n },\n ],\n },\n InstallDependencies: {\n exit: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n invoke: {\n src: \"installApps\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n applications: [\n ..._.context.input.dependencies,\n _.context.input.application,\n ],\n allowMissingApplication: false,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n installPlan:\n _.event.snapshot.context.intermediateValue.installPlan,\n deviceId:\n _.event.snapshot.context.intermediateValue.deviceId ??\n _.context.intermediateValue.deviceId,\n }),\n }),\n },\n onDone: {\n target: \"InstallDependenciesCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<OpenAppWithDependenciesMachineInternalState>(\n {\n Right: (data) => ({\n ..._.context._internalState,\n installResult: data,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n InstallDependenciesCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"OpenApp\",\n },\n ],\n },\n OpenApp: {\n exit: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n invoke: {\n src: \"openApp\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n appName: _.context.input.application.name,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n installPlan: null,\n }),\n }),\n },\n onDone: {\n target: \"OpenAppCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<OpenAppWithDependenciesMachineInternalState>(\n {\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n OpenAppCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n const { context } = args;\n const { error, deviceMetadata, installResult } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right({\n deviceMetadata: deviceMetadata!,\n installResult: installResult!,\n });\n },\n });\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,SAAAC,MAAa,SAG9B,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,8BAAAC,MAAkC,+BAC3C,OAAS,iCAAAC,MAAqC,wEAE9C,OAAS,mCAAAC,MAAuC,4EAEhD,OAAS,uBAAAC,MAA2B,gEAEpC,OAEE,sBAAAC,MACK,
|
|
6
|
-
"names": ["Left", "Right", "assign", "setup", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "UnsupportedFirmwareDAError", "GetDeviceMetadataDeviceAction", "InstallOrUpdateAppsDeviceAction", "OpenAppDeviceAction", "XStateDeviceAction", "OpenAppWithDependenciesDeviceAction", "internalApi", "unlockTimeout", "getMetadataMachine", "installAppsMachine", "openAppMachine", "context", "_", "data", "error", "args", "deviceMetadata", "installResult"]
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, setup } from \"xstate\";\n\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { DEFAULT_UNLOCK_TIMEOUT_MS } from \"@api/device-action/os/Const\";\nimport { UnsupportedFirmwareDAError } from \"@api/device-action/os/Errors\";\nimport { GetDeviceMetadataDeviceAction } from \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\";\nimport type { GetDeviceMetadataDAOutput } from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport { InstallOrUpdateAppsDeviceAction } from \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\";\nimport type { InstallOrUpdateAppsDAOutput } from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\n\nimport {\n type OpenAppWithDependenciesDAError,\n type OpenAppWithDependenciesDAInput,\n type OpenAppWithDependenciesDAIntermediateValue,\n type OpenAppWithDependenciesDAOutput,\n openAppWithDependenciesDAStateStep,\n} from \"./types\";\n\ntype OpenAppWithDependenciesMachineInternalState = {\n readonly error: OpenAppWithDependenciesDAError | null;\n readonly deviceMetadata: GetDeviceMetadataDAOutput | null;\n readonly installResult: InstallOrUpdateAppsDAOutput | null;\n};\n\nexport class OpenAppWithDependenciesDeviceAction extends XStateDeviceAction<\n OpenAppWithDependenciesDAOutput,\n OpenAppWithDependenciesDAInput,\n OpenAppWithDependenciesDAError,\n OpenAppWithDependenciesDAIntermediateValue,\n OpenAppWithDependenciesMachineInternalState\n> {\n makeStateMachine(\n internalApi: InternalApi,\n ): DeviceActionStateMachine<\n OpenAppWithDependenciesDAOutput,\n OpenAppWithDependenciesDAInput,\n OpenAppWithDependenciesDAError,\n OpenAppWithDependenciesDAIntermediateValue,\n OpenAppWithDependenciesMachineInternalState\n > {\n type types = StateMachineTypes<\n OpenAppWithDependenciesDAOutput,\n OpenAppWithDependenciesDAInput,\n OpenAppWithDependenciesDAError,\n OpenAppWithDependenciesDAIntermediateValue,\n OpenAppWithDependenciesMachineInternalState\n >;\n\n const unlockTimeout = this.input.unlockTimeout ?? DEFAULT_UNLOCK_TIMEOUT_MS;\n\n const getMetadataMachine = new GetDeviceMetadataDeviceAction({\n input: {\n unlockTimeout,\n useSecureChannel: true,\n forceUpdate: false,\n },\n }).makeStateMachine(internalApi);\n\n const installAppsMachine = new InstallOrUpdateAppsDeviceAction({\n input: {\n unlockTimeout,\n applications: [...this.input.dependencies, this.input.application],\n allowMissingApplication: this.input.allowMissingApplication ?? false,\n },\n }).makeStateMachine(internalApi);\n\n const openAppMachine = new OpenAppDeviceAction({\n input: {\n unlockTimeout,\n appName: this.input.application.name,\n },\n }).makeStateMachine(internalApi);\n\n return setup({\n types: {\n input: {\n unlockTimeout,\n } as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n getMetadata: getMetadataMachine,\n installApps: installAppsMachine,\n openApp: openAppMachine,\n },\n guards: {\n hasError: ({ context }) => context._internalState.error !== null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n id: \"OpenAppWithDependenciesDeviceAction\",\n initial: \"DeviceReady\",\n context: (_) => {\n return {\n input: {\n application: _.input.application,\n dependencies: _.input.dependencies,\n requireLatestFirmware: _.input.requireLatestFirmware,\n unlockTimeout: _.input.unlockTimeout,\n },\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n installPlan: null,\n },\n _internalState: {\n error: null,\n deviceMetadata: null,\n installResult: null,\n },\n };\n },\n states: {\n DeviceReady: {\n always: [\n {\n target: \"GetDeviceMetadata\",\n },\n ],\n },\n GetDeviceMetadata: {\n exit: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n invoke: {\n id: \"getMetadata\",\n src: \"getMetadata\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n useSecureChannel: true,\n forceUpdate: false,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n deviceId:\n _.event.snapshot.context.intermediateValue.deviceId ??\n _.context.intermediateValue.deviceId,\n }),\n }),\n },\n onDone: {\n target: \"GetDeviceMetadataCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<OpenAppWithDependenciesMachineInternalState>(\n {\n Right: (data) => {\n if (\n _.context.input.requireLatestFirmware &&\n data.firmwareUpdateContext.availableUpdate !==\n undefined\n ) {\n return {\n ..._.context._internalState,\n error: new UnsupportedFirmwareDAError(\n \"Firmware is not the latest version\",\n ),\n };\n } else {\n return {\n ..._.context._internalState,\n deviceMetadata: data,\n };\n }\n },\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n GetDeviceMetadataCheck: {\n always: [\n {\n target: \"Error\",\n guard: \"hasError\",\n },\n {\n target: \"InstallDependencies\",\n },\n ],\n },\n InstallDependencies: {\n exit: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n invoke: {\n src: \"installApps\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n applications: [\n ..._.context.input.dependencies,\n _.context.input.application,\n ],\n allowMissingApplication:\n this.input.allowMissingApplication ?? false,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n installPlan:\n _.event.snapshot.context.intermediateValue.installPlan,\n deviceId:\n _.event.snapshot.context.intermediateValue.deviceId ??\n _.context.intermediateValue.deviceId,\n }),\n }),\n },\n onDone: {\n target: \"InstallDependenciesCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<OpenAppWithDependenciesMachineInternalState>(\n {\n Right: (data) => ({\n ..._.context._internalState,\n installResult: data,\n }),\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n InstallDependenciesCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"OpenApp\",\n },\n ],\n },\n OpenApp: {\n exit: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction: UserInteractionRequired.None,\n }),\n }),\n invoke: {\n src: \"openApp\",\n input: (_) => ({\n unlockTimeout: _.context.input.unlockTimeout,\n appName: _.context.input.application.name,\n }),\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) => ({\n ..._.context.intermediateValue,\n requiredUserInteraction:\n _.event.snapshot.context.intermediateValue\n .requiredUserInteraction,\n installPlan: null,\n }),\n }),\n },\n onDone: {\n target: \"OpenAppCheck\",\n actions: assign({\n _internalState: (_) =>\n _.event.output.caseOf<OpenAppWithDependenciesMachineInternalState>(\n {\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n },\n ),\n }),\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n OpenAppCheck: {\n always: [\n {\n guard: \"hasError\",\n target: \"Error\",\n },\n {\n target: \"Success\",\n },\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: (args) => {\n const { context } = args;\n const { error, deviceMetadata, installResult } = context._internalState;\n if (error) {\n return Left(error);\n }\n return Right({\n deviceMetadata: deviceMetadata!,\n installResult: installResult!,\n });\n },\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,SAAAC,MAAa,SAG9B,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,6BAAAC,MAAiC,8BAC1C,OAAS,8BAAAC,MAAkC,+BAC3C,OAAS,iCAAAC,MAAqC,wEAE9C,OAAS,mCAAAC,MAAuC,4EAEhD,OAAS,uBAAAC,MAA2B,gEAEpC,OAEE,sBAAAC,MACK,qDAEP,OAKE,sCAAAC,MACK,UAQA,MAAMC,UAA4CF,CAMvD,CACA,iBACEG,EAOA,CASA,MAAMC,EAAgB,KAAK,MAAM,eAAiBT,EAE5CU,EAAqB,IAAIR,EAA8B,CAC3D,MAAO,CACL,cAAAO,EACA,iBAAkB,GAClB,YAAa,EACf,CACF,CAAC,EAAE,iBAAiBD,CAAW,EAEzBG,EAAqB,IAAIR,EAAgC,CAC7D,MAAO,CACL,cAAAM,EACA,aAAc,CAAC,GAAG,KAAK,MAAM,aAAc,KAAK,MAAM,WAAW,EACjE,wBAAyB,KAAK,MAAM,yBAA2B,EACjE,CACF,CAAC,EAAE,iBAAiBD,CAAW,EAEzBI,EAAiB,IAAIR,EAAoB,CAC7C,MAAO,CACL,cAAAK,EACA,QAAS,KAAK,MAAM,YAAY,IAClC,CACF,CAAC,EAAE,iBAAiBD,CAAW,EAE/B,OAAOV,EAAM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"assign", "setup", "UserInteractionRequired", "DEFAULT_UNLOCK_TIMEOUT_MS", "UnsupportedFirmwareDAError", "GetDeviceMetadataDeviceAction", "InstallOrUpdateAppsDeviceAction", "OpenAppDeviceAction", "XStateDeviceAction", "openAppWithDependenciesDAStateStep", "OpenAppWithDependenciesDeviceAction", "internalApi", "unlockTimeout", "getMetadataMachine", "installAppsMachine", "openAppMachine", "context", "_", "data", "error", "args", "deviceMetadata", "installResult"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{makeDeviceActionInternalApiMock as
|
|
1
|
+
import{makeDeviceActionInternalApiMock as T}from"../../../device-action/__test-utils__/makeInternalApi";import{setupGetDeviceMetadataMock as o,setupInstallOrUpdateAppsMock as m,setupOpenAppMock as I}from"../../../device-action/__test-utils__/setupTestMachine";import{testDeviceActionStates as l}from"../../../device-action/__test-utils__/testDeviceActionStates";import{DeviceActionStatus as e}from"../../../device-action/model/DeviceActionState";import{UserInteractionRequired as n}from"../../../device-action/model/UserInteractionRequired";import{UnknownDAError as D,UnsupportedFirmwareDAError as v}from"../../../device-action/os/Errors";import{installOrUpdateAppsDAStateStep as U}from"../../../device-action/os/InstallOrUpdateApps/types";import{OpenAppWithDependenciesDeviceAction as c}from"./OpenAppWithDependenciesDeviceAction";import{openAppWithDependenciesDAStateStep as t}from"./types";vi.mock("@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction");vi.mock("@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction");vi.mock("@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction");describe("OpenAppWithDependenciesDeviceAction",()=>{const p=T(),u={firmwareUpdateContext:{}},s={requiredUserInteraction:n.None,step:U.INSTALL_APPLICATION,installPlan:{installPlan:[{versionName:"1inch"}],alreadyInstalled:["Ethereum","Uniswap"],missingApplications:[""],currentIndex:0,currentProgress:.5}},A={successfullyInstalled:[{versionName:"1inch"}],alreadyInstalled:["Ethereum","Uniswap"],missingApplications:[""]};beforeEach(()=>{vi.clearAllMocks()}),describe("success cases",()=>{it("Open app with dependencies",()=>new Promise((i,a)=>{o(u),m(A,s),I();const d=new c({input:{application:{name:"Ethereum"},dependencies:[{name:"Uniswap"},{name:"1inch"}],requireLatestFirmware:!1}}),r=[{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{...s,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{...s,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{requiredUserInteraction:n.ConfirmOpenApp,installPlan:null,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{output:{deviceMetadata:u,installResult:A},status:e.Completed}];l(d,r,p,{onDone:i,onError:a})}))}),describe("error cases",()=>{it("Get device metadata error",()=>new Promise((i,a)=>{o(u,!0);const d=new c({input:{application:{name:"Ethereum"},dependencies:[{name:"Uniswap"},{name:"1inch"}],requireLatestFirmware:!1}}),r=[{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{error:new D("GetDeviceMetadata failed"),status:e.Error}];l(d,r,p,{onDone:i,onError:a})})),it("Unsupported firmware",()=>new Promise((i,a)=>{o({firmwareUpdateContext:{availableUpdate:"mockUpdate"}});const r=new c({input:{application:{name:"Ethereum"},dependencies:[{name:"Uniswap"},{name:"1inch"}],requireLatestFirmware:!0}}),E=[{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{error:new v("Firmware is not the latest version"),status:e.Error}];l(r,E,p,{onDone:i,onError:a})})),it("Install apps error",()=>new Promise((i,a)=>{o({firmwareUpdateContext:{availableUpdate:"mockUpdate"}}),m(A,s,!0);const r=new c({input:{application:{name:"Ethereum"},dependencies:[{name:"Uniswap"},{name:"1inch"}],requireLatestFirmware:!1}}),E=[{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{...s,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{error:new D("InstallOrUpdateApps failed"),status:e.Error}];l(r,E,p,{onDone:i,onError:a})})),it("Open app error",()=>new Promise((i,a)=>{o(u),m(A,s),I(!0);const d=new c({input:{application:{name:"Ethereum"},dependencies:[{name:"Uniswap"},{name:"1inch"}],requireLatestFirmware:!1}}),r=[{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{requiredUserInteraction:n.None,installPlan:null,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{...s,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{...s,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{intermediateValue:{requiredUserInteraction:n.ConfirmOpenApp,installPlan:null,deviceId:void 0,step:t.GET_DEVICE_METADATA},status:e.Pending},{error:new D("OpenApp failed"),status:e.Error}];l(d,r,p,{onDone:i,onError:a})}))})});
|
|
2
2
|
//# sourceMappingURL=OpenAppWithDependenciesDeviceAction.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/api/device-action/os/OpenAppWithDependencies/OpenAppWithDependenciesDeviceAction.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport {\n setupGetDeviceMetadataMock,\n setupInstallOrUpdateAppsMock,\n setupOpenAppMock,\n} from \"@api/device-action/__test-utils__/setupTestMachine\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nimport type { GetDeviceMetadataDAOutput } from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport type { InstallOrUpdateAppsDAIntermediateValue } from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\n\nimport { OpenAppWithDependenciesDeviceAction } from \"./OpenAppWithDependenciesDeviceAction\";\nimport type { OpenAppWithDependenciesDAState } from \"./types\";\n\nvi.mock(\"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\");\nvi.mock(\n \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\",\n);\nvi.mock(\n \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\",\n);\n\ndescribe(\"OpenAppWithDependenciesDeviceAction\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n\n const DEVICE_METADATA = {\n firmwareUpdateContext: {},\n } as unknown as GetDeviceMetadataDAOutput;\n\n const INSTALL_INTERMEDIATE_VALUE: InstallOrUpdateAppsDAIntermediateValue = {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: {\n installPlan: [{ versionName: \"1inch\" }] as unknown as Application[],\n alreadyInstalled: [\"Ethereum\", \"Uniswap\"],\n missingApplications: [\"\"],\n currentIndex: 0,\n currentProgress: 0.5,\n },\n };\n\n const INSTALL_RESULT = {\n successfullyInstalled: [\n { versionName: \"1inch\" },\n ] as unknown as Application[],\n alreadyInstalled: [\"Ethereum\", \"Uniswap\"],\n missingApplications: [\"\"],\n };\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"success cases\", () => {\n it(\"Open app with dependencies\", () =>\n new Promise<void>((resolve, reject) => {\n setupGetDeviceMetadataMock(DEVICE_METADATA);\n setupInstallOrUpdateAppsMock(\n INSTALL_RESULT,\n INSTALL_INTERMEDIATE_VALUE,\n );\n setupOpenAppMock();\n const deviceAction = new OpenAppWithDependenciesDeviceAction({\n input: {\n application: { name: \"Ethereum\" },\n dependencies: [{ name: \"Uniswap\" }, { name: \"1inch\" }],\n requireLatestFirmware: false,\n },\n });\n\n const expectedStates: Array<OpenAppWithDependenciesDAState> = [\n // GetDeviceMetadata\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n // InstallOrUpdateApps\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: INSTALL_INTERMEDIATE_VALUE,\n status: DeviceActionStatus.Pending,\n },\n // OpenApp\n {\n intermediateValue: INSTALL_INTERMEDIATE_VALUE,\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n // Success\n {\n output: {\n deviceMetadata: DEVICE_METADATA,\n installResult: INSTALL_RESULT,\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onDone: resolve,\n onError: reject,\n });\n }));\n });\n\n describe(\"error cases\", () => {\n it(\"Get device metadata error\", () =>\n new Promise<void>((resolve, reject) => {\n setupGetDeviceMetadataMock(DEVICE_METADATA, true);\n const deviceAction = new OpenAppWithDependenciesDeviceAction({\n input: {\n application: { name: \"Ethereum\" },\n dependencies: [{ name: \"Uniswap\" }, { name: \"1inch\" }],\n requireLatestFirmware: false,\n },\n });\n\n const expectedStates: Array<OpenAppWithDependenciesDAState> = [\n // GetDeviceMetadata\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n // Error\n {\n error: new UnknownDAError(\"GetDeviceMetadata failed\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onDone: resolve,\n onError: reject,\n });\n }));\n\n it(\"Unsupported firmware\", () =>\n new Promise<void>((resolve, reject) => {\n const metadataWithUpdate = {\n firmwareUpdateContext: {\n availableUpdate: \"mockUpdate\",\n },\n } as unknown as GetDeviceMetadataDAOutput;\n setupGetDeviceMetadataMock(metadataWithUpdate);\n const deviceAction = new OpenAppWithDependenciesDeviceAction({\n input: {\n application: { name: \"Ethereum\" },\n dependencies: [{ name: \"Uniswap\" }, { name: \"1inch\" }],\n requireLatestFirmware: true,\n },\n });\n\n const expectedStates: Array<OpenAppWithDependenciesDAState> = [\n // GetDeviceMetadata\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n // Error\n {\n error: new UnsupportedFirmwareDAError(\n \"Firmware is not the latest version\",\n ),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onDone: resolve,\n onError: reject,\n });\n }));\n\n it(\"Install apps error\", () =>\n new Promise<void>((resolve, reject) => {\n const metadataWithUpdate = {\n firmwareUpdateContext: {\n availableUpdate: \"mockUpdate\",\n },\n } as unknown as GetDeviceMetadataDAOutput;\n setupGetDeviceMetadataMock(metadataWithUpdate);\n setupInstallOrUpdateAppsMock(\n INSTALL_RESULT,\n INSTALL_INTERMEDIATE_VALUE,\n true,\n );\n const deviceAction = new OpenAppWithDependenciesDeviceAction({\n input: {\n application: { name: \"Ethereum\" },\n dependencies: [{ name: \"Uniswap\" }, { name: \"1inch\" }],\n requireLatestFirmware: false,\n },\n });\n\n const expectedStates: Array<OpenAppWithDependenciesDAState> = [\n // GetDeviceMetadata\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n // InstallOrUpdateApps\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: INSTALL_INTERMEDIATE_VALUE,\n status: DeviceActionStatus.Pending,\n },\n // Error\n {\n error: new UnknownDAError(\"InstallOrUpdateApps failed\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onDone: resolve,\n onError: reject,\n });\n }));\n\n it(\"Open app error\", () =>\n new Promise<void>((resolve, reject) => {\n setupGetDeviceMetadataMock(DEVICE_METADATA);\n setupInstallOrUpdateAppsMock(\n INSTALL_RESULT,\n INSTALL_INTERMEDIATE_VALUE,\n );\n setupOpenAppMock(true);\n const deviceAction = new OpenAppWithDependenciesDeviceAction({\n input: {\n application: { name: \"Ethereum\" },\n dependencies: [{ name: \"Uniswap\" }, { name: \"1inch\" }],\n requireLatestFirmware: false,\n },\n });\n\n const expectedStates: Array<OpenAppWithDependenciesDAState> = [\n // GetDeviceMetadata\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n // InstallOrUpdateApps\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: INSTALL_INTERMEDIATE_VALUE,\n status: DeviceActionStatus.Pending,\n },\n // OpenApp\n {\n intermediateValue: INSTALL_INTERMEDIATE_VALUE,\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n installPlan: null,\n },\n status: DeviceActionStatus.Pending,\n },\n // Error\n {\n error: new UnknownDAError(\"OpenApp failed\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onDone: resolve,\n onError: reject,\n });\n }));\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,mCAAAA,MAAuC,oDAChD,OACE,8BAAAC,EACA,gCAAAC,EACA,oBAAAC,MACK,qDACP,OAAS,0BAAAC,MAA8B,2DACvC,OAAS,sBAAAC,MAA0B,6CACnC,OAAS,2BAAAC,MAA+B,mDACxC,OACE,kBAAAC,EACA,8BAAAC,MACK,+
|
|
6
|
-
"names": ["makeDeviceActionInternalApiMock", "setupGetDeviceMetadataMock", "setupInstallOrUpdateAppsMock", "setupOpenAppMock", "testDeviceActionStates", "DeviceActionStatus", "UserInteractionRequired", "UnknownDAError", "UnsupportedFirmwareDAError", "OpenAppWithDependenciesDeviceAction", "apiMock", "DEVICE_METADATA", "INSTALL_INTERMEDIATE_VALUE", "INSTALL_RESULT", "resolve", "reject", "deviceAction", "expectedStates"]
|
|
4
|
+
"sourcesContent": ["import { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport {\n setupGetDeviceMetadataMock,\n setupInstallOrUpdateAppsMock,\n setupOpenAppMock,\n} from \"@api/device-action/__test-utils__/setupTestMachine\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport { DeviceActionStatus } from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nimport type { GetDeviceMetadataDAOutput } from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport {\n type InstallOrUpdateAppsDAIntermediateValue,\n installOrUpdateAppsDAStateStep,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\n\nimport { OpenAppWithDependenciesDeviceAction } from \"./OpenAppWithDependenciesDeviceAction\";\nimport {\n type OpenAppWithDependenciesDAState,\n openAppWithDependenciesDAStateStep,\n} from \"./types\";\n\nvi.mock(\"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\");\nvi.mock(\n \"@api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction\",\n);\nvi.mock(\n \"@api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction\",\n);\n\ndescribe(\"OpenAppWithDependenciesDeviceAction\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n\n const DEVICE_METADATA = {\n firmwareUpdateContext: {},\n } as unknown as GetDeviceMetadataDAOutput;\n\n const INSTALL_INTERMEDIATE_VALUE: InstallOrUpdateAppsDAIntermediateValue = {\n requiredUserInteraction: UserInteractionRequired.None,\n step: installOrUpdateAppsDAStateStep.INSTALL_APPLICATION,\n installPlan: {\n installPlan: [{ versionName: \"1inch\" }] as unknown as Application[],\n alreadyInstalled: [\"Ethereum\", \"Uniswap\"],\n missingApplications: [\"\"],\n currentIndex: 0,\n currentProgress: 0.5,\n },\n };\n\n const INSTALL_RESULT = {\n successfullyInstalled: [\n { versionName: \"1inch\" },\n ] as unknown as Application[],\n alreadyInstalled: [\"Ethereum\", \"Uniswap\"],\n missingApplications: [\"\"],\n };\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"success cases\", () => {\n it(\"Open app with dependencies\", () =>\n new Promise<void>((resolve, reject) => {\n setupGetDeviceMetadataMock(DEVICE_METADATA);\n setupInstallOrUpdateAppsMock(\n INSTALL_RESULT,\n INSTALL_INTERMEDIATE_VALUE,\n );\n setupOpenAppMock();\n const deviceAction = new OpenAppWithDependenciesDeviceAction({\n input: {\n application: { name: \"Ethereum\" },\n dependencies: [{ name: \"Uniswap\" }, { name: \"1inch\" }],\n requireLatestFirmware: false,\n },\n });\n\n const expectedStates: Array<OpenAppWithDependenciesDAState> = [\n // GetDeviceMetadata\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n // InstallOrUpdateApps\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n ...INSTALL_INTERMEDIATE_VALUE,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n // OpenApp\n {\n intermediateValue: {\n ...INSTALL_INTERMEDIATE_VALUE,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n installPlan: null,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n // Success\n {\n output: {\n deviceMetadata: DEVICE_METADATA,\n installResult: INSTALL_RESULT,\n },\n status: DeviceActionStatus.Completed,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onDone: resolve,\n onError: reject,\n });\n }));\n });\n\n describe(\"error cases\", () => {\n it(\"Get device metadata error\", () =>\n new Promise<void>((resolve, reject) => {\n setupGetDeviceMetadataMock(DEVICE_METADATA, true);\n const deviceAction = new OpenAppWithDependenciesDeviceAction({\n input: {\n application: { name: \"Ethereum\" },\n dependencies: [{ name: \"Uniswap\" }, { name: \"1inch\" }],\n requireLatestFirmware: false,\n },\n });\n\n const expectedStates: Array<OpenAppWithDependenciesDAState> = [\n // GetDeviceMetadata\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n // Error\n {\n error: new UnknownDAError(\"GetDeviceMetadata failed\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onDone: resolve,\n onError: reject,\n });\n }));\n\n it(\"Unsupported firmware\", () =>\n new Promise<void>((resolve, reject) => {\n const metadataWithUpdate = {\n firmwareUpdateContext: {\n availableUpdate: \"mockUpdate\",\n },\n } as unknown as GetDeviceMetadataDAOutput;\n setupGetDeviceMetadataMock(metadataWithUpdate);\n const deviceAction = new OpenAppWithDependenciesDeviceAction({\n input: {\n application: { name: \"Ethereum\" },\n dependencies: [{ name: \"Uniswap\" }, { name: \"1inch\" }],\n requireLatestFirmware: true,\n },\n });\n\n const expectedStates: Array<OpenAppWithDependenciesDAState> = [\n // GetDeviceMetadata\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n // Error\n {\n error: new UnsupportedFirmwareDAError(\n \"Firmware is not the latest version\",\n ),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onDone: resolve,\n onError: reject,\n });\n }));\n\n it(\"Install apps error\", () =>\n new Promise<void>((resolve, reject) => {\n const metadataWithUpdate = {\n firmwareUpdateContext: {\n availableUpdate: \"mockUpdate\",\n },\n } as unknown as GetDeviceMetadataDAOutput;\n setupGetDeviceMetadataMock(metadataWithUpdate);\n setupInstallOrUpdateAppsMock(\n INSTALL_RESULT,\n INSTALL_INTERMEDIATE_VALUE,\n true,\n );\n const deviceAction = new OpenAppWithDependenciesDeviceAction({\n input: {\n application: { name: \"Ethereum\" },\n dependencies: [{ name: \"Uniswap\" }, { name: \"1inch\" }],\n requireLatestFirmware: false,\n },\n });\n\n const expectedStates: Array<OpenAppWithDependenciesDAState> = [\n // GetDeviceMetadata\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n // InstallOrUpdateApps\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n ...INSTALL_INTERMEDIATE_VALUE,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n // Error\n {\n error: new UnknownDAError(\"InstallOrUpdateApps failed\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onDone: resolve,\n onError: reject,\n });\n }));\n\n it(\"Open app error\", () =>\n new Promise<void>((resolve, reject) => {\n setupGetDeviceMetadataMock(DEVICE_METADATA);\n setupInstallOrUpdateAppsMock(\n INSTALL_RESULT,\n INSTALL_INTERMEDIATE_VALUE,\n );\n setupOpenAppMock(true);\n const deviceAction = new OpenAppWithDependenciesDeviceAction({\n input: {\n application: { name: \"Ethereum\" },\n dependencies: [{ name: \"Uniswap\" }, { name: \"1inch\" }],\n requireLatestFirmware: false,\n },\n });\n\n const expectedStates: Array<OpenAppWithDependenciesDAState> = [\n // GetDeviceMetadata\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n // InstallOrUpdateApps\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n installPlan: null,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n ...INSTALL_INTERMEDIATE_VALUE,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n // OpenApp\n {\n intermediateValue: {\n ...INSTALL_INTERMEDIATE_VALUE,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n {\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n installPlan: null,\n deviceId: undefined,\n step: openAppWithDependenciesDAStateStep.GET_DEVICE_METADATA,\n },\n status: DeviceActionStatus.Pending,\n },\n // Error\n {\n error: new UnknownDAError(\"OpenApp failed\"),\n status: DeviceActionStatus.Error,\n },\n ];\n\n testDeviceActionStates(deviceAction, expectedStates, apiMock, {\n onDone: resolve,\n onError: reject,\n });\n }));\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,mCAAAA,MAAuC,oDAChD,OACE,8BAAAC,EACA,gCAAAC,EACA,oBAAAC,MACK,qDACP,OAAS,0BAAAC,MAA8B,2DACvC,OAAS,sBAAAC,MAA0B,6CACnC,OAAS,2BAAAC,MAA+B,mDACxC,OACE,kBAAAC,EACA,8BAAAC,MACK,+BAEP,OAEE,kCAAAC,MACK,kDAGP,OAAS,uCAAAC,MAA2C,wCACpD,OAEE,sCAAAC,MACK,UAEP,GAAG,KAAK,+DAA+D,EACvE,GAAG,KACD,2EACF,EACA,GAAG,KACD,uEACF,EAEA,SAAS,sCAAuC,IAAM,CACpD,MAAMC,EAAUZ,EAAgC,EAE1Ca,EAAkB,CACtB,sBAAuB,CAAC,CAC1B,EAEMC,EAAqE,CACzE,wBAAyBR,EAAwB,KACjD,KAAMG,EAA+B,oBACrC,YAAa,CACX,YAAa,C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AC,CACN,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["makeDeviceActionInternalApiMock", "setupGetDeviceMetadataMock", "setupInstallOrUpdateAppsMock", "setupOpenAppMock", "testDeviceActionStates", "DeviceActionStatus", "UserInteractionRequired", "UnknownDAError", "UnsupportedFirmwareDAError", "installOrUpdateAppsDAStateStep", "OpenAppWithDependenciesDeviceAction", "openAppWithDependenciesDAStateStep", "apiMock", "DEVICE_METADATA", "INSTALL_INTERMEDIATE_VALUE", "INSTALL_RESULT", "resolve", "reject", "deviceAction", "expectedStates"]
|
|
7
7
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
const e=Object.freeze({GET_DEVICE_METADATA:"os.openAppWithDependencies.steps.getDeviceMetadata",INSTALL_OR_UPDATE_APPS:"os.openAppWithDependencies.steps.installOrUpdateApps",OPEN_APP:"os.openAppWithDependencies.steps.openApp"});export{e as openAppWithDependenciesDAStateStep};
|
|
1
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
4
|
-
"sourcesContent": [],
|
|
5
|
-
"mappings": "",
|
|
6
|
-
"names": []
|
|
3
|
+
"sources": ["../../../../../../../src/api/device-action/os/OpenAppWithDependencies/types.ts"],
|
|
4
|
+
"sourcesContent": ["import type { CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport type { DeviceActionState } from \"@api/device-action/model/DeviceActionState\";\nimport type {\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nimport type {\n GetDeviceMetadataDAOutput,\n GetDeviceMetadataDARequiredInteraction,\n} from \"@api/device-action/os/GetDeviceMetadata/types\";\nimport type { GetDeviceStatusDAInput } from \"@api/device-action/os/GetDeviceStatus/types\";\nimport type {\n ApplicationDependency,\n InstallOrUpdateAppsDAError,\n InstallOrUpdateAppsDAOutput,\n InstallOrUpdateAppsDARequiredInteraction,\n InstallPlan,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport type {\n OpenAppDAError,\n OpenAppDARequiredInteraction,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\n\nexport const openAppWithDependenciesDAStateStep = Object.freeze({\n GET_DEVICE_METADATA: \"os.openAppWithDependencies.steps.getDeviceMetadata\",\n INSTALL_OR_UPDATE_APPS:\n \"os.openAppWithDependencies.steps.installOrUpdateApps\",\n OPEN_APP: \"os.openAppWithDependencies.steps.openApp\",\n} as const);\n\nexport type OpenAppWithDependenciesDAStateStep =\n (typeof openAppWithDependenciesDAStateStep)[keyof typeof openAppWithDependenciesDAStateStep];\n\nexport type OpenAppWithDependenciesDAOutput = {\n deviceMetadata: GetDeviceMetadataDAOutput;\n installResult: InstallOrUpdateAppsDAOutput;\n};\n\nexport type OpenAppWithDependenciesDAInput = GetDeviceStatusDAInput & {\n readonly application: ApplicationDependency;\n readonly dependencies: ApplicationDependency[];\n readonly requireLatestFirmware?: boolean;\n readonly allowMissingApplication?: boolean;\n};\n\nexport type OpenAppWithDependenciesDAError =\n | InstallOrUpdateAppsDAError\n | OpenAppDAError\n | UnknownDAError\n | UnsupportedFirmwareDAError\n | CommandErrorResult[\"error\"];\n\nexport type OpenAppWithDependenciesDARequiredInteraction =\n | GetDeviceMetadataDARequiredInteraction\n | InstallOrUpdateAppsDARequiredInteraction\n | OpenAppDARequiredInteraction;\n\nexport type OpenAppWithDependenciesDAIntermediateValue = {\n requiredUserInteraction: OpenAppWithDependenciesDARequiredInteraction;\n installPlan: InstallPlan | null;\n deviceId?: Uint8Array;\n step: OpenAppWithDependenciesDAStateStep;\n};\n\nexport type OpenAppWithDependenciesDAState = DeviceActionState<\n OpenAppWithDependenciesDAOutput,\n OpenAppWithDependenciesDAError,\n OpenAppWithDependenciesDAIntermediateValue\n>;\n"],
|
|
5
|
+
"mappings": "AAuBO,MAAMA,EAAqC,OAAO,OAAO,CAC9D,oBAAqB,qDACrB,uBACE,uDACF,SAAU,0CACZ,CAAU",
|
|
6
|
+
"names": ["openAppWithDependenciesDAStateStep"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as
|
|
1
|
+
import{Left as p,Right as d}from"purify-ts";import{assign as n,fromPromise as i,setup as s}from"xstate";import{isSuccessCommandResult as C}from"../../../command/model/CommandResult";import{UserInteractionRequired as m}from"../../../device-action/model/UserInteractionRequired";import{UnknownDAError as c}from"../../../device-action/os/Errors";import{OpenAppDeviceAction as u}from"../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{XStateDeviceAction as A}from"../../../device-action/xstate-utils/XStateDeviceAction";import{sendCommandInAppDAStateStep as a}from"./SendCommandInAppDeviceActionTypes";class f extends A{makeStateMachine(t){const{sendCommand:o}=this.extractDependencies(t);return s({types:{input:{},context:{},output:{}},actors:{sendCommand:i(o),openAppStateMachine:new u({input:{appName:this.input.appName}}).makeStateMachine(t)},guards:{skipOpenApp:()=>this.input.skipOpenApp,noInternalError:({context:e})=>e._internalState.error===null},actions:{assignErrorFromEvent:n({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"SendCommandInAppDeviceAction",initial:"InitialState",context:({input:e})=>({input:e,intermediateValue:{requiredUserInteraction:m.None,step:a.OPEN_APP},_internalState:{commandResponse:null,error:null}}),states:{InitialState:{always:[{target:"SendCommand",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName},src:"openAppStateMachine",onSnapshot:{actions:n({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{actions:n({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:r=>({...e.context._internalState,error:r})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"SendCommand",guard:"noInternalError"},"Error"]},SendCommand:{entry:n({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction,step:a.SEND_COMMAND}}),exit:n({intermediateValue:{requiredUserInteraction:m.None,step:a.SEND_COMMAND}}),invoke:{id:"sendCommand",src:"sendCommand",input:({context:e})=>e.input.command,onDone:{target:"SendCommandResultCheck",actions:[n({_internalState:({event:e,context:r})=>C(e.output)?{...r._internalState,commandResponse:e.output.data}:{...r._internalState,error:e.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},SendCommandResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:e})=>e._internalState.commandResponse?d(e._internalState.commandResponse):p(e._internalState.error||new c("No error in final state"))})}extractDependencies(t){return{sendCommand:o=>t.sendCommand(o.input)}}}export{f as SendCommandInAppDeviceAction};
|
|
2
2
|
//# sourceMappingURL=SendCommandInAppDeviceAction.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.ts"],
|
|
4
|
-
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type CommandResult,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport { type Command } from \"@api/types\";\n\nimport {\n type SendCommandInAppDAError,\n type SendCommandInAppDAInput,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAInternalState,\n type SendCommandInAppDAOutput,\n} from \"./SendCommandInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, sends a command\n * to the app.\n * The output will be the result of the command.\n *\n * ```ts\n * input: {\n * appName: string;\n * command: Command<CommandResult, CommandArgs>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new SendCommandInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * command: new MyAppSpecificCommand({commandSpecificArg: \"foo\"}),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class SendCommandInAppDeviceAction<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n > {\n type types = StateMachineTypes<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n >;\n\n const { sendCommand } = this.extractDependencies(internalAPI);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n sendCommand: fromPromise(sendCommand),\n openAppStateMachine: new OpenAppDeviceAction({\n input: {\n appName: this.input.appName,\n },\n }).makeStateMachine(internalAPI),\n },\n guards: {\n skipOpenApp: () => this.input.skipOpenApp,\n noInternalError: ({ context }) => context._internalState.error === null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QFEAuALA0mAngJwEsA7KAcTFQEEII85YARMANwIGMxK3UCB7IgHQB5AA5gilESKasOXHvwDEEfmAHFmvANZreYiVIDKqAIaowAWRNt0xMAG0ADAF1EoEb1gEFRNyAAeiACMQQDsAgAcACwAzKEArABMUfGpEQCcEYkANCA4iFGO8QKhjokxERUpQenp8QC+9bloWLiEJORUNHSwjCzsnNx8ggDC6GBsWqLiktL9ckP8AEpwAK4ANqiKTq5IIB5ePn6BCEFR4YkAbKE1Zemh55URufkI8fcC8TGXl0EVoelHJcio1mhhsPhiGQKNRaPQZAN5MMBGMJlN9LMEQsfCtYBstvYgrt3J5vMNjgUQgJLokHlEgldko50rEXoh3uEvj8-hEAUCQU0QC0Ie1oV04b0sYMfAJOrCerARrwALbKkxECDKVTqIiaHQCGDihVK1XqiA7PwHMn8CmnRJBASOFIxKJXJ21GLpHJ5RARGoCEL3CKXDLpS4pCKgoXgtpQuXdeHzaXI+MSxUqtUaxRgPB4Xh4AQidZmABm+eVBphCd6Jsz5pcltJRz2Jyiv0dvIeNJi8UqoWePoQIccn3iId+sSqkajRF4EDgfmFsY6VbTUqRNr2VuboBOAFpLmzTpd0iV+0EkkEylcAVEo0vISujYnZMn+MIMVJ14tfFum+SWwKb1XkSMdIhuQFEidYNSjvQUH1FVMFW-GVUUmaYDDmV8NyIXF8UbQ4AN3X0ogEF17S9eJQhiJ0ojbI8khHc54mvRwGUBXl7xjR8xXlF9ER-WVV2NDMzQI61f2IhBXUdRw5NDX54gvXkjx+CIzxuMdfnKd44LBVoeKQ-jsWRQxVjYDhenEncAmCcMBHKBlqKyIEYivGIjzDGJqQSYMamDa4BX0kU42E4y30EZBc3zayiNshBSmKFjqn7GCMgHV57lIz0aT9P0lL+S5GkaIA */\n id: \"SendCommandInAppDeviceAction\",\n initial: \"InitialState\",\n context: ({ input }) => {\n return {\n input: input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n _internalState: {\n commandResponse: null,\n error: null,\n },\n };\n },\n states: {\n InitialState: {\n always: [\n {\n target: \"SendCommand\",\n guard: \"skipOpenApp\",\n },\n \"OpenAppDeviceAction\",\n ],\n },\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: {\n appName: this.input.appName,\n },\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<\n SendCommandInAppDAInternalState<\n CommandResponse,\n CommandErrorCodes\n >\n >({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n target: \"CheckOpenAppDeviceActionResult\",\n },\n },\n },\n CheckOpenAppDeviceActionResult: {\n always: [\n {\n target: \"SendCommand\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n SendCommand: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: this.input.requiredUserInteraction,\n },\n }),\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n }),\n invoke: {\n id: \"sendCommand\",\n src: \"sendCommand\",\n input: ({ context }) => context.input.command,\n onDone: {\n target: \"SendCommandResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (isSuccessCommandResult(event.output)) {\n return {\n ...context._internalState,\n commandResponse: event.output.data,\n };\n }\n return {\n ...context._internalState,\n error: event.output.error,\n };\n },\n }),\n ],\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n SendCommandResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.commandResponse\n ? Right(context._internalState.commandResponse)\n : Left(\n context._internalState.error ||\n new UnknownDAError(\"No error in final state\"),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n return {\n sendCommand: (_: {\n input: Command<CommandResponse, CommandArgs, CommandErrorCodes>;\n }): Promise<CommandResult<CommandResponse, CommandErrorCodes>> =>\n internalApi.sendCommand(_.input),\n };\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAEE,0BAAAC,MACK,mCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,uBAAAC,MAA2B,gEAEpC,OAEE,sBAAAC,MACK,
|
|
6
|
-
"names": ["Left", "Right", "assign", "fromPromise", "setup", "isSuccessCommandResult", "UserInteractionRequired", "UnknownDAError", "OpenAppDeviceAction", "XStateDeviceAction", "SendCommandInAppDeviceAction", "internalAPI", "sendCommand", "context", "_", "input", "error", "event", "internalApi"]
|
|
4
|
+
"sourcesContent": ["import { Left, Right } from \"purify-ts\";\nimport { assign, fromPromise, setup } from \"xstate\";\n\nimport {\n type CommandResult,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { type InternalApi } from \"@api/device-action/DeviceAction\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type StateMachineTypes } from \"@api/device-action/xstate-utils/StateMachineTypes\";\nimport {\n type DeviceActionStateMachine,\n XStateDeviceAction,\n} from \"@api/device-action/xstate-utils/XStateDeviceAction\";\nimport { type Command } from \"@api/types\";\n\nimport {\n type SendCommandInAppDAError,\n type SendCommandInAppDAInput,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAInternalState,\n type SendCommandInAppDAOutput,\n sendCommandInAppDAStateStep,\n} from \"./SendCommandInAppDeviceActionTypes\";\n\n/**\n * Tries to open an app on the device, and if it is successful, sends a command\n * to the app.\n * The output will be the result of the command.\n *\n * ```ts\n * input: {\n * appName: string;\n * command: Command<CommandResult, CommandArgs>;\n * requiredUserInteraction: UserInteraction;\n * }\n * ```\n *\n * Example of usage:\n *\n * ```ts\n * const deviceAction = new SendCommandInAppDeviceAction({\n * input: {\n * appName: \"MyApp\",\n * command: new MyAppSpecificCommand({commandSpecificArg: \"foo\"}),\n * requiredUserInteraction: UserInteractionRequired.None,\n * },\n * });\n * dmk.executeDeviceAction({ sessionId: \"mySessionId\", deviceAction });\n * ```\n */\nexport class SendCommandInAppDeviceAction<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction extends UserInteractionRequired,\n> extends XStateDeviceAction<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n> {\n makeStateMachine(\n internalAPI: InternalApi,\n ): DeviceActionStateMachine<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n > {\n type types = StateMachineTypes<\n SendCommandInAppDAOutput<CommandResponse>,\n SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction\n >,\n SendCommandInAppDAError<CommandErrorCodes>,\n SendCommandInAppDAIntermediateValue<UserInteraction>,\n SendCommandInAppDAInternalState<CommandResponse, CommandErrorCodes>\n >;\n\n const { sendCommand } = this.extractDependencies(internalAPI);\n\n return setup({\n types: {\n input: {} as types[\"input\"],\n context: {} as types[\"context\"],\n output: {} as types[\"output\"],\n },\n actors: {\n sendCommand: fromPromise(sendCommand),\n openAppStateMachine: new OpenAppDeviceAction({\n input: {\n appName: this.input.appName,\n },\n }).makeStateMachine(internalAPI),\n },\n guards: {\n skipOpenApp: () => this.input.skipOpenApp,\n noInternalError: ({ context }) => context._internalState.error === null,\n },\n actions: {\n assignErrorFromEvent: assign({\n _internalState: (_) => ({\n ..._.context._internalState,\n error: _.event[\"error\"], // NOTE: it should never happen, the error is not typed anymore here\n }),\n }),\n },\n }).createMachine({\n /** @xstate-layout N4IgpgJg5mDOIC5QFEAuALA0mAngJwEsA7KAcTFQEEII85YARMANwIGMxK3UCB7IgHQB5AA5gilESKasOXHvwDEEfmAHFmvANZreYiVIDKqAIaowAWRNt0xMAG0ADAF1EoEb1gEFRNyAAeiACMQQDsAgAcACwAzKEArABMUfGpEQCcEYkANCA4iFGO8QKhjokxERUpQenp8QC+9bloWLiEJORUNHSwjCzsnNx8ggDC6GBsWqLiktL9ckP8AEpwAK4ANqiKTq5IIB5ePn6BCEFR4YkAbKE1Zemh55URufkI8fcC8TGXl0EVoelHJcio1mhhsPhiGQKNRaPQZAN5MMBGMJlN9LMEQsfCtYBstvYgrt3J5vMNjgUQgJLokHlEgldko50rEXoh3uEvj8-hEAUCQU0QC0Ie1oV04b0sYMfAJOrCerARrwALbKkxECDKVTqIiaHQCGDihVK1XqiA7PwHMn8CmnRJBASOFIxKJXJ21GLpHJ5RARGoCEL3CKXDLpS4pCKgoXgtpQuXdeHzaXI+MSxUqtUaxRgPB4Xh4AQidZmABm+eVBphCd6Jsz5pcltJRz2Jyiv0dvIeNJi8UqoWePoQIccn3iId+sSqkajRF4EDgfmFsY6VbTUqRNr2VuboBOAFpLmzTpd0iV+0EkkEylcAVEo0vISujYnZMn+MIMVJ14tfFum+SWwKb1XkSMdIhuQFEidYNSjvQUH1FVMFW-GVUUmaYDDmV8NyIXF8UbQ4AN3X0ogEF17S9eJQhiJ0ojbI8khHc54mvRwGUBXl7xjR8xXlF9ER-WVV2NDMzQI61f2IhBXUdRw5NDX54gvXkjx+CIzxuMdfnKd44LBVoeKQ-jsWRQxVjYDhenEncAmCcMBHKBlqKyIEYivGIjzDGJqQSYMamDa4BX0kU42E4y30EZBc3zayiNshBSmKFjqn7GCMgHV57lIz0aT9P0lL+S5GkaIA */\n id: \"SendCommandInAppDeviceAction\",\n initial: \"InitialState\",\n context: ({ input }) => {\n return {\n input: input,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: sendCommandInAppDAStateStep.OPEN_APP,\n },\n _internalState: {\n commandResponse: null,\n error: null,\n },\n };\n },\n states: {\n InitialState: {\n always: [\n {\n target: \"SendCommand\",\n guard: \"skipOpenApp\",\n },\n \"OpenAppDeviceAction\",\n ],\n },\n OpenAppDeviceAction: {\n invoke: {\n id: \"openAppStateMachine\",\n input: {\n appName: this.input.appName,\n },\n src: \"openAppStateMachine\",\n onSnapshot: {\n actions: assign({\n intermediateValue: (_) =>\n _.event.snapshot.context.intermediateValue,\n }),\n },\n onDone: {\n actions: assign({\n _internalState: (_) => {\n return _.event.output.caseOf<\n SendCommandInAppDAInternalState<\n CommandResponse,\n CommandErrorCodes\n >\n >({\n Right: () => _.context._internalState,\n Left: (error) => ({\n ..._.context._internalState,\n error,\n }),\n });\n },\n }),\n target: \"CheckOpenAppDeviceActionResult\",\n },\n },\n },\n CheckOpenAppDeviceActionResult: {\n always: [\n {\n target: \"SendCommand\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n SendCommand: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: this.input.requiredUserInteraction,\n step: sendCommandInAppDAStateStep.SEND_COMMAND,\n },\n }),\n exit: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: sendCommandInAppDAStateStep.SEND_COMMAND,\n },\n }),\n invoke: {\n id: \"sendCommand\",\n src: \"sendCommand\",\n input: ({ context }) => context.input.command,\n onDone: {\n target: \"SendCommandResultCheck\",\n actions: [\n assign({\n _internalState: ({ event, context }) => {\n if (isSuccessCommandResult(event.output)) {\n return {\n ...context._internalState,\n commandResponse: event.output.data,\n };\n }\n return {\n ...context._internalState,\n error: event.output.error,\n };\n },\n }),\n ],\n },\n onError: {\n target: \"Error\",\n actions: \"assignErrorFromEvent\",\n },\n },\n },\n SendCommandResultCheck: {\n always: [\n {\n target: \"Success\",\n guard: \"noInternalError\",\n },\n \"Error\",\n ],\n },\n Success: {\n type: \"final\",\n },\n Error: {\n type: \"final\",\n },\n },\n output: ({ context }) =>\n context._internalState.commandResponse\n ? Right(context._internalState.commandResponse)\n : Left(\n context._internalState.error ||\n new UnknownDAError(\"No error in final state\"),\n ),\n });\n }\n\n extractDependencies(internalApi: InternalApi) {\n return {\n sendCommand: (_: {\n input: Command<CommandResponse, CommandArgs, CommandErrorCodes>;\n }): Promise<CommandResult<CommandResponse, CommandErrorCodes>> =>\n internalApi.sendCommand(_.input),\n };\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAC5B,OAAS,UAAAC,EAAQ,eAAAC,EAAa,SAAAC,MAAa,SAE3C,OAEE,0BAAAC,MACK,mCAEP,OAAS,2BAAAC,MAA+B,mDACxC,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,uBAAAC,MAA2B,gEAEpC,OAEE,sBAAAC,MACK,qDAGP,OAME,+BAAAC,MACK,sCA4BA,MA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AEL,CAAC,EACD,OAAQ,gCACV,CACF,CACF,EACA,+BAAgC,CAC9B,OAAQ,CACN,CACE,OAAQ,cACR,MAAO,iBACT,EACA,OACF,CACF,EACA,YAAa,CACX,MAAOf,EAAO,CACZ,kBAAmB,CACjB,wBAAyB,KAAK,MAAM,wBACpC,KAAMQ,EAA4B,YACpC,CACF,CAAC,EACD,KAAMR,EAAO,CACX,kBAAmB,CACjB,wBAAyBI,EAAwB,KACjD,KAAMI,EAA4B,YACpC,CACF,CAAC,EACD,OAAQ,CACN,GAAI,cACJ,IAAK,cACL,MAAO,CAAC,CAAE,QAAAI,CAAQ,IAAMA,EAAQ,MAAM,QACtC,OAAQ,CACN,OAAQ,yBACR,QAAS,CACPZ,EAAO,CACL,eAAgB,CAAC,CAAE,MAAAgB,EAAO,QAAAJ,CAAQ,IAC5BT,EAAuBa,EAAM,MAAM,EAC9B,CACL,GAAGJ,EAAQ,eACX,gBAAiBI,EAAM,OAAO,IAChC,EAEK,CACL,GAAGJ,EAAQ,eACX,MAAOI,EAAM,OAAO,KACtB,CAEJ,CAAC,CACH,CACF,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,uBAAwB,CACtB,OAAQ,CACN,CACE,OAAQ,UACR,MAAO,iBACT,EACA,OACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAAQ,CAAC,CAAE,QAAAJ,CAAQ,IACjBA,EAAQ,eAAe,gBACnBb,EAAMa,EAAQ,eAAe,eAAe,EAC5Cd,EACEc,EAAQ,eAAe,OACrB,IAAIP,EAAe,yBAAyB,CAChD,CACR,CAAC,CACH,CAEA,oBAAoBY,EAA0B,CAC5C,MAAO,CACL,YAAcJ,GAGZI,EAAY,YAAYJ,EAAE,KAAK,CACnC,CACF,CACF",
|
|
6
|
+
"names": ["Left", "Right", "assign", "fromPromise", "setup", "isSuccessCommandResult", "UserInteractionRequired", "UnknownDAError", "OpenAppDeviceAction", "XStateDeviceAction", "sendCommandInAppDAStateStep", "SendCommandInAppDeviceAction", "internalAPI", "sendCommand", "context", "_", "input", "error", "event", "internalApi"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Left as
|
|
1
|
+
import{Left as v,Right as M}from"purify-ts";import{assign as k,createMachine as E}from"xstate";import{ApduBuilder as g}from"../../../apdu/utils/ApduBuilder";import{CommandResultFactory as l}from"../../../command/model/CommandResult";import{makeDeviceActionInternalApiMock as p}from"../../../device-action/__test-utils__/makeInternalApi";import{testDeviceActionStates as C}from"../../../device-action/__test-utils__/testDeviceActionStates";import{DeviceActionStatus as n}from"../../../device-action/model/DeviceActionState";import{UserInteractionRequired as e}from"../../../device-action/model/UserInteractionRequired";import{UnknownDAError as y}from"../../../device-action/os/Errors";import{OpenAppDeviceAction as w}from"../../../device-action/os/OpenAppDeviceAction/OpenAppDeviceAction";import{openAppDAStateStep as D}from"../../../device-action/os/OpenAppDeviceAction/types";import{UnknownDeviceExchangeError as I}from"../../../../../src";import{SendCommandInAppDeviceAction as u}from"./SendCommandInAppDeviceAction";import{sendCommandInAppDAStateStep as s}from"./SendCommandInAppDeviceActionTypes";vi.mock("@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction",async r=>({...await r(),OpenAppDeviceAction:vi.fn(()=>({makeStateMachine:vi.fn()}))}));const A=r=>{w.mockImplementation(()=>({makeStateMachine:vi.fn().mockImplementation(()=>E({initial:"pending",states:{pending:{entry:k({intermediateValue:{requiredUserInteraction:e.ConfirmOpenApp,step:D.GET_DEVICE_STATUS}}),after:{0:"done"}},done:{type:"final"}},output:()=>r?v(r):M(void 0)}))}))};describe("SendCommandInAppDeviceAction",()=>{const r=vi.fn(),i=()=>({sendCommand:r}),{sendCommand:f}=p(),m={paramString:"aParameter",paramNumber:1234},S={aNumber:5678,aString:"mockedResponseString"};beforeEach(()=>{vi.resetAllMocks()}),describe("without mocking extractDependencies",()=>{it("should call sendCommand on internalApi with the correct parameters",async()=>{A(),f.mockResolvedValue(l({data:void 0}));const o=new u({input:{command:new d(m),appName:"MyApp",requiredUserInteraction:e.VerifyAddress,skipOpenApp:!1}});await new Promise((a,t)=>{o._execute(p()).observable.subscribe({error:()=>t(),complete:()=>a(),next:()=>{}})}),expect(f).toHaveBeenCalledWith(new d(m))})}),describe("error cases",()=>{it("should error and output the error if the open app fails",()=>new Promise((o,a)=>{A(new y("Mocked error"));const t=[{status:n.Pending,intermediateValue:{requiredUserInteraction:e.None,step:s.OPEN_APP}},{status:n.Pending,intermediateValue:{requiredUserInteraction:e.ConfirmOpenApp,step:D.GET_DEVICE_STATUS}},{status:n.Error,error:new y("Mocked error")}];C(new u({input:{command:new d(m),appName:"MyApp",requiredUserInteraction:e.VerifyAddress,skipOpenApp:!1}}),t,p(),{onDone:o,onError:a})})),it("should error and output an error if the send command fails",()=>new Promise((o,a)=>{A(),r.mockResolvedValue(l({error:new I("Mocked error")}));const t=new u({input:{command:new d(m),appName:"MyApp",requiredUserInteraction:e.VerifyAddress,skipOpenApp:!1}});vi.spyOn(t,"extractDependencies").mockImplementation(i);const c=[{status:n.Pending,intermediateValue:{requiredUserInteraction:e.None,step:s.OPEN_APP}},{status:n.Pending,intermediateValue:{requiredUserInteraction:e.ConfirmOpenApp,step:D.GET_DEVICE_STATUS}},{status:n.Pending,intermediateValue:{requiredUserInteraction:e.VerifyAddress,step:s.SEND_COMMAND}},{status:n.Error,error:new I("Mocked error")}];C(t,c,p(),{onDone:o,onError:a})}))}),describe("success cases",()=>{it("should succeed and output the command result if the send command succeeds",()=>new Promise((o,a)=>{A(),r.mockResolvedValue(l({data:S}));const t=new u({input:{command:new d(m),appName:"MyApp",requiredUserInteraction:e.VerifyAddress,skipOpenApp:!1}});vi.spyOn(t,"extractDependencies").mockImplementation(i);const c=[{status:n.Pending,intermediateValue:{requiredUserInteraction:e.None,step:s.OPEN_APP}},{status:n.Pending,intermediateValue:{requiredUserInteraction:e.ConfirmOpenApp,step:D.GET_DEVICE_STATUS}},{status:n.Pending,intermediateValue:{requiredUserInteraction:e.VerifyAddress,step:s.SEND_COMMAND}},{status:n.Completed,output:S}];C(t,c,p(),{onDone:o,onError:a})})),it("should succeed while skipping OpenApp",()=>new Promise((o,a)=>{A(),r.mockResolvedValue(l({data:S}));const t=new u({input:{command:new d(m),appName:"MyApp",requiredUserInteraction:e.VerifyAddress,skipOpenApp:!0}});vi.spyOn(t,"extractDependencies").mockImplementation(i);const c=[{status:n.Pending,intermediateValue:{requiredUserInteraction:e.VerifyAddress,step:s.SEND_COMMAND}},{status:n.Completed,output:S}];C(t,c,p(),{onDone:o,onError:a})}))})});class d{name="testCommand";params;constructor(i){this.params=i}getApdu(){return new g({cla:0,ins:1,p1:2,p2:3}).add32BitUIntToData(this.params.paramNumber).addAsciiStringToData(this.params.paramString).build()}parseResponse(){return l({data:{aNumber:1,aString:"aString"}})}}
|
|
2
2
|
//# sourceMappingURL=SendCommandInAppDeviceAction.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceAction.test.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint @typescript-eslint/consistent-type-imports:0 */\nimport { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { type Command } from \"@api/types\";\nimport { UnknownDeviceExchangeError } from \"@root/src\";\n\nimport { SendCommandInAppDeviceAction } from \"./SendCommandInAppDeviceAction\";\nimport {\n type SendCommandInAppDAError,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAOutput,\n} from \"./SendCommandInAppDeviceActionTypes\";\n\nvi.mock(\n \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\",\n async (importOriginal) => {\n const original =\n await importOriginal<\n typeof import(\"../OpenAppDeviceAction/OpenAppDeviceAction\")\n >();\n\n return {\n ...original,\n OpenAppDeviceAction: vi.fn(() => ({\n makeStateMachine: vi.fn(),\n })),\n };\n },\n);\n\nconst setupOpenAppDAMock = (error?: unknown) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"pending\",\n states: {\n pending: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => (error ? Left(error) : Right(undefined)),\n }),\n ),\n }));\n};\n\ndescribe(\"SendCommandInAppDeviceAction\", () => {\n const sendMyCommand = vi.fn();\n\n const extractDependenciesMock = () => ({\n sendCommand: sendMyCommand,\n });\n\n const { sendCommand: apiSendCommandMock } = makeDeviceActionInternalApiMock();\n\n const commandParams = {\n paramString: \"aParameter\",\n paramNumber: 1234,\n };\n const mockedCommandResponse = {\n aNumber: 5678,\n aString: \"mockedResponseString\",\n };\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"without mocking extractDependencies\", () => {\n it(\"should call sendCommand on internalApi with the correct parameters\", async () => {\n setupOpenAppDAMock();\n apiSendCommandMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n\n const deviceAction = new SendCommandInAppDeviceAction({\n input: {\n command: new TestCommand(commandParams),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n await new Promise<void>((resolve, reject) => {\n deviceAction\n ._execute(makeDeviceActionInternalApiMock())\n .observable.subscribe({\n error: () => reject(),\n complete: () => resolve(),\n next: () => {},\n });\n });\n\n expect(apiSendCommandMock).toHaveBeenCalledWith(\n new TestCommand(commandParams),\n );\n });\n });\n\n describe(\"error cases\", () => {\n it(\"should error and output the error if the open app fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock(new UnknownDAError(\"Mocked error\"));\n\n const expectedStates: MyCommandSendCommandDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n new SendCommandInAppDeviceAction({\n input: {\n command: new TestCommand(commandParams),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n }),\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error and output an error if the send command fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n sendMyCommand.mockResolvedValue(\n CommandResultFactory({\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n }),\n );\n\n const deviceAction = new SendCommandInAppDeviceAction({\n input: {\n command: new TestCommand(commandParams),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandSendCommandDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should succeed and output the command result if the send command succeeds\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n sendMyCommand.mockResolvedValue(\n CommandResultFactory({ data: mockedCommandResponse }),\n );\n\n const deviceAction = new SendCommandInAppDeviceAction({\n input: {\n command: new TestCommand(commandParams),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandSendCommandDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: mockedCommandResponse,\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should succeed while skipping OpenApp\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n sendMyCommand.mockResolvedValue(\n CommandResultFactory({ data: mockedCommandResponse }),\n );\n\n const deviceAction = new SendCommandInAppDeviceAction({\n input: {\n command: new TestCommand(commandParams),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: true,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandSendCommandDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: mockedCommandResponse,\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n});\n\ntype MyCommandResponse = {\n aNumber: number;\n aString: string;\n};\n\ntype MyCommandParams = {\n paramString: string;\n paramNumber: number;\n};\n\nclass TestCommand implements Command<MyCommandResponse, MyCommandParams> {\n readonly name = \"testCommand\";\n\n params: MyCommandParams;\n constructor(params: MyCommandParams) {\n this.params = params;\n }\n getApdu(): Apdu {\n return new ApduBuilder({ cla: 0x00, ins: 0x01, p1: 0x02, p2: 0x03 })\n .add32BitUIntToData(this.params.paramNumber)\n .addAsciiStringToData(this.params.paramString)\n .build();\n }\n parseResponse() {\n return CommandResultFactory({ data: { aNumber: 1, aString: \"aString\" } });\n }\n}\n\ntype MyCommandSendCommandDAState = DeviceActionState<\n SendCommandInAppDAOutput<MyCommandResponse>,\n SendCommandInAppDAError<UnknownDAError>,\n SendCommandInAppDAIntermediateValue<\n UserInteractionRequired.None | UserInteractionRequired.VerifyAddress\n >\n>;\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Left", "Right", "assign", "createMachine", "ApduBuilder", "CommandResultFactory", "makeDeviceActionInternalApiMock", "testDeviceActionStates", "DeviceActionStatus", "UserInteractionRequired", "UnknownDAError", "OpenAppDeviceAction", "UnknownDeviceExchangeError", "SendCommandInAppDeviceAction", "importOriginal", "setupOpenAppDAMock", "error", "sendMyCommand", "extractDependenciesMock", "apiSendCommandMock", "commandParams", "mockedCommandResponse", "deviceAction", "TestCommand", "resolve", "reject", "expectedStates", "params"]
|
|
4
|
+
"sourcesContent": ["/* eslint @typescript-eslint/consistent-type-imports:0 */\n\nimport { Left, Right } from \"purify-ts\";\nimport { type Mock } from \"vitest\";\nimport { assign, createMachine } from \"xstate\";\n\nimport { type Apdu } from \"@api/apdu/model/Apdu\";\nimport { ApduBuilder } from \"@api/apdu/utils/ApduBuilder\";\nimport { CommandResultFactory } from \"@api/command/model/CommandResult\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport { testDeviceActionStates } from \"@api/device-action/__test-utils__/testDeviceActionStates\";\nimport {\n type DeviceActionState,\n DeviceActionStatus,\n} from \"@api/device-action/model/DeviceActionState\";\nimport { UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport { UnknownDAError } from \"@api/device-action/os/Errors\";\nimport { OpenAppDeviceAction } from \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\";\nimport { openAppDAStateStep } from \"@api/device-action/os/OpenAppDeviceAction/types\";\nimport { type Command } from \"@api/types\";\nimport { UnknownDeviceExchangeError } from \"@root/src\";\n\nimport { SendCommandInAppDeviceAction } from \"./SendCommandInAppDeviceAction\";\nimport {\n type SendCommandInAppDAError,\n type SendCommandInAppDAIntermediateValue,\n type SendCommandInAppDAOutput,\n sendCommandInAppDAStateStep,\n} from \"./SendCommandInAppDeviceActionTypes\";\n\nvi.mock(\n \"@api/device-action/os/OpenAppDeviceAction/OpenAppDeviceAction\",\n async (importOriginal) => {\n const original =\n await importOriginal<\n typeof import(\"../OpenAppDeviceAction/OpenAppDeviceAction\")\n >();\n\n return {\n ...original,\n OpenAppDeviceAction: vi.fn(() => ({\n makeStateMachine: vi.fn(),\n })),\n };\n },\n);\n\nconst setupOpenAppDAMock = (error?: unknown) => {\n (OpenAppDeviceAction as Mock).mockImplementation(() => ({\n makeStateMachine: vi.fn().mockImplementation(() =>\n createMachine({\n initial: \"pending\",\n states: {\n pending: {\n entry: assign({\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n }),\n after: {\n 0: \"done\",\n },\n },\n done: {\n type: \"final\",\n },\n },\n output: () => (error ? Left(error) : Right(undefined)),\n }),\n ),\n }));\n};\n\ndescribe(\"SendCommandInAppDeviceAction\", () => {\n const sendMyCommand = vi.fn();\n\n const extractDependenciesMock = () => ({\n sendCommand: sendMyCommand,\n });\n\n const { sendCommand: apiSendCommandMock } = makeDeviceActionInternalApiMock();\n\n const commandParams = {\n paramString: \"aParameter\",\n paramNumber: 1234,\n };\n const mockedCommandResponse = {\n aNumber: 5678,\n aString: \"mockedResponseString\",\n };\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"without mocking extractDependencies\", () => {\n it(\"should call sendCommand on internalApi with the correct parameters\", async () => {\n setupOpenAppDAMock();\n apiSendCommandMock.mockResolvedValue(\n CommandResultFactory({ data: undefined }),\n );\n\n const deviceAction = new SendCommandInAppDeviceAction({\n input: {\n command: new TestCommand(commandParams),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n await new Promise<void>((resolve, reject) => {\n deviceAction\n ._execute(makeDeviceActionInternalApiMock())\n .observable.subscribe({\n error: () => reject(),\n complete: () => resolve(),\n next: () => {},\n });\n });\n\n expect(apiSendCommandMock).toHaveBeenCalledWith(\n new TestCommand(commandParams),\n );\n });\n });\n\n describe(\"error cases\", () => {\n it(\"should error and output the error if the open app fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock(new UnknownDAError(\"Mocked error\"));\n\n const expectedStates: MyCommandSendCommandDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: sendCommandInAppDAStateStep.OPEN_APP,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDAError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n new SendCommandInAppDeviceAction({\n input: {\n command: new TestCommand(commandParams),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n }),\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should error and output an error if the send command fails\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n sendMyCommand.mockResolvedValue(\n CommandResultFactory({\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n }),\n );\n\n const deviceAction = new SendCommandInAppDeviceAction({\n input: {\n command: new TestCommand(commandParams),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandSendCommandDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: sendCommandInAppDAStateStep.OPEN_APP,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n step: sendCommandInAppDAStateStep.SEND_COMMAND,\n },\n },\n {\n status: DeviceActionStatus.Error,\n error: new UnknownDeviceExchangeError(\"Mocked error\"),\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n\n describe(\"success cases\", () => {\n it(\"should succeed and output the command result if the send command succeeds\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n sendMyCommand.mockResolvedValue(\n CommandResultFactory({ data: mockedCommandResponse }),\n );\n\n const deviceAction = new SendCommandInAppDeviceAction({\n input: {\n command: new TestCommand(commandParams),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandSendCommandDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.None,\n step: sendCommandInAppDAStateStep.OPEN_APP,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.ConfirmOpenApp,\n step: openAppDAStateStep.GET_DEVICE_STATUS,\n },\n },\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n step: sendCommandInAppDAStateStep.SEND_COMMAND,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: mockedCommandResponse,\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n\n it(\"should succeed while skipping OpenApp\", () =>\n new Promise<void>((resolve, reject) => {\n setupOpenAppDAMock();\n\n sendMyCommand.mockResolvedValue(\n CommandResultFactory({ data: mockedCommandResponse }),\n );\n\n const deviceAction = new SendCommandInAppDeviceAction({\n input: {\n command: new TestCommand(commandParams),\n appName: \"MyApp\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: true,\n },\n });\n\n vi.spyOn(deviceAction, \"extractDependencies\").mockImplementation(\n extractDependenciesMock,\n );\n\n const expectedStates: MyCommandSendCommandDAState[] = [\n {\n status: DeviceActionStatus.Pending,\n intermediateValue: {\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n step: sendCommandInAppDAStateStep.SEND_COMMAND,\n },\n },\n {\n status: DeviceActionStatus.Completed,\n output: mockedCommandResponse,\n },\n ];\n\n testDeviceActionStates(\n deviceAction,\n expectedStates,\n makeDeviceActionInternalApiMock(),\n {\n onDone: resolve,\n onError: reject,\n },\n );\n }));\n });\n});\n\ntype MyCommandResponse = {\n aNumber: number;\n aString: string;\n};\n\ntype MyCommandParams = {\n paramString: string;\n paramNumber: number;\n};\n\nclass TestCommand implements Command<MyCommandResponse, MyCommandParams> {\n readonly name = \"testCommand\";\n\n params: MyCommandParams;\n constructor(params: MyCommandParams) {\n this.params = params;\n }\n getApdu(): Apdu {\n return new ApduBuilder({ cla: 0x00, ins: 0x01, p1: 0x02, p2: 0x03 })\n .add32BitUIntToData(this.params.paramNumber)\n .addAsciiStringToData(this.params.paramString)\n .build();\n }\n parseResponse() {\n return CommandResultFactory({ data: { aNumber: 1, aString: \"aString\" } });\n }\n}\n\ntype MyCommandSendCommandDAState = DeviceActionState<\n SendCommandInAppDAOutput<MyCommandResponse>,\n SendCommandInAppDAError<UnknownDAError>,\n SendCommandInAppDAIntermediateValue<\n UserInteractionRequired.None | UserInteractionRequired.VerifyAddress\n >\n>;\n"],
|
|
5
|
+
"mappings": "AAEA,OAAS,QAAAA,EAAM,SAAAC,MAAa,YAE5B,OAAS,UAAAC,EAAQ,iBAAAC,MAAqB,SAGtC,OAAS,eAAAC,MAAmB,8BAC5B,OAAS,wBAAAC,MAA4B,mCACrC,OAAS,mCAAAC,MAAuC,oDAChD,OAAS,0BAAAC,MAA8B,2DACvC,OAEE,sBAAAC,MACK,6CACP,OAAS,2BAAAC,MAA+B,mDAC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hB,EACEiB,EACAI,EACAtB,EAAgC,EAChC,CACE,OAAQoB,EACR,QAASC,CACX,CACF,CACF,CAAC,CAAC,EAEJ,GAAG,wCAAyC,IAC1C,IAAI,QAAc,CAACD,EAASC,IAAW,CACrCV,EAAmB,EAEnBE,EAAc,kBACZd,EAAqB,CAAE,KAAMkB,CAAsB,CAAC,CACtD,EAEA,MAAMC,EAAe,IAAIV,EAA6B,CACpD,MAAO,CACL,QAAS,IAAIW,EAAYH,CAAa,EACtC,QAAS,QACT,wBAAyBb,EAAwB,cACjD,YAAa,EACf,CACF,CAAC,EAED,GAAG,MAAMe,EAAc,qBAAqB,EAAE,mBAC5CJ,CACF,EAEA,MAAMQ,EAAgD,CACpD,CACE,OAAQpB,EAAmB,QAC3B,kBAAmB,CACjB,wBAAyBC,EAAwB,cACjD,KAAMM,EAA4B,YACpC,CACF,EACA,CACE,OAAQP,EAAmB,UAC3B,OAAQe,CACV,CACF,EAEAhB,EACEiB,EACAI,EACAtB,EAAgC,EAChC,CACE,OAAQoB,EACR,QAASC,CACX,CACF,CACF,CAAC,CAAC,CACN,CAAC,CACH,CAAC,EAYD,MAAMF,CAAmE,CAC9D,KAAO,cAEhB,OACA,YAAYI,EAAyB,CACnC,KAAK,OAASA,CAChB,CACA,SAAgB,CACd,OAAO,IAAIzB,EAAY,CAAE,IAAK,EAAM,IAAK,EAAM,GAAI,EAAM,GAAI,CAAK,CAAC,EAChE,mBAAmB,KAAK,OAAO,WAAW,EAC1C,qBAAqB,KAAK,OAAO,WAAW,EAC5C,MAAM,CACX,CACA,eAAgB,CACd,OAAOC,EAAqB,CAAE,KAAM,CAAE,QAAS,EAAG,QAAS,SAAU,CAAE,CAAC,CAC1E,CACF",
|
|
6
|
+
"names": ["Left", "Right", "assign", "createMachine", "ApduBuilder", "CommandResultFactory", "makeDeviceActionInternalApiMock", "testDeviceActionStates", "DeviceActionStatus", "UserInteractionRequired", "UnknownDAError", "OpenAppDeviceAction", "openAppDAStateStep", "UnknownDeviceExchangeError", "SendCommandInAppDeviceAction", "sendCommandInAppDAStateStep", "importOriginal", "setupOpenAppDAMock", "error", "sendMyCommand", "extractDependenciesMock", "apiSendCommandMock", "commandParams", "mockedCommandResponse", "deviceAction", "TestCommand", "resolve", "reject", "expectedStates", "params"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
4
|
-
"sourcesContent": [],
|
|
5
|
-
"mappings": "",
|
|
6
|
-
"names": []
|
|
3
|
+
"sources": ["../../../../../../../src/api/device-action/os/SendCommandInAppDeviceAction/SendCommandInAppDeviceActionTypes.ts"],
|
|
4
|
+
"sourcesContent": ["import { type CommandErrorResult } from \"@api/command/model/CommandResult\";\nimport { type UserInteractionRequired } from \"@api/device-action/model/UserInteractionRequired\";\nimport {\n type OpenAppDAError,\n type OpenAppDAIntermediateValue,\n} from \"@api/device-action/os/OpenAppDeviceAction/types\";\nimport { type Command } from \"@api/types\";\n\nexport const sendCommandInAppDAStateStep = Object.freeze({\n OPEN_APP: \"os.sendCommandInApp.steps.openApp\",\n SEND_COMMAND: \"os.sendCommandInApp.steps.sendCommand\",\n} as const);\n\nexport type SendCommandInAppDAStateStep =\n (typeof sendCommandInAppDAStateStep)[keyof typeof sendCommandInAppDAStateStep];\n\nexport type SendCommandInAppDAOutput<CommandResponse> = CommandResponse;\n\nexport type SendCommandInAppDAInput<\n CommandResponse,\n CommandArgs,\n CommandErrorCodes,\n UserInteraction,\n> = {\n readonly command: Command<CommandResponse, CommandArgs, CommandErrorCodes>;\n readonly appName: string;\n readonly skipOpenApp: boolean;\n readonly requiredUserInteraction: UserInteraction;\n};\n\nexport type SendCommandInAppDAError<CommandErrorCodes = void> =\n | OpenAppDAError\n | CommandErrorResult<CommandErrorCodes>[\"error\"];\n\nexport type SendCommandInAppDARequiredInteraction =\n UserInteractionRequired.None;\n\nexport type SendCommandInAppDAIntermediateValue<UserInteraction> =\n | {\n readonly requiredUserInteraction:\n | UserInteraction\n | SendCommandInAppDARequiredInteraction;\n readonly step: SendCommandInAppDAStateStep;\n }\n | OpenAppDAIntermediateValue;\n\nexport type SendCommandInAppDAInternalState<\n CommandResponse,\n CommandErrorCodes,\n> = {\n readonly commandResponse: CommandResponse | null;\n readonly error: SendCommandInAppDAError<CommandErrorCodes> | null;\n};\n"],
|
|
5
|
+
"mappings": "AAQO,MAAMA,EAA8B,OAAO,OAAO,CACvD,SAAU,oCACV,aAAc,uCAChB,CAAU",
|
|
6
|
+
"names": ["sendCommandInAppDAStateStep"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{InvalidGetFirmwareMetadataResponseError as F}from"../../command/Errors";import{CommandResultFactory as c,isSuccessCommandResult as u}from"../../command/model/CommandResult";import{
|
|
1
|
+
import{InvalidGetFirmwareMetadataResponseError as F}from"../../command/Errors";import{CommandResultFactory as c,isSuccessCommandResult as u}from"../../command/model/CommandResult";import{GetBackgroundImageSizeCommand as V}from"../../command/os/GetBackgroundImageSizeCommand";import{GetOsVersionCommand as g}from"../../command/os/GetOsVersionCommand";class R{constructor(e){this.api=e}async run(){const e=await this.api.sendCommand(new g);if(!u(e))return e;const m={mcu:e.data.mcuSephVersion,bootloader:e.data.mcuBootloaderVersion,os:e.data.seVersion,metadata:e.data},r=this.api.getManagerApiService(),n=await r.getDeviceVersion(e.data).chain(a=>r.getFirmwareVersion(e.data,a).map(i=>({deviceVersion:a,currentFirmware:i})));if(n.isLeft())return c({error:new F});const{deviceVersion:s,currentFirmware:o}=n.unsafeCoerce(),w=(await r.getLatestFirmwareVersion(o,s).chain(a=>r.getNextFirmwareVersion(a).chain(i=>r.getMcuList().map(t=>t.find(l=>l.name===m.mcu)).map(t=>t===void 0||!i.mcuVersions.includes(t.id)).map(t=>({osuFirmware:a,finalFirmware:i,mcuUpdateRequired:t}))))).caseOf({Right:a=>a,Left:a=>{}}),f={currentFirmware:o,availableUpdate:w};let d={};const p=await this.api.sendCommand(new V);return u(p)&&(d={size:p.data}),c({data:{deviceVersion:s,firmware:o,firmwareVersion:m,firmwareUpdateContext:f,customImage:d}})}}export{R as GetFirmwareMetadataTask};
|
|
2
2
|
//# sourceMappingURL=GetFirmwareMetadataTask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/api/device-action/task/GetFirmwareMetadataTask.ts"],
|
|
4
|
-
"sourcesContent": ["import { InvalidGetFirmwareMetadataResponseError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport {
|
|
5
|
-
"mappings": "AAAA,OAAS,2CAAAA,MAA+C,sBACxD,OAEE,wBAAAC,EACA,0BAAAC,MACK,mCACP,OAAS,
|
|
6
|
-
"names": ["InvalidGetFirmwareMetadataResponseError", "CommandResultFactory", "isSuccessCommandResult", "
|
|
4
|
+
"sourcesContent": ["import { InvalidGetFirmwareMetadataResponseError } from \"@api/command/Errors\";\nimport {\n type CommandResult,\n CommandResultFactory,\n isSuccessCommandResult,\n} from \"@api/command/model/CommandResult\";\nimport { GetBackgroundImageSizeCommand } from \"@api/command/os/GetBackgroundImageSizeCommand\";\nimport { GetOsVersionCommand } from \"@api/command/os/GetOsVersionCommand\";\nimport type { InternalApi } from \"@api/device-action/DeviceAction\";\nimport {\n type CustomImage,\n type FirmwareUpdate,\n type FirmwareUpdateContext,\n type FirmwareVersion,\n} from \"@api/device-session/DeviceSessionState\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nexport type GetFirmwareMetadataTaskResult = CommandResult<{\n deviceVersion: DeviceVersion;\n firmware: FinalFirmware;\n firmwareVersion: FirmwareVersion;\n firmwareUpdateContext: FirmwareUpdateContext;\n customImage: CustomImage;\n}>;\n\nexport class GetFirmwareMetadataTask {\n constructor(private readonly api: InternalApi) {}\n\n async run(): Promise<GetFirmwareMetadataTaskResult> {\n // Get installed firmware metadata\n const osVersion = await this.api.sendCommand(new GetOsVersionCommand());\n if (!isSuccessCommandResult(osVersion)) {\n return osVersion;\n }\n const firmwareVersion: FirmwareVersion = {\n mcu: osVersion.data.mcuSephVersion,\n bootloader: osVersion.data.mcuBootloaderVersion,\n os: osVersion.data.seVersion,\n metadata: osVersion.data,\n };\n\n // Fetch current firmware metadata from app store\n const manager = this.api.getManagerApiService();\n const result = await manager\n .getDeviceVersion(osVersion.data)\n .chain((deviceVersion) =>\n manager\n .getFirmwareVersion(osVersion.data, deviceVersion)\n .map((currentFirmware) => ({ deviceVersion, currentFirmware })),\n );\n if (result.isLeft()) {\n return CommandResultFactory({\n error: new InvalidGetFirmwareMetadataResponseError(),\n });\n }\n const { deviceVersion, currentFirmware } = result.unsafeCoerce();\n\n // Fetch latest firmware available, if any\n const maybeUpdate = await manager\n .getLatestFirmwareVersion(currentFirmware, deviceVersion)\n .chain((osuFirmware) =>\n manager.getNextFirmwareVersion(osuFirmware).chain((finalFirmware) =>\n manager\n .getMcuList()\n .map((mcus) => mcus.find((mcu) => mcu.name === firmwareVersion.mcu))\n .map(\n (mcu) =>\n mcu === undefined ||\n !finalFirmware.mcuVersions.includes(mcu.id),\n )\n .map((mcuUpdateRequired) => ({\n osuFirmware,\n finalFirmware,\n mcuUpdateRequired,\n })),\n ),\n );\n const availableUpdate: FirmwareUpdate | undefined = maybeUpdate.caseOf({\n Right: (data) => data,\n Left: (_error) => undefined,\n });\n const firmwareUpdateContext = {\n currentFirmware,\n availableUpdate,\n };\n\n // Get custom image metadata\n let customImage: CustomImage = {};\n const imageSize = await this.api.sendCommand(\n new GetBackgroundImageSizeCommand(),\n );\n if (isSuccessCommandResult(imageSize)) {\n customImage = { size: imageSize.data };\n }\n\n // Return firmware metadata\n return CommandResultFactory({\n data: {\n deviceVersion,\n firmware: currentFirmware,\n firmwareVersion,\n firmwareUpdateContext,\n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ACjB,CAAC,EACKC,EAAwB,CAC5B,gBAAAT,EACA,gBAAAC,CACF,EAGA,IAAIS,EAA2B,CAAC,EAChC,MAAMC,EAAY,MAAM,KAAK,IAAI,YAC/B,IAAIpB,CACN,EACA,OAAID,EAAuBqB,CAAS,IAClCD,EAAc,CAAE,KAAMC,EAAU,IAAK,GAIhCtB,EAAqB,CAC1B,KAAM,CACJ,cAAAU,EACA,SAAUC,EACV,gBAAAJ,EACA,sBAAAa,EACA,YAAAC,CACF,CACF,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["InvalidGetFirmwareMetadataResponseError", "CommandResultFactory", "isSuccessCommandResult", "GetBackgroundImageSizeCommand", "GetOsVersionCommand", "GetFirmwareMetadataTask", "api", "osVersion", "firmwareVersion", "manager", "result", "deviceVersion", "currentFirmware", "availableUpdate", "osuFirmware", "finalFirmware", "mcus", "mcu", "mcuUpdateRequired", "data", "_error", "firmwareUpdateContext", "customImage", "imageSize"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Observable as
|
|
1
|
+
import{Observable as S,ReplaySubject as m,share as d}from"rxjs";import{createActor as y}from"xstate";import{DeviceActionStatus as o}from"../../device-action/model/DeviceActionState";import{noopLoggerFactory as b}from"../../logger-publisher/utils/noopLoggerFactory";class f{input;inspect=!1;logger;loggerFactory;constructor(e){this.input=e.input,this.inspect=!!e.inspect,this.logger=e.logger,this.loggerFactory=e.loggerFactory}getLoggerFactory(e){return this.loggerFactory??e.loggerFactory??b}_execute(e){const t=this.makeStateMachine(e);return!this.logger&&t.id&&(this.logger=this.getLoggerFactory(e)(t.id)),this._subscribeToStateMachine(t)}_subscribeToStateMachine(e){const t=y(e,{input:this.input}),r=new m;let u=!1;const s=a=>{const{context:n,status:c,output:g,error:h}=a;if(this.logger&&!u&&(u=!0,this.logger.debug("[XStateDeviceAction] Input",{data:{input:n.input}})),this.logger&&c==="active"){const i=typeof a.value=="string"?a.value:JSON.stringify(a.value);this.logger.debug(`[XStateDeviceAction] State: ${i}`,{data:{internalState:n._internalState}})}switch(c){case"active":r.next({status:o.Pending,intermediateValue:n.intermediateValue});break;case"done":g.caseOf({Left:i=>{r.next({status:o.Error,error:i})},Right:i=>{r.next({status:o.Completed,output:i})}}),r.complete();break;case"error":r.error(h),r.complete();break;case"stopped":r.next({status:o.Stopped}),r.complete();break;default:this._exhaustiveMatchingGuard(c)}},l=new S(a=>{const n=r.subscribe(a);return()=>{p.unsubscribe(),n.unsubscribe(),t.stop()}}),p=t.subscribe(s);return t.start(),{observable:l.pipe(d()),cancel:()=>{t.stop(),p.unsubscribe(),s(t.getSnapshot())}}}_exhaustiveMatchingGuard(e){throw console.log("_exhaustiveMatchingGuard status",e),new Error(`Unhandled status: ${e}`)}}export{f as XStateDeviceAction};
|
|
2
2
|
//# sourceMappingURL=XStateDeviceAction.js.map
|