winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

ExecutionContextData.h (8208B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #pragma once
      4 #include <AppInstallerDownloader.h>
      5 #include <winget/RepositorySource.h>
      6 #include <winget/Manifest.h>
      7 #include <winget/ARPCorrelation.h>
      8 #include <winget/Authentication.h>
      9 #include <winget/Pin.h>
     10 #include <winget/PinningData.h>
     11 #include "CompletionData.h"
     12 #include "PackageCollection.h"
     13 #include "PortableInstaller.h"
     14 #include "Workflows/WorkflowBase.h"
     15 #include "ConfigurationContext.h"
     16 
     17 #include <filesystem>
     18 #include <map>
     19 #include <string>
     20 #include <utility>
     21 #include <variant>
     22 #include <vector>
     23 
     24 namespace AppInstaller::CLI::Execution
     25 {
     26     // Names a piece of data stored in the context by a workflow step.
     27     // Must start at 0 to enable direct access to variant in Context.
     28     // Max must be last and unused.
     29     enum class Data : size_t
     30     {
     31         Source,
     32         SearchRequest, // Only set for multiple installs
     33         SearchResult,
     34         SourceList,
     35         Package,
     36         Manifest,
     37         PackageVersion,
     38         Installer,
     39         DownloadHashInfo,
     40         InstallerPath,
     41         LogPath,
     42         InstallerArgs,
     43         OperationReturnCode,
     44         CompletionData,
     45         InstalledPackageVersion,
     46         UninstallString,
     47         PackageFamilyNames,
     48         ProductCodes,
     49         // On export: A collection of packages to be exported to a file
     50         // On import: A collection of packages read from a file
     51         PackageCollection,
     52         // When installing multiple packages at once (upgrade all, import, install with multiple args, dependencies):
     53         // A collection of sub-contexts, each of which handles the installation of a single package.
     54         PackageSubContexts,
     55         // On import: Sources for the imported packages
     56         Sources,
     57         ARPCorrelationData,
     58         CorrelatedAppsAndFeaturesEntries,
     59         Dependencies,
     60         DependencySource,
     61         AllowedArchitectures,
     62         AllowUnknownScope,
     63         PortableInstaller,
     64         PinningData,
     65         Pins,
     66         ConfigurationContext,
     67         DownloadDirectory,
     68         ModifyPath,
     69         RepairString,
     70         MsixDigests,
     71         InstallerDownloadAuthenticators,
     72         Max
     73     };
     74 
     75     struct Context;
     76 
     77     namespace details
     78     {
     79         template <Data D>
     80         struct DataMapping
     81         {
     82             // value_t type specifies the type of this data
     83         };
     84 
     85         template <>
     86         struct DataMapping<Data::Source>
     87         {
     88             using value_t = Repository::Source;
     89         };
     90 
     91         template <>
     92         struct DataMapping<Data::SearchRequest>
     93         {
     94             using value_t = Repository::SearchRequest;
     95         };
     96 
     97         template <>
     98         struct DataMapping<Data::SearchResult>
     99         {
    100             using value_t = Repository::SearchResult;
    101         };
    102 
    103         template <>
    104         struct DataMapping<Data::SourceList>
    105         {
    106             using value_t = std::vector<Repository::SourceDetails>;
    107         };
    108 
    109         template <>
    110         struct DataMapping<Data::Package>
    111         {
    112             using value_t = std::shared_ptr<Repository::ICompositePackage>;
    113         };
    114 
    115         template <>
    116         struct DataMapping<Data::Manifest>
    117         {
    118             using value_t = Manifest::Manifest;
    119         };
    120 
    121         template <>
    122         struct DataMapping<Data::PackageVersion>
    123         {
    124             using value_t = std::shared_ptr<Repository::IPackageVersion>;
    125         };
    126 
    127         template <>
    128         struct DataMapping<Data::Installer>
    129         {
    130             using value_t = std::optional<Manifest::ManifestInstaller>;
    131         };
    132 
    133         template <>
    134         struct DataMapping<Data::DownloadHashInfo>
    135         {
    136             using value_t = std::pair<std::vector<uint8_t>, Utility::DownloadResult>;
    137         };
    138 
    139         template <>
    140         struct DataMapping<Data::InstallerPath>
    141         {
    142             using value_t = std::filesystem::path;
    143         };
    144 
    145         template <>
    146         struct DataMapping<Data::LogPath>
    147         {
    148             using value_t = std::filesystem::path;
    149         };
    150 
    151         template <>
    152         struct DataMapping<Data::InstallerArgs>
    153         {
    154             using value_t = std::string;
    155         };
    156 
    157         template <>
    158         struct DataMapping<Data::OperationReturnCode>
    159         {
    160             using value_t = DWORD;
    161         };
    162 
    163         template <>
    164         struct DataMapping<Data::CompletionData>
    165         {
    166             using value_t = CLI::CompletionData;
    167         };
    168 
    169         template <>
    170         struct DataMapping<Data::InstalledPackageVersion>
    171         {
    172             using value_t = std::shared_ptr<Repository::IPackageVersion>;
    173         };
    174 
    175         template <>
    176         struct DataMapping<Data::UninstallString>
    177         {
    178             using value_t = std::string;
    179         };
    180 
    181         template <>
    182         struct DataMapping<Data::PackageFamilyNames>
    183         {
    184             using value_t = std::vector<Utility::LocIndString>;
    185         };
    186 
    187         template <>
    188         struct DataMapping<Data::ProductCodes>
    189         {
    190             using value_t = std::vector<Utility::LocIndString>;
    191         };
    192 
    193         template <>
    194         struct DataMapping<Data::PackageCollection>
    195         {
    196             using value_t = CLI::PackageCollection;
    197         };
    198 
    199         template <>
    200         struct DataMapping<Data::PackageSubContexts>
    201         {
    202             using value_t = std::vector<std::unique_ptr<Context>>;
    203         };
    204 
    205         template <>
    206         struct DataMapping<Data::Sources>
    207         {
    208             using value_t = std::vector<Repository::Source>;
    209         };
    210 
    211         template <>
    212         struct DataMapping<Data::ARPCorrelationData>
    213         {
    214             using value_t = Repository::Correlation::ARPCorrelationData;
    215         };
    216 
    217         template <>
    218         struct DataMapping<Data::CorrelatedAppsAndFeaturesEntries>
    219         {
    220             using value_t = std::vector<Manifest::AppsAndFeaturesEntry>;
    221         };
    222 
    223         template <>
    224         struct DataMapping<Data::Dependencies>
    225         {
    226             using value_t = Manifest::DependencyList;
    227         };
    228 
    229         template <>
    230         struct DataMapping<Data::DependencySource>
    231         {
    232             using value_t = Repository::Source;
    233         };
    234         
    235         template <>
    236         struct DataMapping<Data::AllowedArchitectures>
    237         {
    238             using value_t = std::vector<Utility::Architecture>;
    239         };
    240 
    241         template <>
    242         struct DataMapping<Data::AllowUnknownScope>
    243         {
    244             using value_t = bool;
    245         };
    246 
    247         template <>
    248         struct DataMapping<Data::PortableInstaller>
    249         {
    250             using value_t = CLI::Portable::PortableInstaller;
    251         };
    252 
    253         template <>
    254         struct DataMapping<Data::PinningData>
    255         {
    256             using value_t = Pinning::PinningData;
    257         };
    258 
    259         template <>
    260         struct DataMapping<Data::Pins>
    261         {
    262             using value_t = std::vector<Pinning::Pin>;
    263         };
    264 
    265         template <>
    266         struct DataMapping<Data::ConfigurationContext>
    267         {
    268             using value_t = ConfigurationContext;
    269         };
    270 
    271         template <>
    272         struct DataMapping<Data::DownloadDirectory>
    273         {
    274             using value_t = std::filesystem::path;
    275         };
    276 
    277         template<>
    278         struct DataMapping<Data::ModifyPath>
    279         {
    280             using value_t = std::string;
    281         };
    282 
    283         template<>
    284         struct DataMapping<Data::RepairString>
    285         {
    286             using value_t = std::string;
    287         };
    288 
    289         template<>
    290         struct DataMapping<Data::MsixDigests>
    291         {
    292             // The pair is { URL, Digest }
    293             using value_t = std::vector<std::pair<std::string, std::wstring>>;
    294         };
    295 
    296         template<>
    297         struct DataMapping<Data::InstallerDownloadAuthenticators>
    298         {
    299             // The authenticator map shared with sub contexts
    300             using value_t = std::shared_ptr<std::map<Authentication::AuthenticationInfo, Authentication::Authenticator>>;
    301         };
    302     }
    303 }