@ledgerhq/device-management-kit 0.0.0-develop-20260224001409 → 0.0.0-develop-20260228001144
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/lib/cjs/package.json +1 -1
- 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/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/types.js +1 -1
- package/lib/cjs/src/api/types.js.map +1 -1
- package/lib/esm/package.json +1 -1
- 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/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/types/src/api/device-action/__test-utils__/setupTestMachine.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 +7 -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/types.d.ts +1 -0
- package/lib/types/src/api/types.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -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: 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: 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,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E,QAAQ,eACvB,KAAOE,IAAW,CAChB,GAAGF,EAAE,QAAQ,eACb,MAAAE,CACF,EACF,CACF,CACJ,CAAC,CACH,EACA,QAAS,CACP,OAAQ,QACR,QAAS,sBACX,CACF,CACF,EACA,aAAc,CACZ,OAAQ,CACN,CACE,MAAO,WACP,OAAQ,OACV,EACA,CACE,OAAQ,SACV,CACF,CACF,EACA,QAAS,CACP,KAAM,OACR,EACA,MAAO,CACL,KAAM,OACR,CACF,EACA,OAASC,GAAS,CAChB,KAAM,CAAE,QAAAJ,CAAQ,EAAII,EACd,CAAE,MAAAD,EAAO,eAAAE,EAAgB,cAAAC,CAAc,EAAIN,EAAQ,eACzD,OAAIG,EACKrB,EAAKqB,CAAK,EAEZpB,EAAM,CACX,eAAgBsB,EAChB,cAAeC,CACjB,CAAC,CACH,CACF,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["Left", "Right", "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"],
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BC,EAAwB,KACjD,YAAa,KACb,SAAU,OACV,KAAMK,EAAmC,mBAC3C,EACA,OAAQN,EAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,GAAGS,EACH,SAAU,OACV,KAAMH,EAAmC,mBAC3C,EACA,OAAQN,EAAmB,OAC7B,EAEA,CACE,kBAAmB,CACjB,GAAGS,EACH,SAAU,OACV,KAAMH,EAAmC,mBAC3C,EACA,OAAQN,EAAmB,OAC7B,EACA,CACE,kBAAmB,CACjB,wBAAyBC,EAAwB,eACjD,YAAa,KACb,SAAU,OACV,KAAMK,EAAmC,mBAC3C,EACA,OAAQN,EAAmB,OAC7B,EAEA,CACE,MAAO,IAAIE,EAAe,gBAAgB,EAC1C,OAAQF,EAAmB,KAC7B,CACF,EAEAD,EAAuBc,EAAcC,EAAgBP,EAAS,CAC5D,OAAQI,EACR,QAASC,CACX,CAAC,CACH,CAAC,CAAC,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};\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,MAAMC,UAKHF,CAWR,CACA,iBACEG,EAYA,CAcA,KAAM,CAAE,YAAAC,CAAY,EAAI,KAAK,oBAAoBD,CAAW,EAE5D,OAAOR,EAAM,CACX,MAAO,CACL,MAAO,CAAC,EACR,QAAS,CAAC,EACV,OAAQ,CAAC,CACX,EACA,OAAQ,CACN,YAAaD,EAAYU,CAAW,EACpC,oBAAqB,IAAIL,EAAoB,CAC3C,MAAO,CACL,QAAS,KAAK,MAAM,OACtB,CACF,CAAC,EAAE,iBAAiBI,CAAW,CACjC,EACA,OAAQ,CACN,YAAa,IAAM,KAAK,MAAM,YAC9B,gBAAiB,CAAC,CAAE,QAAAE,CAAQ,IAAMA,EAAQ,eAAe,QAAU,IACrE,EACA,QAAS,CACP,qBAAsBZ,EAAO,CAC3B,eAAiBa,IAAO,CACtB,GAAGA,EAAE,QAAQ,eACb,MAAOA,EAAE,MAAM,KACjB,EACF,CAAC,CACH,CACF,CAAC,EAAE,cAAc,CAEf,GAAI,+BACJ,QAAS,eACT,QAAS,CAAC,CAAE,MAAAC,CAAM,KACT,CACL,MAAOA,EACP,kBAAmB,CACjB,wBAA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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,mDACxC,OAAS,kBAAAC,MAAsB,+BAC/B,OAAS,uBAAAC,MAA2B,gEACpC,OAAS,sBAAAC,MAA0B,kDAEnC,OAAS,8BAAAC,MAAkC,YAE3C,OAAS,gCAAAC,MAAoC,iCAC7C,OAIE,+BAAAC,MACK,sCAEP,GAAG,KACD,gEACA,MAAOC,IAME,CACL,GALA,MAAMA,EAEJ,EAIF,oBAAqB,GAAG,GAAG,KAAO,CAChC,iBAAkB,GAAG,GAAG,CAC1B,EAAE,CACJ,EAEJ,EAEA,MAAMC,EAAsBC,GAAoB,CAC7CP,EAA6B,mBAAmB,KAAO,CACtD,iBAAkB,GAAG,GAAG,EAAE,mBAAmB,IAC3CR,EAAc,CACZ,QAAS,UACT,OAAQ,CACN,QAAS,CACP,MAAOD,EAAO,CACZ,kBAAmB,CACjB,wBAAyBO,EAAwB,eACjD,KAAMG,EAAmB,iBAC3B,CACF,CAAC,EACD,MAAO,CACL,EAAG,MACL,CACF,EACA,KAAM,CACJ,KAAM,OACR,CACF,EACA,OAAQ,IAAOM,EAAQlB,EAAKkB,CAAK,EAAIjB,EAAM,MAAS,CACtD,CAA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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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupTestMachine.d.ts","sourceRoot":"","sources":["../../../../../../src/api/device-action/__test-utils__/setupTestMachine.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"setupTestMachine.d.ts","sourceRoot":"","sources":["../../../../../../src/api/device-action/__test-utils__/setupTestMachine.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,yBAAyB,EAE/B,MAAM,+CAA+C,CAAC;AAMvD,OAAO,EACL,KAAK,sCAAsC,EAC3C,KAAK,2BAA2B,EACjC,MAAM,iDAAiD,CAAC;AAKzD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2DAA2D,CAAC;AAE9F,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,KAAK,GAAG,GAAG,OAAO,OAAO,CAAC;AAE1B,eAAO,MAAM,iBAAiB,GAAI,MAAM,GAAG,EAAE,EAAE,eAAa,SA8B3D,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACrC,UAAU,yBAAyB,EACnC,eAAa,SA+Bd,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,QAAQ,2BAA2B,EACnC,mBAAmB,sCAAsC,EACzD,eAAa,SA4Bd,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,QAAO,OAAe,SA6BtD,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,QAAO,OAAe,SA8B5D,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,UAAS,aAAa,CACpB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GAAG,QAAQ,CAM7D,SAkCF,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACrC,UAAS,KAAK,CAAC;IAAE,aAAa,EAAE,YAAY,EAAE,CAAA;CAAE,GAAG,QAAQ,CAAM,SAkClE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CallTaskInAppDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kDAAkD,CAAC;AAI3F,OAAO,EACL,KAAK,wBAAwB,EAC7B,kBAAkB,EACnB,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,EACrC,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,
|
|
1
|
+
{"version":3,"file":"CallTaskInAppDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceAction.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kDAAkD,CAAC;AAI3F,OAAO,EACL,KAAK,wBAAwB,EAC7B,kBAAkB,EACnB,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,EACrC,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAE3B,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,yBAAyB,CACpC,YAAY,EACZ,cAAc,EACd,eAAe,SAAS,uBAAuB,CAC/C,SAAQ,kBAAkB,CAC1B,qBAAqB,CAAC,YAAY,CAAC,EACnC,oBAAoB,CAAC,YAAY,EAAE,cAAc,EAAE,eAAe,CAAC,EACnE,oBAAoB,CAAC,cAAc,CAAC,EACpC,gCAAgC,CAAC,eAAe,CAAC,EACjD,4BAA4B,CAAC,YAAY,EAAE,cAAc,CAAC,CAC3D;IACC,gBAAgB,CACd,WAAW,EAAE,WAAW,GACvB,wBAAwB,CACzB,qBAAqB,CAAC,YAAY,CAAC,EACnC,oBAAoB,CAAC,YAAY,EAAE,cAAc,EAAE,eAAe,CAAC,EACnE,oBAAoB,CAAC,cAAc,CAAC,EACpC,gCAAgC,CAAC,eAAe,CAAC,EACjD,4BAA4B,CAAC,YAAY,EAAE,cAAc,CAAC,CAC3D;IA2KD,mBAAmB,CAAC,WAAW,EAAE,WAAW;sBAE1B;YACZ,KAAK,EAAE,CACL,WAAW,EAAE,WAAW,KACrB,OAAO,CAAC,aAAa,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;SAC3D,KAAG,OAAO,CAAC,aAAa,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;;CAI7D"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { type CommandErrorResult, type CommandResult } from "../../../command/model/CommandResult";
|
|
2
2
|
import { type InternalApi } from "../../../device-action/DeviceAction";
|
|
3
|
+
import { type UserInteractionRequired } from "../../../device-action/model/UserInteractionRequired";
|
|
3
4
|
import { type OpenAppDAError, type OpenAppDAIntermediateValue } from "../../../device-action/os/OpenAppDeviceAction/types";
|
|
5
|
+
export declare const callTaskInAppDAStateStep: Readonly<{
|
|
6
|
+
readonly OPEN_APP: "os.callTaskInApp.steps.openApp";
|
|
7
|
+
readonly CALL_TASK: "os.callTaskInApp.steps.callTask";
|
|
8
|
+
}>;
|
|
9
|
+
export type CallTaskInAppDAStateStep = (typeof callTaskInAppDAStateStep)[keyof typeof callTaskInAppDAStateStep];
|
|
4
10
|
export type CallTaskInAppDAOutput<TaskResponse> = TaskResponse;
|
|
5
11
|
export type CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction> = {
|
|
6
12
|
readonly task: (internalApi: InternalApi) => Promise<CommandResult<TaskResponse, TaskErrorCodes>>;
|
|
@@ -9,8 +15,10 @@ export type CallTaskInAppDAInput<TaskResponse, TaskErrorCodes, UserInteraction>
|
|
|
9
15
|
readonly requiredUserInteraction: UserInteraction;
|
|
10
16
|
};
|
|
11
17
|
export type CallTaskInAppDAError<TaskErrorCodes = void> = OpenAppDAError | CommandErrorResult<TaskErrorCodes>["error"];
|
|
18
|
+
export type CallTaskInAppDARequiredInteraction = UserInteractionRequired.None;
|
|
12
19
|
export type CallTaskInAppDAIntermediateValue<UserInteraction> = {
|
|
13
|
-
readonly requiredUserInteraction: UserInteraction;
|
|
20
|
+
readonly requiredUserInteraction: UserInteraction | CallTaskInAppDARequiredInteraction;
|
|
21
|
+
readonly step: CallTaskInAppDAStateStep;
|
|
14
22
|
} | OpenAppDAIntermediateValue;
|
|
15
23
|
export type CallTaskInAppDAInternalState<TaskResponse, TaskErrorCodes> = {
|
|
16
24
|
readonly taskResponse: TaskResponse | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CallTaskInAppDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,0BAA0B,EAChC,MAAM,iDAAiD,CAAC;AAEzD,MAAM,MAAM,qBAAqB,CAAC,YAAY,IAAI,YAAY,CAAC;AAE/D,MAAM,MAAM,oBAAoB,CAC9B,YAAY,EACZ,cAAc,EACd,eAAe,IACb;IACF,QAAQ,CAAC,IAAI,EAAE,CACb,WAAW,EAAE,WAAW,KACrB,OAAO,CAAC,aAAa,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;IAC1D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,uBAAuB,EAAE,eAAe,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,cAAc,GAAG,IAAI,IAClD,cAAc,GACd,kBAAkB,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC;AAEhD,MAAM,MAAM,gCAAgC,CAAC,eAAe,IACxD;
|
|
1
|
+
{"version":3,"file":"CallTaskInAppDeviceActionTypes.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/device-action/os/CallTaskInAppDeviceAction/CallTaskInAppDeviceActionTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,kDAAkD,CAAC;AAChG,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,0BAA0B,EAChC,MAAM,iDAAiD,CAAC;AAEzD,eAAO,MAAM,wBAAwB;;;EAG1B,CAAC;AAEZ,MAAM,MAAM,wBAAwB,GAClC,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAC;AAE3E,MAAM,MAAM,qBAAqB,CAAC,YAAY,IAAI,YAAY,CAAC;AAE/D,MAAM,MAAM,oBAAoB,CAC9B,YAAY,EACZ,cAAc,EACd,eAAe,IACb;IACF,QAAQ,CAAC,IAAI,EAAE,CACb,WAAW,EAAE,WAAW,KACrB,OAAO,CAAC,aAAa,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;IAC1D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,uBAAuB,EAAE,eAAe,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,cAAc,GAAG,IAAI,IAClD,cAAc,GACd,kBAAkB,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC;AAEhD,MAAM,MAAM,kCAAkC,GAAG,uBAAuB,CAAC,IAAI,CAAC;AAE9E,MAAM,MAAM,gCAAgC,CAAC,eAAe,IACxD;IACE,QAAQ,CAAC,uBAAuB,EAC5B,eAAe,GACf,kCAAkC,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;CACzC,GACD,0BAA0B,CAAC;AAE/B,MAAM,MAAM,4BAA4B,CAAC,YAAY,EAAE,cAAc,IAAI;IACvE,QAAQ,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;CAC7D,CAAC"}
|
package/lib/types/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GetDeviceMetadataDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAIvC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAKnE,OAAO,EAEL,KAAK,iCAAiC,EACtC,KAAK,YAAY,EAClB,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EACL,KAAK,wBAAwB,EAC7B,kBAAkB,EACnB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,WAAW,EAEhB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC9B,MAAM,wCAAwC,CAAC;AAIhD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,oCAAoC,EACzC,KAAK,yBAAyB,
|
|
1
|
+
{"version":3,"file":"GetDeviceMetadataDeviceAction.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAIvC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAKnE,OAAO,EAEL,KAAK,iCAAiC,EACtC,KAAK,YAAY,EAClB,MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EACL,KAAK,wBAAwB,EAC7B,kBAAkB,EACnB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,WAAW,EAEhB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC9B,MAAM,wCAAwC,CAAC;AAIhD,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,oCAAoC,EACzC,KAAK,yBAAyB,EAE/B,MAAM,SAAS,CAAC;AAEjB,KAAK,qCAAqC,GAAG;IAC3C,QAAQ,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAChD,QAAQ,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,QA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