Skip to content

Commit 1122b32

Browse files
authored
Add support for 1.10 manifest in rest source parsing and winget utils… (#5201)
CP #5197
1 parent c873cda commit 1122b32

22 files changed

+939
-47
lines changed

src/AppInstallerCLITests/AppInstallerCLITests.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@
319319
<ClCompile Include="RestClient.cpp" />
320320
<ClCompile Include="RestInterface_1_0.cpp" />
321321
<ClCompile Include="RestInterface_1_1.cpp" />
322+
<ClCompile Include="RestInterface_1_10.cpp" />
322323
<ClCompile Include="RestInterface_1_4.cpp" />
323324
<ClCompile Include="RestInterface_1_5.cpp" />
324325
<ClCompile Include="RestInterface_1_6.cpp" />

src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@
374374
<ClCompile Include="Fonts.cpp">
375375
<Filter>Source Files\Common</Filter>
376376
</ClCompile>
377+
<ClCompile Include="RestInterface_1_10.cpp">
378+
<Filter>Source Files\Repository</Filter>
379+
</ClCompile>
377380
</ItemGroup>
378381
<ItemGroup>
379382
<None Include="PropertySheet.props" />

src/AppInstallerCLITests/RestClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ TEST_CASE("GetSupportedInterface", "[RestSource]")
6161
REQUIRE(RestClient::GetSupportedInterface(TestRestUri, {}, info, {}, version, {})->GetVersion() == version);
6262

6363
// Update this test to next version so that we don't forget to add to supported versions before rest e2e tests are available.
64-
Version invalid{ "1.10.0" };
64+
Version invalid{ "1.11.0" };
6565
REQUIRE_THROWS_HR(RestClient::GetSupportedInterface(TestRestUri, {}, info, {}, invalid, {}), APPINSTALLER_CLI_ERROR_RESTSOURCE_INVALID_VERSION);
6666

6767
Authentication::AuthenticationArguments authArgs;

src/AppInstallerCLITests/RestInterface_1_10.cpp

+411
Large diffs are not rendered by default.

src/AppInstallerRepositoryCore/AppInstallerRepositoryCore.vcxproj

+4
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@
439439
<ClInclude Include="Rest\Schema\1_0\Json\ManifestDeserializer.h" />
440440
<ClInclude Include="Rest\Schema\1_0\Json\SearchRequestSerializer.h" />
441441
<ClInclude Include="Rest\Schema\1_0\Json\SearchResponseDeserializer.h" />
442+
<ClInclude Include="Rest\Schema\1_10\Interface.h" />
443+
<ClInclude Include="Rest\Schema\1_10\Json\ManifestDeserializer.h" />
442444
<ClInclude Include="Rest\Schema\1_1\Interface.h" />
443445
<ClInclude Include="Rest\Schema\1_1\Json\ManifestDeserializer.h" />
444446
<ClInclude Include="Rest\Schema\1_1\Json\SearchRequestSerializer.h" />
@@ -534,6 +536,8 @@
534536
<ClCompile Include="Rest\Schema\1_0\Json\ManifestDeserializer_1_0.cpp" />
535537
<ClCompile Include="Rest\Schema\1_0\Json\SearchRequestSerializer_1_0.cpp" />
536538
<ClCompile Include="Rest\Schema\1_0\Json\SearchResponseDeserializer_1_0.cpp" />
539+
<ClCompile Include="Rest\Schema\1_10\Json\ManifestDeserializer_1_10.cpp" />
540+
<ClCompile Include="Rest\Schema\1_10\RestInterface_1_10.cpp" />
537541
<ClCompile Include="Rest\Schema\1_1\Json\ManifestDeserializer_1_1.cpp" />
538542
<ClCompile Include="Rest\Schema\1_1\Json\SearchRequestSerializer_1_1.cpp" />
539543
<ClCompile Include="Rest\Schema\1_1\RestInterface_1_1.cpp" />

src/AppInstallerRepositoryCore/AppInstallerRepositoryCore.vcxproj.filters

+18
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@
109109
<Filter Include="Rest\Schema\1_9\Json">
110110
<UniqueIdentifier>{7464e3ff-7a60-4bb6-8806-70562382043b}</UniqueIdentifier>
111111
</Filter>
112+
<Filter Include="Rest\Schema\1_10">
113+
<UniqueIdentifier>{da801426-6d3b-40ca-b204-152e7e18067b}</UniqueIdentifier>
114+
</Filter>
115+
<Filter Include="Rest\Schema\1_10\Json">
116+
<UniqueIdentifier>{1a1efb9f-7332-4094-bb98-a4c51ea68b24}</UniqueIdentifier>
117+
</Filter>
112118
</ItemGroup>
113119
<ItemGroup>
114120
<ClInclude Include="pch.h">
@@ -474,6 +480,12 @@
474480
<ClInclude Include="Rest\Schema\1_9\Interface.h">
475481
<Filter>Rest\Schema\1_9</Filter>
476482
</ClInclude>
483+
<ClInclude Include="Rest\Schema\1_10\Interface.h">
484+
<Filter>Rest\Schema\1_10</Filter>
485+
</ClInclude>
486+
<ClInclude Include="Rest\Schema\1_10\Json\ManifestDeserializer.h">
487+
<Filter>Rest\Schema\1_10\Json</Filter>
488+
</ClInclude>
477489
</ItemGroup>
478490
<ItemGroup>
479491
<ClCompile Include="pch.cpp">
@@ -740,6 +752,12 @@
740752
<ClCompile Include="Rest\Schema\1_9\RestInterface_1_9.cpp">
741753
<Filter>Rest\Schema\1_9</Filter>
742754
</ClCompile>
755+
<ClCompile Include="Rest\Schema\1_10\RestInterface_1_10.cpp">
756+
<Filter>Rest\Schema\1_10</Filter>
757+
</ClCompile>
758+
<ClCompile Include="Rest\Schema\1_10\Json\ManifestDeserializer_1_10.cpp">
759+
<Filter>Rest\Schema\1_10\Json</Filter>
760+
</ClCompile>
743761
</ItemGroup>
744762
<ItemGroup>
745763
<None Include="PropertySheet.props" />

src/AppInstallerRepositoryCore/ManifestJSONParser.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "Rest/Schema/1_6/Json/ManifestDeserializer.h"
1010
#include "Rest/Schema/1_7/Json/ManifestDeserializer.h"
1111
#include "Rest/Schema/1_9/Json/ManifestDeserializer.h"
12+
#include "Rest/Schema/1_10/Json/ManifestDeserializer.h"
1213

1314
namespace AppInstaller::Repository::JSON
1415
{
@@ -51,10 +52,14 @@ namespace AppInstaller::Repository::JSON
5152
{
5253
m_pImpl->m_deserializer = std::make_unique<Rest::Schema::V1_7::Json::ManifestDeserializer>();
5354
}
54-
else
55+
else if (parts.size() > 1 && parts[1].Integer < 10)
5556
{
5657
m_pImpl->m_deserializer = std::make_unique<Rest::Schema::V1_9::Json::ManifestDeserializer>();
5758
}
59+
else
60+
{
61+
m_pImpl->m_deserializer = std::make_unique<Rest::Schema::V1_10::Json::ManifestDeserializer>();
62+
}
5863
}
5964
else
6065
{

src/AppInstallerRepositoryCore/Rest/RestClient.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "Rest/Schema/1_6/Interface.h"
1010
#include "Rest/Schema/1_7/Interface.h"
1111
#include "Rest/Schema/1_9/Interface.h"
12+
#include "Rest/Schema/1_10/Interface.h"
1213
#include "Rest/Schema/InformationResponseDeserializer.h"
1314
#include "Rest/Schema/CommonRestConstants.h"
1415
#include <winget/HttpClientHelper.h>
@@ -23,7 +24,7 @@ using namespace AppInstaller::Http;
2324
namespace AppInstaller::Repository::Rest
2425
{
2526
// Supported versions
26-
std::set<Version> WingetSupportedContracts = { Version_1_0_0, Version_1_1_0, Version_1_4_0, Version_1_5_0, Version_1_6_0, Version_1_7_0, Version_1_9_0 };
27+
std::set<Version> WingetSupportedContracts = { Version_1_0_0, Version_1_1_0, Version_1_4_0, Version_1_5_0, Version_1_6_0, Version_1_7_0, Version_1_9_0, Version_1_10_0 };
2728

2829
constexpr std::string_view WindowsPackageManagerHeader = "Windows-Package-Manager"sv;
2930
constexpr size_t WindowsPackageManagerHeaderMaxLength = 1024;
@@ -181,6 +182,10 @@ namespace AppInstaller::Repository::Rest
181182
{
182183
return std::make_unique<Schema::V1_9::Interface>(api, helper, information, additionalHeaders, authArgs);
183184
}
185+
else if (version == Version_1_10_0)
186+
{
187+
return std::make_unique<Schema::V1_10::Interface>(api, helper, information, additionalHeaders, authArgs);
188+
}
184189

185190
THROW_HR(APPINSTALLER_CLI_ERROR_RESTSOURCE_INVALID_VERSION);
186191
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
#pragma once
4+
#include "Rest/Schema/1_9/Interface.h"
5+
6+
namespace AppInstaller::Repository::Rest::Schema::V1_10
7+
{
8+
// Interface to this schema version exposed through IRestClient.
9+
struct Interface : public V1_9::Interface
10+
{
11+
Interface(const std::string& restApi, const Http::HttpClientHelper& helper, IRestClient::Information information, const Http::HttpClientHelper::HttpRequestHeaders& additionalHeaders = {}, Authentication::AuthenticationArguments authArgs = {});
12+
13+
Interface(const Interface&) = delete;
14+
Interface& operator=(const Interface&) = delete;
15+
16+
Interface(Interface&&) = default;
17+
Interface& operator=(Interface&&) = default;
18+
19+
Utility::Version GetVersion() const override;
20+
};
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
#pragma once
4+
#include "Rest/Schema/1_9/Json/ManifestDeserializer.h"
5+
6+
namespace AppInstaller::Repository::Rest::Schema::V1_10::Json
7+
{
8+
// Manifest Deserializer.
9+
struct ManifestDeserializer : public V1_9::Json::ManifestDeserializer
10+
{
11+
protected:
12+
13+
std::optional<Manifest::ManifestInstaller> DeserializeInstaller(const web::json::value& installerJsonObject) const override;
14+
15+
Manifest::ManifestVer GetManifestVersion() const override;
16+
};
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
#include "pch.h"
4+
#include "ManifestDeserializer.h"
5+
#include "Rest/Schema/AuthenticationInfoParser.h"
6+
#include <winget/JsonUtil.h>
7+
8+
using namespace AppInstaller::Manifest;
9+
10+
namespace AppInstaller::Repository::Rest::Schema::V1_10::Json
11+
{
12+
std::optional<Manifest::ManifestInstaller> ManifestDeserializer::DeserializeInstaller(const web::json::value& installerJsonObject) const
13+
{
14+
auto result = V1_9::Json::ManifestDeserializer::DeserializeInstaller(installerJsonObject);
15+
16+
if (result)
17+
{
18+
auto& installer = result.value();
19+
20+
installer.AuthInfo = ParseAuthenticationInfo(installerJsonObject, ParseAuthenticationInfoType::Installer, GetManifestVersion());
21+
}
22+
23+
return result;
24+
}
25+
26+
Manifest::ManifestVer ManifestDeserializer::GetManifestVersion() const
27+
{
28+
return Manifest::s_ManifestVersionV1_10;
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
#include "pch.h"
4+
#include "Rest/Schema/1_10/Interface.h"
5+
#include "Rest/Schema/CommonRestConstants.h"
6+
#include "Rest/Schema/IRestClient.h"
7+
#include <winget/HttpClientHelper.h>
8+
#include <winget/JsonUtil.h>
9+
10+
namespace AppInstaller::Repository::Rest::Schema::V1_10
11+
{
12+
Interface::Interface(
13+
const std::string& restApi,
14+
const Http::HttpClientHelper& httpClientHelper,
15+
IRestClient::Information information,
16+
const Http::HttpClientHelper::HttpRequestHeaders& additionalHeaders,
17+
Authentication::AuthenticationArguments authArgs) : V1_9::Interface(restApi, httpClientHelper, std::move(information), additionalHeaders, std::move(authArgs))
18+
{
19+
m_requiredRestApiHeaders[JSON::GetUtilityString(ContractVersion)] = JSON::GetUtilityString(Version_1_10_0.ToString());
20+
}
21+
22+
Utility::Version Interface::GetVersion() const
23+
{
24+
return Version_1_10_0;
25+
}
26+
}

src/AppInstallerRepositoryCore/Rest/Schema/CommonRestConstants.h

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace AppInstaller::Repository::Rest::Schema
1313
const Utility::Version Version_1_6_0{ "1.6.0" };
1414
const Utility::Version Version_1_7_0{ "1.7.0" };
1515
const Utility::Version Version_1_9_0{ "1.9.0" };
16+
const Utility::Version Version_1_10_0{ "1.10.0" };
1617

1718
// General API response constants
1819
constexpr std::string_view Data = "Data"sv;

0 commit comments

Comments
 (0)