@ledgerhq/device-management-kit 0.11.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/lib/cjs/package.json +45 -41
  2. package/lib/cjs/src/api/device-action/os/Errors.js +1 -1
  3. package/lib/cjs/src/api/device-action/os/Errors.js.map +3 -3
  4. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  5. package/lib/cjs/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  6. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  7. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  8. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js +1 -1
  9. package/lib/cjs/src/api/device-action/os/InstallOrUpdateApps/types.js.map +1 -1
  10. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
  11. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +2 -2
  12. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
  13. package/lib/cjs/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +2 -2
  14. package/lib/cjs/src/internal/manager-api/data/ManagerApiDataSource.js.map +1 -1
  15. package/lib/esm/package.json +45 -41
  16. package/lib/esm/src/api/device-action/os/Errors.js +1 -1
  17. package/lib/esm/src/api/device-action/os/Errors.js.map +3 -3
  18. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js +1 -1
  19. package/lib/esm/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.js.map +2 -2
  20. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js +1 -1
  21. package/lib/esm/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.js.map +2 -2
  22. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js +1 -1
  23. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.js.map +3 -3
  24. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js +1 -1
  25. package/lib/esm/src/api/device-action/task/BuildAppsInstallPlanTask.test.js.map +3 -3
  26. package/lib/types/src/api/device-action/os/Errors.d.ts +5 -0
  27. package/lib/types/src/api/device-action/os/Errors.d.ts.map +1 -1
  28. package/lib/types/src/api/device-action/os/GetDeviceMetadata/GetDeviceMetadataDeviceAction.d.ts.map +1 -1
  29. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/InstallOrUpdateAppsDeviceAction.d.ts.map +1 -1
  30. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts +2 -2
  31. package/lib/types/src/api/device-action/os/InstallOrUpdateApps/types.d.ts.map +1 -1
  32. package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts +2 -2
  33. package/lib/types/src/api/device-action/task/BuildAppsInstallPlanTask.d.ts.map +1 -1
  34. package/lib/types/src/internal/manager-api/data/ManagerApiDataSource.d.ts +1 -1
  35. package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
  36. package/package.json +33 -29
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var I=(r,e)=>{for(var n in e)c(r,n,{get:e[n],enumerable:!0})},y=(r,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of v(e))!g.call(r,i)&&i!==n&&c(r,i,{get:()=>e[i],enumerable:!(a=A(e,i))||a.enumerable});return r};var M=r=>y(c({},"__esModule",{value:!0}),r);var h={};I(h,{BuildAppsInstallPlanTask:()=>D});module.exports=M(h);var f=require("semver"),p=require("../../device-action/os/Errors"),u=require("../../device-session/DeviceSessionState");class D{constructor(e,n){this.api=e;this.args=n;const a=e.getDeviceModel();this.deviceModelId=a.id}deviceModelId;run(){const e=this.api.getDeviceSessionState();if(e.sessionStateType===u.DeviceSessionStateType.Connected)return{error:new p.UnknownDAError("Invalid device state")};if(e.catalog===void 0)return{error:new p.UnknownDAError("Device apps metadata not fetched")};let n=[],a=[],i=[];for(const t of this.args.applications){const o=e.catalog.applications.find(s=>s.versionName===t.name),l=e.installedApps.find(s=>s.versionName===t.name);if(l!==void 0&&this.validateConstraint(l,o,t.constraints)){a=[...a,t.name];continue}if(o!==void 0&&this.validateConstraint(o,void 0,t.constraints))n=[...n,o];else if(this.args.allowMissingApplication)i=[...i,t.name];else return o!==void 0?{error:new p.UnsupportedFirmwareDAError(`Application ${t.name} not found in the catalog`)}:{error:new p.UnknownDAError(`Application ${t.name} not found in the catalog`)}}return n=[...n.reduce((t,o)=>{const l=o.parentName;if(l){const s=e.catalog.applications.find(d=>d.versionName===l),m=e.installedApps.find(d=>d.versionName===l);if(s&&!m)return[...t,s]}return t},[]),...n],{installPlan:n.filter((t,o)=>n.findIndex(l=>l.versionName===t.versionName)===o),missingApplications:i,alreadyInstalled:a}}validateConstraint(e,n,a){if(a===void 0)return!0;for(const i of a)if(!(i.exemptModels!==void 0&&i.exemptModels.includes(this.deviceModelId))&&!(i.applicableModels!==void 0&&!i.applicableModels.includes(this.deviceModelId)))return i.minVersion==="latest"?!n||(0,f.gte)(e.version,n.version):(0,f.gte)(e.version,i.minVersion);return!0}}0&&(module.exports={BuildAppsInstallPlanTask});
1
+ "use strict";var c=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var I=(o,e)=>{for(var n in e)c(o,n,{get:e[n],enumerable:!0})},y=(o,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of v(e))!g.call(o,i)&&i!==n&&c(o,i,{get:()=>e[i],enumerable:!(a=A(e,i))||a.enumerable});return o};var D=o=>y(c({},"__esModule",{value:!0}),o);var M={};I(M,{BuildAppsInstallPlanTask:()=>w});module.exports=D(M);var f=require("semver"),s=require("../../device-action/os/Errors"),u=require("../../device-session/DeviceSessionState");class w{constructor(e,n){this.api=e;this.args=n;const a=e.getDeviceModel();this.deviceModelId=a.id}deviceModelId;run(){const e=this.api.getDeviceSessionState();if(e.sessionStateType===u.DeviceSessionStateType.Connected)return{error:new s.UnknownDAError("Invalid device state")};if(e.catalog===void 0)return{error:new s.UnknownDAError("Device apps metadata not fetched")};let n=[],a=[],i=[];for(const t of this.args.applications){const r=e.catalog.applications.find(p=>p.versionName===t.name),l=e.installedApps.find(p=>p.versionName===t.name);if(l!==void 0&&this.validateConstraint(l,r,t.constraints)){a=[...a,t.name];continue}if(r!==void 0&&this.validateConstraint(r,void 0,t.constraints))n=[...n,r];else if(this.args.allowMissingApplication)i=[...i,t.name];else return e.firmwareUpdateContext?.availableUpdate!==void 0&&r!==void 0?{error:new s.UnsupportedFirmwareDAError(`Application ${t.name} needs latest firmware`)}:e.firmwareUpdateContext?.availableUpdate!==void 0?{error:new s.UnsupportedFirmwareDAError(`Application ${t.name} needs latest firmware`)}:{error:new s.UnsupportedApplicationDAError(`Application ${t.name} not supported for this device`)}}return n=[...n.reduce((t,r)=>{const l=r.parentName;if(l){const p=e.catalog.applications.find(d=>d.versionName===l),m=e.installedApps.find(d=>d.versionName===l);if(p&&!m)return[...t,p]}return t},[]),...n],{installPlan:n.filter((t,r)=>n.findIndex(l=>l.versionName===t.versionName)===r),missingApplications:i,alreadyInstalled:a}}validateConstraint(e,n,a){if(a===void 0)return!0;for(const i of a)if(!(i.exemptModels!==void 0&&i.exemptModels.includes(this.deviceModelId))&&!(i.applicableModels!==void 0&&!i.applicableModels.includes(this.deviceModelId)))return i.minVersion==="latest"?!n||(0,f.gte)(e.version,n.version):(0,f.gte)(e.version,i.minVersion);return!0}}0&&(module.exports={BuildAppsInstallPlanTask});
2
2
  //# sourceMappingURL=BuildAppsInstallPlanTask.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/task/BuildAppsInstallPlanTask.ts"],
4
- "sourcesContent": ["import { gte } from \"semver\";\n\nimport type { DeviceModelId } from \"@api/device/DeviceModel\";\nimport type { InternalApi } from \"@api/device-action/DeviceAction\";\nimport {\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nimport type {\n ApplicationConstraint,\n ApplicationDependency,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\n\nexport type BuildAppsInstallPlanTaskArgs = {\n /**\n * List of applications to install or update\n */\n readonly applications: ApplicationDependency[];\n\n /**\n * Indicates if the device action should fail if an application is missing from the app store.\n */\n readonly allowMissingApplication: boolean;\n};\n\nexport type BuildAppsInstallPlanTaskResult =\n | {\n installPlan: Application[];\n alreadyInstalled: string[];\n missingApplications: string[];\n }\n | {\n error: UnknownDAError | UnsupportedFirmwareDAError;\n };\n\nexport class BuildAppsInstallPlanTask {\n private readonly deviceModelId: DeviceModelId;\n\n constructor(\n private readonly api: InternalApi,\n private readonly args: BuildAppsInstallPlanTaskArgs,\n ) {\n const deviceModel = api.getDeviceModel();\n this.deviceModelId = deviceModel.id;\n }\n\n run(): BuildAppsInstallPlanTaskResult {\n // Get device session state.\n const deviceState = this.api.getDeviceSessionState();\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n return { error: new UnknownDAError(\"Invalid device state\") };\n }\n\n // Ensure the device metadata were correctly fetched.\n if (deviceState.catalog === undefined) {\n return { error: new UnknownDAError(\"Device apps metadata not fetched\") };\n }\n\n // Build the install plan\n let installPlan: Application[] = [];\n let alreadyInstalled: string[] = [];\n let missingApplications: string[] = [];\n for (const app of this.args.applications) {\n // Get app entry from catalog and from installed apps\n const catalogApp = deviceState.catalog.applications.find(\n (a) => a.versionName === app.name,\n );\n const installedApp = deviceState.installedApps.find(\n (a) => a.versionName === app.name,\n );\n\n // If app is already installed, with validated constraints, continue the iteration\n if (\n installedApp !== undefined &&\n this.validateConstraint(installedApp, catalogApp, app.constraints)\n ) {\n alreadyInstalled = [...alreadyInstalled, app.name];\n continue;\n }\n\n // Handle the catalog application\n if (\n catalogApp !== undefined &&\n this.validateConstraint(catalogApp, undefined, app.constraints)\n ) {\n // Add the catalog application to the install plan\n installPlan = [...installPlan, catalogApp];\n } else if (this.args.allowMissingApplication) {\n missingApplications = [...missingApplications, app.name];\n } else {\n // Fail immediately if missing application is not allowed\n if (catalogApp !== undefined) {\n // Is application is found in the catalog in an old version,\n // it usually means the firmware is also outdated.\n return {\n error: new UnsupportedFirmwareDAError(\n `Application ${app.name} not found in the catalog`,\n ),\n };\n } else {\n return {\n error: new UnknownDAError(\n `Application ${app.name} not found in the catalog`,\n ),\n };\n }\n }\n }\n\n // Find installPlan dependencies\n const dependencies = installPlan.reduce((apps, app) => {\n const dependency = app.parentName;\n if (dependency) {\n const catalogApp = deviceState.catalog!.applications.find(\n (a) => a.versionName === dependency,\n );\n const installedApp = deviceState.installedApps.find(\n (a) => a.versionName === dependency,\n );\n if (catalogApp && !installedApp) {\n return [...apps, catalogApp];\n }\n }\n return apps;\n }, [] as Application[]);\n\n // Reorder and deduplicate the install plan with its dependencies first\n installPlan = [...dependencies, ...installPlan];\n const reorderedInstallPlan = installPlan.filter(\n (app, index) =>\n installPlan.findIndex((a) => a.versionName === app.versionName) ===\n index,\n );\n\n return {\n installPlan: reorderedInstallPlan,\n missingApplications,\n alreadyInstalled,\n };\n }\n\n private validateConstraint(\n app: Application,\n catalogApp?: Application,\n constraints?: ApplicationConstraint[],\n ): boolean {\n if (constraints === undefined) {\n // No constraint\n return true;\n }\n\n // Validate the constraint\n for (const constraint of constraints) {\n // Is current device exempt from the constraint?\n if (\n constraint.exemptModels !== undefined &&\n constraint.exemptModels.includes(this.deviceModelId)\n ) {\n continue;\n }\n\n // Is current device not applicable for the constraint?\n if (\n constraint.applicableModels !== undefined &&\n !constraint.applicableModels.includes(this.deviceModelId)\n ) {\n continue;\n }\n\n // Validate the min version\n if (constraint.minVersion === \"latest\") {\n return !catalogApp || gte(app.version, catalogApp.version);\n } else {\n return gte(app.version, constraint.minVersion);\n }\n }\n\n // No constraint for the device\n return true;\n }\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoB,kBAIpBC,EAGO,wCAKPC,EAAuC,kDAyBhC,MAAMJ,CAAyB,CAGpC,YACmBK,EACAC,EACjB,CAFiB,SAAAD,EACA,UAAAC,EAEjB,MAAMC,EAAcF,EAAI,eAAe,EACvC,KAAK,cAAgBE,EAAY,EACnC,CARiB,cAUjB,KAAsC,CAEpC,MAAMC,EAAc,KAAK,IAAI,sBAAsB,EACnD,GAAIA,EAAY,mBAAqB,yBAAuB,UAC1D,MAAO,CAAE,MAAO,IAAI,iBAAe,sBAAsB,CAAE,EAI7D,GAAIA,EAAY,UAAY,OAC1B,MAAO,CAAE,MAAO,IAAI,iBAAe,kCAAkC,CAAE,EAIzE,IAAIC,EAA6B,CAAC,EAC9BC,EAA6B,CAAC,EAC9BC,EAAgC,CAAC,EACrC,UAAWC,KAAO,KAAK,KAAK,aAAc,CAExC,MAAMC,EAAaL,EAAY,QAAQ,aAAa,KACjDM,GAAMA,EAAE,cAAgBF,EAAI,IAC/B,EACMG,EAAeP,EAAY,cAAc,KAC5CM,GAAMA,EAAE,cAAgBF,EAAI,IAC/B,EAGA,GACEG,IAAiB,QACjB,KAAK,mBAAmBA,EAAcF,EAAYD,EAAI,WAAW,EACjE,CACAF,EAAmB,CAAC,GAAGA,EAAkBE,EAAI,IAAI,EACjD,QACF,CAGA,GACEC,IAAe,QACf,KAAK,mBAAmBA,EAAY,OAAWD,EAAI,WAAW,EAG9DH,EAAc,CAAC,GAAGA,EAAaI,CAAU,UAChC,KAAK,KAAK,wBACnBF,EAAsB,CAAC,GAAGA,EAAqBC,EAAI,IAAI,MAGvD,QAAIC,IAAe,OAGV,CACL,MAAO,IAAI,6BACT,eAAeD,EAAI,IAAI,2BACzB,CACF,EAEO,CACL,MAAO,IAAI,iBACT,eAAeA,EAAI,IAAI,2BACzB,CACF,CAGN,CAoBA,OAAAH,EAAc,CAAC,GAjBMA,EAAY,OAAO,CAACO,EAAMJ,IAAQ,CACrD,MAAMK,EAAaL,EAAI,WACvB,GAAIK,EAAY,CACd,MAAMJ,EAAaL,EAAY,QAAS,aAAa,KAClDM,GAAMA,EAAE,cAAgBG,CAC3B,EACMF,EAAeP,EAAY,cAAc,KAC5CM,GAAMA,EAAE,cAAgBG,CAC3B,EACA,GAAIJ,GAAc,CAACE,EACjB,MAAO,CAAC,GAAGC,EAAMH,CAAU,CAE/B,CACA,OAAOG,CACT,EAAG,CAAC,CAAkB,EAGU,GAAGP,CAAW,EAOvC,CACL,YAP2BA,EAAY,OACvC,CAACG,EAAKM,IACJT,EAAY,UAAWK,GAAMA,EAAE,cAAgBF,EAAI,WAAW,IAC9DM,CACJ,EAIE,oBAAAP,EACA,iBAAAD,CACF,CACF,CAEQ,mBACNE,EACAC,EACAM,EACS,CACT,GAAIA,IAAgB,OAElB,MAAO,GAIT,UAAWC,KAAcD,EAEvB,GACE,EAAAC,EAAW,eAAiB,QAC5BA,EAAW,aAAa,SAAS,KAAK,aAAa,IAOnD,EAAAA,EAAW,mBAAqB,QAChC,CAACA,EAAW,iBAAiB,SAAS,KAAK,aAAa,GAM1D,OAAIA,EAAW,aAAe,SACrB,CAACP,MAAc,OAAID,EAAI,QAASC,EAAW,OAAO,KAElD,OAAID,EAAI,QAASQ,EAAW,UAAU,EAKjD,MAAO,EACT,CACF",
4
+ "sourcesContent": ["import { gte } from \"semver\";\n\nimport type { DeviceModelId } from \"@api/device/DeviceModel\";\nimport type { InternalApi } from \"@api/device-action/DeviceAction\";\nimport {\n UnknownDAError,\n UnsupportedApplicationDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nimport type {\n ApplicationConstraint,\n ApplicationDependency,\n} from \"@api/device-action/os/InstallOrUpdateApps/types\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\n\nexport type BuildAppsInstallPlanTaskArgs = {\n /**\n * List of applications to install or update\n */\n readonly applications: ApplicationDependency[];\n\n /**\n * Indicates if the device action should fail if an application is missing from the app store.\n */\n readonly allowMissingApplication: boolean;\n};\n\nexport type BuildAppsInstallPlanTaskResult =\n | {\n installPlan: Application[];\n alreadyInstalled: string[];\n missingApplications: string[];\n }\n | {\n error:\n | UnknownDAError\n | UnsupportedApplicationDAError\n | UnsupportedFirmwareDAError;\n };\n\nexport class BuildAppsInstallPlanTask {\n private readonly deviceModelId: DeviceModelId;\n\n constructor(\n private readonly api: InternalApi,\n private readonly args: BuildAppsInstallPlanTaskArgs,\n ) {\n const deviceModel = api.getDeviceModel();\n this.deviceModelId = deviceModel.id;\n }\n\n run(): BuildAppsInstallPlanTaskResult {\n // Get device session state.\n const deviceState = this.api.getDeviceSessionState();\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n return { error: new UnknownDAError(\"Invalid device state\") };\n }\n\n // Ensure the device metadata were correctly fetched.\n if (deviceState.catalog === undefined) {\n return { error: new UnknownDAError(\"Device apps metadata not fetched\") };\n }\n\n // Build the install plan\n let installPlan: Application[] = [];\n let alreadyInstalled: string[] = [];\n let missingApplications: string[] = [];\n for (const app of this.args.applications) {\n // Get app entry from catalog and from installed apps\n const catalogApp = deviceState.catalog.applications.find(\n (a) => a.versionName === app.name,\n );\n const installedApp = deviceState.installedApps.find(\n (a) => a.versionName === app.name,\n );\n\n // If app is already installed, with validated constraints, continue the iteration\n if (\n installedApp !== undefined &&\n this.validateConstraint(installedApp, catalogApp, app.constraints)\n ) {\n alreadyInstalled = [...alreadyInstalled, app.name];\n continue;\n }\n\n // Handle the catalog application\n if (\n catalogApp !== undefined &&\n this.validateConstraint(catalogApp, undefined, app.constraints)\n ) {\n // Add the catalog application to the install plan\n installPlan = [...installPlan, catalogApp];\n } else if (this.args.allowMissingApplication) {\n missingApplications = [...missingApplications, app.name];\n } else {\n /**\n * Fail immediately if missing application is not allowed.\n *\n * TODO: If the application is not in catalog, we should also check if the application will be available in the\n * latest firmware catalog before throwing `UnsupportedApplicationDAError`. The actual implementation will always\n * throw `UnsupportedFirmwareDAError` to force the user to update firmware first, even though the application may\n * be still not available after the firmware update. For now, we keep `catalogApp !== undefined` check to prevent\n * from forgetting this case.\n *\n * Decision matrix for application availability according to OS and catalog:\n *\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 Not valid constraint \u2502 Found in catalog \u2502 Not found in catalog \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n * \u2502 OS up-to-date \u2502 UnsupportedApplicationDAError \u2502 UnsupportedApplicationDAError \u2502\n * \u2502 OS out-of-date \u2502 UnsupportedFirmwareDAError \u2502 UnsupportedFirmwareDAError => TODO \u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n */\n if (\n deviceState.firmwareUpdateContext?.availableUpdate !== undefined &&\n catalogApp !== undefined\n ) {\n return {\n error: new UnsupportedFirmwareDAError(\n `Application ${app.name} needs latest firmware`,\n ),\n };\n } else if (\n deviceState.firmwareUpdateContext?.availableUpdate !== undefined\n ) {\n // TODO: Application not found in out-of-date firmware catalog, needs to check if the application will be available\n // after firmware update\n return {\n error: new UnsupportedFirmwareDAError(\n `Application ${app.name} needs latest firmware`,\n ),\n };\n } else {\n return {\n error: new UnsupportedApplicationDAError(\n `Application ${app.name} not supported for this device`,\n ),\n };\n }\n }\n }\n\n // Find installPlan dependencies\n const dependencies = installPlan.reduce((apps, app) => {\n const dependency = app.parentName;\n if (dependency) {\n const catalogApp = deviceState.catalog!.applications.find(\n (a) => a.versionName === dependency,\n );\n const installedApp = deviceState.installedApps.find(\n (a) => a.versionName === dependency,\n );\n if (catalogApp && !installedApp) {\n return [...apps, catalogApp];\n }\n }\n return apps;\n }, [] as Application[]);\n\n // Reorder and deduplicate the install plan with its dependencies first\n installPlan = [...dependencies, ...installPlan];\n const reorderedInstallPlan = installPlan.filter(\n (app, index) =>\n installPlan.findIndex((a) => a.versionName === app.versionName) ===\n index,\n );\n\n return {\n installPlan: reorderedInstallPlan,\n missingApplications,\n alreadyInstalled,\n };\n }\n\n private validateConstraint(\n app: Application,\n catalogApp?: Application,\n constraints?: ApplicationConstraint[],\n ): boolean {\n if (constraints === undefined) {\n // No constraint\n return true;\n }\n\n // Validate the constraint\n for (const constraint of constraints) {\n // Is current device exempt from the constraint?\n if (\n constraint.exemptModels !== undefined &&\n constraint.exemptModels.includes(this.deviceModelId)\n ) {\n continue;\n }\n\n // Is current device not applicable for the constraint?\n if (\n constraint.applicableModels !== undefined &&\n !constraint.applicableModels.includes(this.deviceModelId)\n ) {\n continue;\n }\n\n // Validate the min version\n if (constraint.minVersion === \"latest\") {\n return !catalogApp || gte(app.version, catalogApp.version);\n } else {\n return gte(app.version, constraint.minVersion);\n }\n }\n\n // No constraint for the device\n return true;\n }\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoB,kBAIpBC,EAIO,wCAKPC,EAAuC,kDA4BhC,MAAMJ,CAAyB,CAGpC,YACmBK,EACAC,EACjB,CAFiB,SAAAD,EACA,UAAAC,EAEjB,MAAMC,EAAcF,EAAI,eAAe,EACvC,KAAK,cAAgBE,EAAY,EACnC,CARiB,cAUjB,KAAsC,CAEpC,MAAMC,EAAc,KAAK,IAAI,sBAAsB,EACnD,GAAIA,EAAY,mBAAqB,yBAAuB,UAC1D,MAAO,CAAE,MAAO,IAAI,iBAAe,sBAAsB,CAAE,EAI7D,GAAIA,EAAY,UAAY,OAC1B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AkB,EAGU,GAAGP,CAAW,EAOvC,CACL,YAP2BA,EAAY,OACvC,CAACG,EAAKM,IACJT,EAAY,UAAWK,GAAMA,EAAE,cAAgBF,EAAI,WAAW,IAC9DM,CACJ,EAIE,oBAAAP,EACA,iBAAAD,CACF,CACF,CAEQ,mBACNE,EACAC,EACAM,EACS,CACT,GAAIA,IAAgB,OAElB,MAAO,GAIT,UAAWC,KAAcD,EAEvB,GACE,EAAAC,EAAW,eAAiB,QAC5BA,EAAW,aAAa,SAAS,KAAK,aAAa,IAOnD,EAAAA,EAAW,mBAAqB,QAChC,CAACA,EAAW,iBAAiB,SAAS,KAAK,aAAa,GAM1D,OAAIA,EAAW,aAAe,SACrB,CAACP,MAAc,OAAID,EAAI,QAASC,EAAW,OAAO,KAElD,OAAID,EAAI,QAASQ,EAAW,UAAU,EAKjD,MAAO,EACT,CACF",
6
6
  "names": ["BuildAppsInstallPlanTask_exports", "__export", "BuildAppsInstallPlanTask", "__toCommonJS", "import_semver", "import_Errors", "import_DeviceSessionState", "api", "args", "deviceModel", "deviceState", "installPlan", "alreadyInstalled", "missingApplications", "app", "catalogApp", "a", "installedApp", "apps", "dependency", "index", "constraints", "constraint"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("../../device/DeviceModel"),a=require("../../device/DeviceStatus"),r=require("../../device-action/__test-utils__/makeInternalApi"),o=require("../../device-action/os/Errors"),i=require("../../device-session/DeviceSessionState"),s=require("./BuildAppsInstallPlanTask");describe("BuildAppsInstallPlanTask",()=>{const e=(0,r.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.clearAllMocks(),e.getDeviceModel.mockReturnValue({id:t.DeviceModelId.NANO_X})}),it("Success with no changes needed",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.3.0"}],catalog:{applications:[],languagePackages:[]}});const n=new s.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"},{name:"Bitcoin"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[],alreadyInstalled:["Ethereum","Bitcoin"],missingApplications:[]})}),it("Success with no constraints",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.3.0"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"},{versionName:"MyShitCoin",version:"0.0.1"},{versionName:"Cardano",version:"1.1.0"}],languagePackages:[]}});const n=new s.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"},{name:"Solana"},{name:"Cardano"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[{versionName:"Solana",version:"1.2.0"},{versionName:"Cardano",version:"1.1.0"}],alreadyInstalled:["Ethereum"],missingApplications:[]})}),it("Success with applicable constraints",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.2.0"},{versionName:"Solana",version:"1.1.0"},{versionName:"Cardano",version:"1.1.0"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"},{versionName:"MyShitCoin",version:"0.0.1"},{versionName:"Cardano",version:"1.2.0"}],languagePackages:[]}});const n=new s.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum",constraints:[{minVersion:"1.6.0",applicableModels:[t.DeviceModelId.NANO_X]}]},{name:"Bitcoin",constraints:[{minVersion:"1.2.1",exemptModels:[t.DeviceModelId.NANO_S]}]},{name:"Solana",constraints:[{minVersion:"1.2.0"}]}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"}],alreadyInstalled:[],missingApplications:[]})}),it("Success with non-applicable constraints",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.2.0"},{versionName:"Solana",version:"1.1.0"},{versionName:"Cardano",version:"1.1.0"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"},{versionName:"MyShitCoin",version:"0.0.1"},{versionName:"Cardano",version:"1.2.0"}],languagePackages:[]}});const n=new s.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum",constraints:[{minVersion:"1.6.0",exemptModels:[t.DeviceModelId.NANO_X]}]},{name:"Bitcoin",constraints:[{minVersion:"1.2.1",applicableModels:[t.DeviceModelId.NANO_S]}]},{name:"Cardano",constraints:[{minVersion:"1.1.0"}]}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[],alreadyInstalled:["Ethereum","Bitcoin","Cardano"],missingApplications:[]})}),it("Success with applicable constraints latest version",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.1.0"},{versionName:"MyShitCoin",version:"0.0.1"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"},{versionName:"Cardano",version:"1.2.0"}],languagePackages:[]}});const n=new s.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum",constraints:[{minVersion:"latest"}]},{name:"Bitcoin",constraints:[{minVersion:"latest"}]},{name:"MyShitCoin",constraints:[{minVersion:"latest"}]}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[{versionName:"Ethereum",version:"1.6.0"}],alreadyInstalled:["Bitcoin","MyShitCoin"],missingApplications:[]})}),it("Success with dependencies",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"AlreadyInstalledDep",version:"1.2.0"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0",parentName:void 0},{versionName:"Solana",version:"1.2.0",parentName:void 0},{versionName:"MyEthShitCoin",version:"0.0.1",parentName:"Ethereum"},{versionName:"MySolShitCoin",version:"0.0.1",parentName:"Solana"},{versionName:"MyPumpFunShitCoin",version:"0.0.1",parentName:"Solana"},{versionName:"Cardano",version:"1.2.0",parentName:void 0},{versionName:"AlreadyInstalledDep",version:"1.2.0",parentName:"Cardano"}],languagePackages:[]}});const n=new s.BuildAppsInstallPlanTask(e,{applications:[{name:"MyEthShitCoin"},{name:"MySolShitCoin"},{name:"Solana"},{name:"MyPumpFunShitCoin"},{name:"AlreadyInstalledDep"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[{versionName:"Ethereum",version:"1.6.0",parentName:void 0},{versionName:"Solana",version:"1.2.0",parentName:void 0},{versionName:"MyEthShitCoin",version:"0.0.1",parentName:"Ethereum"},{versionName:"MySolShitCoin",version:"0.0.1",parentName:"Solana"},{versionName:"MyPumpFunShitCoin",version:"0.0.1",parentName:"Solana"}],alreadyInstalled:["AlreadyInstalledDep"],missingApplications:[]})}),it("Success with allowed missing applications",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.3.0"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"}],languagePackages:[]}});const n=new s.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"},{name:"Solana"},{name:"Cardano"}],allowMissingApplication:!0}).run();expect(n).toStrictEqual({installPlan:[{versionName:"Solana",version:"1.2.0"}],alreadyInstalled:["Ethereum"],missingApplications:["Cardano"]})}),it("Error when device is in incorrect state",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.Connected,deviceStatus:a.DeviceStatus.CONNECTED});const n=new s.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({error:new o.UnknownDAError("Invalid device state")})}),it("Error when device session was not populated",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[]});const n=new s.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({error:new o.UnknownDAError("Device apps metadata not fetched")})}),it("Error when an app is not found in the catalog",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[],catalog:{applications:[],languagePackages:[]}});const n=new s.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"},{name:"Bitcoin"},{name:"Solana"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({error:new o.UnknownDAError("Application Ethereum not found in the catalog")})}),it("Error when an app version is not found in the catalog",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[],catalog:{applications:[{versionName:"Ethereum",version:"1.5.0"}],languagePackages:[]}});const n=new s.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum",constraints:[{minVersion:"1.6.0"}]}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({error:new o.UnsupportedFirmwareDAError("Application Ethereum not found in the catalog")})})});
1
+ "use strict";var o=require("../../device/DeviceModel"),a=require("../../device/DeviceStatus"),r=require("../../device-action/__test-utils__/makeInternalApi"),s=require("../../device-action/os/Errors"),i=require("../../device-session/DeviceSessionState"),t=require("./BuildAppsInstallPlanTask");describe("BuildAppsInstallPlanTask",()=>{const e=(0,r.makeDeviceActionInternalApiMock)();beforeEach(()=>{vi.clearAllMocks(),e.getDeviceModel.mockReturnValue({id:o.DeviceModelId.NANO_X})}),it("Success with no changes needed",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.3.0"}],catalog:{applications:[],languagePackages:[]}});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"},{name:"Bitcoin"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[],alreadyInstalled:["Ethereum","Bitcoin"],missingApplications:[]})}),it("Success with no constraints",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.3.0"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"},{versionName:"MyShitCoin",version:"0.0.1"},{versionName:"Cardano",version:"1.1.0"}],languagePackages:[]}});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"},{name:"Solana"},{name:"Cardano"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[{versionName:"Solana",version:"1.2.0"},{versionName:"Cardano",version:"1.1.0"}],alreadyInstalled:["Ethereum"],missingApplications:[]})}),it("Success with applicable constraints",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.2.0"},{versionName:"Solana",version:"1.1.0"},{versionName:"Cardano",version:"1.1.0"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"},{versionName:"MyShitCoin",version:"0.0.1"},{versionName:"Cardano",version:"1.2.0"}],languagePackages:[]}});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum",constraints:[{minVersion:"1.6.0",applicableModels:[o.DeviceModelId.NANO_X]}]},{name:"Bitcoin",constraints:[{minVersion:"1.2.1",exemptModels:[o.DeviceModelId.NANO_S]}]},{name:"Solana",constraints:[{minVersion:"1.2.0"}]}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"}],alreadyInstalled:[],missingApplications:[]})}),it("Success with non-applicable constraints",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.2.0"},{versionName:"Solana",version:"1.1.0"},{versionName:"Cardano",version:"1.1.0"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"},{versionName:"MyShitCoin",version:"0.0.1"},{versionName:"Cardano",version:"1.2.0"}],languagePackages:[]}});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum",constraints:[{minVersion:"1.6.0",exemptModels:[o.DeviceModelId.NANO_X]}]},{name:"Bitcoin",constraints:[{minVersion:"1.2.1",applicableModels:[o.DeviceModelId.NANO_S]}]},{name:"Cardano",constraints:[{minVersion:"1.1.0"}]}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[],alreadyInstalled:["Ethereum","Bitcoin","Cardano"],missingApplications:[]})}),it("Success with applicable constraints latest version",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.1.0"},{versionName:"MyShitCoin",version:"0.0.1"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"},{versionName:"Cardano",version:"1.2.0"}],languagePackages:[]}});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum",constraints:[{minVersion:"latest"}]},{name:"Bitcoin",constraints:[{minVersion:"latest"}]},{name:"MyShitCoin",constraints:[{minVersion:"latest"}]}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[{versionName:"Ethereum",version:"1.6.0"}],alreadyInstalled:["Bitcoin","MyShitCoin"],missingApplications:[]})}),it("Success with dependencies",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"AlreadyInstalledDep",version:"1.2.0"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0",parentName:void 0},{versionName:"Solana",version:"1.2.0",parentName:void 0},{versionName:"MyEthShitCoin",version:"0.0.1",parentName:"Ethereum"},{versionName:"MySolShitCoin",version:"0.0.1",parentName:"Solana"},{versionName:"MyPumpFunShitCoin",version:"0.0.1",parentName:"Solana"},{versionName:"Cardano",version:"1.2.0",parentName:void 0},{versionName:"AlreadyInstalledDep",version:"1.2.0",parentName:"Cardano"}],languagePackages:[]}});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"MyEthShitCoin"},{name:"MySolShitCoin"},{name:"Solana"},{name:"MyPumpFunShitCoin"},{name:"AlreadyInstalledDep"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({installPlan:[{versionName:"Ethereum",version:"1.6.0",parentName:void 0},{versionName:"Solana",version:"1.2.0",parentName:void 0},{versionName:"MyEthShitCoin",version:"0.0.1",parentName:"Ethereum"},{versionName:"MySolShitCoin",version:"0.0.1",parentName:"Solana"},{versionName:"MyPumpFunShitCoin",version:"0.0.1",parentName:"Solana"}],alreadyInstalled:["AlreadyInstalledDep"],missingApplications:[]})}),it("Success with allowed missing applications",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[{versionName:"Ethereum",version:"1.5.0"},{versionName:"Bitcoin",version:"1.3.0"}],catalog:{applications:[{versionName:"Ethereum",version:"1.6.0"},{versionName:"Bitcoin",version:"1.3.0"},{versionName:"Solana",version:"1.2.0"}],languagePackages:[]}});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"},{name:"Solana"},{name:"Cardano"}],allowMissingApplication:!0}).run();expect(n).toStrictEqual({installPlan:[{versionName:"Solana",version:"1.2.0"}],alreadyInstalled:["Ethereum"],missingApplications:["Cardano"]})}),it("Error when device is in incorrect state",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.Connected,deviceStatus:a.DeviceStatus.CONNECTED});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({error:new s.UnknownDAError("Invalid device state")})}),it("Error when device session was not populated",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[]});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({error:new s.UnknownDAError("Device apps metadata not fetched")})}),describe("Error cases for unsupported applications and firmwares",()=>{describe("when firmware is up to date",()=>{it("should throw `UnsupportedApplicationDAError` when application not found in catalog",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,firmwareUpdateContext:{currentFirmware:{}},installedApps:[],catalog:{applications:[],languagePackages:[]}});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({error:new s.UnsupportedApplicationDAError("Application Ethereum not supported for this device")})}),it("should throw `UnsupportedApplicationDAError` when application version is not supported",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,firmwareUpdateContext:{currentFirmware:{}},installedApps:[],catalog:{applications:[{versionName:"Ethereum",version:"1.5.0"}],languagePackages:[]}});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum",constraints:[{minVersion:"1.6.0"}]}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({error:new s.UnsupportedApplicationDAError("Application Ethereum not supported for this device")})})}),describe("when firmware is out of date",()=>{it("should throw `UnsupportedFirmwareDAError` when application not found in catalog",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,firmwareUpdateContext:{currentFirmware:{},availableUpdate:{}},installedApps:[],catalog:{applications:[],languagePackages:[]}});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum"}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({error:new s.UnsupportedFirmwareDAError("Application Ethereum needs latest firmware")})}),it("should throw `UnsupportedFirmwareDAError` when application version is not supported",()=>{e.getDeviceSessionState.mockReturnValueOnce({sessionStateType:i.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:a.DeviceStatus.CONNECTED,installedApps:[],firmwareUpdateContext:{currentFirmware:{},availableUpdate:{}},catalog:{applications:[{versionName:"Ethereum",version:"1.5.0"}],languagePackages:[]}});const n=new t.BuildAppsInstallPlanTask(e,{applications:[{name:"Ethereum",constraints:[{minVersion:"1.6.0"}]}],allowMissingApplication:!1}).run();expect(n).toStrictEqual({error:new s.UnsupportedFirmwareDAError("Application Ethereum needs latest firmware")})})})})});
2
2
  //# sourceMappingURL=BuildAppsInstallPlanTask.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/task/BuildAppsInstallPlanTask.test.ts"],
4
- "sourcesContent": ["import { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport {\n UnknownDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nimport type { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport type { DeviceSessionState } from \"@api/device-session/DeviceSessionState\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\n\nimport { BuildAppsInstallPlanTask } from \"./BuildAppsInstallPlanTask\";\n\ndescribe(\"BuildAppsInstallPlanTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n\n beforeEach(() => {\n vi.clearAllMocks();\n apiMock.getDeviceModel.mockReturnValue({\n id: DeviceModelId.NANO_X,\n } as unknown as TransportDeviceModel);\n });\n\n it(\"Success with no changes needed\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [{ name: \"Ethereum\" }, { name: \"Bitcoin\" }],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [],\n alreadyInstalled: [\"Ethereum\", \"Bitcoin\"],\n missingApplications: [],\n });\n });\n\n it(\"Success with no constraints\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n { versionName: \"MyShitCoin\", version: \"0.0.1\" },\n { versionName: \"Cardano\", version: \"1.1.0\" },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n { name: \"Ethereum\" },\n { name: \"Solana\" },\n { name: \"Cardano\" },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [\n { versionName: \"Solana\", version: \"1.2.0\" },\n { versionName: \"Cardano\", version: \"1.1.0\" },\n ],\n alreadyInstalled: [\"Ethereum\"],\n missingApplications: [],\n });\n });\n\n it(\"Success with applicable constraints\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.2.0\" },\n { versionName: \"Solana\", version: \"1.1.0\" },\n { versionName: \"Cardano\", version: \"1.1.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n { versionName: \"MyShitCoin\", version: \"0.0.1\" },\n { versionName: \"Cardano\", version: \"1.2.0\" },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n {\n name: \"Ethereum\",\n constraints: [\n { minVersion: \"1.6.0\", applicableModels: [DeviceModelId.NANO_X] },\n ],\n },\n {\n name: \"Bitcoin\",\n constraints: [\n { minVersion: \"1.2.1\", exemptModels: [DeviceModelId.NANO_S] },\n ],\n },\n { name: \"Solana\", constraints: [{ minVersion: \"1.2.0\" }] },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n ],\n alreadyInstalled: [],\n missingApplications: [],\n });\n });\n\n it(\"Success with non-applicable constraints\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.2.0\" },\n { versionName: \"Solana\", version: \"1.1.0\" },\n { versionName: \"Cardano\", version: \"1.1.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n { versionName: \"MyShitCoin\", version: \"0.0.1\" },\n { versionName: \"Cardano\", version: \"1.2.0\" },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n {\n name: \"Ethereum\",\n constraints: [\n { minVersion: \"1.6.0\", exemptModels: [DeviceModelId.NANO_X] },\n ],\n },\n {\n name: \"Bitcoin\",\n constraints: [\n { minVersion: \"1.2.1\", applicableModels: [DeviceModelId.NANO_S] },\n ],\n },\n { name: \"Cardano\", constraints: [{ minVersion: \"1.1.0\" }] },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [],\n alreadyInstalled: [\"Ethereum\", \"Bitcoin\", \"Cardano\"],\n missingApplications: [],\n });\n });\n\n it(\"Success with applicable constraints latest version\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.1.0\" },\n { versionName: \"MyShitCoin\", version: \"0.0.1\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n { versionName: \"Cardano\", version: \"1.2.0\" },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n { name: \"Ethereum\", constraints: [{ minVersion: \"latest\" }] },\n { name: \"Bitcoin\", constraints: [{ minVersion: \"latest\" }] },\n { name: \"MyShitCoin\", constraints: [{ minVersion: \"latest\" }] },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [{ versionName: \"Ethereum\", version: \"1.6.0\" }],\n alreadyInstalled: [\"Bitcoin\", \"MyShitCoin\"],\n missingApplications: [],\n });\n });\n\n it(\"Success with dependencies\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"AlreadyInstalledDep\", version: \"1.2.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\", parentName: undefined },\n { versionName: \"Solana\", version: \"1.2.0\", parentName: undefined },\n {\n versionName: \"MyEthShitCoin\",\n version: \"0.0.1\",\n parentName: \"Ethereum\",\n },\n {\n versionName: \"MySolShitCoin\",\n version: \"0.0.1\",\n parentName: \"Solana\",\n },\n {\n versionName: \"MyPumpFunShitCoin\",\n version: \"0.0.1\",\n parentName: \"Solana\",\n },\n { versionName: \"Cardano\", version: \"1.2.0\", parentName: undefined },\n {\n versionName: \"AlreadyInstalledDep\",\n version: \"1.2.0\",\n parentName: \"Cardano\",\n },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n { name: \"MyEthShitCoin\" },\n { name: \"MySolShitCoin\" },\n { name: \"Solana\" },\n { name: \"MyPumpFunShitCoin\" },\n { name: \"AlreadyInstalledDep\" },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [\n { versionName: \"Ethereum\", version: \"1.6.0\", parentName: undefined },\n { versionName: \"Solana\", version: \"1.2.0\", parentName: undefined },\n {\n versionName: \"MyEthShitCoin\",\n version: \"0.0.1\",\n parentName: \"Ethereum\",\n },\n {\n versionName: \"MySolShitCoin\",\n version: \"0.0.1\",\n parentName: \"Solana\",\n },\n {\n versionName: \"MyPumpFunShitCoin\",\n version: \"0.0.1\",\n parentName: \"Solana\",\n },\n ],\n alreadyInstalled: [\"AlreadyInstalledDep\"],\n missingApplications: [],\n });\n });\n\n it(\"Success with allowed missing applications\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n { name: \"Ethereum\" },\n { name: \"Solana\" },\n { name: \"Cardano\" },\n ],\n allowMissingApplication: true,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [{ versionName: \"Solana\", version: \"1.2.0\" }],\n alreadyInstalled: [\"Ethereum\"],\n missingApplications: [\"Cardano\"],\n });\n });\n\n it(\"Error when device is in incorrect state\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n } as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [{ name: \"Ethereum\" }],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnknownDAError(\"Invalid device state\"),\n });\n });\n\n it(\"Error when device session was not populated\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [{ name: \"Ethereum\" }],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnknownDAError(\"Device apps metadata not fetched\"),\n });\n });\n\n it(\"Error when an app is not found in the catalog\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [] as unknown as Application[],\n catalog: {\n applications: [] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n { name: \"Ethereum\" },\n { name: \"Bitcoin\" },\n { name: \"Solana\" },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnknownDAError(\n \"Application Ethereum not found in the catalog\",\n ),\n });\n });\n\n it(\"Error when an app version is not found in the catalog\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n {\n name: \"Ethereum\",\n constraints: [{ minVersion: \"1.6.0\" }],\n },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnsupportedFirmwareDAError(\n \"Application Ethereum not found in the catalog\",\n ),\n });\n });\n});\n"],
5
- "mappings": "aAAA,IAAAA,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAGO,wCAGPC,EAAuC,kDAGvCC,EAAyC,sCAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,KAAU,mCAAgC,EAEhD,WAAW,IAAM,CACf,GAAG,cAAc,EACjBA,EAAQ,eAAe,gBAAgB,CACrC,GAAI,gBAAc,MACpB,CAAoC,CACtC,CAAC,EAED,GAAG,iCAAkC,IAAM,CAEzCA,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CACb,CAAE,YAAa,WAAY,QAAS,OAAQ,EAC5C,CAAE,YAAa,UAAW,QAAS,OAAQ,CAC7C,EACA,QAAS,CACP,aAAc,CAAC,EACf,iBAAkB,CAAC,CACrB,CACF,CAAkC,EAGlC,MAAMC,EAAS,IAAI,2BAAyBD,EAAS,CACnD,aAAc,CAAC,CAAE,KAAM,UAAW,EAAG,CAAE,KAAM,SAAU,CAAC,EACxD,wBAAyB,EAC3B,CAAC,EAAE,IAAI,EAGP,OAAOC,CAAM,EAAE,cAAc,CAC3B,YAAa,CAAC,EACd,iBAAkB,CAAC,WAAY,SAAS,EACxC,oBAAqB,CAAC,CACxB,CAAC,CACH,CAAC,EAED,GAAG,8BAA+B,IAAM,CAEtCD,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CACb,CAAE,YAAa,WAAY,QAAS,OAAQ,EAC5C,CAAE,YAAa,UAAW,QAAS,OAAQ,CAC7C,EACA,QAAS,CACP,aAAc,CACZ,CAAE,YAAa,WAAY,QAAS,OAAQ,EAC5C,CAAE,YAAa,UAAW,QAAS,OAAQ,EAC3C,CAAE,YAAa,SAAU,QAAS,OAAQ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AAa,UAC3B,cAAe,CAAC,EAChB,QAAS,CACP,aAAc,CAAC,EACf,iBAAkB,CAAC,CACrB,CACF,CAAkC,EAGlC,MAAMC,EAAS,IAAI,2BAAyBD,EAAS,CACnD,aAAc,CACZ,CAAE,KAAM,UAAW,EACnB,CAAE,KAAM,SAAU,EAClB,CAAE,KAAM,QAAS,CACnB,EACA,wBAAyB,EAC3B,CAAC,EAAE,IAAI,EAGP,OAAOC,CAAM,EAAE,cAAc,CAC3B,MAAO,IAAI,iBACT,+CACF,CACF,CAAC,CACH,CAAC,EAED,GAAG,wDAAyD,IAAM,CAEhED,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,QAAS,CACP,aAAc,CACZ,CAAE,YAAa,WAAY,QAAS,OAAQ,CAC9C,EACA,iBAAkB,CAAC,CACrB,CACF,CAAkC,EAGlC,MAAMC,EAAS,IAAI,2BAAyBD,EAAS,CACnD,aAAc,CACZ,CACE,KAAM,WACN,YAAa,CAAC,CAAE,WAAY,OAAQ,CAAC,CACvC,CACF,EACA,wBAAyB,EAC3B,CAAC,EAAE,IAAI,EAGP,OAAOC,CAAM,EAAE,cAAc,CAC3B,MAAO,IAAI,6BACT,+CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC",
4
+ "sourcesContent": ["import { DeviceModelId } from \"@api/device/DeviceModel\";\nimport { DeviceStatus } from \"@api/device/DeviceStatus\";\nimport { makeDeviceActionInternalApiMock } from \"@api/device-action/__test-utils__/makeInternalApi\";\nimport {\n UnknownDAError,\n UnsupportedApplicationDAError,\n UnsupportedFirmwareDAError,\n} from \"@api/device-action/os/Errors\";\nimport type { TransportDeviceModel } from \"@api/device-model/model/DeviceModel\";\nimport type {\n DeviceSessionState,\n FirmwareUpdate,\n} from \"@api/device-session/DeviceSessionState\";\nimport { DeviceSessionStateType } from \"@api/device-session/DeviceSessionState\";\nimport type { Application } from \"@internal/manager-api/model/Application\";\nimport { type FinalFirmware } from \"@internal/manager-api/model/Firmware\";\n\nimport { BuildAppsInstallPlanTask } from \"./BuildAppsInstallPlanTask\";\n\ndescribe(\"BuildAppsInstallPlanTask\", () => {\n const apiMock = makeDeviceActionInternalApiMock();\n\n beforeEach(() => {\n vi.clearAllMocks();\n apiMock.getDeviceModel.mockReturnValue({\n id: DeviceModelId.NANO_X,\n } as unknown as TransportDeviceModel);\n });\n\n it(\"Success with no changes needed\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [{ name: \"Ethereum\" }, { name: \"Bitcoin\" }],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [],\n alreadyInstalled: [\"Ethereum\", \"Bitcoin\"],\n missingApplications: [],\n });\n });\n\n it(\"Success with no constraints\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n { versionName: \"MyShitCoin\", version: \"0.0.1\" },\n { versionName: \"Cardano\", version: \"1.1.0\" },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n { name: \"Ethereum\" },\n { name: \"Solana\" },\n { name: \"Cardano\" },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [\n { versionName: \"Solana\", version: \"1.2.0\" },\n { versionName: \"Cardano\", version: \"1.1.0\" },\n ],\n alreadyInstalled: [\"Ethereum\"],\n missingApplications: [],\n });\n });\n\n it(\"Success with applicable constraints\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.2.0\" },\n { versionName: \"Solana\", version: \"1.1.0\" },\n { versionName: \"Cardano\", version: \"1.1.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n { versionName: \"MyShitCoin\", version: \"0.0.1\" },\n { versionName: \"Cardano\", version: \"1.2.0\" },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n {\n name: \"Ethereum\",\n constraints: [\n { minVersion: \"1.6.0\", applicableModels: [DeviceModelId.NANO_X] },\n ],\n },\n {\n name: \"Bitcoin\",\n constraints: [\n { minVersion: \"1.2.1\", exemptModels: [DeviceModelId.NANO_S] },\n ],\n },\n { name: \"Solana\", constraints: [{ minVersion: \"1.2.0\" }] },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n ],\n alreadyInstalled: [],\n missingApplications: [],\n });\n });\n\n it(\"Success with non-applicable constraints\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.2.0\" },\n { versionName: \"Solana\", version: \"1.1.0\" },\n { versionName: \"Cardano\", version: \"1.1.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n { versionName: \"MyShitCoin\", version: \"0.0.1\" },\n { versionName: \"Cardano\", version: \"1.2.0\" },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n {\n name: \"Ethereum\",\n constraints: [\n { minVersion: \"1.6.0\", exemptModels: [DeviceModelId.NANO_X] },\n ],\n },\n {\n name: \"Bitcoin\",\n constraints: [\n { minVersion: \"1.2.1\", applicableModels: [DeviceModelId.NANO_S] },\n ],\n },\n { name: \"Cardano\", constraints: [{ minVersion: \"1.1.0\" }] },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [],\n alreadyInstalled: [\"Ethereum\", \"Bitcoin\", \"Cardano\"],\n missingApplications: [],\n });\n });\n\n it(\"Success with applicable constraints latest version\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.1.0\" },\n { versionName: \"MyShitCoin\", version: \"0.0.1\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n { versionName: \"Cardano\", version: \"1.2.0\" },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n { name: \"Ethereum\", constraints: [{ minVersion: \"latest\" }] },\n { name: \"Bitcoin\", constraints: [{ minVersion: \"latest\" }] },\n { name: \"MyShitCoin\", constraints: [{ minVersion: \"latest\" }] },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [{ versionName: \"Ethereum\", version: \"1.6.0\" }],\n alreadyInstalled: [\"Bitcoin\", \"MyShitCoin\"],\n missingApplications: [],\n });\n });\n\n it(\"Success with dependencies\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"AlreadyInstalledDep\", version: \"1.2.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\", parentName: undefined },\n { versionName: \"Solana\", version: \"1.2.0\", parentName: undefined },\n {\n versionName: \"MyEthShitCoin\",\n version: \"0.0.1\",\n parentName: \"Ethereum\",\n },\n {\n versionName: \"MySolShitCoin\",\n version: \"0.0.1\",\n parentName: \"Solana\",\n },\n {\n versionName: \"MyPumpFunShitCoin\",\n version: \"0.0.1\",\n parentName: \"Solana\",\n },\n { versionName: \"Cardano\", version: \"1.2.0\", parentName: undefined },\n {\n versionName: \"AlreadyInstalledDep\",\n version: \"1.2.0\",\n parentName: \"Cardano\",\n },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n { name: \"MyEthShitCoin\" },\n { name: \"MySolShitCoin\" },\n { name: \"Solana\" },\n { name: \"MyPumpFunShitCoin\" },\n { name: \"AlreadyInstalledDep\" },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [\n { versionName: \"Ethereum\", version: \"1.6.0\", parentName: undefined },\n { versionName: \"Solana\", version: \"1.2.0\", parentName: undefined },\n {\n versionName: \"MyEthShitCoin\",\n version: \"0.0.1\",\n parentName: \"Ethereum\",\n },\n {\n versionName: \"MySolShitCoin\",\n version: \"0.0.1\",\n parentName: \"Solana\",\n },\n {\n versionName: \"MyPumpFunShitCoin\",\n version: \"0.0.1\",\n parentName: \"Solana\",\n },\n ],\n alreadyInstalled: [\"AlreadyInstalledDep\"],\n missingApplications: [],\n });\n });\n\n it(\"Success with allowed missing applications\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n ] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.6.0\" },\n { versionName: \"Bitcoin\", version: \"1.3.0\" },\n { versionName: \"Solana\", version: \"1.2.0\" },\n ] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n { name: \"Ethereum\" },\n { name: \"Solana\" },\n { name: \"Cardano\" },\n ],\n allowMissingApplication: true,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n installPlan: [{ versionName: \"Solana\", version: \"1.2.0\" }],\n alreadyInstalled: [\"Ethereum\"],\n missingApplications: [\"Cardano\"],\n });\n });\n\n it(\"Error when device is in incorrect state\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n } as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [{ name: \"Ethereum\" }],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnknownDAError(\"Invalid device state\"),\n });\n });\n\n it(\"Error when device session was not populated\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [{ name: \"Ethereum\" }],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnknownDAError(\"Device apps metadata not fetched\"),\n });\n });\n\n describe(\"Error cases for unsupported applications and firmwares\", () => {\n describe(\"when firmware is up to date\", () => {\n it(\"should throw `UnsupportedApplicationDAError` when application not found in catalog\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n firmwareUpdateContext: {\n currentFirmware: {} as FinalFirmware,\n },\n installedApps: [] as unknown as Application[],\n catalog: {\n applications: [] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [{ name: \"Ethereum\" }],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnsupportedApplicationDAError(\n \"Application Ethereum not supported for this device\",\n ),\n });\n });\n it(\"should throw `UnsupportedApplicationDAError` when application version is not supported\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n firmwareUpdateContext: {\n currentFirmware: {} as FinalFirmware,\n },\n installedApps: [] as unknown as Application[],\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n ] as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n {\n name: \"Ethereum\",\n constraints: [{ minVersion: \"1.6.0\" }],\n },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnsupportedApplicationDAError(\n \"Application Ethereum not supported for this device\",\n ),\n });\n });\n });\n describe(\"when firmware is out of date\", () => {\n it(\"should throw `UnsupportedFirmwareDAError` when application not found in catalog\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n firmwareUpdateContext: {\n currentFirmware: {} as FinalFirmware,\n availableUpdate: {} as FirmwareUpdate,\n },\n installedApps: [] as unknown as Application[],\n catalog: {\n applications: [] as unknown as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [{ name: \"Ethereum\" }],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnsupportedFirmwareDAError(\n \"Application Ethereum needs latest firmware\",\n ),\n });\n });\n it(\"should throw `UnsupportedFirmwareDAError` when application version is not supported\", () => {\n // GIVEN\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [] as unknown as Application[],\n firmwareUpdateContext: {\n currentFirmware: {} as FinalFirmware,\n availableUpdate: {} as FirmwareUpdate,\n },\n catalog: {\n applications: [\n { versionName: \"Ethereum\", version: \"1.5.0\" },\n ] as Application[],\n languagePackages: [],\n },\n } as unknown as DeviceSessionState);\n\n // WHEN\n const result = new BuildAppsInstallPlanTask(apiMock, {\n applications: [\n {\n name: \"Ethereum\",\n constraints: [{ minVersion: \"1.6.0\" }],\n },\n ],\n allowMissingApplication: false,\n }).run();\n\n // THEN\n expect(result).toStrictEqual({\n error: new UnsupportedFirmwareDAError(\n \"Application Ethereum needs latest firmware\",\n ),\n });\n });\n });\n });\n});\n"],
5
+ "mappings": "aAAA,IAAAA,EAA8B,mCAC9BC,EAA6B,oCAC7BC,EAAgD,6DAChDC,EAIO,wCAMPC,EAAuC,kDAIvCC,EAAyC,sCAEzC,SAAS,2BAA4B,IAAM,CACzC,MAAMC,KAAU,mCAAgC,EAEhD,WAAW,IAAM,CACf,GAAG,cAAc,EACjBA,EAAQ,eAAe,gBAAgB,CACrC,GAAI,gBAAc,MACpB,CAAoC,CACtC,CAAC,EAED,GAAG,iCAAkC,IAAM,CAEzCA,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CACb,CAAE,YAAa,WAAY,QAAS,OAAQ,EAC5C,CAAE,YAAa,UAAW,QAAS,OAAQ,CAC7C,EACA,QAAS,CACP,aAAc,CAAC,EACf,iBAAkB,CAAC,CACrB,CACF,CAAkC,EAGlC,MAAMC,EAAS,IAAI,2BAAyBD,EAAS,CACnD,aAAc,CAAC,CAAE,KAAM,UAAW,EAAG,CAAE,KAAM,SAAU,CAAC,EACxD,wBAAyB,EAC3B,CAAC,EAAE,IAAI,EAGP,OAAOC,CAAM,EAAE,cAAc,CAC3B,YAAa,CAAC,EACd,iBAAkB,CAAC,WAAY,SAAS,EACxC,oBAAqB,CAAC,CACxB,CAAC,CACH,CAAC,EAED,GAAG,8BAA+B,IAAM,CAEtCD,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAA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AoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,sBAAuB,CACrB,gBAAiB,CAAC,EAClB,gBAAiB,CAAC,CACpB,EACA,cAAe,CAAC,EAChB,QAAS,CACP,aAAc,CAAC,EACf,iBAAkB,CAAC,CACrB,CACF,CAAkC,EAGlC,MAAMC,EAAS,IAAI,2BAAyBD,EAAS,CACnD,aAAc,CAAC,CAAE,KAAM,UAAW,CAAC,EACnC,wBAAyB,EAC3B,CAAC,EAAE,IAAI,EAGP,OAAOC,CAAM,EAAE,cAAc,CAC3B,MAAO,IAAI,6BACT,4CACF,CACF,CAAC,CACH,CAAC,EACD,GAAG,sFAAuF,IAAM,CAE9FD,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,sBAAuB,CACrB,gBAAiB,CAAC,EAClB,gBAAiB,CAAC,CACpB,EACA,QAAS,CACP,aAAc,CACZ,CAAE,YAAa,WAAY,QAAS,OAAQ,CAC9C,EACA,iBAAkB,CAAC,CACrB,CACF,CAAkC,EAGlC,MAAMC,EAAS,IAAI,2BAAyBD,EAAS,CACnD,aAAc,CACZ,CACE,KAAM,WACN,YAAa,CAAC,CAAE,WAAY,OAAQ,CAAC,CACvC,CACF,EACA,wBAAyB,EAC3B,CAAC,EAAE,IAAI,EAGP,OAAOC,CAAM,EAAE,cAAc,CAC3B,MAAO,IAAI,6BACT,4CACF,CACF,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC,CACH,CAAC",
6
6
  "names": ["import_DeviceModel", "import_DeviceStatus", "import_makeInternalApi", "import_Errors", "import_DeviceSessionState", "import_BuildAppsInstallPlanTask", "apiMock", "result"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/internal/manager-api/data/ManagerApiDataSource.ts"],
4
- "sourcesContent": ["import { type EitherAsync } from \"purify-ts\";\n\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\nimport {\n type FinalFirmware,\n type McuFirmware,\n type OsuFirmware,\n} from \"@internal/manager-api/model/Firmware\";\nimport { type LanguagePackage } from \"@internal/manager-api/model/Language\";\nimport {\n type GetAppByHashParams,\n type GetAppListParams,\n type GetDeviceVersionParams,\n type GetFirmwareVersionParams,\n type GetLanguagePackagesParams,\n type GetLatestFirmwareVersionParams,\n} from \"@internal/manager-api/model/Params\";\n\n/**\n * Interface representing a data source for the Manager API.\n */\nexport interface ManagerApiDataSource {\n /**\n * Retrieves the list of applications for a given target ID, and firmware version.\n *\n * @param params - The parameters for getting the application list.\n * @returns EitherAsync containing an array of applications or an HttpFetchApiError.\n */\n getAppList(\n params: GetAppListParams,\n ): EitherAsync<HttpFetchApiError, Array<Application>>;\n\n /**\n * Retrieves applications by their hashes.\n *\n * @param hashes - An array of application hashes, can be got from the response of the ListAppsCommand.\n * @returns EitherAsync containing an array of applications or null values, or an HttpFetchApiError.\n */\n getAppsByHash(\n params: GetAppByHashParams,\n ): EitherAsync<HttpFetchApiError, Array<Application | null>>;\n\n /**\n * Retrieves the device version for a given target ID.\n *\n * @param params - The parameters for getting the device version.\n * @returns EitherAsync containing the device version or an HttpFetchApiError.\n */\n getDeviceVersion(\n params: GetDeviceVersionParams,\n ): EitherAsync<HttpFetchApiError, DeviceVersion>;\n\n /**\n * Retrieves the firmware version for a given version, device ID.\n *\n * @param params - The parameters for getting the firmware version.\n * @returns EitherAsync containing the final firmware or an HttpFetchApiError.\n */\n getFirmwareVersion(\n params: GetFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, FinalFirmware>;\n\n /**\n * Sets the provider identifier.\n *\n * @param provider - The provider identifier.\n */\n setProvider(provider: number): void;\n\n /**\n * Returns the current provider.\n */\n getProvider(): number;\n\n /**\n * Retrieves a firmware version from a final firmware ID.\n *\n * @param finalFirmwareId - The ID of the final firmware to retrieve.\n * @returns EitherAsync containing the final firmware or an HttpFetchApiError.\n */\n getFirmwareVersionById(\n finalFirmwareId: number,\n ): EitherAsync<HttpFetchApiError, FinalFirmware>;\n\n /**\n * Retrieves the an OSU firmware version for a given version, device ID.\n *\n * @param params - The parameters for getting the firmware version.\n * @returns EitherAsync containing the OSU firmware or an HttpFetchApiError.\n */\n getOsuFirmwareVersion(\n params: GetFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, OsuFirmware>;\n\n /**\n * Retrieves the latest firmware available for a given current firmware, device ID.\n *\n * @param params - The parameters for getting the firmware version.\n * @returns EitherAsync containing the OSU firmware or an HttpFetchApiError.\n */\n getLatestFirmwareVersion(\n params: GetLatestFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, OsuFirmware>;\n\n /**\n * Retrieves the available language packages for a device.\n *\n * @param params - The parameters for getting the language packages.\n * @returns EitherAsync containing the list of language packages or an HttpFetchApiError.\n */\n getLanguagePackages(\n params: GetLanguagePackagesParams,\n ): EitherAsync<HttpFetchApiError, Array<LanguagePackage>>;\n\n /**\n * Retrieves the list of available MCU firmwares.\n *\n * @returns EitherAsync containing an array of mcu firmwares or an HttpFetchApiError.\n */\n getMcuList(): EitherAsync<HttpFetchApiError, Array<McuFirmware>>;\n}\n"],
4
+ "sourcesContent": ["import { type EitherAsync } from \"purify-ts\";\n\nimport { type Application } from \"@internal/manager-api/model/Application\";\nimport { type DeviceVersion } from \"@internal/manager-api/model/Device\";\nimport { type HttpFetchApiError } from \"@internal/manager-api/model/Errors\";\nimport {\n type FinalFirmware,\n type McuFirmware,\n type OsuFirmware,\n} from \"@internal/manager-api/model/Firmware\";\nimport { type LanguagePackage } from \"@internal/manager-api/model/Language\";\nimport {\n type GetAppByHashParams,\n type GetAppListParams,\n type GetDeviceVersionParams,\n type GetFirmwareVersionParams,\n type GetLanguagePackagesParams,\n type GetLatestFirmwareVersionParams,\n} from \"@internal/manager-api/model/Params\";\n\n/**\n * Interface representing a data source for the Manager API.\n */\nexport interface ManagerApiDataSource {\n /**\n * Retrieves the list of applications for a given target ID and firmware version.\n *\n * @param params - The parameters for getting the application list.\n * @returns EitherAsync containing an array of applications or an HttpFetchApiError.\n */\n getAppList(\n params: GetAppListParams,\n ): EitherAsync<HttpFetchApiError, Array<Application>>;\n\n /**\n * Retrieves applications by their hashes.\n *\n * @param hashes - An array of application hashes, can be got from the response of the ListAppsCommand.\n * @returns EitherAsync containing an array of applications or null values, or an HttpFetchApiError.\n */\n getAppsByHash(\n params: GetAppByHashParams,\n ): EitherAsync<HttpFetchApiError, Array<Application | null>>;\n\n /**\n * Retrieves the device version for a given target ID.\n *\n * @param params - The parameters for getting the device version.\n * @returns EitherAsync containing the device version or an HttpFetchApiError.\n */\n getDeviceVersion(\n params: GetDeviceVersionParams,\n ): EitherAsync<HttpFetchApiError, DeviceVersion>;\n\n /**\n * Retrieves the firmware version for a given version, device ID.\n *\n * @param params - The parameters for getting the firmware version.\n * @returns EitherAsync containing the final firmware or an HttpFetchApiError.\n */\n getFirmwareVersion(\n params: GetFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, FinalFirmware>;\n\n /**\n * Sets the provider identifier.\n *\n * @param provider - The provider identifier.\n */\n setProvider(provider: number): void;\n\n /**\n * Returns the current provider.\n */\n getProvider(): number;\n\n /**\n * Retrieves a firmware version from a final firmware ID.\n *\n * @param finalFirmwareId - The ID of the final firmware to retrieve.\n * @returns EitherAsync containing the final firmware or an HttpFetchApiError.\n */\n getFirmwareVersionById(\n finalFirmwareId: number,\n ): EitherAsync<HttpFetchApiError, FinalFirmware>;\n\n /**\n * Retrieves the an OSU firmware version for a given version, device ID.\n *\n * @param params - The parameters for getting the firmware version.\n * @returns EitherAsync containing the OSU firmware or an HttpFetchApiError.\n */\n getOsuFirmwareVersion(\n params: GetFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, OsuFirmware>;\n\n /**\n * Retrieves the latest firmware available for a given current firmware, device ID.\n *\n * @param params - The parameters for getting the firmware version.\n * @returns EitherAsync containing the OSU firmware or an HttpFetchApiError.\n */\n getLatestFirmwareVersion(\n params: GetLatestFirmwareVersionParams,\n ): EitherAsync<HttpFetchApiError, OsuFirmware>;\n\n /**\n * Retrieves the available language packages for a device.\n *\n * @param params - The parameters for getting the language packages.\n * @returns EitherAsync containing the list of language packages or an HttpFetchApiError.\n */\n getLanguagePackages(\n params: GetLanguagePackagesParams,\n ): EitherAsync<HttpFetchApiError, Array<LanguagePackage>>;\n\n /**\n * Retrieves the list of available MCU firmwares.\n *\n * @returns EitherAsync containing an array of mcu firmwares or an HttpFetchApiError.\n */\n getMcuList(): EitherAsync<HttpFetchApiError, Array<McuFirmware>>;\n}\n"],
5
5
  "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
6
  "names": ["ManagerApiDataSource_exports", "__toCommonJS"]
7
7
  }
@@ -1,36 +1,4 @@
1
1
  {
2
- "name": "@ledgerhq/device-management-kit",
3
- "version": "0.11.2",
4
- "private": false,
5
- "license": "Apache-2.0",
6
- "exports": {
7
- ".": {
8
- "types": "./lib/types/index.d.ts",
9
- "import": "./lib/esm/index.js",
10
- "require": "./lib/cjs/index.js"
11
- }
12
- },
13
- "files": [
14
- "./lib",
15
- "package.json"
16
- ],
17
- "scripts": {
18
- "prebuild": "rimraf lib",
19
- "build": "pnpm ldmk-tool build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
20
- "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
21
- "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
22
- "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"",
23
- "lint": "eslint",
24
- "lint:fix": "pnpm lint --fix",
25
- "postpack": "find . -name '*.tgz' -exec cp {} ../../dist/ \\; ",
26
- "prettier": "prettier . --check",
27
- "prettier:fix": "prettier . --write",
28
- "test": "vitest run",
29
- "test:watch": "vitest",
30
- "test:coverage": "vitest run --coverage",
31
- "typecheck": "tsc --noEmit",
32
- "module:create": "pnpm hygen core-module with-prompt"
33
- },
34
2
  "dependencies": {
35
3
  "@noble/hashes": "^1.8.0",
36
4
  "@sentry/minimal": "catalog:",
@@ -45,20 +13,56 @@
45
13
  "ws": "catalog:",
46
14
  "xstate": "catalog:"
47
15
  },
48
- "peerDependencies": {
49
- "rxjs": "catalog:"
50
- },
51
16
  "devDependencies": {
52
- "@ledgerhq/ldmk-tool": "workspace:*",
53
- "@ledgerhq/eslint-config-dsdk": "workspace:*",
54
- "@ledgerhq/prettier-config-dsdk": "workspace:*",
55
- "@ledgerhq/tsconfig-dsdk": "workspace:*",
56
- "@ledgerhq/vitest-config-dmk": "workspace:*",
17
+ "@ledgerhq/eslint-config-dsdk": "workspace:^",
18
+ "@ledgerhq/ldmk-tool": "workspace:^",
19
+ "@ledgerhq/prettier-config-dsdk": "workspace:^",
20
+ "@ledgerhq/tsconfig-dsdk": "workspace:^",
21
+ "@ledgerhq/vitest-config-dmk": "workspace:^",
57
22
  "@statelyai/inspect": "catalog:",
58
23
  "@types/semver": "catalog:",
59
24
  "@types/uuid": "catalog:",
60
25
  "@types/ws": "catalog:",
61
26
  "rxjs": "catalog:",
62
27
  "ts-node": "catalog:"
63
- }
28
+ },
29
+ "exports": {
30
+ ".": {
31
+ "import": "./lib/esm/index.js",
32
+ "require": "./lib/cjs/index.js",
33
+ "types": "./lib/types/index.d.ts"
34
+ }
35
+ },
36
+ "files": [
37
+ "./lib",
38
+ "package.json"
39
+ ],
40
+ "license": "Apache-2.0",
41
+ "name": "@ledgerhq/device-management-kit",
42
+ "peerDependencies": {
43
+ "rxjs": "catalog:"
44
+ },
45
+ "private": false,
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/LedgerHQ/device-sdk-ts.git"
49
+ },
50
+ "scripts": {
51
+ "build": "pnpm ldmk-tool build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
52
+ "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"",
53
+ "lint": "eslint",
54
+ "lint:fix": "pnpm lint --fix",
55
+ "module:create": "pnpm hygen core-module with-prompt",
56
+ "postpack": "find . -name '*.tgz' -exec cp {} ../../dist/ \\; ",
57
+ "prebuild": "rimraf lib",
58
+ "prettier": "prettier . --check",
59
+ "prettier:fix": "prettier . --write",
60
+ "test": "vitest run",
61
+ "test:coverage": "vitest run --coverage",
62
+ "test:watch": "vitest",
63
+ "typecheck": "tsc --noEmit",
64
+ "watch:builds": "pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",
65
+ "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\""
66
+ },
67
+ "version": "0.12.0"
64
68
  }
@@ -1,2 +1,2 @@
1
- class n{_tag="DeviceNotOnboardedError";originalError;constructor(r){this.originalError=new Error(r??"Device not onboarded.")}}class e{_tag="DeviceLockedError";originalError;constructor(r){this.originalError=new Error(r??"Device locked.")}}class t{_tag="UnsupportedFirmwareDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class i{_tag="RefusedByUserDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class a{_tag="AppAlreadyInstalledDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class s{_tag="OutOfMemoryDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class E{_tag="UnknownDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}export{a as AppAlreadyInstalledDAError,e as DeviceLockedError,n as DeviceNotOnboardedError,s as OutOfMemoryDAError,i as RefusedByUserDAError,E as UnknownDAError,t as UnsupportedFirmwareDAError};
1
+ class n{_tag="DeviceNotOnboardedError";originalError;constructor(r){this.originalError=new Error(r??"Device not onboarded.")}}class e{_tag="DeviceLockedError";originalError;constructor(r){this.originalError=new Error(r??"Device locked.")}}class t{_tag="UnsupportedFirmwareDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class i{_tag="RefusedByUserDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class a{_tag="AppAlreadyInstalledDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class l{_tag="OutOfMemoryDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class s{_tag="UnknownDAError";originalError;constructor(r){this.originalError=new Error(r??"Unknown error.")}}class E{_tag="UnsupportedApplicationDAError";originalError;constructor(r){this.originalError=new Error(r??"Application currently not supported.")}}export{a as AppAlreadyInstalledDAError,e as DeviceLockedError,n as DeviceNotOnboardedError,l as OutOfMemoryDAError,i as RefusedByUserDAError,s as UnknownDAError,E as UnsupportedApplicationDAError,t as UnsupportedFirmwareDAError};
2
2
  //# sourceMappingURL=Errors.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/api/device-action/os/Errors.ts"],
4
- "sourcesContent": ["import { type DmkError } from \"@api/Error\";\n\nexport class DeviceNotOnboardedError implements DmkError {\n readonly _tag = \"DeviceNotOnboardedError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Device not onboarded.\");\n }\n}\n\nexport class DeviceLockedError implements DmkError {\n readonly _tag = \"DeviceLockedError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Device locked.\");\n }\n}\n\nexport class UnsupportedFirmwareDAError implements DmkError {\n readonly _tag = \"UnsupportedFirmwareDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class RefusedByUserDAError implements DmkError {\n readonly _tag = \"RefusedByUserDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class AppAlreadyInstalledDAError implements DmkError {\n readonly _tag = \"AppAlreadyInstalledDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class OutOfMemoryDAError implements DmkError {\n readonly _tag = \"OutOfMemoryDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class UnknownDAError implements DmkError {\n readonly _tag = \"UnknownDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n"],
5
- "mappings": "AAEO,MAAMA,CAA4C,CAC9C,KAAO,0BACP,cAET,YAAYC,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,uBAAuB,CACnE,CACF,CAEO,MAAMC,CAAsC,CACxC,KAAO,oBACP,cAET,YAAYD,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAME,CAA+C,CACjD,KAAO,6BACP,cAET,YAAYF,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMG,CAAyC,CAC3C,KAAO,uBACP,cAET,YAAYH,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMI,CAA+C,CACjD,KAAO,6BACP,cAET,YAAYJ,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMK,CAAuC,CACzC,KAAO,qBACP,cAET,YAAYL,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMM,CAAmC,CACrC,KAAO,iBACP,cAET,YAAYN,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF",
6
- "names": ["DeviceNotOnboardedError", "message", "DeviceLockedError", "UnsupportedFirmwareDAError", "RefusedByUserDAError", "AppAlreadyInstalledDAError", "OutOfMemoryDAError", "UnknownDAError"]
4
+ "sourcesContent": ["import { type DmkError } from \"@api/Error\";\n\nexport class DeviceNotOnboardedError implements DmkError {\n readonly _tag = \"DeviceNotOnboardedError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Device not onboarded.\");\n }\n}\n\nexport class DeviceLockedError implements DmkError {\n readonly _tag = \"DeviceLockedError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Device locked.\");\n }\n}\n\nexport class UnsupportedFirmwareDAError implements DmkError {\n readonly _tag = \"UnsupportedFirmwareDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class RefusedByUserDAError implements DmkError {\n readonly _tag = \"RefusedByUserDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class AppAlreadyInstalledDAError implements DmkError {\n readonly _tag = \"AppAlreadyInstalledDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class OutOfMemoryDAError implements DmkError {\n readonly _tag = \"OutOfMemoryDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class UnknownDAError implements DmkError {\n readonly _tag = \"UnknownDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(message ?? \"Unknown error.\");\n }\n}\n\nexport class UnsupportedApplicationDAError implements DmkError {\n readonly _tag = \"UnsupportedApplicationDAError\";\n readonly originalError?: Error;\n\n constructor(message?: string) {\n this.originalError = new Error(\n message ?? \"Application currently not supported.\",\n );\n }\n}\n"],
5
+ "mappings": "AAEO,MAAMA,CAA4C,CAC9C,KAAO,0BACP,cAET,YAAYC,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,uBAAuB,CACnE,CACF,CAEO,MAAMC,CAAsC,CACxC,KAAO,oBACP,cAET,YAAYD,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAME,CAA+C,CACjD,KAAO,6BACP,cAET,YAAYF,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMG,CAAyC,CAC3C,KAAO,uBACP,cAET,YAAYH,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMI,CAA+C,CACjD,KAAO,6BACP,cAET,YAAYJ,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMK,CAAuC,CACzC,KAAO,qBACP,cAET,YAAYL,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMM,CAAmC,CACrC,KAAO,iBACP,cAET,YAAYN,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MAAMA,GAAW,gBAAgB,CAC5D,CACF,CAEO,MAAMO,CAAkD,CACpD,KAAO,gCACP,cAET,YAAYP,EAAkB,CAC5B,KAAK,cAAgB,IAAI,MACvBA,GAAW,sCACb,CACF,CACF",
6
+ "names": ["DeviceNotOnboardedError", "message", "DeviceLockedError", "UnsupportedFirmwareDAError", "RefusedByUserDAError", "AppAlreadyInstalledDAError", "OutOfMemoryDAError", "UnknownDAError", "UnsupportedApplicationDAError"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Left as C,Right as x}from"purify-ts";import{assign as r,fromObservable as V,fromPromise as c,setup as I}from"xstate";import{isSuccessCommandResult as f}from"../../../command/model/CommandResult";import{UserInteractionRequired as i}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as G}from"../../../device-action/os/Const";import{GoToDashboardDeviceAction as E}from"../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{ListAppsDeviceAction as F}from"../../../device-action/os/ListApps/ListAppsDeviceAction";import{GetApplicationsMetadataTask as U}from"../../../device-action/task/GetApplicationsMetadataTask";import{GetFirmwareMetadataTask as k}from"../../../device-action/task/GetFirmwareMetadataTask";import{XStateDeviceAction as T}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as s}from"../../../device-session/DeviceSessionState";import{installedAppResultGuard as L}from"../../../secure-channel/device-action/ListInstalledApps/types";import{ConnectToSecureChannelTask as R}from"../../../secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as o}from"../../../secure-channel/task/types";class Y extends T{makeStateMachine(n){const{getDeviceMetadata:u,getFirmwareMetadata:d,getApplicationsMetadata:m,listAppsSecureChannel:g}=this.extractDependencies(n),t=this.input.unlockTimeout??G,l=new E({input:{unlockTimeout:t}}).makeStateMachine(n),p=new F({input:{unlockTimeout:t}}).makeStateMachine(n);return I({types:{input:{unlockTimeout:t},context:{},output:{}},actors:{goToDashboard:l,getDeviceMetadata:c(u),getFirmwareMetadata:c(d),getApplicationsMetadata:c(m),listApps:p,listAppsSecureChannel:V(g)},guards:{hasError:({context:e})=>e._internalState.error!==null,hasMetadata:({context:e})=>e._internalState.firmwareVersion!==null&&e._internalState.firmwareUpdateContext!==null&&e._internalState.customImage!==null&&e._internalState.applications!==null&&e._internalState.applicationsUpdates!==null&&e._internalState.installedLanguages!==null&&e._internalState.catalog!==null,forceUpdate:({context:e})=>!!e.input.forceUpdate,useSecureChannel:({context:e})=>!!e.input.useSecureChannel},actions:{assignErrorFromEvent:r({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GetDeviceMetadataDeviceAction",initial:"DeviceReady",context:e=>({input:{useSecureChannel:e.input.useSecureChannel,forceUpdate:e.input.forceUpdate,unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:i.None},_internalState:{error:null,deviceVersion:null,firmware:null,firmwareVersion:null,firmwareUpdateContext:null,customImage:null,installedApps:null,applications:null,applicationsUpdates:null,installedLanguages:null,catalog:null}}),states:{DeviceReady:{always:[{target:"GoToDashboard",guard:"forceUpdate"},{target:"GetDeviceMetadataFromContext"}]},GetDeviceMetadataFromContext:{invoke:{src:"getDeviceMetadata",onDone:{target:"GetDeviceMetadataFromContextResultCheck",actions:r({_internalState:e=>e.event.output===null?e.context._internalState:{...e.context._internalState,firmwareVersion:e.event.output.firmwareVersion,firmwareUpdateContext:e.event.output.firmwareUpdateContext,customImage:e.event.output.customImage,applications:e.event.output.applications,applicationsUpdates:e.event.output.applicationsUpdates,installedLanguages:e.event.output.installedLanguages,catalog:e.event.output.catalog}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceMetadataFromContextResultCheck:{always:[{target:"Success",guard:"hasMetadata"},{target:"GoToDashboard"}]},GoToDashboard:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"dashboard",src:"goToDashboard",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:r({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"GoToDashboardCheck",actions:r({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:a=>({...e.context._internalState,error:a})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetFirmwareMetadata"}]},GetFirmwareMetadata:{invoke:{src:"getFirmwareMetadata",onDone:{target:"GetFirmwareMetadataResultCheck",actions:r({_internalState:e=>{if(f(e.event.output)){const a=n.getDeviceSessionState();return a.sessionStateType!==s.Connected&&n.setDeviceSessionState({...a,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}),{...e.context._internalState,deviceVersion:e.event.output.data.deviceVersion,firmware:e.event.output.data.firmware,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetFirmwareMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{guard:"useSecureChannel",target:"ListAppsSecureChannel"},{target:"ListApps"}]},ListAppsSecureChannel:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"listAppsSecureChannel",src:"listAppsSecureChannel",input:e=>({firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion}),onSnapshot:{actions:r({intermediateValue:e=>{switch(e.event.snapshot.context?.type){case o.DeviceId:return{...e.context.intermediateValue,deviceId:e.event.snapshot.context.payload.deviceId};case o.PermissionRequested:return{...e.context.intermediateValue,requiredUserInteraction:i.AllowSecureConnection};case o.PermissionGranted:{const a=n.getDeviceSessionState();return a.sessionStateType!==s.Connected&&n.setDeviceSessionState({...a,isSecureConnectionAllowed:!0}),{...e.context.intermediateValue,requiredUserInteraction:i.None}}default:return{...e.context.intermediateValue}}},_internalState:e=>{if(e.event.snapshot.context?.type===o.Error)return{...e.context._internalState,error:e.event.snapshot.context.error.mapDAErrors()};if(e.event.snapshot.context?.type===o.Result){if(L(e.event.snapshot.context.payload))return{...e.context._internalState,installedApps:e.event.snapshot.context.payload.map(a=>({name:a.name,hash:a.hash,hashCode:a.hash_code_data}))};throw new Error(`Invalid result ${JSON.stringify(e.event.snapshot.context.payload)}`)}return{...e.context._internalState}}})},onDone:{target:"ListAppsCheck"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListApps:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"listApps",src:"listApps",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:r({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"ListAppsCheck",actions:r({_internalState:e=>e.event.output.isLeft()?{...e.context._internalState,error:e.event.output.extract()}:{...e.context._internalState,installedApps:e.event.output.unsafeCoerce().map(a=>({name:a.appName,hash:a.appFullHash,hashCode:a.appCodeHash}))}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetApplicationsMetadata"}]},GetApplicationsMetadata:{invoke:{src:"getApplicationsMetadata",input:e=>({deviceVersion:e.context._internalState.deviceVersion,firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion,installedApps:e.context._internalState.installedApps}),onDone:{target:"GetApplicationsMetadataResultCheck",actions:r({_internalState:e=>{if(f(e.event.output)){const a=n.getDeviceSessionState();return a.sessionStateType!==s.Connected&&n.setDeviceSessionState({...a,installedApps:e.event.output.data.applications,appsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}),{...e.context._internalState,applications:e.event.output.data.applications,applicationsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetApplicationsMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:a}=e,{error:v,firmwareVersion:S,firmwareUpdateContext:w,customImage:h,applications:D,applicationsUpdates:M,installedLanguages:y,catalog:A}=a._internalState;return v?C(v):x({firmwareVersion:S,firmwareUpdateContext:w,customImage:h,applications:D,applicationsUpdates:M,installedLanguages:y,catalog:A})}})}extractDependencies(n){return{getDeviceMetadata:async()=>{const t=n.getDeviceSessionState();return t.sessionStateType===s.Connected||t.firmwareVersion?.metadata===void 0||t.firmwareUpdateContext===void 0||t.customImage===void 0||t.installedApps.length===0||t.appsUpdates===void 0||t.installedLanguages===void 0||t.catalog===void 0?null:{firmwareVersion:t.firmwareVersion,firmwareUpdateContext:t.firmwareUpdateContext,customImage:t.customImage,applications:t.installedApps,applicationsUpdates:t.appsUpdates,installedLanguages:t.installedLanguages,catalog:t.catalog}},getFirmwareMetadata:async()=>new k(n).run(),getApplicationsMetadata:async t=>new U(n,{deviceVersion:t.input.deviceVersion,firmware:t.input.firmware,firmwareVersion:t.input.firmwareVersion,installedApps:t.input.installedApps}).run(),listAppsSecureChannel:t=>{const{firmware:l,firmwareVersion:p}=t.input,e=n.getSecureChannelService().listInstalledApps(p.metadata,l);return new R(n,{connection:e}).run()}}}}export{Y as GetDeviceMetadataDeviceAction};
1
+ import{Left as C,Right as x}from"purify-ts";import{assign as r,fromObservable as V,fromPromise as c,setup as I}from"xstate";import{isSuccessCommandResult as f}from"../../../command/model/CommandResult";import{UserInteractionRequired as i}from"../../../device-action/model/UserInteractionRequired";import{DEFAULT_UNLOCK_TIMEOUT_MS as G}from"../../../device-action/os/Const";import{GoToDashboardDeviceAction as E}from"../../../device-action/os/GoToDashboard/GoToDashboardDeviceAction";import{ListAppsDeviceAction as F}from"../../../device-action/os/ListApps/ListAppsDeviceAction";import{GetApplicationsMetadataTask as U}from"../../../device-action/task/GetApplicationsMetadataTask";import{GetFirmwareMetadataTask as k}from"../../../device-action/task/GetFirmwareMetadataTask";import{XStateDeviceAction as T}from"../../../device-action/xstate-utils/XStateDeviceAction";import{DeviceSessionStateType as s}from"../../../device-session/DeviceSessionState";import{installedAppResultGuard as L}from"../../../secure-channel/device-action/ListInstalledApps/types";import{ConnectToSecureChannelTask as R}from"../../../secure-channel/task/ConnectToSecureChannelTask";import{SecureChannelEventType as o}from"../../../secure-channel/task/types";class Y extends T{makeStateMachine(n){const{getDeviceMetadata:u,getFirmwareMetadata:d,getApplicationsMetadata:m,listAppsSecureChannel:g}=this.extractDependencies(n),t=this.input.unlockTimeout??G,l=new E({input:{unlockTimeout:t}}).makeStateMachine(n),p=new F({input:{unlockTimeout:t}}).makeStateMachine(n);return I({types:{input:{unlockTimeout:t},context:{},output:{}},actors:{goToDashboard:l,getDeviceMetadata:c(u),getFirmwareMetadata:c(d),getApplicationsMetadata:c(m),listApps:p,listAppsSecureChannel:V(g)},guards:{hasError:({context:e})=>e._internalState.error!==null,hasMetadata:({context:e})=>e._internalState.firmwareVersion!==null&&e._internalState.firmwareUpdateContext!==null&&e._internalState.customImage!==null&&e._internalState.applications!==null&&e._internalState.applicationsUpdates!==null&&e._internalState.installedLanguages!==null&&e._internalState.catalog!==null,forceUpdate:({context:e})=>!!e.input.forceUpdate,useSecureChannel:({context:e})=>!!e.input.useSecureChannel},actions:{assignErrorFromEvent:r({_internalState:e=>({...e.context._internalState,error:e.event.error})})}}).createMachine({id:"GetDeviceMetadataDeviceAction",initial:"DeviceReady",context:e=>({input:{useSecureChannel:e.input.useSecureChannel,forceUpdate:e.input.forceUpdate,unlockTimeout:e.input.unlockTimeout},intermediateValue:{requiredUserInteraction:i.None},_internalState:{error:null,deviceVersion:null,firmware:null,firmwareVersion:null,firmwareUpdateContext:null,customImage:null,installedApps:null,applications:null,applicationsUpdates:null,installedLanguages:null,catalog:null}}),states:{DeviceReady:{always:[{target:"GoToDashboard",guard:"forceUpdate"},{target:"GetDeviceMetadataFromContext"}]},GetDeviceMetadataFromContext:{invoke:{src:"getDeviceMetadata",onDone:{target:"GetDeviceMetadataFromContextResultCheck",actions:r({_internalState:e=>e.event.output===null?e.context._internalState:{...e.context._internalState,firmwareVersion:e.event.output.firmwareVersion,firmwareUpdateContext:e.event.output.firmwareUpdateContext,customImage:e.event.output.customImage,applications:e.event.output.applications,applicationsUpdates:e.event.output.applicationsUpdates,installedLanguages:e.event.output.installedLanguages,catalog:e.event.output.catalog}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceMetadataFromContextResultCheck:{always:[{target:"Success",guard:"hasMetadata"},{target:"GoToDashboard"}]},GoToDashboard:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"dashboard",src:"goToDashboard",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:r({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"GoToDashboardCheck",actions:r({_internalState:e=>e.event.output.caseOf({Right:()=>e.context._internalState,Left:a=>({...e.context._internalState,error:a})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetFirmwareMetadata"}]},GetFirmwareMetadata:{invoke:{src:"getFirmwareMetadata",onDone:{target:"GetFirmwareMetadataResultCheck",actions:r({_internalState:e=>{if(f(e.event.output)){const a=n.getDeviceSessionState();return a.sessionStateType!==s.Connected&&n.setDeviceSessionState({...a,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}),{...e.context._internalState,deviceVersion:e.event.output.data.deviceVersion,firmware:e.event.output.data.firmware,firmwareVersion:e.event.output.data.firmwareVersion,firmwareUpdateContext:e.event.output.data.firmwareUpdateContext,customImage:e.event.output.data.customImage}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetFirmwareMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{guard:"useSecureChannel",target:"ListAppsSecureChannel"},{target:"ListApps"}]},ListAppsSecureChannel:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"listAppsSecureChannel",src:"listAppsSecureChannel",input:e=>({firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion}),onSnapshot:{actions:r({intermediateValue:e=>{switch(e.event.snapshot.context?.type){case o.DeviceId:return{...e.context.intermediateValue,deviceId:e.event.snapshot.context.payload.deviceId};case o.PermissionRequested:return{...e.context.intermediateValue,requiredUserInteraction:i.AllowSecureConnection};case o.PermissionGranted:{const a=n.getDeviceSessionState();return a.sessionStateType!==s.Connected&&n.setDeviceSessionState({...a,isSecureConnectionAllowed:!0}),{...e.context.intermediateValue,requiredUserInteraction:i.None}}default:return{...e.context.intermediateValue}}},_internalState:e=>{if(e.event.snapshot.context?.type===o.Error)return{...e.context._internalState,error:e.event.snapshot.context.error.mapDAErrors()};if(e.event.snapshot.context?.type===o.Result){if(L(e.event.snapshot.context.payload))return{...e.context._internalState,installedApps:e.event.snapshot.context.payload.map(a=>({name:a.name,hash:a.hash,hashCode:a.hash_code_data}))};throw new Error(`Invalid result ${JSON.stringify(e.event.snapshot.context.payload)}`)}return{...e.context._internalState}}})},onDone:{target:"ListAppsCheck"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListApps:{exit:r({intermediateValue:{requiredUserInteraction:i.None}}),invoke:{id:"listApps",src:"listApps",input:e=>({unlockTimeout:e.context.input.unlockTimeout}),onSnapshot:{actions:r({intermediateValue:e=>e.event.snapshot.context.intermediateValue})},onDone:{target:"ListAppsCheck",actions:r({_internalState:e=>e.event.output.isLeft()?{...e.context._internalState,error:e.event.output.extract()}:{...e.context._internalState,installedApps:e.event.output.unsafeCoerce().map(a=>({name:a.appName,hash:a.appFullHash,hashCode:a.appCodeHash}))}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetApplicationsMetadata"}]},GetApplicationsMetadata:{invoke:{src:"getApplicationsMetadata",input:e=>({deviceVersion:e.context._internalState.deviceVersion,firmware:e.context._internalState.firmware,firmwareVersion:e.context._internalState.firmwareVersion,installedApps:e.context._internalState.installedApps}),onDone:{target:"GetApplicationsMetadataResultCheck",actions:r({_internalState:e=>{if(f(e.event.output)){const a=n.getDeviceSessionState();return a.sessionStateType!==s.Connected&&n.setDeviceSessionState({...a,installedApps:e.event.output.data.applications,appsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}),{...e.context._internalState,applications:e.event.output.data.applications,applicationsUpdates:e.event.output.data.applicationsUpdates,installedLanguages:e.event.output.data.installedLanguages,catalog:e.event.output.data.catalog}}return{...e.context._internalState,error:e.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetApplicationsMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:e=>{const{context:a}=e,{error:v,firmwareVersion:S,firmwareUpdateContext:w,customImage:h,applications:D,applicationsUpdates:M,installedLanguages:y,catalog:A}=a._internalState;return v?C(v):x({firmwareVersion:S,firmwareUpdateContext:w,customImage:h,applications:D,applicationsUpdates:M,installedLanguages:y,catalog:A})}})}extractDependencies(n){return{getDeviceMetadata:()=>{const t=n.getDeviceSessionState();return t.sessionStateType===s.Connected||t.firmwareVersion?.metadata===void 0||t.firmwareUpdateContext===void 0||t.customImage===void 0||t.installedApps.length===0||t.appsUpdates===void 0||t.installedLanguages===void 0||t.catalog===void 0?Promise.resolve(null):Promise.resolve({firmwareVersion:t.firmwareVersion,firmwareUpdateContext:t.firmwareUpdateContext,customImage:t.customImage,applications:t.installedApps,applicationsUpdates:t.appsUpdates,installedLanguages:t.installedLanguages,catalog:t.catalog})},getFirmwareMetadata:async()=>new k(n).run(),getApplicationsMetadata:async t=>new U(n,{deviceVersion:t.input.deviceVersion,firmware:t.input.firmware,firmwareVersion:t.input.firmwareVersion,installedApps:t.input.installedApps}).run(),listAppsSecureChannel:t=>{const{firmware:l,firmwareVersion:p}=t.input,e=n.getSecureChannelService().listInstalledApps(p.metadata,l);return new R(n,{connection:e}).run()}}}}export{Y as GetDeviceMetadataDeviceAction};
2
2
  //# sourceMappingURL=GetDeviceMetadataDeviceAction.js.map