From e451c8d34067e26614a509a9d32a5ac43b1a6641 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 10:45:46 -0400 Subject: [PATCH 01/14] feat: adds types and bundle for CSharp --- src/kiota/appsettings.json | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/kiota/appsettings.json b/src/kiota/appsettings.json index 2b019cb999..f00b97cd87 100644 --- a/src/kiota/appsettings.json +++ b/src/kiota/appsettings.json @@ -27,31 +27,43 @@ "Dependencies": [ { "Name": "Microsoft.Kiota.Abstractions", - "Version": "1.9.6" + "Version": "1.9.6", + "Type": "Abstractions" }, { "Name": "Microsoft.Kiota.Http.HttpClientLibrary", - "Version": "1.4.3" + "Version": "1.4.3", + "Type": "Http" }, { "Name": "Microsoft.Kiota.Serialization.Form", - "Version": "1.2.4" + "Version": "1.2.4", + "Type": "Serialization" }, { "Name": "Microsoft.Kiota.Serialization.Json", - "Version": "1.3.3" + "Version": "1.3.3", + "Type": "Serialization" }, { "Name": "Microsoft.Kiota.Authentication.Azure", - "Version": "1.1.7" + "Version": "1.1.7", + "Type": "Authentication" }, { "Name": "Microsoft.Kiota.Serialization.Text", - "Version": "1.2.2" + "Version": "1.2.2", + "Type": "Serialization" }, { "Name": "Microsoft.Kiota.Serialization.Multipart", - "Version": "1.1.5" + "Version": "1.1.5", + "Type": "Serialization" + }, + { + "Name": "Microsoft.Kiota.Bundle", + "Version": "1.0.0", + "Type": "Bundle" } ], "DependencyInstallCommand": "dotnet add package {0} --version {1}" @@ -292,4 +304,4 @@ "DependencyInstallCommand": "dotnet add package {0} --version {1}" } } -} +} \ No newline at end of file From 46bfbdb8952cae7c8b544b63e9b149b61d143cef Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 10:46:24 -0400 Subject: [PATCH 02/14] chore: updates dependencies versions --- src/kiota/appsettings.json | 80 +++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/kiota/appsettings.json b/src/kiota/appsettings.json index f00b97cd87..b92e56cea9 100644 --- a/src/kiota/appsettings.json +++ b/src/kiota/appsettings.json @@ -27,42 +27,42 @@ "Dependencies": [ { "Name": "Microsoft.Kiota.Abstractions", - "Version": "1.9.6", + "Version": "1.12.4", "Type": "Abstractions" }, { "Name": "Microsoft.Kiota.Http.HttpClientLibrary", - "Version": "1.4.3", + "Version": "1.12.4", "Type": "Http" }, { "Name": "Microsoft.Kiota.Serialization.Form", - "Version": "1.2.4", + "Version": "1.12.4", "Type": "Serialization" }, { "Name": "Microsoft.Kiota.Serialization.Json", - "Version": "1.3.3", + "Version": "1.12.4", "Type": "Serialization" }, { "Name": "Microsoft.Kiota.Authentication.Azure", - "Version": "1.1.7", + "Version": "1.12.4", "Type": "Authentication" }, { "Name": "Microsoft.Kiota.Serialization.Text", - "Version": "1.2.2", + "Version": "1.12.4", "Type": "Serialization" }, { "Name": "Microsoft.Kiota.Serialization.Multipart", - "Version": "1.1.5", + "Version": "1.12.4", "Type": "Serialization" }, { "Name": "Microsoft.Kiota.Bundle", - "Version": "1.0.0", + "Version": "1.12.4", "Type": "Bundle" } ], @@ -73,31 +73,31 @@ "Dependencies": [ { "Name": "com.microsoft.kiota:microsoft-kiota-abstractions", - "Version": "1.1.14" + "Version": "1.3.0" }, { "Name": "com.microsoft.kiota:microsoft-kiota-http-okHttp", - "Version": "1.1.14" + "Version": "1.3.0" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-form", - "Version": "1.1.14" + "Version": "1.3.0" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-json", - "Version": "1.1.14" + "Version": "1.3.0" }, { "Name": "com.microsoft.kiota:microsoft-kiota-authentication-azure", - "Version": "1.1.14" + "Version": "1.3.0" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-text", - "Version": "1.1.14" + "Version": "1.3.0" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-multipart", - "Version": "1.1.14" + "Version": "1.3.0" }, { "Name": "jakarta.annotation:jakarta.annotation-api", @@ -111,11 +111,11 @@ "Dependencies": [ { "Name": "github.com/microsoft/kiota-abstractions-go", - "Version": "v1.6.0" + "Version": "v1.7.0" }, { "Name": "github.com/microsoft/kiota-http-go", - "Version": "v1.4.1" + "Version": "v1.4.5" }, { "Name": "github.com/microsoft/kiota-serialization-form-go", @@ -123,11 +123,11 @@ }, { "Name": "github.com/microsoft/kiota-serialization-json-go", - "Version": "v1.0.7" + "Version": "v1.0.8" }, { "Name": "github.com/microsoft/kiota-authentication-azure-go", - "Version": "v1.0.2" + "Version": "v1.1.0" }, { "Name": "github.com/microsoft/kiota-serialization-text-go", @@ -145,31 +145,31 @@ "Dependencies": [ { "Name": "@microsoft/kiota-abstractions", - "Version": "1.0.0-preview.56" + "Version": "1.0.0-preview.66" }, { "Name": "@microsoft/kiota-http-fetchlibrary", - "Version": "1.0.0-preview.55" + "Version": "1.0.0-preview.65" }, { "Name": "@microsoft/kiota-serialization-form", - "Version": "1.0.0-preview.45" + "Version": "1.0.0-preview.54" }, { "Name": "@microsoft/kiota-serialization-json", - "Version": "1.0.0-preview.56" + "Version": "1.0.0-preview.66" }, { "Name": "@microsoft/kiota-authentication-azure", - "Version": "1.0.0-preview.51" + "Version": "1.0.0-preview.61" }, { "Name": "@microsoft/kiota-serialization-text", - "Version": "1.0.0-preview.53" + "Version": "1.0.0-preview.63" }, { "Name": "@microsoft/kiota-serialization-multipart", - "Version": "1.0.0-preview.34" + "Version": "1.0.0-preview.44" } ], "DependencyInstallCommand": "npm install {0}@{1} -SE" @@ -183,7 +183,7 @@ }, { "Name": "microsoft/kiota-http-guzzle", - "Version": "1.3.0" + "Version": "1.3.1" }, { "Name": "microsoft/kiota-serialization-json", @@ -191,7 +191,7 @@ }, { "Name": "microsoft/kiota-authentication-phpleague", - "Version": "1.1.0" + "Version": "1.2.0" }, { "Name": "microsoft/kiota-serialization-text", @@ -217,15 +217,15 @@ }, { "Name": "microsoft-kiota-http", - "Version": "1.3.1" + "Version": "1.3.3" }, { "Name": "microsoft-kiota-serialization-json", - "Version": "1.2.0" + "Version": "1.3.2" }, { "Name": "microsoft-kiota-authentication-azure", - "Version": "1.0.0" + "Version": "1.1.0" }, { "Name": "microsoft-kiota-serialization-text", @@ -233,7 +233,7 @@ }, { "Name": "microsoft-kiota-serialization-form", - "Version": "0.1.0" + "Version": "0.1.1" }, { "Name": "microsoft-kiota-serialization-multipart", @@ -274,34 +274,34 @@ "Dependencies": [ { "Name": "Microsoft.Kiota.Abstractions", - "Version": "1.9.6" + "Version": "1.12.4" }, { "Name": "Microsoft.Kiota.Http.HttpClientLibrary", - "Version": "1.4.3" + "Version": "1.12.4" }, { "Name": "Microsoft.Kiota.Serialization.Form", - "Version": "1.2.4" + "Version": "1.12.4" }, { "Name": "Microsoft.Kiota.Serialization.Json", - "Version": "1.3.3" + "Version": "1.12.4" }, { "Name": "Microsoft.Kiota.Authentication.Azure", - "Version": "1.1.7" + "Version": "1.12.4" }, { "Name": "Microsoft.Kiota.Serialization.Text", - "Version": "1.2.2" + "Version": "1.12.4" }, { "Name": "Microsoft.Kiota.Cli.Commons", - "Version": "1.1.1" + "Version": "1.1.2" } ], "DependencyInstallCommand": "dotnet add package {0} --version {1}" } } -} \ No newline at end of file +} From fe75ed2c4d73f0909e9f751fe2cfc004f1fb861f Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 10:54:04 -0400 Subject: [PATCH 03/14] fix: no new line when updating versions Signed-off-by: Vincent Biret --- scripts/update-versions.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update-versions.ps1 b/scripts/update-versions.ps1 index b06f17a1fe..47b55fc0bc 100644 --- a/scripts/update-versions.ps1 +++ b/scripts/update-versions.ps1 @@ -180,5 +180,5 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP } # Write the updated appsettings.json file -$appSettings | ConvertTo-Json -Depth 100 | Set-Content -Path $mainSettings +$appSettings | ConvertTo-Json -Depth 100 | Set-Content -Path $mainSettings -NoNewLine From 9f5b3270550adcfeebb3b11e86aa9cc7e5bbb716 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 12:38:53 -0400 Subject: [PATCH 04/14] feat: adds dependency type parsing Signed-off-by: Vincent Biret --- src/Kiota.Builder/LanguageInformation.cs | 24 +++++++++++++++++++++++ src/kiota/KiotaConfigurationExtensions.cs | 1 + 2 files changed, 25 insertions(+) diff --git a/src/Kiota.Builder/LanguageInformation.cs b/src/Kiota.Builder/LanguageInformation.cs index 30fccbc17c..b27ec003f6 100644 --- a/src/Kiota.Builder/LanguageInformation.cs +++ b/src/Kiota.Builder/LanguageInformation.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Serialization; using Kiota.Builder.Extensions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; @@ -72,6 +73,12 @@ public record LanguageDependency : IOpenApiSerializable { public string Name { get; set; } = string.Empty; public string Version { get; set; } = string.Empty; + [JsonPropertyName("Type")] + public DependencyType? DependencyType + { + get; set; + } + private const string TypePropertyName = "type"; public void SerializeAsV2(IOpenApiWriter writer) => SerializeAsV3(writer); public void SerializeAsV3(IOpenApiWriter writer) { @@ -79,6 +86,10 @@ public void SerializeAsV3(IOpenApiWriter writer) writer.WriteStartObject(); writer.WriteProperty(nameof(Name).ToFirstCharacterLowerCase(), Name); writer.WriteProperty(nameof(Version).ToFirstCharacterLowerCase(), Version); + if (DependencyType is not null) + { + writer.WriteProperty(TypePropertyName, DependencyType.ToString()); + } writer.WriteEndObject(); } public static LanguageDependency Parse(IOpenApiAny source) @@ -93,6 +104,10 @@ public static LanguageDependency Parse(IOpenApiAny source) { extension.Version = versionValue.Value; } + if (rawObject.TryGetValue(TypePropertyName, out var typeValue) && typeValue is OpenApiString typeStringValue && Enum.TryParse(typeStringValue.Value, true, out var parsedTypeValue)) + { + extension.DependencyType = parsedTypeValue; + } return extension; } } @@ -103,3 +118,12 @@ public enum LanguageMaturityLevel Preview, Stable } + +public enum DependencyType +{ + Abstractions, + Serialization, + Authentication, + Http, + Bundle, +} diff --git a/src/kiota/KiotaConfigurationExtensions.cs b/src/kiota/KiotaConfigurationExtensions.cs index 8c212b694c..a4e241847c 100644 --- a/src/kiota/KiotaConfigurationExtensions.cs +++ b/src/kiota/KiotaConfigurationExtensions.cs @@ -45,6 +45,7 @@ public static void BindConfiguration(this KiotaConfiguration configObject, IConf { Version = dependency[nameof(LanguageDependency.Version)] ?? string.Empty, Name = dependency[nameof(LanguageDependency.Name)] ?? string.Empty, + DependencyType = dependency["Type"] is string typeValue && !string.IsNullOrEmpty(typeValue) && Enum.TryParse(typeValue, true, out var dt) ? dt : null, }); } configObject.Languages.Add(section.Key, lngInfo); From 291833d51a6c3901107ec377155c054294a0771e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 12:39:18 -0400 Subject: [PATCH 05/14] feat: displays dependency type and filters dependencies Signed-off-by: Vincent Biret --- src/kiota/Handlers/KiotaInfoCommandHandler.cs | 24 +++++++++++++++---- src/kiota/KiotaHost.cs | 15 ++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/kiota/Handlers/KiotaInfoCommandHandler.cs b/src/kiota/Handlers/KiotaInfoCommandHandler.cs index cd0272bee6..b8f9e005f8 100644 --- a/src/kiota/Handlers/KiotaInfoCommandHandler.cs +++ b/src/kiota/Handlers/KiotaInfoCommandHandler.cs @@ -39,6 +39,10 @@ public required Option JsonOption { get; init; } + public required Option DependencyTypesOption + { + get; init; + } public override async Task InvokeAsync(InvocationContext context) { @@ -48,6 +52,7 @@ public override async Task InvokeAsync(InvocationContext context) string searchTerm = context.ParseResult.GetValueForOption(SearchTermOption) ?? string.Empty; string version = context.ParseResult.GetValueForOption(VersionOption) ?? string.Empty; bool json = context.ParseResult.GetValueForOption(JsonOption); + DependencyType[] dependencyTypes = context.ParseResult.GetValueForOption(DependencyTypesOption) ?? []; GenerationLanguage? language = context.ParseResult.GetValueForOption(GenerationLanguage); CancellationToken cancellationToken = context.BindingContext.GetService(typeof(CancellationToken)) is CancellationToken token ? token : CancellationToken.None; var (loggerFactory, logger) = GetLoggerAndFactory(context); @@ -95,7 +100,7 @@ public override async Task InvokeAsync(InvocationContext context) return 1; #endif } - ShowLanguageInformation(language.Value, instructions, json); + ShowLanguageInformation(language.Value, instructions, json, dependencyTypes); return 0; } } @@ -113,7 +118,7 @@ private void ShowLanguagesTable() var layout = new StackLayoutView { view }; console.Append(layout); } - private void ShowLanguageInformation(GenerationLanguage language, LanguagesInformation informationSource, bool json) + private void ShowLanguageInformation(GenerationLanguage language, LanguagesInformation informationSource, bool json, DependencyType[] dependencyTypes) { if (informationSource.TryGetValue(language.ToString(), out var languageInformation)) { @@ -122,17 +127,28 @@ private void ShowLanguageInformation(GenerationLanguage language, LanguagesInfor DisplayInfo($"The language {language} is currently in {languageInformation.MaturityLevel} maturity level.", "After generating code for this language, you need to install the following packages:"); var orderedDependencies = languageInformation.Dependencies.OrderBy(static x => x.Name).Select(static x => x).ToList(); + var filteredDependencies = (dependencyTypes.ToHashSet(), orderedDependencies.Any(static x => x.DependencyType is DependencyType.Bundle)) switch + { + //if the user requested a specific type, we filter the dependencies + ({ Count: > 0 }, _) => orderedDependencies.Where(x => x.DependencyType is null || dependencyTypes.Contains(x.DependencyType.Value)).ToList(), + //otherwise we display only the bundle dependencies + (_, true) => orderedDependencies.Where(static x => x.DependencyType is DependencyType.Bundle or DependencyType.Authentication).ToList(), + //otherwise we display all dependencies + _ => orderedDependencies + }; var view = new TableView() { - Items = orderedDependencies, + Items = filteredDependencies, }; view.AddColumn(static x => x.Name, "Package Name"); view.AddColumn(static x => x.Version, "Version"); + if (orderedDependencies.Any(static x => x.DependencyType is not null)) + view.AddColumn(static x => x.DependencyType?.ToString(), "Type"); var console = new SystemConsole(); using var terminal = new SystemConsoleTerminal(console); var layout = new StackLayoutView { view }; console.Append(layout); - DisplayInstallHint(languageInformation, orderedDependencies); + DisplayInstallHint(languageInformation, filteredDependencies); } else { diff --git a/src/kiota/KiotaHost.cs b/src/kiota/KiotaHost.cs index 40a6fd37b8..238406b020 100644 --- a/src/kiota/KiotaHost.cs +++ b/src/kiota/KiotaHost.cs @@ -108,6 +108,7 @@ private static Command GetInfoCommand() var clearCacheOption = GetClearCacheOption(defaultGenerationConfiguration.ClearCache); var searchTermOption = GetSearchKeyOption(); var languageOption = new Option("--language", "The target language for the dependencies instructions."); + var dependencyTypesOption = GetDependencyTypesOption(); var jsonOption = new Option("--json", "Generate a plain and machine-parsable json output."); languageOption.AddAlias("-l"); AddEnumValidator(languageOption, "language"); @@ -120,6 +121,7 @@ private static Command GetInfoCommand() searchTermOption, languageOption, jsonOption, + dependencyTypesOption, }; infoCommand.Handler = new KiotaInfoCommandHandler { @@ -131,9 +133,22 @@ private static Command GetInfoCommand() SearchTermOption = searchTermOption, GenerationLanguage = languageOption, JsonOption = jsonOption, + DependencyTypesOption = dependencyTypesOption, }; return infoCommand; } + private static Option GetDependencyTypesOption() + { + var dependencyTypesOption = new Option("--dependency-type", "The type of dependency to display instructions for.") + { + IsRequired = false, + Arity = ArgumentArity.ZeroOrMore, + }; + dependencyTypesOption.AddAlias("--dt"); + dependencyTypesOption.SetDefaultValue(Array.Empty()); + dependencyTypesOption.AddCompletions(Enum.GetNames()); + return dependencyTypesOption; + } private static Option GetSearchKeyOption() { var option = new Option("--search-key", () => string.Empty, "The API search key to display the description for. Use the search command to get the key."); From 32d0eade4740a0982c57f7b91ec8904930624676 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 12:48:20 -0400 Subject: [PATCH 06/14] fix: adds support for additional dependencies Signed-off-by: Vincent Biret --- src/Kiota.Builder/LanguageInformation.cs | 1 + src/kiota/Handlers/KiotaInfoCommandHandler.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Kiota.Builder/LanguageInformation.cs b/src/Kiota.Builder/LanguageInformation.cs index b27ec003f6..c0b36309aa 100644 --- a/src/Kiota.Builder/LanguageInformation.cs +++ b/src/Kiota.Builder/LanguageInformation.cs @@ -126,4 +126,5 @@ public enum DependencyType Authentication, Http, Bundle, + Additional } diff --git a/src/kiota/Handlers/KiotaInfoCommandHandler.cs b/src/kiota/Handlers/KiotaInfoCommandHandler.cs index b8f9e005f8..41dfce3b50 100644 --- a/src/kiota/Handlers/KiotaInfoCommandHandler.cs +++ b/src/kiota/Handlers/KiotaInfoCommandHandler.cs @@ -132,7 +132,7 @@ private void ShowLanguageInformation(GenerationLanguage language, LanguagesInfor //if the user requested a specific type, we filter the dependencies ({ Count: > 0 }, _) => orderedDependencies.Where(x => x.DependencyType is null || dependencyTypes.Contains(x.DependencyType.Value)).ToList(), //otherwise we display only the bundle dependencies - (_, true) => orderedDependencies.Where(static x => x.DependencyType is DependencyType.Bundle or DependencyType.Authentication).ToList(), + (_, true) => orderedDependencies.Where(static x => x.DependencyType is DependencyType.Bundle or DependencyType.Authentication or DependencyType.Additional).ToList(), //otherwise we display all dependencies _ => orderedDependencies }; From 531b8f33c2b5f35fa5856fa8dfe72110a0d3d98f Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 12:52:55 -0400 Subject: [PATCH 07/14] feat: adds bundle information for all languages Signed-off-by: Vincent Biret --- src/kiota/appsettings.json | 161 ++++++++++++++++++++++++++----------- 1 file changed, 114 insertions(+), 47 deletions(-) diff --git a/src/kiota/appsettings.json b/src/kiota/appsettings.json index b92e56cea9..a168c818ca 100644 --- a/src/kiota/appsettings.json +++ b/src/kiota/appsettings.json @@ -73,35 +73,48 @@ "Dependencies": [ { "Name": "com.microsoft.kiota:microsoft-kiota-abstractions", - "Version": "1.3.0" + "Version": "1.3.0", + "Type": "Abstractions" }, { "Name": "com.microsoft.kiota:microsoft-kiota-http-okHttp", - "Version": "1.3.0" + "Version": "1.3.0", + "Type": "Http" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-form", - "Version": "1.3.0" + "Version": "1.3.0", + "Type": "Serialization" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-json", - "Version": "1.3.0" + "Version": "1.3.0", + "Type": "Serialization" }, { "Name": "com.microsoft.kiota:microsoft-kiota-authentication-azure", - "Version": "1.3.0" + "Version": "1.3.0", + "Type": "Authentication" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-text", - "Version": "1.3.0" + "Version": "1.3.0", + "Type": "Serialization" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-multipart", - "Version": "1.3.0" + "Version": "1.3.0", + "Type": "Serialization" + }, + { + "Name": "com.microsoft.kiota:microsoft-kiota-bundle", + "Version": "1.3.0", + "Type": "Bundle" }, { "Name": "jakarta.annotation:jakarta.annotation-api", - "Version": "3.0.0" + "Version": "2.0.0", + "Type": "Additional" } ], "DependencyInstallCommand": "{0}:{1}" @@ -111,31 +124,43 @@ "Dependencies": [ { "Name": "github.com/microsoft/kiota-abstractions-go", - "Version": "v1.7.0" + "Version": "v1.7.0", + "Type": "Abstractions" }, { "Name": "github.com/microsoft/kiota-http-go", - "Version": "v1.4.5" + "Version": "v1.4.5", + "Type": "Http" }, { "Name": "github.com/microsoft/kiota-serialization-form-go", - "Version": "v1.0.0" + "Version": "v1.0.0", + "Type": "Serialization" }, { "Name": "github.com/microsoft/kiota-serialization-json-go", - "Version": "v1.0.8" + "Version": "v1.0.8", + "Type": "Serialization" }, { "Name": "github.com/microsoft/kiota-authentication-azure-go", - "Version": "v1.1.0" + "Version": "v1.1.0", + "Type": "Authentication" }, { "Name": "github.com/microsoft/kiota-serialization-text-go", - "Version": "v1.0.0" + "Version": "v1.0.0", + "Type": "Serialization" }, { "Name": "github.com/microsoft/kiota-serialization-multipart-go", - "Version": "v1.0.0" + "Version": "v1.0.0", + "Type": "Serialization" + }, + { + "Name": "github.com/microsoft/kiota-bundle-go", + "Version": "v1.0.0", + "Type": "Bundle" } ], "DependencyInstallCommand": "go get {0}@{1}" @@ -145,31 +170,43 @@ "Dependencies": [ { "Name": "@microsoft/kiota-abstractions", - "Version": "1.0.0-preview.66" + "Version": "1.0.0-preview.66", + "Type": "Abstractions" }, { "Name": "@microsoft/kiota-http-fetchlibrary", - "Version": "1.0.0-preview.65" + "Version": "1.0.0-preview.65", + "Type": "Http" }, { "Name": "@microsoft/kiota-serialization-form", - "Version": "1.0.0-preview.54" + "Version": "1.0.0-preview.54", + "Type": "Serialization" }, { "Name": "@microsoft/kiota-serialization-json", - "Version": "1.0.0-preview.66" + "Version": "1.0.0-preview.66", + "Type": "Serialization" }, { "Name": "@microsoft/kiota-authentication-azure", - "Version": "1.0.0-preview.61" + "Version": "1.0.0-preview.61", + "Type": "Authentication" }, { "Name": "@microsoft/kiota-serialization-text", - "Version": "1.0.0-preview.63" + "Version": "1.0.0-preview.63", + "Type": "Serialization" }, { "Name": "@microsoft/kiota-serialization-multipart", - "Version": "1.0.0-preview.44" + "Version": "1.0.0-preview.44", + "Type": "Serialization" + }, + { + "Name": "@microsoft/kiota-bundle", + "Version": "1.0.0-preview.9", + "Type": "Bundle" } ], "DependencyInstallCommand": "npm install {0}@{1} -SE" @@ -179,31 +216,38 @@ "Dependencies": [ { "Name": "microsoft/kiota-abstractions", - "Version": "1.4.0" + "Version": "1.4.0", + "Type": "Abstractions" }, { "Name": "microsoft/kiota-http-guzzle", - "Version": "1.3.1" + "Version": "1.3.1", + "Type": "Http" }, { "Name": "microsoft/kiota-serialization-json", - "Version": "1.3.0" + "Version": "1.3.0", + "Type": "Serialization" }, { "Name": "microsoft/kiota-authentication-phpleague", - "Version": "1.2.0" + "Version": "1.2.0", + "Type": "Authentication" }, { "Name": "microsoft/kiota-serialization-text", - "Version": "1.1.0" + "Version": "1.1.0", + "Type": "Serialization" }, { "Name": "microsoft/kiota-serialization-multipart", - "Version": "1.0.0" + "Version": "1.0.0", + "Type": "Serialization" }, { "Name": "microsoft/kiota-serialization-form", - "Version": "1.1.1" + "Version": "1.1.1", + "Type": "Serialization" } ], "DependencyInstallCommand": "composer require {0}:{1}" @@ -213,31 +257,38 @@ "Dependencies": [ { "Name": "microsoft-kiota-abstractions", - "Version": "1.3.3" + "Version": "1.3.3", + "Type": "Abstractions" }, { "Name": "microsoft-kiota-http", - "Version": "1.3.3" + "Version": "1.3.3", + "Type": "Http" }, { "Name": "microsoft-kiota-serialization-json", - "Version": "1.3.2" + "Version": "1.3.2", + "Type": "Serialization" }, { "Name": "microsoft-kiota-authentication-azure", - "Version": "1.1.0" + "Version": "1.1.0", + "Type": "Authentication" }, { "Name": "microsoft-kiota-serialization-text", - "Version": "1.0.0" + "Version": "1.0.0", + "Type": "Serialization" }, { "Name": "microsoft-kiota-serialization-form", - "Version": "0.1.1" + "Version": "0.1.1", + "Type": "Serialization" }, { "Name": "microsoft-kiota-serialization-multipart", - "Version": "0.1.0" + "Version": "0.1.0", + "Type": "Serialization" } ], "DependencyInstallCommand": "pip install {0}=={1}" @@ -247,19 +298,23 @@ "Dependencies": [ { "Name": "microsoft_kiota_abstractions", - "Version": "0.14.4" + "Version": "0.14.4", + "Type": "Abstractions" }, { "Name": "microsoft_kiota_faraday", - "Version": "0.15.0" + "Version": "0.15.0", + "Type": "Http" }, { "Name": "microsoft_kiota_serialization_json", - "Version": "0.9.1" + "Version": "0.9.1", + "Type": "Serialization" }, { "Name": "microsoft_kiota_authentication_oauth", - "Version": "0.8.0" + "Version": "0.8.0", + "Type": "Authentication" } ], "DependencyInstallCommand": "gem install \"{0}\" -v \"{1}\"" @@ -274,31 +329,43 @@ "Dependencies": [ { "Name": "Microsoft.Kiota.Abstractions", - "Version": "1.12.4" + "Version": "1.12.4", + "Type": "Abstractions" }, { "Name": "Microsoft.Kiota.Http.HttpClientLibrary", - "Version": "1.12.4" + "Version": "1.12.4", + "Type": "Http" }, { "Name": "Microsoft.Kiota.Serialization.Form", - "Version": "1.12.4" + "Version": "1.12.4", + "Type": "Serialization" }, { "Name": "Microsoft.Kiota.Serialization.Json", - "Version": "1.12.4" + "Version": "1.12.4", + "Type": "Serialization" }, { "Name": "Microsoft.Kiota.Authentication.Azure", - "Version": "1.12.4" + "Version": "1.12.4", + "Type": "Authentication" }, { "Name": "Microsoft.Kiota.Serialization.Text", - "Version": "1.12.4" + "Version": "1.12.4", + "Type": "Serialization" }, { "Name": "Microsoft.Kiota.Cli.Commons", - "Version": "1.1.2" + "Version": "1.1.2", + "Type": "Additional" + }, + { + "Name": "Microsoft.Kiota.Bundle", + "Version": "1.12.4", + "Type": "Bundle" } ], "DependencyInstallCommand": "dotnet add package {0} --version {1}" From 3c905c3baba84821c31a6cdfb1f336e79471d4d2 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 13:07:35 -0400 Subject: [PATCH 08/14] feat: adds hint for info command Signed-off-by: Vincent Biret --- src/kiota/Handlers/BaseKiotaCommandHandler.cs | 12 ++++++++++++ src/kiota/Handlers/KiotaInfoCommandHandler.cs | 1 + 2 files changed, 13 insertions(+) diff --git a/src/kiota/Handlers/BaseKiotaCommandHandler.cs b/src/kiota/Handlers/BaseKiotaCommandHandler.cs index 049f24cfc2..700bf37711 100644 --- a/src/kiota/Handlers/BaseKiotaCommandHandler.cs +++ b/src/kiota/Handlers/BaseKiotaCommandHandler.cs @@ -325,6 +325,18 @@ protected void DisplayInfoHint(GenerationLanguage language, string path, string DisplayHint("Hint: use the info command to get the list of dependencies you need to add to your project.", $"Example: kiota info {sourceArg} -l {language}"); } + protected void DisplayDependenciesHint(GenerationLanguage generationLanguage) + { + DisplayHint("Legend:", + "- Abstractions dependencies define the core concepts of the language. Required at build time.", + "- Authentication dependencies implement authentication providers. Optional at runtime.", + "- Additional dependencies are required in addition to the abstractions or bundle. Required at build time.", + "- Bundle dependencies include abstractions, serialization and HTTP dependencies for simpler management.", + "- HTTP dependencies implement the request adapter with a specific HTTP client. Required at runtime.", + "- Serialization dependencies implement serialization and deserialization for a given format. Required at runtime."); + DisplayHint("Hint: use the --dependency-type argument to filter the dependencies by type.", + $"Example: kiota info -l {generationLanguage} --dependency-type serialization"); + } protected void DisplayInstallHint(LanguageInformation languageInformation, List languageDependencies) { if (!string.IsNullOrEmpty(languageInformation.DependencyInstallCommand) && languageDependencies.Count > 0) diff --git a/src/kiota/Handlers/KiotaInfoCommandHandler.cs b/src/kiota/Handlers/KiotaInfoCommandHandler.cs index 41dfce3b50..949b4f00b3 100644 --- a/src/kiota/Handlers/KiotaInfoCommandHandler.cs +++ b/src/kiota/Handlers/KiotaInfoCommandHandler.cs @@ -148,6 +148,7 @@ private void ShowLanguageInformation(GenerationLanguage language, LanguagesInfor using var terminal = new SystemConsoleTerminal(console); var layout = new StackLayoutView { view }; console.Append(layout); + DisplayDependenciesHint(language); DisplayInstallHint(languageInformation, filteredDependencies); } else From 72719e94484d4e730a53ce360299076ac95836a2 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 14:40:16 -0400 Subject: [PATCH 09/14] fix: adds query name for special casing of depedencies --- scripts/update-versions.ps1 | 21 ++++++++++++++------- src/kiota/appsettings.json | 8 +++++--- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/scripts/update-versions.ps1 b/scripts/update-versions.ps1 index 47b55fc0bc..9bd90f4313 100644 --- a/scripts/update-versions.ps1 +++ b/scripts/update-versions.ps1 @@ -105,6 +105,13 @@ function Retry-Command { } } +function Get-QueryName { + Param( + $dependency + ) + $dependency.QueryName ?? $dependency.Name +} + # Read the appsettings.json file $mainSettings = Join-Path -Path $PSScriptRoot -ChildPath "..\src\kiota\appsettings.json" $appSettings = Get-Content -Path $mainSettings -Raw | ConvertFrom-Json @@ -114,7 +121,7 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP if ($languageName -eq "CSharp" -or $languageName -eq "CLI") { foreach ($dependency in $language.Dependencies) { Retry-Command -ScriptBlock { - $latestVersion = Get-LatestNugetVersion -packageId $dependency.Name + $latestVersion = Get-LatestNugetVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -123,7 +130,7 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP elseif ($languageName -eq "Go") { foreach ($dependency in $language.Dependencies) { Retry-Command -ScriptBlock { - $latestVersion = Get-LatestGithubRelease -packageId $dependency.Name + $latestVersion = Get-LatestGithubRelease -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -132,7 +139,7 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP elseif ($languageName -eq "TypeScript") { foreach ($dependency in $language.Dependencies) { Retry-Command -ScriptBlock { - $latestVersion = Get-LatestNpmVersion -packageId $dependency.Name + $latestVersion = Get-LatestNpmVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -141,7 +148,7 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP elseif ($languageName -eq "Java") { foreach ($dependency in $language.Dependencies) { Retry-Command -ScriptBlock { - $latestVersion = Get-LatestMavenVersion -packageId $dependency.Name.Replace("jakarta.annotation:jakarta.annotation-api", "jakarta/annotation.jakarta|annotation-api") + $latestVersion = Get-LatestMavenVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -150,7 +157,7 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP elseif ($languageName -eq "PHP") { foreach ($dependency in $language.Dependencies) { Retry-Command -ScriptBlock { - $latestVersion = Get-LatestComposerVersion -packageId $dependency.Name + $latestVersion = Get-LatestComposerVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -159,7 +166,7 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP elseif ($languageName -eq "Python") { foreach ($dependency in $language.Dependencies) { Retry-Command -ScriptBlock { - $latestVersion = Get-LatestPypiVersion -packageId $dependency.Name + $latestVersion = Get-LatestPypiVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -168,7 +175,7 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP elseif ($languageName -eq "Ruby") { foreach ($dependency in $language.Dependencies) { Retry-Command -ScriptBlock { - $latestVersion = Get-LatestRubygemVersion -packageId $dependency.Name + $latestVersion = Get-LatestRubygemVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } diff --git a/src/kiota/appsettings.json b/src/kiota/appsettings.json index a168c818ca..73105ebc4f 100644 --- a/src/kiota/appsettings.json +++ b/src/kiota/appsettings.json @@ -113,8 +113,10 @@ }, { "Name": "jakarta.annotation:jakarta.annotation-api", - "Version": "2.0.0", - "Type": "Additional" + "Version": "3.0.0", + "Type": "Additional", + "MaximumVersion": "2.0.0", + "QueryName": "jakarta/annotation.jakarta|annotation-api" } ], "DependencyInstallCommand": "{0}:{1}" @@ -371,4 +373,4 @@ "DependencyInstallCommand": "dotnet add package {0} --version {1}" } } -} +} \ No newline at end of file From c1de72c66cdcca75dcf580a2c555234f8ea9655d Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 14:43:10 -0400 Subject: [PATCH 10/14] fix: adds a maximum version mechanism for dependencies update script Signed-off-by: Vincent Biret --- scripts/update-versions.ps1 | 28 ++++++++++++++++++++++++++++ src/kiota/appsettings.json | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/scripts/update-versions.ps1 b/scripts/update-versions.ps1 index 9bd90f4313..c32b1707a8 100644 --- a/scripts/update-versions.ps1 +++ b/scripts/update-versions.ps1 @@ -120,6 +120,10 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP $language = $appSettings.Languages.$languageName if ($languageName -eq "CSharp" -or $languageName -eq "CLI") { foreach ($dependency in $language.Dependencies) { + if ($null -ne $dependency.MaximumVersion -and $dependency.MaximumVersion -eq $dependency.Version) { + Write-Information "Skipping $($dependency.Name) as it's already at the maximum version" + continue + } Retry-Command -ScriptBlock { $latestVersion = Get-LatestNugetVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" @@ -129,6 +133,10 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP } elseif ($languageName -eq "Go") { foreach ($dependency in $language.Dependencies) { + if ($null -ne $dependency.MaximumVersion -and $dependency.MaximumVersion -eq $dependency.Version) { + Write-Information "Skipping $($dependency.Name) as it's already at the maximum version" + continue + } Retry-Command -ScriptBlock { $latestVersion = Get-LatestGithubRelease -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" @@ -138,6 +146,10 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP } elseif ($languageName -eq "TypeScript") { foreach ($dependency in $language.Dependencies) { + if ($null -ne $dependency.MaximumVersion -and $dependency.MaximumVersion -eq $dependency.Version) { + Write-Information "Skipping $($dependency.Name) as it's already at the maximum version" + continue + } Retry-Command -ScriptBlock { $latestVersion = Get-LatestNpmVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" @@ -147,6 +159,10 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP } elseif ($languageName -eq "Java") { foreach ($dependency in $language.Dependencies) { + if ($null -ne $dependency.MaximumVersion -and $dependency.MaximumVersion -eq $dependency.Version) { + Write-Information "Skipping $($dependency.Name) as it's already at the maximum version" + continue + } Retry-Command -ScriptBlock { $latestVersion = Get-LatestMavenVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" @@ -156,6 +172,10 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP } elseif ($languageName -eq "PHP") { foreach ($dependency in $language.Dependencies) { + if ($null -ne $dependency.MaximumVersion -and $dependency.MaximumVersion -eq $dependency.Version) { + Write-Information "Skipping $($dependency.Name) as it's already at the maximum version" + continue + } Retry-Command -ScriptBlock { $latestVersion = Get-LatestComposerVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" @@ -165,6 +185,10 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP } elseif ($languageName -eq "Python") { foreach ($dependency in $language.Dependencies) { + if ($null -ne $dependency.MaximumVersion -and $dependency.MaximumVersion -eq $dependency.Version) { + Write-Information "Skipping $($dependency.Name) as it's already at the maximum version" + continue + } Retry-Command -ScriptBlock { $latestVersion = Get-LatestPypiVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" @@ -174,6 +198,10 @@ foreach ($languageName in ($appSettings.Languages | Get-Member -MemberType NoteP } elseif ($languageName -eq "Ruby") { foreach ($dependency in $language.Dependencies) { + if ($null -ne $dependency.MaximumVersion -and $dependency.MaximumVersion -eq $dependency.Version) { + Write-Information "Skipping $($dependency.Name) as it's already at the maximum version" + continue + } Retry-Command -ScriptBlock { $latestVersion = Get-LatestRubygemVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" diff --git a/src/kiota/appsettings.json b/src/kiota/appsettings.json index 73105ebc4f..9f75a92a3f 100644 --- a/src/kiota/appsettings.json +++ b/src/kiota/appsettings.json @@ -113,7 +113,7 @@ }, { "Name": "jakarta.annotation:jakarta.annotation-api", - "Version": "3.0.0", + "Version": "2.0.0", "Type": "Additional", "MaximumVersion": "2.0.0", "QueryName": "jakarta/annotation.jakarta|annotation-api" From 44d36763bb841992ec83491dd3be081c54d80ec7 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 14:49:53 -0400 Subject: [PATCH 11/14] chore: updates kiota version for extension --- vscode/microsoft-kiota/package.json | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 351d772311..d29b0aaec1 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -4,7 +4,7 @@ "publisher": "ms-graph", "description": "Client generator for HTTP REST APIs described by OpenAPI which helps eliminate the need to take a dependency on a different API client for every API that you need to call, as well as limiting the generation to the exact API surface area you're interested in, thanks to a filtering capability.", "version": "1.18.100000001", - "kiotaVersion": "1.17.0", + "kiotaVersion": "1.18.0", "telemetryInstrumentationKey": "4c6357e0-daf9-42b5-bdfb-67878f8957b5", "icon": "images/logo.png", "engines": { @@ -430,7 +430,6 @@ "command": "kiota.migrateFromLockFile", "title": "%kiota.migrateClients.title%" } - ], "languages": [ { @@ -487,23 +486,23 @@ "runtimeDependencies": [ { "platformId": "win-x64", - "sha256": "103A685302D9F3DC6D87B446414DDE7099F36749959AD3B31506AA306E6106B7" + "sha256": "EAB71122320CC135A18FA18E7D5079B65AD0BF2AE2355D29312841289453C443" }, { "platformId": "win-x86", - "sha256": "C79D2108129C3187DE14320478AE9588DF100FF5E37270BEBACFBBDC2EF9AEED" + "sha256": "20F56AD821023B8A396AC0ACC197AB4CD62511D635A4ED9B1969BD8CFF286F16" }, { "platformId": "linux-x64", - "sha256": "C8F518D723B8ADFCE699E1E4E03BB3E03A300D9BA4F10558351634396EF3AA1E" + "sha256": "730C0A5469D83DBC9CDC206C9A3837DBE5892A7A3F0F09AF5A1EAC4CED4B033E" }, { "platformId": "osx-x64", - "sha256": "8EEFB9BF46871E8830BC59F3A52B0C2F20643F0C094611539A00548C70A2223A" + "sha256": "3446A580FFF5F8567E37E9E04D6E944A8B8E83F0B5584A5683527F501E6181FD" }, { "platformId": "osx-arm64", - "sha256": "5FE16C08C749ABEB286520A7A2C9E7F62BE4102765486211433CAE6E8252E44F" + "sha256": "2525D4A8C3ED4972C05E57E4DB2D244E1A708325CE4A5CFB24822D9FD7BB7ED3" } ] } From 6feac7410019b3dbe6a69b26e3d626348e9051da Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 15:19:02 -0400 Subject: [PATCH 12/14] feat: bundles support for extension dependencies panel Signed-off-by: Vincent Biret --- .../microsoft-kiota/l10n/bundle.l10n.fr.json | 5 +++- .../src/dependenciesViewProvider.ts | 20 +++++++++---- vscode/microsoft-kiota/src/kiotaInterop.ts | 28 +++++++++++++++++++ 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json index 7c1e97b38c..b2949c980d 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json @@ -77,5 +77,8 @@ "Migration completed, but no changes were detected.": "Migration terminée, mais aucun changement n'a été détecté.", "Migration failed": "Echec de la migration", "API clients migrated successfully!": "Clients d'API migrés avec succès!", - "Could not determine the workspace folder.": "Impossible de déterminer le dossier de l'espace de travail." + "Could not determine the workspace folder.": "Impossible de déterminer le dossier de l'espace de travail.", + "Version": "Version", + "Name": "Nom", + "Type": "Type" } diff --git a/vscode/microsoft-kiota/src/dependenciesViewProvider.ts b/vscode/microsoft-kiota/src/dependenciesViewProvider.ts index 9a4b7886ae..a2bea84a55 100644 --- a/vscode/microsoft-kiota/src/dependenciesViewProvider.ts +++ b/vscode/microsoft-kiota/src/dependenciesViewProvider.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; import { KiotaGenerationLanguage } from './enums'; -import { generationLanguageToString, LanguageInformation, LanguagesInformation } from './kiotaInterop'; +import { DependencyType, dependencyTypeToString, generationLanguageToString, LanguageInformation, LanguagesInformation } from './kiotaInterop'; export class DependenciesViewProvider implements vscode.WebviewViewProvider { private _view?: vscode.WebviewView; @@ -39,8 +39,17 @@ export class DependenciesViewProvider implements vscode.WebviewViewProvider { const noLanguageSelected = vscode.l10n.t('No language selected, select a language first'); const title = vscode.l10n.t('Kiota Dependencies Information'); const dependencies = vscode.l10n.t('Dependencies'); + const name = vscode.l10n.t('Name'); + const version = vscode.l10n.t('Version'); + const type = vscode.l10n.t('Type'); + let dependenciesList = this._languageInformation ? + this._languageInformation.Dependencies : + []; + if (dependenciesList.filter(dep => dep.DependencyType === DependencyType.bundle).length > 0) { + dependenciesList = dependenciesList.filter(dep => dep.DependencyType === DependencyType.bundle || dep.DependencyType === DependencyType.additional || dep.DependencyType === DependencyType.authentication); + } const installationBlock = this._languageInformation?.DependencyInstallCommand ? `

${installationCommands}

-
${this._languageInformation.Dependencies.map(dep => this._languageInformation!.DependencyInstallCommand.replace(/\{0\}/g, dep.Name).replace(/\{1\}/g, dep.Version)).join('\n')}
` +
${dependenciesList.map(dep => this._languageInformation!.DependencyInstallCommand.replace(/\{0\}/g, dep.Name).replace(/\{1\}/g, dep.Version)).join('\n')}
` : ''; return ` @@ -55,9 +64,10 @@ export class DependenciesViewProvider implements vscode.WebviewViewProvider {

${this._language !== undefined ? generationLanguageToString(this._language) : noLanguageSelected}

${dependencies}

-
    - ${this._languageInformation ? this._languageInformation?.Dependencies.map(dep => `
  • ${dep.Name} (${dep.Version})
  • `).join('') : ''} -
+ + + ${dependenciesList.map(dep => ``).join('')} +
${name}${version}${type}
${dep.Name}${dep.Version}${dependencyTypeToString(dep.DependencyType)}
${installationBlock} `; diff --git a/vscode/microsoft-kiota/src/kiotaInterop.ts b/vscode/microsoft-kiota/src/kiotaInterop.ts index 8e2636f675..cc22cc9cc6 100644 --- a/vscode/microsoft-kiota/src/kiotaInterop.ts +++ b/vscode/microsoft-kiota/src/kiotaInterop.ts @@ -175,6 +175,8 @@ export interface LanguageDependency { Name: string; // eslint-disable-next-line @typescript-eslint/naming-convention Version: string; + // eslint-disable-next-line @typescript-eslint/naming-convention + DependencyType: DependencyType; } export enum MaturityLevel { experimental = 0, @@ -193,6 +195,32 @@ export function maturityLevelToString(level: MaturityLevel): string { throw new Error("unknown level"); } } +export enum DependencyType { + abstractions, + serialization, + authentication, + http, + bundle, + additional, +} +export function dependencyTypeToString(type: DependencyType): string { + switch (type) { + case DependencyType.abstractions: + return "abstractions"; + case DependencyType.serialization: + return "serialization"; + case DependencyType.authentication: + return "authentication"; + case DependencyType.http: + return "http"; + case DependencyType.bundle: + return "bundle"; + case DependencyType.additional: + return "additional"; + default: + throw new Error("unknown type"); + } +} export interface ConfigurationFile { version: string; clients: Record; From 4c9f51b0fb99fbbe867929d6f787fc6c6ca9a663 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 15:21:16 -0400 Subject: [PATCH 13/14] docs: adds changelog entry for dependency view Signed-off-by: Vincent Biret --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3bb6cb577..d31362529f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed a stack overflow in the core generator caused by circular comparisons. [#5369](https://github.com/microsoft/kiota/issues/5369) - Fixed a bug where collection/array of primitive types members for union/intersection types would be ignored. [#5283](https://github.com/microsoft/kiota/issues/5283) +- Updated dependencies command and view to reflect the availability of bundles. [#5317](https://github.com/microsoft/kiota/issues/5317) - Fixed a when generating a plugin when only an operation is selected in the root node in the extension. [#5300](https://github.com/microsoft/kiota/issues/5300) - Fixed a bug where function descriptions in plugin manifest defaults to path summary instead of description. [#5301](https://github.com/microsoft/kiota/issues/5301) - Fixed a bug where TypeScript would not properly build URIs with uppercase first characters query parameter names.[#5382](https://github.com/microsoft/kiota/issues/5382) From bea4e5986541bb80e29cf6f128290f53373924b5 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Wed, 11 Sep 2024 15:30:30 -0400 Subject: [PATCH 14/14] chore: updates parsing and serialization unit tests Signed-off-by: Vincent Biret --- .../OpenApiExtensions/OpenApiKiotaExtensionTests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Kiota.Builder.Tests/OpenApiExtensions/OpenApiKiotaExtensionTests.cs b/tests/Kiota.Builder.Tests/OpenApiExtensions/OpenApiKiotaExtensionTests.cs index 27096a9862..beb4c3fe4f 100644 --- a/tests/Kiota.Builder.Tests/OpenApiExtensions/OpenApiKiotaExtensionTests.cs +++ b/tests/Kiota.Builder.Tests/OpenApiExtensions/OpenApiKiotaExtensionTests.cs @@ -22,6 +22,7 @@ public void Serializes() new LanguageDependency { Name = "Microsoft.Graph.Core", Version = "1.0.0", + DependencyType = DependencyType.Bundle, } }, DependencyInstallCommand = "dotnet add package", @@ -42,7 +43,7 @@ public void Serializes() value.Write(writer, OpenApiSpecVersion.OpenApi3_0); var result = sWriter.ToString(); - Assert.Equal("{\"languagesInformation\":{\"CSharp\":{\"maturityLevel\":\"Preview\",\"dependencyInstallCommand\":\"dotnet add package\",\"dependencies\":[{\"name\":\"Microsoft.Graph.Core\",\"version\":\"1.0.0\"}],\"clientClassName\":\"GraphServiceClient\",\"clientNamespaceName\":\"Microsoft.Graph\",\"structuredMimeTypes\":[\"application/json\",\"application/xml\"]}}}", result); + Assert.Equal("{\"languagesInformation\":{\"CSharp\":{\"maturityLevel\":\"Preview\",\"dependencyInstallCommand\":\"dotnet add package\",\"dependencies\":[{\"name\":\"Microsoft.Graph.Core\",\"version\":\"1.0.0\",\"type\":\"Bundle\"}],\"clientClassName\":\"GraphServiceClient\",\"clientNamespaceName\":\"Microsoft.Graph\",\"structuredMimeTypes\":[\"application/json\",\"application/xml\"]}}}", result); } [Fact] public void Parses() @@ -55,6 +56,7 @@ public void Parses() new OpenApiObject { {"name", new OpenApiString("Microsoft.Graph.Core")}, {"version", new OpenApiString("1.0.0") }, + {"type", new OpenApiString("bundle")} } }}, {"dependencyInstallCommand", new OpenApiString("dotnet add package") }, @@ -82,5 +84,6 @@ public void Parses() Assert.Contains("application/json", CSEntry.StructuredMimeTypes); Assert.Contains("application/xml", CSEntry.StructuredMimeTypes); Assert.Equal("1.0.0", CSEntry.Dependencies[0].Version); + Assert.Equal(DependencyType.Bundle, CSEntry.Dependencies[0].DependencyType); } }