diff --git a/.github/workflows/graphprojects.yml b/.github/workflows/graphprojects.yml index f1f100b67f..f697bf9b89 100644 --- a/.github/workflows/graphprojects.yml +++ b/.github/workflows/graphprojects.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Generate token id: generate_token - uses: tibdex/github-app-token@0914d50df753bbc42180d982a6550f195390069f + uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a with: app_id: ${{ secrets.GRAPHBOT_APP_ID }} private_key: ${{ secrets.GRAPHBOT_APP_PEM }} diff --git a/it/python/requirements-dev.txt b/it/python/requirements-dev.txt index c4b2203583..9c67e2d28c 100644 --- a/it/python/requirements-dev.txt +++ b/it/python/requirements-dev.txt @@ -58,7 +58,7 @@ tomlkit==0.12.1 ; python_version >= '3.7' typing-extensions==4.8.0 ; python_version >= '3.7' -urllib3==2.0.4 ; python_version >= '3.7' +urllib3==2.0.5 ; python_version >= '3.7' wrapt==1.15.0 ; python_version < '3.11' @@ -82,7 +82,7 @@ azure-identity==1.14.0 cffi==1.15.1 -cryptography==41.0.3 ; python_version >= '3.7' +cryptography==41.0.4 ; python_version >= '3.7' frozenlist==1.4.0 ; python_version >= '3.7' @@ -98,7 +98,7 @@ httpx[http2]==0.25.0 hyperframe==6.0.1 ; python_full_version >= '3.6.1' -microsoft-kiota-abstractions==0.8.5 +microsoft-kiota-abstractions==0.8.6 microsoft-kiota-authentication-azure==0.3.0 diff --git a/it/typescript/package-lock.json b/it/typescript/package-lock.json index b148084236..f476388f60 100644 --- a/it/typescript/package-lock.json +++ b/it/typescript/package-lock.json @@ -22,7 +22,7 @@ }, "devDependencies": { "@es-exec/esbuild-plugin-start": "^0.0.5", - "@types/node": "^20.6.2", + "@types/node": "^20.6.3", "@typescript-eslint/eslint-plugin": "^6.7.2", "@typescript-eslint/parser": "^6.7.2", "esbuild": "^0.19.3", @@ -805,9 +805,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.6.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.2.tgz", - "integrity": "sha512-Y+/1vGBHV/cYk6OI1Na/LHzwnlNCAfU3ZNGrc1LdRe/LAIbdDPTTv/HU3M7yXN448aTVDq3eKRm2cg7iKLb8gw==", + "version": "20.6.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.3.tgz", + "integrity": "sha512-HksnYH4Ljr4VQgEy2lTStbCKv/P590tmPe5HqOnv9Gprffgv5WXAY+Y5Gqniu0GGqeTCUdBnzC3QSrzPkBkAMA==", "dev": true }, "node_modules/@types/semver": { diff --git a/it/typescript/package.json b/it/typescript/package.json index 2945ab884e..5b189323e6 100644 --- a/it/typescript/package.json +++ b/it/typescript/package.json @@ -19,7 +19,7 @@ "prettier": "./.prettierrc.json", "devDependencies": { "@es-exec/esbuild-plugin-start": "^0.0.5", - "@types/node": "^20.6.2", + "@types/node": "^20.6.3", "@typescript-eslint/eslint-plugin": "^6.7.2", "@typescript-eslint/parser": "^6.7.2", "esbuild": "^0.19.3", diff --git a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs index e26e45f012..e68845ae38 100644 --- a/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs +++ b/src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs @@ -12,7 +12,6 @@ public CodeMethodWriter(TypeScriptConventionService conventionService, bool uses { _usesBackingStore = usesBackingStore; } - private TypeScriptConventionService? localConventions; private readonly bool _usesBackingStore; public override void WriteCodeElement(CodeMethod codeElement, LanguageWriter writer) @@ -23,8 +22,7 @@ public override void WriteCodeElement(CodeMethod codeElement, LanguageWriter wri if (codeElement.Parent is CodeFunction) return; if (codeElement.Parent is not CodeClass parentClass) throw new InvalidOperationException("the parent of a method should be a class"); - localConventions = new TypeScriptConventionService(writer); //because we allow inline type definitions for methods parameters - var returnType = localConventions.GetTypeString(codeElement.ReturnType, codeElement); + var returnType = conventions.GetTypeString(codeElement.ReturnType, codeElement); var isVoid = "void".EqualsIgnoreCase(returnType); WriteMethodDocumentation(codeElement, writer, isVoid); WriteMethodPrototype(codeElement, writer, returnType, isVoid); @@ -126,10 +124,9 @@ internal static void WriteDefensiveStatements(CodeMethod codeElement, LanguageWr private void WriteIndexerBody(CodeMethod codeElement, CodeClass parentClass, string returnType, LanguageWriter writer) { if (parentClass.GetPropertyOfKind(CodePropertyKind.PathParameters) is CodeProperty pathParametersProperty && - localConventions != null && codeElement.OriginalIndexer != null) { - localConventions.AddParametersAssignment(writer, pathParametersProperty.Type, $"this.{pathParametersProperty.Name}", + conventions.AddParametersAssignment(writer, pathParametersProperty.Type, $"this.{pathParametersProperty.Name}", parameters: (codeElement.OriginalIndexer.IndexParameter.Type, codeElement.OriginalIndexer.IndexParameter.SerializationName, codeElement.OriginalIndexer.IndexParameter.Name.ToFirstCharacterLowerCase())); } conventions.AddRequestBuilderBody(parentClass, returnType, writer, conventions.TempDictionaryVarName); @@ -242,7 +239,7 @@ private void WriteConstructorBody(CodeClass parentClass, CodeMethod currentMetho currentMethod.Parameters.FirstOrDefault(static x => x.IsOfKind(CodeParameterKind.PathParameters)) is CodeParameter pathParametersParam && parentClass.Properties.FirstOrDefaultOfKind(CodePropertyKind.PathParameters) is CodeProperty pathParametersProperty) { - localConventions?.AddParametersAssignment(writer, + conventions.AddParametersAssignment(writer, pathParametersParam.Type.AllTypes.OfType().First(), pathParametersParam.Name.ToFirstCharacterLowerCase(), $"this.{pathParametersProperty.Name.ToFirstCharacterLowerCase()}", @@ -385,7 +382,7 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req private void ComposeContentInRequestGeneratorBody(CodeParameter requestBody, CodeProperty requestAdapterProperty, string contentType, LanguageWriter writer) { - if (requestBody.Type.Name.Equals(localConventions?.StreamTypeName, StringComparison.OrdinalIgnoreCase)) + if (requestBody.Type.Name.Equals(conventions.StreamTypeName, StringComparison.OrdinalIgnoreCase)) { writer.WriteLine($"{RequestInfoVarName}.setStreamContent({requestBody.Name});"); return; @@ -423,8 +420,7 @@ private void WriteMethodDocumentation(CodeMethod code, LanguageWriter writer, bo private static readonly BaseCodeParameterOrderComparer parameterOrderComparer = new(); private void WriteMethodPrototype(CodeMethod code, LanguageWriter writer, string returnType, bool isVoid) { - if (localConventions != null) - WriteMethodPrototypeInternal(code, writer, returnType, isVoid, localConventions, false); + WriteMethodPrototypeInternal(code, writer, returnType, isVoid, conventions, false); } internal static void WriteMethodPrototypeInternal(CodeMethod code, LanguageWriter writer, string returnType, bool isVoid, TypeScriptConventionService pConventions, bool isFunction) { @@ -455,9 +451,8 @@ internal static void WriteMethodPrototypeInternal(CodeMethod code, LanguageWrite } private string GetFactoryMethodName(CodeTypeBase targetClassType, CodeMethod currentElement, LanguageWriter writer) { - if (localConventions == null) throw new InvalidOperationException("localConventions is null"); - var returnType = localConventions.GetTypeString(targetClassType, currentElement, false, writer); - var targetClassName = localConventions.TranslateType(targetClassType); + var returnType = conventions.GetTypeString(targetClassType, currentElement, false, writer); + var targetClassName = conventions.TranslateType(targetClassType); var resultName = $"create{targetClassName.ToFirstCharacterUpperCase()}FromDiscriminatorValue"; if (targetClassName.Equals(returnType, StringComparison.OrdinalIgnoreCase)) return resultName; @@ -466,7 +461,7 @@ currentType.TypeDefinition is CodeClass definitionClass && definitionClass.GetImmediateParentOfType() is CodeNamespace parentNamespace && parentNamespace.FindChildByName(resultName) is CodeFunction factoryMethod) { - var methodName = localConventions.GetTypeString(new CodeType + var methodName = conventions.GetTypeString(new CodeType { Name = resultName, TypeDefinition = factoryMethod diff --git a/src/Kiota.Builder/Writers/TypeScript/TypeScriptConventionService.cs b/src/Kiota.Builder/Writers/TypeScript/TypeScriptConventionService.cs index 5d0d63f64c..9100efc20c 100644 --- a/src/Kiota.Builder/Writers/TypeScript/TypeScriptConventionService.cs +++ b/src/Kiota.Builder/Writers/TypeScript/TypeScriptConventionService.cs @@ -11,10 +11,6 @@ namespace Kiota.Builder.Writers.TypeScript; public class TypeScriptConventionService : CommonLanguageConventionService { - public TypeScriptConventionService(LanguageWriter languageWriter) - { - writer = languageWriter; - } internal void WriteAutoGeneratedStart(LanguageWriter writer) { writer.WriteLine("// tslint:disable"); @@ -26,7 +22,6 @@ internal void WriteAutoGeneratedEnd(LanguageWriter writer) writer.WriteLine("// tslint:enable"); writer.WriteLine("// eslint-enable"); } - private readonly LanguageWriter writer; public override string StreamTypeName => "ArrayBuffer"; public override string VoidTypeName => "void"; public override string DocCommentPrefix => " * "; @@ -86,8 +81,6 @@ public override string GetTypeString(CodeTypeBase code, CodeElement targetElemen if (code is CodeType currentType) { var typeName = GetTypeAlias(currentType, targetElement) is string alias && !string.IsNullOrEmpty(alias) ? alias : TranslateType(currentType); - if (code.ActionOf) - return WriteInlineDeclaration(currentType, targetElement); return $"{typeName}{collectionSuffix}"; } @@ -104,27 +97,6 @@ private static string GetTypeAlias(CodeType targetType, CodeElement targetElemen return aliasedUsing.Alias; return string.Empty; } - private string WriteInlineDeclaration(CodeType currentType, CodeElement targetElement) - { - writer.IncreaseIndent(4); - var childElements = (currentType?.TypeDefinition as CodeClass) - ?.Properties - ?.OrderBy(x => x.Name) - ?.Select(x => $"{x.Name}?: {GetTypeString(x.Type, targetElement)}"); - var innerDeclaration = childElements?.Any() ?? false ? - LanguageWriter.NewLine + - writer.GetIndent() + - childElements - .Aggregate((x, y) => $"{x};{LanguageWriter.NewLine}{writer.GetIndent()}{y}") - .Replace(';', ',') + - LanguageWriter.NewLine + - writer.GetIndent() - : string.Empty; - writer.DecreaseIndent(); - if (string.IsNullOrEmpty(innerDeclaration)) - return "object"; - return $"{{{innerDeclaration}}}"; - } public override string TranslateType(CodeType type) { diff --git a/src/Kiota.Builder/Writers/TypeScript/TypeScriptWriter.cs b/src/Kiota.Builder/Writers/TypeScript/TypeScriptWriter.cs index 4984b1ab56..11233a0f31 100644 --- a/src/Kiota.Builder/Writers/TypeScript/TypeScriptWriter.cs +++ b/src/Kiota.Builder/Writers/TypeScript/TypeScriptWriter.cs @@ -7,7 +7,7 @@ public class TypeScriptWriter : LanguageWriter public TypeScriptWriter(string rootPath, string clientNamespaceName, bool usesBackingStore = false) { PathSegmenter = new TypeScriptPathSegmenter(rootPath, clientNamespaceName); - var conventionService = new TypeScriptConventionService(this); + var conventionService = new TypeScriptConventionService(); AddOrReplaceCodeElementWriter(new CodeClassDeclarationWriter(conventionService, clientNamespaceName)); AddOrReplaceCodeElementWriter(new CodeBlockEndWriter(conventionService)); AddOrReplaceCodeElementWriter(new CodeEnumWriter(conventionService)); diff --git a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeClassDeclarationWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeClassDeclarationWriterTests.cs index a33b8f81fe..3abb2c3022 100644 --- a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeClassDeclarationWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeClassDeclarationWriterTests.cs @@ -20,7 +20,7 @@ public class CodeClassDeclarationWriterTests : IDisposable public CodeClassDeclarationWriterTests() { writer = LanguageWriter.GetLanguageWriter(GenerationLanguage.TypeScript, DefaultPath, DefaultName); - codeElementWriter = new CodeClassDeclarationWriter(new TypeScriptConventionService(writer), "graphtests"); + codeElementWriter = new CodeClassDeclarationWriter(new TypeScriptConventionService(), "graphtests"); tw = new StringWriter(); writer.SetTextWriter(tw); var root = CodeNamespace.InitRootNamespace(); diff --git a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeClassEndWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeClassEndWriterTests.cs index 1513b0e70c..f1c1eb388c 100644 --- a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeClassEndWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeClassEndWriterTests.cs @@ -20,7 +20,7 @@ public class CodeClassEndWriterTests : IDisposable public CodeClassEndWriterTests() { writer = LanguageWriter.GetLanguageWriter(GenerationLanguage.TypeScript, DefaultPath, DefaultName); - codeElementWriter = new CodeBlockEndWriter(new(writer)); + codeElementWriter = new CodeBlockEndWriter(new()); tw = new StringWriter(); writer.SetTextWriter(tw); var root = CodeNamespace.InitRootNamespace(); diff --git a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs index 1925687097..eb5b715349 100644 --- a/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs +++ b/tests/Kiota.Builder.Tests/Writers/TypeScript/CodeMethodWriterTests.cs @@ -131,7 +131,6 @@ private void AddRequestBodyParameters(bool useComplexTypeForBody = false) { Name = "RequestConfig", TypeDefinition = requestConfigClass, - ActionOf = true, }, Optional = true, }); @@ -392,7 +391,7 @@ public void WritesMethodDescriptionLink() [Fact] public void Defensive() { - var codeMethodWriter = new CodeMethodWriter(new TypeScriptConventionService(writer), false); + var codeMethodWriter = new CodeMethodWriter(new TypeScriptConventionService(), false); Assert.Throws(() => codeMethodWriter.WriteCodeElement(null, writer)); Assert.Throws(() => codeMethodWriter.WriteCodeElement(method, null)); var originalParent = method.Parent; diff --git a/vscode/microsoft-kiota/package-lock.json b/vscode/microsoft-kiota/package-lock.json index 8b59959ace..c10c88b741 100644 --- a/vscode/microsoft-kiota/package-lock.json +++ b/vscode/microsoft-kiota/package-lock.json @@ -13,7 +13,7 @@ "adm-zip": "^0.5.10", "is-online": "^10.0.0", "original-fs": "^1.2.0", - "vscode-jsonrpc": "^8.1.0" + "vscode-jsonrpc": "^8.2.0" }, "devDependencies": { "@types/adm-zip": "^0.5.1", @@ -792,9 +792,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.6.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.2.tgz", - "integrity": "sha512-Y+/1vGBHV/cYk6OI1Na/LHzwnlNCAfU3ZNGrc1LdRe/LAIbdDPTTv/HU3M7yXN448aTVDq3eKRm2cg7iKLb8gw==", + "version": "20.6.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.6.3.tgz", + "integrity": "sha512-HksnYH4Ljr4VQgEy2lTStbCKv/P590tmPe5HqOnv9Gprffgv5WXAY+Y5Gqniu0GGqeTCUdBnzC3QSrzPkBkAMA==", "dev": true }, "node_modules/@types/semver": { @@ -4452,9 +4452,9 @@ } }, "node_modules/vscode-jsonrpc": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0.tgz", - "integrity": "sha512-6TDy/abTQk+zDGYazgbIPc+4JoXdwC8NHU9Pbn4UJP1fehUyZmM4RHp5IthX7A6L5KS30PRui+j+tbbMMMafdw==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz", + "integrity": "sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==", "engines": { "node": ">=14.0.0" } diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 8b5c7e9f47..6a68d5aff0 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -278,7 +278,7 @@ "adm-zip": "^0.5.10", "is-online": "^10.0.0", "original-fs": "^1.2.0", - "vscode-jsonrpc": "^8.1.0" + "vscode-jsonrpc": "^8.2.0" }, "preview": true, "runtimeDependencies": [