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) diff --git a/scripts/update-versions.ps1 b/scripts/update-versions.ps1 index b06f17a1fe..c32b1707a8 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 @@ -113,8 +120,12 @@ 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 $dependency.Name + $latestVersion = Get-LatestNugetVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -122,8 +133,12 @@ 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 $dependency.Name + $latestVersion = Get-LatestGithubRelease -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -131,8 +146,12 @@ 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 $dependency.Name + $latestVersion = Get-LatestNpmVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -140,8 +159,12 @@ 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 $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 } @@ -149,8 +172,12 @@ 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 $dependency.Name + $latestVersion = Get-LatestComposerVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -158,8 +185,12 @@ 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 $dependency.Name + $latestVersion = Get-LatestPypiVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -167,8 +198,12 @@ 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 $dependency.Name + $latestVersion = Get-LatestRubygemVersion -packageId (Get-QueryName -dependency $dependency) Write-Information "Updating $($dependency.Name) from $($dependency.Version) to $latestVersion" $dependency.Version = $latestVersion } @@ -180,5 +215,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 diff --git a/src/Kiota.Builder/LanguageInformation.cs b/src/Kiota.Builder/LanguageInformation.cs index 30fccbc17c..c0b36309aa 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,13 @@ public enum LanguageMaturityLevel Preview, Stable } + +public enum DependencyType +{ + Abstractions, + Serialization, + Authentication, + Http, + Bundle, + Additional +} 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 cd0272bee6..949b4f00b3 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,29 @@ 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 or DependencyType.Additional).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); + DisplayDependenciesHint(language); + DisplayInstallHint(languageInformation, filteredDependencies); } else { 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); 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."); diff --git a/src/kiota/appsettings.json b/src/kiota/appsettings.json index 2b019cb999..9f75a92a3f 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.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.12.4", + "Type": "Bundle" } ], "DependencyInstallCommand": "dotnet add package {0} --version {1}" @@ -61,35 +73,50 @@ "Dependencies": [ { "Name": "com.microsoft.kiota:microsoft-kiota-abstractions", - "Version": "1.1.14" + "Version": "1.3.0", + "Type": "Abstractions" }, { "Name": "com.microsoft.kiota:microsoft-kiota-http-okHttp", - "Version": "1.1.14" + "Version": "1.3.0", + "Type": "Http" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-form", - "Version": "1.1.14" + "Version": "1.3.0", + "Type": "Serialization" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-json", - "Version": "1.1.14" + "Version": "1.3.0", + "Type": "Serialization" }, { "Name": "com.microsoft.kiota:microsoft-kiota-authentication-azure", - "Version": "1.1.14" + "Version": "1.3.0", + "Type": "Authentication" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-text", - "Version": "1.1.14" + "Version": "1.3.0", + "Type": "Serialization" }, { "Name": "com.microsoft.kiota:microsoft-kiota-serialization-multipart", - "Version": "1.1.14" + "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", + "MaximumVersion": "2.0.0", + "QueryName": "jakarta/annotation.jakarta|annotation-api" } ], "DependencyInstallCommand": "{0}:{1}" @@ -99,31 +126,43 @@ "Dependencies": [ { "Name": "github.com/microsoft/kiota-abstractions-go", - "Version": "v1.6.0" + "Version": "v1.7.0", + "Type": "Abstractions" }, { "Name": "github.com/microsoft/kiota-http-go", - "Version": "v1.4.1" + "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.7" + "Version": "v1.0.8", + "Type": "Serialization" }, { "Name": "github.com/microsoft/kiota-authentication-azure-go", - "Version": "v1.0.2" + "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}" @@ -133,31 +172,43 @@ "Dependencies": [ { "Name": "@microsoft/kiota-abstractions", - "Version": "1.0.0-preview.56" + "Version": "1.0.0-preview.66", + "Type": "Abstractions" }, { "Name": "@microsoft/kiota-http-fetchlibrary", - "Version": "1.0.0-preview.55" + "Version": "1.0.0-preview.65", + "Type": "Http" }, { "Name": "@microsoft/kiota-serialization-form", - "Version": "1.0.0-preview.45" + "Version": "1.0.0-preview.54", + "Type": "Serialization" }, { "Name": "@microsoft/kiota-serialization-json", - "Version": "1.0.0-preview.56" + "Version": "1.0.0-preview.66", + "Type": "Serialization" }, { "Name": "@microsoft/kiota-authentication-azure", - "Version": "1.0.0-preview.51" + "Version": "1.0.0-preview.61", + "Type": "Authentication" }, { "Name": "@microsoft/kiota-serialization-text", - "Version": "1.0.0-preview.53" + "Version": "1.0.0-preview.63", + "Type": "Serialization" }, { "Name": "@microsoft/kiota-serialization-multipart", - "Version": "1.0.0-preview.34" + "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" @@ -167,31 +218,38 @@ "Dependencies": [ { "Name": "microsoft/kiota-abstractions", - "Version": "1.4.0" + "Version": "1.4.0", + "Type": "Abstractions" }, { "Name": "microsoft/kiota-http-guzzle", - "Version": "1.3.0" + "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.1.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}" @@ -201,31 +259,38 @@ "Dependencies": [ { "Name": "microsoft-kiota-abstractions", - "Version": "1.3.3" + "Version": "1.3.3", + "Type": "Abstractions" }, { "Name": "microsoft-kiota-http", - "Version": "1.3.1" + "Version": "1.3.3", + "Type": "Http" }, { "Name": "microsoft-kiota-serialization-json", - "Version": "1.2.0" + "Version": "1.3.2", + "Type": "Serialization" }, { "Name": "microsoft-kiota-authentication-azure", - "Version": "1.0.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.0" + "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}" @@ -235,19 +300,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}\"" @@ -262,34 +331,46 @@ "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.Cli.Commons", - "Version": "1.1.1" + "Version": "1.1.2", + "Type": "Additional" + }, + { + "Name": "Microsoft.Kiota.Bundle", + "Version": "1.12.4", + "Type": "Bundle" } ], "DependencyInstallCommand": "dotnet add package {0} --version {1}" } } -} +} \ No newline at end of file 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); } } 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/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" } ] } 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;