From f62c3223341e9f86d3a2d1e7d10b5c45cb14c088 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 3 Apr 2024 17:47:39 +0300 Subject: [PATCH 001/150] add tree view --- vscode/microsoft-kiota/package.json | 14 ++++++++------ vscode/microsoft-kiota/package.nls.json | 7 ++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 6660f892e7..58fa2a91ff 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -190,12 +190,6 @@ } } }, - "viewsWelcome": [ - { - "view": "kiota.openApiExplorer", - "contents": "%kiota.openApiExplorer.welcome%" - } - ], "viewsContainers": { "activitybar": [ { @@ -214,6 +208,14 @@ }, "views": { "kiota-openapi-explorer": [ + { + "id": "kiota.apiClients", + "name": "%kiota.openApiExplorer.apiClient.name%" + }, + { + "id": "kiota.apiPlugins", + "name": "%kiota.openApiExplorer.apiPlugin.name%" + }, { "id": "kiota.openApiExplorer", "name": "%kiota.openApiExplorer.name%", diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index b8879840bd..a9adcf618c 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "Kiota OpenAPI Explorer", "kiota.openApiExplorer.contextualTitle": "OpenAPI Explorer", "kiota-dependencies-info.panel.title": "Kiota Dependencies Information", - "kiota-openapi-explorer.activitybar.title": "Kiota OpenAPI Explorer", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "Select lock file for API explorer view", "kiota.updateClients.title": "Update API clients in the current workspace", "kiota.openApiExplorer.generateClient.title": "Generate API client", @@ -15,7 +15,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Remove all", "kiota.openApiExplorer.closeDescription.title": "Close API description", "kiota.openApiExplorer.openDescription.title": "Open API description", - "kiota.openApiExplorer.welcome": "No API description selected.\n[Search](command:kiota.searchApiDescription)\n[Open API description](command:kiota.openApiExplorer.openDescription)\n[Open a manifest](command:kiota.openApiExplorer.openManifestPath)\n[Paste a manifest](command:kiota.openApiExplorer.pasteManifest)\n[Select lock file](command:kiota.searchLock)", "kiota.searchLock.title": "Search for a lock file", "kiota.openApiExplorer.filterDescription.title": "Filter API description", "kiota.openApiExplorer.openDocumentationPage.title": "Open documentation page", @@ -29,5 +28,7 @@ "kiota.generate.serializer.description": "The fully qualified class names for serializers", "kiota.generate.deserializer.description": "The fully qualified class names for deserializers", "kiota.generate.structuredMimeTypes.description": "The MIME types and preference to use for structured data model generation. As per RFC9110 Accept header notation.", - "kiota.generate.includeAdditionalData.description": "Will include the 'AdditionalData' property for models" + "kiota.generate.includeAdditionalData.description": "Will include the 'AdditionalData' property for models", + "kiota.openApiExplorer.apiClient.name":"My API Clients", + "kiota.openApiExplorer.apiPlugin.name":"My API Plugins" } From f62cdfac749d46f21a1674a794f7d1d6234c6152 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 11 Apr 2024 18:22:21 +0300 Subject: [PATCH 002/150] add Api files conatiner and remove previous containers --- vscode/microsoft-kiota/package.json | 39 +++++++++---------------- vscode/microsoft-kiota/package.nls.json | 5 ++-- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 58fa2a91ff..c3adf9881d 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -209,18 +209,12 @@ "views": { "kiota-openapi-explorer": [ { - "id": "kiota.apiClients", - "name": "%kiota.openApiExplorer.apiClient.name%" - }, - { - "id": "kiota.apiPlugins", - "name": "%kiota.openApiExplorer.apiPlugin.name%" + "id": "kiota.openApiExplorer", + "name": "%kiota.openApiExplorer.name%" }, { - "id": "kiota.openApiExplorer", - "name": "%kiota.openApiExplorer.name%", - "icon": "media/logo.svg", - "contextualTitle": "%kiota.openApiExplorer.contextualTitle%" + "id": "kiota.apiFiles", + "name": "%kiota.apiFiles.name%" } ], "kiota-dependencies-info": [ @@ -248,25 +242,10 @@ "when": "view == kiota.openApiExplorer", "group": "navigation@2" }, - { - "command": "kiota.searchApiDescription", - "when": "view == kiota.openApiExplorer", - "group": "navigation@1" - }, { "command": "kiota.openApiExplorer.filterDescription", "when": "view == kiota.openApiExplorer", "group": "navigation@3" - }, - { - "command": "kiota.openApiExplorer.generateClient", - "when": "view == kiota.openApiExplorer", - "group": "navigation@4" - }, - { - "command": "kiota.openApiExplorer.closeDescription", - "when": "view == kiota.openApiExplorer", - "group": "navigation@5" } ], "view/item/context": [ @@ -409,7 +388,15 @@ "command": "kiota.openApiExplorer.openDescription", "category": "Kiota", "title": "%kiota.openApiExplorer.openDescription.title%", - "icon": "$(go-to-file)" + "icon": "$(file-add)" + }, + { + "command": "kiota.openApiExplorer.newClient", + "title": "New client" + }, + { + "command": "kiota.openApiExplorer.newPlugin", + "title": "New plugin" } ] }, diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index a9adcf618c..de9ab0011e 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -1,7 +1,7 @@ { "kiota.dependenciesInfo.name": "Kiota Dependencies Information", "kiota.dependenciesInfo.contextualTitle": "Dependencies Information", - "kiota.openApiExplorer.name": "Kiota OpenAPI Explorer", + "kiota.openApiExplorer.name": "API Explorer", "kiota.openApiExplorer.contextualTitle": "OpenAPI Explorer", "kiota-dependencies-info.panel.title": "Kiota Dependencies Information", "kiota-openapi-explorer.activitybar.title": "Kiota", @@ -29,6 +29,5 @@ "kiota.generate.deserializer.description": "The fully qualified class names for deserializers", "kiota.generate.structuredMimeTypes.description": "The MIME types and preference to use for structured data model generation. As per RFC9110 Accept header notation.", "kiota.generate.includeAdditionalData.description": "Will include the 'AdditionalData' property for models", - "kiota.openApiExplorer.apiClient.name":"My API Clients", - "kiota.openApiExplorer.apiPlugin.name":"My API Plugins" + "kiota.apiFiles.Name": "My API Files" } From 45d5b421f9b5bafc41c343c253ef70d68e1fe9ac Mon Sep 17 00:00:00 2001 From: ElinorW Date: Mon, 15 Apr 2024 15:02:53 +0300 Subject: [PATCH 003/150] rename workspace title --- vscode/microsoft-kiota/package.json | 28 ++++++++++++++++--------- vscode/microsoft-kiota/package.nls.json | 5 +++-- vscode/microsoft-kiota/src/extension.ts | 1 + 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index c3adf9881d..5d55818e80 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -213,8 +213,8 @@ "name": "%kiota.openApiExplorer.name%" }, { - "id": "kiota.apiFiles", - "name": "%kiota.apiFiles.name%" + "id": "kiota.workspace", + "name": "%kiota.workspace.name%" } ], "kiota-dependencies-info": [ @@ -246,6 +246,16 @@ "command": "kiota.openApiExplorer.filterDescription", "when": "view == kiota.openApiExplorer", "group": "navigation@3" + }, + { + "command": "kiota.openApiExplorer.generateClient", + "when": "view == kiota.openApiExplorer", + "group": "navigation@4" + }, + { + "command": "kiota.openApiExplorer.openFile", + "when": "view == kiota.workspace", + "group": "navigation@2" } ], "view/item/context": [ @@ -334,7 +344,7 @@ "command": "kiota.openApiExplorer.generateClient", "category": "Kiota", "title": "%kiota.openApiExplorer.generateClient.title%", - "icon": "$(play)" + "icon": "$(run-all)" }, { "command": "kiota.openApiExplorer.filterDescription", @@ -388,15 +398,13 @@ "command": "kiota.openApiExplorer.openDescription", "category": "Kiota", "title": "%kiota.openApiExplorer.openDescription.title%", - "icon": "$(file-add)" - }, - { - "command": "kiota.openApiExplorer.newClient", - "title": "New client" + "icon": "$(add)" }, { - "command": "kiota.openApiExplorer.newPlugin", - "title": "New plugin" + "command": "kiota.openApiExplorer.openFile", + "category": "Kiota", + "title": "%kiota.openApiExplorer.openFile.title%", + "icon": "$(folder-opened)" } ] }, diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index de9ab0011e..f59f00e5b1 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -14,7 +14,7 @@ "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "Add all", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Remove all", "kiota.openApiExplorer.closeDescription.title": "Close API description", - "kiota.openApiExplorer.openDescription.title": "Open API description", + "kiota.openApiExplorer.openDescription.title": "Add API description", "kiota.searchLock.title": "Search for a lock file", "kiota.openApiExplorer.filterDescription.title": "Filter API description", "kiota.openApiExplorer.openDocumentationPage.title": "Open documentation page", @@ -29,5 +29,6 @@ "kiota.generate.deserializer.description": "The fully qualified class names for deserializers", "kiota.generate.structuredMimeTypes.description": "The MIME types and preference to use for structured data model generation. As per RFC9110 Accept header notation.", "kiota.generate.includeAdditionalData.description": "Will include the 'AdditionalData' property for models", - "kiota.apiFiles.Name": "My API Files" + "kiota.workspace.name": "My Workspace", + "kiota.openApiExplorer.openFile.title": "Open file" } diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index db60f3cb88..04e9c5eda4 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -117,6 +117,7 @@ export async function activate( dependenciesInfo, dependenciesInfoProvider ), + vscode.commands.registerCommand(`${treeViewId}.openFile`, () => vscode.window.showInformationMessage(`Successfully called open api file.`)), vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider), registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, From d9b921fac0b0e9465cc6f4d1ea684457b5a2de23 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 16 Apr 2024 17:20:01 +0300 Subject: [PATCH 004/150] combine search and open description functions --- vscode/microsoft-kiota/package.json | 4 +-- vscode/microsoft-kiota/src/extension.ts | 2 +- vscode/microsoft-kiota/src/steps.ts | 35 ++++++++++++++++++++----- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 5d55818e80..e791d9f62e 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -238,7 +238,7 @@ ], "view/title": [ { - "command": "kiota.openApiExplorer.openDescription", + "command": "kiota.openApiExplorer.searchOrOpenApiDescription", "when": "view == kiota.openApiExplorer", "group": "navigation@2" }, @@ -395,7 +395,7 @@ "icon": "$(close)" }, { - "command": "kiota.openApiExplorer.openDescription", + "command": "kiota.openApiExplorer.searchOrOpenApiDescription", "category": "Kiota", "title": "%kiota.openApiExplorer.openDescription.title%", "icon": "$(add)" diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 04e9c5eda4..c44bbee6f8 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -244,7 +244,7 @@ export async function activate( } ), registerCommandWithTelemetry(reporter, - `${extensionId}.searchApiDescription`, + `${treeViewId}.searchOrOpenApiDescription`, async () => { const config = await searchSteps(x => vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index dc3c0c3cf2..807e51e3c3 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -121,25 +121,46 @@ export async function filterSteps(existingFilter: string, filterCallback: (searc } export async function searchSteps(searchCallBack: (searchQuery: string) => Thenable | undefined>) { - const state = {} as Partial; - const title = l10n.t('Search for an API description'); + const state: Partial = {}; + const title = l10n.t('Add an API description'); let step = 1; let totalSteps = 2; - async function inputSearchQuery(input: MultiStepInput, state: Partial) { + async function inputPathOrSearch(input: MultiStepInput, state: Partial) { state.searchQuery = await input.showInputBox({ title, step: step++, totalSteps: totalSteps, value: state.searchQuery || '', - prompt: l10n.t('Enter a search query'), + prompt: l10n.t('Search or paste a path to an API description'), validate: validateIsNotEmpty, shouldResume: shouldResume }); state.searchResults = await searchCallBack(state.searchQuery); - return (input: MultiStepInput) => pickSearchResult(input, state); + if(state.searchResults && Object.keys(state.searchResults).length > 0) { + return (input: MultiStepInput) => pickSearchResult(input, state); + } + else { + state.descriptionPath = state.searchQuery; + return (input: MultiStepInput) => inputPathOrUrl(input, state); + } + } + + async function inputPathOrUrl(input: MultiStepInput, state: Partial) { + if (state.descriptionPath) { + return; + } + state.descriptionPath = await input.showInputBox({ + title, + step: step++, + totalSteps: 1, + value: state.descriptionPath || '', + prompt: l10n.t('Search or paste a path to an API description'), + validate: validateIsNotEmpty, + shouldResume: shouldResume + }); } - async function pickSearchResult(input: MultiStepInput, state: Partial) { + async function pickSearchResult(input: MultiStepInput, state: Partial) { const items: QuickSearchPickItem[] = []; if(state.searchResults) { for (const key of Object.keys(state.searchResults)) { @@ -157,7 +178,7 @@ export async function searchSteps(searchCallBack: (searchQuery: string) => Thena }); state.descriptionPath = items.find(x => x.label === pick?.label)?.descriptionUrl || ''; } - await MultiStepInput.run(input => inputSearchQuery(input, state), () => step-=2); + await MultiStepInput.run(input => inputPathOrSearch(input, state), () => step-=2); return state; } From 1a1d1c42c96809d2ee42f0b9aa182792e6c274f8 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 17 Apr 2024 23:17:50 +0300 Subject: [PATCH 005/150] Add 'close description' button to api title node --- vscode/microsoft-kiota/package.json | 9 +++++++-- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index a0f3405b3c..ea63cf0525 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -259,9 +259,14 @@ } ], "view/item/context": [ + { + "command": "kiota.openApiExplorer.closeDescription", + "when": "view == kiota.openApiExplorer && viewItem == apiTitle", + "group": "inline@6" + }, { "command": "kiota.openApiExplorer.openDocumentationPage", - "when": "view == kiota.openApiExplorer && (viewItem || false)", + "when": "view == kiota.openApiExplorer && (viewItem == documentationUrl)", "group": "inline@1" }, { @@ -392,7 +397,7 @@ "command": "kiota.openApiExplorer.closeDescription", "category": "Kiota", "title": "%kiota.openApiExplorer.closeDescription.title%", - "icon": "$(close)" + "icon": "$(trash)" }, { "command": "kiota.openApiExplorer.searchOrOpenApiDescription", diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 881be00ba2..f459879dd1 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -266,11 +266,11 @@ export class OpenApiTreeNode extends vscode.TreeItem { private readonly isOperation: boolean, filterTokens: string[], public readonly children: OpenApiTreeNode[] = [], - public readonly documentationUrl?: string, + public readonly documentationUrl?: string ) { super(label, collapsibleState); this.id = `${path}_${filterTokens.join('_')}`; // so the collapsed state is NOT persisted between filter changes - this.contextValue = documentationUrl; + this.contextValue =(this.label.indexOf('(') !== -1) ? 'apiTitle' : (this.documentationUrl ? 'documentationUrl' : ''); this.iconPath = selected ? OpenApiTreeNode.selectedSet : OpenApiTreeNode.unselectedSet; } public isNodeVisible(tokenizedFilter: string[]): boolean { From 1431b900e91b2bec43dfa338a28289d268eb0108 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 17 Apr 2024 23:18:12 +0300 Subject: [PATCH 006/150] add close description dialog --- vscode/microsoft-kiota/src/extension.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index c44bbee6f8..e95fe233f2 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -259,8 +259,18 @@ export async function activate( } } ), - registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, () => - openApiTreeProvider.closeDescription() + registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, async () => + { + const yesAnswer = vscode.l10n.t("Yes"); + const response = await vscode.window.showInformationMessage( + vscode.l10n.t("Do you want to remove this API description?"), + yesAnswer, + vscode.l10n.t("No") + ); + if(response === yesAnswer) { + openApiTreeProvider.closeDescription(); + } + } ), registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`, async () => { From 9c84f5cde54bacb75634a4c20b32df45a0d4de6a Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 18 Apr 2024 00:20:58 +0300 Subject: [PATCH 007/150] add generate option step --- vscode/microsoft-kiota/src/extension.ts | 1 + vscode/microsoft-kiota/src/steps.ts | 37 +++++++++++++++++++------ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index e95fe233f2..faff21a1a8 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -161,6 +161,7 @@ export async function activate( let languagesInformation = await getLanguageInformation(context); const config = await generateSteps( { + generationType: '', clientClassName: openApiTreeProvider.clientClassName, clientNamespaceName: openApiTreeProvider.clientNamespaceName, language: openApiTreeProvider.language, diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 807e51e3c3..f0d11c6188 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -189,21 +189,38 @@ type QuickSearchPickItem = QuickPickItem & SearchItem; export async function generateSteps(existingConfiguration: Partial, languagesInformation?: LanguagesInformation) { const state = {...existingConfiguration} as Partial; - if (existingConfiguration.clientClassName && existingConfiguration.clientNamespaceName && existingConfiguration.outputPath && existingConfiguration.language && - typeof existingConfiguration.clientNamespaceName === 'string' && typeof existingConfiguration.outputPath === 'string' && typeof existingConfiguration.language === 'string' && - existingConfiguration.clientClassName.length > 0 && existingConfiguration.clientNamespaceName.length > 0 && existingConfiguration.outputPath.length > 0 && existingConfiguration.language.length > 0) { + if (existingConfiguration.generationType && existingConfiguration.clientClassName && existingConfiguration.clientNamespaceName && existingConfiguration.outputPath && existingConfiguration.language && + typeof existingConfiguration.generationType === 'string' && existingConfiguration.clientNamespaceName === 'string' && typeof existingConfiguration.outputPath === 'string' && typeof existingConfiguration.language === 'string' && + existingConfiguration.generationType.length > 0 && existingConfiguration.clientClassName.length > 0 && existingConfiguration.clientNamespaceName.length > 0 && existingConfiguration.outputPath.length > 0 && existingConfiguration.language.length > 0) { return state; } if(typeof state.outputPath === 'string') { state.outputPath = workspace.asRelativePath(state.outputPath); } - const title = l10n.t('Generate an API client'); let step = 1; let totalSteps = 4; + async function inputGenerationType(input: MultiStepInput, state: Partial) { + const items = ['Generate an API client', 'Generate a plugin', 'Generate an API manifest']; + const option = await input.showQuickPick({ + title: 'What do you want to generate?', + step: 1, + totalSteps: 1, + placeholder: 'Select an option', + items: items.map(x => ({label: x})), + validate: validateIsNotEmpty, + shouldResume: shouldResume + }); + state.generationType = option.label; + if(option.label === 'Generate an API client') { + return (input: MultiStepInput) => inputClientClassName(input, state); + } + else if(option.label === 'Generate a plugin') { return ;} + else if(option.label === 'Generate an API manifest') { return; } + } async function inputClientClassName(input: MultiStepInput, state: Partial) { state.clientClassName = await input.showInputBox({ - title, + title: l10n.t('Create a new API client - class'), step: step++, totalSteps: totalSteps, value: state.clientClassName || '', @@ -216,7 +233,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.clientNamespaceName = await input.showInputBox({ - title, + title: l10n.t('Create a new API client - namespace'), step: step++, totalSteps: totalSteps, value: typeof state.clientNamespaceName === 'string' ? state.clientNamespaceName : '', @@ -229,7 +246,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.outputPath = await input.showInputBox({ - title, + title: l10n.t('Create a new API client - output path'), step: step++, totalSteps: totalSteps, value: typeof state.outputPath === 'string' ? state.outputPath : '', @@ -251,7 +268,7 @@ export async function generateSteps(existingConfiguration: Partial inputClientClassName(input, state), () => step-=2); + await MultiStepInput.run(input => inputGenerationType(input, state), () => step-=2); return state; } @@ -305,6 +322,7 @@ interface SelectApiManifestKey extends BaseStepsState { } interface GenerateState extends BaseStepsState { + generationType: QuickPickItem | string; clientClassName: string; clientNamespaceName: QuickPickItem | string; language: QuickPickItem | string; @@ -342,6 +360,7 @@ interface InputBoxParameters { shouldResume: () => Thenable; } + class MultiStepInput { static async run(start: InputStep, onNavBack?: () => void) { From df0618ff3e73c12c1a72882665d2b17c0f1606bc Mon Sep 17 00:00:00 2001 From: ElinorW Date: Mon, 22 Apr 2024 19:11:34 +0300 Subject: [PATCH 008/150] added plugin dialog steps --- vscode/microsoft-kiota/src/steps.ts | 32 ++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index f0d11c6188..b91b93e42a 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -215,7 +215,9 @@ export async function generateSteps(existingConfiguration: Partial inputClientClassName(input, state); } - else if(option.label === 'Generate a plugin') { return ;} + else if(option.label === 'Generate a plugin') { + return (input: MultiStepInput) => inputPluginName(input, state); + } else if(option.label === 'Generate an API manifest') { return; } } async function inputClientClassName(input: MultiStepInput, state: Partial) { @@ -278,6 +280,33 @@ export async function generateSteps(existingConfiguration: Partial) { + state.pluginName = await input.showInputBox({ + title: l10n.t('Create a new Microsoft plugin - plugin name'), + step: step++, + totalSteps: 2, + value: state.pluginName || '', + placeholder: 'MyPlugin', + prompt: l10n.t('Choose a name for the plugin'), + validate: validateIsNotEmpty, + shouldResume: shouldResume + }); + return (input: MultiStepInput) => inputPluginOutputPath(input, state); + } + async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { + state.outputPath = await input.showInputBox({ + title: l10n.t('Create a new Microsoft plugin - output path'), + step: step++, + totalSteps: 2, + value: typeof state.outputPath === 'string' ? state.outputPath : '', + placeholder: 'myproject/myplugin', + prompt: l10n.t('Enter an output path relative to the root of the project'), + validate: validateIsNotEmpty, + shouldResume: shouldResume + }); + } + + await MultiStepInput.run(input => inputGenerationType(input, state), () => step-=2); return state; } @@ -323,6 +352,7 @@ interface SelectApiManifestKey extends BaseStepsState { interface GenerateState extends BaseStepsState { generationType: QuickPickItem | string; + pluginName:string; clientClassName: string; clientNamespaceName: QuickPickItem | string; language: QuickPickItem | string; From 3678c341b4a6022f328aa5867a4cd4f3cf5b6fd2 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Mon, 22 Apr 2024 19:11:51 +0300 Subject: [PATCH 009/150] added icon toggling --- vscode/microsoft-kiota/package.json | 4 +++- vscode/microsoft-kiota/src/extension.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index ea63cf0525..b198b6f3e4 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -233,7 +233,7 @@ { "command": "kiota.selectLock", "group": "2_kiota@1", - "when": "resourceLangId == json && resourceFilename =~ /kiota-lock\\.json$/" + "when": "resourceLangId == json && resourceFilename =~ /workspace\\.json$/" } ], "view/title": [ @@ -349,12 +349,14 @@ "command": "kiota.openApiExplorer.generateClient", "category": "Kiota", "title": "%kiota.openApiExplorer.generateClient.title%", + "enablement": "kiota.openApiExplorer.showIcons", "icon": "$(run-all)" }, { "command": "kiota.openApiExplorer.filterDescription", "category": "Kiota", "title": "%kiota.openApiExplorer.filterDescription.title%", + "enablement": "kiota.openApiExplorer.showIcons", "icon": "$(filter)" }, { diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index faff21a1a8..146e8f67b9 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -161,7 +161,6 @@ export async function activate( let languagesInformation = await getLanguageInformation(context); const config = await generateSteps( { - generationType: '', clientClassName: openApiTreeProvider.clientClassName, clientNamespaceName: openApiTreeProvider.clientNamespaceName, language: openApiTreeProvider.language, @@ -257,6 +256,7 @@ export async function activate( })); if (config.descriptionPath) { await openTreeViewWithProgress(() => openApiTreeProvider.setDescriptionUrl(config.descriptionPath!)); + await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, true); } } ), From 50f73ea7d62e8ed5c8f5bcf4f9dd1728d15cc515 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 23 Apr 2024 16:33:42 +0300 Subject: [PATCH 010/150] add workspace.json file to workspace --- vscode/microsoft-kiota/package.json | 6 +- vscode/microsoft-kiota/src/extension.ts | 7 ++- .../src/workspaceTreeProvider.ts | 60 +++++++++++++++++++ 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 vscode/microsoft-kiota/src/workspaceTreeProvider.ts diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index b198b6f3e4..0d85aa63e9 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -412,7 +412,11 @@ "category": "Kiota", "title": "%kiota.openApiExplorer.openFile.title%", "icon": "$(folder-opened)" - } + }, + { + "command": "kiota.workspace.openWorkspaceFile", + "title": "%kiota.openApiExplorer.openFile.title%" + } ] }, "scripts": { diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 146e8f67b9..2a0447c05a 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -22,6 +22,7 @@ import { DependenciesViewProvider } from "./dependenciesViewProvider"; import { updateClients } from "./updateClients"; import { ApiManifest } from "./apiManifest"; import { getExtensionSettings } from "./extensionSettings"; +import { KiotaWorkspace } from "./workspaceTreeProvider"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; @@ -31,7 +32,7 @@ const statusBarCommandId = `${extensionId}.status`; const treeViewId = `${extensionId}.openApiExplorer`; const treeViewFocusCommand = `${treeViewId}${focusCommandId}`; const dependenciesInfo = `${extensionId}.dependenciesInfo`; -export const kiotaLockFile = "kiota-lock.json"; +export const kiotaLockFile = "workspace.json"; // This method is called when your extension is activated // Your extension is activated the very first time the command is executed @@ -46,6 +47,7 @@ export async function activate( context.extensionUri ); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); + new KiotaWorkspace(context), context.subscriptions.push( vscode.window.registerUriHandler({ handleUri: async (uri: vscode.Uri) => { @@ -91,7 +93,7 @@ export async function activate( }), reporter, registerCommandWithTelemetry(reporter, - `${extensionId}.searchLock`, + `${treeViewId}.openFile`, async () => { const lockFilePath = await searchLockSteps(); if (lockFilePath?.lockFilePath) { @@ -117,7 +119,6 @@ export async function activate( dependenciesInfo, dependenciesInfoProvider ), - vscode.commands.registerCommand(`${treeViewId}.openFile`, () => vscode.window.showInformationMessage(`Successfully called open api file.`)), vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider), registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, diff --git a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts new file mode 100644 index 0000000000..47c5ddef08 --- /dev/null +++ b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts @@ -0,0 +1,60 @@ +import * as vscode from 'vscode'; +import * as path from 'path'; +import * as fs from 'fs'; + +const workspaceJsonPath = path.join(vscode.workspace.workspaceFolders?.map(folder => folder.uri.fsPath).join('') || '', '.kiota', 'workspace.json'); + +export class WorkspaceTreeProvider implements vscode.TreeDataProvider { + + constructor(private context: vscode.ExtensionContext) { + void this.ensureKiotaDirectory(); + } + async getChildren(element?: vscode.TreeItem): Promise { + if (!element) { + return [new vscode.TreeItem('workspace.json', vscode.TreeItemCollapsibleState.None)]; + } + return []; + } + + getTreeItem(element: vscode.TreeItem): vscode.TreeItem { + if (element) { + element.command = { command: 'kiota.workspace.openWorkspaceFile', title: "Open File", arguments: [vscode.Uri.file(workspaceJsonPath)], }; + element.contextValue = 'file'; + } + return element; + } + + private async ensureKiotaDirectory(): Promise { + if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) { + await vscode.window.showErrorMessage( + vscode.l10n.t("No workspace folder found, open a folder first") + ); + return; + } + const kiotaDir = path.dirname(workspaceJsonPath); + try { + await fs.promises.access(kiotaDir); + } catch (error) { + await fs.promises.mkdir(kiotaDir, { recursive: true }); + } + + } + +} + +export class KiotaWorkspace { + constructor(context: vscode.ExtensionContext) { + const treeDataProvider = new WorkspaceTreeProvider(context); + context.subscriptions.push(vscode.window.createTreeView('kiota.workspace', { treeDataProvider })); + vscode.commands.registerCommand('kiota.workspace.openWorkspaceFile', async (resource) => await this.openResource(resource)); + } + private async openResource(resource: vscode.Uri): Promise { + try{ + await vscode.window.showTextDocument(resource); + } catch (error) { + await fs.promises.writeFile(workspaceJsonPath, Buffer.from('{}')); + await vscode.window.showTextDocument(resource); + } + + } +} \ No newline at end of file From 75eb6df7a26626b66c11911f90cbe1f125899255 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Fri, 26 Apr 2024 13:23:06 +0300 Subject: [PATCH 011/150] Fix some server configs --- src/kiota/Rpc/Server.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/kiota/Rpc/Server.cs b/src/kiota/Rpc/Server.cs index 878aa9b9d0..d1ee38ca91 100644 --- a/src/kiota/Rpc/Server.cs +++ b/src/kiota/Rpc/Server.cs @@ -80,7 +80,7 @@ private static async Task GenerateClientAsync(GenerationConfiguration conf { using var fileLogger = new FileLogLogger(config.OutputPath, LogLevel.Warning); var logger = new AggregateLogger(globalLogger, fileLogger); - return await new KiotaBuilder(logger, config, httpClient).GenerateClientAsync(cancellationToken); + return await new KiotaBuilder(logger, config, httpClient, true).GenerateClientAsync(cancellationToken); } public async Task SearchAsync(string searchTerm, bool clearCache, CancellationToken cancellationToken) { @@ -97,7 +97,7 @@ public async Task GetManifestDetailsAsync(string manifestPath, s var configuration = Configuration.Generation; configuration.ClearCache = clearCache; configuration.ApiManifestPath = $"{manifestPath}#{apiIdentifier}"; - var builder = new KiotaBuilder(logger, configuration, httpClient); + var builder = new KiotaBuilder(logger, configuration, httpClient, true); var manifestResult = await builder.GetApiManifestDetailsAsync(cancellationToken: cancellationToken); return new ManifestResult(logger.LogEntries, manifestResult?.Item1, @@ -109,12 +109,12 @@ public async Task ShowAsync(string descriptionPath, string[] include var configuration = Configuration.Generation; configuration.ClearCache = clearCache; configuration.OpenAPIFilePath = GetAbsolutePath(descriptionPath); - var builder = new KiotaBuilder(logger, configuration, httpClient); + var builder = new KiotaBuilder(logger, configuration, httpClient, true); var fullUrlTreeNode = await builder.GetUrlTreeNodeAsync(cancellationToken); configuration.IncludePatterns = includeFilters.ToHashSet(StringComparer.Ordinal); configuration.ExcludePatterns = excludeFilters.ToHashSet(StringComparer.Ordinal); var filteredTreeNode = configuration.IncludePatterns.Count != 0 || configuration.ExcludePatterns.Count != 0 ? - await new KiotaBuilder(new NoopLogger(), configuration, httpClient).GetUrlTreeNodeAsync(cancellationToken) : // openapi.net seems to have side effects between tree node and the document, we need to drop all references + await new KiotaBuilder(new NoopLogger(), configuration, httpClient, true).GetUrlTreeNodeAsync(cancellationToken) : // openapi.net seems to have side effects between tree node and the document, we need to drop all references default; var filteredPaths = filteredTreeNode is null ? new HashSet() : GetOperationsFromTreeNode(filteredTreeNode).ToHashSet(StringComparer.Ordinal); var rootNode = fullUrlTreeNode != null ? ConvertOpenApiUrlTreeNodeToPathItem(fullUrlTreeNode, filteredPaths) : null; @@ -191,7 +191,7 @@ private async Task InfoInternalAsync(string descriptionPat var configuration = Configuration.Generation; configuration.ClearCache = clearCache; configuration.OpenAPIFilePath = GetAbsolutePath(descriptionPath); - var builder = new KiotaBuilder(logger, configuration, httpClient); + var builder = new KiotaBuilder(logger, configuration, httpClient, true); var result = await builder.GetLanguagesInformationAsync(cancellationToken); if (result is not null) return result; return Configuration.Languages; @@ -214,13 +214,13 @@ private static PathItem ConvertOpenApiUrlTreeNodeToPathItem(OpenApiUrlTreeNode n .ToArray(); return new PathItem(node.Path, node.DeduplicatedSegment(), children, filteredPaths.Count == 0 || Array.Exists(children, static x => x.isOperation) && children.Where(static x => x.isOperation).All(static x => x.selected)); } - protected static string GetAbsolutePath(string source) + private static string GetAbsolutePath(string source) { if (string.IsNullOrEmpty(source)) return string.Empty; return Path.IsPathRooted(source) || source.StartsWith("http", StringComparison.OrdinalIgnoreCase) ? source : NormalizeSlashesInPath(Path.Combine(Directory.GetCurrentDirectory(), source)); } - protected static string NormalizeSlashesInPath(string path) + private static string NormalizeSlashesInPath(string path) { if (string.IsNullOrEmpty(path)) return path; From ff8f0fabd59c8f232f4f6129a95651e440e62828 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Fri, 26 Apr 2024 10:45:58 +0300 Subject: [PATCH 012/150] Ensure the RPC commands use preview features if config is enabled. --- src/kiota/Rpc/Server.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/kiota/Rpc/Server.cs b/src/kiota/Rpc/Server.cs index d1ee38ca91..4464d4377c 100644 --- a/src/kiota/Rpc/Server.cs +++ b/src/kiota/Rpc/Server.cs @@ -30,6 +30,7 @@ protected KiotaConfiguration Configuration return configObject; }); private static readonly HttpClient httpClient = new(); + private static readonly Lazy IsConfigPreviewEnabled = new(() => bool.TryParse(Environment.GetEnvironmentVariable("KIOTA_CONFIG_PREVIEW"), out var isPreviewEnabled) && isPreviewEnabled); public string GetVersion() { return KiotaVersion.Current(); @@ -80,7 +81,7 @@ private static async Task GenerateClientAsync(GenerationConfiguration conf { using var fileLogger = new FileLogLogger(config.OutputPath, LogLevel.Warning); var logger = new AggregateLogger(globalLogger, fileLogger); - return await new KiotaBuilder(logger, config, httpClient, true).GenerateClientAsync(cancellationToken); + return await new KiotaBuilder(logger, config, httpClient, IsConfigPreviewEnabled.Value).GenerateClientAsync(cancellationToken); } public async Task SearchAsync(string searchTerm, bool clearCache, CancellationToken cancellationToken) { @@ -97,7 +98,7 @@ public async Task GetManifestDetailsAsync(string manifestPath, s var configuration = Configuration.Generation; configuration.ClearCache = clearCache; configuration.ApiManifestPath = $"{manifestPath}#{apiIdentifier}"; - var builder = new KiotaBuilder(logger, configuration, httpClient, true); + var builder = new KiotaBuilder(logger, configuration, httpClient, IsConfigPreviewEnabled.Value); var manifestResult = await builder.GetApiManifestDetailsAsync(cancellationToken: cancellationToken); return new ManifestResult(logger.LogEntries, manifestResult?.Item1, @@ -109,12 +110,12 @@ public async Task ShowAsync(string descriptionPath, string[] include var configuration = Configuration.Generation; configuration.ClearCache = clearCache; configuration.OpenAPIFilePath = GetAbsolutePath(descriptionPath); - var builder = new KiotaBuilder(logger, configuration, httpClient, true); + var builder = new KiotaBuilder(logger, configuration, httpClient, IsConfigPreviewEnabled.Value); var fullUrlTreeNode = await builder.GetUrlTreeNodeAsync(cancellationToken); configuration.IncludePatterns = includeFilters.ToHashSet(StringComparer.Ordinal); configuration.ExcludePatterns = excludeFilters.ToHashSet(StringComparer.Ordinal); var filteredTreeNode = configuration.IncludePatterns.Count != 0 || configuration.ExcludePatterns.Count != 0 ? - await new KiotaBuilder(new NoopLogger(), configuration, httpClient, true).GetUrlTreeNodeAsync(cancellationToken) : // openapi.net seems to have side effects between tree node and the document, we need to drop all references + await new KiotaBuilder(new NoopLogger(), configuration, httpClient, IsConfigPreviewEnabled.Value).GetUrlTreeNodeAsync(cancellationToken) : // openapi.net seems to have side effects between tree node and the document, we need to drop all references default; var filteredPaths = filteredTreeNode is null ? new HashSet() : GetOperationsFromTreeNode(filteredTreeNode).ToHashSet(StringComparer.Ordinal); var rootNode = fullUrlTreeNode != null ? ConvertOpenApiUrlTreeNodeToPathItem(fullUrlTreeNode, filteredPaths) : null; @@ -191,7 +192,7 @@ private async Task InfoInternalAsync(string descriptionPat var configuration = Configuration.Generation; configuration.ClearCache = clearCache; configuration.OpenAPIFilePath = GetAbsolutePath(descriptionPath); - var builder = new KiotaBuilder(logger, configuration, httpClient, true); + var builder = new KiotaBuilder(logger, configuration, httpClient, IsConfigPreviewEnabled.Value); var result = await builder.GetLanguagesInformationAsync(cancellationToken); if (result is not null) return result; return Configuration.Languages; From ab2f99e78d2d83696405bdc8509a378d761dccc4 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 26 Apr 2024 12:04:34 -0400 Subject: [PATCH 013/150] - updates references kiota version for CLI --- vscode/microsoft-kiota/package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 0d85aa63e9..d14ebc920e 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -3,8 +3,8 @@ "displayName": "Microsoft Kiota", "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.12.100000001", - "kiotaVersion": "1.12.0", + "version": "1.13.100000001", + "kiotaVersion": "1.13.0", "telemetryInstrumentationKey": "4c6357e0-daf9-42b5-bdfb-67878f8957b5", "icon": "images/logo.png", "engines": { @@ -259,9 +259,9 @@ } ], "view/item/context": [ - { + { "command": "kiota.openApiExplorer.closeDescription", - "when": "view == kiota.openApiExplorer && viewItem == apiTitle", + "when": "view == kiota.openApiExplorer && viewItem == apiTitle", "group": "inline@6" }, { @@ -416,7 +416,7 @@ { "command": "kiota.workspace.openWorkspaceFile", "title": "%kiota.openApiExplorer.openFile.title%" - } + } ] }, "scripts": { @@ -458,23 +458,23 @@ "runtimeDependencies": [ { "platformId": "win-x64", - "sha256": "04884ED264534CCE1708F0377809A98BFBE73F1B916432B71845CFF426B4E15D" + "sha256": "502715936A379A60ACDE5CABD3BD98583DD29FBDA35E1D9AC342F61D064C73DD" }, { "platformId": "win-x86", - "sha256": "9324A3B58889B0DD123B478608E6A59FED3147B3268C4EF37F172BC9517B1233" + "sha256": "995F25489BF5B50A76E7CA87F10C5E6EF9E95FB8CE1EA0959F6CC76436584E72" }, { "platformId": "linux-x64", - "sha256": "C093782E42DFA98574A1503D27F661F54F1C8CA92B66F6ED7B9DF475447E1769" + "sha256": "C69FB6ECE60B518DF8EA989AFBB9A475E866F514DFB4D4DDFBF681651D57D3FF" }, { "platformId": "osx-x64", - "sha256": "7911E277474EFF71D00C9983A9F3E43460F5C3C3FBB565CFE069854BA4069FCD" + "sha256": "F9548767005D6B5B8E861B3120042EC03FFF2A263E8FCA8F8402C3CE0548C72B" }, { "platformId": "osx-arm64", - "sha256": "032AFBCF63FFF1C21215277E5EAFDD1909E1EFE5213B15F52ED4BBBDF3695C0A" + "sha256": "A59C9FE6B13F7936BB655CE29893307583949C4769BDD7BE53AC41F94AE2F4AC" } ] } From d3947b3c36bb1abbc141d4306fa18e58cff98358 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 26 Apr 2024 12:24:24 -0400 Subject: [PATCH 014/150] - cleans up localization files from unused resource Signed-off-by: Vincent Biret --- vscode/microsoft-kiota/package.nls.ar.json | 3 +-- vscode/microsoft-kiota/package.nls.cs.json | 3 +-- vscode/microsoft-kiota/package.nls.es.json | 3 +-- vscode/microsoft-kiota/package.nls.fr.json | 3 +-- vscode/microsoft-kiota/package.nls.it.json | 3 +-- vscode/microsoft-kiota/package.nls.ja.json | 3 +-- vscode/microsoft-kiota/package.nls.json | 1 - vscode/microsoft-kiota/package.nls.pt.json | 3 +-- vscode/microsoft-kiota/package.nls.ru.json | 3 +-- vscode/microsoft-kiota/package.nls.sw.json | 3 +-- vscode/microsoft-kiota/package.nls.tr.json | 3 +-- vscode/microsoft-kiota/package.nls.zh-cn.json | 3 +-- 12 files changed, 11 insertions(+), 23 deletions(-) diff --git a/vscode/microsoft-kiota/package.nls.ar.json b/vscode/microsoft-kiota/package.nls.ar.json index a88a2ef3eb..3b203a39ec 100644 --- a/vscode/microsoft-kiota/package.nls.ar.json +++ b/vscode/microsoft-kiota/package.nls.ar.json @@ -8,14 +8,13 @@ "kiota.selectLock.title": "اختر ملف القفل لمستكشف الAPI", "kiota.updateClients.title": "حدث عملاء الAPI في مساحة العمل الحالية", "kiota.openApiExplorer.generateClient.title": "انشاء عميل الAPI", - "kiota.searchApiDescription.title": "ابحث عن وصف API", "kiota.openApiExplorer.addToSelectedEndpoints.title": "اضف", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "احذف", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "اضف الكل", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "احذف الكل", "kiota.openApiExplorer.closeDescription.title": "اغلق وصف API", "kiota.openApiExplorer.openDescription.title": "افتح وصف API", - "kiota.openApiExplorer.welcome": "لم يتم اختيار وصف API\n[ابحث](command:kiota.searchApiDescription)\n[افتح وصف API](command:kiota.openApiExplorer.openDescription)\n[افتح البيان](command:command:kiota.openApiExplorer.openManifestPath)\n[الصق البيان](command:kiota.openApiExplorer.pasteManifest)\n[اختر ملف](command:kiota.searchLock)", + "kiota.openApiExplorer.welcome": "لم يتم اختيار وصف API\n[ابحث](command:kiota.searchOrOpenApiDescription)\n[افتح وصف API](command:kiota.openApiExplorer.openDescription)\n[افتح البيان](command:command:kiota.openApiExplorer.openManifestPath)\n[الصق البيان](command:kiota.openApiExplorer.pasteManifest)\n[اختر ملف](command:kiota.searchLock)", "kiota.searchLock.title": "ابحث عن ملف قفل", "kiota.openApiExplorer.filterDescription.title": "قم بتصفية وصف API", "kiota.openApiExplorer.openDocumentationPage.title": "افتح صفحة الوثائق", diff --git a/vscode/microsoft-kiota/package.nls.cs.json b/vscode/microsoft-kiota/package.nls.cs.json index 6809d58fe4..fa8f77b94d 100644 --- a/vscode/microsoft-kiota/package.nls.cs.json +++ b/vscode/microsoft-kiota/package.nls.cs.json @@ -8,14 +8,13 @@ "kiota.selectLock.title": "Vyberte soubor zámku pro průzkumníka API", "kiota.updateClients.title": "Aktualizovat klienty v aktuálním pracovním prostoru", "kiota.openApiExplorer.generateClient.title": "Vygenerovat API klienta", - "kiota.searchApiDescription.title": "Hledat popis API", "kiota.openApiExplorer.addToSelectedEndpoints.title": "Přidat", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "Odebrat", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "Přidat vše", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Odebrat vše", "kiota.openApiExplorer.closeDescription.title": "Zavřít popis API", "kiota.openApiExplorer.openDescription.title": "Otevřít popis API", - "kiota.openApiExplorer.welcome": "Není vybrán žádný popis API.\n[Hledat](command:kiota.searchApiDescription)\n[Otevřít popis API](command:kiota.openApiExplorer.openDescription)\n[Otevřít manifest](command:kiota.openApiExplorer.openManifestPath)\n[Vložit manifest](command:kiota.openApiExplorer.pasteManifest)\n[Vybrat soubor se zámkem](command:kiota.searchLock)", + "kiota.openApiExplorer.welcome": "Není vybrán žádný popis API.\n[Hledat](command:kiota.searchOrOpenApiDescription)\n[Otevřít popis API](command:kiota.openApiExplorer.openDescription)\n[Otevřít manifest](command:kiota.openApiExplorer.openManifestPath)\n[Vložit manifest](command:kiota.openApiExplorer.pasteManifest)\n[Vybrat soubor se zámkem](command:kiota.searchLock)", "kiota.searchLock.title": "Hledat soubor se zámkem", "kiota.openApiExplorer.filterDescription.title": "Filtrovat popis API", "kiota.openApiExplorer.openDocumentationPage.title": "Otevřít stránku dokumentace", diff --git a/vscode/microsoft-kiota/package.nls.es.json b/vscode/microsoft-kiota/package.nls.es.json index 6a29c5dd5c..0bfec62161 100644 --- a/vscode/microsoft-kiota/package.nls.es.json +++ b/vscode/microsoft-kiota/package.nls.es.json @@ -8,14 +8,13 @@ "kiota.selectLock.title": "Seleccionar archivo de bloqueo para vista en Explorador de API", "kiota.updateClients.title": "Actualizar clientes del API en este espacio de trabajo", "kiota.openApiExplorer.generateClient.title": "Generar cliente del API", - "kiota.searchApiDescription.title": "Buscar descripciones de APIs", "kiota.openApiExplorer.addToSelectedEndpoints.title": "Agregar", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "Quitar", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "Agregar todo", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Quitar todo", "kiota.openApiExplorer.closeDescription.title": "Cerrar descripción del API", "kiota.openApiExplorer.openDescription.title": "Abrir descripción del API", - "kiota.openApiExplorer.welcome": "No ha seleccionado una descripción de API.\n[Buscar](command:kiota.searchApiDescription)\n[Abrir](command:kiota.openApiExplorer.openDescription)\n[Seleccionar archivo lock](command:kiota.searchLock)", + "kiota.openApiExplorer.welcome": "No ha seleccionado una descripción de API.\n[Buscar](command:kiota.searchOrOpenApiDescription)\n[Abrir](command:kiota.openApiExplorer.openDescription)\n[Seleccionar archivo lock](command:kiota.searchLock)", "kiota.searchLock.title": "Buscar un archivo lock", "kiota.openApiExplorer.filterDescription.title": "Filtrar descripción de API", "kiota.openApiExplorer.openDocumentationPage.title": "Abrir documentación", diff --git a/vscode/microsoft-kiota/package.nls.fr.json b/vscode/microsoft-kiota/package.nls.fr.json index 1bf8b76657..90a875105e 100644 --- a/vscode/microsoft-kiota/package.nls.fr.json +++ b/vscode/microsoft-kiota/package.nls.fr.json @@ -8,14 +8,13 @@ "kiota.selectLock.title": "Sélectionner pour la vue explorateur d'API", "kiota.updateClients.title": "Mettre à jour les clients d'API dans l'environment courant", "kiota.openApiExplorer.generateClient.title": "Générer le client d'API", - "kiota.searchApiDescription.title": "Rechercher une description d'API", "kiota.openApiExplorer.addToSelectedEndpoints.title": "Ajouter", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "Supprimer", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "Tout ajouter", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Tout supprimer", "kiota.openApiExplorer.closeDescription.title": "Fermer la description d'API", "kiota.openApiExplorer.openDescription.title": "Ouvrir une description d'API", - "kiota.openApiExplorer.welcome": "Aucune description sélectionnée.\n[Rechercher](command:kiota.searchApiDescription)\n[Ouvrir une description OpenAPI](command:kiota.openApiExplorer.openDescription)\n[Ouvrir un manifeste d'API](command:command:kiota.openApiExplorer.openManifestPath)\n[Coller un manifeste d'API](command:kiota.openApiExplorer.pasteManifest)\n[Sélectionner un fichier verrou](command:kiota.searchLock)", + "kiota.openApiExplorer.welcome": "Aucune description sélectionnée.\n[Rechercher](command:kiota.searchOrOpenApiDescription)\n[Ouvrir une description OpenAPI](command:kiota.openApiExplorer.openDescription)\n[Ouvrir un manifeste d'API](command:command:kiota.openApiExplorer.openManifestPath)\n[Coller un manifeste d'API](command:kiota.openApiExplorer.pasteManifest)\n[Sélectionner un fichier verrou](command:kiota.searchLock)", "kiota.searchLock.title": "Rechercher un fichier verrou", "kiota.openApiExplorer.filterDescription.title": "Filtrer la description", "kiota.openApiExplorer.openDocumentationPage.title": "Ouvrir la page de documentation", diff --git a/vscode/microsoft-kiota/package.nls.it.json b/vscode/microsoft-kiota/package.nls.it.json index f6e638b902..1e93c7d767 100644 --- a/vscode/microsoft-kiota/package.nls.it.json +++ b/vscode/microsoft-kiota/package.nls.it.json @@ -8,14 +8,13 @@ "kiota.selectLock.title": "Seleziona un file di lock per visualizzarlo all'interno di API Explorer", "kiota.updateClients.title": "Aggiorna i client API nel workspace corrente", "kiota.openApiExplorer.generateClient.title": "Genera un client API", - "kiota.searchApiDescription.title": "Cerca una descrizione API", "kiota.openApiExplorer.addToSelectedEndpoints.title": "Aggiungi", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "Rimuovi", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "Aggiungi tutti", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Rimuovi tutti", "kiota.openApiExplorer.closeDescription.title": "Chiudi la descrizione API", "kiota.openApiExplorer.openDescription.title": "Apri una descrizione API", - "kiota.openApiExplorer.welcome": "Nessuna descrizione delle API selezionata.\n[Search](command:kiota.searchApiDescription)\n[Apri una descrizione API](command:kiota.openApiExplorer.openDescription)\n[Apri un manifest](command:kiota.openApiExplorer.openManifestPath)\n[Copia un manifest](command:kiota.openApiExplorer.pasteManifest)\n[Seleziona un file di lock](command:kiota.searchLock)", + "kiota.openApiExplorer.welcome": "Nessuna descrizione delle API selezionata.\n[Search](command:kiota.searchOrOpenApiDescription)\n[Apri una descrizione API](command:kiota.openApiExplorer.openDescription)\n[Apri un manifest](command:kiota.openApiExplorer.openManifestPath)\n[Copia un manifest](command:kiota.openApiExplorer.pasteManifest)\n[Seleziona un file di lock](command:kiota.searchLock)", "kiota.searchLock.title": "Cerca il file di lock", "kiota.openApiExplorer.filterDescription.title": "Filtra la descrizione delle API", "kiota.openApiExplorer.openDocumentationPage.title": "Apri la pagina di documentazione", diff --git a/vscode/microsoft-kiota/package.nls.ja.json b/vscode/microsoft-kiota/package.nls.ja.json index 6dfc8041a8..4f5f26e423 100644 --- a/vscode/microsoft-kiota/package.nls.ja.json +++ b/vscode/microsoft-kiota/package.nls.ja.json @@ -8,14 +8,13 @@ "kiota.selectLock.title": "APIエクスプローラビューのロックファイルを選択", "kiota.updateClients.title": "現在のワークスペースでAPIクライアントを更新", "kiota.openApiExplorer.generateClient.title": "APIクライアントを生成", - "kiota.searchApiDescription.title": "API仕様書を検索", "kiota.openApiExplorer.addToSelectedEndpoints.title": "追加", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "削除", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "すべて追加", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "すべて削除", "kiota.openApiExplorer.closeDescription.title": "API仕様書を閉じる", "kiota.openApiExplorer.openDescription.title": "API仕様書を開く", - "kiota.openApiExplorer.welcome": "API仕様書が選択されていません。\n[検索](command:kiota.searchApiDescription)\n[API仕様書を開く](command:kiota.openApiExplorer.openDescription)\n[マニフェストを開く](command:kiota.openApiExplorer.openManifestPath)\n[マニフェストを貼り付け](command:kiota.openApiExplorer.pasteManifest)\n[ロックファイルを選択](command:kiota.searchLock)", + "kiota.openApiExplorer.welcome": "API仕様書が選択されていません。\n[検索](command:kiota.searchOrOpenApiDescription)\n[API仕様書を開く](command:kiota.openApiExplorer.openDescription)\n[マニフェストを開く](command:kiota.openApiExplorer.openManifestPath)\n[マニフェストを貼り付け](command:kiota.openApiExplorer.pasteManifest)\n[ロックファイルを選択](command:kiota.searchLock)", "kiota.searchLock.title": "ロックファイルを検索", "kiota.openApiExplorer.filterDescription.title": "API仕様書をフィルタ", "kiota.openApiExplorer.openDocumentationPage.title": "ドキュメントページを開く", diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index f59f00e5b1..8b6f4a82cc 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -8,7 +8,6 @@ "kiota.selectLock.title": "Select lock file for API explorer view", "kiota.updateClients.title": "Update API clients in the current workspace", "kiota.openApiExplorer.generateClient.title": "Generate API client", - "kiota.searchApiDescription.title": "Search for an API description", "kiota.openApiExplorer.addToSelectedEndpoints.title": "Add", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "Remove", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "Add all", diff --git a/vscode/microsoft-kiota/package.nls.pt.json b/vscode/microsoft-kiota/package.nls.pt.json index 3315187181..a5b2500248 100644 --- a/vscode/microsoft-kiota/package.nls.pt.json +++ b/vscode/microsoft-kiota/package.nls.pt.json @@ -8,14 +8,13 @@ "kiota.selectLock.title": "Selecione o arquivo 'lock' para visualizar o explorador de API", "kiota.updateClients.title": "Atualizar os clientes de APIs no espaço de trabalho atual", "kiota.openApiExplorer.generateClient.title": "Gerar cliente da API", - "kiota.searchApiDescription.title": "Procurar por uma descrição de API", "kiota.openApiExplorer.addToSelectedEndpoints.title": "Adicionar", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "Remover", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "Adicionar todos", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Remover todos", "kiota.openApiExplorer.closeDescription.title": "Fechar a descrição da API", "kiota.openApiExplorer.openDescription.title": "Abrir a descrição da API", - "kiota.openApiExplorer.welcome": "Nenhuma descrição de API selecionada.\n[Procurar](command:kiota.searchApiDescription)\n[Abrir a descrição da API](command:kiota.openApiExplorer.openDescription)\n[Abrir um manifesto](command:command:kiota.openApiExplorer.openManifestPath)\n[Colar um manifesto](command:kiota.openApiExplorer.pasteManifest)\n[Selecionar arquivo lock](command:kiota.searchLock)", + "kiota.openApiExplorer.welcome": "Nenhuma descrição de API selecionada.\n[Procurar](command:kiota.searchOrOpenApiDescription)\n[Abrir a descrição da API](command:kiota.openApiExplorer.openDescription)\n[Abrir um manifesto](command:command:kiota.openApiExplorer.openManifestPath)\n[Colar um manifesto](command:kiota.openApiExplorer.pasteManifest)\n[Selecionar arquivo lock](command:kiota.searchLock)", "kiota.searchLock.title": "Buscar um arquivo lock", "kiota.openApiExplorer.filterDescription.title": "Filtrar descrição da API", "kiota.openApiExplorer.openDocumentationPage.title": "Abrir página de documentação", diff --git a/vscode/microsoft-kiota/package.nls.ru.json b/vscode/microsoft-kiota/package.nls.ru.json index b5f5d795dd..7f9d7b6d23 100644 --- a/vscode/microsoft-kiota/package.nls.ru.json +++ b/vscode/microsoft-kiota/package.nls.ru.json @@ -8,14 +8,13 @@ "kiota.selectLock.title": "Выберите файл блокировки для просмотра API-исследователя", "kiota.updateClients.title": "Обновите API-клиенты в текущем рабочем пространстве", "kiota.openApiExplorer.generateClient.title": "Создать клиент API", - "kiota.searchApiDescription.title": "Искать описание API", "kiota.openApiExplorer.addToSelectedEndpoints.title": "Добавить", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "Удалить", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "Добавить всё", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Удалить всё", "kiota.openApiExplorer.closeDescription.title": "Закрыть описание API", "kiota.openApiExplorer.openDescription.title": "Открыть описание API", - "kiota.openApiExplorer.welcome": "Не выбрано описание API.\n[поиск](command:kiota.searchApiDescription)\n[Открыть описание API](command:kiota.openApiExplorer.openDescription)\n[Вставьте манифест](command:kiota.openApiExplorer.openManifestPath)\n[Откройте манифест](command:kiota.openApiExplorer.pasteManifest)\n[выделить](command:kiota.searchLock)", + "kiota.openApiExplorer.welcome": "Не выбрано описание API.\n[поиск](command:kiota.searchOrOpenApiDescription)\n[Открыть описание API](command:kiota.openApiExplorer.openDescription)\n[Вставьте манифест](command:kiota.openApiExplorer.openManifestPath)\n[Откройте манифест](command:kiota.openApiExplorer.pasteManifest)\n[выделить](command:kiota.searchLock)", "kiota.searchLock.title": "Искать файл блокировки", "kiota.openApiExplorer.filterDescription.title": "Отфильтровать описание API", "kiota.openApiExplorer.openDocumentationPage.title": "Открыть страницу документации", diff --git a/vscode/microsoft-kiota/package.nls.sw.json b/vscode/microsoft-kiota/package.nls.sw.json index 1f11640bf3..4fafae3e48 100644 --- a/vscode/microsoft-kiota/package.nls.sw.json +++ b/vscode/microsoft-kiota/package.nls.sw.json @@ -8,14 +8,13 @@ "kiota.selectLock.title": "Chagua faili ya kufunga ili uone kichunguzi cha API", "kiota.updateClients.title": "Sasisha wateja wa API katika nafasi ya kazi", "kiota.openApiExplorer.generateClient.title": "Tengeneza mteja wa API", - "kiota.searchApiDescription.title": "Tafuta maelezo ya API", "kiota.openApiExplorer.addToSelectedEndpoints.title": "Ongeza", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "Ondoa", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "Ongeza yote", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Ondoa yote", "kiota.openApiExplorer.closeDescription.title": "Funga maelezo ya API", "kiota.openApiExplorer.openDescription.title": "Fungua maelezo ya API", - "kiota.openApiExplorer.welcome": "Hakuna maelezo ya API yaliyochaguliwa.\n[Tafuta](command:kiota.searchApiDescription)\n[Fungua maelezo ya API](command:kiota.openApiExplorer.openDescription)\n[Fungua faili ya dhahiri](command:kiota.openApiExplorer.openManifestPath)\\n[Bandika faili ya dhahiri](command:kiota.openApiExplorer.pasteManifest)\n[Chagua faili ya kufunga](command:kiota.searchLock)", + "kiota.openApiExplorer.welcome": "Hakuna maelezo ya API yaliyochaguliwa.\n[Tafuta](command:kiota.searchOrOpenApiDescription)\n[Fungua maelezo ya API](command:kiota.openApiExplorer.openDescription)\n[Fungua faili ya dhahiri](command:kiota.openApiExplorer.openManifestPath)\\n[Bandika faili ya dhahiri](command:kiota.openApiExplorer.pasteManifest)\n[Chagua faili ya kufunga](command:kiota.searchLock)", "kiota.searchLock.title": "Tafuta faili ya kufunga", "kiota.openApiExplorer.filterDescription.title": "Chuja maelezo ya API", "kiota.openApiExplorer.openDocumentationPage.title": "Fungua ukurasa wa nyaraka", diff --git a/vscode/microsoft-kiota/package.nls.tr.json b/vscode/microsoft-kiota/package.nls.tr.json index a4965405bd..0b5cf84a28 100644 --- a/vscode/microsoft-kiota/package.nls.tr.json +++ b/vscode/microsoft-kiota/package.nls.tr.json @@ -8,14 +8,13 @@ "kiota.selectLock.title": "API gezgini görünümü için kilit dosyasını seçin", "kiota.updateClients.title": "Mevcut çalışma alanındaki API istecilerini güncelle", "kiota.openApiExplorer.generateClient.title": "API istemcisi oluştur", - "kiota.searchApiDescription.title": "API açıklaması ara", "kiota.openApiExplorer.addToSelectedEndpoints.title": "Ekle", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "Kaldır", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "Tümünü ekle", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Tümünü kaldır", "kiota.openApiExplorer.closeDescription.title": "API açıklamasını kapat", "kiota.openApiExplorer.openDescription.title": "API açıklamasını aç", - "kiota.openApiExplorer.welcome": "Seçili bir API açıklaması yok.\n[Ara](command:kiota.searchApiDescription)\n[Aç](command:kiota.openApiExplorer.openDescription)\n[Kilit dosyasını seç](command:kiota.searchLock)", + "kiota.openApiExplorer.welcome": "Seçili bir API açıklaması yok.\n[Ara](command:kiota.searchOrOpenApiDescription)\n[Aç](command:kiota.openApiExplorer.openDescription)\n[Kilit dosyasını seç](command:kiota.searchLock)", "kiota.searchLock.title": "Kilit dosyası arayın", "kiota.openApiExplorer.filterDescription.title": "API açıklaması filtrele", "kiota.openApiExplorer.openDocumentationPage.title": "API belgelerini aç", diff --git a/vscode/microsoft-kiota/package.nls.zh-cn.json b/vscode/microsoft-kiota/package.nls.zh-cn.json index f24ca8c9aa..044854653c 100644 --- a/vscode/microsoft-kiota/package.nls.zh-cn.json +++ b/vscode/microsoft-kiota/package.nls.zh-cn.json @@ -8,14 +8,13 @@ "kiota.selectLock.title": "选择API资源浏览器的锁定文件", "kiota.updateClients.title": "更新当前工作区API客户端", "kiota.openApiExplorer.generateClient.title": "建立API客户端", - "kiota.searchApiDescription.title": "搜索API描述", "kiota.openApiExplorer.addToSelectedEndpoints.title": "添加", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "删除", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "添加所有", "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "删除所有", "kiota.openApiExplorer.closeDescription.title": "关闭API描述文档", "kiota.openApiExplorer.openDescription.title": "打开API描述文档", - "kiota.openApiExplorer.welcome": "无API描述文档选择.\n[搜索](command:kiota.searchApiDescription)\n[打开API描述文档](command:kiota.openApiExplorer.openDescription)\n[打开清单](command:command:kiota.openApiExplorer.openManifestPath)\n[粘贴清单](command:kiota.openApiExplorer.pasteManifest)\n[选择锁定文件](command:kiota.searchLock)", + "kiota.openApiExplorer.welcome": "无API描述文档选择.\n[搜索](command:kiota.searchOrOpenApiDescription)\n[打开API描述文档](command:kiota.openApiExplorer.openDescription)\n[打开清单](command:command:kiota.openApiExplorer.openManifestPath)\n[粘贴清单](command:kiota.openApiExplorer.pasteManifest)\n[选择锁定文件](command:kiota.searchLock)", "kiota.searchLock.title": "搜索锁定文件", "kiota.openApiExplorer.filterDescription.title": "筛选API描述", "kiota.openApiExplorer.openDocumentationPage.title": "打开文档页", From d440b29e1f2c3a529c74122600315c702fbda6fd Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 26 Apr 2024 12:25:10 -0400 Subject: [PATCH 015/150] - removes unimplemented command Signed-off-by: Vincent Biret --- vscode/microsoft-kiota/package.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index d14ebc920e..f0740ef7eb 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -359,12 +359,6 @@ "enablement": "kiota.openApiExplorer.showIcons", "icon": "$(filter)" }, - { - "command": "kiota.searchApiDescription", - "category": "Kiota", - "title": "%kiota.searchApiDescription.title%", - "icon": "$(search)" - }, { "command": "kiota.openApiExplorer.addToSelectedEndpoints", "category": "Kiota", From 807fc0097718d18258a79e17ed019d544f68d3ce Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 26 Apr 2024 12:25:32 -0400 Subject: [PATCH 016/150] - adds the environment variable passing to the json RPC server Signed-off-by: Vincent Biret --- vscode/microsoft-kiota/src/kiotaInterop.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/kiotaInterop.ts b/vscode/microsoft-kiota/src/kiotaInterop.ts index a7965067a5..0df8200f8c 100644 --- a/vscode/microsoft-kiota/src/kiotaInterop.ts +++ b/vscode/microsoft-kiota/src/kiotaInterop.ts @@ -7,7 +7,12 @@ export async function connectToKiota(context: vscode.ExtensionContext, callba const kiotaPath = getKiotaPath(context); await ensureKiotaIsPresent(context); const childProcess = cp.spawn(kiotaPath, ["rpc"],{ - cwd: vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 ? vscode.workspace.workspaceFolders[0].uri.fsPath : undefined + cwd: vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 ? vscode.workspace.workspaceFolders[0].uri.fsPath : undefined, + env: { + ...process.env, + // eslint-disable-next-line @typescript-eslint/naming-convention + KIOTA_CONFIG_PREVIEW: "true", + } }); let connection = rpc.createMessageConnection( new rpc.StreamMessageReader(childProcess.stdout), From e93920fd2b102a0756923d6e4b3fc9e2f3203001 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 26 Apr 2024 12:36:34 -0400 Subject: [PATCH 017/150] - refactors to constant Signed-off-by: Vincent Biret --- src/kiota/KiotaHost.cs | 3 ++- src/kiota/Rpc/Server.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kiota/KiotaHost.cs b/src/kiota/KiotaHost.cs index 5923772de7..8dda187bf3 100644 --- a/src/kiota/KiotaHost.cs +++ b/src/kiota/KiotaHost.cs @@ -11,7 +11,8 @@ namespace kiota; public static partial class KiotaHost { - internal static readonly Lazy IsConfigPreviewEnabled = new(() => bool.TryParse(Environment.GetEnvironmentVariable("KIOTA_CONFIG_PREVIEW"), out var isPreviewEnabled) && isPreviewEnabled); + internal const string KiotaPreviewEnvironmentVariable = "KIOTA_CONFIG_PREVIEW"; + internal static readonly Lazy IsConfigPreviewEnabled = new(() => bool.TryParse(Environment.GetEnvironmentVariable(KiotaPreviewEnvironmentVariable), out var isPreviewEnabled) && isPreviewEnabled); public static RootCommand GetRootCommand() { var rootCommand = new RootCommand(); diff --git a/src/kiota/Rpc/Server.cs b/src/kiota/Rpc/Server.cs index 4464d4377c..8c32d3b059 100644 --- a/src/kiota/Rpc/Server.cs +++ b/src/kiota/Rpc/Server.cs @@ -30,7 +30,7 @@ protected KiotaConfiguration Configuration return configObject; }); private static readonly HttpClient httpClient = new(); - private static readonly Lazy IsConfigPreviewEnabled = new(() => bool.TryParse(Environment.GetEnvironmentVariable("KIOTA_CONFIG_PREVIEW"), out var isPreviewEnabled) && isPreviewEnabled); + private static readonly Lazy IsConfigPreviewEnabled = new(() => bool.TryParse(Environment.GetEnvironmentVariable(KiotaHost.KiotaPreviewEnvironmentVariable), out var isPreviewEnabled) && isPreviewEnabled); public string GetVersion() { return KiotaVersion.Current(); From cc0f413187af4c4d111b0886819f85877dd1bfd4 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 26 Apr 2024 14:01:17 -0400 Subject: [PATCH 018/150] - removes serializers in preview mode Signed-off-by: Vincent Biret --- src/kiota/Rpc/Server.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/kiota/Rpc/Server.cs b/src/kiota/Rpc/Server.cs index 8c32d3b059..f45df4b580 100644 --- a/src/kiota/Rpc/Server.cs +++ b/src/kiota/Rpc/Server.cs @@ -151,14 +151,19 @@ public async Task> GenerateAsync(string openAPIFilePath, string o configuration.ClearCache = clearCache; configuration.ExcludeBackwardCompatible = excludeBackwardCompatible; configuration.IncludeAdditionalData = includeAdditionalData; - if (disabledValidationRules is not null && disabledValidationRules.Length != 0) + if (disabledValidationRules is { Length: > 0 }) configuration.DisabledValidationRules = disabledValidationRules.ToHashSet(StringComparer.OrdinalIgnoreCase); - if (serializers is not null && serializers.Length != 0) + if (serializers is { Length: > 0 }) configuration.Serializers = serializers.ToHashSet(StringComparer.OrdinalIgnoreCase); - if (deserializers is not null && deserializers.Length != 0) + if (deserializers is { Length: > 0 }) configuration.Deserializers = deserializers.ToHashSet(StringComparer.OrdinalIgnoreCase); - if (structuredMimeTypes is not null && structuredMimeTypes.Length != 0) + if (structuredMimeTypes is { Length: > 0 }) configuration.StructuredMimeTypes = new(structuredMimeTypes); + if (IsConfigPreviewEnabled.Value) + { + configuration.Serializers.Clear(); + configuration.Deserializers.Clear(); + } if (!string.IsNullOrEmpty(clientClassName)) configuration.ClientClassName = clientClassName; if (!string.IsNullOrEmpty(clientNamespaceName)) From e71d83f6951f76eaa414986c002a6389e20009e0 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 26 Apr 2024 14:17:12 -0400 Subject: [PATCH 019/150] - code linting --- vscode/microsoft-kiota/src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 2a0447c05a..fc2d6247e1 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -47,7 +47,7 @@ export async function activate( context.extensionUri ); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); - new KiotaWorkspace(context), + new KiotaWorkspace(context); context.subscriptions.push( vscode.window.registerUriHandler({ handleUri: async (uri: vscode.Uri) => { From cd183a0c1380408c43181d452026a652c00cf011 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 26 Apr 2024 15:07:25 -0400 Subject: [PATCH 020/150] - initial plugin generation Signed-off-by: Vincent Biret --- src/kiota/Rpc/IServer.cs | 1 + src/kiota/Rpc/Server.cs | 40 ++++ vscode/microsoft-kiota/src/extension.ts | 187 ++++++++++++------- vscode/microsoft-kiota/src/generatePlugin.ts | 34 ++++ vscode/microsoft-kiota/src/kiotaInterop.ts | 21 +++ vscode/microsoft-kiota/src/steps.ts | 36 +++- 6 files changed, 252 insertions(+), 67 deletions(-) create mode 100644 vscode/microsoft-kiota/src/generatePlugin.ts diff --git a/src/kiota/Rpc/IServer.cs b/src/kiota/Rpc/IServer.cs index 52f1409e41..5c467acdbe 100644 --- a/src/kiota/Rpc/IServer.cs +++ b/src/kiota/Rpc/IServer.cs @@ -12,4 +12,5 @@ internal interface IServer Task GetManifestDetailsAsync(string manifestPath, string apiIdentifier, bool clearCache, CancellationToken cancellationToken); Task> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, CancellationToken cancellationToken); Task InfoForDescriptionAsync(string descriptionPath, bool clearCache, CancellationToken cancellationToken); + Task> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, CancellationToken cancellationToken); } diff --git a/src/kiota/Rpc/Server.cs b/src/kiota/Rpc/Server.cs index f45df4b580..e717529237 100644 --- a/src/kiota/Rpc/Server.cs +++ b/src/kiota/Rpc/Server.cs @@ -151,6 +151,7 @@ public async Task> GenerateAsync(string openAPIFilePath, string o configuration.ClearCache = clearCache; configuration.ExcludeBackwardCompatible = excludeBackwardCompatible; configuration.IncludeAdditionalData = includeAdditionalData; + configuration.Operation = ConsumerOperation.Add; //TODO should be updated to edit in the edit scenario if (disabledValidationRules is { Length: > 0 }) configuration.DisabledValidationRules = disabledValidationRules.ToHashSet(StringComparer.OrdinalIgnoreCase); if (serializers is { Length: > 0 }) @@ -182,6 +183,45 @@ public async Task> GenerateAsync(string openAPIFilePath, string o } return logger.LogEntries; } + public async Task> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, CancellationToken cancellationToken) + { + var globalLogger = new ForwardedLogger(); + var configuration = Configuration.Generation; + configuration.PluginTypes = pluginTypes.ToHashSet(); + configuration.OpenAPIFilePath = GetAbsolutePath(openAPIFilePath); + configuration.OutputPath = GetAbsolutePath(outputPath); + if (!string.IsNullOrEmpty(clientClassName)) + configuration.ClientClassName = clientClassName; + // configuration.SkipGeneration = skipGeneration; + configuration.CleanOutput = cleanOutput; + configuration.ClearCache = clearCache; + configuration.Operation = ConsumerOperation.Add; //TODO should be updated to edit in the edit scenario + if (disabledValidationRules is { Length: > 0 }) + configuration.DisabledValidationRules = disabledValidationRules.ToHashSet(StringComparer.OrdinalIgnoreCase); + if (pluginTypes is { Length: > 0 }) + configuration.PluginTypes = pluginTypes.ToHashSet(); + if (includePatterns is { Length: > 0 }) + configuration.IncludePatterns = includePatterns.Select(static x => x.TrimQuotes()).ToHashSet(StringComparer.OrdinalIgnoreCase); + if (excludePatterns is { Length: > 0 }) + configuration.ExcludePatterns = excludePatterns.Select(static x => x.TrimQuotes()).ToHashSet(StringComparer.OrdinalIgnoreCase); + configuration.OpenAPIFilePath = GetAbsolutePath(configuration.OpenAPIFilePath); + configuration.OutputPath = NormalizeSlashesInPath(GetAbsolutePath(configuration.OutputPath)); + try + { + using var fileLogger = new FileLogLogger(configuration.OutputPath, LogLevel.Warning); + var logger = new AggregateLogger(globalLogger, fileLogger); + var result = await new KiotaBuilder(logger, configuration, httpClient, IsConfigPreviewEnabled.Value).GeneratePluginAsync(cancellationToken); + if (result) + logger.LogInformation("Generation completed successfully"); + else + logger.LogInformation("Generation skipped as --skip-generation was passed"); + } + catch (Exception ex) + { + globalLogger.LogCritical("error adding the client: {exceptionMessage}", ex.Message); + } + return globalLogger.LogEntries; + } public LanguagesInformation Info() { return Configuration.Languages; diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index fc2d6247e1..4ba669a169 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -10,10 +10,13 @@ import { getLogEntriesForLevel, KiotaGenerationLanguage, KiotaLogEntry, + KiotaPluginType, + LanguageInformation, LogLevel, parseGenerationLanguage, + parsePluginType, } from "./kiotaInterop"; -import { filterSteps, generateSteps, openManifestSteps, openSteps, searchLockSteps, searchSteps, selectApiManifestKey } from "./steps"; +import { GenerateState, GenerationType, filterSteps, generateSteps, openManifestSteps, openSteps, parseGenerationType, searchLockSteps, searchSteps, selectApiManifestKey } from "./steps"; import { getKiotaVersion } from "./getKiotaVersion"; import { searchDescription } from "./searchDescription"; import { generateClient } from "./generateClient"; @@ -21,8 +24,9 @@ import { getLanguageInformation, getLanguageInformationForDescription } from "./ import { DependenciesViewProvider } from "./dependenciesViewProvider"; import { updateClients } from "./updateClients"; import { ApiManifest } from "./apiManifest"; -import { getExtensionSettings } from "./extensionSettings"; +import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; import { KiotaWorkspace } from "./workspaceTreeProvider"; +import { generatePlugin } from "./generatePlugin"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; @@ -169,6 +173,7 @@ export async function activate( }, languagesInformation ); + const generationType = parseGenerationType(config.generationType); const outputPath = typeof config.outputPath === "string" ? config.outputPath : "./output"; @@ -179,68 +184,20 @@ export async function activate( ); return; } - const language = - typeof config.language === "string" - ? parseGenerationLanguage(config.language) - : KiotaGenerationLanguage.CSharp; - const settings = getExtensionSettings(extensionId); - const result = await vscode.window.withProgress({ - location: vscode.ProgressLocation.Notification, - cancellable: false, - title: vscode.l10n.t("Generating client...") - }, async (progress, _) => { - const start = performance.now(); - const result = await generateClient( - context, - openApiTreeProvider.descriptionUrl, - outputPath, - language, - selectedPaths, - [], - typeof config.clientClassName === "string" - ? config.clientClassName - : "ApiClient", - typeof config.clientNamespaceName === "string" - ? config.clientNamespaceName - : "ApiSdk", - settings.backingStore, - settings.clearCache, - settings.cleanOutput, - settings.excludeBackwardCompatible, - settings.disableValidationRules, - settings.languagesSerializationConfiguration[language].serializers, - settings.languagesSerializationConfiguration[language].deserializers, - settings.structuredMimeTypes, - settings.includeAdditionalData - ); - const duration = performance.now() - start; - const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; - reporter.sendRawTelemetryEvent(`${extensionId}.generateClient.completed`, { - "language": generationLanguageToString(language), - "errorsCount": errorsCount.toString(), - }, { - "duration": duration, - }); - return result; - }); - languagesInformation = await getLanguageInformationForDescription( - context, - openApiTreeProvider.descriptionUrl, - settings.clearCache - ); - if (languagesInformation) { - dependenciesInfoProvider.update(languagesInformation, language); - await vscode.commands.executeCommand(treeViewFocusCommand); - } - if (typeof config.outputPath === "string" && !openApiTreeProvider.isLockFileLoaded && - vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 && - result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) { - await openApiTreeProvider.loadLockFile(path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, config.outputPath, kiotaLockFile)); - } - if (result) - { - await exportLogsAndShowErrors(result); + const settings = getExtensionSettings(extensionId); + switch (generationType) { + case GenerationType.Client: + await generateClientAndRefreshUI(config, settings, outputPath, selectedPaths); + break; + case GenerationType.Plugin: + await generatePluginAndRefreshUI(config, settings, outputPath, selectedPaths); + break; + default: + await vscode.window.showErrorMessage( + vscode.l10n.t("Invalid generation type") + ); + break; } } ), @@ -303,6 +260,110 @@ export async function activate( ) ); + async function generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { + const pluginTypes = config.pluginTypes?.map(x => parsePluginType(x)) ?? [KiotaPluginType.Microsoft];//TODO remove the default once we have the question in steps + const result = await vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Generating plugin...") + }, async (progress, _) => { + const start = performance.now(); + const result = await generatePlugin( + context, + openApiTreeProvider.descriptionUrl, + outputPath, + pluginTypes, + selectedPaths, + [], + typeof config.clientClassName === "string" + ? config.clientClassName + : "ApiClient", + settings.clearCache, + settings.cleanOutput, + settings.disableValidationRules, + ); + const duration = performance.now() - start; + const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; + reporter.sendRawTelemetryEvent(`${extensionId}.generatePlugin.completed`, { + //TODO log plugin type + "errorsCount": errorsCount.toString(), + }, { + "duration": duration, + }); + return result; + }); + //TODO refresh the kiota workspace + if (result) + { + await exportLogsAndShowErrors(result); + } + } + async function generateClientAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { + const language = + typeof config.language === "string" + ? parseGenerationLanguage(config.language) + : KiotaGenerationLanguage.CSharp; + const result = await vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Generating client...") + }, async (progress, _) => { + const start = performance.now(); + const result = await generateClient( + context, + openApiTreeProvider.descriptionUrl, + outputPath, + language, + selectedPaths, + [], + typeof config.clientClassName === "string" + ? config.clientClassName + : "ApiClient", + typeof config.clientNamespaceName === "string" + ? config.clientNamespaceName + : "ApiSdk", + settings.backingStore, + settings.clearCache, + settings.cleanOutput, + settings.excludeBackwardCompatible, + settings.disableValidationRules, + settings.languagesSerializationConfiguration[language].serializers, + settings.languagesSerializationConfiguration[language].deserializers, + settings.structuredMimeTypes, + settings.includeAdditionalData + ); + const duration = performance.now() - start; + const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; + reporter.sendRawTelemetryEvent(`${extensionId}.generateClient.completed`, { + "language": generationLanguageToString(language), + "errorsCount": errorsCount.toString(), + }, { + "duration": duration, + }); + return result; + }); + + let languagesInformation = await getLanguageInformationForDescription( + context, + openApiTreeProvider.descriptionUrl, + settings.clearCache + ); + if (languagesInformation) { + dependenciesInfoProvider.update(languagesInformation, language); + await vscode.commands.executeCommand(treeViewFocusCommand); + } + if (typeof config.outputPath === "string" && !openApiTreeProvider.isLockFileLoaded && + vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 && + result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) { + await openApiTreeProvider.loadLockFile(path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, config.outputPath, kiotaLockFile)); + //TODO this will need to be updated to refresh the workspace instead + } + if (result) + { + await exportLogsAndShowErrors(result); + } + } + // create a new status bar item that we can now manage kiotaStatusBarItem = vscode.window.createStatusBarItem( vscode.StatusBarAlignment.Right, diff --git a/vscode/microsoft-kiota/src/generatePlugin.ts b/vscode/microsoft-kiota/src/generatePlugin.ts new file mode 100644 index 0000000000..5329cc4432 --- /dev/null +++ b/vscode/microsoft-kiota/src/generatePlugin.ts @@ -0,0 +1,34 @@ +import { connectToKiota, GenerationConfiguration, KiotaGenerationLanguage, KiotaLogEntry, KiotaPluginType } from "./kiotaInterop"; +import * as rpc from "vscode-jsonrpc/node"; +import * as vscode from "vscode"; + +export function generatePlugin(context: vscode.ExtensionContext, + descriptionPath: string, + output: string, + pluginTypes: KiotaPluginType[], + includeFilters: string[], + excludeFilters: string[], + clientClassName: string, + clearCache: boolean, + cleanOutput: boolean, + disableValidationRules: string[]): Promise { + return connectToKiota(context, async (connection) => { + const request = new rpc.RequestType1( + "GeneratePlugin" + ); + return await connection.sendRequest( + request, + { + pluginTypes: pluginTypes, + cleanOutput: cleanOutput, + clearCache: clearCache, + clientClassName: clientClassName, + disabledValidationRules: disableValidationRules, + excludePatterns: excludeFilters, + includePatterns: includeFilters, + openAPIFilePath: descriptionPath, + outputPath: output, + } as GenerationConfiguration, + ); + }); +}; \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/kiotaInterop.ts b/vscode/microsoft-kiota/src/kiotaInterop.ts index 0df8200f8c..83e8df13fc 100644 --- a/vscode/microsoft-kiota/src/kiotaInterop.ts +++ b/vscode/microsoft-kiota/src/kiotaInterop.ts @@ -105,6 +105,26 @@ export enum KiotaGenerationLanguage { // eslint-disable-next-line @typescript-eslint/naming-convention CLI = 8, } +export enum KiotaPluginType { + // eslint-disable-next-line @typescript-eslint/naming-convention + OpenAI = 0, + // eslint-disable-next-line @typescript-eslint/naming-convention + ApiManifest = 1, + // eslint-disable-next-line @typescript-eslint/naming-convention + Microsoft = 2, +} +export function parsePluginType(value: string): KiotaPluginType { + switch (value) { + case "OpenAI": + return KiotaPluginType.OpenAI; + case "ApiManifest": + return KiotaPluginType.ApiManifest; + case "Microsoft": + return KiotaPluginType.Microsoft; + default: + throw new Error("unknown plugin type"); + } +} export function generationLanguageToString(language: KiotaGenerationLanguage): string { switch (language) { case KiotaGenerationLanguage.CSharp: @@ -258,4 +278,5 @@ export interface GenerationConfiguration { serializers: string[]; structuredMimeTypes: string[]; usesBackingStore: boolean; + pluginTypes: KiotaPluginType[]; } \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index b91b93e42a..ca794cfdd4 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -211,14 +211,18 @@ export async function generateSteps(existingConfiguration: Partial inputClientClassName(input, state); + state.generationType = "client"; + return (input: MultiStepInput) => inputClientClassName(input, state); } else if(option.label === 'Generate a plugin') { + state.generationType = "plugin"; return (input: MultiStepInput) => inputPluginName(input, state); } - else if(option.label === 'Generate an API manifest') { return; } + else if(option.label === 'Generate an API manifest') { + state.generationType = "apimanifest"; + return; + } } async function inputClientClassName(input: MultiStepInput, state: Partial) { state.clientClassName = await input.showInputBox({ @@ -350,14 +354,38 @@ interface SelectApiManifestKey extends BaseStepsState { selectedKey: string; } -interface GenerateState extends BaseStepsState { +export interface GenerateState extends BaseStepsState { generationType: QuickPickItem | string; + pluginTypes: string[]; //TODO update type when we have multi-select pluginName:string; clientClassName: string; clientNamespaceName: QuickPickItem | string; language: QuickPickItem | string; outputPath: QuickPickItem | string; } +export enum GenerationType { + // eslint-disable-next-line @typescript-eslint/naming-convention + Client = 0, + // eslint-disable-next-line @typescript-eslint/naming-convention + Plugin = 1, + // eslint-disable-next-line @typescript-eslint/naming-convention + ApiManifest = 2, +} +export function parseGenerationType(generationType: string | QuickPickItem | undefined): GenerationType { + if(typeof generationType !== 'string') { + throw new Error('generationType has not been selected yet'); + } + switch(generationType) { + case "client": + return GenerationType.Client; + case "plugin": + return GenerationType.Plugin; + case "apimanifest": + return GenerationType.ApiManifest; + default: + throw new Error(`Unknown generation type ${generationType}`); + } +} class InputFlowAction { static back = new InputFlowAction(); static cancel = new InputFlowAction(); From 161bae16f2f2f4378efcb6b2858e22815718d444 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Tue, 30 Apr 2024 16:58:47 +0300 Subject: [PATCH 021/150] Fixed the collection of plugin name --- vscode/microsoft-kiota/src/extension.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 4ba669a169..b80a99fc8d 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -275,8 +275,8 @@ export async function activate( pluginTypes, selectedPaths, [], - typeof config.clientClassName === "string" - ? config.clientClassName + typeof config.pluginName === "string" + ? config.pluginName : "ApiClient", settings.clearCache, settings.cleanOutput, From 88dde13e174c7f303775bd576a0d859722d20d06 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 2 May 2024 16:06:17 +0300 Subject: [PATCH 022/150] rename title string --- vscode/microsoft-kiota/package.nls.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index 8b6f4a82cc..a182f66c42 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -7,7 +7,7 @@ "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "Select lock file for API explorer view", "kiota.updateClients.title": "Update API clients in the current workspace", - "kiota.openApiExplorer.generateClient.title": "Generate API client", + "kiota.openApiExplorer.generateClient.title": "Generate", "kiota.openApiExplorer.addToSelectedEndpoints.title": "Add", "kiota.openApiExplorer.removeFromSelectedEndpoints.title": "Remove", "kiota.openApiExplorer.addAllToSelectedEndpoints.title": "Add all", From 056540dc7a63d1172dae973bc89783098fc9b97c Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 2 May 2024 16:07:26 +0300 Subject: [PATCH 023/150] Add plugin type step --- vscode/microsoft-kiota/src/extension.ts | 8 ++++--- vscode/microsoft-kiota/src/steps.ts | 30 +++++++++++++++++-------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index b80a99fc8d..dcc39e4aa3 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -228,6 +228,7 @@ export async function activate( ); if(response === yesAnswer) { openApiTreeProvider.closeDescription(); + await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, false); } } ), @@ -261,7 +262,7 @@ export async function activate( ); async function generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { - const pluginTypes = config.pluginTypes?.map(x => parsePluginType(x)) ?? [KiotaPluginType.Microsoft];//TODO remove the default once we have the question in steps + const pluginTypes = typeof config.pluginTypes === 'string' ? parsePluginType(config.pluginTypes) : KiotaPluginType.Microsoft; const result = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, @@ -272,7 +273,7 @@ export async function activate( context, openApiTreeProvider.descriptionUrl, outputPath, - pluginTypes, + [pluginTypes], selectedPaths, [], typeof config.pluginName === "string" @@ -355,12 +356,13 @@ export async function activate( if (typeof config.outputPath === "string" && !openApiTreeProvider.isLockFileLoaded && vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 && result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) { - await openApiTreeProvider.loadLockFile(path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, config.outputPath, kiotaLockFile)); + await openApiTreeProvider.loadLockFile(path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, '.kiota', kiotaLockFile)); //TODO this will need to be updated to refresh the workspace instead } if (result) { await exportLogsAndShowErrors(result); + openApiTreeProvider.closeDescription(); } } diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index ca794cfdd4..226390f7cf 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -286,22 +286,36 @@ export async function generateSteps(existingConfiguration: Partial) { state.pluginName = await input.showInputBox({ - title: l10n.t('Create a new Microsoft plugin - plugin name'), + title: l10n.t('Create a new plugin - plugin name'), step: step++, - totalSteps: 2, + totalSteps: 3, value: state.pluginName || '', placeholder: 'MyPlugin', prompt: l10n.t('Choose a name for the plugin'), validate: validateIsNotEmpty, shouldResume: shouldResume }); - return (input: MultiStepInput) => inputPluginOutputPath(input, state); - } + return (input: MultiStepInput) => inputPluginType(input, state); + } + async function inputPluginType(input: MultiStepInput, state: Partial) { + const items = ['Microsoft','Open AI'].map(x => ({ label: x})as QuickPickItem); + const pluginTypes = await input.showQuickPick({ + title: 'Choose a plugin type', + step: step++, + totalSteps: 3, + placeholder: 'Select an option', + items: items, + validate: validateIsNotEmpty, + shouldResume: shouldResume + }); + pluginTypes.label === 'Microsoft'? state.pluginTypes = 'Microsoft' : state.pluginTypes = 'OpenAI'; + return (input: MultiStepInput) => inputPluginOutputPath(input, state); + } async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { state.outputPath = await input.showInputBox({ - title: l10n.t('Create a new Microsoft plugin - output path'), + title: l10n.t('Create a new plugin - output path'), step: step++, - totalSteps: 2, + totalSteps: 3, value: typeof state.outputPath === 'string' ? state.outputPath : '', placeholder: 'myproject/myplugin', prompt: l10n.t('Enter an output path relative to the root of the project'), @@ -309,8 +323,6 @@ export async function generateSteps(existingConfiguration: Partial inputGenerationType(input, state), () => step-=2); return state; } @@ -356,7 +368,7 @@ interface SelectApiManifestKey extends BaseStepsState { export interface GenerateState extends BaseStepsState { generationType: QuickPickItem | string; - pluginTypes: string[]; //TODO update type when we have multi-select + pluginTypes: QuickPickItem | string; pluginName:string; clientClassName: string; clientNamespaceName: QuickPickItem | string; From 9bb134db1aadb396ee46902692b28330e38fc988 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 2 May 2024 16:26:50 +0300 Subject: [PATCH 024/150] add generate a manifest type --- vscode/microsoft-kiota/src/extension.ts | 42 ++++++++++++++++++++++++- vscode/microsoft-kiota/src/steps.ts | 27 +++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index dcc39e4aa3..701c651f31 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -193,6 +193,8 @@ export async function activate( case GenerationType.Plugin: await generatePluginAndRefreshUI(config, settings, outputPath, selectedPaths); break; + case GenerationType.ApiManifest: + await generateManifestAndRefreshUI(config, settings, outputPath, selectedPaths); default: await vscode.window.showErrorMessage( vscode.l10n.t("Invalid generation type") @@ -261,6 +263,44 @@ export async function activate( ) ); + async function generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { + const pluginTypes = KiotaPluginType.ApiManifest; + const result = await vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Generating manifest...") + }, async (progress, _) => { + const start = performance.now(); + const result = await generatePlugin( + context, + openApiTreeProvider.descriptionUrl, + outputPath, + [pluginTypes], + selectedPaths, + [], + typeof config.pluginName === "string" + ? config.pluginName + : "ApiClient", + settings.clearCache, + settings.cleanOutput, + settings.disableValidationRules, + ); + const duration = performance.now() - start; + const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; + reporter.sendRawTelemetryEvent(`${extensionId}.generateManifest.completed`, { + "pluginType": pluginTypes.toString(), + "errorsCount": errorsCount.toString(), + }, { + "duration": duration, + }); + return result; + }); + //TODO refresh the kiota workspace + if (result) + { + await exportLogsAndShowErrors(result); + } + } async function generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { const pluginTypes = typeof config.pluginTypes === 'string' ? parsePluginType(config.pluginTypes) : KiotaPluginType.Microsoft; const result = await vscode.window.withProgress({ @@ -286,7 +326,7 @@ export async function activate( const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; reporter.sendRawTelemetryEvent(`${extensionId}.generatePlugin.completed`, { - //TODO log plugin type + "pluginType": pluginTypes.toString(), "errorsCount": errorsCount.toString(), }, { "duration": duration, diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 226390f7cf..dfa0918f4c 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -221,7 +221,7 @@ export async function generateSteps(existingConfiguration: Partial inputManifestName(input, state); } } async function inputClientClassName(input: MultiStepInput, state: Partial) { @@ -323,6 +323,31 @@ export async function generateSteps(existingConfiguration: Partial) { + state.pluginName = await input.showInputBox({ + title: l10n.t('Create a new manifest - manifest name'), + step: step++, + totalSteps: 3, + value: state.pluginName || '', + placeholder: 'MyManifest', + prompt: l10n.t('Choose a name for the manifest'), + validate: validateIsNotEmpty, + shouldResume: shouldResume + }); + return (input: MultiStepInput) => inputManifestOutputPath(input, state); + } + async function inputManifestOutputPath(input: MultiStepInput, state: Partial) { + state.outputPath = await input.showInputBox({ + title: l10n.t('Create a new manifest - output path'), + step: step++, + totalSteps: 3, + value: typeof state.outputPath === 'string' ? state.outputPath : '', + placeholder: 'myproject/mymanifest', + prompt: l10n.t('Enter an output path relative to the root of the project'), + validate: validateIsNotEmpty, + shouldResume: shouldResume + }); + } await MultiStepInput.run(input => inputGenerationType(input, state), () => step-=2); return state; } From aa4571633e0cec6f3cfdf84865db2866003ed632 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 2 May 2024 20:10:41 +0300 Subject: [PATCH 025/150] close description after generation --- vscode/microsoft-kiota/src/extension.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 701c651f31..d4c8628b9f 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -293,6 +293,7 @@ export async function activate( }, { "duration": duration, }); + openApiTreeProvider.closeDescription(); return result; }); //TODO refresh the kiota workspace @@ -331,6 +332,7 @@ export async function activate( }, { "duration": duration, }); + openApiTreeProvider.closeDescription(); return result; }); //TODO refresh the kiota workspace @@ -381,6 +383,7 @@ export async function activate( }, { "duration": duration, }); + openApiTreeProvider.closeDescription(); return result; }); @@ -402,7 +405,6 @@ export async function activate( if (result) { await exportLogsAndShowErrors(result); - openApiTreeProvider.closeDescription(); } } From 2c42eda39207df6f98d8d7cc0100c8f43d26c67f Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 8 May 2024 14:39:58 +0300 Subject: [PATCH 026/150] add "Edit Path' button --- vscode/microsoft-kiota/package-lock.json | 4 +- vscode/microsoft-kiota/package.json | 16 ++++++++ .../microsoft-kiota/src/codelensProvider.ts | 40 +++++++++++++++++++ vscode/microsoft-kiota/src/extension.ts | 9 ++++- vscode/microsoft-kiota/src/steps.ts | 2 +- 5 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 vscode/microsoft-kiota/src/codelensProvider.ts diff --git a/vscode/microsoft-kiota/package-lock.json b/vscode/microsoft-kiota/package-lock.json index 63b0e51944..a59bb82c79 100644 --- a/vscode/microsoft-kiota/package-lock.json +++ b/vscode/microsoft-kiota/package-lock.json @@ -1,12 +1,12 @@ { "name": "kiota", - "version": "1.12.100000001", + "version": "1.13.100000001", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kiota", - "version": "1.12.100000001", + "version": "1.13.100000001", "dependencies": { "@vscode/extension-telemetry": "^0.9.6", "@vscode/l10n": "^0.0.18", diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index f0740ef7eb..6365f8eed8 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -410,6 +410,22 @@ { "command": "kiota.workspace.openWorkspaceFile", "title": "%kiota.openApiExplorer.openFile.title%" + }, + { + "command": "kiota.editPaths", + "title": "Edit Paths" + } + ], + "languages": [ + { + "id": "json", + "extensions": [ ".json" ] + } + ], + "codeLensProviders": [ + { + "language": "json", + "provideCodeLenses": true } ] }, diff --git a/vscode/microsoft-kiota/src/codelensProvider.ts b/vscode/microsoft-kiota/src/codelensProvider.ts new file mode 100644 index 0000000000..80716609ae --- /dev/null +++ b/vscode/microsoft-kiota/src/codelensProvider.ts @@ -0,0 +1,40 @@ +import * as vscode from 'vscode'; + +export class CodeLensProvider implements vscode.CodeLensProvider { + public provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.ProviderResult { + console.log("provideCodeLenses called"); + const codeLenses: vscode.CodeLens[] = []; + const text = document.getText(); + const jsonObject = JSON.parse(text); + + if (document.fileName.endsWith('workspace.json')) { + const clientsObject = jsonObject['clients']; + if (clientsObject) { + const clientsStartLine = this.findPropertyLine(text, "clients"); + if (clientsStartLine !== -1) { + const clientKeys = Object.keys(clientsObject); + clientKeys.forEach(clientKey => { + const clientStartLine = this.findPropertyLine(text, clientKey); + if (clientStartLine !== -1) { + const positionBeforeClient = new vscode.Position(clientStartLine, 0); + const rangeBeforeClient = new vscode.Range(positionBeforeClient, positionBeforeClient); + const commandBeforeClient = { + title: "Edit Paths", + command: "kiota.editPaths", + arguments: [document.fileName, clientKey] + }; + codeLenses.push(new vscode.CodeLens(rangeBeforeClient, commandBeforeClient)); + } + }); + } + } + } + return codeLenses; + } + + private findPropertyLine(text: string, property: string): number { + const propertyRegex = new RegExp(`"${property}"\\s*:\\s*{`); + const match = text.match(propertyRegex); + return match ? text.substr(0, match.index).split('\n').length - 1 : -1; + } +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index d4c8628b9f..f7d8833130 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -27,6 +27,7 @@ import { ApiManifest } from "./apiManifest"; import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; import { KiotaWorkspace } from "./workspaceTreeProvider"; import { generatePlugin } from "./generatePlugin"; +import { CodeLensProvider } from "./codeLensProvider"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; @@ -52,6 +53,7 @@ export async function activate( ); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); new KiotaWorkspace(context); + let codeLensProvider = new CodeLensProvider(); context.subscriptions.push( vscode.window.registerUriHandler({ handleUri: async (uri: vscode.Uri) => { @@ -95,6 +97,8 @@ export async function activate( ); } }), + + vscode.languages.registerCodeLensProvider('json', codeLensProvider), reporter, registerCommandWithTelemetry(reporter, `${treeViewId}.openFile`, @@ -260,7 +264,10 @@ export async function activate( registerCommandWithTelemetry(reporter, `${treeViewId}.pasteManifest`, () => openManifestFromClipboard(openApiTreeProvider, "") - ) + ), + vscode.commands.registerCommand(`${extensionId}.editPaths`, (fileName: string, key: string) => { + void vscode.window.showInformationMessage(`Editing paths for ${key} in ${fileName}`); + }), ); async function generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index dfa0918f4c..23921c89a5 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -203,7 +203,7 @@ export async function generateSteps(existingConfiguration: Partial) { const items = ['Generate an API client', 'Generate a plugin', 'Generate an API manifest']; const option = await input.showQuickPick({ - title: 'What do you want to generate?', + title: l10n.t('What do you want to generate?'), step: 1, totalSteps: 1, placeholder: 'Select an option', From 564ed0366fe23e19285b1cf2086f865bb9223958 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 8 May 2024 15:13:17 +0300 Subject: [PATCH 027/150] add regenerate call --- vscode/microsoft-kiota/package.json | 4 ++++ vscode/microsoft-kiota/src/codelensProvider.ts | 11 ++++++++--- vscode/microsoft-kiota/src/extension.ts | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 6365f8eed8..9343d23a9f 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -414,6 +414,10 @@ { "command": "kiota.editPaths", "title": "Edit Paths" + }, + { + "command": "kiota.regenerate", + "title": "Re-generate" } ], "languages": [ diff --git a/vscode/microsoft-kiota/src/codelensProvider.ts b/vscode/microsoft-kiota/src/codelensProvider.ts index 80716609ae..d494e721b6 100644 --- a/vscode/microsoft-kiota/src/codelensProvider.ts +++ b/vscode/microsoft-kiota/src/codelensProvider.ts @@ -2,7 +2,6 @@ import * as vscode from 'vscode'; export class CodeLensProvider implements vscode.CodeLensProvider { public provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.ProviderResult { - console.log("provideCodeLenses called"); const codeLenses: vscode.CodeLens[] = []; const text = document.getText(); const jsonObject = JSON.parse(text); @@ -18,12 +17,18 @@ export class CodeLensProvider implements vscode.CodeLensProvider { if (clientStartLine !== -1) { const positionBeforeClient = new vscode.Position(clientStartLine, 0); const rangeBeforeClient = new vscode.Range(positionBeforeClient, positionBeforeClient); - const commandBeforeClient = { + const editPathsCommand = { title: "Edit Paths", command: "kiota.editPaths", arguments: [document.fileName, clientKey] }; - codeLenses.push(new vscode.CodeLens(rangeBeforeClient, commandBeforeClient)); + codeLenses.push(new vscode.CodeLens(rangeBeforeClient, editPathsCommand)); + const regenerateCommand = { + title: "Regenerate", + command: "kiota.regenerate", + arguments: [document.fileName, clientKey] + }; + codeLenses.push(new vscode.CodeLens(rangeBeforeClient, regenerateCommand)); } }); } diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index f7d8833130..6e577864c5 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -265,9 +265,12 @@ export async function activate( `${treeViewId}.pasteManifest`, () => openManifestFromClipboard(openApiTreeProvider, "") ), - vscode.commands.registerCommand(`${extensionId}.editPaths`, (fileName: string, key: string) => { + registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, (fileName: string, key: string) => { void vscode.window.showInformationMessage(`Editing paths for ${key} in ${fileName}`); }), + registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, (fileName: string, key: string) => { + void vscode.window.showInformationMessage(`Regenerating paths for ${key} in ${fileName}`); + }), ); async function generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { From 4174297a57cc1874d9e22192ebf59c4bc13d4c84 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 8 May 2024 15:34:33 +0300 Subject: [PATCH 028/150] update file name --- vscode/microsoft-kiota/src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 6e577864c5..9f738efcf2 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -27,7 +27,7 @@ import { ApiManifest } from "./apiManifest"; import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; import { KiotaWorkspace } from "./workspaceTreeProvider"; import { generatePlugin } from "./generatePlugin"; -import { CodeLensProvider } from "./codeLensProvider"; +import { CodeLensProvider } from "./codelensProvider"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; From 9e8e8d9f96d5ddd48d6a406e6ede31133277a5b4 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 8 May 2024 16:59:14 +0300 Subject: [PATCH 029/150] enable editing paths on api explorer --- vscode/microsoft-kiota/src/codelensProvider.ts | 5 +++-- vscode/microsoft-kiota/src/extension.ts | 9 +++++++-- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/vscode/microsoft-kiota/src/codelensProvider.ts b/vscode/microsoft-kiota/src/codelensProvider.ts index d494e721b6..f73efb35ea 100644 --- a/vscode/microsoft-kiota/src/codelensProvider.ts +++ b/vscode/microsoft-kiota/src/codelensProvider.ts @@ -13,6 +13,7 @@ export class CodeLensProvider implements vscode.CodeLensProvider { if (clientsStartLine !== -1) { const clientKeys = Object.keys(clientsObject); clientKeys.forEach(clientKey => { + const clientObject = clientsObject[clientKey]; const clientStartLine = this.findPropertyLine(text, clientKey); if (clientStartLine !== -1) { const positionBeforeClient = new vscode.Position(clientStartLine, 0); @@ -20,11 +21,11 @@ export class CodeLensProvider implements vscode.CodeLensProvider { const editPathsCommand = { title: "Edit Paths", command: "kiota.editPaths", - arguments: [document.fileName, clientKey] + arguments: [document.fileName, clientObject] }; codeLenses.push(new vscode.CodeLens(rangeBeforeClient, editPathsCommand)); const regenerateCommand = { - title: "Regenerate", + title: "Re-generate", command: "kiota.regenerate", arguments: [document.fileName, clientKey] }; diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 9f738efcf2..f4bc217a27 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -265,8 +265,9 @@ export async function activate( `${treeViewId}.pasteManifest`, () => openManifestFromClipboard(openApiTreeProvider, "") ), - registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, (fileName: string, key: string) => { - void vscode.window.showInformationMessage(`Editing paths for ${key} in ${fileName}`); + registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (fileName: string, clientObject: any) => { + // void vscode.window.showInformationMessage(`Regenerating paths for ${key} in ${fileName}`); + await loadEditPaths(clientObject, openApiTreeProvider); }), registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, (fileName: string, key: string) => { void vscode.window.showInformationMessage(`Regenerating paths for ${key} in ${fileName}`); @@ -552,6 +553,10 @@ async function loadLockFile(node: { fsPath: string }, openApiTreeProvider: OpenA await openTreeViewWithProgress(() => openApiTreeProvider.loadLockFile(node.fsPath)); } +async function loadEditPaths(clientObject: any, openApiTreeProvider: OpenApiTreeProvider): Promise { + await openTreeViewWithProgress(() => openApiTreeProvider.loadEditPaths(clientObject)); +} + async function exportLogsAndShowErrors(result: KiotaLogEntry[]) : Promise { const informationMessages = result ? getLogEntriesForLevel(result, LogLevel.information) diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index f459879dd1..286d85a3ce 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -39,6 +39,20 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider { + this.closeDescription(false); + this._lockFile = clientObject; + if (this._lockFile?.descriptionLocation) { + this._descriptionUrl = this._lockFile.descriptionLocation; + this.includeFilters = this._lockFile.includePatterns; + this.excludeFilters = this._lockFile.excludePatterns; + const settings = this.settingsGetter(); + await this.loadNodes(settings.clearCache); + if (this.rawRootNode) { + this.refreshView(); + } + } + } public async loadManifestFromUri(path: string, apiIdentifier?: string): Promise { this.closeDescription(false); const logs = await this.loadNodesFromManifest(path, apiIdentifier); From 8b629ab8abdae6e80d22ded075aa1e53339e8d11 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 9 May 2024 19:11:37 +0300 Subject: [PATCH 030/150] add regenerate functionality --- src/kiota/Rpc/IServer.cs | 2 +- src/kiota/Rpc/Server.cs | 4 +- .../microsoft-kiota/src/codelensProvider.ts | 4 +- vscode/microsoft-kiota/src/extension.ts | 67 +++++++++++++++++-- vscode/microsoft-kiota/src/generateClient.ts | 7 +- vscode/microsoft-kiota/src/kiotaInterop.ts | 12 ++++ 6 files changed, 84 insertions(+), 12 deletions(-) diff --git a/src/kiota/Rpc/IServer.cs b/src/kiota/Rpc/IServer.cs index 5c467acdbe..8e610f6414 100644 --- a/src/kiota/Rpc/IServer.cs +++ b/src/kiota/Rpc/IServer.cs @@ -10,7 +10,7 @@ internal interface IServer Task SearchAsync(string searchTerm, bool clearCache, CancellationToken cancellationToken); Task ShowAsync(string descriptionPath, string[] includeFilters, string[] excludeFilters, bool clearCache, CancellationToken cancellationToken); Task GetManifestDetailsAsync(string manifestPath, string apiIdentifier, bool clearCache, CancellationToken cancellationToken); - Task> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, CancellationToken cancellationToken); + Task> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, ConsumerOperation operation, CancellationToken cancellationToken); Task InfoForDescriptionAsync(string descriptionPath, bool clearCache, CancellationToken cancellationToken); Task> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, CancellationToken cancellationToken); } diff --git a/src/kiota/Rpc/Server.cs b/src/kiota/Rpc/Server.cs index 871f20bb54..7fbc29e816 100644 --- a/src/kiota/Rpc/Server.cs +++ b/src/kiota/Rpc/Server.cs @@ -137,7 +137,7 @@ private static string NormalizeOperationNodePath(OpenApiUrlTreeNode node, Operat return indexingNormalizationRegex().Replace(name, "{}"); return name; } - public async Task> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, CancellationToken cancellationToken) + public async Task> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, ConsumerOperation operation, CancellationToken cancellationToken) { var logger = new ForwardedLogger(); var configuration = Configuration.Generation; @@ -151,7 +151,7 @@ public async Task> GenerateAsync(string openAPIFilePath, string o configuration.ClearCache = clearCache; configuration.ExcludeBackwardCompatible = excludeBackwardCompatible; configuration.IncludeAdditionalData = includeAdditionalData; - configuration.Operation = ConsumerOperation.Add; //TODO should be updated to edit in the edit scenario + configuration.Operation = operation; if (disabledValidationRules is { Length: > 0 }) configuration.DisabledValidationRules = disabledValidationRules.ToHashSet(StringComparer.OrdinalIgnoreCase); if (serializers is { Length: > 0 }) diff --git a/vscode/microsoft-kiota/src/codelensProvider.ts b/vscode/microsoft-kiota/src/codelensProvider.ts index f73efb35ea..b6aea433e7 100644 --- a/vscode/microsoft-kiota/src/codelensProvider.ts +++ b/vscode/microsoft-kiota/src/codelensProvider.ts @@ -21,13 +21,13 @@ export class CodeLensProvider implements vscode.CodeLensProvider { const editPathsCommand = { title: "Edit Paths", command: "kiota.editPaths", - arguments: [document.fileName, clientObject] + arguments: [clientObject] }; codeLenses.push(new vscode.CodeLens(rangeBeforeClient, editPathsCommand)); const regenerateCommand = { title: "Re-generate", command: "kiota.regenerate", - arguments: [document.fileName, clientKey] + arguments: [clientKey, clientObject] }; codeLenses.push(new vscode.CodeLens(rangeBeforeClient, regenerateCommand)); } diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index f4bc217a27..635ebde33c 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -6,6 +6,7 @@ import * as path from 'path'; import * as fs from 'fs'; import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider"; import { + ConsumerOperation, generationLanguageToString, getLogEntriesForLevel, KiotaGenerationLanguage, @@ -265,12 +266,13 @@ export async function activate( `${treeViewId}.pasteManifest`, () => openManifestFromClipboard(openApiTreeProvider, "") ), - registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (fileName: string, clientObject: any) => { - // void vscode.window.showInformationMessage(`Regenerating paths for ${key} in ${fileName}`); + registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientObject: any) => { await loadEditPaths(clientObject, openApiTreeProvider); + await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, true); }), - registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, (fileName: string, key: string) => { - void vscode.window.showInformationMessage(`Regenerating paths for ${key} in ${fileName}`); + registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: any) => { + const settings = getExtensionSettings(extensionId); + await regenerateClient(clientKey, clientObject, settings); }), ); @@ -384,7 +386,8 @@ export async function activate( settings.languagesSerializationConfiguration[language].serializers, settings.languagesSerializationConfiguration[language].deserializers, settings.structuredMimeTypes, - settings.includeAdditionalData + settings.includeAdditionalData, + ConsumerOperation.Add ); const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; @@ -418,6 +421,60 @@ export async function activate( await exportLogsAndShowErrors(result); } } + async function regenerateClient(clientKey: string, clientObject:any, settings: ExtensionSettings): Promise { + const language = + typeof clientObject.language === "string" + ? parseGenerationLanguage(clientObject.language) + : KiotaGenerationLanguage.CSharp; + console.log( + context, + clientObject.descriptionLocation, + clientObject.outputPath, + language, + clientObject.includePatterns, + clientObject.excludePatterns, + clientKey, + clientObject.clientNamespaceName, + clientObject.usesBackingStore, + true, // clearCache + true, // cleanOutput + clientObject.excludeBackwardCompatible, + clientObject.disabledValidationRules, + settings.languagesSerializationConfiguration[language].serializers, + settings.languagesSerializationConfiguration[language].deserializers, + clientObject.structuredMimeTypes, + clientObject.includeAdditionalData + ); + await vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Generating client...") + }, async (progress, _) => { + const result = await generateClient( + context, + clientObject.descriptionLocation, + clientObject.outputPath, + language, + clientObject.includePatterns, + clientObject.excludePatterns, + clientKey, + clientObject.clientNamespaceName, + clientObject.usesBackingStore, + true, // clearCache + true, // cleanOutput + clientObject.excludeBackwardCompatible, + clientObject.disabledValidationRules, + settings.languagesSerializationConfiguration[language].serializers, + settings.languagesSerializationConfiguration[language].deserializers, + clientObject.structuredMimeTypes, + clientObject.includeAdditionalData, + ConsumerOperation.Edit + ); + return result; + }); + + void vscode.window.showInformationMessage(`Client ${clientKey} regenerated successfully.`); + } // create a new status bar item that we can now manage kiotaStatusBarItem = vscode.window.createStatusBarItem( diff --git a/vscode/microsoft-kiota/src/generateClient.ts b/vscode/microsoft-kiota/src/generateClient.ts index 9bbbf56762..4c69f2c4bb 100644 --- a/vscode/microsoft-kiota/src/generateClient.ts +++ b/vscode/microsoft-kiota/src/generateClient.ts @@ -1,4 +1,4 @@ -import { connectToKiota, GenerationConfiguration, KiotaGenerationLanguage, KiotaLogEntry } from "./kiotaInterop"; +import { connectToKiota, ConsumerOperation, GenerationConfiguration, KiotaGenerationLanguage, KiotaLogEntry } from "./kiotaInterop"; import * as rpc from "vscode-jsonrpc/node"; import * as vscode from "vscode"; @@ -18,7 +18,9 @@ export function generateClient(context: vscode.ExtensionContext, serializers: string[], deserializers: string[], structuredMimeTypes: string[], - includeAdditionalData: boolean): Promise { + includeAdditionalData: boolean, + operation: ConsumerOperation +): Promise { return connectToKiota(context, async (connection) => { const request = new rpc.RequestType1( "Generate" @@ -42,6 +44,7 @@ export function generateClient(context: vscode.ExtensionContext, serializers: serializers, structuredMimeTypes: structuredMimeTypes, usesBackingStore: usesBackingStore, + operation: operation } as GenerationConfiguration, ); }); diff --git a/vscode/microsoft-kiota/src/kiotaInterop.ts b/vscode/microsoft-kiota/src/kiotaInterop.ts index 83e8df13fc..8f1f4477f4 100644 --- a/vscode/microsoft-kiota/src/kiotaInterop.ts +++ b/vscode/microsoft-kiota/src/kiotaInterop.ts @@ -113,6 +113,17 @@ export enum KiotaPluginType { // eslint-disable-next-line @typescript-eslint/naming-convention Microsoft = 2, } + +export enum ConsumerOperation { + // eslint-disable-next-line @typescript-eslint/naming-convention + Add, + // eslint-disable-next-line @typescript-eslint/naming-convention + Edit, + // eslint-disable-next-line @typescript-eslint/naming-convention + Remove, + // eslint-disable-next-line @typescript-eslint/naming-convention + Generate +} export function parsePluginType(value: string): KiotaPluginType { switch (value) { case "OpenAI": @@ -279,4 +290,5 @@ export interface GenerationConfiguration { structuredMimeTypes: string[]; usesBackingStore: boolean; pluginTypes: KiotaPluginType[]; + operation: ConsumerOperation; } \ No newline at end of file From 5db4e6da14711e0661a5dce861ab34ee25ba58da Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 10 May 2024 09:58:58 -0400 Subject: [PATCH 031/150] - bumps kiota versions to avoid updates which confuses @sebastienlevert and @maisarissi --- vscode/microsoft-kiota/package.json | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 55c8e216dc..2b9ed151f9 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -3,8 +3,8 @@ "displayName": "Microsoft Kiota", "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.13.100000001", - "kiotaVersion": "1.13.0", + "version": "1.14.100000001", + "kiotaVersion": "1.14.0", "telemetryInstrumentationKey": "4c6357e0-daf9-42b5-bdfb-67878f8957b5", "icon": "images/logo.png", "engines": { @@ -422,14 +422,16 @@ ], "languages": [ { - "id": "json", - "extensions": [ ".json" ] + "id": "json", + "extensions": [ + ".json" + ] } ], "codeLensProviders": [ { - "language": "json", - "provideCodeLenses": true + "language": "json", + "provideCodeLenses": true } ] }, @@ -472,23 +474,23 @@ "runtimeDependencies": [ { "platformId": "win-x64", - "sha256": "502715936A379A60ACDE5CABD3BD98583DD29FBDA35E1D9AC342F61D064C73DD" + "sha256": "7AB8DA15620971C53BF14F67F957F19D3E7C2F53C66631E7E01D1BF639D1FBF6" }, { "platformId": "win-x86", - "sha256": "995F25489BF5B50A76E7CA87F10C5E6EF9E95FB8CE1EA0959F6CC76436584E72" + "sha256": "92918467EEBEB489A5F61AD41D3A31BE6EB6B05E2C016B0AAC2CAEA3A44FE99E" }, { "platformId": "linux-x64", - "sha256": "C69FB6ECE60B518DF8EA989AFBB9A475E866F514DFB4D4DDFBF681651D57D3FF" + "sha256": "388592EC1496BD1EA83A467238FCC751C0C7551ED903D23843420D2D8FB42669" }, { "platformId": "osx-x64", - "sha256": "F9548767005D6B5B8E861B3120042EC03FFF2A263E8FCA8F8402C3CE0548C72B" + "sha256": "54165FAC96060FA89B007C66A1005A8B3FB014E24F089243C8D9058B9398327B" }, { "platformId": "osx-arm64", - "sha256": "A59C9FE6B13F7936BB655CE29893307583949C4769BDD7BE53AC41F94AE2F4AC" + "sha256": "5666D266ED3A087F7AB18F065CE824FE9FB5362A49FF83B363D499A5EDC81EB5" } ] } From 6d1d8b6cdce5c5def00c3b234bddcffb872a0622 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 10 May 2024 10:12:40 -0400 Subject: [PATCH 032/150] - adds FAQ documentation for vs code reinstalling over --- vscode/microsoft-kiota/debugging.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vscode/microsoft-kiota/debugging.md b/vscode/microsoft-kiota/debugging.md index 8f5fda2247..4d8c88011a 100644 --- a/vscode/microsoft-kiota/debugging.md +++ b/vscode/microsoft-kiota/debugging.md @@ -46,3 +46,13 @@ Where kiotaVersionInPackage is the kiotaVersion field and versionInPackage is th > Note: the **.vscode** segment might change to **.vscode-server** if you're remoting to WSL. > Note: alternatively to building executable yourself, you can download it from [the pipeline](https://github.com/microsoft/kiota/actions/workflows/dotnet.yml) by filtering the branch (top right corner) with the pull request branch, selecting the latest run, and downloading the right OS version from the artifacts. The only remaining work will be to move the downloaded files to the right path above. + +## FAQ + +### VS Code keeps reinstalling from the marketplace + +This is most likely caused by the fact that there's a newer released version. Run the following script replacing the version argument with the latest version of kiota. + +```powershell +.\scripts\update-vscode-releases.ps1 -version "versionWithoutVPrefix" -online -filePath .\vscode\microsoft-kiota\package.json +``` From 2bebba52e04bb3b9ed2d7d8347e6d99273ef78de Mon Sep 17 00:00:00 2001 From: ElinorW Date: Mon, 13 May 2024 18:45:50 +0300 Subject: [PATCH 033/150] add regeneration button on api explorer --- vscode/microsoft-kiota/package-lock.json | 4 +- vscode/microsoft-kiota/package.json | 24 ++++++--- vscode/microsoft-kiota/package.nls.json | 5 +- .../microsoft-kiota/src/codelensProvider.ts | 2 +- vscode/microsoft-kiota/src/extension.ts | 53 ++++++++++--------- 5 files changed, 52 insertions(+), 36 deletions(-) diff --git a/vscode/microsoft-kiota/package-lock.json b/vscode/microsoft-kiota/package-lock.json index 28b6e2182d..423a71fd7d 100644 --- a/vscode/microsoft-kiota/package-lock.json +++ b/vscode/microsoft-kiota/package-lock.json @@ -1,12 +1,12 @@ { "name": "kiota", - "version": "1.13.100000001", + "version": "1.14.100000001", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kiota", - "version": "1.13.100000001", + "version": "1.14.100000001", "dependencies": { "@vscode/extension-telemetry": "^0.9.6", "@vscode/l10n": "^0.0.18", diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index af3bf0deb4..1c167733bc 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -240,22 +240,27 @@ { "command": "kiota.openApiExplorer.searchOrOpenApiDescription", "when": "view == kiota.openApiExplorer", - "group": "navigation@2" + "group": "navigation@1" }, { "command": "kiota.openApiExplorer.filterDescription", "when": "view == kiota.openApiExplorer", - "group": "navigation@3" + "group": "navigation@2" }, { "command": "kiota.openApiExplorer.generateClient", "when": "view == kiota.openApiExplorer", - "group": "navigation@4" + "group": "navigation@3" }, { "command": "kiota.openApiExplorer.openFile", "when": "view == kiota.workspace", - "group": "navigation@2" + "group": "navigation@1" + }, + { + "command": "kiota.openApiExplorer.regenerateButton", + "when": "view == kiota.openApiExplorer", + "group": "navigation@4" } ], "view/item/context": [ @@ -352,6 +357,13 @@ "enablement": "kiota.openApiExplorer.showIcons", "icon": "$(run-all)" }, + { + "command": "kiota.openApiExplorer.regenerateButton", + "category": "Kiota", + "title": "%kiota.openApiExplorer.regenerateButton.title%", + "enablement": "kiota.openApiExplorer.showRegenerateIcon", + "icon": "$(sync)" + }, { "command": "kiota.openApiExplorer.filterDescription", "category": "Kiota", @@ -413,11 +425,11 @@ }, { "command": "kiota.editPaths", - "title": "Edit Paths" + "title": "%kiota.openApiExplorer.editPaths.title%" }, { "command": "kiota.regenerate", - "title": "Re-generate" + "title": "%kiota.openApiExplorer.regenerateButton.title%" } ], "languages": [ diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index a182f66c42..858bcaec74 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -29,5 +29,8 @@ "kiota.generate.structuredMimeTypes.description": "The MIME types and preference to use for structured data model generation. As per RFC9110 Accept header notation.", "kiota.generate.includeAdditionalData.description": "Will include the 'AdditionalData' property for models", "kiota.workspace.name": "My Workspace", - "kiota.openApiExplorer.openFile.title": "Open file" + "kiota.openApiExplorer.openFile.title": "Open file", + "kiota.openApiExplorer.regenerateButton.title": "Re-generate", + "kiota.openApiExplorer.editPaths.title": "Edit paths" + } diff --git a/vscode/microsoft-kiota/src/codelensProvider.ts b/vscode/microsoft-kiota/src/codelensProvider.ts index b6aea433e7..fdb0896dad 100644 --- a/vscode/microsoft-kiota/src/codelensProvider.ts +++ b/vscode/microsoft-kiota/src/codelensProvider.ts @@ -21,7 +21,7 @@ export class CodeLensProvider implements vscode.CodeLensProvider { const editPathsCommand = { title: "Edit Paths", command: "kiota.editPaths", - arguments: [clientObject] + arguments: [clientKey, clientObject] }; codeLenses.push(new vscode.CodeLens(rangeBeforeClient, editPathsCommand)); const regenerateCommand = { diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 635ebde33c..cccd48a11c 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -39,6 +39,8 @@ const treeViewId = `${extensionId}.openApiExplorer`; const treeViewFocusCommand = `${treeViewId}${focusCommandId}`; const dependenciesInfo = `${extensionId}.dependenciesInfo`; export const kiotaLockFile = "workspace.json"; +let globalClientKey: string; +let globalClientObject: any; // This method is called when your extension is activated // Your extension is activated the very first time the command is executed @@ -222,6 +224,7 @@ export async function activate( if (config.descriptionPath) { await openTreeViewWithProgress(() => openApiTreeProvider.setDescriptionUrl(config.descriptionPath!)); await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, true); + await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, false); } } ), @@ -266,10 +269,26 @@ export async function activate( `${treeViewId}.pasteManifest`, () => openManifestFromClipboard(openApiTreeProvider, "") ), - registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientObject: any) => { - await loadEditPaths(clientObject, openApiTreeProvider); - await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, true); + registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: any) => { + globalClientKey = clientKey; + globalClientObject = clientObject; + await loadEditPaths(clientObject, openApiTreeProvider); + await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, false); + await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, true); }), + + vscode.commands.registerCommand(`${treeViewId}.regenerateButton`, async (clientKey: string, clientObject: any) => { + const settings = getExtensionSettings(extensionId); + const selectedPaths = openApiTreeProvider.getSelectedPaths(); + if (selectedPaths.length === 0) { + await vscode.window.showErrorMessage( + vscode.l10n.t("No endpoints selected, select endpoints first") + ); + } + await regenerateClient(globalClientKey, globalClientObject, settings, selectedPaths); + }), + + registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: any) => { const settings = getExtensionSettings(extensionId); await regenerateClient(clientKey, clientObject, settings); @@ -421,41 +440,22 @@ export async function activate( await exportLogsAndShowErrors(result); } } - async function regenerateClient(clientKey: string, clientObject:any, settings: ExtensionSettings): Promise { + async function regenerateClient(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]): Promise { const language = typeof clientObject.language === "string" ? parseGenerationLanguage(clientObject.language) : KiotaGenerationLanguage.CSharp; - console.log( - context, - clientObject.descriptionLocation, - clientObject.outputPath, - language, - clientObject.includePatterns, - clientObject.excludePatterns, - clientKey, - clientObject.clientNamespaceName, - clientObject.usesBackingStore, - true, // clearCache - true, // cleanOutput - clientObject.excludeBackwardCompatible, - clientObject.disabledValidationRules, - settings.languagesSerializationConfiguration[language].serializers, - settings.languagesSerializationConfiguration[language].deserializers, - clientObject.structuredMimeTypes, - clientObject.includeAdditionalData - ); await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, - title: vscode.l10n.t("Generating client...") + title: vscode.l10n.t("Re-generating client...") }, async (progress, _) => { const result = await generateClient( context, clientObject.descriptionLocation, clientObject.outputPath, language, - clientObject.includePatterns, + selectedPaths ? selectedPaths : clientObject.includePatterns, clientObject.excludePatterns, clientKey, clientObject.clientNamespaceName, @@ -473,7 +473,8 @@ export async function activate( return result; }); - void vscode.window.showInformationMessage(`Client ${clientKey} regenerated successfully.`); + void vscode.window.showInformationMessage(`Client ${clientKey} re-generated successfully.`); + openApiTreeProvider.closeDescription(); } // create a new status bar item that we can now manage From b21736aea38c46e1f690137d80be000d5d8213c9 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Mon, 13 May 2024 18:51:27 +0300 Subject: [PATCH 034/150] remove automatic workspace.json file add --- vscode/microsoft-kiota/src/workspaceTreeProvider.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts index 47c5ddef08..ac8176e186 100644 --- a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts +++ b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts @@ -24,22 +24,20 @@ export class WorkspaceTreeProvider implements vscode.TreeDataProvider { + private async ensureKiotaDirectory(): Promise { if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) { await vscode.window.showErrorMessage( vscode.l10n.t("No workspace folder found, open a folder first") ); return; } - const kiotaDir = path.dirname(workspaceJsonPath); + const kiotaDir = path.dirname(workspaceJsonPath); try { await fs.promises.access(kiotaDir); } catch (error) { - await fs.promises.mkdir(kiotaDir, { recursive: true }); + return error; } - } - } export class KiotaWorkspace { From 3bcc0e64ac3134fdeb10736aad328c15955cd17e Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 14 May 2024 11:59:02 +0300 Subject: [PATCH 035/150] replace string --- vscode/microsoft-kiota/l10n/bundle.l10n.ar.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.cs.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.es.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.fr.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.it.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.ja.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.pl.json | 4 ++-- vscode/microsoft-kiota/l10n/bundle.l10n.pt.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.ru.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.sw.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.tr.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json | 2 +- vscode/microsoft-kiota/src/steps.ts | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json index 797dd1b706..91bba6d3c1 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json @@ -28,7 +28,7 @@ "Generating client...": "انشاء العميل...", "Loading...": "جاري التحميل...", "Updating clients...": "تحديث العملاء...", - "Pick a lock file": "اختر ملف قفل", + "Pick a workspace file": "اختر ملف قفل", "Open a lock file": "افتح ملف قفل", "Filter the API description": "قم بتصفية وصف API", "Enter a filter": "أدخل عامل التصفية", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json index 0c7a52d554..8557192d66 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json @@ -28,7 +28,7 @@ "Generating client...": "Generování klienta...", "Updating clients...": "Aktualizace klientů...", "Loading...": "Načítání...", - "Pick a lock file": "Vybrat soubor zámku", + "Pick a workspace file": "Vybrat soubor zámku", "Open a lock file": "Otevřít soubor zámku", "Filter the API description": "Filtrovat popis API", "Enter a filter": "Zadejte filtr", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json index 8918ec1050..675220017d 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json @@ -28,7 +28,7 @@ "Generating client...": "Generando cliente...", "Updating clients...": "Actualizando clientes...", "Loading...": "Cargando...", - "Pick a lock file": "Seleccionar un archivo lock", + "Pick a workspace file": "Seleccionar un archivo lock", "Open a lock file": "Abrir un archivo lock", "Filter the API description": "Filtrar descripción de API", "Enter a filter": "Ingresar un filtro", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json index d38a9ca7c0..1b41011b49 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json @@ -28,7 +28,7 @@ "Generating client...": "Génération du client...", "Updating clients...": "Mise à jour des clients...", "Loading...": "Chargement...", - "Pick a lock file": "Sélectionnez un fichier verrou", + "Pick a workspace file": "Sélectionnez un fichier verrou", "Open a lock file": "Ouvrir un fichier verrou", "Filter the API description": "Filtrer la description d'API", "Enter a filter": "Entrez un filtre", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json index b9644dbb57..060177cac0 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json @@ -28,7 +28,7 @@ "Generating client...": "Generazione del client in corso...", "Updating clients...": "Aggiornamento dei client in corso...", "Loading...": "Caricamento...", - "Pick a lock file": "Seleziona un file di lock", + "Pick a workspace file": "Seleziona un file di lock", "Open a lock file": "Apri un file di lock", "Filter the API description": "Filtra la descrizione API", "Enter a filter": "Inserisci un filtro", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json index c4a9f9503a..aa845bc001 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json @@ -29,7 +29,7 @@ "Generating client...": "クライアントを生成中...", "Updating clients...": "クライアントを更新中...", "Loading...": "読み込み中...", - "Pick a lock file": "ロックファイルを選択", + "Pick a workspace file": "ロックファイルを選択", "Open a lock file": "ロックファイルを開く", "Filter the API description": "API仕様書をフィルタ", "Enter a filter": "フィルタを入力", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json index 734da9d9b2..cf713472cb 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json @@ -28,7 +28,7 @@ "Generating client...": "Generowanie klienta...", "Updating clients...": "Aktualizowanie klientów...", "Loading...": "Ładowanie...", - "Pick a lock file": "Wybierz plik lock", + "Pick a workspace file": "Wybierz plik lock", "Open a lock file": "Otwórz plik lock", "Filter the API description": "Filtruj opis API", "Enter a filter": "Wprowadź filtr", @@ -39,4 +39,4 @@ "No content found in the clipboard": "Nie znaleziono zawartości w schowku", "Invalid content found in the clipboard": "Znaleziono nieprawidłową zawartość w schowku", "Select an API manifest key": "Wybierz klucz manifestu API" -} \ No newline at end of file +} diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json index 16ff82a061..c3df497d53 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json @@ -28,7 +28,7 @@ "Generating client...": "Gerando o cliente...", "Updating clients...": "Atualizando os clientes...", "Loading...": "Carregando...", - "Pick a lock file": "Selecionar um arquivo lock", + "Pick a workspace file": "Selecionar um arquivo lock", "Open a lock file": "Abrir um arquivo lock", "Filter the API description": "Filtrar descrição da API", "Enter a filter": "Adicionar um filtro", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json index 3becda22a8..132bf2114f 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json @@ -27,7 +27,7 @@ "Generating client...": "Генерирование клиента...", "Updating clients...": "Обновление клиентов...", "Loading...": "Загрузка...", - "Pick a lock file": "Выбрать файл блокировки", + "Pick a workspace file": "Выбрать файл блокировки", "Open a lock file": "Открыть файл блокировки", "Filter the API description": "Отфильтровать описание API", "Enter a filter": "Ввести фильтр", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json index c42a14f1f8..c7e16273da 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json @@ -28,7 +28,7 @@ "Generating client...": "Inatengeneza mteja...", "Updating clients...": "Inasasisha wateja...", "Loading...": "Inapakia...", - "Pick a lock file": "Chagua faili ya kufunga", + "Pick a workspace file": "Chagua faili ya kufunga", "Open a lock file": "Fungua faili ya kufunga", "Filter the API description": "Chuja maelezo ya API", "Enter a filter": "Ingiza kichujio", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json index 84f00f97e9..e521f1abf7 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json @@ -28,7 +28,7 @@ "Generating client...": "İstemci oluşturuluyor...", "Updating clients...": "İstemciler güncelleniyor...", "Loading...": "Yükleniyor...", - "Pick a lock file": "Bir kilit dosyası seçin", + "Pick a workspace file": "Bir kilit dosyası seçin", "Open a lock file": "Bir kilit dosyası açın", "Filter the API description": "API açıklamasını filtreleyin", "Enter a filter": "Filtre girin", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json index 4a24b4c5c0..390b462adb 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json @@ -27,7 +27,7 @@ "Generating client...": "正在生成客户端...", "Updating clients...": "正在更新客户端...", "Loading...": "加载中...", - "Pick a lock file": "请选择一个锁定文件", + "Pick a workspace file": "请选择一个锁定文件", "Open a lock file": "请打开一个锁定文件", "Filter the API description": "筛选API描述", "Enter a filter": "输入一个筛选项", diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 23921c89a5..2b91efa851 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -86,7 +86,7 @@ export async function searchLockSteps() { title, step: step++, totalSteps: totalSteps, - placeholder: l10n.t('Pick a lock file'), + placeholder: l10n.t('Pick a workspace file'), items: items, shouldResume: shouldResume }); From 45afefd8db57b998fc9ce8cd36bdd7cb18c746a1 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 14 May 2024 12:11:05 +0300 Subject: [PATCH 036/150] update icon --- vscode/microsoft-kiota/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 1c167733bc..0c47120728 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -362,7 +362,7 @@ "category": "Kiota", "title": "%kiota.openApiExplorer.regenerateButton.title%", "enablement": "kiota.openApiExplorer.showRegenerateIcon", - "icon": "$(sync)" + "icon": "$(debug-rerun)" }, { "command": "kiota.openApiExplorer.filterDescription", From 93c3b13b86adbab4c98bceadf53823acd3c33a23 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 14 May 2024 16:19:49 +0300 Subject: [PATCH 037/150] add plugin re-generation --- src/kiota/Rpc/IServer.cs | 2 +- src/kiota/Rpc/Server.cs | 4 +- .../microsoft-kiota/src/codelensProvider.ts | 32 +++++------ vscode/microsoft-kiota/src/extension.ts | 57 +++++++++++++++++-- vscode/microsoft-kiota/src/generatePlugin.ts | 6 +- 5 files changed, 76 insertions(+), 25 deletions(-) diff --git a/src/kiota/Rpc/IServer.cs b/src/kiota/Rpc/IServer.cs index 8e610f6414..a592200948 100644 --- a/src/kiota/Rpc/IServer.cs +++ b/src/kiota/Rpc/IServer.cs @@ -12,5 +12,5 @@ internal interface IServer Task GetManifestDetailsAsync(string manifestPath, string apiIdentifier, bool clearCache, CancellationToken cancellationToken); Task> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, ConsumerOperation operation, CancellationToken cancellationToken); Task InfoForDescriptionAsync(string descriptionPath, bool clearCache, CancellationToken cancellationToken); - Task> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, CancellationToken cancellationToken); + Task> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, ConsumerOperation operation, CancellationToken cancellationToken); } diff --git a/src/kiota/Rpc/Server.cs b/src/kiota/Rpc/Server.cs index 7fbc29e816..dbdb285175 100644 --- a/src/kiota/Rpc/Server.cs +++ b/src/kiota/Rpc/Server.cs @@ -183,7 +183,7 @@ public async Task> GenerateAsync(string openAPIFilePath, string o } return logger.LogEntries; } - public async Task> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, CancellationToken cancellationToken) + public async Task> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, ConsumerOperation operation, CancellationToken cancellationToken) { var globalLogger = new ForwardedLogger(); var configuration = Configuration.Generation; @@ -194,7 +194,7 @@ public async Task> GeneratePluginAsync(string openAPIFilePath, st configuration.ClientClassName = clientClassName; configuration.CleanOutput = cleanOutput; configuration.ClearCache = clearCache; - configuration.Operation = ConsumerOperation.Add; //TODO should be updated to edit in the edit scenario + configuration.Operation = operation; if (disabledValidationRules is { Length: > 0 }) configuration.DisabledValidationRules = disabledValidationRules.ToHashSet(StringComparer.OrdinalIgnoreCase); if (pluginTypes is { Length: > 0 }) diff --git a/vscode/microsoft-kiota/src/codelensProvider.ts b/vscode/microsoft-kiota/src/codelensProvider.ts index fdb0896dad..a025b7be5a 100644 --- a/vscode/microsoft-kiota/src/codelensProvider.ts +++ b/vscode/microsoft-kiota/src/codelensProvider.ts @@ -7,33 +7,33 @@ export class CodeLensProvider implements vscode.CodeLensProvider { const jsonObject = JSON.parse(text); if (document.fileName.endsWith('workspace.json')) { - const clientsObject = jsonObject['clients']; - if (clientsObject) { - const clientsStartLine = this.findPropertyLine(text, "clients"); - if (clientsStartLine !== -1) { - const clientKeys = Object.keys(clientsObject); - clientKeys.forEach(clientKey => { - const clientObject = clientsObject[clientKey]; - const clientStartLine = this.findPropertyLine(text, clientKey); - if (clientStartLine !== -1) { - const positionBeforeClient = new vscode.Position(clientStartLine, 0); - const rangeBeforeClient = new vscode.Range(positionBeforeClient, positionBeforeClient); + ['clients', 'plugins'].forEach(objectKey => { + const object = jsonObject[objectKey]; + if (object) { + Object.keys(object).forEach(key => { + const obj = object[key]; + const startLine = this.findPropertyLine(text, key); + if (startLine !== -1) { + const positionBeforeObj = new vscode.Position(startLine, 0); + const rangeBeforeObj = new vscode.Range(positionBeforeObj, positionBeforeObj); + const editPathsCommand = { title: "Edit Paths", command: "kiota.editPaths", - arguments: [clientKey, clientObject] + arguments: [key, obj, objectKey] }; - codeLenses.push(new vscode.CodeLens(rangeBeforeClient, editPathsCommand)); + codeLenses.push(new vscode.CodeLens(rangeBeforeObj, editPathsCommand)); + const regenerateCommand = { title: "Re-generate", command: "kiota.regenerate", - arguments: [clientKey, clientObject] + arguments: [key, obj, objectKey] }; - codeLenses.push(new vscode.CodeLens(rangeBeforeClient, regenerateCommand)); + codeLenses.push(new vscode.CodeLens(rangeBeforeObj, regenerateCommand)); } }); } - } + }); } return codeLenses; } diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index cccd48a11c..dde858a6ba 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -41,6 +41,7 @@ const dependenciesInfo = `${extensionId}.dependenciesInfo`; export const kiotaLockFile = "workspace.json"; let globalClientKey: string; let globalClientObject: any; +let globalGenerationType: string; // This method is called when your extension is activated // Your extension is activated the very first time the command is executed @@ -269,15 +270,16 @@ export async function activate( `${treeViewId}.pasteManifest`, () => openManifestFromClipboard(openApiTreeProvider, "") ), - registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: any) => { + registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: any, generationType: string) => { globalClientKey = clientKey; globalClientObject = clientObject; + globalGenerationType = generationType; await loadEditPaths(clientObject, openApiTreeProvider); await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, false); await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, true); }), - vscode.commands.registerCommand(`${treeViewId}.regenerateButton`, async (clientKey: string, clientObject: any) => { + vscode.commands.registerCommand(`${treeViewId}.regenerateButton`, async () => { const settings = getExtensionSettings(extensionId); const selectedPaths = openApiTreeProvider.getSelectedPaths(); if (selectedPaths.length === 0) { @@ -285,13 +287,23 @@ export async function activate( vscode.l10n.t("No endpoints selected, select endpoints first") ); } - await regenerateClient(globalClientKey, globalClientObject, settings, selectedPaths); + if(globalGenerationType === "clients") { + await regenerateClient(globalClientKey, globalClientObject, settings, selectedPaths); + } + if (globalGenerationType === "plugins") { + await regeneratePlugin(globalClientKey, globalClientObject, settings, selectedPaths); + } }), - registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: any) => { + registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: any, generationType: string) => { const settings = getExtensionSettings(extensionId); + if (generationType === "clients") { await regenerateClient(clientKey, clientObject, settings); + } + if (generationType === "plugins") { + await regeneratePlugin(clientKey, clientObject, settings); + } }), ); @@ -316,6 +328,7 @@ export async function activate( settings.clearCache, settings.cleanOutput, settings.disableValidationRules, + ConsumerOperation.Add ); const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; @@ -355,6 +368,7 @@ export async function activate( settings.clearCache, settings.cleanOutput, settings.disableValidationRules, + ConsumerOperation.Add ); const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; @@ -477,6 +491,41 @@ export async function activate( openApiTreeProvider.closeDescription(); } + async function regeneratePlugin(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]) { + const pluginTypes = typeof clientObject.pluginTypes === 'string' ? parsePluginType(clientObject.pluginTypes) : KiotaPluginType.Microsoft; + await vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Re-generating plugin...") + }, async (progress, _) => { + const start = performance.now(); + const result = await generatePlugin( + context, + clientObject.descriptionLocation, + clientObject.outputPath, + [pluginTypes], + selectedPaths ? selectedPaths : clientObject.includePatterns, + [], + clientKey, + settings.clearCache, + settings.cleanOutput, + settings.disableValidationRules, + ConsumerOperation.Edit + ); + const duration = performance.now() - start; + const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; + reporter.sendRawTelemetryEvent(`${extensionId}.re-generatePlugin.completed`, { + "pluginType": pluginTypes.toString(), + "errorsCount": errorsCount.toString(), + }, { + "duration": duration, + }); + return result; + }); + void vscode.window.showInformationMessage(`Plugin ${clientKey} re-generated successfully.`); + openApiTreeProvider.closeDescription(); + } + // create a new status bar item that we can now manage kiotaStatusBarItem = vscode.window.createStatusBarItem( vscode.StatusBarAlignment.Right, diff --git a/vscode/microsoft-kiota/src/generatePlugin.ts b/vscode/microsoft-kiota/src/generatePlugin.ts index 5329cc4432..609a6de073 100644 --- a/vscode/microsoft-kiota/src/generatePlugin.ts +++ b/vscode/microsoft-kiota/src/generatePlugin.ts @@ -1,4 +1,4 @@ -import { connectToKiota, GenerationConfiguration, KiotaGenerationLanguage, KiotaLogEntry, KiotaPluginType } from "./kiotaInterop"; +import { connectToKiota, ConsumerOperation, GenerationConfiguration, KiotaGenerationLanguage, KiotaLogEntry, KiotaPluginType } from "./kiotaInterop"; import * as rpc from "vscode-jsonrpc/node"; import * as vscode from "vscode"; @@ -11,7 +11,8 @@ export function generatePlugin(context: vscode.ExtensionContext, clientClassName: string, clearCache: boolean, cleanOutput: boolean, - disableValidationRules: string[]): Promise { + disableValidationRules: string[], + operation: ConsumerOperation ): Promise { return connectToKiota(context, async (connection) => { const request = new rpc.RequestType1( "GeneratePlugin" @@ -28,6 +29,7 @@ export function generatePlugin(context: vscode.ExtensionContext, includePatterns: includeFilters, openAPIFilePath: descriptionPath, outputPath: output, + operation: operation } as GenerationConfiguration, ); }); From d187094048f32f89c1e43811bdd1f8b02555cbfa Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 14 May 2024 17:52:50 +0300 Subject: [PATCH 038/150] add warning notification --- vscode/microsoft-kiota/src/extension.ts | 12 ++++++++++++ vscode/microsoft-kiota/src/openApiTreeProvider.ts | 3 +++ 2 files changed, 15 insertions(+) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index dde858a6ba..8d1894c0de 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -214,6 +214,18 @@ export async function activate( registerCommandWithTelemetry(reporter, `${treeViewId}.searchOrOpenApiDescription`, async () => { + const yesAnswer = vscode.l10n.t("Yes, override it"); + if (!openApiTreeProvider.isEmpty()) { + const response = await vscode.window.showWarningMessage( + vscode.l10n.t( + "Are you sure you want to add a new API Description?"), + yesAnswer, + vscode.l10n.t("Cancel") + ); + if (response !== yesAnswer) { + return; + } + } const config = await searchSteps(x => vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 286d85a3ce..83e53b5efe 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -95,6 +95,9 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider { this.closeDescription(false); this._descriptionUrl = descriptionUrl; From cb2ef16b77185b2699410f650e96ef4c0e799c4d Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 14 May 2024 18:19:37 +0300 Subject: [PATCH 039/150] add save notification --- vscode/microsoft-kiota/src/extension.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 8d1894c0de..d7dea4f59c 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -218,7 +218,7 @@ export async function activate( if (!openApiTreeProvider.isEmpty()) { const response = await vscode.window.showWarningMessage( vscode.l10n.t( - "Are you sure you want to add a new API Description?"), + "Before adding a new API description, consider that your changes and current selection will be lost."), yesAnswer, vscode.l10n.t("Cancel") ); @@ -307,9 +307,16 @@ export async function activate( } }), - registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: any, generationType: string) => { const settings = getExtensionSettings(extensionId); + const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith("workspace.json")); + if (workspaceJson && workspaceJson.isDirty) { + await vscode.window.showInformationMessage( + vscode.l10n.t("Please save the workspace.json file before re-generation."), + vscode.l10n.t("OK") + ); + return; + } if (generationType === "clients") { await regenerateClient(clientKey, clientObject, settings); } From 277303955e02940dbdde6dd6890f72aee09876d0 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 16 May 2024 14:45:37 +0300 Subject: [PATCH 040/150] fix delete description appearing on wrong nodes --- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 83e53b5efe..718cf49fbe 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -246,8 +246,9 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider this.getTreeNodeFromKiotaNode(x)), - node.documentationUrl + node.documentationUrl, ); } getChildren(element?: OpenApiTreeNode): vscode.ProviderResult { @@ -275,6 +276,7 @@ type IconSet = string | vscode.Uri | { light: string | vscode.Uri; dark: string export class OpenApiTreeNode extends vscode.TreeItem { private static readonly selectedSet: IconSet = new vscode.ThemeIcon('check'); private static readonly unselectedSet: IconSet = new vscode.ThemeIcon('circle-slash'); + constructor( public readonly path: string, public readonly label: string, @@ -282,12 +284,13 @@ export class OpenApiTreeNode extends vscode.TreeItem { public readonly collapsibleState: vscode.TreeItemCollapsibleState, private readonly isOperation: boolean, filterTokens: string[], + apiTitle: string | undefined, public readonly children: OpenApiTreeNode[] = [], public readonly documentationUrl?: string ) { super(label, collapsibleState); this.id = `${path}_${filterTokens.join('_')}`; // so the collapsed state is NOT persisted between filter changes - this.contextValue =(this.label.indexOf('(') !== -1) ? 'apiTitle' : (this.documentationUrl ? 'documentationUrl' : ''); + this.contextValue = label === pathSeparator + " (" + apiTitle + ")" ? 'apiTitle' : (this.documentationUrl ? 'documentationUrl' : ''); this.iconPath = selected ? OpenApiTreeNode.selectedSet : OpenApiTreeNode.unselectedSet; } public isNodeVisible(tokenizedFilter: string[]): boolean { From 38a1a65181fdf2bb7d2b04707c166adcf1eba58b Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 16 May 2024 14:50:18 +0300 Subject: [PATCH 041/150] remove open file command --- vscode/microsoft-kiota/package.json | 15 --------------- vscode/microsoft-kiota/package.nls.json | 1 - .../microsoft-kiota/src/workspaceTreeProvider.ts | 4 ---- 3 files changed, 20 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 0c47120728..968ceb3f81 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -252,11 +252,6 @@ "when": "view == kiota.openApiExplorer", "group": "navigation@3" }, - { - "command": "kiota.openApiExplorer.openFile", - "when": "view == kiota.workspace", - "group": "navigation@1" - }, { "command": "kiota.openApiExplorer.regenerateButton", "when": "view == kiota.openApiExplorer", @@ -413,16 +408,6 @@ "title": "%kiota.openApiExplorer.openDescription.title%", "icon": "$(add)" }, - { - "command": "kiota.openApiExplorer.openFile", - "category": "Kiota", - "title": "%kiota.openApiExplorer.openFile.title%", - "icon": "$(folder-opened)" - }, - { - "command": "kiota.workspace.openWorkspaceFile", - "title": "%kiota.openApiExplorer.openFile.title%" - }, { "command": "kiota.editPaths", "title": "%kiota.openApiExplorer.editPaths.title%" diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index 858bcaec74..ac9e300e0b 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -29,7 +29,6 @@ "kiota.generate.structuredMimeTypes.description": "The MIME types and preference to use for structured data model generation. As per RFC9110 Accept header notation.", "kiota.generate.includeAdditionalData.description": "Will include the 'AdditionalData' property for models", "kiota.workspace.name": "My Workspace", - "kiota.openApiExplorer.openFile.title": "Open file", "kiota.openApiExplorer.regenerateButton.title": "Re-generate", "kiota.openApiExplorer.editPaths.title": "Edit paths" diff --git a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts index ac8176e186..a5ca4d9115 100644 --- a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts +++ b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts @@ -17,10 +17,6 @@ export class WorkspaceTreeProvider implements vscode.TreeDataProvider Date: Thu, 16 May 2024 16:15:32 +0300 Subject: [PATCH 042/150] remove output path validation and default to ouptut folder --- vscode/microsoft-kiota/src/steps.ts | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 2b91efa851..b0d2e382ff 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -258,9 +258,9 @@ export async function generateSteps(existingConfiguration: Partial pickLanguage(input, state); } async function pickLanguage(input: MultiStepInput, state: Partial) { @@ -319,9 +319,9 @@ export async function generateSteps(existingConfiguration: Partial) { state.pluginName = await input.showInputBox({ @@ -344,9 +344,9 @@ export async function generateSteps(existingConfiguration: Partial inputGenerationType(input, state), () => step-=2); return state; @@ -448,7 +448,7 @@ interface InputBoxParameters { totalSteps: number; value: string; prompt: string; - validate: (value: string) => Promise; + validate?: (value: string) => Promise; buttons?: QuickInputButton[]; ignoreFocusOut?: boolean; placeholder?: string; @@ -558,7 +558,7 @@ class MultiStepInput { ...(this.steps.length > 1 ? [QuickInputButtons.Back] : []), ...(buttons || []) ]; - let validating = validate(''); + let validating = validate ? validate(''): Promise.resolve(undefined); disposables.push( input.onDidTriggerButton(item => { if (item === QuickInputButtons.Back) { @@ -571,19 +571,21 @@ class MultiStepInput { const value = input.value; input.enabled = false; input.busy = true; - if (!(await validate(value))) { + if (!(validate && await validate(value))) { resolve(value); } input.enabled = true; input.busy = false; }), input.onDidChangeValue(async text => { - const current = validate(text); - validating = current; - const validationMessage = await current; - if (current === validating) { - input.validationMessage = validationMessage; - } + if(validate){ + const current = validate(text); + validating = current; + const validationMessage = await current; + if (current === validating) { + input.validationMessage = validationMessage; + } + } }), input.onDidHide(() => { (async () => { From 0e325f94f56020ee707b6296f9db9bb591cfb562 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 16 May 2024 16:45:51 +0300 Subject: [PATCH 043/150] move constants to separate file --- vscode/microsoft-kiota/src/constants.ts | 7 +++++++ vscode/microsoft-kiota/src/extension.ts | 8 +------- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 2 ++ vscode/microsoft-kiota/src/steps.ts | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 vscode/microsoft-kiota/src/constants.ts diff --git a/vscode/microsoft-kiota/src/constants.ts b/vscode/microsoft-kiota/src/constants.ts new file mode 100644 index 0000000000..776039173e --- /dev/null +++ b/vscode/microsoft-kiota/src/constants.ts @@ -0,0 +1,7 @@ +export const extensionId = "kiota"; +export const focusCommandId = ".focus"; +export const statusBarCommandId = `${extensionId}.status`; +export const treeViewId = `${extensionId}.openApiExplorer`; +export const treeViewFocusCommand = `${treeViewId}${focusCommandId}`; +export const dependenciesInfo = `${extensionId}.dependenciesInfo`; +export const kiotaLockFile = "workspace.json"; \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index d7dea4f59c..97202a72d6 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -29,16 +29,10 @@ import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; import { KiotaWorkspace } from "./workspaceTreeProvider"; import { generatePlugin } from "./generatePlugin"; import { CodeLensProvider } from "./codelensProvider"; +import { dependenciesInfo, extensionId, kiotaLockFile, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; -const extensionId = "kiota"; -const focusCommandId = ".focus"; -const statusBarCommandId = `${extensionId}.status`; -const treeViewId = `${extensionId}.openApiExplorer`; -const treeViewFocusCommand = `${treeViewId}${focusCommandId}`; -const dependenciesInfo = `${extensionId}.dependenciesInfo`; -export const kiotaLockFile = "workspace.json"; let globalClientKey: string; let globalClientObject: any; let globalGenerationType: string; diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 718cf49fbe..67f92b90b0 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -5,6 +5,7 @@ import * as vscode from 'vscode'; import * as rpc from 'vscode-jsonrpc/node'; import { connectToKiota, KiotaGetManifestDetailsConfiguration, KiotaLogEntry, KiotaManifestResult, KiotaOpenApiNode, KiotaShowConfiguration, KiotaShowResult, LockFile } from './kiotaInterop'; import { ExtensionSettings } from './extensionSettings'; +import { treeViewId } from './constants'; export class OpenApiTreeProvider implements vscode.TreeDataProvider { private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter(); @@ -94,6 +95,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider Date: Thu, 16 May 2024 18:01:07 +0300 Subject: [PATCH 044/150] remove path autoselection when description is loaded for the first time --- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 67f92b90b0..d57a1be2e1 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -229,6 +229,9 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider Date: Thu, 16 May 2024 18:01:26 +0300 Subject: [PATCH 045/150] fix workspace.json file not opening --- vscode/microsoft-kiota/package.json | 4 ++++ vscode/microsoft-kiota/package.nls.json | 1 + vscode/microsoft-kiota/src/workspaceTreeProvider.ts | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 968ceb3f81..e04ee19345 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -408,6 +408,10 @@ "title": "%kiota.openApiExplorer.openDescription.title%", "icon": "$(add)" }, + { + "command": "kiota.workspace.openWorkspaceFile", + "title": "%kiota.openApiExplorer.openFile.title%" + }, { "command": "kiota.editPaths", "title": "%kiota.openApiExplorer.editPaths.title%" diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index ac9e300e0b..8422222b56 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -28,6 +28,7 @@ "kiota.generate.deserializer.description": "The fully qualified class names for deserializers", "kiota.generate.structuredMimeTypes.description": "The MIME types and preference to use for structured data model generation. As per RFC9110 Accept header notation.", "kiota.generate.includeAdditionalData.description": "Will include the 'AdditionalData' property for models", + "kiota.openApiExplorer.openFile.title": "Open file", "kiota.workspace.name": "My Workspace", "kiota.openApiExplorer.regenerateButton.title": "Re-generate", "kiota.openApiExplorer.editPaths.title": "Edit paths" diff --git a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts index a5ca4d9115..ac8176e186 100644 --- a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts +++ b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts @@ -17,6 +17,10 @@ export class WorkspaceTreeProvider implements vscode.TreeDataProvider Date: Thu, 16 May 2024 18:57:04 +0300 Subject: [PATCH 046/150] hide add and remove icon on apiTitle node --- vscode/microsoft-kiota/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 036b0c03d0..4b2893e032 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -271,7 +271,7 @@ }, { "command": "kiota.openApiExplorer.addToSelectedEndpoints", - "when": "view == kiota.openApiExplorer", + "when": "view == kiota.openApiExplorer && viewItem != apiTitle", "group": "inline@2" }, { @@ -281,7 +281,7 @@ }, { "command": "kiota.openApiExplorer.removeFromSelectedEndpoints", - "when": "view == kiota.openApiExplorer", + "when": "view == kiota.openApiExplorer && viewItem != apiTitle", "group": "inline@3" }, { From 5bfe67537ce4182efbf0be3c5ae563e3b67abdcd Mon Sep 17 00:00:00 2001 From: ElinorW Date: Fri, 17 May 2024 15:12:47 +0300 Subject: [PATCH 047/150] undo closing descriptions after generation --- vscode/microsoft-kiota/src/extension.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 97202a72d6..f09292fb7b 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -292,6 +292,7 @@ export async function activate( await vscode.window.showErrorMessage( vscode.l10n.t("No endpoints selected, select endpoints first") ); + return; } if(globalGenerationType === "clients") { await regenerateClient(globalClientKey, globalClientObject, settings, selectedPaths); @@ -351,7 +352,6 @@ export async function activate( }, { "duration": duration, }); - openApiTreeProvider.closeDescription(); return result; }); //TODO refresh the kiota workspace @@ -391,7 +391,6 @@ export async function activate( }, { "duration": duration, }); - openApiTreeProvider.closeDescription(); return result; }); //TODO refresh the kiota workspace @@ -443,7 +442,6 @@ export async function activate( }, { "duration": duration, }); - openApiTreeProvider.closeDescription(); return result; }); @@ -501,7 +499,6 @@ export async function activate( }); void vscode.window.showInformationMessage(`Client ${clientKey} re-generated successfully.`); - openApiTreeProvider.closeDescription(); } async function regeneratePlugin(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]) { @@ -536,7 +533,6 @@ export async function activate( return result; }); void vscode.window.showInformationMessage(`Plugin ${clientKey} re-generated successfully.`); - openApiTreeProvider.closeDescription(); } // create a new status bar item that we can now manage From 6f1c049be2bf2824608b4bbb0e1aedf0ba37a512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Levert?= Date: Fri, 17 May 2024 14:39:35 +0000 Subject: [PATCH 048/150] Adding the automatic sideloading script --- scripts/execute-vscode-sideload.ps1 | 38 +++++++++++++++++++++++++++++ vscode/microsoft-kiota/debugging.md | 14 +++++++++++ 2 files changed, 52 insertions(+) create mode 100644 scripts/execute-vscode-sideload.ps1 diff --git a/scripts/execute-vscode-sideload.ps1 b/scripts/execute-vscode-sideload.ps1 new file mode 100644 index 0000000000..ce46669585 --- /dev/null +++ b/scripts/execute-vscode-sideload.ps1 @@ -0,0 +1,38 @@ +param ( + [string] + [Parameter(Mandatory = $false)] + $Platform = "win-x64", + [switch] + $WSL +) + + +Push-Location ./vscode/microsoft-kiota + +# Install all dependencies +npm i + +# Package the VS Code extension +vsce package + +# Getting package for its version +$PackageJson = Get-Content "package.json" -Raw | ConvertFrom-Json + +# Install the extension +code --install-extension "./kiota-$($PackageJson.version).vsix" + +$VsCodeRootPath = "~/.vscode" + +if ($WSL) { + $Platform = "linux-x64" + $VsCodeRootPath = "~/.vscode-server" +} + +$KiotaBin = "$VsCodeRootPath/extensions/ms-graph.kiota-$($PackageJson.version)/.kiotabin/$($PackageJson.kiotaVersion)/$Platform" + + + +Pop-Location + +# Building Kiota +dotnet publish ./src/kiota/kiota.csproj -p:PublishSingleFile=true -p:PublishReadyToRun=true --self-contained -c Release -r $platform -o $KiotaBin \ No newline at end of file diff --git a/vscode/microsoft-kiota/debugging.md b/vscode/microsoft-kiota/debugging.md index 4d8c88011a..bd3cfc59d9 100644 --- a/vscode/microsoft-kiota/debugging.md +++ b/vscode/microsoft-kiota/debugging.md @@ -47,6 +47,20 @@ Where kiotaVersionInPackage is the kiotaVersion field and versionInPackage is th > Note: alternatively to building executable yourself, you can download it from [the pipeline](https://github.com/microsoft/kiota/actions/workflows/dotnet.yml) by filtering the branch (top right corner) with the pull request branch, selecting the latest run, and downloading the right OS version from the artifacts. The only remaining work will be to move the downloaded files to the right path above. +#### Using the ready-made script + +If you want to automate these steps, you can use the following script to automate the process: + +```powershell +.\scripts\execute-vscode-sideload.ps1 -Platform "win-x64|linux-x64|osx-x64" +``` + +If you are using WSL, you can use the following: + +```powershell +.\scripts\execute-vscode-sideload.ps1 -WSL +``` + ## FAQ ### VS Code keeps reinstalling from the marketplace From 1fce6c87194458ccb6cad1705f362e6f8816307f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Levert?= Date: Fri, 17 May 2024 16:58:30 +0000 Subject: [PATCH 049/150] Update to using vsx --- scripts/execute-vscode-sideload.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/execute-vscode-sideload.ps1 b/scripts/execute-vscode-sideload.ps1 index ce46669585..d727f7626f 100644 --- a/scripts/execute-vscode-sideload.ps1 +++ b/scripts/execute-vscode-sideload.ps1 @@ -13,7 +13,7 @@ Push-Location ./vscode/microsoft-kiota npm i # Package the VS Code extension -vsce package +npx @vscode/vsce package # Getting package for its version $PackageJson = Get-Content "package.json" -Raw | ConvertFrom-Json @@ -30,8 +30,6 @@ if ($WSL) { $KiotaBin = "$VsCodeRootPath/extensions/ms-graph.kiota-$($PackageJson.version)/.kiotabin/$($PackageJson.kiotaVersion)/$Platform" - - Pop-Location # Building Kiota From 2a0db345e38bf348058b17244850282e1451e8fc Mon Sep 17 00:00:00 2001 From: ElinorW Date: Mon, 20 May 2024 15:33:18 +0300 Subject: [PATCH 050/150] fix icons display --- vscode/microsoft-kiota/src/extension.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index f09292fb7b..ad85af6e7e 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -280,7 +280,7 @@ export async function activate( globalClientKey = clientKey; globalClientObject = clientObject; globalGenerationType = generationType; - await loadEditPaths(clientObject, openApiTreeProvider); + await loadEditPaths(clientObject, openApiTreeProvider); await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, false); await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, true); }), @@ -667,6 +667,7 @@ async function showUpgradeWarningMessage(clientPath: string, context: vscode.Ext async function loadLockFile(node: { fsPath: string }, openApiTreeProvider: OpenApiTreeProvider): Promise { await openTreeViewWithProgress(() => openApiTreeProvider.loadLockFile(node.fsPath)); + await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, true); } async function loadEditPaths(clientObject: any, openApiTreeProvider: OpenApiTreeProvider): Promise { From 2bbf30105f31daf5324b2139def07910b14cfa73 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Mon, 20 May 2024 19:02:32 +0300 Subject: [PATCH 051/150] Merge branch 'main' into elinor/add-kiota-workspace --- .github/policies/resourceManagement.yml | 32 +++++++++---------- CHANGELOG.md | 1 + it/python/requirements-dev.txt | 8 ++--- .../Configuration/DownloadConfiguration.cs | 7 +++- .../Configuration/GenerationConfiguration.cs | 6 ++++ src/Kiota.Builder/Lock/KiotaLock.cs | 9 ++++++ src/Kiota.Builder/Lock/KiotaLockComparer.cs | 1 + .../GitHub/GitHubClient/kiota-lock.json | 5 +-- src/kiota/Handlers/BaseKiotaCommandHandler.cs | 26 ++++++++++++++- .../Handlers/KiotaDownloadCommandHandler.cs | 6 ++++ .../Handlers/KiotaGenerateCommandHandler.cs | 6 ++++ src/kiota/Handlers/KiotaShowCommandHandler.cs | 6 ++++ src/kiota/KiotaHost.cs | 19 +++++++++++ src/kiota/Properties/launchSettings.json | 2 +- 14 files changed, 109 insertions(+), 25 deletions(-) diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml index 25cff265f1..b9f1ee1a07 100644 --- a/.github/policies/resourceManagement.yml +++ b/.github/policies/resourceManagement.yml @@ -1,14 +1,14 @@ -id: +id: name: GitOps.PullRequestIssueManagement description: GitOps.PullRequestIssueManagement primitive -owner: +owner: resource: repository disabled: false -where: +where: configuration: resourceManagementConfiguration: scheduledSearches: - - description: + - description: frequencies: - hourly: hour: 6 @@ -16,14 +16,14 @@ configuration: - isIssue - isOpen - hasLabel: - label: 'Needs: Author Feedback' + label: 'status:waiting-for-author-feedback' - hasLabel: label: 'Status: No Recent Activity' - noActivitySince: days: 3 actions: - closeIssue - - description: + - description: frequencies: - hourly: hour: 6 @@ -31,7 +31,7 @@ configuration: - isIssue - isOpen - hasLabel: - label: 'Needs: Author Feedback' + label: 'status:waiting-for-author-feedback' - noActivitySince: days: 4 - isNotLabeledWith: @@ -41,7 +41,7 @@ configuration: label: 'Status: No Recent Activity' - addReply: reply: This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**. - - description: + - description: frequencies: - hourly: hour: 6 @@ -64,14 +64,14 @@ configuration: - isActivitySender: issueAuthor: True - hasLabel: - label: 'Needs: Author Feedback' + label: 'status:waiting-for-author-feedback' - isOpen then: - addLabel: label: 'Needs: Attention :wave:' - removeLabel: - label: 'Needs: Author Feedback' - description: + label: 'status:waiting-for-author-feedback' + description: - if: - payloadType: Issues - not: @@ -82,7 +82,7 @@ configuration: then: - removeLabel: label: 'Status: No Recent Activity' - description: + description: - if: - payloadType: Issue_Comment - hasLabel: @@ -90,12 +90,12 @@ configuration: then: - removeLabel: label: 'Status: No Recent Activity' - description: + description: - if: - payloadType: Pull_Request then: - inPrLabel: label: WIP - description: -onFailure: -onSuccess: + description: +onFailure: +onSuccess: diff --git a/CHANGELOG.md b/CHANGELOG.md index 611469f436..2e2b58c4ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added support for multipart form data request body in PHP. [#3029](https://github.com/microsoft/kiota/issues/3029) - Added uri-form encoded serialization for PHP. [#2074](https://github.com/microsoft/kiota/issues/2074) - Added information message with base URL in the CLI experience. [#4635](https://github.com/microsoft/kiota/issues/4635) +- Added optional parameter --disable-ssl-validation for generate, show, and download commands. [#4176](https://github.com/microsoft/kiota/issues/4176) ### Changed diff --git a/it/python/requirements-dev.txt b/it/python/requirements-dev.txt index 8c72e67286..9c0f3a43c3 100644 --- a/it/python/requirements-dev.txt +++ b/it/python/requirements-dev.txt @@ -1,6 +1,6 @@ -i https://pypi.org/simple -astroid==3.2.1 ; python_full_version >= '3.7.2' +astroid==3.2.2 ; python_full_version >= '3.7.2' certifi==2024.2.2 ; python_version >= '3.6' @@ -40,11 +40,11 @@ platformdirs==4.2.2 ; python_version >= '3.7' pluggy==1.5.0 ; python_version >= '3.7' -pylint==3.2.0 +pylint==3.2.2 -pytest==8.2.0 +pytest==8.2.1 -pytest-asyncio==0.23.6 +pytest-asyncio==0.23.7 requests==2.31.0 ; python_version >= '3.7' diff --git a/src/Kiota.Builder/Configuration/DownloadConfiguration.cs b/src/Kiota.Builder/Configuration/DownloadConfiguration.cs index df3c30ef24..b63a5a41d8 100644 --- a/src/Kiota.Builder/Configuration/DownloadConfiguration.cs +++ b/src/Kiota.Builder/Configuration/DownloadConfiguration.cs @@ -9,6 +9,10 @@ public bool CleanOutput { get; set; } + public bool DisableSSLValidation + { + get; set; + } public object Clone() { @@ -16,7 +20,8 @@ public object Clone() { OutputPath = OutputPath, CleanOutput = CleanOutput, - ClearCache = ClearCache + ClearCache = ClearCache, + DisableSSLValidation = DisableSSLValidation, }; } } diff --git a/src/Kiota.Builder/Configuration/GenerationConfiguration.cs b/src/Kiota.Builder/Configuration/GenerationConfiguration.cs index d00d410f9b..7200211e63 100644 --- a/src/Kiota.Builder/Configuration/GenerationConfiguration.cs +++ b/src/Kiota.Builder/Configuration/GenerationConfiguration.cs @@ -151,6 +151,7 @@ public object Clone() Operation = Operation, PatternsOverride = new(PatternsOverride ?? Enumerable.Empty(), StringComparer.OrdinalIgnoreCase), PluginTypes = new(PluginTypes ?? Enumerable.Empty()), + DisableSSLValidation = DisableSSLValidation, }; } private static readonly StringIEnumerableDeepComparer comparer = new(); @@ -200,6 +201,11 @@ private string NormalizeDescriptionLocation(string targetDirectory) return OpenAPIFilePath; } public bool IsPluginConfiguration => PluginTypes.Count != 0; + + public bool DisableSSLValidation + { + get; set; + } } #pragma warning restore CA1056 #pragma warning restore CA2227 diff --git a/src/Kiota.Builder/Lock/KiotaLock.cs b/src/Kiota.Builder/Lock/KiotaLock.cs index a299234a5d..433861a2fa 100644 --- a/src/Kiota.Builder/Lock/KiotaLock.cs +++ b/src/Kiota.Builder/Lock/KiotaLock.cs @@ -59,6 +59,13 @@ public bool IncludeAdditionalData { get; set; } + /// + /// Whether SSL Validation was disabled for this client. + /// + public bool DisableSSLValidation + { + get; set; + } #pragma warning disable CA2227 /// /// The serializers used for this client. @@ -108,6 +115,7 @@ public void UpdateGenerationConfigurationFromLock(GenerationConfiguration config config.ExcludePatterns = ExcludePatterns; config.OpenAPIFilePath = DescriptionLocation; config.DisabledValidationRules = DisabledValidationRules; + config.DisableSSLValidation = DisableSSLValidation; } /// /// Initializes a new instance of the class. @@ -135,5 +143,6 @@ public KiotaLock(GenerationConfiguration config) ExcludePatterns = config.ExcludePatterns; DescriptionLocation = config.OpenAPIFilePath; DisabledValidationRules = config.DisabledValidationRules; + DisableSSLValidation = config.DisableSSLValidation; } } diff --git a/src/Kiota.Builder/Lock/KiotaLockComparer.cs b/src/Kiota.Builder/Lock/KiotaLockComparer.cs index d4e564b776..ccaa75a1a4 100644 --- a/src/Kiota.Builder/Lock/KiotaLockComparer.cs +++ b/src/Kiota.Builder/Lock/KiotaLockComparer.cs @@ -21,6 +21,7 @@ public int GetHashCode([DisallowNull] KiotaLock obj) { if (obj == null) return 0; return + obj.DisableSSLValidation.GetHashCode() * 59 + _stringIEnumerableDeepComparer.GetHashCode(obj.DisabledValidationRules?.Order(StringComparer.OrdinalIgnoreCase) ?? Enumerable.Empty()) * 53 + obj.KiotaVersion.GetHashCode(StringComparison.OrdinalIgnoreCase) * 47 + obj.LockFileVersion.GetHashCode(StringComparison.OrdinalIgnoreCase) * 43 + diff --git a/src/Kiota.Builder/SearchProviders/GitHub/GitHubClient/kiota-lock.json b/src/Kiota.Builder/SearchProviders/GitHub/GitHubClient/kiota-lock.json index 226089fd75..0b438e5c4f 100644 --- a/src/Kiota.Builder/SearchProviders/GitHub/GitHubClient/kiota-lock.json +++ b/src/Kiota.Builder/SearchProviders/GitHub/GitHubClient/kiota-lock.json @@ -37,5 +37,6 @@ "**/generate", "**/repos/**/topics" ], - "disabledValidationRules": [] -} \ No newline at end of file + "disabledValidationRules": [], + "disableSSLValidation": false +} diff --git a/src/kiota/Handlers/BaseKiotaCommandHandler.cs b/src/kiota/Handlers/BaseKiotaCommandHandler.cs index 8d9f25d494..f1f2ce5fb7 100644 --- a/src/kiota/Handlers/BaseKiotaCommandHandler.cs +++ b/src/kiota/Handlers/BaseKiotaCommandHandler.cs @@ -31,7 +31,16 @@ protected static void DefaultSerializersAndDeserializers(GenerationConfiguration Logger = logger, FileName = "pat-api.github.com" }; - internal static readonly HttpClient httpClient = new(); + + private HttpClient? _httpClient; + protected HttpClient httpClient + { + get + { + _httpClient ??= GetHttpClient(); + return _httpClient; + } + } public required Option LogLevelOption { get; init; @@ -52,6 +61,21 @@ protected KiotaConfiguration Configuration configObject.BindConfiguration(configuration); return configObject; }); + + protected HttpClient GetHttpClient() + { + var httpClientHandler = new HttpClientHandler(); + if (Configuration.Generation.DisableSSLValidation) + httpClientHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; + + var httpClient = new HttpClient(httpClientHandler); + + disposables.Add(httpClientHandler); + disposables.Add(httpClient); + + return httpClient; + } + private const string GitHubScope = "repo"; private Func> GetIsGitHubDeviceSignedInCallback(ILogger logger) => (cancellationToken) => { diff --git a/src/kiota/Handlers/KiotaDownloadCommandHandler.cs b/src/kiota/Handlers/KiotaDownloadCommandHandler.cs index e5d8334be3..e61fa83fc3 100644 --- a/src/kiota/Handlers/KiotaDownloadCommandHandler.cs +++ b/src/kiota/Handlers/KiotaDownloadCommandHandler.cs @@ -31,6 +31,10 @@ public required Option CleanOutputOption { get; init; } + public required Option DisableSSLValidationOption + { + get; init; + } public override async Task InvokeAsync(InvocationContext context) { string searchTerm = context.ParseResult.GetValueForArgument(SearchTermArgument); @@ -38,9 +42,11 @@ public override async Task InvokeAsync(InvocationContext context) string outputPath = context.ParseResult.GetValueForOption(OutputPathOption) ?? string.Empty; bool cleanOutput = context.ParseResult.GetValueForOption(CleanOutputOption); bool clearCache = context.ParseResult.GetValueForOption(ClearCacheOption); + bool disableSSLValidation = context.ParseResult.GetValueForOption(DisableSSLValidationOption); CancellationToken cancellationToken = context.BindingContext.GetService(typeof(CancellationToken)) is CancellationToken token ? token : CancellationToken.None; Configuration.Download.ClearCache = clearCache; + Configuration.Download.DisableSSLValidation = disableSSLValidation; Configuration.Download.CleanOutput = cleanOutput; Configuration.Download.OutputPath = NormalizeSlashesInPath(outputPath); diff --git a/src/kiota/Handlers/KiotaGenerateCommandHandler.cs b/src/kiota/Handlers/KiotaGenerateCommandHandler.cs index 1f9cbbee49..a0442d81af 100644 --- a/src/kiota/Handlers/KiotaGenerateCommandHandler.cs +++ b/src/kiota/Handlers/KiotaGenerateCommandHandler.cs @@ -69,6 +69,7 @@ public override async Task InvokeAsync(InvocationContext context) bool backingStore = context.ParseResult.GetValueForOption(BackingStoreOption); bool excludeBackwardCompatible = context.ParseResult.GetValueForOption(ExcludeBackwardCompatibleOption); bool clearCache = context.ParseResult.GetValueForOption(ClearCacheOption); + bool disableSSLValidation = context.ParseResult.GetValueForOption(DisableSSLValidationOption); bool includeAdditionalData = context.ParseResult.GetValueForOption(AdditionalDataOption); string className = context.ParseResult.GetValueForOption(ClassOption) ?? string.Empty; string namespaceName = context.ParseResult.GetValueForOption(NamespaceOption) ?? string.Empty; @@ -112,6 +113,7 @@ public override async Task InvokeAsync(InvocationContext context) Configuration.Generation.ApiManifestPath = NormalizeSlashesInPath(GetAbsolutePath(Configuration.Generation.ApiManifestPath)); Configuration.Generation.CleanOutput = cleanOutput; Configuration.Generation.ClearCache = clearCache; + Configuration.Generation.DisableSSLValidation = disableSSLValidation; var (loggerFactory, logger) = GetLoggerAndFactory(context, Configuration.Generation.OutputPath); using (loggerFactory) @@ -173,4 +175,8 @@ public required Option ExcludeBackwardCompatibleOption get; set; } + public required Option DisableSSLValidationOption + { + get; init; + } } diff --git a/src/kiota/Handlers/KiotaShowCommandHandler.cs b/src/kiota/Handlers/KiotaShowCommandHandler.cs index eba912371e..e268ab55bf 100644 --- a/src/kiota/Handlers/KiotaShowCommandHandler.cs +++ b/src/kiota/Handlers/KiotaShowCommandHandler.cs @@ -41,6 +41,10 @@ public required Option ManifestOption { get; init; } + public required Option DisableSSLValidationOption + { + get; init; + } public override async Task InvokeAsync(InvocationContext context) { @@ -52,11 +56,13 @@ public override async Task InvokeAsync(InvocationContext context) List includePatterns = context.ParseResult.GetValueForOption(IncludePatternsOption) ?? new List(); List excludePatterns = context.ParseResult.GetValueForOption(ExcludePatternsOption) ?? new List(); bool clearCache = context.ParseResult.GetValueForOption(ClearCacheOption); + bool disableSSLValidation = context.ParseResult.GetValueForOption(DisableSSLValidationOption); CancellationToken cancellationToken = context.BindingContext.GetService(typeof(CancellationToken)) is CancellationToken token ? token : CancellationToken.None; var (loggerFactory, logger) = GetLoggerAndFactory(context); Configuration.Search.ClearCache = clearCache; + Configuration.Generation.DisableSSLValidation = disableSSLValidation; using (loggerFactory) { await CheckForNewVersionAsync(logger, cancellationToken).ConfigureAwait(false); diff --git a/src/kiota/KiotaHost.cs b/src/kiota/KiotaHost.cs index 8dda187bf3..955d22e4a4 100644 --- a/src/kiota/KiotaHost.cs +++ b/src/kiota/KiotaHost.cs @@ -153,6 +153,7 @@ private static Command GetShowCommand() var searchTermOption = GetSearchKeyOption(); var maxDepthOption = new Option("--max-depth", () => 5, "The maximum depth of the tree to display"); maxDepthOption.AddAlias("--m-d"); + var disableSSLValidationOption = GetDisableSSLValidationOption(defaultGenerationConfiguration.DisableSSLValidation); var displayCommand = new Command("show", "Displays the API tree in a given description."){ searchTermOption, logLevelOption, @@ -163,6 +164,7 @@ private static Command GetShowCommand() includePatterns, excludePatterns, clearCacheOption, + disableSSLValidationOption, }; displayCommand.Handler = new KiotaShowCommandHandler { @@ -175,6 +177,7 @@ private static Command GetShowCommand() IncludePatternsOption = includePatterns, ExcludePatternsOption = excludePatterns, ClearCacheOption = clearCacheOption, + DisableSSLValidationOption = disableSSLValidationOption, }; return displayCommand; } @@ -213,6 +216,8 @@ private static Command GetDownloadCommand() var outputOption = GetOutputPathOption(defaultConfiguration.OutputPath); + var disableSSLValidationOption = GetDisableSSLValidationOption(defaultConfiguration.DisableSSLValidation); + var searchCommand = new Command("download", "Downloads an OpenAPI description from multiple registries."){ keyArgument, logLevelOption, @@ -220,6 +225,7 @@ private static Command GetDownloadCommand() versionOption, cleanOutputOption, outputOption, + disableSSLValidationOption, }; searchCommand.Handler = new KiotaDownloadCommandHandler { @@ -229,6 +235,7 @@ private static Command GetDownloadCommand() VersionOption = versionOption, CleanOutputOption = cleanOutputOption, OutputPathOption = outputOption, + DisableSSLValidationOption = disableSSLValidationOption, }; return searchCommand; } @@ -444,6 +451,8 @@ private static Command GetGenerateCommand() var clearCacheOption = GetClearCacheOption(defaultConfiguration.ClearCache); + var disableSSLValidationOption = GetDisableSSLValidationOption(defaultConfiguration.DisableSSLValidation); + var command = new Command("generate", "Generates a REST HTTP API client from an OpenAPI description file.") { descriptionOption, manifestOption, @@ -463,6 +472,7 @@ private static Command GetGenerateCommand() excludePatterns, dvrOption, clearCacheOption, + disableSSLValidationOption, }; command.Handler = new KiotaGenerateCommandHandler { @@ -484,6 +494,7 @@ private static Command GetGenerateCommand() ExcludePatternsOption = excludePatterns, DisabledValidationRulesOption = dvrOption, ClearCacheOption = clearCacheOption, + DisableSSLValidationOption = disableSSLValidationOption, }; return command; } @@ -541,6 +552,14 @@ private static Option GetClearCacheOption(bool defaultValue) clearCacheOption.AddAlias("--cc"); return clearCacheOption; } + + private static Option GetDisableSSLValidationOption(bool defaultValue) + { + var disableSSLValidationOption = new Option("--disable-ssl-validation", () => defaultValue, "Disables SSL certificate validation."); + disableSSLValidationOption.AddAlias("--dsv"); + return disableSSLValidationOption; + } + private static void AddStringRegexValidator(Option option, Regex validator, string parameterName, bool allowEmpty = false) { option.AddValidator(input => diff --git a/src/kiota/Properties/launchSettings.json b/src/kiota/Properties/launchSettings.json index cfdf1701e0..627716184d 100644 --- a/src/kiota/Properties/launchSettings.json +++ b/src/kiota/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "kiota": { "commandName": "Project", - "commandLineArgs": "--openapi C:\\src\\msgraph-sdk-powershell\\openApiDocs\\v1.0\\mail.yml -o C:\\Users\\darrmi\\source\\github\\darrelmiller\\OpenApiClient\\Generated -c GraphClient --loglevel Information" + "commandLineArgs": "generate --openapi https://localhost:3000/swagger.json -o E:\\OSS\\kiota\\Output\\local_3 -c GraphClient --log-level Information -l CSharp --dsv" } } } From 669348dd856adb694c447327bb4d597c473c6406 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 12:26:41 +0300 Subject: [PATCH 052/150] remove welcome translations --- vscode/microsoft-kiota/package.nls.it.json | 1 - vscode/microsoft-kiota/package.nls.ja.json | 1 - vscode/microsoft-kiota/package.nls.pl.json | 3 +-- vscode/microsoft-kiota/package.nls.pt.json | 1 - vscode/microsoft-kiota/package.nls.ru.json | 1 - vscode/microsoft-kiota/package.nls.sw.json | 1 - vscode/microsoft-kiota/package.nls.tr.json | 1 - vscode/microsoft-kiota/package.nls.zh-cn.json | 1 - 8 files changed, 1 insertion(+), 9 deletions(-) diff --git a/vscode/microsoft-kiota/package.nls.it.json b/vscode/microsoft-kiota/package.nls.it.json index 1e93c7d767..27ce1f4849 100644 --- a/vscode/microsoft-kiota/package.nls.it.json +++ b/vscode/microsoft-kiota/package.nls.it.json @@ -14,7 +14,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Rimuovi tutti", "kiota.openApiExplorer.closeDescription.title": "Chiudi la descrizione API", "kiota.openApiExplorer.openDescription.title": "Apri una descrizione API", - "kiota.openApiExplorer.welcome": "Nessuna descrizione delle API selezionata.\n[Search](command:kiota.searchOrOpenApiDescription)\n[Apri una descrizione API](command:kiota.openApiExplorer.openDescription)\n[Apri un manifest](command:kiota.openApiExplorer.openManifestPath)\n[Copia un manifest](command:kiota.openApiExplorer.pasteManifest)\n[Seleziona un file di lock](command:kiota.searchLock)", "kiota.searchLock.title": "Cerca il file di lock", "kiota.openApiExplorer.filterDescription.title": "Filtra la descrizione delle API", "kiota.openApiExplorer.openDocumentationPage.title": "Apri la pagina di documentazione", diff --git a/vscode/microsoft-kiota/package.nls.ja.json b/vscode/microsoft-kiota/package.nls.ja.json index 4f5f26e423..945185816a 100644 --- a/vscode/microsoft-kiota/package.nls.ja.json +++ b/vscode/microsoft-kiota/package.nls.ja.json @@ -14,7 +14,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "すべて削除", "kiota.openApiExplorer.closeDescription.title": "API仕様書を閉じる", "kiota.openApiExplorer.openDescription.title": "API仕様書を開く", - "kiota.openApiExplorer.welcome": "API仕様書が選択されていません。\n[検索](command:kiota.searchOrOpenApiDescription)\n[API仕様書を開く](command:kiota.openApiExplorer.openDescription)\n[マニフェストを開く](command:kiota.openApiExplorer.openManifestPath)\n[マニフェストを貼り付け](command:kiota.openApiExplorer.pasteManifest)\n[ロックファイルを選択](command:kiota.searchLock)", "kiota.searchLock.title": "ロックファイルを検索", "kiota.openApiExplorer.filterDescription.title": "API仕様書をフィルタ", "kiota.openApiExplorer.openDocumentationPage.title": "ドキュメントページを開く", diff --git a/vscode/microsoft-kiota/package.nls.pl.json b/vscode/microsoft-kiota/package.nls.pl.json index 0cce8f2530..2fc27cf3ce 100644 --- a/vscode/microsoft-kiota/package.nls.pl.json +++ b/vscode/microsoft-kiota/package.nls.pl.json @@ -15,7 +15,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Usuń wszystkie", "kiota.openApiExplorer.closeDescription.title": "Zamknij opis API", "kiota.openApiExplorer.openDescription.title": "Otwórz opis API", - "kiota.openApiExplorer.welcome": "Nie wybrano opisu API.\n[Wyszukaj](command:kiota.searchApiDescription)\n[Otwórz opis API](command:kiota.openApiExplorer.openDescription)\n[Otwórz manifest](command:kiota.openApiExplorer.openManifestPath)\n[Wklej manifest](command:kiota.openApiExplorer.pasteManifest)\n[Wybierz plik lock](command:kiota.searchLock)", "kiota.searchLock.title": "Wyszukaj plik lock", "kiota.openApiExplorer.filterDescription.title": "Filtruj opis API", "kiota.openApiExplorer.openDocumentationPage.title": "Otwórz stronę dokumentacji", @@ -30,4 +29,4 @@ "kiota.generate.deserializer.description": "Pełne nazwy klas dla deserializatorów", "kiota.generate.structuredMimeTypes.description": "Typy MIME i preferencje do użycia dla generacji modeli danych strukturalnych. Zgodnie z notacją nagłówka Accept RFC9110.", "kiota.generate.includeAdditionalData.description": "Doda właściwości 'AdditionalData' do modeli" -} \ No newline at end of file +} diff --git a/vscode/microsoft-kiota/package.nls.pt.json b/vscode/microsoft-kiota/package.nls.pt.json index a5b2500248..e48ffdc145 100644 --- a/vscode/microsoft-kiota/package.nls.pt.json +++ b/vscode/microsoft-kiota/package.nls.pt.json @@ -14,7 +14,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Remover todos", "kiota.openApiExplorer.closeDescription.title": "Fechar a descrição da API", "kiota.openApiExplorer.openDescription.title": "Abrir a descrição da API", - "kiota.openApiExplorer.welcome": "Nenhuma descrição de API selecionada.\n[Procurar](command:kiota.searchOrOpenApiDescription)\n[Abrir a descrição da API](command:kiota.openApiExplorer.openDescription)\n[Abrir um manifesto](command:command:kiota.openApiExplorer.openManifestPath)\n[Colar um manifesto](command:kiota.openApiExplorer.pasteManifest)\n[Selecionar arquivo lock](command:kiota.searchLock)", "kiota.searchLock.title": "Buscar um arquivo lock", "kiota.openApiExplorer.filterDescription.title": "Filtrar descrição da API", "kiota.openApiExplorer.openDocumentationPage.title": "Abrir página de documentação", diff --git a/vscode/microsoft-kiota/package.nls.ru.json b/vscode/microsoft-kiota/package.nls.ru.json index 7f9d7b6d23..809c1b4d93 100644 --- a/vscode/microsoft-kiota/package.nls.ru.json +++ b/vscode/microsoft-kiota/package.nls.ru.json @@ -14,7 +14,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Удалить всё", "kiota.openApiExplorer.closeDescription.title": "Закрыть описание API", "kiota.openApiExplorer.openDescription.title": "Открыть описание API", - "kiota.openApiExplorer.welcome": "Не выбрано описание API.\n[поиск](command:kiota.searchOrOpenApiDescription)\n[Открыть описание API](command:kiota.openApiExplorer.openDescription)\n[Вставьте манифест](command:kiota.openApiExplorer.openManifestPath)\n[Откройте манифест](command:kiota.openApiExplorer.pasteManifest)\n[выделить](command:kiota.searchLock)", "kiota.searchLock.title": "Искать файл блокировки", "kiota.openApiExplorer.filterDescription.title": "Отфильтровать описание API", "kiota.openApiExplorer.openDocumentationPage.title": "Открыть страницу документации", diff --git a/vscode/microsoft-kiota/package.nls.sw.json b/vscode/microsoft-kiota/package.nls.sw.json index 4fafae3e48..2437ae419d 100644 --- a/vscode/microsoft-kiota/package.nls.sw.json +++ b/vscode/microsoft-kiota/package.nls.sw.json @@ -14,7 +14,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Ondoa yote", "kiota.openApiExplorer.closeDescription.title": "Funga maelezo ya API", "kiota.openApiExplorer.openDescription.title": "Fungua maelezo ya API", - "kiota.openApiExplorer.welcome": "Hakuna maelezo ya API yaliyochaguliwa.\n[Tafuta](command:kiota.searchOrOpenApiDescription)\n[Fungua maelezo ya API](command:kiota.openApiExplorer.openDescription)\n[Fungua faili ya dhahiri](command:kiota.openApiExplorer.openManifestPath)\\n[Bandika faili ya dhahiri](command:kiota.openApiExplorer.pasteManifest)\n[Chagua faili ya kufunga](command:kiota.searchLock)", "kiota.searchLock.title": "Tafuta faili ya kufunga", "kiota.openApiExplorer.filterDescription.title": "Chuja maelezo ya API", "kiota.openApiExplorer.openDocumentationPage.title": "Fungua ukurasa wa nyaraka", diff --git a/vscode/microsoft-kiota/package.nls.tr.json b/vscode/microsoft-kiota/package.nls.tr.json index 713c3ba59d..ae99d85a02 100644 --- a/vscode/microsoft-kiota/package.nls.tr.json +++ b/vscode/microsoft-kiota/package.nls.tr.json @@ -14,7 +14,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Tümünü kaldır", "kiota.openApiExplorer.closeDescription.title": "API açıklamasını kapat", "kiota.openApiExplorer.openDescription.title": "API açıklamasını aç", - "kiota.openApiExplorer.welcome": "Seçili bir API açıklaması yok.\n[Ara](command:kiota.searchOrOpenApiDescription)\n[Aç](command:kiota.openApiExplorer.openDescription)\n[Kilit dosyasını seç](command:kiota.searchLock)", "kiota.searchLock.title": "Kilit dosyası arayın", "kiota.openApiExplorer.filterDescription.title": "API açıklaması filtrele", "kiota.openApiExplorer.openDocumentationPage.title": "API belgelerini aç", diff --git a/vscode/microsoft-kiota/package.nls.zh-cn.json b/vscode/microsoft-kiota/package.nls.zh-cn.json index 044854653c..41a799a764 100644 --- a/vscode/microsoft-kiota/package.nls.zh-cn.json +++ b/vscode/microsoft-kiota/package.nls.zh-cn.json @@ -14,7 +14,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "删除所有", "kiota.openApiExplorer.closeDescription.title": "关闭API描述文档", "kiota.openApiExplorer.openDescription.title": "打开API描述文档", - "kiota.openApiExplorer.welcome": "无API描述文档选择.\n[搜索](command:kiota.searchOrOpenApiDescription)\n[打开API描述文档](command:kiota.openApiExplorer.openDescription)\n[打开清单](command:command:kiota.openApiExplorer.openManifestPath)\n[粘贴清单](command:kiota.openApiExplorer.pasteManifest)\n[选择锁定文件](command:kiota.searchLock)", "kiota.searchLock.title": "搜索锁定文件", "kiota.openApiExplorer.filterDescription.title": "筛选API描述", "kiota.openApiExplorer.openDocumentationPage.title": "打开文档页", From 65558cb2ba748278d30b7414b0fc5eefdc5dbfe8 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 12:31:09 +0300 Subject: [PATCH 053/150] remove welcome string translation --- vscode/microsoft-kiota/package.nls.ar.json | 1 - vscode/microsoft-kiota/package.nls.cs.json | 1 - vscode/microsoft-kiota/package.nls.es.json | 1 - vscode/microsoft-kiota/package.nls.fr.json | 1 - 4 files changed, 4 deletions(-) diff --git a/vscode/microsoft-kiota/package.nls.ar.json b/vscode/microsoft-kiota/package.nls.ar.json index 3b203a39ec..1aa0acd146 100644 --- a/vscode/microsoft-kiota/package.nls.ar.json +++ b/vscode/microsoft-kiota/package.nls.ar.json @@ -14,7 +14,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "احذف الكل", "kiota.openApiExplorer.closeDescription.title": "اغلق وصف API", "kiota.openApiExplorer.openDescription.title": "افتح وصف API", - "kiota.openApiExplorer.welcome": "لم يتم اختيار وصف API\n[ابحث](command:kiota.searchOrOpenApiDescription)\n[افتح وصف API](command:kiota.openApiExplorer.openDescription)\n[افتح البيان](command:command:kiota.openApiExplorer.openManifestPath)\n[الصق البيان](command:kiota.openApiExplorer.pasteManifest)\n[اختر ملف](command:kiota.searchLock)", "kiota.searchLock.title": "ابحث عن ملف قفل", "kiota.openApiExplorer.filterDescription.title": "قم بتصفية وصف API", "kiota.openApiExplorer.openDocumentationPage.title": "افتح صفحة الوثائق", diff --git a/vscode/microsoft-kiota/package.nls.cs.json b/vscode/microsoft-kiota/package.nls.cs.json index fa8f77b94d..7ba0a21872 100644 --- a/vscode/microsoft-kiota/package.nls.cs.json +++ b/vscode/microsoft-kiota/package.nls.cs.json @@ -14,7 +14,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Odebrat vše", "kiota.openApiExplorer.closeDescription.title": "Zavřít popis API", "kiota.openApiExplorer.openDescription.title": "Otevřít popis API", - "kiota.openApiExplorer.welcome": "Není vybrán žádný popis API.\n[Hledat](command:kiota.searchOrOpenApiDescription)\n[Otevřít popis API](command:kiota.openApiExplorer.openDescription)\n[Otevřít manifest](command:kiota.openApiExplorer.openManifestPath)\n[Vložit manifest](command:kiota.openApiExplorer.pasteManifest)\n[Vybrat soubor se zámkem](command:kiota.searchLock)", "kiota.searchLock.title": "Hledat soubor se zámkem", "kiota.openApiExplorer.filterDescription.title": "Filtrovat popis API", "kiota.openApiExplorer.openDocumentationPage.title": "Otevřít stránku dokumentace", diff --git a/vscode/microsoft-kiota/package.nls.es.json b/vscode/microsoft-kiota/package.nls.es.json index 0bfec62161..31c43f3a56 100644 --- a/vscode/microsoft-kiota/package.nls.es.json +++ b/vscode/microsoft-kiota/package.nls.es.json @@ -14,7 +14,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Quitar todo", "kiota.openApiExplorer.closeDescription.title": "Cerrar descripción del API", "kiota.openApiExplorer.openDescription.title": "Abrir descripción del API", - "kiota.openApiExplorer.welcome": "No ha seleccionado una descripción de API.\n[Buscar](command:kiota.searchOrOpenApiDescription)\n[Abrir](command:kiota.openApiExplorer.openDescription)\n[Seleccionar archivo lock](command:kiota.searchLock)", "kiota.searchLock.title": "Buscar un archivo lock", "kiota.openApiExplorer.filterDescription.title": "Filtrar descripción de API", "kiota.openApiExplorer.openDocumentationPage.title": "Abrir documentación", diff --git a/vscode/microsoft-kiota/package.nls.fr.json b/vscode/microsoft-kiota/package.nls.fr.json index 90a875105e..97a3590115 100644 --- a/vscode/microsoft-kiota/package.nls.fr.json +++ b/vscode/microsoft-kiota/package.nls.fr.json @@ -14,7 +14,6 @@ "kiota.openApiExplorer.removeAllFromSelectedEndpoints.title": "Tout supprimer", "kiota.openApiExplorer.closeDescription.title": "Fermer la description d'API", "kiota.openApiExplorer.openDescription.title": "Ouvrir une description d'API", - "kiota.openApiExplorer.welcome": "Aucune description sélectionnée.\n[Rechercher](command:kiota.searchOrOpenApiDescription)\n[Ouvrir une description OpenAPI](command:kiota.openApiExplorer.openDescription)\n[Ouvrir un manifeste d'API](command:command:kiota.openApiExplorer.openManifestPath)\n[Coller un manifeste d'API](command:kiota.openApiExplorer.pasteManifest)\n[Sélectionner un fichier verrou](command:kiota.searchLock)", "kiota.searchLock.title": "Rechercher un fichier verrou", "kiota.openApiExplorer.filterDescription.title": "Filtrer la description", "kiota.openApiExplorer.openDocumentationPage.title": "Ouvrir la page de documentation", From 7b03451416fd0e6391e025e479776f875effb90e Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 14:27:11 +0300 Subject: [PATCH 054/150] add string translations --- .../microsoft-kiota/l10n/bundle.l10n.ar.json | 35 ++++++++++++++++++- .../microsoft-kiota/l10n/bundle.l10n.cs.json | 35 ++++++++++++++++++- .../microsoft-kiota/l10n/bundle.l10n.es.json | 35 ++++++++++++++++++- .../microsoft-kiota/l10n/bundle.l10n.fr.json | 35 ++++++++++++++++++- .../microsoft-kiota/l10n/bundle.l10n.it.json | 35 ++++++++++++++++++- .../microsoft-kiota/l10n/bundle.l10n.ja.json | 34 +++++++++++++++++- .../microsoft-kiota/l10n/bundle.l10n.pl.json | 35 ++++++++++++++++++- .../microsoft-kiota/l10n/bundle.l10n.pt.json | 35 ++++++++++++++++++- .../microsoft-kiota/l10n/bundle.l10n.ru.json | 35 ++++++++++++++++++- .../microsoft-kiota/l10n/bundle.l10n.sw.json | 35 ++++++++++++++++++- .../microsoft-kiota/l10n/bundle.l10n.tr.json | 35 ++++++++++++++++++- .../l10n/bundle.l10n.zh-cn.json | 35 ++++++++++++++++++- .../microsoft-kiota/src/codelensProvider.ts | 5 +-- vscode/microsoft-kiota/src/steps.ts | 28 +++++++-------- 14 files changed, 424 insertions(+), 28 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json index 91bba6d3c1..eeaa295800 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json @@ -38,5 +38,38 @@ "Invalid URL, please check the documentation for the supported URLs": "عنوان URL غير صالح ، يرجى التحقق من الوثائق الخاصة بعناوين URL المدعومة", "No content found in the clipboard": "لم يتم العثور على محتوى في الحافظة", "Invalid content found in the clipboard": "تم العثور على محتوى غير صالح في الحافظة", - "Select an API manifest key": "حدد مفتاح بيان واجهة برمجة التطبيقات" + "Select an API manifest key": "حدد مفتاح بيان واجهة برمجة التطبيقات", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "", + "Generate a plugin": "", + "Generate an API manifest": "", + "What do you want to generate?": "", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "", + "Create a new plugin": "", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Open installation instructions for kiota?": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json index 8557192d66..6c500c13c5 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json @@ -38,5 +38,38 @@ "Invalid URL, please check the documentation for the supported URLs": "Neplatná URL adresa, zkontrolujte dokumentaci pro podporované URL adresy", "No content found in the clipboard": "V schránce nebyl nalezen žádný obsah", "Invalid content found in the clipboard": "V schránce byl nalezen neplatný obsah", - "Select an API manifest key": "Vyberte klíč manifestu API" + "Select an API manifest key": "Vyberte klíč manifestu API", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "Hledat nebo vložit cestu k popisu API", + "Generate a plugin": "Generovat plugin", + "Generate an API manifest": "Generovat API manifest", + "What do you want to generate?": "Co chcete generovat? ", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "Vytvořit nového API klienta", + "Create a new plugin": "Vytvořit nový plugin", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Open installation instructions for kiota?": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "Chcete odstranit tento popis API?", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json index 675220017d..2934a7b281 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json @@ -38,5 +38,38 @@ "Invalid URL, please check the documentation for the supported URLs": "URL inválido, por favor revise la documentación de URL soportados.", "No content found in the clipboard": "Sin contenido en el portapapeles.", "Invalid content found in the clipboard": "Contenido inválido en el portapapeles.", - "Select an API manifest key": "Seleccione una llave de manifesto de API." + "Select an API manifest key": "Seleccione una llave de manifesto de API.", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "Busca o pega una ruta a una descripcion de API", + "Generate a plugin": "Generar un plugin", + "Generate an API manifest": "Generar un manifesto de API", + "What do you want to generate?": "Qué quieres generar?", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "Crear un nuevo cliente de API", + "Create a new plugin": "Crear un nuevo plugin", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Open installation instructions for kiota?": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "Quieres quitar esta descripcion de API?", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json index 1b41011b49..778a8271e0 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json @@ -38,5 +38,38 @@ "Invalid URL, please check the documentation for the supported URLs": "URL invalide, veuillez vérifier la documentation pour les URL prises en charge", "No content found in the clipboard": "Aucun contenu trouvé dans le presse-papiers", "Invalid content found in the clipboard": "Contenu non valide trouvé dans le presse-papiers", - "Select an API manifest key": "Sélectionnez une clé de manifeste d'API" + "Select an API manifest key": "Sélectionnez une clé de manifeste d'API", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "Rechercher ou coller un chemin vers unde description d'API", + "Generate a plugin": "Générer un plugin", + "Generate an API manifest": "Générer un manifeste d'API", + "What do you want to generate?": "Que souhaitez vous générer?", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "Créer un nouveau client d'API", + "Create a new plugin": "Créer un nouveau composant", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Open installation instructions for kiota?": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "Voulez-vous supprimer cette description d'API?", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json index 060177cac0..3bb0322267 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json @@ -38,5 +38,38 @@ "Invalid URL, please check the documentation for the supported URLs": "URL non valido, controlla la documentazione per gli URL supportati", "No content found in the clipboard": "Nessun contenuto trovato negli appunti", "Invalid content found in the clipboard": "Contenuto non valido trovato negli appunti", - "Select an API manifest key": "Seleziona una chiave del manifest API" + "Select an API manifest key": "Seleziona una chiave del manifest API", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "Cerca o incolla un percorso ad un file di descrizione API", + "Generate a plugin": "Genera un plugin", + "Generate an API manifest": "Genera un manifest API", + "What do you want to generate?": "Cosa vuoi generare?", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "Crea un nuovo client API", + "Create a new plugin": "Crea un nuovo plugin", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Open installation instructions for kiota?": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "Vuoi rimuovere questa descrizione API ?", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json index aa845bc001..c9c13a2abf 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json @@ -39,5 +39,37 @@ "Invalid URL, please check the documentation for the supported URLs": "URLが無効です。サポートされているURLについてはドキュメントを確認してください", "No content found in the clipboard": "クリップボードの内容が空です", "Invalid content found in the clipboard": "クリップボードの内容が無効です", - "Select an API manifest key": "APIマニフェストキーを選択" + "Select an API manifest key": "APIマニフェストキーを選択", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "", + "Generate a plugin": "", + "Generate an API manifest": "", + "What do you want to generate?": "", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "", + "Create a new plugin": "", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json index cf713472cb..101705d1b7 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json @@ -38,5 +38,38 @@ "Invalid URL, please check the documentation for the supported URLs": "Nieprawidłowy adres URL, sprawdź dokumentację żeby dowiedzieć się jakie są obsługiwane adresy URL", "No content found in the clipboard": "Nie znaleziono zawartości w schowku", "Invalid content found in the clipboard": "Znaleziono nieprawidłową zawartość w schowku", - "Select an API manifest key": "Wybierz klucz manifestu API" + "Select an API manifest key": "Wybierz klucz manifestu API", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "Wyszukaj lub wklej ścieżkę do opisu API", + "Generate a plugin": "Wygeneruj wtyczkę ", + "Generate an API manifest": "Wygeneruj manifest API ", + "What do you want to generate?": "Co chcesz wygenerować? ", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "Utwórz nowego klienta API ", + "Create a new plugin": "Utwórz nową wtyczkę", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Open installation instructions for kiota?": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "Czy chcesz usunąć ten opis API?", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json index c3df497d53..38416e7d68 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json @@ -38,5 +38,38 @@ "Invalid URL, please check the documentation for the supported URLs": "URL inválida, por favor, confira a documentação de URLs compatíveis", "No content found in the clipboard": "Nenhum conteúdo encontrado na área de transferência", "Invalid content found in the clipboard": "Conteúdo inváido na área de transferência", - "Select an API manifest key": "Selecione uma chave para um manifesto de API" + "Select an API manifest key": "Selecione uma chave para um manifesto de API", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "Busque ou cole o caminho para uma descrição de API", + "Generate a plugin": "Gerar um plugin ", + "Generate an API manifest": "Gerar um API manifest", + "What do you want to generate?": "O que você quer gerar?", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "Criar um novo cliente de API", + "Create a new plugin": "Criar um novo plugin ", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Open installation instructions for kiota?": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "Você quer remover a descrição dessa API?", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json index 132bf2114f..38f478299d 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json @@ -37,5 +37,38 @@ "Invalid URL, please check the documentation for the supported URLs": "Неверный URL, пожалуйста, проверьте документацию на поддерживаемые URL", "No content found in the clipboard": "В буфере обмена нет содержимого", "Invalid content found in the clipboard": "В буфере обмена обнаружено недопустимое содержимое", - "Select an API manifest key": "Выберите ключ манифеста API для редактирования" + "Select an API manifest key": "Выберите ключ манифеста API для редактирования", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "", + "Generate a plugin": "", + "Generate an API manifest": "", + "What do you want to generate?": "", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "", + "Create a new plugin": "", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Open installation instructions for kiota?": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json index c7e16273da..e1cbd9041a 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json @@ -38,5 +38,38 @@ "Invalid URL, please check the documentation for the supported URLs": "URL batili, tafadhali angalia nyaraka kupata URL zinazotumika", "No content found in the clipboard": "Hakuna maudhui yaliyopatikana katika eneo la kunakili", "Invalid content found in the clipboard": "Maudhui batili yamepatikana katika eneo la kunakili", - "Select an API manifest key": "Chagua funguo ya dhahiri ya API" + "Select an API manifest key": "Chagua funguo ya dhahiri ya API", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "Tafuta au bandika njia ya maelezo ya API", + "Generate a plugin": "Tengeneza programu-jalizi", + "Generate an API manifest": "Tengeneza dhahiri ya API", + "What do you want to generate?": "Unataka kutengeneza nini?", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "Tengeneza mteja mpya wa API", + "Create a new plugin": "Tengeneza programu-jalizi mpya", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Open installation instructions for kiota?": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "Ungetaka kuondoa maelezo haya ya API?", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json index e521f1abf7..5d216dc217 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json @@ -38,5 +38,38 @@ "Invalid URL, please check the documentation for the supported URLs": "Geçersiz URL, lütfen desteklenen URL'ler için dokümanları kontrol edin", "No content found in the clipboard": "Panoda içerik bulunamadı", "Invalid content found in the clipboard": "Panoda geçersiz içerik bulundu", - "Select an API manifest key": "Bir API manifest anahtarı seçin" + "Select an API manifest key": "Bir API manifest anahtarı seçin", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "", + "Generate a plugin": "", + "Generate an API manifest": "", + "What do you want to generate?": "", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "", + "Create a new plugin": "", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Open installation instructions for kiota?": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json index 390b462adb..46dfed048f 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json @@ -37,5 +37,38 @@ "Invalid URL, please check the documentation for the supported URLs": "无效路径,请检查在文档中寻找支持的路径", "No content found in the clipboard": "剪贴板空白", "Invalid content found in the clipboard": "剪贴板内容无效", - "Select an API manifest key": "选择API清单访问密钥" + "Select an API manifest key": "选择API清单访问密钥", + "Edit Paths":"", + "Re-generate": "", + "Add an API description": "", + "Search or paste a path to an API description": "搜索或粘贴 API 描述的路径", + "Generate a plugin": "生成插件", + "Generate an API manifest": "生成 API 清单", + "What do you want to generate?": "您要生成什么", + "Select an option": "", + "class": "", + "namespace": "", + "output path": "", + "language": "", + "Create a new API client": "创建新的 API 客户端", + "Create a new plugin": "创建一个新插件", + "Create a new manifest": "", + "plugin name:": "", + "Choose a name for the plugin:": "", + "Choose a plugin type": "", + "manifest name": "", + "Choose a name for the manifest": "", + "Required": "", + "Open installation instructions for kiota?": "", + "Invalid generation type": "", + "Yes, override it": "", + "Before adding a new API description, consider that your changes and current selection will be lost.": "", + "Cancel": "", + "Do you want to remove this API description?": "是否要删除此 API 描述?", + "Please save the workspace.json file before re-generation.": "", + "OK": "", + "Generating manifest...": "", + "Generating plugin...": "", + "Re-generating client...": "", + "Re-generating plugin...": "" } diff --git a/vscode/microsoft-kiota/src/codelensProvider.ts b/vscode/microsoft-kiota/src/codelensProvider.ts index a025b7be5a..63550c9506 100644 --- a/vscode/microsoft-kiota/src/codelensProvider.ts +++ b/vscode/microsoft-kiota/src/codelensProvider.ts @@ -1,4 +1,5 @@ import * as vscode from 'vscode'; +import { l10n } from 'vscode'; export class CodeLensProvider implements vscode.CodeLensProvider { public provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.ProviderResult { @@ -18,14 +19,14 @@ export class CodeLensProvider implements vscode.CodeLensProvider { const rangeBeforeObj = new vscode.Range(positionBeforeObj, positionBeforeObj); const editPathsCommand = { - title: "Edit Paths", + title: l10n.t("Edit Paths"), command: "kiota.editPaths", arguments: [key, obj, objectKey] }; codeLenses.push(new vscode.CodeLens(rangeBeforeObj, editPathsCommand)); const regenerateCommand = { - title: "Re-generate", + title: l10n.t("Re-generate"), command: "kiota.regenerate", arguments: [key, obj, objectKey] }; diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index e5cfc6a7a1..f1ff0aaa7a 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -201,32 +201,32 @@ export async function generateSteps(existingConfiguration: Partial) { - const items = ['Generate an API client', 'Generate a plugin', 'Generate an API manifest']; + const items = [l10n.t('Generate an API client'), l10n.t('Generate a plugin'), l10n.t('Generate an API manifest')]; const option = await input.showQuickPick({ title: l10n.t('What do you want to generate?'), step: 1, totalSteps: 1, - placeholder: 'Select an option', + placeholder: l10n.t('Select an option'), items: items.map(x => ({label: x})), validate: validateIsNotEmpty, shouldResume: shouldResume }); - if(option.label === 'Generate an API client') { + if(option.label === l10n.t('Generate an API client')) { state.generationType = "client"; return (input: MultiStepInput) => inputClientClassName(input, state); } - else if(option.label === 'Generate a plugin') { + else if(option.label === l10n.t('Generate a plugin')) { state.generationType = "plugin"; return (input: MultiStepInput) => inputPluginName(input, state); } - else if(option.label === 'Generate an API manifest') { + else if(option.label === l10n.t('Generate an API manifest')) { state.generationType = "apimanifest"; return (input: MultiStepInput) => inputManifestName(input, state); } } async function inputClientClassName(input: MultiStepInput, state: Partial) { state.clientClassName = await input.showInputBox({ - title: l10n.t('Create a new API client - class'), + title: `${l10n.t('Create a new API client')} - ${l10n.t('class')}`, step: step++, totalSteps: totalSteps, value: state.clientClassName || '', @@ -239,7 +239,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.clientNamespaceName = await input.showInputBox({ - title: l10n.t('Create a new API client - namespace'), + title: `${l10n.t('Create a new API client')} - ${l10n.t('namespace')}`, step: step++, totalSteps: totalSteps, value: typeof state.clientNamespaceName === 'string' ? state.clientNamespaceName : '', @@ -252,7 +252,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.outputPath = await input.showInputBox({ - title: l10n.t('Create a new API client - output path'), + title: `${l10n.t('Create a new API client')} - ${l10n.t('output path')}`, step: step++, totalSteps: totalSteps, value: typeof state.outputPath === 'string' ? state.outputPath : '', @@ -274,7 +274,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.pluginName = await input.showInputBox({ - title: l10n.t('Create a new plugin - plugin name'), + title: `${l10n.t('Create a new plugin')} - ${('plugin name')}`, step: step++, totalSteps: 3, value: state.pluginName || '', @@ -313,7 +313,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.outputPath = await input.showInputBox({ - title: l10n.t('Create a new plugin - output path'), + title: `${l10n.t('Create a new plugin')} - ${('output path')}}`, step: step++, totalSteps: 3, value: typeof state.outputPath === 'string' ? state.outputPath : '', @@ -325,7 +325,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.pluginName = await input.showInputBox({ - title: l10n.t('Create a new manifest - manifest name'), + title: `${l10n.t('Create a new manifest')} - ${('manifest name')}`, step: step++, totalSteps: 3, value: state.pluginName || '', @@ -338,7 +338,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.outputPath = await input.showInputBox({ - title: l10n.t('Create a new manifest - output path'), + title: `${l10n.t('Create a new manifest')} - ${('output path')}`, step: step++, totalSteps: 3, value: typeof state.outputPath === 'string' ? state.outputPath : '', @@ -360,7 +360,7 @@ function shouldResume() { } function validateIsNotEmpty(value: string) { - return Promise.resolve(value.length > 0 ? undefined : 'Required'); + return Promise.resolve(value.length > 0 ? undefined : l10n.t('Required')); } interface BaseStepsState { From 3476f3faad11a16c674027c63531bd254ef63d8a Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 17:35:12 +0300 Subject: [PATCH 055/150] remove unused search lock function --- .../microsoft-kiota/l10n/bundle.l10n.ar.json | 1 - .../microsoft-kiota/l10n/bundle.l10n.cs.json | 1 - .../microsoft-kiota/l10n/bundle.l10n.es.json | 1 - .../microsoft-kiota/l10n/bundle.l10n.fr.json | 1 - .../microsoft-kiota/l10n/bundle.l10n.it.json | 5 ++-- .../microsoft-kiota/l10n/bundle.l10n.ja.json | 1 - .../microsoft-kiota/l10n/bundle.l10n.pl.json | 1 - .../microsoft-kiota/l10n/bundle.l10n.pt.json | 1 - .../microsoft-kiota/l10n/bundle.l10n.ru.json | 1 - .../microsoft-kiota/l10n/bundle.l10n.sw.json | 1 - .../microsoft-kiota/l10n/bundle.l10n.tr.json | 1 - .../l10n/bundle.l10n.zh-cn.json | 1 - vscode/microsoft-kiota/src/extension.ts | 10 +------ vscode/microsoft-kiota/src/steps.ts | 28 ------------------- 14 files changed, 3 insertions(+), 51 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json index eeaa295800..0491789a7d 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json @@ -28,7 +28,6 @@ "Generating client...": "انشاء العميل...", "Loading...": "جاري التحميل...", "Updating clients...": "تحديث العملاء...", - "Pick a workspace file": "اختر ملف قفل", "Open a lock file": "افتح ملف قفل", "Filter the API description": "قم بتصفية وصف API", "Enter a filter": "أدخل عامل التصفية", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json index 6c500c13c5..f3957f29bd 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json @@ -28,7 +28,6 @@ "Generating client...": "Generování klienta...", "Updating clients...": "Aktualizace klientů...", "Loading...": "Načítání...", - "Pick a workspace file": "Vybrat soubor zámku", "Open a lock file": "Otevřít soubor zámku", "Filter the API description": "Filtrovat popis API", "Enter a filter": "Zadejte filtr", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json index 2934a7b281..9717046cc5 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json @@ -28,7 +28,6 @@ "Generating client...": "Generando cliente...", "Updating clients...": "Actualizando clientes...", "Loading...": "Cargando...", - "Pick a workspace file": "Seleccionar un archivo lock", "Open a lock file": "Abrir un archivo lock", "Filter the API description": "Filtrar descripción de API", "Enter a filter": "Ingresar un filtro", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json index 778a8271e0..c3c8603dfb 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json @@ -28,7 +28,6 @@ "Generating client...": "Génération du client...", "Updating clients...": "Mise à jour des clients...", "Loading...": "Chargement...", - "Pick a workspace file": "Sélectionnez un fichier verrou", "Open a lock file": "Ouvrir un fichier verrou", "Filter the API description": "Filtrer la description d'API", "Enter a filter": "Entrez un filtre", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json index 3bb0322267..a6f1d3f9d1 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json @@ -28,7 +28,6 @@ "Generating client...": "Generazione del client in corso...", "Updating clients...": "Aggiornamento dei client in corso...", "Loading...": "Caricamento...", - "Pick a workspace file": "Seleziona un file di lock", "Open a lock file": "Apri un file di lock", "Filter the API description": "Filtra la descrizione API", "Enter a filter": "Inserisci un filtro", @@ -54,8 +53,8 @@ "Create a new API client": "Crea un nuovo client API", "Create a new plugin": "Crea un nuovo plugin", "Create a new manifest": "", - "plugin name:": "", - "Choose a name for the plugin:": "", + "plugin name": "", + "Choose a name for the plugin": "", "Choose a plugin type": "", "manifest name": "", "Choose a name for the manifest": "", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json index c9c13a2abf..d4bc28bae9 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json @@ -29,7 +29,6 @@ "Generating client...": "クライアントを生成中...", "Updating clients...": "クライアントを更新中...", "Loading...": "読み込み中...", - "Pick a workspace file": "ロックファイルを選択", "Open a lock file": "ロックファイルを開く", "Filter the API description": "API仕様書をフィルタ", "Enter a filter": "フィルタを入力", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json index 101705d1b7..b73c4d6fbc 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json @@ -28,7 +28,6 @@ "Generating client...": "Generowanie klienta...", "Updating clients...": "Aktualizowanie klientów...", "Loading...": "Ładowanie...", - "Pick a workspace file": "Wybierz plik lock", "Open a lock file": "Otwórz plik lock", "Filter the API description": "Filtruj opis API", "Enter a filter": "Wprowadź filtr", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json index 38416e7d68..32df883b16 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json @@ -28,7 +28,6 @@ "Generating client...": "Gerando o cliente...", "Updating clients...": "Atualizando os clientes...", "Loading...": "Carregando...", - "Pick a workspace file": "Selecionar um arquivo lock", "Open a lock file": "Abrir um arquivo lock", "Filter the API description": "Filtrar descrição da API", "Enter a filter": "Adicionar um filtro", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json index 38f478299d..f4dcc9fa7a 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json @@ -27,7 +27,6 @@ "Generating client...": "Генерирование клиента...", "Updating clients...": "Обновление клиентов...", "Loading...": "Загрузка...", - "Pick a workspace file": "Выбрать файл блокировки", "Open a lock file": "Открыть файл блокировки", "Filter the API description": "Отфильтровать описание API", "Enter a filter": "Ввести фильтр", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json index e1cbd9041a..b3e335a90e 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json @@ -28,7 +28,6 @@ "Generating client...": "Inatengeneza mteja...", "Updating clients...": "Inasasisha wateja...", "Loading...": "Inapakia...", - "Pick a workspace file": "Chagua faili ya kufunga", "Open a lock file": "Fungua faili ya kufunga", "Filter the API description": "Chuja maelezo ya API", "Enter a filter": "Ingiza kichujio", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json index 5d216dc217..63dde4072a 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json @@ -28,7 +28,6 @@ "Generating client...": "İstemci oluşturuluyor...", "Updating clients...": "İstemciler güncelleniyor...", "Loading...": "Yükleniyor...", - "Pick a workspace file": "Bir kilit dosyası seçin", "Open a lock file": "Bir kilit dosyası açın", "Filter the API description": "API açıklamasını filtreleyin", "Enter a filter": "Filtre girin", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json index 46dfed048f..cff11bf4b4 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json @@ -27,7 +27,6 @@ "Generating client...": "正在生成客户端...", "Updating clients...": "正在更新客户端...", "Loading...": "加载中...", - "Pick a workspace file": "请选择一个锁定文件", "Open a lock file": "请打开一个锁定文件", "Filter the API description": "筛选API描述", "Enter a filter": "输入一个筛选项", diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index ad85af6e7e..247c6447a4 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -17,7 +17,7 @@ import { parseGenerationLanguage, parsePluginType, } from "./kiotaInterop"; -import { GenerateState, GenerationType, filterSteps, generateSteps, openManifestSteps, openSteps, parseGenerationType, searchLockSteps, searchSteps, selectApiManifestKey } from "./steps"; +import { GenerateState, GenerationType, filterSteps, generateSteps, openManifestSteps, openSteps, parseGenerationType, searchSteps, selectApiManifestKey } from "./steps"; import { getKiotaVersion } from "./getKiotaVersion"; import { searchDescription } from "./searchDescription"; import { generateClient } from "./generateClient"; @@ -98,14 +98,6 @@ export async function activate( vscode.languages.registerCodeLensProvider('json', codeLensProvider), reporter, - registerCommandWithTelemetry(reporter, - `${treeViewId}.openFile`, - async () => { - const lockFilePath = await searchLockSteps(); - if (lockFilePath?.lockFilePath) { - await loadLockFile(lockFilePath.lockFilePath, openApiTreeProvider); - } - }), registerCommandWithTelemetry(reporter, `${extensionId}.selectLock`, (x) => loadLockFile(x, openApiTreeProvider) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index f1ff0aaa7a..ebc126ef20 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -68,34 +68,6 @@ export async function selectApiManifestKey(keys: string[]) { await MultiStepInput.run(input => pickSearchResult(input, state), () => step-=2); return state; } - -export async function searchLockSteps() { - const state = {} as Partial; - let step = 1; - let totalSteps = 1; - const title = l10n.t('Open a lock file'); - async function pickSearchResult(input: MultiStepInput, state: Partial) { - const searchResults = await workspace.findFiles(`**/${kiotaLockFile}`); - const items = searchResults.map(x => - { - return { - label: x.path.replace(workspace.getWorkspaceFolder(x)?.uri.path || '', ''), - } as QuickPickItem; - }); - const pick = await input.showQuickPick({ - title, - step: step++, - totalSteps: totalSteps, - placeholder: l10n.t('Pick a workspace file'), - items: items, - shouldResume: shouldResume - }); - state.lockFilePath = searchResults.find(x => x.path.replace(workspace.getWorkspaceFolder(x)?.uri.path || '', '') === pick?.label); - } - await MultiStepInput.run(input => pickSearchResult(input, state), () => step-=2); - return state; -} - export async function filterSteps(existingFilter: string, filterCallback: (searchQuery: string) => void) { const state = {} as Partial; const title = l10n.t('Filter the API description'); From 858d4cd9479f11c8fc7ae63b335500196743aafa Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 17:39:13 +0300 Subject: [PATCH 056/150] add french translations --- .../microsoft-kiota/l10n/bundle.l10n.fr.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json index c3c8603dfb..378b5e7e9b 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json @@ -38,37 +38,37 @@ "No content found in the clipboard": "Aucun contenu trouvé dans le presse-papiers", "Invalid content found in the clipboard": "Contenu non valide trouvé dans le presse-papiers", "Select an API manifest key": "Sélectionnez une clé de manifeste d'API", - "Edit Paths":"", - "Re-generate": "", - "Add an API description": "", + "Edit Paths":"Modifier les chemins", + "Re-generate": "Générer de nouveau", + "Add an API description": "Ajouter une description d'API", "Search or paste a path to an API description": "Rechercher ou coller un chemin vers unde description d'API", "Generate a plugin": "Générer un plugin", "Generate an API manifest": "Générer un manifeste d'API", "What do you want to generate?": "Que souhaitez vous générer?", - "Select an option": "", - "class": "", - "namespace": "", - "output path": "", - "language": "", + "Select an option": "Sélectionnez une option", + "class": "classe", + "namespace": "espace de nommage", + "output path": "chemin de sortie", + "language": "langage", "Create a new API client": "Créer un nouveau client d'API", "Create a new plugin": "Créer un nouveau composant", - "Create a new manifest": "", - "plugin name:": "", - "Choose a name for the plugin:": "", - "Choose a plugin type": "", - "manifest name": "", - "Choose a name for the manifest": "", - "Required": "", - "Open installation instructions for kiota?": "", - "Invalid generation type": "", - "Yes, override it": "", - "Before adding a new API description, consider that your changes and current selection will be lost.": "", - "Cancel": "", + "Create a new manifest": "Créer un nouveau manifeste", + "plugin name:": "nom du composant", + "Choose a name for the plugin:": "Choisissez un nom pour le composant", + "Choose a plugin type": "Choisisses un type de composant", + "manifest name": "nom du manifeste", + "Choose a name for the manifest": "Choisissez un nom pour le manifeste", + "Required": "Requis", + "Open installation instructions for kiota?": "Ouvrir les instructions d'installation pour kiota?", + "Invalid generation type": "Type de génération invalide", + "Yes, override it": "Oui, l'écraser", + "Before adding a new API description, consider that your changes and current selection will be lost.": "Avant d'ajouter une nouvelle description d'API veuillez noter que vos modifications et sélections actuelles seront perdues", + "Cancel": "Annuler", "Do you want to remove this API description?": "Voulez-vous supprimer cette description d'API?", - "Please save the workspace.json file before re-generation.": "", - "OK": "", - "Generating manifest...": "", - "Generating plugin...": "", - "Re-generating client...": "", - "Re-generating plugin...": "" + "Please save the workspace.json file before re-generation.": "Veuillez sauvegarder le fichier workspace.json avant de générer à nouveau.", + "OK": "Ok", + "Generating manifest...": "Génération du manifeste...", + "Generating plugin...": "Génération du composant...", + "Re-generating client...": "Rafraichissement du client...", + "Re-generating plugin...": "Refraichissement du composant..." } From e8775817880b74a65adedf00b9d9f9a674c83810 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 17:43:28 +0300 Subject: [PATCH 057/150] added czech translations --- .../microsoft-kiota/l10n/bundle.l10n.cs.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json index f3957f29bd..1efc4abeb0 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json @@ -38,37 +38,37 @@ "No content found in the clipboard": "V schránce nebyl nalezen žádný obsah", "Invalid content found in the clipboard": "V schránce byl nalezen neplatný obsah", "Select an API manifest key": "Vyberte klíč manifestu API", - "Edit Paths":"", - "Re-generate": "", - "Add an API description": "", + "Edit Paths":"Upravit cesty", + "Re-generate": "Znovu vygenerovat", + "Add an API description": "Přidat popis API", "Search or paste a path to an API description": "Hledat nebo vložit cestu k popisu API", "Generate a plugin": "Generovat plugin", "Generate an API manifest": "Generovat API manifest", "What do you want to generate?": "Co chcete generovat? ", - "Select an option": "", - "class": "", - "namespace": "", - "output path": "", - "language": "", + "Select an option": "Vyberte možnost", + "class": "třída", + "namespace": "jmenný prostor", + "output path": "výstupní cesta", + "language": "jazyk", "Create a new API client": "Vytvořit nového API klienta", "Create a new plugin": "Vytvořit nový plugin", - "Create a new manifest": "", - "plugin name:": "", - "Choose a name for the plugin:": "", - "Choose a plugin type": "", - "manifest name": "", - "Choose a name for the manifest": "", - "Required": "", - "Open installation instructions for kiota?": "", - "Invalid generation type": "", - "Yes, override it": "", - "Before adding a new API description, consider that your changes and current selection will be lost.": "", - "Cancel": "", + "Create a new manifest": "Vytvořit nový manifest", + "plugin name:": "název pluginu", + "Choose a name for the plugin:": "Vyberte název pro plugin", + "Choose a plugin type": "Vyberte typ pluginu", + "manifest name": "název manifestu", + "Choose a name for the manifest": "Vyberte název pro manifest", + "Required": "Požadováno", + "Open installation instructions for kiota?": "Otevřít instalační pokyny pro kiota", + "Invalid generation type": "Neplatný typ generování", + "Yes, override it": "Ano, přepsat", + "Before adding a new API description, consider that your changes and current selection will be lost.": "Před přidáním nového popisu API zvažte, že vaše změny a aktuální výběr budou ztraceny.", + "Cancel": "Zrušit", "Do you want to remove this API description?": "Chcete odstranit tento popis API?", - "Please save the workspace.json file before re-generation.": "", - "OK": "", - "Generating manifest...": "", - "Generating plugin...": "", - "Re-generating client...": "", - "Re-generating plugin...": "" + "Please save the workspace.json file before re-generation.": "Před generováním prosím uložte soubor workspace.json", + "OK": "OK", + "Generating manifest...": "Generování manifestu...", + "Generating plugin...": "Generování pluginu...", + "Re-generating client...": "Opětovné generování klienta...", + "Re-generating plugin...": "Opětovné generování pluginu..." } From 8f4a32f1ba567554849c31a0066821f179efe357 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 17:50:26 +0300 Subject: [PATCH 058/150] add portuguese translations --- .../microsoft-kiota/l10n/bundle.l10n.pt.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json index 32df883b16..9399d1777f 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json @@ -38,37 +38,37 @@ "No content found in the clipboard": "Nenhum conteúdo encontrado na área de transferência", "Invalid content found in the clipboard": "Conteúdo inváido na área de transferência", "Select an API manifest key": "Selecione uma chave para um manifesto de API", - "Edit Paths":"", - "Re-generate": "", - "Add an API description": "", + "Edit Paths":"Modificar endpoints", + "Re-generate": "Gerar novamente", + "Add an API description": "Adicione a descrição de uma API", "Search or paste a path to an API description": "Busque ou cole o caminho para uma descrição de API", "Generate a plugin": "Gerar um plugin ", "Generate an API manifest": "Gerar um API manifest", "What do you want to generate?": "O que você quer gerar?", - "Select an option": "", - "class": "", - "namespace": "", - "output path": "", - "language": "", + "Select an option": "Selecione uma opção ", + "class": "classe", + "namespace": "namespace", + "output directory": "Diretório de destino", + "language": "linguagem", "Create a new API client": "Criar um novo cliente de API", "Create a new plugin": "Criar um novo plugin ", - "Create a new manifest": "", - "plugin name:": "", - "Choose a name for the plugin:": "", - "Choose a plugin type": "", - "manifest name": "", - "Choose a name for the manifest": "", - "Required": "", - "Open installation instructions for kiota?": "", - "Invalid generation type": "", - "Yes, override it": "", - "Before adding a new API description, consider that your changes and current selection will be lost.": "", - "Cancel": "", + "Create a new manifest": "Criar um novo manifesto", + "plugin name:": "Nome do plugin", + "Choose a name for the plugin:": "Escolha um nome para o plugin", + "Choose a plugin type": "Escolha o tipo do plugin", + "manifest name": "nome do manifesto", + "Choose a name for the manifest": "Escolha um nome para o manifesto", + "Required": "Obrigatório ", + "Open installation instructions for kiota?": "Abrir as instruções de instalação do Kiota?", + "Invalid generation type": "Tipo de geração inválido ", + "Yes, override it": "Sim, substituir", + "Before adding a new API description, consider that your changes and current selection will be lost.": "Antes de adicionar uma nova descrição de API, considere que as alterações e a seleção atual será perdida.", + "Cancel": "Cancela", "Do you want to remove this API description?": "Você quer remover a descrição dessa API?", - "Please save the workspace.json file before re-generation.": "", - "OK": "", - "Generating manifest...": "", - "Generating plugin...": "", - "Re-generating client...": "", - "Re-generating plugin...": "" + "Please save the workspace.json file before re-generation.": "Por favor, salve o arquivo workspace.json antes de gerar novamente.", + "OK": "Ok", + "Generating manifest...": "Gerando o manifesto...", + "Generating plugin...": "Gerando o plugin...", + "Re-generating client...": "Regerando o cliente...", + "Re-generating plugin...": "Regerando o plugin..." } From 284e59d50df2442c90344fc32c550784546104b1 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 17:54:53 +0300 Subject: [PATCH 059/150] update output diectory string --- vscode/microsoft-kiota/l10n/bundle.l10n.ar.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.cs.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.es.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.it.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.ja.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.pl.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.ru.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.sw.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.tr.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json | 2 +- vscode/microsoft-kiota/src/steps.ts | 6 +++--- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json index 0491789a7d..f9b5b585db 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json @@ -48,7 +48,7 @@ "Select an option": "", "class": "", "namespace": "", - "output path": "", + "output directory": "", "language": "", "Create a new API client": "", "Create a new plugin": "", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json index 1efc4abeb0..ae9fddff1a 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json @@ -48,7 +48,7 @@ "Select an option": "Vyberte možnost", "class": "třída", "namespace": "jmenný prostor", - "output path": "výstupní cesta", + "output directory": "výstupní adresář", "language": "jazyk", "Create a new API client": "Vytvořit nového API klienta", "Create a new plugin": "Vytvořit nový plugin", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json index 9717046cc5..318181c9be 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json @@ -48,7 +48,7 @@ "Select an option": "", "class": "", "namespace": "", - "output path": "", + "output directory": "", "language": "", "Create a new API client": "Crear un nuevo cliente de API", "Create a new plugin": "Crear un nuevo plugin", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json index a6f1d3f9d1..a801f866c2 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json @@ -48,7 +48,7 @@ "Select an option": "", "class": "", "namespace": "", - "output path": "", + "output directory": "", "language": "", "Create a new API client": "Crea un nuovo client API", "Create a new plugin": "Crea un nuovo plugin", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json index d4bc28bae9..b7246b36dd 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json @@ -49,7 +49,7 @@ "Select an option": "", "class": "", "namespace": "", - "output path": "", + "output directory": "", "language": "", "Create a new API client": "", "Create a new plugin": "", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json index b73c4d6fbc..e19314f3b1 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json @@ -48,7 +48,7 @@ "Select an option": "", "class": "", "namespace": "", - "output path": "", + "output directory": "", "language": "", "Create a new API client": "Utwórz nowego klienta API ", "Create a new plugin": "Utwórz nową wtyczkę", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json index f4dcc9fa7a..ba088d3b87 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json @@ -47,7 +47,7 @@ "Select an option": "", "class": "", "namespace": "", - "output path": "", + "output directory": "", "language": "", "Create a new API client": "", "Create a new plugin": "", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json index b3e335a90e..f047ab166f 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json @@ -48,7 +48,7 @@ "Select an option": "", "class": "", "namespace": "", - "output path": "", + "output directory": "", "language": "", "Create a new API client": "Tengeneza mteja mpya wa API", "Create a new plugin": "Tengeneza programu-jalizi mpya", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json index 63dde4072a..acae4f4aa9 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json @@ -48,7 +48,7 @@ "Select an option": "", "class": "", "namespace": "", - "output path": "", + "output directory": "", "language": "", "Create a new API client": "", "Create a new plugin": "", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json index cff11bf4b4..ffae6d81f9 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json @@ -47,7 +47,7 @@ "Select an option": "", "class": "", "namespace": "", - "output path": "", + "output directory": "", "language": "", "Create a new API client": "创建新的 API 客户端", "Create a new plugin": "创建一个新插件", diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index ebc126ef20..7df8201c20 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -224,7 +224,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.outputPath = await input.showInputBox({ - title: `${l10n.t('Create a new API client')} - ${l10n.t('output path')}`, + title: `${l10n.t('Create a new API client')} - ${l10n.t('output directory')}`, step: step++, totalSteps: totalSteps, value: typeof state.outputPath === 'string' ? state.outputPath : '', @@ -285,7 +285,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.outputPath = await input.showInputBox({ - title: `${l10n.t('Create a new plugin')} - ${('output path')}}`, + title: `${l10n.t('Create a new plugin')} - ${('output directory')}}`, step: step++, totalSteps: 3, value: typeof state.outputPath === 'string' ? state.outputPath : '', @@ -310,7 +310,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.outputPath = await input.showInputBox({ - title: `${l10n.t('Create a new manifest')} - ${('output path')}`, + title: `${l10n.t('Create a new manifest')} - ${('output directory')}`, step: step++, totalSteps: 3, value: typeof state.outputPath === 'string' ? state.outputPath : '', From d0ec92f2707d6a9dc0ad810d0111b88d439b1dce Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 18:06:55 +0300 Subject: [PATCH 060/150] set workspace file constant --- vscode/microsoft-kiota/src/codelensProvider.ts | 3 ++- vscode/microsoft-kiota/src/constants.ts | 2 +- vscode/microsoft-kiota/src/extension.ts | 10 +++++----- vscode/microsoft-kiota/src/steps.ts | 1 - vscode/microsoft-kiota/src/workspaceTreeProvider.ts | 5 +++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/vscode/microsoft-kiota/src/codelensProvider.ts b/vscode/microsoft-kiota/src/codelensProvider.ts index 63550c9506..f392483199 100644 --- a/vscode/microsoft-kiota/src/codelensProvider.ts +++ b/vscode/microsoft-kiota/src/codelensProvider.ts @@ -1,5 +1,6 @@ import * as vscode from 'vscode'; import { l10n } from 'vscode'; +import { kiotaWorkspaceFile } from './constants'; export class CodeLensProvider implements vscode.CodeLensProvider { public provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.ProviderResult { @@ -7,7 +8,7 @@ export class CodeLensProvider implements vscode.CodeLensProvider { const text = document.getText(); const jsonObject = JSON.parse(text); - if (document.fileName.endsWith('workspace.json')) { + if (document.fileName.endsWith(kiotaWorkspaceFile)) { ['clients', 'plugins'].forEach(objectKey => { const object = jsonObject[objectKey]; if (object) { diff --git a/vscode/microsoft-kiota/src/constants.ts b/vscode/microsoft-kiota/src/constants.ts index 776039173e..f4623f57b6 100644 --- a/vscode/microsoft-kiota/src/constants.ts +++ b/vscode/microsoft-kiota/src/constants.ts @@ -4,4 +4,4 @@ export const statusBarCommandId = `${extensionId}.status`; export const treeViewId = `${extensionId}.openApiExplorer`; export const treeViewFocusCommand = `${treeViewId}${focusCommandId}`; export const dependenciesInfo = `${extensionId}.dependenciesInfo`; -export const kiotaLockFile = "workspace.json"; \ No newline at end of file +export const kiotaWorkspaceFile = "workspace.json"; \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 247c6447a4..8e35898930 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -29,7 +29,7 @@ import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; import { KiotaWorkspace } from "./workspaceTreeProvider"; import { generatePlugin } from "./generatePlugin"; import { CodeLensProvider } from "./codelensProvider"; -import { dependenciesInfo, extensionId, kiotaLockFile, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; +import { dependenciesInfo, extensionId, kiotaWorkspaceFile, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; @@ -296,7 +296,7 @@ export async function activate( registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: any, generationType: string) => { const settings = getExtensionSettings(extensionId); - const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith("workspace.json")); + const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(kiotaWorkspaceFile)); if (workspaceJson && workspaceJson.isDirty) { await vscode.window.showInformationMessage( vscode.l10n.t("Please save the workspace.json file before re-generation."), @@ -449,7 +449,7 @@ export async function activate( if (typeof config.outputPath === "string" && !openApiTreeProvider.isLockFileLoaded && vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 && result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) { - await openApiTreeProvider.loadLockFile(path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, '.kiota', kiotaLockFile)); + await openApiTreeProvider.loadLockFile(path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, '.kiota', kiotaWorkspaceFile)); //TODO this will need to be updated to refresh the workspace instead } if (result) @@ -549,7 +549,7 @@ export async function activate( ); return; } - const existingLockFileUris = await vscode.workspace.findFiles(`**/${kiotaLockFile}`); + const existingLockFileUris = await vscode.workspace.findFiles(`**/${kiotaWorkspaceFile}`); if (existingLockFileUris.length > 0) { await Promise.all(existingLockFileUris.map(x => path.dirname(x.fsPath)).map(x => showUpgradeWarningMessage(x, context))); } @@ -645,7 +645,7 @@ function registerCommandWithTelemetry(reporter: TelemetryReporter, command: stri async function showUpgradeWarningMessage(clientPath: string, context: vscode.ExtensionContext): Promise { const kiotaVersion = context.extension.packageJSON.kiotaVersion.toLocaleLowerCase(); - const lockFilePath = path.join(clientPath, kiotaLockFile); + const lockFilePath = path.join(clientPath, kiotaWorkspaceFile); if(!fs.existsSync(lockFilePath)) { return; } diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 7df8201c20..fe5bb091de 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -1,6 +1,5 @@ import { QuickPickItem, window, Disposable, QuickInputButton, QuickInput, QuickInputButtons, workspace, l10n, Uri } from 'vscode'; import { allGenerationLanguages, generationLanguageToString, KiotaSearchResultItem, LanguagesInformation, maturityLevelToString } from './kiotaInterop'; -import { kiotaLockFile } from './constants'; export async function openSteps() { diff --git a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts index ac8176e186..5a016e4c6f 100644 --- a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts +++ b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts @@ -1,8 +1,9 @@ import * as vscode from 'vscode'; import * as path from 'path'; import * as fs from 'fs'; +import { kiotaWorkspaceFile } from './constants'; -const workspaceJsonPath = path.join(vscode.workspace.workspaceFolders?.map(folder => folder.uri.fsPath).join('') || '', '.kiota', 'workspace.json'); +const workspaceJsonPath = path.join(vscode.workspace.workspaceFolders?.map(folder => folder.uri.fsPath).join('') || '', '.kiota', kiotaWorkspaceFile); export class WorkspaceTreeProvider implements vscode.TreeDataProvider { @@ -11,7 +12,7 @@ export class WorkspaceTreeProvider implements vscode.TreeDataProvider { if (!element) { - return [new vscode.TreeItem('workspace.json', vscode.TreeItemCollapsibleState.None)]; + return [new vscode.TreeItem(kiotaWorkspaceFile, vscode.TreeItemCollapsibleState.None)]; } return []; } From 74aaf10cb34c9587c76a7b735cf8b9b82bb2a6a7 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 18:10:07 +0300 Subject: [PATCH 061/150] add else clause --- vscode/microsoft-kiota/src/extension.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 8e35898930..7d71634f9b 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -289,7 +289,7 @@ export async function activate( if(globalGenerationType === "clients") { await regenerateClient(globalClientKey, globalClientObject, settings, selectedPaths); } - if (globalGenerationType === "plugins") { + else if (globalGenerationType === "plugins") { await regeneratePlugin(globalClientKey, globalClientObject, settings, selectedPaths); } }), @@ -307,7 +307,7 @@ export async function activate( if (generationType === "clients") { await regenerateClient(clientKey, clientObject, settings); } - if (generationType === "plugins") { + else if (generationType === "plugins") { await regeneratePlugin(clientKey, clientObject, settings); } }), From d513b8a58ea2c9b726664e4f0fafb462566d2bcc Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 18:26:02 +0300 Subject: [PATCH 062/150] remove TODO comments --- vscode/microsoft-kiota/src/extension.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 7d71634f9b..0f424fb8e2 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -346,7 +346,6 @@ export async function activate( }); return result; }); - //TODO refresh the kiota workspace if (result) { await exportLogsAndShowErrors(result); @@ -385,7 +384,6 @@ export async function activate( }); return result; }); - //TODO refresh the kiota workspace if (result) { await exportLogsAndShowErrors(result); @@ -450,7 +448,6 @@ export async function activate( vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 && result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) { await openApiTreeProvider.loadLockFile(path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, '.kiota', kiotaWorkspaceFile)); - //TODO this will need to be updated to refresh the workspace instead } if (result) { From 07ceaa4a0f344a1f9cef61da3e2bc32c3c811a20 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 19:09:26 +0300 Subject: [PATCH 063/150] return vscode error --- vscode/microsoft-kiota/src/workspaceTreeProvider.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts index 5a016e4c6f..ab92d1409a 100644 --- a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts +++ b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts @@ -36,7 +36,9 @@ export class WorkspaceTreeProvider implements vscode.TreeDataProvider Date: Tue, 21 May 2024 19:46:11 +0300 Subject: [PATCH 064/150] add types --- vscode/microsoft-kiota/src/extension.ts | 27 +++++++++++----------- vscode/microsoft-kiota/src/kiotaInterop.ts | 25 +++++++++++++++++++- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 0f424fb8e2..db3cfea594 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -6,6 +6,7 @@ import * as path from 'path'; import * as fs from 'fs'; import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider"; import { + ClientOrPluginProperties, ConsumerOperation, generationLanguageToString, getLogEntriesForLevel, @@ -33,9 +34,9 @@ import { dependenciesInfo, extensionId, kiotaWorkspaceFile, statusBarCommandId, let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; -let globalClientKey: string; -let globalClientObject: any; -let globalGenerationType: string; +let clientOrPluginKey: string; +let clientOrPluginObject: ClientOrPluginProperties; +let workspaceGenerationType: string; // This method is called when your extension is activated // Your extension is activated the very first time the command is executed @@ -268,16 +269,16 @@ export async function activate( `${treeViewId}.pasteManifest`, () => openManifestFromClipboard(openApiTreeProvider, "") ), - registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: any, generationType: string) => { - globalClientKey = clientKey; - globalClientObject = clientObject; - globalGenerationType = generationType; + registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { + clientOrPluginKey = clientKey; + clientOrPluginObject = clientObject; + workspaceGenerationType = generationType; await loadEditPaths(clientObject, openApiTreeProvider); await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, false); await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, true); }), - vscode.commands.registerCommand(`${treeViewId}.regenerateButton`, async () => { + registerCommandWithTelemetry(reporter,`${treeViewId}.regenerateButton`, async () => { const settings = getExtensionSettings(extensionId); const selectedPaths = openApiTreeProvider.getSelectedPaths(); if (selectedPaths.length === 0) { @@ -286,15 +287,15 @@ export async function activate( ); return; } - if(globalGenerationType === "clients") { - await regenerateClient(globalClientKey, globalClientObject, settings, selectedPaths); + if(workspaceGenerationType === "clients") { + await regenerateClient(clientOrPluginKey, clientOrPluginObject, settings, selectedPaths); } - else if (globalGenerationType === "plugins") { - await regeneratePlugin(globalClientKey, globalClientObject, settings, selectedPaths); + else if (workspaceGenerationType === "plugins") { + await regeneratePlugin(clientOrPluginKey, clientOrPluginObject, settings, selectedPaths); } }), - registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: any, generationType: string) => { + registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { const settings = getExtensionSettings(extensionId); const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(kiotaWorkspaceFile)); if (workspaceJson && workspaceJson.isDirty) { diff --git a/vscode/microsoft-kiota/src/kiotaInterop.ts b/vscode/microsoft-kiota/src/kiotaInterop.ts index 8f1f4477f4..d48b828d55 100644 --- a/vscode/microsoft-kiota/src/kiotaInterop.ts +++ b/vscode/microsoft-kiota/src/kiotaInterop.ts @@ -291,4 +291,27 @@ export interface GenerationConfiguration { usesBackingStore: boolean; pluginTypes: KiotaPluginType[]; operation: ConsumerOperation; -} \ No newline at end of file +} + +interface WorkspaceObjectProperties { + descriptionLocation: string; + includePatterns: string[]; + excludePatterns: string[]; + outputPath: string; +} + +interface ClientObjectProperties extends WorkspaceObjectProperties { + language: string; + structuredMimeTypes: string[]; + clientNamespaceName: string; + usesBackingStore: boolean; + includeAdditionalData: boolean; + excludeBackwardCompatible: boolean; + disabledValidationRules: string[]; +} + +interface PluginObjectProperties extends WorkspaceObjectProperties { + types: string[]; +} + +export type ClientOrPluginProperties = ClientObjectProperties | PluginObjectProperties; \ No newline at end of file From 6c8f59c59d9ec49d1cf85e43ece83acfb3efd2a0 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 21 May 2024 20:02:27 +0300 Subject: [PATCH 065/150] use nullish coalescing operator instead of Logical OR --- vscode/microsoft-kiota/src/steps.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index fe5bb091de..eadde8e138 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -32,7 +32,7 @@ export async function openManifestSteps() { title, step: step++, totalSteps: totalSteps, - value: state.manifestPath || '', + value: state.manifestPath ?? '', prompt: l10n.t('A path or URL to an API manifest'), validate: validateIsNotEmpty, shouldResume: shouldResume @@ -101,7 +101,7 @@ export async function searchSteps(searchCallBack: (searchQuery: string) => Thena title, step: step++, totalSteps: totalSteps, - value: state.searchQuery || '', + value: state.searchQuery ?? '', prompt: l10n.t('Search or paste a path to an API description'), validate: validateIsNotEmpty, shouldResume: shouldResume @@ -200,7 +200,7 @@ export async function generateSteps(existingConfiguration: Partial Date: Wed, 22 May 2024 14:22:17 +0300 Subject: [PATCH 066/150] add spanish translations --- .../microsoft-kiota/l10n/bundle.l10n.es.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json index 318181c9be..4005c2461b 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json @@ -38,37 +38,37 @@ "No content found in the clipboard": "Sin contenido en el portapapeles.", "Invalid content found in the clipboard": "Contenido inválido en el portapapeles.", "Select an API manifest key": "Seleccione una llave de manifesto de API.", - "Edit Paths":"", - "Re-generate": "", - "Add an API description": "", + "Edit Paths":"Editar ruta de acceso", + "Re-generate": "Re-generar", + "Add an API description": "Agregar una descripción de API", "Search or paste a path to an API description": "Busca o pega una ruta a una descripcion de API", "Generate a plugin": "Generar un plugin", "Generate an API manifest": "Generar un manifesto de API", "What do you want to generate?": "Qué quieres generar?", - "Select an option": "", - "class": "", - "namespace": "", - "output directory": "", - "language": "", + "Select an option": "Seleccionar una opción", + "class": "clase", + "namespace": "namespace", + "output directory": "directorio de salida", + "language": "idioma", "Create a new API client": "Crear un nuevo cliente de API", "Create a new plugin": "Crear un nuevo plugin", - "Create a new manifest": "", - "plugin name:": "", - "Choose a name for the plugin:": "", - "Choose a plugin type": "", - "manifest name": "", - "Choose a name for the manifest": "", - "Required": "", - "Open installation instructions for kiota?": "", - "Invalid generation type": "", - "Yes, override it": "", - "Before adding a new API description, consider that your changes and current selection will be lost.": "", - "Cancel": "", + "Create a new manifest": "Crear un nuevo manifesto", + "plugin name:": "nombre del plugin", + "Choose a name for the plugin:": "Elija un nombre para el plugin", + "Choose a plugin type": "Elija un tipo de plugin", + "manifest name": "Nombre de manifesto", + "Choose a name for the manifest": "Elija un nombre para el manifesto", + "Required": "Requerido", + "Open installation instructions for kiota?": "Abrir las instrucciones de instalación para Kiota", + "Invalid generation type": "Tipo de generación inválido", + "Yes, override it": "Sí, sobrescribir", + "Before adding a new API description, consider that your changes and current selection will be lost.": "Antes de agregar una nueva descripción de API, considere que sus cambios and selección actual se perderá", + "Cancel": "Cancelar", "Do you want to remove this API description?": "Quieres quitar esta descripcion de API?", - "Please save the workspace.json file before re-generation.": "", - "OK": "", - "Generating manifest...": "", - "Generating plugin...": "", - "Re-generating client...": "", - "Re-generating plugin...": "" + "Please save the workspace.json file before re-generation.": "Por favor, guarde el archivo workspace.json antes de re-generar.", + "OK": "Ok", + "Generating manifest...": "Generando manifesto...", + "Generating plugin...": "Generando plugin...", + "Re-generating client...": "Re-generando cliente...", + "Re-generating plugin...": "Re-generando plugin..." } From d5823aafaefaed71a9f089846eb4c7c0e99f304e Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 22 May 2024 14:26:31 +0300 Subject: [PATCH 067/150] add italian translation --- .../microsoft-kiota/l10n/bundle.l10n.it.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json index a801f866c2..b10609f433 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json @@ -38,37 +38,37 @@ "No content found in the clipboard": "Nessun contenuto trovato negli appunti", "Invalid content found in the clipboard": "Contenuto non valido trovato negli appunti", "Select an API manifest key": "Seleziona una chiave del manifest API", - "Edit Paths":"", - "Re-generate": "", - "Add an API description": "", + "Edit Paths":"Modifica i percorsi", + "Re-generate": "Rigenera", + "Add an API description": "Aggiungi una descrizione di API", "Search or paste a path to an API description": "Cerca o incolla un percorso ad un file di descrizione API", "Generate a plugin": "Genera un plugin", "Generate an API manifest": "Genera un manifest API", "What do you want to generate?": "Cosa vuoi generare?", - "Select an option": "", - "class": "", - "namespace": "", - "output directory": "", - "language": "", + "Select an option": "Seleziona un'opzione", + "class": "classe", + "namespace": "namespace", + "output directory": "directory di output", + "language": "lingua", "Create a new API client": "Crea un nuovo client API", "Create a new plugin": "Crea un nuovo plugin", - "Create a new manifest": "", - "plugin name": "", - "Choose a name for the plugin": "", - "Choose a plugin type": "", - "manifest name": "", - "Choose a name for the manifest": "", - "Required": "", - "Open installation instructions for kiota?": "", - "Invalid generation type": "", - "Yes, override it": "", - "Before adding a new API description, consider that your changes and current selection will be lost.": "", - "Cancel": "", + "Create a new manifest": "Crea un nuovo manifest", + "plugin name": "nome del plugin", + "Choose a name for the plugin": "Scegli un nome per il plugin", + "Choose a plugin type": "Scegli un tipo di plugin", + "manifest name": "Nome del manifest", + "Choose a name for the manifest": "Scegli un nome per il manifest", + "Required": "Richiesto", + "Open installation instructions for kiota?": "Aprire le istruzioni di installazione di kiota", + "Invalid generation type": "Tipo di generazione invalido", + "Yes, override it": "Si, sovrascrivi", + "Before adding a new API description, consider that your changes and current selection will be lost.": "Prima di aggiungere una nuova descrizione di API, considera che le tue modifiche e la selezione corrente andranno persi", + "Cancel": "Cancella", "Do you want to remove this API description?": "Vuoi rimuovere questa descrizione API ?", - "Please save the workspace.json file before re-generation.": "", - "OK": "", - "Generating manifest...": "", - "Generating plugin...": "", - "Re-generating client...": "", - "Re-generating plugin...": "" + "Please save the workspace.json file before re-generation.": "Per favore, salva il file workspace.json prima di rigenerare", + "OK": "Ok", + "Generating manifest...": "Generando il manifest...", + "Generating plugin...": "Generando il plugin...", + "Re-generating client...": "Ri-generando il client...", + "Re-generating plugin...": "Ri-generando il plugin..." } From 8dd5e5c5b8ef5a897f7eadcf21ee3bc454c70cb9 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 22 May 2024 14:30:22 +0300 Subject: [PATCH 068/150] add chinese translations --- .../l10n/bundle.l10n.zh-cn.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json index ffae6d81f9..ffc8d9e7ec 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json @@ -37,37 +37,37 @@ "No content found in the clipboard": "剪贴板空白", "Invalid content found in the clipboard": "剪贴板内容无效", "Select an API manifest key": "选择API清单访问密钥", - "Edit Paths":"", - "Re-generate": "", - "Add an API description": "", + "Edit Paths":"编辑路径", + "Re-generate": "重新生成", + "Add an API description": "添加 API 描述", "Search or paste a path to an API description": "搜索或粘贴 API 描述的路径", "Generate a plugin": "生成插件", "Generate an API manifest": "生成 API 清单", "What do you want to generate?": "您要生成什么", - "Select an option": "", - "class": "", - "namespace": "", - "output directory": "", - "language": "", + "Select an option": "选择一个选项", + "class": "类", + "namespace": "命名空间", + "output directory": "输出目录", + "language": "语言", "Create a new API client": "创建新的 API 客户端", "Create a new plugin": "创建一个新插件", - "Create a new manifest": "", - "plugin name:": "", - "Choose a name for the plugin:": "", - "Choose a plugin type": "", - "manifest name": "", - "Choose a name for the manifest": "", - "Required": "", - "Open installation instructions for kiota?": "", - "Invalid generation type": "", - "Yes, override it": "", - "Before adding a new API description, consider that your changes and current selection will be lost.": "", - "Cancel": "", + "Create a new manifest": "创建新清单", + "plugin name:": "插件名称", + "Choose a name for the plugin:": "为插件选择一个名称", + "Choose a plugin type": "选择插件类型", + "manifest name": "清单名", + "Choose a name for the manifest": "选择清单的名称", + "Required": "必填", + "Open installation instructions for kiota?": "打开 kiota 的安装说明?", + "Invalid generation type": "无效的生成类型", + "Yes, override it": "是的,覆盖它", + "Before adding a new API description, consider that your changes and current selection will be lost.": "在添加新的 API 描述之前,请考虑您的更改和当前选择将丢失。", + "Cancel": "取消", "Do you want to remove this API description?": "是否要删除此 API 描述?", - "Please save the workspace.json file before re-generation.": "", - "OK": "", - "Generating manifest...": "", - "Generating plugin...": "", - "Re-generating client...": "", - "Re-generating plugin...": "" + "Please save the workspace.json file before re-generation.": "请在重新生成之前保存workspace.json文件", + "OK": "OK", + "Generating manifest...": "正在生成清单...", + "Generating plugin...": "正在生成插件...", + "Re-generating client...": "重新生成客户端...", + "Re-generating plugin...": "正在重新生成插件..." } From a880d300c8c7e79647aa89fcc7919ecd355d3538 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 22 May 2024 15:09:25 +0300 Subject: [PATCH 069/150] remove unused functions --- vscode/microsoft-kiota/package.json | 10 --- vscode/microsoft-kiota/src/extension.ts | 82 +----------------------- vscode/microsoft-kiota/src/steps.ts | 83 +------------------------ 3 files changed, 4 insertions(+), 171 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 4b2893e032..15dd1fec75 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -318,16 +318,6 @@ ] }, "commands": [ - { - "command": "kiota.openApiExplorer.pasteManifest", - "category": "Kiota", - "title": "%kiota.openApiExplorer.pasteManifest.title%" - }, - { - "command": "kiota.openApiExplorer.openManifestPath", - "category": "Kiota", - "title": "%kiota.openApiExplorer.openManifestPath.title%" - }, { "command": "kiota.selectLock", "category": "Kiota", diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index db3cfea594..7b550d6be3 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -18,7 +18,7 @@ import { parseGenerationLanguage, parsePluginType, } from "./kiotaInterop"; -import { GenerateState, GenerationType, filterSteps, generateSteps, openManifestSteps, openSteps, parseGenerationType, searchSteps, selectApiManifestKey } from "./steps"; +import { GenerateState, GenerationType, filterSteps, generateSteps, parseGenerationType, searchSteps } from "./steps"; import { getKiotaVersion } from "./getKiotaVersion"; import { searchDescription } from "./searchDescription"; import { generateClient } from "./generateClient"; @@ -68,29 +68,6 @@ export async function activate( return; } } - if (uri.path.toLowerCase() === "/openmanifest") { - reporter.sendTelemetryEvent("DeepLink.OpenManifest"); - const manifestUrl = queryParameters["manifesturl"]; - const manifestContent = queryParameters["manifestcontent"]; - const apiIdentifier = queryParameters["apiidentifier"]; - const fromClipboard = queryParameters["fromclipboard"]; - if (manifestUrl) { - await openTreeViewWithProgress(async () => { - const logs = await openApiTreeProvider.loadManifestFromUri(manifestUrl, apiIdentifier); - await exportLogsAndShowErrors(logs); - }); - return; - } else if (manifestContent) { - await openTreeViewWithProgress(async () => { - const logs = await openApiTreeProvider.loadManifestFromContent(manifestContent, apiIdentifier); - await exportLogsAndShowErrors(logs); - }); - return; - } else if (fromClipboard.toLowerCase() === "true") { - await openManifestFromClipboard(openApiTreeProvider, apiIdentifier!); - return; - } - } void vscode.window.showErrorMessage( vscode.l10n.t("Invalid URL, please check the documentation for the supported URLs") ); @@ -247,28 +224,6 @@ export async function activate( await filterSteps(openApiTreeProvider.filter, x => openApiTreeProvider.filter = x); } ), - registerCommandWithTelemetry(reporter, - `${treeViewId}.openDescription`, - async () => { - const openState = await openSteps(); - if (openState.descriptionPath) { - await openTreeViewWithProgress(() => openApiTreeProvider.setDescriptionUrl(openState.descriptionPath!)); - } - } - ), - registerCommandWithTelemetry(reporter, - `${treeViewId}.openManifestPath`, - async () => { - const openState = await openManifestSteps(); - if (openState.manifestPath) { - await openTreeViewWithProgress(() => openApiTreeProvider.loadManifestFromUri(openState.manifestPath!)); - } - } - ), - registerCommandWithTelemetry(reporter, - `${treeViewId}.pasteManifest`, - () => openManifestFromClipboard(openApiTreeProvider, "") - ), registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { clientOrPluginKey = clientKey; clientOrPluginObject = clientObject; @@ -586,41 +541,6 @@ export async function activate( context.subscriptions.push(disposable); } -async function openManifestFromClipboard(openApiTreeProvider: OpenApiTreeProvider, apiIdentifier?: string): Promise { - await openTreeViewWithProgress(async () => { - let clipBoardContent = await vscode.env.clipboard.readText(); - if (!clipBoardContent) { - await vscode.window.showErrorMessage( - vscode.l10n.t("No content found in the clipboard") - ); - return; - } - try { - let deserializedContent: ApiManifest; - try { - deserializedContent = JSON.parse(clipBoardContent) as ApiManifest; - // if it's valid json, it's not base64 encoded - } catch { - clipBoardContent = Buffer.from(clipBoardContent, 'base64').toString('utf-8'); - deserializedContent = JSON.parse(clipBoardContent) as ApiManifest; - } - if (!apiIdentifier && deserializedContent.apiDependencies && Object.keys(deserializedContent.apiDependencies).length > 1) { - const apiKeys = Object.keys(deserializedContent.apiDependencies); - const selectKeyResult = await selectApiManifestKey(apiKeys); - if (selectKeyResult.selectedKey) { - apiIdentifier = selectKeyResult.selectedKey; - } - } - } catch (error) { - await vscode.window.showErrorMessage( - vscode.l10n.t("Invalid content found in the clipboard") - ); - return; - } - const logs = await openApiTreeProvider.loadManifestFromContent(clipBoardContent, apiIdentifier); - await exportLogsAndShowErrors(logs); - }); -} function openTreeViewWithProgress(callback: () => Promise): Thenable { return vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index eadde8e138..c6b64a86ef 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -1,72 +1,6 @@ import { QuickPickItem, window, Disposable, QuickInputButton, QuickInput, QuickInputButtons, workspace, l10n, Uri } from 'vscode'; import { allGenerationLanguages, generationLanguageToString, KiotaSearchResultItem, LanguagesInformation, maturityLevelToString } from './kiotaInterop'; - -export async function openSteps() { - const state = {} as Partial; - const title = l10n.t('Open an API description'); - let step = 1; - let totalSteps = 1; - async function inputPathOrUrl(input: MultiStepInput, state: Partial) { - state.descriptionPath = await input.showInputBox({ - title, - step: step++, - totalSteps: totalSteps, - value: state.descriptionPath || '', - prompt: l10n.t('A path or url to an OpenAPI description'), - validate: validateIsNotEmpty, - shouldResume: shouldResume - }); - } - await MultiStepInput.run(input => inputPathOrUrl(input, state), () => step-=2); - return state; -}; - -export async function openManifestSteps() { - const state = {} as Partial; - const title = l10n.t('Open an API manifest'); - let step = 1; - let totalSteps = 1; - async function inputPathOrUrl(input: MultiStepInput, state: Partial) { - state.manifestPath = await input.showInputBox({ - title, - step: step++, - totalSteps: totalSteps, - value: state.manifestPath ?? '', - prompt: l10n.t('A path or URL to an API manifest'), - validate: validateIsNotEmpty, - shouldResume: shouldResume - }); - } - await MultiStepInput.run(input => inputPathOrUrl(input, state), () => step-=2); - return state; -}; - -export async function selectApiManifestKey(keys: string[]) { - const state = {} as Partial; - let step = 1; - let totalSteps = 1; - const title = l10n.t('Select an API manifest key'); - async function pickSearchResult(input: MultiStepInput, state: Partial) { - const items = keys.map(x => - { - return { - label: x, - } as QuickPickItem; - }); - const pick = await input.showQuickPick({ - title, - step: step++, - totalSteps: totalSteps, - placeholder: l10n.t('Select an API manifest key'), - items: items, - shouldResume: shouldResume - }); - state.selectedKey = keys.find(x => x === pick?.label); - } - await MultiStepInput.run(input => pickSearchResult(input, state), () => step-=2); - return state; -} export async function filterSteps(existingFilter: string, filterCallback: (searchQuery: string) => void) { const state = {} as Partial; const title = l10n.t('Filter the API description'); @@ -153,10 +87,6 @@ export async function searchSteps(searchCallBack: (searchQuery: string) => Thena return state; } -interface SearchItem { - descriptionUrl?: string; -} -type QuickSearchPickItem = QuickPickItem & SearchItem; export async function generateSteps(existingConfiguration: Partial, languagesInformation?: LanguagesInformation) { const state = {...existingConfiguration} as Partial; @@ -350,17 +280,10 @@ interface OpenState extends BaseStepsState { descriptionPath: string; } -interface OpenManifestState extends BaseStepsState { - manifestPath: string; -} - -interface SearchLockState extends BaseStepsState { - lockFilePath: Uri; -} - -interface SelectApiManifestKey extends BaseStepsState { - selectedKey: string; +interface SearchItem { + descriptionUrl?: string; } +type QuickSearchPickItem = QuickPickItem & SearchItem; export interface GenerateState extends BaseStepsState { generationType: QuickPickItem | string; From cbd508ebe1d4055bcb64f7fc715146cbb77fee79 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 22 May 2024 15:10:51 +0300 Subject: [PATCH 070/150] update static strings --- vscode/microsoft-kiota/package.nls.ar.json | 4 +--- vscode/microsoft-kiota/package.nls.cs.json | 2 -- vscode/microsoft-kiota/package.nls.es.json | 4 +--- vscode/microsoft-kiota/package.nls.fr.json | 4 +--- vscode/microsoft-kiota/package.nls.it.json | 4 +--- vscode/microsoft-kiota/package.nls.ja.json | 4 +--- vscode/microsoft-kiota/package.nls.json | 2 -- vscode/microsoft-kiota/package.nls.pl.json | 4 +--- vscode/microsoft-kiota/package.nls.pt.json | 4 +--- vscode/microsoft-kiota/package.nls.ru.json | 6 ++---- vscode/microsoft-kiota/package.nls.sw.json | 6 ++---- vscode/microsoft-kiota/package.nls.tr.json | 4 +--- vscode/microsoft-kiota/package.nls.zh-cn.json | 4 +--- 13 files changed, 13 insertions(+), 39 deletions(-) diff --git a/vscode/microsoft-kiota/package.nls.ar.json b/vscode/microsoft-kiota/package.nls.ar.json index 1aa0acd146..48366f0a8e 100644 --- a/vscode/microsoft-kiota/package.nls.ar.json +++ b/vscode/microsoft-kiota/package.nls.ar.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "مستكشف Kiota OpenAPI", "kiota.openApiExplorer.contextualTitle": "مستكشف OpenAPI", "kiota-dependencies-info.panel.title": "معلومات حول تبعيات Kiota", - "kiota-openapi-explorer.activitybar.title": "مستكشف Kiota OpenAPI", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "اختر ملف القفل لمستكشف الAPI", "kiota.updateClients.title": "حدث عملاء الAPI في مساحة العمل الحالية", "kiota.openApiExplorer.generateClient.title": "انشاء عميل الAPI", @@ -17,8 +17,6 @@ "kiota.searchLock.title": "ابحث عن ملف قفل", "kiota.openApiExplorer.filterDescription.title": "قم بتصفية وصف API", "kiota.openApiExplorer.openDocumentationPage.title": "افتح صفحة الوثائق", - "kiota.openApiExplorer.openManifestPath.title": "افتح بيان واجهة برمجة التطبيقات", - "kiota.openApiExplorer.pasteManifest.title": "الصق بيان واجهة برمجة التطبيقات", "kiota.generate.backingStore.description": "تمكين مخزن الدعم للنماذج", "kiota.generate.excludeBackwardCompatible.description": "يستبعد الأصول المتوافقة مع الإصدارات السابقة والمتقادمة من النتيجة التي تم إنشاؤها. ينبغي أن تستخدم للعملاء الجدد", "kiota.cleanOutput.description": "يزيل كافة الملفات من دليل الإخراج قبل إنشاء ملفات التعليمات البرمجية", diff --git a/vscode/microsoft-kiota/package.nls.cs.json b/vscode/microsoft-kiota/package.nls.cs.json index 7ba0a21872..a7b800f5bb 100644 --- a/vscode/microsoft-kiota/package.nls.cs.json +++ b/vscode/microsoft-kiota/package.nls.cs.json @@ -17,8 +17,6 @@ "kiota.searchLock.title": "Hledat soubor se zámkem", "kiota.openApiExplorer.filterDescription.title": "Filtrovat popis API", "kiota.openApiExplorer.openDocumentationPage.title": "Otevřít stránku dokumentace", - "kiota.openApiExplorer.openManifestPath.title": "Otevřít API manifest", - "kiota.openApiExplorer.pasteManifest.title": "Vložit API manifest", "kiota.generate.backingStore.description": "Povoluje úložiště pro modely", "kiota.generate.excludeBackwardCompatible.description": "Vylučuje zpětně kompatibilní a zastaralé prvky z vygenerovaného výsledku. Mělo by se používat pro nové klienty", "kiota.cleanOutput.description": "Odstraní všechny soubory z výstupního adresáře před generováním souborů s kódem", diff --git a/vscode/microsoft-kiota/package.nls.es.json b/vscode/microsoft-kiota/package.nls.es.json index 31c43f3a56..9f19360fca 100644 --- a/vscode/microsoft-kiota/package.nls.es.json +++ b/vscode/microsoft-kiota/package.nls.es.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "Explorador de OpenAPI de Kiota", "kiota.openApiExplorer.contextualTitle": "Explorador de OpenAPI", "kiota-dependencies-info.panel.title": "Información sobre las dependencias de Kiota", - "kiota-openapi-explorer.activitybar.title": "Explorador de OpenAPI de Kiota", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "Seleccionar archivo de bloqueo para vista en Explorador de API", "kiota.updateClients.title": "Actualizar clientes del API en este espacio de trabajo", "kiota.openApiExplorer.generateClient.title": "Generar cliente del API", @@ -17,8 +17,6 @@ "kiota.searchLock.title": "Buscar un archivo lock", "kiota.openApiExplorer.filterDescription.title": "Filtrar descripción de API", "kiota.openApiExplorer.openDocumentationPage.title": "Abrir documentación", - "kiota.openApiExplorer.openManifestPath.title": "Abrir manifesto de OpenAPI", - "kiota.openApiExplorer.pasteManifest.title": "Pegar manifesto de OpenAPI", "kiota.generate.backingStore.description": "Habilita almacenamiento de respaldo para los modelos.", "kiota.generate.excludeBackwardCompatible.description": "Excluye activos obsoletos y compatibles con anteriores versiones del resultado generado. Debe ser usado para nuevos clientes.", "kiota.cleanOutput.description": "Remueve todos los archivos del directorio producido antes de generar los archivos de código.", diff --git a/vscode/microsoft-kiota/package.nls.fr.json b/vscode/microsoft-kiota/package.nls.fr.json index 97a3590115..3d725ceae7 100644 --- a/vscode/microsoft-kiota/package.nls.fr.json +++ b/vscode/microsoft-kiota/package.nls.fr.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "Explorateur OpenAPI Kiota", "kiota.openApiExplorer.contextualTitle": "Explorateur OpenAPI", "kiota-dependencies-info.panel.title": "Informations sur les dépendances Kiota", - "kiota-openapi-explorer.activitybar.title": "Explorateur OpenAPI Kiota", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "Sélectionner pour la vue explorateur d'API", "kiota.updateClients.title": "Mettre à jour les clients d'API dans l'environment courant", "kiota.openApiExplorer.generateClient.title": "Générer le client d'API", @@ -17,8 +17,6 @@ "kiota.searchLock.title": "Rechercher un fichier verrou", "kiota.openApiExplorer.filterDescription.title": "Filtrer la description", "kiota.openApiExplorer.openDocumentationPage.title": "Ouvrir la page de documentation", - "kiota.openApiExplorer.openManifestPath.title": "Ouvrir un manifeste d'API", - "kiota.openApiExplorer.pasteManifest.title": "Coller un manifeste d'API", "kiota.generate.backingStore.description": "Active le stockage d'informations déporté pour les modèles.", "kiota.generate.excludeBackwardCompatible.description": "Exclue les éléments de compatibilité et obsolètes du résultat. Devrait être activé pour tout nouveau client.", "kiota.cleanOutput.description": "Supprime tous les fichiers du répertoire de destination avant de générer les nouveaux fichiers.", diff --git a/vscode/microsoft-kiota/package.nls.it.json b/vscode/microsoft-kiota/package.nls.it.json index 27ce1f4849..34678ba045 100644 --- a/vscode/microsoft-kiota/package.nls.it.json +++ b/vscode/microsoft-kiota/package.nls.it.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "Kiota OpenAPI Explorer", "kiota.openApiExplorer.contextualTitle": "OpenAPI Explorer", "kiota-dependencies-info.panel.title": "Informazioni sulle Dipendenze di Kiota", - "kiota-openapi-explorer.activitybar.title": "Kiota OpenAPI Explorer", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "Seleziona un file di lock per visualizzarlo all'interno di API Explorer", "kiota.updateClients.title": "Aggiorna i client API nel workspace corrente", "kiota.openApiExplorer.generateClient.title": "Genera un client API", @@ -17,8 +17,6 @@ "kiota.searchLock.title": "Cerca il file di lock", "kiota.openApiExplorer.filterDescription.title": "Filtra la descrizione delle API", "kiota.openApiExplorer.openDocumentationPage.title": "Apri la pagina di documentazione", - "kiota.openApiExplorer.openManifestPath.title": "Apri il manifest delle API", - "kiota.openApiExplorer.pasteManifest.title": "Copia il manifest delle API", "kiota.generate.backingStore.description": "Abilita il backing store per i modelli", "kiota.generate.excludeBackwardCompatible.description": "Esclude gli asset retrocompatibili e obsoleti dal risultato generato. Da utilizzare per i nuovi clienti", "kiota.cleanOutput.description": "Rimuove tutti i file dalla directory di output prima di generare i file di codice.", diff --git a/vscode/microsoft-kiota/package.nls.ja.json b/vscode/microsoft-kiota/package.nls.ja.json index 945185816a..2ad913f65a 100644 --- a/vscode/microsoft-kiota/package.nls.ja.json +++ b/vscode/microsoft-kiota/package.nls.ja.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "Kiota OpenAPIエクスプローラ", "kiota.openApiExplorer.contextualTitle": "OpenAPIエクスプローラ", "kiota-dependencies-info.panel.title": "Kiota依存関係情報", - "kiota-openapi-explorer.activitybar.title": "Kiota OpenAPIエクスプローラ", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "APIエクスプローラビューのロックファイルを選択", "kiota.updateClients.title": "現在のワークスペースでAPIクライアントを更新", "kiota.openApiExplorer.generateClient.title": "APIクライアントを生成", @@ -17,8 +17,6 @@ "kiota.searchLock.title": "ロックファイルを検索", "kiota.openApiExplorer.filterDescription.title": "API仕様書をフィルタ", "kiota.openApiExplorer.openDocumentationPage.title": "ドキュメントページを開く", - "kiota.openApiExplorer.openManifestPath.title": "APIマニフェストを開く", - "kiota.openApiExplorer.pasteManifest.title": "APIマニフェストを貼り付け", "kiota.generate.backingStore.description": "モデルのバッキングストアを有効にする", "kiota.generate.excludeBackwardCompatible.description": "生成された結果から後方互換性のある古いアセットを除外する(新規クライアントに使用)", "kiota.cleanOutput.description": "コードファイルを生成する前に出力先のディレクトリからすべてのファイルを削除する", diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index 8422222b56..920543c492 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -17,8 +17,6 @@ "kiota.searchLock.title": "Search for a lock file", "kiota.openApiExplorer.filterDescription.title": "Filter API description", "kiota.openApiExplorer.openDocumentationPage.title": "Open documentation page", - "kiota.openApiExplorer.openManifestPath.title": "Open API manifest", - "kiota.openApiExplorer.pasteManifest.title": "Paste API manifest", "kiota.generate.backingStore.description": "Enables backing store for models", "kiota.generate.excludeBackwardCompatible.description": "Excludes backward compatible and obsolete assets from the generated result. Should be used for new clients", "kiota.cleanOutput.description": "Removes all files from the output directory before generating the code files", diff --git a/vscode/microsoft-kiota/package.nls.pl.json b/vscode/microsoft-kiota/package.nls.pl.json index 2fc27cf3ce..eeee8fe439 100644 --- a/vscode/microsoft-kiota/package.nls.pl.json +++ b/vscode/microsoft-kiota/package.nls.pl.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "Przeglądarka OpenAPI Kiota", "kiota.openApiExplorer.contextualTitle": "Przeglądarka OpenAPI", "kiota-dependencies-info.panel.title": "Informacje o zależnościach Kiota", - "kiota-openapi-explorer.activitybar.title": "Przeglądarka OpenAPI Kiota", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "Wybierz plik lock dla widoku eksploratora API", "kiota.updateClients.title": "Zaktualizuj klientów API w bieżącej przestrzeni roboczej", "kiota.openApiExplorer.generateClient.title": "Generuj klienta API", @@ -18,8 +18,6 @@ "kiota.searchLock.title": "Wyszukaj plik lock", "kiota.openApiExplorer.filterDescription.title": "Filtruj opis API", "kiota.openApiExplorer.openDocumentationPage.title": "Otwórz stronę dokumentacji", - "kiota.openApiExplorer.openManifestPath.title": "Otwórz manifest API", - "kiota.openApiExplorer.pasteManifest.title": "Wklej manifest API", "kiota.generate.backingStore.description": "Włącza kopię zapasową dla modeli", "kiota.generate.excludeBackwardCompatible.description": "Wyklucza zgodne wstecz i przestarzałe zasoby z wyniku generacji. Należy używać w przypadku nowych klientów", "kiota.cleanOutput.description": "Usuwa wszystkie pliki z katalogu wyjściowego przed wygenerowaniem plików kodu", diff --git a/vscode/microsoft-kiota/package.nls.pt.json b/vscode/microsoft-kiota/package.nls.pt.json index e48ffdc145..7e0397e9cf 100644 --- a/vscode/microsoft-kiota/package.nls.pt.json +++ b/vscode/microsoft-kiota/package.nls.pt.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "Explorador de OpenAPI do Kiota", "kiota.openApiExplorer.contextualTitle": "Explorador de OpenAPI", "kiota-dependencies-info.panel.title": "Informação de dependências do Kiota", - "kiota-openapi-explorer.activitybar.title": "Explorador de OpenAPI do Kiota", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "Selecione o arquivo 'lock' para visualizar o explorador de API", "kiota.updateClients.title": "Atualizar os clientes de APIs no espaço de trabalho atual", "kiota.openApiExplorer.generateClient.title": "Gerar cliente da API", @@ -17,8 +17,6 @@ "kiota.searchLock.title": "Buscar um arquivo lock", "kiota.openApiExplorer.filterDescription.title": "Filtrar descrição da API", "kiota.openApiExplorer.openDocumentationPage.title": "Abrir página de documentação", - "kiota.openApiExplorer.openManifestPath.title": "Abrir manifesto da API", - "kiota.openApiExplorer.pasteManifest.title": "Colar manifesto da API", "kiota.generate.backingStore.description": "Habilita armazenamento de apoio para os modelos", "kiota.generate.excludeBackwardCompatible.description": "Exclui retrocompatibilidade e ativos obsoletos do resultado gerado. Deve ser usado para novos clientes", "kiota.cleanOutput.description": "Remove todos os arquivos do diretório de saída antes de gerar os arquivos de código", diff --git a/vscode/microsoft-kiota/package.nls.ru.json b/vscode/microsoft-kiota/package.nls.ru.json index 809c1b4d93..e5bde6083a 100644 --- a/vscode/microsoft-kiota/package.nls.ru.json +++ b/vscode/microsoft-kiota/package.nls.ru.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "OpenAPI исследователь для Kiota", "kiota.openApiExplorer.contextualTitle": "OpenAPI исследователь", "kiota-dependencies-info.panel.title": "Информация о зависимостях Kiota", - "kiota-openapi-explorer.activitybar.title": "OpenAPI исследователь для Kiota", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "Выберите файл блокировки для просмотра API-исследователя", "kiota.updateClients.title": "Обновите API-клиенты в текущем рабочем пространстве", "kiota.openApiExplorer.generateClient.title": "Создать клиент API", @@ -16,7 +16,5 @@ "kiota.openApiExplorer.openDescription.title": "Открыть описание API", "kiota.searchLock.title": "Искать файл блокировки", "kiota.openApiExplorer.filterDescription.title": "Отфильтровать описание API", - "kiota.openApiExplorer.openDocumentationPage.title": "Открыть страницу документации", - "kiota.openApiExplorer.openManifestPath.title": "Откройте манифест API", - "kiota.openApiExplorer.pasteManifest.title": "Вставьте манифест API" + "kiota.openApiExplorer.openDocumentationPage.title": "Открыть страницу документации" } diff --git a/vscode/microsoft-kiota/package.nls.sw.json b/vscode/microsoft-kiota/package.nls.sw.json index 2437ae419d..c5d47fcc3b 100644 --- a/vscode/microsoft-kiota/package.nls.sw.json +++ b/vscode/microsoft-kiota/package.nls.sw.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "Mchunguzi wa OpenAPI Kiota", "kiota.openApiExplorer.contextualTitle": "Mchunguzi wa OpenAPI", "kiota-dependencies-info.panel.title": "Taarifa za Mategemeo za Kiota", - "kiota-openapi-explorer.activitybar.title": "Mchunguzi wa OpenAPI Kiota", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "Chagua faili ya kufunga ili uone kichunguzi cha API", "kiota.updateClients.title": "Sasisha wateja wa API katika nafasi ya kazi", "kiota.openApiExplorer.generateClient.title": "Tengeneza mteja wa API", @@ -16,7 +16,5 @@ "kiota.openApiExplorer.openDescription.title": "Fungua maelezo ya API", "kiota.searchLock.title": "Tafuta faili ya kufunga", "kiota.openApiExplorer.filterDescription.title": "Chuja maelezo ya API", - "kiota.openApiExplorer.openDocumentationPage.title": "Fungua ukurasa wa nyaraka", - "kiota.openApiExplorer.openManifestPath.title": "Fungua dhahiri ya API", - "kiota.openApiExplorer.pasteManifest.title": "Bandiko dhahiri ya dhahiri" + "kiota.openApiExplorer.openDocumentationPage.title": "Fungua ukurasa wa nyaraka" } diff --git a/vscode/microsoft-kiota/package.nls.tr.json b/vscode/microsoft-kiota/package.nls.tr.json index ae99d85a02..4c543c438d 100644 --- a/vscode/microsoft-kiota/package.nls.tr.json +++ b/vscode/microsoft-kiota/package.nls.tr.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "Kiota OpenAPI Gezgini", "kiota.openApiExplorer.contextualTitle": "OpenAPI Gezgini", "kiota-dependencies-info.panel.title": "Kiota Bağımlılıkları Bilgisi", - "kiota-openapi-explorer.activitybar.title": "Kiota OpenAPI Gezgini", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "API gezgini görünümü için kilit dosyasını seçin", "kiota.updateClients.title": "Mevcut çalışma alanındaki API istecilerini güncelle", "kiota.openApiExplorer.generateClient.title": "API istemcisi oluştur", @@ -17,8 +17,6 @@ "kiota.searchLock.title": "Kilit dosyası arayın", "kiota.openApiExplorer.filterDescription.title": "API açıklaması filtrele", "kiota.openApiExplorer.openDocumentationPage.title": "API belgelerini aç", - "kiota.openApiExplorer.openManifestPath.title": "API manifestini aç", - "kiota.openApiExplorer.pasteManifest.title": "API manifestini yapıştır", "kiota.generate.backingStore.description": "Modeller için yedekleme deposunu etkinleştirir", "kiota.generate.excludeBackwardCompatible.description": "Geriye dönük olarak uyumlu ve eski varlıkları oluşturulan sonuçtan hariç tutar. Yeni müşteriler için kullanılmalı", "kiota.cleanOutput.description": "Kod dosyalarını oluşturmadan önce çıktı dizinindeki tüm dosyaları kaldırır", diff --git a/vscode/microsoft-kiota/package.nls.zh-cn.json b/vscode/microsoft-kiota/package.nls.zh-cn.json index 41a799a764..570e155d74 100644 --- a/vscode/microsoft-kiota/package.nls.zh-cn.json +++ b/vscode/microsoft-kiota/package.nls.zh-cn.json @@ -4,7 +4,7 @@ "kiota.openApiExplorer.name": "Kiota OpenAPI 资源浏览器", "kiota.openApiExplorer.contextualTitle": "OpenAPI 资源浏览器", "kiota-dependencies-info.panel.title": "Kiota依赖项信息", - "kiota-openapi-explorer.activitybar.title": "Kiota OpenAPI 资源浏览器", + "kiota-openapi-explorer.activitybar.title": "Kiota", "kiota.selectLock.title": "选择API资源浏览器的锁定文件", "kiota.updateClients.title": "更新当前工作区API客户端", "kiota.openApiExplorer.generateClient.title": "建立API客户端", @@ -17,8 +17,6 @@ "kiota.searchLock.title": "搜索锁定文件", "kiota.openApiExplorer.filterDescription.title": "筛选API描述", "kiota.openApiExplorer.openDocumentationPage.title": "打开文档页", - "kiota.openApiExplorer.openManifestPath.title": "打开API清单", - "kiota.openApiExplorer.pasteManifest.title": "粘贴API清单", "kiota.generate.backingStore.description": "启用模型后备存储", "kiota.generate.excludeBackwardCompatible.description": "从生成的结果中排除向后兼容和过时的资产。应该用于新客户端", "kiota.cleanOutput.description": "在生成代码文件之前从输出目录中删除所有文件", From bf1e227b51697ab19267daea62608e9ed5439c36 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 22 May 2024 15:24:52 +0300 Subject: [PATCH 071/150] add missing l10n --- vscode/microsoft-kiota/src/steps.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index c6b64a86ef..12d75531e5 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -187,7 +187,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.pluginName = await input.showInputBox({ - title: `${l10n.t('Create a new plugin')} - ${('plugin name')}`, + title: `${l10n.t('Create a new plugin')} - ${l10n.t('plugin name')}`, step: step++, totalSteps: 3, value: state.pluginName ?? '', @@ -201,10 +201,10 @@ export async function generateSteps(existingConfiguration: Partial) { const items = ['Microsoft','Open AI'].map(x => ({ label: x})as QuickPickItem); const pluginTypes = await input.showQuickPick({ - title: 'Choose a plugin type', + title: l10n.t('Choose a plugin type'), step: step++, totalSteps: 3, - placeholder: 'Select an option', + placeholder: l10n.t('Select an option'), items: items, validate: validateIsNotEmpty, shouldResume: shouldResume @@ -214,7 +214,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.outputPath = await input.showInputBox({ - title: `${l10n.t('Create a new plugin')} - ${('output directory')}}`, + title: `${l10n.t('Create a new plugin')} - ${l10n.t('output directory')}`, step: step++, totalSteps: 3, value: typeof state.outputPath === 'string' ? state.outputPath : '', @@ -226,7 +226,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.pluginName = await input.showInputBox({ - title: `${l10n.t('Create a new manifest')} - ${('manifest name')}`, + title: `${l10n.t('Create a new manifest')} - ${l10n.t('manifest name')}`, step: step++, totalSteps: 3, value: state.pluginName ?? '', @@ -239,7 +239,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.outputPath = await input.showInputBox({ - title: `${l10n.t('Create a new manifest')} - ${('output directory')}`, + title: `${l10n.t('Create a new manifest')} - ${l10n.t('output directory')}`, step: step++, totalSteps: 3, value: typeof state.outputPath === 'string' ? state.outputPath : '', From 1650da1f7e06de6f4ea7a4e045f5bc59c8dc1fdb Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 22 May 2024 15:25:35 +0300 Subject: [PATCH 072/150] update string typo --- vscode/microsoft-kiota/l10n/bundle.l10n.ar.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.cs.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.es.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.fr.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.ja.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.pl.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.pt.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.ru.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.sw.json | 2 +- vscode/microsoft-kiota/l10n/bundle.l10n.tr.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json index f9b5b585db..441b9e14fb 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json @@ -54,7 +54,7 @@ "Create a new plugin": "", "Create a new manifest": "", "plugin name:": "", - "Choose a name for the plugin:": "", + "Choose a name for the plugin": "", "Choose a plugin type": "", "manifest name": "", "Choose a name for the manifest": "", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json index ae9fddff1a..108bae1484 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json @@ -54,7 +54,7 @@ "Create a new plugin": "Vytvořit nový plugin", "Create a new manifest": "Vytvořit nový manifest", "plugin name:": "název pluginu", - "Choose a name for the plugin:": "Vyberte název pro plugin", + "Choose a name for the plugin": "Vyberte název pro plugin", "Choose a plugin type": "Vyberte typ pluginu", "manifest name": "název manifestu", "Choose a name for the manifest": "Vyberte název pro manifest", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json index 4005c2461b..417be3b3d3 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json @@ -54,7 +54,7 @@ "Create a new plugin": "Crear un nuevo plugin", "Create a new manifest": "Crear un nuevo manifesto", "plugin name:": "nombre del plugin", - "Choose a name for the plugin:": "Elija un nombre para el plugin", + "Choose a name for the plugin": "Elija un nombre para el plugin", "Choose a plugin type": "Elija un tipo de plugin", "manifest name": "Nombre de manifesto", "Choose a name for the manifest": "Elija un nombre para el manifesto", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json index 378b5e7e9b..36c88bf1e5 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json @@ -54,7 +54,7 @@ "Create a new plugin": "Créer un nouveau composant", "Create a new manifest": "Créer un nouveau manifeste", "plugin name:": "nom du composant", - "Choose a name for the plugin:": "Choisissez un nom pour le composant", + "Choose a name for the plugin": "Choisissez un nom pour le composant", "Choose a plugin type": "Choisisses un type de composant", "manifest name": "nom du manifeste", "Choose a name for the manifest": "Choisissez un nom pour le manifeste", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json index b7246b36dd..e248530e02 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json @@ -55,7 +55,7 @@ "Create a new plugin": "", "Create a new manifest": "", "plugin name:": "", - "Choose a name for the plugin:": "", + "Choose a name for the plugin": "", "Choose a plugin type": "", "manifest name": "", "Choose a name for the manifest": "", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json index e19314f3b1..01a11e96cf 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json @@ -54,7 +54,7 @@ "Create a new plugin": "Utwórz nową wtyczkę", "Create a new manifest": "", "plugin name:": "", - "Choose a name for the plugin:": "", + "Choose a name for the plugin": "", "Choose a plugin type": "", "manifest name": "", "Choose a name for the manifest": "", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json index 9399d1777f..7f9a96542f 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json @@ -54,7 +54,7 @@ "Create a new plugin": "Criar um novo plugin ", "Create a new manifest": "Criar um novo manifesto", "plugin name:": "Nome do plugin", - "Choose a name for the plugin:": "Escolha um nome para o plugin", + "Choose a name for the plugin": "Escolha um nome para o plugin", "Choose a plugin type": "Escolha o tipo do plugin", "manifest name": "nome do manifesto", "Choose a name for the manifest": "Escolha um nome para o manifesto", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json index ba088d3b87..c3e06fd588 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json @@ -53,7 +53,7 @@ "Create a new plugin": "", "Create a new manifest": "", "plugin name:": "", - "Choose a name for the plugin:": "", + "Choose a name for the plugin": "", "Choose a plugin type": "", "manifest name": "", "Choose a name for the manifest": "", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json index f047ab166f..acd171d40c 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json @@ -54,7 +54,7 @@ "Create a new plugin": "Tengeneza programu-jalizi mpya", "Create a new manifest": "", "plugin name:": "", - "Choose a name for the plugin:": "", + "Choose a name for the plugin": "", "Choose a plugin type": "", "manifest name": "", "Choose a name for the manifest": "", diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json index acae4f4aa9..1db954277f 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json @@ -54,7 +54,7 @@ "Create a new plugin": "", "Create a new manifest": "", "plugin name:": "", - "Choose a name for the plugin:": "", + "Choose a name for the plugin": "", "Choose a plugin type": "", "manifest name": "", "Choose a name for the manifest": "", From 8377932a1b3f4cefdb2630efdd16f71f3d9260da Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 22 May 2024 15:40:26 +0300 Subject: [PATCH 073/150] update static string localization files --- vscode/microsoft-kiota/package.nls.ar.json | 5 ++++- vscode/microsoft-kiota/package.nls.cs.json | 3 ++- vscode/microsoft-kiota/package.nls.es.json | 5 ++++- vscode/microsoft-kiota/package.nls.fr.json | 5 ++++- vscode/microsoft-kiota/package.nls.it.json | 5 ++++- vscode/microsoft-kiota/package.nls.ja.json | 5 ++++- vscode/microsoft-kiota/package.nls.json | 1 - vscode/microsoft-kiota/package.nls.pl.json | 5 ++++- vscode/microsoft-kiota/package.nls.pt.json | 5 ++++- vscode/microsoft-kiota/package.nls.sw.json | 6 +++++- vscode/microsoft-kiota/package.nls.tr.json | 5 ++++- vscode/microsoft-kiota/package.nls.zh-cn.json | 5 ++++- 12 files changed, 43 insertions(+), 12 deletions(-) diff --git a/vscode/microsoft-kiota/package.nls.ar.json b/vscode/microsoft-kiota/package.nls.ar.json index 48366f0a8e..8f80d7c77a 100644 --- a/vscode/microsoft-kiota/package.nls.ar.json +++ b/vscode/microsoft-kiota/package.nls.ar.json @@ -25,5 +25,8 @@ "kiota.generate.serializer.description": "أسماء الفئات المؤهلة بالكامل للمتسلسلات", "kiota.generate.deserializer.description": "أسماء الفئات المؤهلة بالكامل لإلغاء التسلسل", "kiota.generate.structuredMimeTypes.description": "أنواع MIME والتفضيلات المستخدمة لإنشاء نماذج البيانات المنظمة. وفقًا لـ RFC9110، قم بقبول تدوين الرأس.", - "kiota.generate.includeAdditionalData.description": "سيتم تضمين خاصية 'Additional Data' للنماذج" + "kiota.generate.includeAdditionalData.description": "سيتم تضمين خاصية 'Additional Data' للنماذج", + "kiota.workspace.name": "", + "kiota.openApiExplorer.regenerateButton.title": "", + "kiota.openApiExplorer.editPaths.title": "" } diff --git a/vscode/microsoft-kiota/package.nls.cs.json b/vscode/microsoft-kiota/package.nls.cs.json index a7b800f5bb..eebfa55d3d 100644 --- a/vscode/microsoft-kiota/package.nls.cs.json +++ b/vscode/microsoft-kiota/package.nls.cs.json @@ -27,5 +27,6 @@ "kiota.generate.structuredMimeTypes.description": "MIME typy a preference pro generování strukturovaných datových modelů. Podle notace Accept hlavičky dle RFC9110.", "kiota.generate.includeAdditionalData.description": "Bude zahrnuta vlastnost 'AdditionalData' pro modely", "kiota.workspace.name": "Můj pracovní prostor", - "kiota.openApiExplorer.openFile.title": "Otevřít soubor" + "kiota.openApiExplorer.regenerateButton.title": "Znovu vygenerovat", + "kiota.openApiExplorer.editPaths.title": "Upravit cesty" } diff --git a/vscode/microsoft-kiota/package.nls.es.json b/vscode/microsoft-kiota/package.nls.es.json index 9f19360fca..60a2d1fdaa 100644 --- a/vscode/microsoft-kiota/package.nls.es.json +++ b/vscode/microsoft-kiota/package.nls.es.json @@ -25,5 +25,8 @@ "kiota.generate.serializer.description": "Los nombres de clase completamente calificados para serializadores", "kiota.generate.deserializer.description": "Los nombres de clase completamente calificados para deserializadores", "kiota.generate.structuredMimeTypes.description": "Las preferencias y tipos MIME para usar en la generación de modelos de data estructurados. De acuerdo con RFC9110, acepte notación de encabezado.", - "kiota.generate.includeAdditionalData.description": "Incluirá la propiedad 'AdditionalData' para modelos." + "kiota.generate.includeAdditionalData.description": "Incluirá la propiedad 'AdditionalData' para modelos.", + "kiota.workspace.name": "Mi espacio de trabajo", + "kiota.openApiExplorer.regenerateButton.title": "Re-generar", + "kiota.openApiExplorer.editPaths.title": "Editar ruta de acceso" } diff --git a/vscode/microsoft-kiota/package.nls.fr.json b/vscode/microsoft-kiota/package.nls.fr.json index 3d725ceae7..6fc8376876 100644 --- a/vscode/microsoft-kiota/package.nls.fr.json +++ b/vscode/microsoft-kiota/package.nls.fr.json @@ -25,5 +25,8 @@ "kiota.generate.serializer.description": "Le nom complet des classes de sérialisation.", "kiota.generate.deserializer.description": "Le nom complet des classes de désérialisation.", "kiota.generate.structuredMimeTypes.description": "Les types MIME et ordre de préférence à utiliser pour la génération de modèles structurés. Suit la convention décrite dans la RFC 9110 pour l'entête Accept.", - "kiota.generate.includeAdditionalData.description": "Incluera la propriété 'AdditionalData' pour les modèles générés." + "kiota.generate.includeAdditionalData.description": "Incluera la propriété 'AdditionalData' pour les modèles générés.", + "kiota.workspace.name": "Mon espace de travail", + "kiota.openApiExplorer.regenerateButton.title": "Générer de nouveau", + "kiota.openApiExplorer.editPaths.title": "Modifier les chemins" } diff --git a/vscode/microsoft-kiota/package.nls.it.json b/vscode/microsoft-kiota/package.nls.it.json index 34678ba045..ac68bf7ec4 100644 --- a/vscode/microsoft-kiota/package.nls.it.json +++ b/vscode/microsoft-kiota/package.nls.it.json @@ -25,5 +25,8 @@ "kiota.generate.serializer.description": "I nomi di classe completamente qualificati per i serializzatori", "kiota.generate.deserializer.description": "I nomi delle classi completamente qualificate per i deserializzatori", "kiota.generate.structuredMimeTypes.description": "I tipi MIME e le preferenze da utilizzare per la generazione di modelli di dati strutturati. Come riportato nella notazione RFC9110 dell'header Accept.", - "kiota.generate.includeAdditionalData.description": "Includerà la proprietà 'AdditionalData' per i modelli" + "kiota.generate.includeAdditionalData.description": "Includerà la proprietà 'AdditionalData' per i modelli", + "kiota.workspace.name": "Il mio spazio di lavoro", + "kiota.openApiExplorer.regenerateButton.title": "Rigener", + "kiota.openApiExplorer.editPaths.title": "Modifica i percorsi" } diff --git a/vscode/microsoft-kiota/package.nls.ja.json b/vscode/microsoft-kiota/package.nls.ja.json index 2ad913f65a..20e515b42a 100644 --- a/vscode/microsoft-kiota/package.nls.ja.json +++ b/vscode/microsoft-kiota/package.nls.ja.json @@ -25,5 +25,8 @@ "kiota.generate.serializer.description": "シリアライザの完全修飾クラス名", "kiota.generate.deserializer.description": "デシリアライザの完全修飾クラス名", "kiota.generate.structuredMimeTypes.description": "構造化データモデル生成に使用するMIMEタイプと設定(RFC 9110のAcceptヘッダー表記)", - "kiota.generate.includeAdditionalData.description": "モデルのための“AdditionalData”プロパティを含める" + "kiota.generate.includeAdditionalData.description": "モデルのための“AdditionalData”プロパティを含める", + "kiota.workspace.name": "My Workspace", + "kiota.openApiExplorer.regenerateButton.title": "Re-generate", + "kiota.openApiExplorer.editPaths.title": "Edit paths" } diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index 920543c492..eb1facdf59 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -30,5 +30,4 @@ "kiota.workspace.name": "My Workspace", "kiota.openApiExplorer.regenerateButton.title": "Re-generate", "kiota.openApiExplorer.editPaths.title": "Edit paths" - } diff --git a/vscode/microsoft-kiota/package.nls.pl.json b/vscode/microsoft-kiota/package.nls.pl.json index eeee8fe439..db57de062a 100644 --- a/vscode/microsoft-kiota/package.nls.pl.json +++ b/vscode/microsoft-kiota/package.nls.pl.json @@ -26,5 +26,8 @@ "kiota.generate.serializer.description": "Pełne nazwy klas dla serializatorów", "kiota.generate.deserializer.description": "Pełne nazwy klas dla deserializatorów", "kiota.generate.structuredMimeTypes.description": "Typy MIME i preferencje do użycia dla generacji modeli danych strukturalnych. Zgodnie z notacją nagłówka Accept RFC9110.", - "kiota.generate.includeAdditionalData.description": "Doda właściwości 'AdditionalData' do modeli" + "kiota.generate.includeAdditionalData.description": "Doda właściwości 'AdditionalData' do modeli", + "kiota.workspace.name": "My Workspace", + "kiota.openApiExplorer.regenerateButton.title": "Re-generate", + "kiota.openApiExplorer.editPaths.title": "Edit paths" } diff --git a/vscode/microsoft-kiota/package.nls.pt.json b/vscode/microsoft-kiota/package.nls.pt.json index 7e0397e9cf..8128a1e643 100644 --- a/vscode/microsoft-kiota/package.nls.pt.json +++ b/vscode/microsoft-kiota/package.nls.pt.json @@ -25,5 +25,8 @@ "kiota.generate.serializer.description": "O nome totalmente qualificado da classe para serializadores", "kiota.generate.deserializer.description": "O nome totalmente qualificado da classe para desserializadores", "kiota.generate.structuredMimeTypes.description": "As preferências e os tipos MIME a serem usados para a geração de modelos de dados estruturados. De acordo com a notação do cabeçalho Accept do RFC9110..", - "kiota.generate.includeAdditionalData.description": "Será incluído a propriedade 'AdditionalData' para modelos" + "kiota.generate.includeAdditionalData.description": "Será incluído a propriedade 'AdditionalData' para modelos", + "kiota.workspace.name": "Meu espaço de trabalho", + "kiota.openApiExplorer.regenerateButton.title": "Gerar novamente", + "kiota.openApiExplorer.editPaths.title": "Modificar endpoints" } diff --git a/vscode/microsoft-kiota/package.nls.sw.json b/vscode/microsoft-kiota/package.nls.sw.json index c5d47fcc3b..254f2975c7 100644 --- a/vscode/microsoft-kiota/package.nls.sw.json +++ b/vscode/microsoft-kiota/package.nls.sw.json @@ -16,5 +16,9 @@ "kiota.openApiExplorer.openDescription.title": "Fungua maelezo ya API", "kiota.searchLock.title": "Tafuta faili ya kufunga", "kiota.openApiExplorer.filterDescription.title": "Chuja maelezo ya API", - "kiota.openApiExplorer.openDocumentationPage.title": "Fungua ukurasa wa nyaraka" + "kiota.openApiExplorer.openDocumentationPage.title": "Fungua ukurasa wa nyaraka", + "kiota.openApiExplorer.openFile.title": "fungua faili", + "kiota.workspace.name": "Mahali pa kazi yangu", + "kiota.openApiExplorer.regenerateButton.title": "Kuunda upya", + "kiota.openApiExplorer.editPaths.title": "Hariri pointi za mwisho" } diff --git a/vscode/microsoft-kiota/package.nls.tr.json b/vscode/microsoft-kiota/package.nls.tr.json index 4c543c438d..04006690ea 100644 --- a/vscode/microsoft-kiota/package.nls.tr.json +++ b/vscode/microsoft-kiota/package.nls.tr.json @@ -25,5 +25,8 @@ "kiota.generate.serializer.description": "Serileştiriciler için tam nitelikli sınıf adları", "kiota.generate.deserializer.description": "Seri durumdan çıkarma işlemleri için tam nitelikli sınıf adları", "kiota.generate.structuredMimeTypes.description": "Yapılandırılmış veri modeli oluşturmak için kullanılacak MIME türleri ve tercihi. RFC9110'a göre Başlık gösterimini kabul et.", - "kiota.generate.includeAdditionalData.description": "Modeller için 'AdditionalData' özelliğini içerecektir" + "kiota.generate.includeAdditionalData.description": "Modeller için 'AdditionalData' özelliğini içerecektir", + "kiota.workspace.name": "My Workspace", + "kiota.openApiExplorer.regenerateButton.title": "Re-generate", + "kiota.openApiExplorer.editPaths.title": "Edit paths" } diff --git a/vscode/microsoft-kiota/package.nls.zh-cn.json b/vscode/microsoft-kiota/package.nls.zh-cn.json index 570e155d74..7aaa9d1dce 100644 --- a/vscode/microsoft-kiota/package.nls.zh-cn.json +++ b/vscode/microsoft-kiota/package.nls.zh-cn.json @@ -25,5 +25,8 @@ "kiota.generate.serializer.description": "合格的序列化器类名", "kiota.generate.deserializer.description": "合格的反序列化器类名", "kiota.generate.structuredMimeTypes.description": "用于生成结构化数据模型的 MIME 类型和首选项。根据符合 RFC9110 标题符号。", - "kiota.generate.includeAdditionalData.description": "将包含模型的“AdditionalData”属性" + "kiota.generate.includeAdditionalData.description": "将包含模型的“AdditionalData”属性", + "kiota.workspace.name": "我的工作空间", + "kiota.openApiExplorer.regenerateButton.title": "重新生成", + "kiota.openApiExplorer.editPaths.title": "编辑路径" } From 6ebfac1d3b3b7a1dc19f8b7f71cf7cf253de43f4 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 22 May 2024 16:46:57 +0300 Subject: [PATCH 074/150] update french string --- vscode/microsoft-kiota/l10n/bundle.l10n.fr.json | 2 +- vscode/microsoft-kiota/src/extension.ts | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json index 36c88bf1e5..e639041a90 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json @@ -48,7 +48,7 @@ "Select an option": "Sélectionnez une option", "class": "classe", "namespace": "espace de nommage", - "output path": "chemin de sortie", + "output directory": "répertoire de sortie", "language": "langage", "Create a new API client": "Créer un nouveau client d'API", "Create a new plugin": "Créer un nouveau composant", diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 7b550d6be3..a3719a7dd8 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -232,8 +232,7 @@ export async function activate( await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, false); await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, true); }), - - registerCommandWithTelemetry(reporter,`${treeViewId}.regenerateButton`, async () => { + registerCommandWithTelemetry(reporter,`${treeViewId}.regenerateButton`, async () => { const settings = getExtensionSettings(extensionId); const selectedPaths = openApiTreeProvider.getSelectedPaths(); if (selectedPaths.length === 0) { @@ -249,7 +248,6 @@ export async function activate( await regeneratePlugin(clientOrPluginKey, clientOrPluginObject, settings, selectedPaths); } }), - registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { const settings = getExtensionSettings(extensionId); const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(kiotaWorkspaceFile)); @@ -445,7 +443,6 @@ export async function activate( void vscode.window.showInformationMessage(`Client ${clientKey} re-generated successfully.`); } - async function regeneratePlugin(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]) { const pluginTypes = typeof clientObject.pluginTypes === 'string' ? parsePluginType(clientObject.pluginTypes) : KiotaPluginType.Microsoft; await vscode.window.withProgress({ From 469108d97be0142d6e8e35ff8dc0d864b82c6f5f Mon Sep 17 00:00:00 2001 From: Elinor Date: Thu, 23 May 2024 13:13:33 +0300 Subject: [PATCH 075/150] remove else Co-authored-by: Musale Martin --- vscode/microsoft-kiota/src/steps.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 12d75531e5..aa65c3c9e2 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -45,10 +45,8 @@ export async function searchSteps(searchCallBack: (searchQuery: string) => Thena if(state.searchResults && Object.keys(state.searchResults).length > 0) { return (input: MultiStepInput) => pickSearchResult(input, state); } - else { - state.descriptionPath = state.searchQuery; - return (input: MultiStepInput) => inputPathOrUrl(input, state); - } + state.descriptionPath = state.searchQuery; + return (input: MultiStepInput) => inputPathOrUrl(input, state); } async function inputPathOrUrl(input: MultiStepInput, state: Partial) { From e2cfdf87973b44d89fbc75b3765acf431220d4b7 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 23 May 2024 15:02:47 +0300 Subject: [PATCH 076/150] add plugin output selection --- vscode/microsoft-kiota/src/steps.ts | 72 +++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 14 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 12d75531e5..be7b89c945 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -1,4 +1,4 @@ -import { QuickPickItem, window, Disposable, QuickInputButton, QuickInput, QuickInputButtons, workspace, l10n, Uri } from 'vscode'; +import { QuickPickItem, window, Disposable, QuickInputButton, QuickInput, QuickInputButtons, workspace, l10n, Uri, OpenDialogOptions } from 'vscode'; import { allGenerationLanguages, generationLanguageToString, KiotaSearchResultItem, LanguagesInformation, maturityLevelToString } from './kiotaInterop'; export async function filterSteps(existingFilter: string, filterCallback: (searchQuery: string) => void) { @@ -212,18 +212,33 @@ export async function generateSteps(existingConfiguration: Partial inputPluginOutputPath(input, state); } - async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { - state.outputPath = await input.showInputBox({ - title: `${l10n.t('Create a new plugin')} - ${l10n.t('output directory')}`, - step: step++, - totalSteps: 3, - value: typeof state.outputPath === 'string' ? state.outputPath : '', - placeholder: 'myproject/myplugin', - prompt: l10n.t('Enter an output path relative to the root of the project'), - shouldResume: shouldResume - }); - state.outputPath === ''? state.outputPath = 'output' : state.outputPath; - } + async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { + const folderSelectionOption = l10n.t('Browse your output directory'); + const inputOptions = [folderSelectionOption]; + + const selectedOption = await input.showQuickPick({ + title: `${l10n.t('Create a new plugin')} - ${l10n.t('output directory')}`, + step: step++, + totalSteps: 3, + placeholder: l10n.t('Enter an output path relative to the root of the project'), + items: inputOptions.map(label => ({ label: label as string })), + shouldResume: shouldResume + }); + if (selectedOption?.label === folderSelectionOption) { + const folderUri = await input.showOpenDialog({ + canSelectMany: false, + openLabel: 'Select', + canSelectFolders: true, + canSelectFiles: false + }); + + if (folderUri && folderUri[0]) { + state.outputPath = folderUri[0].fsPath; + } + } + state.outputPath = state.outputPath === '' ? 'output' : state.outputPath; + } + async function inputManifestName(input:MultiStepInput, state: Partial) { state.pluginName = await input.showInputBox({ title: `${l10n.t('Create a new manifest')} - ${l10n.t('manifest name')}`, @@ -348,9 +363,38 @@ interface InputBoxParameters { placeholder?: string; shouldResume: () => Thenable; } - + interface OpenDialogParameters { + canSelectMany: boolean; + openLabel: string; + canSelectFolders: boolean; + canSelectFiles: boolean; +} class MultiStepInput { + async showOpenDialog({ canSelectMany, openLabel, canSelectFolders, canSelectFiles} : OpenDialogParameters): Promise { + const disposables: Disposable[] = []; + + try { + return await new Promise((resolve) => { + const input: OpenDialogOptions = { + canSelectMany, + openLabel, + canSelectFolders, + canSelectFiles + }; + + void window.showOpenDialog(input).then(folderUris => { + if (folderUris && folderUris.length > 0) { + resolve([folderUris[0]]); + } else { + resolve(undefined); + } + }); + }); + } finally { + disposables.forEach(d => d.dispose()); + } +} static async run(start: InputStep, onNavBack?: () => void) { const input = new MultiStepInput(); From 9551fa84b0614aeda9d57b302352a83395f4d117 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 23 May 2024 15:05:36 +0300 Subject: [PATCH 077/150] add output directory selection for client generation --- vscode/microsoft-kiota/src/steps.ts | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index be7b89c945..4a129bbcc9 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -152,16 +152,30 @@ export async function generateSteps(existingConfiguration: Partial inputOutputPath(input, state); } async function inputOutputPath(input: MultiStepInput, state: Partial) { - state.outputPath = await input.showInputBox({ + const folderSelectionOption = l10n.t('Browse your output directory'); + const inputOptions = [folderSelectionOption]; + + const selectedOption = await input.showQuickPick({ title: `${l10n.t('Create a new API client')} - ${l10n.t('output directory')}`, step: step++, totalSteps: totalSteps, - value: typeof state.outputPath === 'string' ? state.outputPath : '', - placeholder: 'myproject/apiclient', - prompt: l10n.t('Enter an output path relative to the root of the project'), + placeholder: l10n.t('Enter an output path relative to the root of the project'), + items: inputOptions.map(label => ({ label: label as string })), shouldResume: shouldResume }); - state.outputPath === '' ? state.outputPath = 'output' : state.outputPath; + if (selectedOption?.label === folderSelectionOption) { + const folderUri = await input.showOpenDialog({ + canSelectMany: false, + openLabel: 'Select', + canSelectFolders: true, + canSelectFiles: false + }); + + if (folderUri && folderUri[0]) { + state.outputPath = folderUri[0].fsPath; + } + } + state.outputPath = state.outputPath === '' ? 'output' : state.outputPath; return (input: MultiStepInput) => pickLanguage(input, state); } async function pickLanguage(input: MultiStepInput, state: Partial) { From 4730105b3f0aed40e35bb84beb73cb1b1ac761d1 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 23 May 2024 15:18:35 +0300 Subject: [PATCH 078/150] add output directory selection for manifest generation --- vscode/microsoft-kiota/src/steps.ts | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 4a129bbcc9..85c6003b1c 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -101,6 +101,8 @@ export async function generateSteps(existingConfiguration: Partial) { const items = [l10n.t('Generate an API client'), l10n.t('Generate a plugin'), l10n.t('Generate an API manifest')]; const option = await input.showQuickPick({ @@ -152,9 +154,6 @@ export async function generateSteps(existingConfiguration: Partial inputOutputPath(input, state); } async function inputOutputPath(input: MultiStepInput, state: Partial) { - const folderSelectionOption = l10n.t('Browse your output directory'); - const inputOptions = [folderSelectionOption]; - const selectedOption = await input.showQuickPick({ title: `${l10n.t('Create a new API client')} - ${l10n.t('output directory')}`, step: step++, @@ -226,10 +225,7 @@ export async function generateSteps(existingConfiguration: Partial inputPluginOutputPath(input, state); } - async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { - const folderSelectionOption = l10n.t('Browse your output directory'); - const inputOptions = [folderSelectionOption]; - + async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { const selectedOption = await input.showQuickPick({ title: `${l10n.t('Create a new plugin')} - ${l10n.t('output directory')}`, step: step++, @@ -267,15 +263,26 @@ export async function generateSteps(existingConfiguration: Partial inputManifestOutputPath(input, state); } async function inputManifestOutputPath(input: MultiStepInput, state: Partial) { - state.outputPath = await input.showInputBox({ + const selectedOption = await input.showQuickPick({ title: `${l10n.t('Create a new manifest')} - ${l10n.t('output directory')}`, step: step++, totalSteps: 3, - value: typeof state.outputPath === 'string' ? state.outputPath : '', - placeholder: 'myproject/mymanifest', - prompt: l10n.t('Enter an output path relative to the root of the project'), + placeholder: l10n.t('Enter an output path relative to the root of the project'), + items: inputOptions.map(label => ({ label: label as string })), shouldResume: shouldResume - }); + }); + if (selectedOption?.label === folderSelectionOption) { + const folderUri = await input.showOpenDialog({ + canSelectMany: false, + openLabel: 'Select', + canSelectFolders: true, + canSelectFiles: false + }); + + if (folderUri && folderUri[0]) { + state.outputPath = folderUri[0].fsPath; + } + } state.outputPath === ''? state.outputPath = 'output' : state.outputPath; } await MultiStepInput.run(input => inputGenerationType(input, state), () => step-=2); From 8e0d4291fe38c04fa2c686d777e383a7dfa87851 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Fri, 24 May 2024 16:02:25 +0300 Subject: [PATCH 079/150] add polish translations --- .../microsoft-kiota/l10n/bundle.l10n.pl.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json index 01a11e96cf..828b872e19 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json @@ -38,37 +38,37 @@ "No content found in the clipboard": "Nie znaleziono zawartości w schowku", "Invalid content found in the clipboard": "Znaleziono nieprawidłową zawartość w schowku", "Select an API manifest key": "Wybierz klucz manifestu API", - "Edit Paths":"", - "Re-generate": "", - "Add an API description": "", + "Edit Paths":"Edytuj ścieżki", + "Re-generate": "Wygeneruj ponownie", + "Add an API description": "Dodaj opis API", "Search or paste a path to an API description": "Wyszukaj lub wklej ścieżkę do opisu API", "Generate a plugin": "Wygeneruj wtyczkę ", "Generate an API manifest": "Wygeneruj manifest API ", "What do you want to generate?": "Co chcesz wygenerować? ", - "Select an option": "", - "class": "", - "namespace": "", - "output directory": "", - "language": "", + "Select an option": "Wybierz opcję", + "class": "klasa", + "namespace": "przestrzeń nazw", + "output directory": "katalog wyjściowy", + "language": "język", "Create a new API client": "Utwórz nowego klienta API ", "Create a new plugin": "Utwórz nową wtyczkę", - "Create a new manifest": "", - "plugin name:": "", - "Choose a name for the plugin": "", - "Choose a plugin type": "", - "manifest name": "", - "Choose a name for the manifest": "", - "Required": "", - "Open installation instructions for kiota?": "", - "Invalid generation type": "", - "Yes, override it": "", - "Before adding a new API description, consider that your changes and current selection will be lost.": "", - "Cancel": "", + "Create a new manifest": "Utwórz nowy manifest", + "plugin name:": "nazwa wtyczki", + "Choose a name for the plugin": "Wybierz nazwę dla wtyczki", + "Choose a plugin type": "Wybierz typ wtyczki", + "manifest name": "nazwa manifestu", + "Choose a name for the manifest": "Wybierz nazwę dla manifestu", + "Required": "Wymagane", + "Open installation instructions for kiota?": "Otwórz instrukcje instalacji kiota?", + "Invalid generation type": "Nieprawidłowy typ generacji", + "Yes, override it": "Tak, nadpisz", + "Before adding a new API description, consider that your changes and current selection will be lost.": "Przed dodaniem nowego opisu API, rozważ, że Twoje zmiany i bieżący wybór zostaną utracone.", + "Cancel": "Anuluj", "Do you want to remove this API description?": "Czy chcesz usunąć ten opis API?", - "Please save the workspace.json file before re-generation.": "", - "OK": "", - "Generating manifest...": "", - "Generating plugin...": "", - "Re-generating client...": "", - "Re-generating plugin...": "" + "Please save the workspace.json file before re-generation.": "Proszę zapisz plik workspace.json przed ponowną generacją.", + "OK": "OK", + "Generating manifest...": "Generowanie manifestu...", + "Generating plugin...": "Generowanie wtyczki", + "Re-generating client...": "Ponowne generowanie klienta...", + "Re-generating plugin...": "Ponowne generowanie wtyczki..." } From b98b8c16770cb161255349ddaf1f43e28a3e32c6 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Fri, 24 May 2024 16:02:35 +0300 Subject: [PATCH 080/150] add russian translations --- .../microsoft-kiota/l10n/bundle.l10n.ru.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json index c3e06fd588..031b80012c 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json @@ -37,37 +37,37 @@ "No content found in the clipboard": "В буфере обмена нет содержимого", "Invalid content found in the clipboard": "В буфере обмена обнаружено недопустимое содержимое", "Select an API manifest key": "Выберите ключ манифеста API для редактирования", - "Edit Paths":"", - "Re-generate": "", - "Add an API description": "", + "Edit Paths":"Редактировать пути", + "Re-generate": "Перегенерировать", + "Add an API description": "Добавить описание API", "Search or paste a path to an API description": "", "Generate a plugin": "", "Generate an API manifest": "", "What do you want to generate?": "", - "Select an option": "", - "class": "", - "namespace": "", - "output directory": "", - "language": "", + "Select an option": "Выбрать вариант", + "class": "класс", + "namespace": "пространство имен", + "output directory": "директория для вывода", + "language": "язык", "Create a new API client": "", "Create a new plugin": "", - "Create a new manifest": "", - "plugin name:": "", - "Choose a name for the plugin": "", - "Choose a plugin type": "", - "manifest name": "", - "Choose a name for the manifest": "", - "Required": "", - "Open installation instructions for kiota?": "", - "Invalid generation type": "", - "Yes, override it": "", - "Before adding a new API description, consider that your changes and current selection will be lost.": "", - "Cancel": "", + "Create a new manifest": "Создать новый манифест", + "plugin name:": "имя плагина", + "Choose a name for the plugin": "Выберите имя для плагина", + "Choose a plugin type": "Выберите тип плагина", + "manifest name": "имя манифеста", + "Choose a name for the manifest": "Выберите имя для манифеста", + "Required": "Обязательно", + "Open installation instructions for kiota?": "Открыть инструкцию по установке Kiota?", + "Invalid generation type": "Неверный тип генерации", + "Yes, override it": "Да, перезаписать", + "Before adding a new API description, consider that your changes and current selection will be lost.": "Прежде чем добавить новое описание API, учтите, что ваши изменения и текущий выбор будут потеряны.", + "Cancel": "Отмена", "Do you want to remove this API description?": "", - "Please save the workspace.json file before re-generation.": "", - "OK": "", - "Generating manifest...": "", - "Generating plugin...": "", - "Re-generating client...": "", - "Re-generating plugin...": "" + "Please save the workspace.json file before re-generation.": "Пожалуйста, сохраните файл workspace.json перед перегенерацией.", + "OK": "OK", + "Generating manifest...": "Генерация манифеста...", + "Generating plugin...": "Генерация плагина...", + "Re-generating client...": "Перегенерация клиента...", + "Re-generating plugin...": "Перегенерация плагина..." } From 880a61bbd5b107462eec360c8a2bb3aeddbd4a5a Mon Sep 17 00:00:00 2001 From: ElinorW Date: Fri, 24 May 2024 16:02:45 +0300 Subject: [PATCH 081/150] add swahili translations --- .../microsoft-kiota/l10n/bundle.l10n.sw.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json index acd171d40c..1d1613baa8 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json @@ -38,37 +38,37 @@ "No content found in the clipboard": "Hakuna maudhui yaliyopatikana katika eneo la kunakili", "Invalid content found in the clipboard": "Maudhui batili yamepatikana katika eneo la kunakili", "Select an API manifest key": "Chagua funguo ya dhahiri ya API", - "Edit Paths":"", - "Re-generate": "", - "Add an API description": "", + "Edit Paths":"Hariri njia", + "Re-generate": "Tengeneza upya", + "Add an API description": "Ongeza maelezo ya API", "Search or paste a path to an API description": "Tafuta au bandika njia ya maelezo ya API", "Generate a plugin": "Tengeneza programu-jalizi", "Generate an API manifest": "Tengeneza dhahiri ya API", "What do you want to generate?": "Unataka kutengeneza nini?", - "Select an option": "", - "class": "", - "namespace": "", - "output directory": "", - "language": "", + "Select an option": "Chagua chaguo", + "class": "darasa", + "namespace": "nafasijina", + "output directory": "eneo ya pato", + "language": "lugha", "Create a new API client": "Tengeneza mteja mpya wa API", "Create a new plugin": "Tengeneza programu-jalizi mpya", - "Create a new manifest": "", - "plugin name:": "", - "Choose a name for the plugin": "", - "Choose a plugin type": "", - "manifest name": "", - "Choose a name for the manifest": "", - "Required": "", - "Open installation instructions for kiota?": "", - "Invalid generation type": "", - "Yes, override it": "", - "Before adding a new API description, consider that your changes and current selection will be lost.": "", - "Cancel": "", + "Create a new manifest": "Tengeneza dhariri mpya", + "plugin name:": "Jina ya programu-jalizi", + "Choose a name for the plugin": "Changua jina ya programu-jalizi", + "Choose a plugin type": "Chagua aina ya programu-jalizi", + "manifest name": "jina ya dhariri", + "Choose a name for the manifest": "Chagua jina ya dhariri ", + "Required": "Inahitajika", + "Open installation instructions for kiota?": "Je, ungetaka kufungua maagizo ya usakinishaji ya Kiota?", + "Invalid generation type": "Aina ya kutengeneza ni batili", + "Yes, override it": "Ndio, ipuuze", + "Before adding a new API description, consider that your changes and current selection will be lost.": "Kabla ya kuongeza maelezo mapya ya API, fikiria kuwa mabadiliko yako na uteuzi wa sasa utapotea.", + "Cancel": "Katisha", "Do you want to remove this API description?": "Ungetaka kuondoa maelezo haya ya API?", - "Please save the workspace.json file before re-generation.": "", - "OK": "", - "Generating manifest...": "", - "Generating plugin...": "", - "Re-generating client...": "", - "Re-generating plugin...": "" + "Please save the workspace.json file before re-generation.": "Tafadhali hifadhi faili ya workspace.json kabla ya kutengeneza upya.", + "OK": "Sawa", + "Generating manifest...": "Inatengeneza dhariri..", + "Generating plugin...": "Inatengeneza programu-jalizi...", + "Re-generating client...": "Inatengeneza mteja upya...", + "Re-generating plugin...": "Inatengeneza programu-jalizi upya ..." } From 337856e238a10ba885dce0f26f3b9a32aaaa32c7 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Fri, 24 May 2024 16:17:21 +0300 Subject: [PATCH 082/150] add success message and toggle icons --- vscode/microsoft-kiota/src/extension.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index a3719a7dd8..5065fabd56 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -302,6 +302,7 @@ export async function activate( }); if (result) { + await checkForSuccess(result); await exportLogsAndShowErrors(result); } } @@ -340,6 +341,7 @@ export async function activate( }); if (result) { + await checkForSuccess(result); await exportLogsAndShowErrors(result); } } @@ -405,6 +407,7 @@ export async function activate( } if (result) { + await checkForSuccess(result); await exportLogsAndShowErrors(result); } } @@ -655,6 +658,19 @@ function getQueryParameters(uri: vscode.Uri): Record { }); return parameters; } +async function checkForSuccess(results: KiotaLogEntry[]) { + for (const result of results) { + if (result && result.message) { + if (result.message.includes("Generation completed successfully")) { + void vscode.window.showInformationMessage('Generation completed successfully.'); + await vscode.commands.executeCommand('setContext', `${treeViewId}.showIcons`, false); + await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, true); + break; + } + } + } +} + // This method is called when your extension is deactivated export function deactivate() {} From fe57457cd859690952f33889798df0a0e20294bf Mon Sep 17 00:00:00 2001 From: ElinorW Date: Fri, 24 May 2024 16:55:04 +0300 Subject: [PATCH 083/150] add constants --- .../microsoft-kiota/src/codelensProvider.ts | 6 ++--- vscode/microsoft-kiota/src/constants.ts | 6 ++++- vscode/microsoft-kiota/src/extension.ts | 24 +++++++++---------- .../src/workspaceTreeProvider.ts | 6 ++--- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/vscode/microsoft-kiota/src/codelensProvider.ts b/vscode/microsoft-kiota/src/codelensProvider.ts index f392483199..274fc46805 100644 --- a/vscode/microsoft-kiota/src/codelensProvider.ts +++ b/vscode/microsoft-kiota/src/codelensProvider.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; import { l10n } from 'vscode'; -import { kiotaWorkspaceFile } from './constants'; +import { CLIENTS, KIOTA_WORKSPACE_FILE, PLUGINS } from './constants'; export class CodeLensProvider implements vscode.CodeLensProvider { public provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.ProviderResult { @@ -8,8 +8,8 @@ export class CodeLensProvider implements vscode.CodeLensProvider { const text = document.getText(); const jsonObject = JSON.parse(text); - if (document.fileName.endsWith(kiotaWorkspaceFile)) { - ['clients', 'plugins'].forEach(objectKey => { + if (document.fileName.endsWith(KIOTA_WORKSPACE_FILE)) { + [CLIENTS, PLUGINS].forEach(objectKey => { const object = jsonObject[objectKey]; if (object) { Object.keys(object).forEach(key => { diff --git a/vscode/microsoft-kiota/src/constants.ts b/vscode/microsoft-kiota/src/constants.ts index f4623f57b6..6b601563b9 100644 --- a/vscode/microsoft-kiota/src/constants.ts +++ b/vscode/microsoft-kiota/src/constants.ts @@ -4,4 +4,8 @@ export const statusBarCommandId = `${extensionId}.status`; export const treeViewId = `${extensionId}.openApiExplorer`; export const treeViewFocusCommand = `${treeViewId}${focusCommandId}`; export const dependenciesInfo = `${extensionId}.dependenciesInfo`; -export const kiotaWorkspaceFile = "workspace.json"; \ No newline at end of file +export const KIOTA_WORKSPACE_FILE = "workspace.json"; +export const KIOTA_DIRECTORY = '.kiota'; +export const CLIENTS = "clients"; +export const PLUGINS = "plugins"; + diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 5065fabd56..2034372e5a 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -25,12 +25,11 @@ import { generateClient } from "./generateClient"; import { getLanguageInformation, getLanguageInformationForDescription } from "./getLanguageInformation"; import { DependenciesViewProvider } from "./dependenciesViewProvider"; import { updateClients } from "./updateClients"; -import { ApiManifest } from "./apiManifest"; import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; import { KiotaWorkspace } from "./workspaceTreeProvider"; import { generatePlugin } from "./generatePlugin"; import { CodeLensProvider } from "./codelensProvider"; -import { dependenciesInfo, extensionId, kiotaWorkspaceFile, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; +import { CLIENTS, KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE, PLUGINS, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; @@ -241,16 +240,16 @@ export async function activate( ); return; } - if(workspaceGenerationType === "clients") { + if(workspaceGenerationType === CLIENTS) { await regenerateClient(clientOrPluginKey, clientOrPluginObject, settings, selectedPaths); } - else if (workspaceGenerationType === "plugins") { + else if (workspaceGenerationType === PLUGINS) { await regeneratePlugin(clientOrPluginKey, clientOrPluginObject, settings, selectedPaths); } }), registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { const settings = getExtensionSettings(extensionId); - const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(kiotaWorkspaceFile)); + const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(KIOTA_WORKSPACE_FILE)); if (workspaceJson && workspaceJson.isDirty) { await vscode.window.showInformationMessage( vscode.l10n.t("Please save the workspace.json file before re-generation."), @@ -258,10 +257,10 @@ export async function activate( ); return; } - if (generationType === "clients") { + if (generationType === CLIENTS) { await regenerateClient(clientKey, clientObject, settings); } - else if (generationType === "plugins") { + else if (generationType === PLUGINS) { await regeneratePlugin(clientKey, clientObject, settings); } }), @@ -403,8 +402,10 @@ export async function activate( if (typeof config.outputPath === "string" && !openApiTreeProvider.isLockFileLoaded && vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 && result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) { - await openApiTreeProvider.loadLockFile(path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, '.kiota', kiotaWorkspaceFile)); - } + const WORKSPACE_FOLDER = vscode.workspace.workspaceFolders[0].uri.fsPath; + const KIOTA_WORKSPACE_PATH = path.join(WORKSPACE_FOLDER, KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE); + await openApiTreeProvider.loadLockFile(KIOTA_WORKSPACE_PATH); + } if (result) { await checkForSuccess(result); @@ -502,7 +503,7 @@ export async function activate( ); return; } - const existingLockFileUris = await vscode.workspace.findFiles(`**/${kiotaWorkspaceFile}`); + const existingLockFileUris = await vscode.workspace.findFiles(`**/${KIOTA_WORKSPACE_FILE}`); if (existingLockFileUris.length > 0) { await Promise.all(existingLockFileUris.map(x => path.dirname(x.fsPath)).map(x => showUpgradeWarningMessage(x, context))); } @@ -563,7 +564,7 @@ function registerCommandWithTelemetry(reporter: TelemetryReporter, command: stri async function showUpgradeWarningMessage(clientPath: string, context: vscode.ExtensionContext): Promise { const kiotaVersion = context.extension.packageJSON.kiotaVersion.toLocaleLowerCase(); - const lockFilePath = path.join(clientPath, kiotaWorkspaceFile); + const lockFilePath = path.join(clientPath, KIOTA_WORKSPACE_FILE); if(!fs.existsSync(lockFilePath)) { return; } @@ -665,7 +666,6 @@ async function checkForSuccess(results: KiotaLogEntry[]) { void vscode.window.showInformationMessage('Generation completed successfully.'); await vscode.commands.executeCommand('setContext', `${treeViewId}.showIcons`, false); await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, true); - break; } } } diff --git a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts index ab92d1409a..236a3a0da4 100644 --- a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts +++ b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts @@ -1,9 +1,9 @@ import * as vscode from 'vscode'; import * as path from 'path'; import * as fs from 'fs'; -import { kiotaWorkspaceFile } from './constants'; +import { KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE } from './constants'; -const workspaceJsonPath = path.join(vscode.workspace.workspaceFolders?.map(folder => folder.uri.fsPath).join('') || '', '.kiota', kiotaWorkspaceFile); +const workspaceJsonPath = path.join(vscode.workspace.workspaceFolders?.map(folder => folder.uri.fsPath).join('') || '', KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE); export class WorkspaceTreeProvider implements vscode.TreeDataProvider { @@ -12,7 +12,7 @@ export class WorkspaceTreeProvider implements vscode.TreeDataProvider { if (!element) { - return [new vscode.TreeItem(kiotaWorkspaceFile, vscode.TreeItemCollapsibleState.None)]; + return [new vscode.TreeItem(KIOTA_WORKSPACE_FILE, vscode.TreeItemCollapsibleState.None)]; } return []; } From d14cdab26bdacebc7efdd9155ea975c81c2f5095 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Mon, 27 May 2024 16:05:10 +0300 Subject: [PATCH 084/150] localize string --- vscode/microsoft-kiota/src/workspaceTreeProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts index 236a3a0da4..ab590f4535 100644 --- a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts +++ b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts @@ -19,7 +19,7 @@ export class WorkspaceTreeProvider implements vscode.TreeDataProvider Date: Mon, 27 May 2024 16:05:51 +0300 Subject: [PATCH 085/150] add default and browse output options --- vscode/microsoft-kiota/src/steps.ts | 151 +++++++++++++++++----------- 1 file changed, 93 insertions(+), 58 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index e8a3095b93..37e4298ea9 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -1,5 +1,6 @@ import { QuickPickItem, window, Disposable, QuickInputButton, QuickInput, QuickInputButtons, workspace, l10n, Uri, OpenDialogOptions } from 'vscode'; import { allGenerationLanguages, generationLanguageToString, KiotaSearchResultItem, LanguagesInformation, maturityLevelToString } from './kiotaInterop'; +import * as vscode from 'vscode'; export async function filterSteps(existingFilter: string, filterCallback: (searchQuery: string) => void) { const state = {} as Partial; @@ -96,11 +97,17 @@ export async function generateSteps(existingConfiguration: Partial) { const items = [l10n.t('Generate an API client'), l10n.t('Generate a plugin'), l10n.t('Generate an API manifest')]; const option = await input.showQuickPick({ @@ -152,28 +159,37 @@ export async function generateSteps(existingConfiguration: Partial inputOutputPath(input, state); } async function inputOutputPath(input: MultiStepInput, state: Partial) { - const selectedOption = await input.showQuickPick({ - title: `${l10n.t('Create a new API client')} - ${l10n.t('output directory')}`, - step: step++, - totalSteps: totalSteps, - placeholder: l10n.t('Enter an output path relative to the root of the project'), - items: inputOptions.map(label => ({ label: label as string })), - shouldResume: shouldResume - }); - if (selectedOption?.label === folderSelectionOption) { - const folderUri = await input.showOpenDialog({ - canSelectMany: false, - openLabel: 'Select', - canSelectFolders: true, - canSelectFiles: false + while(true) { + const selectedOption = await input.showQuickPick({ + title: `${l10n.t('Create a new API client')} - ${l10n.t('output directory')}`, + step: 4, + totalSteps: totalSteps, + placeholder: l10n.t('Enter an output path relative to the root of the project'), + items: inputOptions, + shouldResume: shouldResume }); - - if (folderUri && folderUri[0]) { - state.outputPath = folderUri[0].fsPath; + if(selectedOption){ + if (selectedOption?.label === folderSelectionOption) { + const folderUri = await input.showOpenDialog({ + canSelectMany: false, + openLabel: 'Select', + canSelectFolders: true, + canSelectFiles: false + }); + + if (folderUri && folderUri[0]) { + state.outputPath = folderUri[0].fsPath; + } else{ + continue; + } + } else { + state.outputPath = selectedOption.description; } - } - state.outputPath = state.outputPath === '' ? 'output' : state.outputPath; - return (input: MultiStepInput) => pickLanguage(input, state); + } + state.outputPath = state.outputPath === '' ? 'output' : state.outputPath; + return (input: MultiStepInput) => pickLanguage(input, state); + } + } async function pickLanguage(input: MultiStepInput, state: Partial) { const items = allGenerationLanguages.map(x => { @@ -223,28 +239,37 @@ export async function generateSteps(existingConfiguration: Partial inputPluginOutputPath(input, state); } - async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { + async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { + while (true) { const selectedOption = await input.showQuickPick({ title: `${l10n.t('Create a new plugin')} - ${l10n.t('output directory')}`, - step: step++, + step: 3, totalSteps: 3, - placeholder: l10n.t('Enter an output path relative to the root of the project'), - items: inputOptions.map(label => ({ label: label as string })), + placeholder: l10n.t('Enter an output path relative to the root of the project'), + items: inputOptions, shouldResume: shouldResume }); - if (selectedOption?.label === folderSelectionOption) { - const folderUri = await input.showOpenDialog({ - canSelectMany: false, - openLabel: 'Select', - canSelectFolders: true, - canSelectFiles: false - }); - - if (folderUri && folderUri[0]) { - state.outputPath = folderUri[0].fsPath; - } + if(selectedOption){ + if (selectedOption?.label === folderSelectionOption) { + const folderUri = await input.showOpenDialog({ + canSelectMany: false, + openLabel: 'Select', + canSelectFolders: true, + canSelectFiles: false + }); + + if (folderUri && folderUri[0]) { + state.outputPath = folderUri[0].fsPath; + } else{ + continue; + } + } else { + state.outputPath = selectedOption.description; + } } - state.outputPath = state.outputPath === '' ? 'output' : state.outputPath; + state.outputPath = state.outputPath === '' ? 'output' : state.outputPath; + break; + } } async function inputManifestName(input:MultiStepInput, state: Partial) { @@ -261,27 +286,37 @@ export async function generateSteps(existingConfiguration: Partial inputManifestOutputPath(input, state); } async function inputManifestOutputPath(input: MultiStepInput, state: Partial) { - const selectedOption = await input.showQuickPick({ - title: `${l10n.t('Create a new manifest')} - ${l10n.t('output directory')}`, - step: step++, - totalSteps: 3, - placeholder: l10n.t('Enter an output path relative to the root of the project'), - items: inputOptions.map(label => ({ label: label as string })), - shouldResume: shouldResume - }); - if (selectedOption?.label === folderSelectionOption) { - const folderUri = await input.showOpenDialog({ - canSelectMany: false, - openLabel: 'Select', - canSelectFolders: true, - canSelectFiles: false + while (true) { + const selectedOption = await input.showQuickPick({ + title: `${l10n.t('Create a new manifest')} - ${l10n.t('output directory')}`, + step: 2, + totalSteps: 3, + placeholder: l10n.t('Enter an output path relative to the root of the project'), + items: inputOptions, + shouldResume: shouldResume }); - - if (folderUri && folderUri[0]) { - state.outputPath = folderUri[0].fsPath; - } - } - state.outputPath === ''? state.outputPath = 'output' : state.outputPath; + if(selectedOption) { + if (selectedOption?.label === folderSelectionOption) { + const folderUri = await input.showOpenDialog({ + canSelectMany: false, + openLabel: 'Select', + canSelectFolders: true, + canSelectFiles: false + }); + + if (folderUri && folderUri[0]) { + state.outputPath = folderUri[0].fsPath; + } else { + continue; + } + } else{ + state.outputPath = selectedOption.description; + } + } + state.outputPath === ''? state.outputPath = 'output' : state.outputPath; + break; + } + } await MultiStepInput.run(input => inputGenerationType(input, state), () => step-=2); return state; From 972b8e31035fca5e2c756d60c4ad40860655e5ef Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 29 May 2024 16:26:02 +0300 Subject: [PATCH 086/150] add dropdown for api path selection --- vscode/microsoft-kiota/src/steps.ts | 58 ++++++++++++++++++----------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 37e4298ea9..f95bba3de1 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -32,37 +32,49 @@ export async function searchSteps(searchCallBack: (searchQuery: string) => Thena let step = 1; let totalSteps = 2; async function inputPathOrSearch(input: MultiStepInput, state: Partial) { + const selectedOption = await input.showQuickPick({ + title, + step: step++, + totalSteps: totalSteps, + placeholder: l10n.t('Search or paste a path to an API description'), + items: [{label: l10n.t('Search')}, {label: l10n.t('Browse path')}], + validate: validateIsNotEmpty, + shouldResume: shouldResume + }); + if(selectedOption?.label === l10n.t('Search')) { + return (input: MultiStepInput) => inputSearch(input, state); + } + else if(selectedOption?.label === l10n.t('Browse path')) { + const fileUri = await input.showOpenDialog({ + canSelectMany: false, + openLabel: 'Select', + canSelectFolders: false, + canSelectFiles: true + }); + + if (fileUri && fileUri[0]) { + state.descriptionPath = fileUri[0].fsPath; + } else{ + return; + } + } + } + + async function inputSearch(input: MultiStepInput, state: Partial) { state.searchQuery = await input.showInputBox({ title, step: step++, totalSteps: totalSteps, value: state.searchQuery ?? '', - prompt: l10n.t('Search or paste a path to an API description'), + prompt: l10n.t('Search a path to an API description'), validate: validateIsNotEmpty, shouldResume: shouldResume }); - state.searchResults = await searchCallBack(state.searchQuery); if(state.searchResults && Object.keys(state.searchResults).length > 0) { return (input: MultiStepInput) => pickSearchResult(input, state); } - state.descriptionPath = state.searchQuery; - return (input: MultiStepInput) => inputPathOrUrl(input, state); - } - - async function inputPathOrUrl(input: MultiStepInput, state: Partial) { - if (state.descriptionPath) { - return; - } - state.descriptionPath = await input.showInputBox({ - title, - step: step++, - totalSteps: 1, - value: state.descriptionPath || '', - prompt: l10n.t('Search or paste a path to an API description'), - validate: validateIsNotEmpty, - shouldResume: shouldResume - }); + } async function pickSearchResult(input: MultiStepInput, state: Partial) { const items: QuickSearchPickItem[] = []; @@ -270,7 +282,7 @@ export async function generateSteps(existingConfiguration: Partial) { state.pluginName = await input.showInputBox({ @@ -422,10 +434,11 @@ interface InputBoxParameters { openLabel: string; canSelectFolders: boolean; canSelectFiles: boolean; + filters?: { [name: string]: string[] }; } class MultiStepInput { - async showOpenDialog({ canSelectMany, openLabel, canSelectFolders, canSelectFiles} : OpenDialogParameters): Promise { + async showOpenDialog({ canSelectMany, openLabel, canSelectFolders, canSelectFiles, filters} : OpenDialogParameters): Promise { const disposables: Disposable[] = []; try { @@ -434,7 +447,8 @@ class MultiStepInput { canSelectMany, openLabel, canSelectFolders, - canSelectFiles + canSelectFiles, + filters }; void window.showOpenDialog(input).then(folderUris => { From 94f713e4bb49747fc6a6cb3e40843df61a4c4f3a Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 29 May 2024 18:27:01 +0300 Subject: [PATCH 087/150] remove unused filter property --- vscode/microsoft-kiota/src/steps.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index f95bba3de1..e0f2c1fd50 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -434,11 +434,10 @@ interface InputBoxParameters { openLabel: string; canSelectFolders: boolean; canSelectFiles: boolean; - filters?: { [name: string]: string[] }; } class MultiStepInput { - async showOpenDialog({ canSelectMany, openLabel, canSelectFolders, canSelectFiles, filters} : OpenDialogParameters): Promise { + async showOpenDialog({ canSelectMany, openLabel, canSelectFolders, canSelectFiles} : OpenDialogParameters): Promise { const disposables: Disposable[] = []; try { @@ -447,8 +446,7 @@ class MultiStepInput { canSelectMany, openLabel, canSelectFolders, - canSelectFiles, - filters + canSelectFiles }; void window.showOpenDialog(input).then(folderUris => { From d86275bd974b988a46479351ba43382ead9a6780 Mon Sep 17 00:00:00 2001 From: Elinor Date: Thu, 30 May 2024 12:47:38 +0300 Subject: [PATCH 088/150] remove else Co-authored-by: silaskenneth --- vscode/microsoft-kiota/src/steps.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index e0f2c1fd50..b9a7389b85 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -54,8 +54,6 @@ export async function searchSteps(searchCallBack: (searchQuery: string) => Thena if (fileUri && fileUri[0]) { state.descriptionPath = fileUri[0].fsPath; - } else{ - return; } } } From d3a2b119d7aa1e3941e7fb2cc3cfcf90014ea325 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 30 May 2024 15:45:23 +0300 Subject: [PATCH 089/150] update icon --- vscode/microsoft-kiota/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 127b4c5d1d..76cd86b8ac 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -396,7 +396,7 @@ "command": "kiota.openApiExplorer.searchOrOpenApiDescription", "category": "Kiota", "title": "%kiota.openApiExplorer.openDescription.title%", - "icon": "$(add)" + "icon": "$(new-file)" }, { "command": "kiota.workspace.openWorkspaceFile", From 6258833b11acfce79c4bc4d57b6cb28663846187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Levert?= Date: Mon, 3 Jun 2024 15:16:13 -0400 Subject: [PATCH 090/150] Fixing vscode sideloading script for Windows --- scripts/execute-vscode-sideload.ps1 | 4 ++-- vscode/microsoft-kiota/debugging.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/execute-vscode-sideload.ps1 b/scripts/execute-vscode-sideload.ps1 index d727f7626f..7352e36676 100644 --- a/scripts/execute-vscode-sideload.ps1 +++ b/scripts/execute-vscode-sideload.ps1 @@ -21,11 +21,11 @@ $PackageJson = Get-Content "package.json" -Raw | ConvertFrom-Json # Install the extension code --install-extension "./kiota-$($PackageJson.version).vsix" -$VsCodeRootPath = "~/.vscode" +$VsCodeRootPath = (Resolve-Path "~/.vscode").Path if ($WSL) { $Platform = "linux-x64" - $VsCodeRootPath = "~/.vscode-server" + $VsCodeRootPath = (Resolve-Path "~/.vscode-server").Path } $KiotaBin = "$VsCodeRootPath/extensions/ms-graph.kiota-$($PackageJson.version)/.kiotabin/$($PackageJson.kiotaVersion)/$Platform" diff --git a/vscode/microsoft-kiota/debugging.md b/vscode/microsoft-kiota/debugging.md index bd3cfc59d9..a4e6564fc7 100644 --- a/vscode/microsoft-kiota/debugging.md +++ b/vscode/microsoft-kiota/debugging.md @@ -17,7 +17,7 @@ Context: you're most likely a program manager eager to demo the latest bits from - GitHub CLI `winget install GitHub.CLI` - dotnet 8 `winget install Microsoft.DotNet.SDK.8` - node 20 `winget install CoreyButler.NVMforWindows && nvm install lts && nvm use lts` -- vsce & TypeScript `npm i -g TypeScript @vscode/vsce` +- vsce & TypeScript `npm i -g typescript @vscode/vsce` ### Steps From 2c32919a5c4b9709e3e25e4bab17424b2fc041e8 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Tue, 4 Jun 2024 15:46:21 +0300 Subject: [PATCH 091/150] enable generation from a deeplink --- vscode/microsoft-kiota/src/extension.ts | 2 -- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 2034372e5a..00e5531db3 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -199,8 +199,6 @@ export async function activate( })); if (config.descriptionPath) { await openTreeViewWithProgress(() => openApiTreeProvider.setDescriptionUrl(config.descriptionPath!)); - await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, true); - await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, false); } } ), diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index d57a1be2e1..bd26850ddf 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -233,6 +233,8 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider Date: Wed, 5 Jun 2024 11:55:26 +0300 Subject: [PATCH 092/150] Updates plugin naming --- vscode/microsoft-kiota/src/extension.ts | 4 ++-- vscode/microsoft-kiota/src/kiotaInterop.ts | 6 +++--- vscode/microsoft-kiota/src/steps.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 00e5531db3..05f3069d17 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -304,7 +304,7 @@ export async function activate( } } async function generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { - const pluginTypes = typeof config.pluginTypes === 'string' ? parsePluginType(config.pluginTypes) : KiotaPluginType.Microsoft; + const pluginTypes = typeof config.pluginTypes === 'string' ? parsePluginType(config.pluginTypes) : KiotaPluginType.ApiPlugin; const result = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, @@ -446,7 +446,7 @@ export async function activate( void vscode.window.showInformationMessage(`Client ${clientKey} re-generated successfully.`); } async function regeneratePlugin(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]) { - const pluginTypes = typeof clientObject.pluginTypes === 'string' ? parsePluginType(clientObject.pluginTypes) : KiotaPluginType.Microsoft; + const pluginTypes = typeof clientObject.pluginTypes === 'string' ? parsePluginType(clientObject.pluginTypes) : KiotaPluginType.ApiPlugin; await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, diff --git a/vscode/microsoft-kiota/src/kiotaInterop.ts b/vscode/microsoft-kiota/src/kiotaInterop.ts index d48b828d55..974544ebfd 100644 --- a/vscode/microsoft-kiota/src/kiotaInterop.ts +++ b/vscode/microsoft-kiota/src/kiotaInterop.ts @@ -111,7 +111,7 @@ export enum KiotaPluginType { // eslint-disable-next-line @typescript-eslint/naming-convention ApiManifest = 1, // eslint-disable-next-line @typescript-eslint/naming-convention - Microsoft = 2, + ApiPlugin = 2, } export enum ConsumerOperation { @@ -130,8 +130,8 @@ export function parsePluginType(value: string): KiotaPluginType { return KiotaPluginType.OpenAI; case "ApiManifest": return KiotaPluginType.ApiManifest; - case "Microsoft": - return KiotaPluginType.Microsoft; + case "ApiPlugin": + return KiotaPluginType.ApiPlugin; default: throw new Error("unknown plugin type"); } diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index b9a7389b85..4a652552c3 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -236,7 +236,7 @@ export async function generateSteps(existingConfiguration: Partial inputPluginType(input, state); } async function inputPluginType(input: MultiStepInput, state: Partial) { - const items = ['Microsoft','Open AI'].map(x => ({ label: x})as QuickPickItem); + const items = ['ApiPlugin','Open AI'].map(x => ({ label: x})as QuickPickItem); const pluginTypes = await input.showQuickPick({ title: l10n.t('Choose a plugin type'), step: step++, @@ -246,7 +246,7 @@ export async function generateSteps(existingConfiguration: Partial inputPluginOutputPath(input, state); } async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { From def06cf75dfff902b0056b44124bc5a54962d318 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Mon, 10 Jun 2024 15:57:31 +0300 Subject: [PATCH 093/150] update vscode engine --- vscode/microsoft-kiota/package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/package-lock.json b/vscode/microsoft-kiota/package-lock.json index b1a9ce9ab2..fde0a4b6be 100644 --- a/vscode/microsoft-kiota/package-lock.json +++ b/vscode/microsoft-kiota/package-lock.json @@ -32,7 +32,7 @@ "webpack-cli": "^5.1.4" }, "engines": { - "vscode": "^1.89.0" + "vscode": "^1.90.0" } }, "node_modules/@aashutoshrathi/word-wrap": { From c0ad7980314e8c813943862ef7ab7a47aa50ee47 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 12 Jun 2024 18:43:57 +0300 Subject: [PATCH 094/150] bump kiota extension version --- vscode/microsoft-kiota/package-lock.json | 4 ++-- vscode/microsoft-kiota/package.json | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/vscode/microsoft-kiota/package-lock.json b/vscode/microsoft-kiota/package-lock.json index 338da26847..383506f490 100644 --- a/vscode/microsoft-kiota/package-lock.json +++ b/vscode/microsoft-kiota/package-lock.json @@ -1,12 +1,12 @@ { "name": "kiota", - "version": "1.14.100000001", + "version": "1.15.100000001", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kiota", - "version": "1.14.100000001", + "version": "1.15.100000001", "dependencies": { "@vscode/extension-telemetry": "^0.9.6", "@vscode/l10n": "^0.0.18", diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 4c00c925d6..07df58710c 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -3,8 +3,8 @@ "displayName": "Microsoft Kiota", "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.14.100000001", - "kiotaVersion": "1.14.0", + "version": "1.15.100000001", + "kiotaVersion": "1.15.0", "telemetryInstrumentationKey": "4c6357e0-daf9-42b5-bdfb-67878f8957b5", "icon": "images/logo.png", "engines": { @@ -465,23 +465,23 @@ "runtimeDependencies": [ { "platformId": "win-x64", - "sha256": "7AB8DA15620971C53BF14F67F957F19D3E7C2F53C66631E7E01D1BF639D1FBF6" + "sha256": "A34EF636542E6AAF32FDA9D730534A9410B2E2D1F15DC8344C45D8CC694EE037" }, { "platformId": "win-x86", - "sha256": "92918467EEBEB489A5F61AD41D3A31BE6EB6B05E2C016B0AAC2CAEA3A44FE99E" + "sha256": "314106D1E6D446BF259F47FF3D112CD099E77B9E87CD5AD1EC8007106A281C8F" }, { "platformId": "linux-x64", - "sha256": "388592EC1496BD1EA83A467238FCC751C0C7551ED903D23843420D2D8FB42669" + "sha256": "C56146FBBF0381B3419098B64EEB1BAA06473C4A085B3D18659B9CFB64E34B65" }, { "platformId": "osx-x64", - "sha256": "54165FAC96060FA89B007C66A1005A8B3FB014E24F089243C8D9058B9398327B" + "sha256": "53BDDE6E0042E16392C9B123B0DDDBED1935C5831D6837D6B673942B012FFD73" }, { "platformId": "osx-arm64", - "sha256": "5666D266ED3A087F7AB18F065CE824FE9FB5362A49FF83B363D499A5EDC81EB5" + "sha256": "31215E1EE60A1E558FC5A190268E4D3016BFD5908445C45E90E63F22F91C54E8" } ] } From 4c97bf4a3250c71daf3b03c3318f83aec5ffda84 Mon Sep 17 00:00:00 2001 From: Elinor Date: Thu, 13 Jun 2024 16:05:31 +0300 Subject: [PATCH 095/150] Task: Display client/plugin name on API explorer (#4801) --- vscode/microsoft-kiota/package.json | 8 +- vscode/microsoft-kiota/src/extension.ts | 19 +- vscode/microsoft-kiota/src/kiotaInterop.ts | 26 +-- .../src/openApiTreeProvider.ts | 211 +++++++++++++----- 4 files changed, 185 insertions(+), 79 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 07df58710c..d5c8c0a356 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -271,22 +271,22 @@ }, { "command": "kiota.openApiExplorer.addToSelectedEndpoints", - "when": "view == kiota.openApiExplorer && viewItem != apiTitle", + "when": "view == kiota.openApiExplorer && viewItem != apiTitle && viewItem != clientNameOrPluginName", "group": "inline@2" }, { "command": "kiota.openApiExplorer.addAllToSelectedEndpoints", - "when": "view == kiota.openApiExplorer", + "when": "view == kiota.openApiExplorer && viewItem != clientNameOrPluginName", "group": "inline@4" }, { "command": "kiota.openApiExplorer.removeFromSelectedEndpoints", - "when": "view == kiota.openApiExplorer && viewItem != apiTitle", + "when": "view == kiota.openApiExplorer && viewItem != apiTitle && viewItem != clientNameOrPluginName", "group": "inline@3" }, { "command": "kiota.openApiExplorer.removeAllFromSelectedEndpoints", - "when": "view == kiota.openApiExplorer", + "when": "view == kiota.openApiExplorer && viewItem != clientNameOrPluginName", "group": "inline@5" } ], diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 05f3069d17..66b36ff9b0 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -45,6 +45,7 @@ export async function activate( kiotaOutputChannel = vscode.window.createOutputChannel("Kiota", { log: true, }); + const workspaceJsonPath = path.join(vscode.workspace.workspaceFolders?.map(folder => folder.uri.fsPath).join('') || '', KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE); const openApiTreeProvider = new OpenApiTreeProvider(context, () => getExtensionSettings(extensionId)); const dependenciesInfoProvider = new DependenciesViewProvider( context.extensionUri @@ -225,7 +226,7 @@ export async function activate( clientOrPluginKey = clientKey; clientOrPluginObject = clientObject; workspaceGenerationType = generationType; - await loadEditPaths(clientObject, openApiTreeProvider); + await loadEditPaths(clientOrPluginKey, clientObject, openApiTreeProvider); await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, false); await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, true); }), @@ -300,6 +301,8 @@ export async function activate( if (result) { await checkForSuccess(result); + openApiTreeProvider.refreshView(); + await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.pluginName); await exportLogsAndShowErrors(result); } } @@ -339,6 +342,8 @@ export async function activate( if (result) { await checkForSuccess(result); + openApiTreeProvider.refreshView(); + await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.pluginName); await exportLogsAndShowErrors(result); } } @@ -402,11 +407,13 @@ export async function activate( result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) { const WORKSPACE_FOLDER = vscode.workspace.workspaceFolders[0].uri.fsPath; const KIOTA_WORKSPACE_PATH = path.join(WORKSPACE_FOLDER, KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE); - await openApiTreeProvider.loadLockFile(KIOTA_WORKSPACE_PATH); + await openApiTreeProvider.loadLockFile(KIOTA_WORKSPACE_PATH, config.clientClassName); } if (result) { await checkForSuccess(result); + openApiTreeProvider.refreshView(); + await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.clientClassName); await exportLogsAndShowErrors(result); } } @@ -574,13 +581,13 @@ async function showUpgradeWarningMessage(clientPath: string, context: vscode.Ext } } -async function loadLockFile(node: { fsPath: string }, openApiTreeProvider: OpenApiTreeProvider): Promise { - await openTreeViewWithProgress(() => openApiTreeProvider.loadLockFile(node.fsPath)); +async function loadLockFile(node: { fsPath: string }, openApiTreeProvider: OpenApiTreeProvider, clientOrPluginName?: string): Promise { + await openTreeViewWithProgress(() => openApiTreeProvider.loadLockFile(node.fsPath, clientOrPluginName)); await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, true); } -async function loadEditPaths(clientObject: any, openApiTreeProvider: OpenApiTreeProvider): Promise { - await openTreeViewWithProgress(() => openApiTreeProvider.loadEditPaths(clientObject)); +async function loadEditPaths(clientOrPluginKey: string, clientObject: any, openApiTreeProvider: OpenApiTreeProvider): Promise { + await openTreeViewWithProgress(() => openApiTreeProvider.loadEditPaths(clientOrPluginKey, clientObject)); } async function exportLogsAndShowErrors(result: KiotaLogEntry[]) : Promise { diff --git a/vscode/microsoft-kiota/src/kiotaInterop.ts b/vscode/microsoft-kiota/src/kiotaInterop.ts index 974544ebfd..01a862cd72 100644 --- a/vscode/microsoft-kiota/src/kiotaInterop.ts +++ b/vscode/microsoft-kiota/src/kiotaInterop.ts @@ -41,6 +41,7 @@ export interface KiotaOpenApiNode { selected?: boolean, isOperation?: boolean; documentationUrl?: string; + clientNameOrPluginName?: string; } interface CacheClearableConfiguration { clearCache: boolean; @@ -253,23 +254,10 @@ export function maturityLevelToString(level: MaturityLevel): string { throw new Error("unknown level"); } } -export interface LockFile { - clientClassName: string; - clientNamespaceName: string; - descriptionHash: string; - descriptionLocation: string; - deserializers: string[]; - disabledValidationRules: string[]; - excludeBackwardCompatible: boolean; - excludePatterns: string[]; - includeAdditionalData: boolean; - includePatterns: string[]; - kiotaVersion: string; - language: string; - lockFileVersion: string; - serializers: string[]; - structuredMimeTypes: string[]; - usesBackingStore: boolean; +export interface ConfigurationFile { + version: string; + clients: Record; + plugins: Record; } export interface GenerationConfiguration { @@ -300,7 +288,7 @@ interface WorkspaceObjectProperties { outputPath: string; } -interface ClientObjectProperties extends WorkspaceObjectProperties { +export interface ClientObjectProperties extends WorkspaceObjectProperties { language: string; structuredMimeTypes: string[]; clientNamespaceName: string; @@ -310,7 +298,7 @@ interface ClientObjectProperties extends WorkspaceObjectProperties { disabledValidationRules: string[]; } -interface PluginObjectProperties extends WorkspaceObjectProperties { +export interface PluginObjectProperties extends WorkspaceObjectProperties { types: string[]; } diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index bd26850ddf..2d34ad150e 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -3,7 +3,18 @@ import * as os from 'os'; import * as path from 'path'; import * as vscode from 'vscode'; import * as rpc from 'vscode-jsonrpc/node'; -import { connectToKiota, KiotaGetManifestDetailsConfiguration, KiotaLogEntry, KiotaManifestResult, KiotaOpenApiNode, KiotaShowConfiguration, KiotaShowResult, LockFile } from './kiotaInterop'; +import { + ClientObjectProperties, + ClientOrPluginProperties, + connectToKiota, + KiotaGetManifestDetailsConfiguration, + KiotaLogEntry, + KiotaManifestResult, + KiotaOpenApiNode, + KiotaShowConfiguration, + KiotaShowResult, + ConfigurationFile, + PluginObjectProperties } from './kiotaInterop'; import { ExtensionSettings } from './extensionSettings'; import { treeViewId } from './constants'; @@ -13,47 +24,83 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider ExtensionSettings, + private readonly settingsGetter: () => ExtensionSettings, private _descriptionUrl?: string, public includeFilters: string[] = [], public excludeFilters: string[] = []) { - + } private _lockFilePath?: string; - private _lockFile?: LockFile; + private _lockFile?: ConfigurationFile | Partial = {}; public get isLockFileLoaded(): boolean { return !!this._lockFile; } - public async loadLockFile(path: string): Promise { - this.closeDescription(false); - this._lockFilePath = path; - const lockFileData = await vscode.workspace.fs.readFile(vscode.Uri.file(path)); - this._lockFile = JSON.parse(lockFileData.toString()) as LockFile; - if (this._lockFile?.descriptionLocation) { - this._descriptionUrl = this._lockFile.descriptionLocation; - this.includeFilters = this._lockFile.includePatterns; - this.excludeFilters = this._lockFile.excludePatterns; - const settings = this.settingsGetter(); - await this.loadNodes(settings.clearCache); - if (this.rawRootNode) { - this.refreshView(); + public async loadLockFile(path: string, clientOrPluginName?: string): Promise { + this.closeDescription(false); + this._lockFilePath = path; + const lockFileData = await vscode.workspace.fs.readFile(vscode.Uri.file(path)); + let parsedLockFile = JSON.parse(lockFileData.toString()) as ConfigurationFile; + + if (clientOrPluginName) { + let filteredData: Partial = { version: parsedLockFile.version }; + + if (parsedLockFile.clients && parsedLockFile.clients[clientOrPluginName]) { + filteredData.clients = { + [clientOrPluginName]: parsedLockFile.clients[clientOrPluginName] + }; + } + + if (parsedLockFile.plugins && parsedLockFile.plugins[clientOrPluginName]) { + filteredData.plugins = { + [clientOrPluginName]: parsedLockFile.plugins[clientOrPluginName] + }; + } + + parsedLockFile = filteredData as ConfigurationFile; + } + + this._lockFile = parsedLockFile; + + const clientOrPlugin: ClientOrPluginProperties | undefined = + Object.values(this._lockFile.clients ?? {})[0] || + Object.values(this._lockFile.plugins ?? {})[0]; + + if (clientOrPlugin) { + this._descriptionUrl = clientOrPlugin.descriptionLocation; + this.includeFilters = clientOrPlugin.includePatterns; + this.excludeFilters = clientOrPlugin.excludePatterns; + + const settings = this.settingsGetter(); + await this.loadNodes(settings.clearCache, clientOrPluginName); + + if (this.rawRootNode) { + this.refreshView(); + } } - } } - public async loadEditPaths(clientObject: any): Promise { + public async loadEditPaths(clientOrPluginKey: string, clientObject: ClientOrPluginProperties): Promise { this.closeDescription(false); - this._lockFile = clientObject; - if (this._lockFile?.descriptionLocation) { - this._descriptionUrl = this._lockFile.descriptionLocation; - this.includeFilters = this._lockFile.includePatterns; - this.excludeFilters = this._lockFile.excludePatterns; - const settings = this.settingsGetter(); - await this.loadNodes(settings.clearCache); - if (this.rawRootNode) { - this.refreshView(); - } + const newLockFile: ConfigurationFile = { version: '1.0.0', clients: {}, plugins: {} }; + + if ((clientObject as ClientObjectProperties).clientNamespaceName) { + newLockFile.clients[clientOrPluginKey] = clientObject as ClientObjectProperties; + } else { + newLockFile.plugins[clientOrPluginKey] = clientObject as PluginObjectProperties; + } + this._lockFile = newLockFile; + if (clientObject.descriptionLocation) { + this._descriptionUrl = clientObject.descriptionLocation; + this.includeFilters = clientObject.includePatterns; + this.excludeFilters = clientObject.excludePatterns; + + const settings = this.settingsGetter(); + await this.loadNodes(settings.clearCache, clientOrPluginKey); + + if (this.rawRootNode) { + this.refreshView(); + } } - } + } public async loadManifestFromUri(path: string, apiIdentifier?: string): Promise { this.closeDescription(false); const logs = await this.loadNodesFromManifest(path, apiIdentifier); @@ -73,17 +120,34 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider this.setAllSelected(x, selected)); } + private getFirstClient(): ClientObjectProperties | undefined { + return this._lockFile?.clients ? Object.values(this._lockFile.clients)[0] : undefined; + } public get outputPath(): string { - return this._lockFilePath ? path.parse(this._lockFilePath).dir : ''; + return this._lockFilePath ? path.parse(this._lockFilePath).dir : ''; } public get clientClassName(): string { - return this._lockFile?.clientClassName ?? ''; + if (this._lockFile?.clients) { + const client = this.getFirstClient(); + return client ? client.clientNamespaceName : ''; + } + return ''; } + public get clientNamespaceName(): string { - return this._lockFile?.clientNamespaceName ?? ''; + if (this._lockFile?.clients) { + const client = this.getFirstClient(); + return client ? client.clientNamespaceName : ''; + } + return ''; } + public get language(): string { - return this._lockFile?.language ?? ''; + if (this._lockFile?.clients) { + const client = this.getFirstClient(); + return client ? client.language : ''; + } + return ''; } public closeDescription(shouldRefresh = true) { this._descriptionUrl = ''; @@ -92,10 +156,12 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider this.selectInternal(x, selected, recursive)); } else if (!isOperationNode) { apiNode.children.filter(x => x.isOperation ?? false).forEach(x => this.selectInternal(x, selected, false)); @@ -140,7 +206,15 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider x.segment === segment); + let child: KiotaOpenApiNode | undefined; + if (currentNode.clientNameOrPluginName) { + const rootChild = currentNode.children.find(x => x.segment === '/'); + if (rootChild) { + child = rootChild.children.find(x => x.segment === segment); + } + } else { + child = currentNode.children.find(x => x.segment === segment); + } if (child) { return this.findApiNode(segments, child); } else if (segment.startsWith('{') && segment.endsWith('}')) { @@ -168,7 +242,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider { + private async loadNodes(clearCache: boolean, clientNameOrPluginName?: string): Promise { if (!this.descriptionUrl || this.descriptionUrl.length === 0) { return; } @@ -226,24 +300,35 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider this.getTreeNodeFromKiotaNode(x)), node.documentationUrl, + node.clientNameOrPluginName ); } getChildren(element?: OpenApiTreeNode): vscode.ProviderResult { @@ -279,6 +365,26 @@ function getPathSegments(path: string): string[] { function trimOperation(path: string): string { return path.split(operationSeparator)[0]; } + +function createKiotaOpenApiNode( + segment: string, + path: string, + children: KiotaOpenApiNode[] = [], + selected?: boolean, + isOperation?: boolean, + documentationUrl?: string, + clientNameOrPluginName?: string +): KiotaOpenApiNode { + return { + segment, + path, + children, + selected, + isOperation, + documentationUrl, + clientNameOrPluginName + }; +} type IconSet = string | vscode.Uri | { light: string | vscode.Uri; dark: string | vscode.Uri } | vscode.ThemeIcon; export class OpenApiTreeNode extends vscode.TreeItem { private static readonly selectedSet: IconSet = new vscode.ThemeIcon('check'); @@ -293,12 +399,17 @@ export class OpenApiTreeNode extends vscode.TreeItem { filterTokens: string[], apiTitle: string | undefined, public readonly children: OpenApiTreeNode[] = [], - public readonly documentationUrl?: string + public readonly documentationUrl?: string, + public readonly clientNameOrPluginName?: string ) { super(label, collapsibleState); this.id = `${path}_${filterTokens.join('_')}`; // so the collapsed state is NOT persisted between filter changes - this.contextValue = label === pathSeparator + " (" + apiTitle + ")" ? 'apiTitle' : (this.documentationUrl ? 'documentationUrl' : ''); + this.contextValue = label === pathSeparator + " (" + apiTitle + ")" ? 'apiTitle' : (this.documentationUrl ? 'documentationUrl' : ''); this.iconPath = selected ? OpenApiTreeNode.selectedSet : OpenApiTreeNode.unselectedSet; + if (clientNameOrPluginName) { + this.label = clientNameOrPluginName; + this.contextValue = 'clientNameOrPluginName'; + } } public isNodeVisible(tokenizedFilter: string[]): boolean { if (tokenizedFilter.length === 0) { From a357533e278dd8ee64c337d61c5a9811611ed5c9 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 13 Jun 2024 17:35:17 +0300 Subject: [PATCH 096/150] hide information messages --- vscode/microsoft-kiota/src/extension.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 66b36ff9b0..5395f7a302 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -591,9 +591,6 @@ async function loadEditPaths(clientOrPluginKey: string, clientObject: any, openA } async function exportLogsAndShowErrors(result: KiotaLogEntry[]) : Promise { - const informationMessages = result - ? getLogEntriesForLevel(result, LogLevel.information) - : []; const errorMessages = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error) : []; @@ -605,10 +602,6 @@ async function exportLogsAndShowErrors(result: KiotaLogEntry[]) : Promise await Promise.all(errorMessages.map((element) => { return vscode.window.showErrorMessage(element.message); })); - } else { - await Promise.all(informationMessages.map((element) => { - return vscode.window.showInformationMessage(element.message); - })); } } From 8654d3d05a4239f0ac0de38d7a97d0b07519afaf Mon Sep 17 00:00:00 2001 From: ElinorW Date: Thu, 13 Jun 2024 19:45:53 +0300 Subject: [PATCH 097/150] update warning message display --- vscode/microsoft-kiota/src/extension.ts | 15 ++++++++------- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 15 ++++++++++++--- vscode/microsoft-kiota/src/util.ts | 8 ++++++++ 3 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 vscode/microsoft-kiota/src/util.ts diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 5395f7a302..2f530cdca7 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -30,6 +30,7 @@ import { KiotaWorkspace } from "./workspaceTreeProvider"; import { generatePlugin } from "./generatePlugin"; import { CodeLensProvider } from "./codelensProvider"; import { CLIENTS, KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE, PLUGINS, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; +import { updateTreeViewIcons } from "./util"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; @@ -179,7 +180,7 @@ export async function activate( `${treeViewId}.searchOrOpenApiDescription`, async () => { const yesAnswer = vscode.l10n.t("Yes, override it"); - if (!openApiTreeProvider.isEmpty()) { + if (!openApiTreeProvider.isEmpty() && openApiTreeProvider.hasSelectionChanged()) { const response = await vscode.window.showWarningMessage( vscode.l10n.t( "Before adding a new API description, consider that your changes and current selection will be lost."), @@ -213,7 +214,7 @@ export async function activate( ); if(response === yesAnswer) { openApiTreeProvider.closeDescription(); - await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, false); + await updateTreeViewIcons(treeViewId, false); } } ), @@ -227,8 +228,7 @@ export async function activate( clientOrPluginObject = clientObject; workspaceGenerationType = generationType; await loadEditPaths(clientOrPluginKey, clientObject, openApiTreeProvider); - await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, false); - await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, true); + await updateTreeViewIcons(treeViewId, false, true); }), registerCommandWithTelemetry(reporter,`${treeViewId}.regenerateButton`, async () => { const settings = getExtensionSettings(extensionId); @@ -303,6 +303,7 @@ export async function activate( await checkForSuccess(result); openApiTreeProvider.refreshView(); await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.pluginName); + await updateTreeViewIcons(treeViewId, false, true); await exportLogsAndShowErrors(result); } } @@ -344,6 +345,7 @@ export async function activate( await checkForSuccess(result); openApiTreeProvider.refreshView(); await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.pluginName); + await updateTreeViewIcons(treeViewId, false, true); await exportLogsAndShowErrors(result); } } @@ -414,6 +416,7 @@ export async function activate( await checkForSuccess(result); openApiTreeProvider.refreshView(); await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.clientClassName); + await updateTreeViewIcons(treeViewId, false, true); await exportLogsAndShowErrors(result); } } @@ -583,7 +586,7 @@ async function showUpgradeWarningMessage(clientPath: string, context: vscode.Ext async function loadLockFile(node: { fsPath: string }, openApiTreeProvider: OpenApiTreeProvider, clientOrPluginName?: string): Promise { await openTreeViewWithProgress(() => openApiTreeProvider.loadLockFile(node.fsPath, clientOrPluginName)); - await vscode.commands.executeCommand('setContext',`${treeViewId}.showIcons`, true); + await updateTreeViewIcons(treeViewId, true); } async function loadEditPaths(clientOrPluginKey: string, clientObject: any, openApiTreeProvider: OpenApiTreeProvider): Promise { @@ -662,8 +665,6 @@ async function checkForSuccess(results: KiotaLogEntry[]) { if (result && result.message) { if (result.message.includes("Generation completed successfully")) { void vscode.window.showInformationMessage('Generation completed successfully.'); - await vscode.commands.executeCommand('setContext', `${treeViewId}.showIcons`, false); - await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, true); } } } diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 2d34ad150e..d8313bfef3 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -17,11 +17,13 @@ import { PluginObjectProperties } from './kiotaInterop'; import { ExtensionSettings } from './extensionSettings'; import { treeViewId } from './constants'; +import { updateTreeViewIcons } from './util'; export class OpenApiTreeProvider implements vscode.TreeDataProvider { private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter(); readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; private apiTitle?: string; + private selectionChanged: boolean = false; constructor( private readonly context: vscode.ExtensionContext, private readonly settingsGetter: () => ExtensionSettings, @@ -161,11 +163,17 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider { this.closeDescription(false); this._descriptionUrl = descriptionUrl; @@ -188,6 +196,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider this.selectInternal(x, selected, recursive)); @@ -197,6 +206,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider Date: Fri, 28 Jun 2024 11:28:47 +0300 Subject: [PATCH 098/150] update regenerate function --- vscode/microsoft-kiota/src/extension.ts | 29 ++++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 2f530cdca7..cf181ad3d2 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -37,6 +37,7 @@ let kiotaOutputChannel: vscode.LogOutputChannel; let clientOrPluginKey: string; let clientOrPluginObject: ClientOrPluginProperties; let workspaceGenerationType: string; +let config: Partial; // This method is called when your extension is activated // Your extension is activated the very first time the command is executed @@ -137,7 +138,7 @@ export async function activate( return; } let languagesInformation = await getLanguageInformation(context); - const config = await generateSteps( + config = await generateSteps( { clientClassName: openApiTreeProvider.clientClassName, clientNamespaceName: openApiTreeProvider.clientNamespaceName, @@ -159,6 +160,7 @@ export async function activate( } const settings = getExtensionSettings(extensionId); + workspaceGenerationType = config.generationType as string; switch (generationType) { case GenerationType.Client: await generateClientAndRefreshUI(config, settings, outputPath, selectedPaths); @@ -231,6 +233,7 @@ export async function activate( await updateTreeViewIcons(treeViewId, false, true); }), registerCommandWithTelemetry(reporter,`${treeViewId}.regenerateButton`, async () => { + clientOrPluginKey = config.clientClassName ? config.clientClassName! : config.pluginName!; const settings = getExtensionSettings(extensionId); const selectedPaths = openApiTreeProvider.getSelectedPaths(); if (selectedPaths.length === 0) { @@ -239,11 +242,11 @@ export async function activate( ); return; } - if(workspaceGenerationType === CLIENTS) { - await regenerateClient(clientOrPluginKey, clientOrPluginObject, settings, selectedPaths); + if(workspaceGenerationType === 'client') { + await regenerateClient(clientOrPluginKey, config, settings, selectedPaths); } - else if (workspaceGenerationType === PLUGINS) { - await regeneratePlugin(clientOrPluginKey, clientOrPluginObject, settings, selectedPaths); + else if (workspaceGenerationType === 'plugin') { + await regeneratePlugin(clientOrPluginKey, config, settings, selectedPaths); } }), registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { @@ -432,22 +435,22 @@ export async function activate( }, async (progress, _) => { const result = await generateClient( context, - clientObject.descriptionLocation, + clientObject.descriptionLocation ? clientObject.descriptionLocation: openApiTreeProvider.descriptionUrl, clientObject.outputPath, language, selectedPaths ? selectedPaths : clientObject.includePatterns, - clientObject.excludePatterns, + clientObject.excludePatterns ? clientObject.excludePatterns : [], clientKey, clientObject.clientNamespaceName, - clientObject.usesBackingStore, + clientObject.usesBackingStore ? clientObject.usesBackingStore : settings.backingStore, true, // clearCache true, // cleanOutput - clientObject.excludeBackwardCompatible, - clientObject.disabledValidationRules, + clientObject.excludeBackwardCompatible ? clientObject.excludeBackwardCompatible : settings.excludeBackwardCompatible , + clientObject.disabledValidationRules ? clientObject.disabledValidationRules : settings.disableValidationRules, settings.languagesSerializationConfiguration[language].serializers, settings.languagesSerializationConfiguration[language].deserializers, - clientObject.structuredMimeTypes, - clientObject.includeAdditionalData, + clientObject.structuredMimeTypes ? clientObject.structuredMimeTypes : settings.structuredMimeTypes, + clientObject.includeAdditionalData ? clientObject.includeAdditionalData : settings.includeAdditionalData, ConsumerOperation.Edit ); return result; @@ -465,7 +468,7 @@ export async function activate( const start = performance.now(); const result = await generatePlugin( context, - clientObject.descriptionLocation, + clientObject.descriptionLocation ? clientObject.descriptionLocation: openApiTreeProvider.descriptionUrl, clientObject.outputPath, [pluginTypes], selectedPaths ? selectedPaths : clientObject.includePatterns, From 395a42b9891f0c936aa03aafd44ef275b414551d Mon Sep 17 00:00:00 2001 From: ElinorW Date: Fri, 28 Jun 2024 15:21:46 +0300 Subject: [PATCH 099/150] Add constants --- vscode/microsoft-kiota/src/constants.ts | 2 ++ vscode/microsoft-kiota/src/extension.ts | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/vscode/microsoft-kiota/src/constants.ts b/vscode/microsoft-kiota/src/constants.ts index 6b601563b9..4ed39fc9f9 100644 --- a/vscode/microsoft-kiota/src/constants.ts +++ b/vscode/microsoft-kiota/src/constants.ts @@ -8,4 +8,6 @@ export const KIOTA_WORKSPACE_FILE = "workspace.json"; export const KIOTA_DIRECTORY = '.kiota'; export const CLIENTS = "clients"; export const PLUGINS = "plugins"; +export const CLIENT = "client"; +export const PLUGIN = "plugin"; diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index cf181ad3d2..d1526f792c 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -29,7 +29,7 @@ import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; import { KiotaWorkspace } from "./workspaceTreeProvider"; import { generatePlugin } from "./generatePlugin"; import { CodeLensProvider } from "./codelensProvider"; -import { CLIENTS, KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE, PLUGINS, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; +import { CLIENT, CLIENTS, KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE, PLUGIN, PLUGINS, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; import { updateTreeViewIcons } from "./util"; let kiotaStatusBarItem: vscode.StatusBarItem; @@ -242,10 +242,10 @@ export async function activate( ); return; } - if(workspaceGenerationType === 'client') { + if(workspaceGenerationType === CLIENT) { await regenerateClient(clientOrPluginKey, config, settings, selectedPaths); } - else if (workspaceGenerationType === 'plugin') { + else if (workspaceGenerationType === PLUGIN) { await regeneratePlugin(clientOrPluginKey, config, settings, selectedPaths); } }), From 361d3aeddbb2894467b0d1f429581c3725cb7d20 Mon Sep 17 00:00:00 2001 From: Elinor Date: Fri, 28 Jun 2024 15:23:44 +0300 Subject: [PATCH 100/150] Fix: "Override" message only displays if there's a change on the tree (#4899) --- vscode/microsoft-kiota/src/extension.ts | 6 +++++- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 2f530cdca7..b34d05802a 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -302,6 +302,7 @@ export async function activate( { await checkForSuccess(result); openApiTreeProvider.refreshView(); + openApiTreeProvider.setSelectionChanged(false); await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.pluginName); await updateTreeViewIcons(treeViewId, false, true); await exportLogsAndShowErrors(result); @@ -344,6 +345,7 @@ export async function activate( { await checkForSuccess(result); openApiTreeProvider.refreshView(); + openApiTreeProvider.setSelectionChanged(false); await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.pluginName); await updateTreeViewIcons(treeViewId, false, true); await exportLogsAndShowErrors(result); @@ -415,6 +417,7 @@ export async function activate( { await checkForSuccess(result); openApiTreeProvider.refreshView(); + openApiTreeProvider.setSelectionChanged(false); await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.clientClassName); await updateTreeViewIcons(treeViewId, false, true); await exportLogsAndShowErrors(result); @@ -452,8 +455,8 @@ export async function activate( ); return result; }); - void vscode.window.showInformationMessage(`Client ${clientKey} re-generated successfully.`); + openApiTreeProvider.setSelectionChanged(false); } async function regeneratePlugin(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]) { const pluginTypes = typeof clientObject.pluginTypes === 'string' ? parsePluginType(clientObject.pluginTypes) : KiotaPluginType.ApiPlugin; @@ -487,6 +490,7 @@ export async function activate( return result; }); void vscode.window.showInformationMessage(`Plugin ${clientKey} re-generated successfully.`); + openApiTreeProvider.setSelectionChanged(false); } // create a new status bar item that we can now manage diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index d8313bfef3..ad0310d43f 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -171,8 +171,8 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider { this.closeDescription(false); @@ -196,7 +196,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider this.selectInternal(x, selected, recursive)); @@ -206,7 +206,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider Date: Mon, 1 Jul 2024 17:31:15 +0300 Subject: [PATCH 101/150] code clean up --- vscode/microsoft-kiota/src/extension.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index d1526f792c..4173e30b97 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -35,7 +35,6 @@ import { updateTreeViewIcons } from "./util"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; let clientOrPluginKey: string; -let clientOrPluginObject: ClientOrPluginProperties; let workspaceGenerationType: string; let config: Partial; @@ -227,7 +226,6 @@ export async function activate( ), registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { clientOrPluginKey = clientKey; - clientOrPluginObject = clientObject; workspaceGenerationType = generationType; await loadEditPaths(clientOrPluginKey, clientObject, openApiTreeProvider); await updateTreeViewIcons(treeViewId, false, true); From 9a17b5257d64395c0c6fff6610dd19af5820d235 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Mon, 1 Jul 2024 21:39:01 +0300 Subject: [PATCH 102/150] update plugin type to accept array --- vscode/microsoft-kiota/src/extension.ts | 8 +++---- vscode/microsoft-kiota/src/kiotaInterop.ts | 25 ++++++++++++---------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index b34d05802a..fe185a9eb1 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -309,7 +309,7 @@ export async function activate( } } async function generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { - const pluginTypes = typeof config.pluginTypes === 'string' ? parsePluginType(config.pluginTypes) : KiotaPluginType.ApiPlugin; + const pluginTypes = Array.isArray(config.pluginTypes) ? parsePluginType(config.pluginTypes) : [KiotaPluginType.ApiPlugin]; const result = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, @@ -320,7 +320,7 @@ export async function activate( context, openApiTreeProvider.descriptionUrl, outputPath, - [pluginTypes], + pluginTypes, selectedPaths, [], typeof config.pluginName === "string" @@ -459,7 +459,7 @@ export async function activate( openApiTreeProvider.setSelectionChanged(false); } async function regeneratePlugin(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]) { - const pluginTypes = typeof clientObject.pluginTypes === 'string' ? parsePluginType(clientObject.pluginTypes) : KiotaPluginType.ApiPlugin; + const pluginTypes = Array.isArray(clientObject.types) ? parsePluginType(clientObject.types) : [KiotaPluginType.ApiPlugin]; await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, @@ -470,7 +470,7 @@ export async function activate( context, clientObject.descriptionLocation, clientObject.outputPath, - [pluginTypes], + pluginTypes, selectedPaths ? selectedPaths : clientObject.includePatterns, [], clientKey, diff --git a/vscode/microsoft-kiota/src/kiotaInterop.ts b/vscode/microsoft-kiota/src/kiotaInterop.ts index 01a862cd72..411a3790bc 100644 --- a/vscode/microsoft-kiota/src/kiotaInterop.ts +++ b/vscode/microsoft-kiota/src/kiotaInterop.ts @@ -125,18 +125,21 @@ export enum ConsumerOperation { // eslint-disable-next-line @typescript-eslint/naming-convention Generate } -export function parsePluginType(value: string): KiotaPluginType { - switch (value) { - case "OpenAI": - return KiotaPluginType.OpenAI; - case "ApiManifest": - return KiotaPluginType.ApiManifest; - case "ApiPlugin": - return KiotaPluginType.ApiPlugin; - default: - throw new Error("unknown plugin type"); - } +export function parsePluginType(values: string[]): KiotaPluginType[] { + return values.map(value => { + switch (value.toLowerCase()) { + case "openai": + return KiotaPluginType.OpenAI; + case "apimanifest": + return KiotaPluginType.ApiManifest; + case "apiplugin": + return KiotaPluginType.ApiPlugin; + default: + throw new Error(`unknown plugin type: ${value}`); + } + }); } + export function generationLanguageToString(language: KiotaGenerationLanguage): string { switch (language) { case KiotaGenerationLanguage.CSharp: From f195c6e5bd6e02d85175fd9123dfb4296c905ac8 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 4 Jul 2024 08:52:27 -0400 Subject: [PATCH 103/150] chore: lock update --- vscode/microsoft-kiota/package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/package-lock.json b/vscode/microsoft-kiota/package-lock.json index 4a3bbb1dc8..f4da435585 100644 --- a/vscode/microsoft-kiota/package-lock.json +++ b/vscode/microsoft-kiota/package-lock.json @@ -32,7 +32,7 @@ "webpack-cli": "^5.1.4" }, "engines": { - "vscode": "^1.90.0" + "vscode": "^1.91.0" } }, "node_modules/@aashutoshrathi/word-wrap": { From 099f0a357e58f680752621221cc2fd20158cc288 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 5 Jul 2024 11:27:55 -0400 Subject: [PATCH 104/150] chore: bumps version to avoid auto-update --- vscode/microsoft-kiota/package-lock.json | 4 ++-- vscode/microsoft-kiota/package.json | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/vscode/microsoft-kiota/package-lock.json b/vscode/microsoft-kiota/package-lock.json index f4da435585..d47a7de8aa 100644 --- a/vscode/microsoft-kiota/package-lock.json +++ b/vscode/microsoft-kiota/package-lock.json @@ -1,12 +1,12 @@ { "name": "kiota", - "version": "1.15.100000001", + "version": "1.16.100000001", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kiota", - "version": "1.15.100000001", + "version": "1.16.100000001", "dependencies": { "@vscode/extension-telemetry": "^0.9.6", "@vscode/l10n": "^0.0.18", diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 22249bba1f..5fb1b97aa3 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -3,8 +3,8 @@ "displayName": "Microsoft Kiota", "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.15.100000001", - "kiotaVersion": "1.15.0", + "version": "1.16.100000001", + "kiotaVersion": "1.16.0", "telemetryInstrumentationKey": "4c6357e0-daf9-42b5-bdfb-67878f8957b5", "icon": "images/logo.png", "engines": { @@ -465,23 +465,23 @@ "runtimeDependencies": [ { "platformId": "win-x64", - "sha256": "A34EF636542E6AAF32FDA9D730534A9410B2E2D1F15DC8344C45D8CC694EE037" + "sha256": "4E1FE93EF66722266D99978DB4B96FA49EACBC7FB8DDC2330384C276EEED8A4F" }, { "platformId": "win-x86", - "sha256": "314106D1E6D446BF259F47FF3D112CD099E77B9E87CD5AD1EC8007106A281C8F" + "sha256": "200FE8C8A868AA7C1826923DE62DCD4E1261FEE32D5E02AD86BBB74031C62DB6" }, { "platformId": "linux-x64", - "sha256": "C56146FBBF0381B3419098B64EEB1BAA06473C4A085B3D18659B9CFB64E34B65" + "sha256": "C4CD448622E7EC35CDB66C68A9B01F7726246A3AE07B872ECD1B4980A6D06971" }, { "platformId": "osx-x64", - "sha256": "53BDDE6E0042E16392C9B123B0DDDBED1935C5831D6837D6B673942B012FFD73" + "sha256": "993AFDA8F91B4240D314540DE7B0CEDFF0CACB70DACF17B49A6460A6EA1CFB4E" }, { "platformId": "osx-arm64", - "sha256": "31215E1EE60A1E558FC5A190268E4D3016BFD5908445C45E90E63F22F91C54E8" + "sha256": "1D53A307228F3572BBA7B9A76B2575EE9E057FBCA3C8C1EBC188E4EDFB8DA2B2" } ] } From 868b14c13ea99289d0b0cb83881f966c82736920 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Thu, 11 Jul 2024 13:10:31 +0300 Subject: [PATCH 105/150] Fixes unselected paths --- src/kiota/Rpc/Server.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/kiota/Rpc/Server.cs b/src/kiota/Rpc/Server.cs index dbdb285175..a034c5b4c5 100644 --- a/src/kiota/Rpc/Server.cs +++ b/src/kiota/Rpc/Server.cs @@ -1,4 +1,4 @@ -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; using Kiota.Builder; using Kiota.Builder.Configuration; using Kiota.Builder.Extensions; @@ -257,7 +257,10 @@ private static PathItem ConvertOpenApiUrlTreeNodeToPathItem(OpenApiUrlTreeNode n .OrderByDescending(static x => x.isOperation) .ThenBy(static x => x.segment, StringComparer.OrdinalIgnoreCase) .ToArray(); - return new PathItem(node.Path, node.DeduplicatedSegment(), children, filteredPaths.Count == 0 || Array.Exists(children, static x => x.isOperation) && children.Where(static x => x.isOperation).All(static x => x.selected)); + bool isSelected = filteredPaths.Count == 0 || // There are no filtered paths + Array.Exists(children, static x => x.isOperation) && children.Where(static x => x.isOperation).All(static x => x.selected) || // All operations have been selected + !Array.Exists(children, static x => x.isOperation) && Array.TrueForAll(children, static x => x.selected); // All paths selected but no operations present + return new PathItem(node.Path, node.DeduplicatedSegment(), children, isSelected); } private static string GetAbsolutePath(string source) { From 10dd28292eec0aec7b554aeb65359cff9ccd465b Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Thu, 11 Jul 2024 13:28:22 +0300 Subject: [PATCH 106/150] format --- src/kiota/Rpc/Server.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kiota/Rpc/Server.cs b/src/kiota/Rpc/Server.cs index a034c5b4c5..f9e77d04d6 100644 --- a/src/kiota/Rpc/Server.cs +++ b/src/kiota/Rpc/Server.cs @@ -1,4 +1,4 @@ -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; using Kiota.Builder; using Kiota.Builder.Configuration; using Kiota.Builder.Extensions; From 15064a414db4e2675e98f3bc2b27f7ddac429c76 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Fri, 12 Jul 2024 15:58:08 +0300 Subject: [PATCH 107/150] fix regeneration --- vscode/microsoft-kiota/src/constants.ts | 1 + vscode/microsoft-kiota/src/extension.ts | 26 +++++++++++++++++-------- vscode/microsoft-kiota/src/util.ts | 12 ++++++++++++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/vscode/microsoft-kiota/src/constants.ts b/vscode/microsoft-kiota/src/constants.ts index 4ed39fc9f9..c604466f7e 100644 --- a/vscode/microsoft-kiota/src/constants.ts +++ b/vscode/microsoft-kiota/src/constants.ts @@ -10,4 +10,5 @@ export const CLIENTS = "clients"; export const PLUGINS = "plugins"; export const CLIENT = "client"; export const PLUGIN = "plugin"; +export const APIMANIFEST = "apimanifest"; diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index f9ce7debbc..c134d61ea2 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -13,7 +13,6 @@ import { KiotaGenerationLanguage, KiotaLogEntry, KiotaPluginType, - LanguageInformation, LogLevel, parseGenerationLanguage, parsePluginType, @@ -29,12 +28,13 @@ import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; import { KiotaWorkspace } from "./workspaceTreeProvider"; import { generatePlugin } from "./generatePlugin"; import { CodeLensProvider } from "./codelensProvider"; -import { CLIENT, CLIENTS, KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE, PLUGIN, PLUGINS, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; -import { updateTreeViewIcons } from "./util"; +import { KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; +import { isClientType, isPluginType, updateTreeViewIcons } from "./util"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; let clientOrPluginKey: string; +let clientOrPluginObject: ClientOrPluginProperties; let workspaceGenerationType: string; let config: Partial; @@ -169,6 +169,7 @@ export async function activate( break; case GenerationType.ApiManifest: await generateManifestAndRefreshUI(config, settings, outputPath, selectedPaths); + break; default: await vscode.window.showErrorMessage( vscode.l10n.t("Invalid generation type") @@ -226,12 +227,21 @@ export async function activate( ), registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { clientOrPluginKey = clientKey; + clientOrPluginObject = clientObject; workspaceGenerationType = generationType; await loadEditPaths(clientOrPluginKey, clientObject, openApiTreeProvider); await updateTreeViewIcons(treeViewId, false, true); }), registerCommandWithTelemetry(reporter,`${treeViewId}.regenerateButton`, async () => { - clientOrPluginKey = config.clientClassName ? config.clientClassName! : config.pluginName!; + if (!clientOrPluginKey || clientOrPluginKey === '') { + clientOrPluginKey = config.clientClassName || config.pluginName || ''; + } + if (!config) { + config = { + outputPath: clientOrPluginObject.outputPath, + clientClassName: clientOrPluginKey, + }; + } const settings = getExtensionSettings(extensionId); const selectedPaths = openApiTreeProvider.getSelectedPaths(); if (selectedPaths.length === 0) { @@ -240,10 +250,10 @@ export async function activate( ); return; } - if(workspaceGenerationType === CLIENT) { + if(isClientType(workspaceGenerationType)) { await regenerateClient(clientOrPluginKey, config, settings, selectedPaths); } - else if (workspaceGenerationType === PLUGIN) { + if (isPluginType(workspaceGenerationType)) { await regeneratePlugin(clientOrPluginKey, config, settings, selectedPaths); } }), @@ -257,10 +267,10 @@ export async function activate( ); return; } - if (generationType === CLIENTS) { + if (isClientType(generationType)) { await regenerateClient(clientKey, clientObject, settings); } - else if (generationType === PLUGINS) { + if (isClientType(generationType)) { await regeneratePlugin(clientKey, clientObject, settings); } }), diff --git a/vscode/microsoft-kiota/src/util.ts b/vscode/microsoft-kiota/src/util.ts index 4d84fb7e90..e51e832381 100644 --- a/vscode/microsoft-kiota/src/util.ts +++ b/vscode/microsoft-kiota/src/util.ts @@ -1,4 +1,16 @@ import * as vscode from 'vscode'; +import { APIMANIFEST, CLIENT, CLIENTS, PLUGIN, PLUGINS } from './constants'; + +const clientTypes = [CLIENT, CLIENTS]; +const pluginTypes = [PLUGIN, PLUGINS, APIMANIFEST]; + +export function isClientType(type: string): boolean { + return clientTypes.includes(type); +} + +export function isPluginType(type: string): boolean { + return pluginTypes.includes(type); +} export async function updateTreeViewIcons(treeViewId: string, showIcons: boolean, showRegenerateIcon?: boolean) { await vscode.commands.executeCommand('setContext', `${treeViewId}.showIcons`, showIcons); From fc3a34e8c81e678dc6c2cd7a4696ab12277dcedd Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Mon, 15 Jul 2024 13:12:52 +0300 Subject: [PATCH 108/150] API change to migrate lockfile to workspace file --- src/kiota/Rpc/IServer.cs | 1 + src/kiota/Rpc/Server.cs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/kiota/Rpc/IServer.cs b/src/kiota/Rpc/IServer.cs index a592200948..de7a284c0a 100644 --- a/src/kiota/Rpc/IServer.cs +++ b/src/kiota/Rpc/IServer.cs @@ -13,4 +13,5 @@ internal interface IServer Task> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, ConsumerOperation operation, CancellationToken cancellationToken); Task InfoForDescriptionAsync(string descriptionPath, bool clearCache, CancellationToken cancellationToken); Task> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, ConsumerOperation operation, CancellationToken cancellationToken); + Task> MigrateFromLockFileAsync(string lockDirectoryPath, CancellationToken cancellationToken); } diff --git a/src/kiota/Rpc/Server.cs b/src/kiota/Rpc/Server.cs index f9e77d04d6..a4af5fd573 100644 --- a/src/kiota/Rpc/Server.cs +++ b/src/kiota/Rpc/Server.cs @@ -4,6 +4,7 @@ using Kiota.Builder.Extensions; using Kiota.Builder.Lock; using Kiota.Builder.Logging; +using Kiota.Builder.WorkspaceManagement; using Kiota.Generated; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; @@ -230,6 +231,21 @@ public Task InfoForDescriptionAsync(string descriptionPath ArgumentException.ThrowIfNullOrEmpty(descriptionPath); return InfoInternalAsync(descriptionPath, clearCache, cancellationToken); } + + public async Task> MigrateFromLockFileAsync(string lockDirectoryPath, CancellationToken cancellationToken) + { + ArgumentException.ThrowIfNullOrEmpty(lockDirectoryPath); + var logger = new ForwardedLogger(); + var workspaceManagementService = new WorkspaceManagementService(logger, httpClient, IsConfigPreviewEnabled.Value); + var clientNames = await workspaceManagementService.MigrateFromLockFileAsync(string.Empty, lockDirectoryPath, cancellationToken).ConfigureAwait(false); + if (!clientNames.Any()) + { + logger.LogWarning("no client configuration was migrated"); + } + logger.LogInformation("Client configurations migrated successfully: {Clients}", string.Join(", ", clientNames)); + return logger.LogEntries; + } + private async Task InfoInternalAsync(string descriptionPath, bool clearCache, CancellationToken cancellationToken) { var logger = new ForwardedLogger(); From 5097c036be97750895dff1524910a97237636a54 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Mon, 15 Jul 2024 14:03:20 +0300 Subject: [PATCH 109/150] Adds connections to migrate workspace file --- src/kiota/Rpc/Server.cs | 17 ++++++++++++----- .../microsoft-kiota/src/migrateFromLockFile.ts | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 vscode/microsoft-kiota/src/migrateFromLockFile.ts diff --git a/src/kiota/Rpc/Server.cs b/src/kiota/Rpc/Server.cs index a4af5fd573..66634daed2 100644 --- a/src/kiota/Rpc/Server.cs +++ b/src/kiota/Rpc/Server.cs @@ -236,13 +236,20 @@ public async Task> MigrateFromLockFileAsync(string lockDirectoryP { ArgumentException.ThrowIfNullOrEmpty(lockDirectoryPath); var logger = new ForwardedLogger(); - var workspaceManagementService = new WorkspaceManagementService(logger, httpClient, IsConfigPreviewEnabled.Value); - var clientNames = await workspaceManagementService.MigrateFromLockFileAsync(string.Empty, lockDirectoryPath, cancellationToken).ConfigureAwait(false); - if (!clientNames.Any()) + try + { + var workspaceManagementService = new WorkspaceManagementService(logger, httpClient, IsConfigPreviewEnabled.Value); + var clientNames = await workspaceManagementService.MigrateFromLockFileAsync(string.Empty, lockDirectoryPath, cancellationToken).ConfigureAwait(false); + if (!clientNames.Any()) + { + logger.LogWarning("no client configuration was migrated"); + } + logger.LogInformation("Client configurations migrated successfully: {Clients}", string.Join(", ", clientNames)); + } + catch (Exception ex) { - logger.LogWarning("no client configuration was migrated"); + logger.LogCritical(ex, "error migrating the lock file: {ExceptionMessage}", ex.Message); } - logger.LogInformation("Client configurations migrated successfully: {Clients}", string.Join(", ", clientNames)); return logger.LogEntries; } diff --git a/vscode/microsoft-kiota/src/migrateFromLockFile.ts b/vscode/microsoft-kiota/src/migrateFromLockFile.ts new file mode 100644 index 0000000000..33593b8590 --- /dev/null +++ b/vscode/microsoft-kiota/src/migrateFromLockFile.ts @@ -0,0 +1,16 @@ +import { connectToKiota, KiotaLogEntry } from "./kiotaInterop"; +import * as rpc from "vscode-jsonrpc/node"; +import * as vscode from "vscode"; + +export function migrateFromLockFile(context: vscode.ExtensionContext, lockFileDirectory: string): Promise { + return connectToKiota(context, async (connection) => { + const request = new rpc.RequestType1( + "MigrateFromLockFile" + ); + const result = await connection.sendRequest( + request, + lockFileDirectory + ); + return result; + }); +}; \ No newline at end of file From 49df293b711deb72a909ae15f8715500ccf51f09 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Tue, 16 Jul 2024 11:46:48 +0300 Subject: [PATCH 110/150] Fix path maching --- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index ad0310d43f..5a67cf2378 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -433,7 +433,8 @@ export class OpenApiTreeNode extends vscode.TreeItem { return true; } - const segments = getPathSegments(splatPath); + // "tokenizedFilter" is lowercased so ensure the same is dome for the path segments for proper matching + const segments = getPathSegments(splatPath).map(x => x.trim().toLowerCase()); return tokenizedFilter.some(x => segments.some(s => s.includes(x))) || this.children.some(x => x.isNodeVisible(tokenizedFilter)); From 476ba16f03a8e80ae67eca4c1ead14306a9c37fd Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 16 Jul 2024 07:27:28 -0400 Subject: [PATCH 111/150] Update vscode/microsoft-kiota/src/openApiTreeProvider.ts --- vscode/microsoft-kiota/src/openApiTreeProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 5a67cf2378..9763cfa1e8 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -433,7 +433,7 @@ export class OpenApiTreeNode extends vscode.TreeItem { return true; } - // "tokenizedFilter" is lowercased so ensure the same is dome for the path segments for proper matching + // "tokenizedFilter" is lowercased so ensure the same is DOM for the path segments for proper matching const segments = getPathSegments(splatPath).map(x => x.trim().toLowerCase()); return tokenizedFilter.some(x => segments.some(s => s.includes(x))) From 19366c7274553409aab8b685e4e236c4f26a8971 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Wed, 17 Jul 2024 12:25:58 +0300 Subject: [PATCH 112/150] Fixes plugin generation check --- vscode/microsoft-kiota/src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index c134d61ea2..b3143af53c 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -270,7 +270,7 @@ export async function activate( if (isClientType(generationType)) { await regenerateClient(clientKey, clientObject, settings); } - if (isClientType(generationType)) { + if (isPluginType(generationType)) { await regeneratePlugin(clientKey, clientObject, settings); } }), From 7ffb8644280b29d331d12fe002b3bf856b2f91ed Mon Sep 17 00:00:00 2001 From: Elinor Date: Mon, 22 Jul 2024 15:33:40 +0300 Subject: [PATCH 113/150] Fix: Add paste path functionality (#4994) --- vscode/microsoft-kiota/src/steps.ts | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 4a652552c3..166c21a7f8 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -36,7 +36,7 @@ export async function searchSteps(searchCallBack: (searchQuery: string) => Thena title, step: step++, totalSteps: totalSteps, - placeholder: l10n.t('Search or paste a path to an API description'), + placeholder: l10n.t('Search or browse a path to an API description'), items: [{label: l10n.t('Search')}, {label: l10n.t('Browse path')}], validate: validateIsNotEmpty, shouldResume: shouldResume @@ -64,16 +64,34 @@ export async function searchSteps(searchCallBack: (searchQuery: string) => Thena step: step++, totalSteps: totalSteps, value: state.searchQuery ?? '', - prompt: l10n.t('Search a path to an API description'), + prompt: l10n.t('Search or paste a path to an API description'), validate: validateIsNotEmpty, shouldResume: shouldResume }); state.searchResults = await searchCallBack(state.searchQuery); if(state.searchResults && Object.keys(state.searchResults).length > 0) { return (input: MultiStepInput) => pickSearchResult(input, state); + } else { + state.descriptionPath = state.searchQuery; + return (input: MultiStepInput) => inputPathOrUrl(input, state); } - } + + async function inputPathOrUrl(input: MultiStepInput, state: Partial) { + if (state.descriptionPath) { + return; + } + state.descriptionPath = await input.showInputBox({ + title, + step: step++, + totalSteps: 1, + value: state.descriptionPath || '', + prompt: l10n.t('Search or paste a path to an API description'), + validate: validateIsNotEmpty, + shouldResume: shouldResume + }); + } + async function pickSearchResult(input: MultiStepInput, state: Partial) { const items: QuickSearchPickItem[] = []; if(state.searchResults) { @@ -236,7 +254,7 @@ export async function generateSteps(existingConfiguration: Partial inputPluginType(input, state); } async function inputPluginType(input: MultiStepInput, state: Partial) { - const items = ['ApiPlugin','Open AI'].map(x => ({ label: x})as QuickPickItem); + const items = ['Api Plugin','Open AI'].map(x => ({ label: x})as QuickPickItem); const pluginTypes = await input.showQuickPick({ title: l10n.t('Choose a plugin type'), step: step++, @@ -246,7 +264,7 @@ export async function generateSteps(existingConfiguration: Partial inputPluginOutputPath(input, state); } async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { From cbea6da3594a99de49e401b88dffa8090dcf4b00 Mon Sep 17 00:00:00 2001 From: Elinor Date: Fri, 26 Jul 2024 10:53:20 +0300 Subject: [PATCH 114/150] Fix: Kiota extension works without a workspace folder open (#4958) --- vscode/microsoft-kiota/src/extension.ts | 110 ++++++++++-------- vscode/microsoft-kiota/src/generateClient.ts | 6 +- vscode/microsoft-kiota/src/generatePlugin.ts | 6 +- vscode/microsoft-kiota/src/kiotaInterop.ts | 5 +- vscode/microsoft-kiota/src/steps.ts | 50 ++++++-- vscode/microsoft-kiota/src/util.ts | 50 +++++++- .../src/workspaceTreeProvider.ts | 77 ++++++------ 7 files changed, 200 insertions(+), 104 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index b3143af53c..cc06ad07f8 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -25,11 +25,11 @@ import { getLanguageInformation, getLanguageInformationForDescription } from "./ import { DependenciesViewProvider } from "./dependenciesViewProvider"; import { updateClients } from "./updateClients"; import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; -import { KiotaWorkspace } from "./workspaceTreeProvider"; +import { loadTreeView } from "./workspaceTreeProvider"; import { generatePlugin } from "./generatePlugin"; import { CodeLensProvider } from "./codelensProvider"; import { KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; -import { isClientType, isPluginType, updateTreeViewIcons } from "./util"; +import { getWorkspaceJsonDirectory, getWorkspaceJsonPath, isClientType, isPluginType, updateTreeViewIcons } from "./util"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; @@ -38,6 +38,11 @@ let clientOrPluginObject: ClientOrPluginProperties; let workspaceGenerationType: string; let config: Partial; +interface GeneratedOutputState { + outputPath: string; + clientClassName: string; +} + // This method is called when your extension is activated // Your extension is activated the very first time the command is executed export async function activate( @@ -46,13 +51,12 @@ export async function activate( kiotaOutputChannel = vscode.window.createOutputChannel("Kiota", { log: true, }); - const workspaceJsonPath = path.join(vscode.workspace.workspaceFolders?.map(folder => folder.uri.fsPath).join('') || '', KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE); const openApiTreeProvider = new OpenApiTreeProvider(context, () => getExtensionSettings(extensionId)); const dependenciesInfoProvider = new DependenciesViewProvider( context.extensionUri ); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); - new KiotaWorkspace(context); + await loadTreeView(context); let codeLensProvider = new CodeLensProvider(); context.subscriptions.push( vscode.window.registerUriHandler({ @@ -127,15 +131,7 @@ export async function activate( ); return; } - if ( - !vscode.workspace.workspaceFolders || - vscode.workspace.workspaceFolders.length === 0 - ) { - await vscode.window.showErrorMessage( - vscode.l10n.t("No workspace folder found, open a folder first") - ); - return; - } + let languagesInformation = await getLanguageInformation(context); config = await generateSteps( { @@ -157,27 +153,50 @@ export async function activate( ); return; } - + const settings = getExtensionSettings(extensionId); workspaceGenerationType = config.generationType as string; + let result; switch (generationType) { case GenerationType.Client: - await generateClientAndRefreshUI(config, settings, outputPath, selectedPaths); - break; + result = await generateClientAndRefreshUI(config, settings, outputPath, selectedPaths); + break; case GenerationType.Plugin: - await generatePluginAndRefreshUI(config, settings, outputPath, selectedPaths); - break; + result = await generatePluginAndRefreshUI(config, settings, outputPath, selectedPaths); + break; case GenerationType.ApiManifest: - await generateManifestAndRefreshUI(config, settings, outputPath, selectedPaths); - break; + result = await generateManifestAndRefreshUI(config, settings, outputPath, selectedPaths); + break; default: await vscode.window.showErrorMessage( vscode.l10n.t("Invalid generation type") ); - break; + return; + } + if (result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) { + // Save state before opening the new window + void context.workspaceState.update('generatedOutput', { + outputPath, + config, + clientClassName: config.clientClassName || config.pluginName + } as GeneratedOutputState); + if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) { + await vscode.commands.executeCommand('vscode.openFolder', vscode.Uri.file(config.workingDirectory ?? getWorkspaceJsonDirectory()), true); + } else { + await displayGenerationResults(context, openApiTreeProvider, config, outputPath); + } } } ), + vscode.workspace.onDidChangeWorkspaceFolders(async () => { + const generatedOutput = context.workspaceState.get('generatedOutput'); + if (generatedOutput) { + const { outputPath} = generatedOutput; + await displayGenerationResults(context, openApiTreeProvider, config, outputPath); + // Clear the state + void context.workspaceState.update('generatedOutput', undefined); + } + }), registerCommandWithTelemetry(reporter, `${treeViewId}.searchOrOpenApiDescription`, async () => { @@ -276,7 +295,7 @@ export async function activate( }), ); - async function generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { + async function generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { const pluginTypes = KiotaPluginType.ApiManifest; const result = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, @@ -297,7 +316,8 @@ export async function activate( settings.clearCache, settings.cleanOutput, settings.disableValidationRules, - ConsumerOperation.Add + ConsumerOperation.Add, + config.workingDirectory ); const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; @@ -311,15 +331,11 @@ export async function activate( }); if (result) { - await checkForSuccess(result); - openApiTreeProvider.refreshView(); - openApiTreeProvider.setSelectionChanged(false); - await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.pluginName); - await updateTreeViewIcons(treeViewId, false, true); await exportLogsAndShowErrors(result); } + return result; } - async function generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { + async function generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { const pluginTypes = Array.isArray(config.pluginTypes) ? parsePluginType(config.pluginTypes) : [KiotaPluginType.ApiPlugin]; const result = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, @@ -340,7 +356,8 @@ export async function activate( settings.clearCache, settings.cleanOutput, settings.disableValidationRules, - ConsumerOperation.Add + ConsumerOperation.Add, + config.workingDirectory ); const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; @@ -354,15 +371,11 @@ export async function activate( }); if (result) { - await checkForSuccess(result); - openApiTreeProvider.refreshView(); - openApiTreeProvider.setSelectionChanged(false); - await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.pluginName); - await updateTreeViewIcons(treeViewId, false, true); await exportLogsAndShowErrors(result); } + return result; } - async function generateClientAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { + async function generateClientAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { const language = typeof config.language === "string" ? parseGenerationLanguage(config.language) @@ -395,7 +408,8 @@ export async function activate( settings.languagesSerializationConfiguration[language].deserializers, settings.structuredMimeTypes, settings.includeAdditionalData, - ConsumerOperation.Add + ConsumerOperation.Add, + config.workingDirectory ); const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; @@ -417,22 +431,20 @@ export async function activate( dependenciesInfoProvider.update(languagesInformation, language); await vscode.commands.executeCommand(treeViewFocusCommand); } - if (typeof config.outputPath === "string" && !openApiTreeProvider.isLockFileLoaded && - vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 && - result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) { - const WORKSPACE_FOLDER = vscode.workspace.workspaceFolders[0].uri.fsPath; - const KIOTA_WORKSPACE_PATH = path.join(WORKSPACE_FOLDER, KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE); - await openApiTreeProvider.loadLockFile(KIOTA_WORKSPACE_PATH, config.clientClassName); - } if (result) { - await checkForSuccess(result); - openApiTreeProvider.refreshView(); - openApiTreeProvider.setSelectionChanged(false); - await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, config.clientClassName); - await updateTreeViewIcons(treeViewId, false, true); await exportLogsAndShowErrors(result); } + return result; + } + + async function displayGenerationResults(context: vscode.ExtensionContext, openApiTreeProvider: OpenApiTreeProvider, config: any, outputPath: string) { + const clientNameOrPluginName = config.clientClassName || config.pluginName; + openApiTreeProvider.refreshView(); + openApiTreeProvider.setSelectionChanged(false); + const workspaceJsonPath = getWorkspaceJsonPath(); + await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, clientNameOrPluginName ); + await updateTreeViewIcons(treeViewId, false, true); } async function regenerateClient(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]): Promise { const language = diff --git a/vscode/microsoft-kiota/src/generateClient.ts b/vscode/microsoft-kiota/src/generateClient.ts index 4c69f2c4bb..97475b8747 100644 --- a/vscode/microsoft-kiota/src/generateClient.ts +++ b/vscode/microsoft-kiota/src/generateClient.ts @@ -1,6 +1,7 @@ import { connectToKiota, ConsumerOperation, GenerationConfiguration, KiotaGenerationLanguage, KiotaLogEntry } from "./kiotaInterop"; import * as rpc from "vscode-jsonrpc/node"; import * as vscode from "vscode"; +import { getWorkspaceJsonDirectory } from "./util"; export function generateClient(context: vscode.ExtensionContext, descriptionPath: string, @@ -19,7 +20,8 @@ export function generateClient(context: vscode.ExtensionContext, deserializers: string[], structuredMimeTypes: string[], includeAdditionalData: boolean, - operation: ConsumerOperation + operation: ConsumerOperation, + workingDirectory: string = getWorkspaceJsonDirectory() ): Promise { return connectToKiota(context, async (connection) => { const request = new rpc.RequestType1( @@ -47,5 +49,5 @@ export function generateClient(context: vscode.ExtensionContext, operation: operation } as GenerationConfiguration, ); - }); + }, workingDirectory); }; \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/generatePlugin.ts b/vscode/microsoft-kiota/src/generatePlugin.ts index 609a6de073..8e9948bcf0 100644 --- a/vscode/microsoft-kiota/src/generatePlugin.ts +++ b/vscode/microsoft-kiota/src/generatePlugin.ts @@ -1,6 +1,7 @@ import { connectToKiota, ConsumerOperation, GenerationConfiguration, KiotaGenerationLanguage, KiotaLogEntry, KiotaPluginType } from "./kiotaInterop"; import * as rpc from "vscode-jsonrpc/node"; import * as vscode from "vscode"; +import { getWorkspaceJsonDirectory } from "./util"; export function generatePlugin(context: vscode.ExtensionContext, descriptionPath: string, @@ -12,7 +13,8 @@ export function generatePlugin(context: vscode.ExtensionContext, clearCache: boolean, cleanOutput: boolean, disableValidationRules: string[], - operation: ConsumerOperation ): Promise { + operation: ConsumerOperation, + workingDirectory: string = getWorkspaceJsonDirectory() ): Promise { return connectToKiota(context, async (connection) => { const request = new rpc.RequestType1( "GeneratePlugin" @@ -32,5 +34,5 @@ export function generatePlugin(context: vscode.ExtensionContext, operation: operation } as GenerationConfiguration, ); - }); + }, workingDirectory); }; \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/kiotaInterop.ts b/vscode/microsoft-kiota/src/kiotaInterop.ts index 411a3790bc..3aea7cc663 100644 --- a/vscode/microsoft-kiota/src/kiotaInterop.ts +++ b/vscode/microsoft-kiota/src/kiotaInterop.ts @@ -2,12 +2,13 @@ import * as vscode from "vscode"; import * as cp from 'child_process'; import * as rpc from 'vscode-jsonrpc/node'; import { ensureKiotaIsPresent, getKiotaPath } from './kiotaInstall'; +import { getWorkspaceJsonDirectory } from "./util"; -export async function connectToKiota(context: vscode.ExtensionContext, callback:(connection: rpc.MessageConnection) => Promise): Promise { +export async function connectToKiota(context: vscode.ExtensionContext, callback:(connection: rpc.MessageConnection) => Promise, workingDirectory:string = getWorkspaceJsonDirectory()): Promise { const kiotaPath = getKiotaPath(context); await ensureKiotaIsPresent(context); const childProcess = cp.spawn(kiotaPath, ["rpc"],{ - cwd: vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 ? vscode.workspace.workspaceFolders[0].uri.fsPath : undefined, + cwd: workingDirectory, env: { ...process.env, // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 166c21a7f8..28fa25ef81 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -1,6 +1,8 @@ +import * as vscode from 'vscode'; import { QuickPickItem, window, Disposable, QuickInputButton, QuickInput, QuickInputButtons, workspace, l10n, Uri, OpenDialogOptions } from 'vscode'; import { allGenerationLanguages, generationLanguageToString, KiotaSearchResultItem, LanguagesInformation, maturityLevelToString } from './kiotaInterop'; -import * as vscode from 'vscode'; +import { findAppPackageDirectory, getWorkspaceJsonDirectory } from './util'; +import * as path from 'path'; export async function filterSteps(existingFilter: string, filterCallback: (searchQuery: string) => void) { const state = {} as Partial; @@ -125,17 +127,33 @@ export async function generateSteps(existingConfiguration: Partial) { const items = [l10n.t('Generate an API client'), l10n.t('Generate a plugin'), l10n.t('Generate an API manifest')]; const option = await input.showQuickPick({ @@ -171,6 +189,7 @@ export async function generateSteps(existingConfiguration: Partial inputClientNamespaceName(input, state); } async function inputClientNamespaceName(input: MultiStepInput, state: Partial) { @@ -212,6 +231,9 @@ export async function generateSteps(existingConfiguration: Partial inputPluginType(input, state); } async function inputPluginType(input: MultiStepInput, state: Partial) { @@ -264,7 +287,7 @@ export async function generateSteps(existingConfiguration: Partial inputPluginOutputPath(input, state); } async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { @@ -293,6 +316,9 @@ export async function generateSteps(existingConfiguration: Partial inputManifestOutputPath(input, state); } async function inputManifestOutputPath(input: MultiStepInput, state: Partial) { @@ -339,14 +366,20 @@ export async function generateSteps(existingConfiguration: Partial inputGenerationType(input, state), () => step-=2); + if(!state.workingDirectory){ + state.workingDirectory = state.outputPath as string; + } return state; } @@ -384,12 +417,13 @@ type QuickSearchPickItem = QuickPickItem & SearchItem; export interface GenerateState extends BaseStepsState { generationType: QuickPickItem | string; - pluginTypes: QuickPickItem | string; + pluginTypes: QuickPickItem | string[]; pluginName:string; clientClassName: string; clientNamespaceName: QuickPickItem | string; language: QuickPickItem | string; outputPath: QuickPickItem | string; + workingDirectory: string; } export enum GenerationType { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/vscode/microsoft-kiota/src/util.ts b/vscode/microsoft-kiota/src/util.ts index e51e832381..a45854b3f2 100644 --- a/vscode/microsoft-kiota/src/util.ts +++ b/vscode/microsoft-kiota/src/util.ts @@ -1,5 +1,7 @@ import * as vscode from 'vscode'; -import { APIMANIFEST, CLIENT, CLIENTS, PLUGIN, PLUGINS } from './constants'; +import * as path from 'path'; +import * as fs from 'fs'; +import { APIMANIFEST, CLIENT, CLIENTS, KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE, PLUGIN, PLUGINS } from './constants'; const clientTypes = [CLIENT, CLIENTS]; const pluginTypes = [PLUGIN, PLUGINS, APIMANIFEST]; @@ -17,4 +19,50 @@ export async function updateTreeViewIcons(treeViewId: string, showIcons: boolean if (showRegenerateIcon !== undefined) { await vscode.commands.executeCommand('setContext', `${treeViewId}.showRegenerateIcon`, showRegenerateIcon); } +} + +export function getWorkspaceJsonPath(): string { + return path.join(getWorkspaceJsonDirectory(),KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE); +}; + +export function getWorkspaceJsonDirectory(clientNameOrPluginName?: string): string { + const baseDir = path.join( + vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 + ? vscode.workspace.workspaceFolders[0].uri.fsPath + : process.env.HOME ?? process.env.USERPROFILE ?? process.cwd() + ); + + let workspaceFolder = !vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0 + ? path.join(baseDir, 'kiota', clientNameOrPluginName ?? '') + : baseDir; + + if (!fs.existsSync(workspaceFolder)) { + fs.mkdirSync(workspaceFolder, { recursive: true }); + } + return workspaceFolder; +} + +export function findAppPackageDirectory(directory: string): string | null { + if (!fs.existsSync(directory)) { + return null; + } + + const entries = fs.readdirSync(directory, { withFileTypes: true }); + + for (const entry of entries) { + const fullPath = path.join(directory, entry.name); + + if (entry.isDirectory()) { + if (entry.name === 'appPackage') { + return fullPath; + } + + const subDirectory = findAppPackageDirectory(fullPath); + if (subDirectory) { + return subDirectory; + } + } + } + + return null; } \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts index ab590f4535..a82efd3c27 100644 --- a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts +++ b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts @@ -1,61 +1,58 @@ import * as vscode from 'vscode'; import * as path from 'path'; import * as fs from 'fs'; -import { KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE } from './constants'; +import { KIOTA_WORKSPACE_FILE } from './constants'; +import { getWorkspaceJsonPath } from './util'; -const workspaceJsonPath = path.join(vscode.workspace.workspaceFolders?.map(folder => folder.uri.fsPath).join('') || '', KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE); export class WorkspaceTreeProvider implements vscode.TreeDataProvider { - - constructor(private context: vscode.ExtensionContext) { - void this.ensureKiotaDirectory(); + constructor(public isWSPresent: boolean) { } async getChildren(element?: vscode.TreeItem): Promise { - if (!element) { - return [new vscode.TreeItem(KIOTA_WORKSPACE_FILE, vscode.TreeItemCollapsibleState.None)]; - } + if (!this.isWSPresent) { return []; + } + if (!element) { + return [new vscode.TreeItem(KIOTA_WORKSPACE_FILE, vscode.TreeItemCollapsibleState.None)]; + } + return []; } getTreeItem(element: vscode.TreeItem): vscode.TreeItem { if (element) { - element.command = { command: 'kiota.workspace.openWorkspaceFile', title: vscode.l10n.t("Open File"), arguments: [vscode.Uri.file(workspaceJsonPath)], }; + element.command = { + command: 'kiota.workspace.openWorkspaceFile', + title: vscode.l10n.t("Open File"), + arguments: [vscode.Uri.file(getWorkspaceJsonPath())] + }; element.contextValue = 'file'; } return element; } +} - private async ensureKiotaDirectory(): Promise { - if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) { - await vscode.window.showErrorMessage( - vscode.l10n.t("No workspace folder found, open a folder first") - ); - return; - } - const kiotaDir = path.dirname(workspaceJsonPath); - try { - await fs.promises.access(kiotaDir); - } catch (error) { - await vscode.window.showErrorMessage( - vscode.l10n.t("Kiota directory not found") - ); - } +async function openResource(resource: vscode.Uri): Promise { + await vscode.window.showTextDocument(resource); +} +async function isKiotaWorkspaceFilePresent(): Promise { + const workspaceFileDir = path.resolve(getWorkspaceJsonPath()); + try { + await fs.promises.access(workspaceFileDir); + } catch (error) { + return false; } + return true; } -export class KiotaWorkspace { - constructor(context: vscode.ExtensionContext) { - const treeDataProvider = new WorkspaceTreeProvider(context); - context.subscriptions.push(vscode.window.createTreeView('kiota.workspace', { treeDataProvider })); - vscode.commands.registerCommand('kiota.workspace.openWorkspaceFile', async (resource) => await this.openResource(resource)); - } - private async openResource(resource: vscode.Uri): Promise { - try{ - await vscode.window.showTextDocument(resource); - } catch (error) { - await fs.promises.writeFile(workspaceJsonPath, Buffer.from('{}')); - await vscode.window.showTextDocument(resource); - } - - } -} \ No newline at end of file +export async function loadTreeView(context: vscode.ExtensionContext): Promise { + const treeDataProvider = new WorkspaceTreeProvider(await isKiotaWorkspaceFilePresent()); + context.subscriptions.push(vscode.workspace.onDidChangeWorkspaceFolders(async () => { + treeDataProvider.isWSPresent = await isKiotaWorkspaceFilePresent(); + await vscode.commands.executeCommand('kiota.workspace.refresh'); // Refresh the tree view when workspace folders change + })); + context.subscriptions.push(vscode.window.createTreeView('kiota.workspace', { treeDataProvider })); + context.subscriptions.push(vscode.commands.registerCommand('kiota.workspace.openWorkspaceFile', openResource)); + context.subscriptions.push(vscode.commands.registerCommand('kiota.workspace.refresh', async () => { + treeDataProvider.isWSPresent = await isKiotaWorkspaceFilePresent(); + })); +} From 72e3f8b9b1f5737513b655ccf4bfaa5faa6c0406 Mon Sep 17 00:00:00 2001 From: Elinor Date: Mon, 29 Jul 2024 19:55:31 +0300 Subject: [PATCH 115/150] Fix: Workspace file display (#5029) --- vscode/microsoft-kiota/package.json | 4 ++ vscode/microsoft-kiota/package.nls.json | 3 +- vscode/microsoft-kiota/src/extension.ts | 1 + vscode/microsoft-kiota/src/util.ts | 1 + .../src/workspaceTreeProvider.ts | 67 +++++++++++-------- 5 files changed, 48 insertions(+), 28 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index 41cbfdcbb6..c5b6cc0865 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -409,6 +409,10 @@ { "command": "kiota.regenerate", "title": "%kiota.openApiExplorer.regenerateButton.title%" + }, + { + "command": "kiota.workspace.refresh", + "title": "%kiota.openApiExplorer.refresh.title%" } ], "languages": [ diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index eb1facdf59..00e54d3cb5 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -29,5 +29,6 @@ "kiota.openApiExplorer.openFile.title": "Open file", "kiota.workspace.name": "My Workspace", "kiota.openApiExplorer.regenerateButton.title": "Re-generate", - "kiota.openApiExplorer.editPaths.title": "Edit paths" + "kiota.openApiExplorer.editPaths.title": "Edit paths", + "kiota.openApiExplorer.refresh.title": "Refresh" } diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index cc06ad07f8..cfc16c15b5 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -444,6 +444,7 @@ export async function activate( openApiTreeProvider.setSelectionChanged(false); const workspaceJsonPath = getWorkspaceJsonPath(); await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, clientNameOrPluginName ); + await vscode.commands.executeCommand('kiota.workspace.refresh'); await updateTreeViewIcons(treeViewId, false, true); } async function regenerateClient(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]): Promise { diff --git a/vscode/microsoft-kiota/src/util.ts b/vscode/microsoft-kiota/src/util.ts index a45854b3f2..087dc03fde 100644 --- a/vscode/microsoft-kiota/src/util.ts +++ b/vscode/microsoft-kiota/src/util.ts @@ -42,6 +42,7 @@ export function getWorkspaceJsonDirectory(clientNameOrPluginName?: string): stri return workspaceFolder; } +//used to store output in the App Package directory in the case where the workspace is a Teams Toolkit Project export function findAppPackageDirectory(directory: string): string | null { if (!fs.existsSync(directory)) { return null; diff --git a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts index a82efd3c27..e97a32d47b 100644 --- a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts +++ b/vscode/microsoft-kiota/src/workspaceTreeProvider.ts @@ -6,42 +6,54 @@ import { getWorkspaceJsonPath } from './util'; export class WorkspaceTreeProvider implements vscode.TreeDataProvider { - constructor(public isWSPresent: boolean) { - } - async getChildren(element?: vscode.TreeItem): Promise { - if (!this.isWSPresent) { - return []; - } - if (!element) { - return [new vscode.TreeItem(KIOTA_WORKSPACE_FILE, vscode.TreeItemCollapsibleState.None)]; - } + public isWSPresent: boolean; + private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter(); + readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; + constructor( isWSPresent: boolean) { + this.isWSPresent = isWSPresent; + } + + async refreshView(): Promise { + this._onDidChangeTreeData.fire(); +} + + async getChildren(element?: vscode.TreeItem): Promise { + if (!this.isWSPresent) { return []; } - - getTreeItem(element: vscode.TreeItem): vscode.TreeItem { - if (element) { - element.command = { - command: 'kiota.workspace.openWorkspaceFile', - title: vscode.l10n.t("Open File"), - arguments: [vscode.Uri.file(getWorkspaceJsonPath())] - }; - element.contextValue = 'file'; - } - return element; + if (!element) { + return [new vscode.TreeItem(KIOTA_WORKSPACE_FILE, vscode.TreeItemCollapsibleState.None)]; } + return []; + } + + getTreeItem(element: vscode.TreeItem): vscode.TreeItem { + if (element) { + element.command = { + command: 'kiota.workspace.openWorkspaceFile', + title: vscode.l10n.t("Open File"), + arguments: [vscode.Uri.file(getWorkspaceJsonPath())] + }; + element.contextValue = 'file'; + } + return element; + } } async function openResource(resource: vscode.Uri): Promise { await vscode.window.showTextDocument(resource); } async function isKiotaWorkspaceFilePresent(): Promise { - const workspaceFileDir = path.resolve(getWorkspaceJsonPath()); - try { - await fs.promises.access(workspaceFileDir); - } catch (error) { - return false; - } - return true; + if(!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0){ + return false; + } + const workspaceFileDir = path.resolve(getWorkspaceJsonPath()); + try { + await fs.promises.access(workspaceFileDir); + } catch (error) { + return false; + } + return true; } export async function loadTreeView(context: vscode.ExtensionContext): Promise { @@ -54,5 +66,6 @@ export async function loadTreeView(context: vscode.ExtensionContext): Promise { treeDataProvider.isWSPresent = await isKiotaWorkspaceFilePresent(); + await treeDataProvider.refreshView(); })); } From 48f3d9f2a26c2579db747df58d7afe641179967b Mon Sep 17 00:00:00 2001 From: Elinor Date: Thu, 1 Aug 2024 14:48:46 +0300 Subject: [PATCH 116/150] Fix: Display "override" message only when changes have been made (#5048) --- vscode/microsoft-kiota/src/extension.ts | 9 +++--- .../src/openApiTreeProvider.ts | 29 +++++++++++++------ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index cfc16c15b5..45576ea78b 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -201,7 +201,7 @@ export async function activate( `${treeViewId}.searchOrOpenApiDescription`, async () => { const yesAnswer = vscode.l10n.t("Yes, override it"); - if (!openApiTreeProvider.isEmpty() && openApiTreeProvider.hasSelectionChanged()) { + if (!openApiTreeProvider.isEmpty() && openApiTreeProvider.hasChanges()) { const response = await vscode.window.showWarningMessage( vscode.l10n.t( "Before adding a new API description, consider that your changes and current selection will be lost."), @@ -249,6 +249,7 @@ export async function activate( clientOrPluginObject = clientObject; workspaceGenerationType = generationType; await loadEditPaths(clientOrPluginKey, clientObject, openApiTreeProvider); + openApiTreeProvider.resetInitialState(); await updateTreeViewIcons(treeViewId, false, true); }), registerCommandWithTelemetry(reporter,`${treeViewId}.regenerateButton`, async () => { @@ -441,10 +442,10 @@ export async function activate( async function displayGenerationResults(context: vscode.ExtensionContext, openApiTreeProvider: OpenApiTreeProvider, config: any, outputPath: string) { const clientNameOrPluginName = config.clientClassName || config.pluginName; openApiTreeProvider.refreshView(); - openApiTreeProvider.setSelectionChanged(false); const workspaceJsonPath = getWorkspaceJsonPath(); await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, clientNameOrPluginName ); await vscode.commands.executeCommand('kiota.workspace.refresh'); + openApiTreeProvider.resetInitialState(); await updateTreeViewIcons(treeViewId, false, true); } async function regenerateClient(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]): Promise { @@ -480,7 +481,7 @@ export async function activate( return result; }); void vscode.window.showInformationMessage(`Client ${clientKey} re-generated successfully.`); - openApiTreeProvider.setSelectionChanged(false); + openApiTreeProvider.resetInitialState(); } async function regeneratePlugin(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]) { const pluginTypes = Array.isArray(clientObject.types) ? parsePluginType(clientObject.types) : [KiotaPluginType.ApiPlugin]; @@ -514,7 +515,7 @@ export async function activate( return result; }); void vscode.window.showInformationMessage(`Plugin ${clientKey} re-generated successfully.`); - openApiTreeProvider.setSelectionChanged(false); + openApiTreeProvider.resetInitialState(); } // create a new status bar item that we can now manage diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/openApiTreeProvider.ts index 9763cfa1e8..c84ae71c3a 100644 --- a/vscode/microsoft-kiota/src/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/openApiTreeProvider.ts @@ -3,6 +3,7 @@ import * as os from 'os'; import * as path from 'path'; import * as vscode from 'vscode'; import * as rpc from 'vscode-jsonrpc/node'; +import * as crypto from 'crypto'; import { ClientObjectProperties, ClientOrPluginProperties, @@ -23,7 +24,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider = new vscode.EventEmitter(); readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; private apiTitle?: string; - private selectionChanged: boolean = false; + private initialStateHash: string = ''; constructor( private readonly context: vscode.ExtensionContext, private readonly settingsGetter: () => ExtensionSettings, @@ -168,17 +169,12 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider { this.closeDescription(false); this._descriptionUrl = descriptionUrl; const settings = this.settingsGetter(); await this.loadNodes(settings.clearCache); + this.initialStateHash = this.hashDescription(this.rawRootNode); this.refreshView(); } public get descriptionUrl(): string { @@ -196,7 +192,6 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider this.selectInternal(x, selected, recursive)); @@ -206,7 +201,6 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider Date: Wed, 7 Aug 2024 18:51:37 +0300 Subject: [PATCH 117/150] fix typo issue --- vscode/microsoft-kiota/src/steps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 28fa25ef81..47e44cbd98 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -287,7 +287,7 @@ export async function generateSteps(existingConfiguration: Partial inputPluginOutputPath(input, state); } async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { From c340bbf639f4fe8b77dbf2660644b906619a70e1 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 7 Aug 2024 19:08:58 +0300 Subject: [PATCH 118/150] fix typecase --- vscode/microsoft-kiota/src/steps.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 47e44cbd98..3349292194 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -277,7 +277,7 @@ export async function generateSteps(existingConfiguration: Partial inputPluginType(input, state); } async function inputPluginType(input: MultiStepInput, state: Partial) { - const items = ['Api Plugin','Open AI'].map(x => ({ label: x})as QuickPickItem); + const items = ['API Plugin','Open AI'].map(x => ({ label: x})as QuickPickItem); const pluginTypes = await input.showQuickPick({ title: l10n.t('Choose a plugin type'), step: step++, @@ -287,7 +287,7 @@ export async function generateSteps(existingConfiguration: Partial inputPluginOutputPath(input, state); } async function inputPluginOutputPath(input: MultiStepInput, state: Partial) { From 211335f28e0c5b1f5f038719052eff6f720c6ce0 Mon Sep 17 00:00:00 2001 From: ElinorW Date: Wed, 7 Aug 2024 22:37:24 +0300 Subject: [PATCH 119/150] fix cwd update --- vscode/microsoft-kiota/src/steps.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/vscode/microsoft-kiota/src/steps.ts b/vscode/microsoft-kiota/src/steps.ts index 3349292194..5dfacc34d1 100644 --- a/vscode/microsoft-kiota/src/steps.ts +++ b/vscode/microsoft-kiota/src/steps.ts @@ -128,7 +128,7 @@ export async function generateSteps(existingConfiguration: Partial 0; let workspaceFolder = getWorkspaceJsonDirectory(); const appPackagePath = findAppPackageDirectory(workspaceFolder); @@ -146,7 +146,7 @@ export async function generateSteps(existingConfiguration: Partial inputGenerationType(input, state), () => step-=2); if(!state.workingDirectory){ - state.workingDirectory = state.outputPath as string; + state.workingDirectory = workspaceOpen ? vscode.workspace.workspaceFolders![0].uri.fsPath : state.outputPath as string; } return state; } From c900844a7cec024fd6cabb46dc2d58e12ea9f076 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 12 Aug 2024 10:36:09 -0400 Subject: [PATCH 120/150] chore: bumps extension engine version --- vscode/microsoft-kiota/package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index f001fb8aa4..532c6aff73 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -3,8 +3,8 @@ "displayName": "Microsoft Kiota", "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.16.100000001", - "kiotaVersion": "1.16.0", + "version": "1.17.100000001", + "kiotaVersion": "1.17.0", "telemetryInstrumentationKey": "4c6357e0-daf9-42b5-bdfb-67878f8957b5", "icon": "images/logo.png", "engines": { @@ -470,23 +470,23 @@ "runtimeDependencies": [ { "platformId": "win-x64", - "sha256": "4E1FE93EF66722266D99978DB4B96FA49EACBC7FB8DDC2330384C276EEED8A4F" + "sha256": "103A685302D9F3DC6D87B446414DDE7099F36749959AD3B31506AA306E6106B7" }, { "platformId": "win-x86", - "sha256": "200FE8C8A868AA7C1826923DE62DCD4E1261FEE32D5E02AD86BBB74031C62DB6" + "sha256": "C79D2108129C3187DE14320478AE9588DF100FF5E37270BEBACFBBDC2EF9AEED" }, { "platformId": "linux-x64", - "sha256": "C4CD448622E7EC35CDB66C68A9B01F7726246A3AE07B872ECD1B4980A6D06971" + "sha256": "C8F518D723B8ADFCE699E1E4E03BB3E03A300D9BA4F10558351634396EF3AA1E" }, { "platformId": "osx-x64", - "sha256": "993AFDA8F91B4240D314540DE7B0CEDFF0CACB70DACF17B49A6460A6EA1CFB4E" + "sha256": "8EEFB9BF46871E8830BC59F3A52B0C2F20643F0C094611539A00548C70A2223A" }, { "platformId": "osx-arm64", - "sha256": "1D53A307228F3572BBA7B9A76B2575EE9E057FBCA3C8C1EBC188E4EDFB8DA2B2" + "sha256": "5FE16C08C749ABEB286520A7A2C9E7F62BE4102765486211433CAE6E8252E44F" } ] } From 2178d4716d50aaa8803d3d732c1d72d9588f2702 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 12 Aug 2024 10:38:21 -0400 Subject: [PATCH 121/150] chore: updates lock file --- vscode/microsoft-kiota/package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vscode/microsoft-kiota/package-lock.json b/vscode/microsoft-kiota/package-lock.json index d1b4f0b8c4..924dc550e0 100644 --- a/vscode/microsoft-kiota/package-lock.json +++ b/vscode/microsoft-kiota/package-lock.json @@ -1,12 +1,12 @@ { "name": "kiota", - "version": "1.16.100000001", + "version": "1.17.100000001", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kiota", - "version": "1.16.100000001", + "version": "1.17.100000001", "dependencies": { "@vscode/extension-telemetry": "^0.9.7", "@vscode/l10n": "^0.0.18", From 8fda776a27afaf39a506c0ccd5068ecaac41df78 Mon Sep 17 00:00:00 2001 From: thewahome Date: Tue, 13 Aug 2024 17:46:55 +0300 Subject: [PATCH 122/150] extract kiota status command --- .../src/commands/KiotaStatusCommand.ts | 20 ++ vscode/microsoft-kiota/src/extension.ts | 245 +++++++++--------- 2 files changed, 138 insertions(+), 127 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts diff --git a/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts b/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts new file mode 100644 index 0000000000..b3e8d8b65a --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts @@ -0,0 +1,20 @@ +import * as vscode from "vscode"; + +export class KiotaStatusCommand { + public constructor() { + } + + public async run(): Promise<() => Promise> { + return async () => { + const yesAnswer = vscode.l10n.t("Yes"); + const response = await vscode.window.showInformationMessage( + vscode.l10n.t("Open installation instructions for kiota?"), + yesAnswer, + vscode.l10n.t("No") + ); + if (response === yesAnswer) { + await vscode.env.openExternal(vscode.Uri.parse("https://aka.ms/get/kiota")); + } + }; + } +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 45576ea78b..52730ff284 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -1,35 +1,37 @@ // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below -import * as vscode from "vscode"; import TelemetryReporter from '@vscode/extension-telemetry'; -import * as path from 'path'; import * as fs from 'fs'; -import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider"; +import * as path from 'path'; +import * as vscode from "vscode"; + +import { CodeLensProvider } from "./codelensProvider"; +import { KiotaStatusCommand } from "./commands/KiotaStatusCommand"; +import { KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; +import { DependenciesViewProvider } from "./dependenciesViewProvider"; +import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; +import { generateClient } from "./generateClient"; +import { generatePlugin } from "./generatePlugin"; +import { getKiotaVersion } from "./getKiotaVersion"; +import { getLanguageInformation, getLanguageInformationForDescription } from "./getLanguageInformation"; import { ClientOrPluginProperties, ConsumerOperation, - generationLanguageToString, - getLogEntriesForLevel, KiotaGenerationLanguage, KiotaLogEntry, KiotaPluginType, LogLevel, + generationLanguageToString, + getLogEntriesForLevel, parseGenerationLanguage, parsePluginType, } from "./kiotaInterop"; -import { GenerateState, GenerationType, filterSteps, generateSteps, parseGenerationType, searchSteps } from "./steps"; -import { getKiotaVersion } from "./getKiotaVersion"; +import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider"; import { searchDescription } from "./searchDescription"; -import { generateClient } from "./generateClient"; -import { getLanguageInformation, getLanguageInformationForDescription } from "./getLanguageInformation"; -import { DependenciesViewProvider } from "./dependenciesViewProvider"; +import { GenerateState, GenerationType, filterSteps, generateSteps, parseGenerationType, searchSteps } from "./steps"; import { updateClients } from "./updateClients"; -import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; -import { loadTreeView } from "./workspaceTreeProvider"; -import { generatePlugin } from "./generatePlugin"; -import { CodeLensProvider } from "./codelensProvider"; -import { KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; import { getWorkspaceJsonDirectory, getWorkspaceJsonPath, isClientType, isPluginType, updateTreeViewIcons } from "./util"; +import { loadTreeView } from "./workspaceTreeProvider"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; @@ -55,73 +57,65 @@ export async function activate( const dependenciesInfoProvider = new DependenciesViewProvider( context.extensionUri ); + const kiotaStatusCommand = new KiotaStatusCommand(); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); let codeLensProvider = new CodeLensProvider(); + const handleUri = async (uri: vscode.Uri) => { + if (uri.path === "/") { + return; + } + const queryParameters = getQueryParameters(uri); + if (uri.path.toLowerCase() === "/opendescription") { + reporter.sendTelemetryEvent("DeepLink.OpenDescription"); + const descriptionUrl = queryParameters["descriptionurl"]; + if (descriptionUrl) { + await openTreeViewWithProgress(() => openApiTreeProvider.setDescriptionUrl(descriptionUrl)); + return; + } + } + void vscode.window.showErrorMessage( + vscode.l10n.t("Invalid URL, please check the documentation for the supported URLs") + ); + }; context.subscriptions.push( vscode.window.registerUriHandler({ - handleUri: async (uri: vscode.Uri) => { - if (uri.path === "/") { - return; - } - const queryParameters = getQueryParameters(uri); - if (uri.path.toLowerCase() === "/opendescription") { - reporter.sendTelemetryEvent("DeepLink.OpenDescription"); - const descriptionUrl = queryParameters["descriptionurl"]; - if (descriptionUrl) { - await openTreeViewWithProgress(() => openApiTreeProvider.setDescriptionUrl(descriptionUrl)); - return; - } - } - void vscode.window.showErrorMessage( - vscode.l10n.t("Invalid URL, please check the documentation for the supported URLs") - ); - } + handleUri }), - + vscode.languages.registerCodeLensProvider('json', codeLensProvider), reporter, - registerCommandWithTelemetry(reporter, + registerCommandWithTelemetry(reporter, `${extensionId}.selectLock`, (x) => loadLockFile(x, openApiTreeProvider) ), - registerCommandWithTelemetry(reporter, statusBarCommandId, async () => { - const yesAnswer = vscode.l10n.t("Yes"); - const response = await vscode.window.showInformationMessage( - vscode.l10n.t("Open installation instructions for kiota?"), - yesAnswer, - vscode.l10n.t("No") - ); - if (response === yesAnswer) { - await vscode.env.openExternal(vscode.Uri.parse("https://aka.ms/get/kiota")); - } - }), + registerCommandWithTelemetry(reporter, statusBarCommandId, await kiotaStatusCommand.run()), vscode.window.registerWebviewViewProvider( dependenciesInfo, dependenciesInfoProvider ), vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider), - registerCommandWithTelemetry(reporter, + registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, (x: OpenApiTreeNode) => x.documentationUrl && vscode.env.openExternal(vscode.Uri.parse(x.documentationUrl)) ), - registerCommandWithTelemetry(reporter, + registerCommandWithTelemetry(reporter, `${treeViewId}.addToSelectedEndpoints`, (x: OpenApiTreeNode) => openApiTreeProvider.select(x, true, false) ), - registerCommandWithTelemetry(reporter, + registerCommandWithTelemetry(reporter, `${treeViewId}.addAllToSelectedEndpoints`, (x: OpenApiTreeNode) => openApiTreeProvider.select(x, true, true) ), - registerCommandWithTelemetry(reporter, + registerCommandWithTelemetry(reporter, `${treeViewId}.removeFromSelectedEndpoints`, (x: OpenApiTreeNode) => openApiTreeProvider.select(x, false, false) ), - registerCommandWithTelemetry(reporter, + registerCommandWithTelemetry(reporter, `${treeViewId}.removeAllFromSelectedEndpoints`, (x: OpenApiTreeNode) => openApiTreeProvider.select(x, false, true) ), - registerCommandWithTelemetry(reporter, + registerCommandWithTelemetry(reporter, `${treeViewId}.generateClient`, async () => { const selectedPaths = openApiTreeProvider.getSelectedPaths(); @@ -131,7 +125,7 @@ export async function activate( ); return; } - + let languagesInformation = await getLanguageInformation(context); config = await generateSteps( { @@ -144,8 +138,8 @@ export async function activate( ); const generationType = parseGenerationType(config.generationType); const outputPath = typeof config.outputPath === "string" - ? config.outputPath - : "./output"; + ? config.outputPath + : "./output"; await showUpgradeWarningMessage(outputPath, context); if (!openApiTreeProvider.descriptionUrl) { await vscode.window.showErrorMessage( @@ -153,7 +147,7 @@ export async function activate( ); return; } - + const settings = getExtensionSettings(extensionId); workspaceGenerationType = config.generationType as string; let result; @@ -191,13 +185,13 @@ export async function activate( vscode.workspace.onDidChangeWorkspaceFolders(async () => { const generatedOutput = context.workspaceState.get('generatedOutput'); if (generatedOutput) { - const { outputPath} = generatedOutput; + const { outputPath } = generatedOutput; await displayGenerationResults(context, openApiTreeProvider, config, outputPath); // Clear the state void context.workspaceState.update('generatedOutput', undefined); } }), - registerCommandWithTelemetry(reporter, + registerCommandWithTelemetry(reporter, `${treeViewId}.searchOrOpenApiDescription`, async () => { const yesAnswer = vscode.l10n.t("Yes, override it"); @@ -205,13 +199,13 @@ export async function activate( const response = await vscode.window.showWarningMessage( vscode.l10n.t( "Before adding a new API description, consider that your changes and current selection will be lost."), - yesAnswer, - vscode.l10n.t("Cancel") + yesAnswer, + vscode.l10n.t("Cancel") ); if (response !== yesAnswer) { - return; + return; } - } + } const config = await searchSteps(x => vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, @@ -225,15 +219,14 @@ export async function activate( } } ), - registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, async () => - { + registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, async () => { const yesAnswer = vscode.l10n.t("Yes"); const response = await vscode.window.showInformationMessage( vscode.l10n.t("Do you want to remove this API description?"), yesAnswer, vscode.l10n.t("No") ); - if(response === yesAnswer) { + if (response === yesAnswer) { openApiTreeProvider.closeDescription(); await updateTreeViewIcons(treeViewId, false); } @@ -245,50 +238,50 @@ export async function activate( } ), registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { - clientOrPluginKey = clientKey; - clientOrPluginObject = clientObject; - workspaceGenerationType = generationType; - await loadEditPaths(clientOrPluginKey, clientObject, openApiTreeProvider); - openApiTreeProvider.resetInitialState(); - await updateTreeViewIcons(treeViewId, false, true); + clientOrPluginKey = clientKey; + clientOrPluginObject = clientObject; + workspaceGenerationType = generationType; + await loadEditPaths(clientOrPluginKey, clientObject, openApiTreeProvider); + openApiTreeProvider.resetInitialState(); + await updateTreeViewIcons(treeViewId, false, true); }), - registerCommandWithTelemetry(reporter,`${treeViewId}.regenerateButton`, async () => { + registerCommandWithTelemetry(reporter, `${treeViewId}.regenerateButton`, async () => { if (!clientOrPluginKey || clientOrPluginKey === '') { clientOrPluginKey = config.clientClassName || config.pluginName || ''; } if (!config) { config = { outputPath: clientOrPluginObject.outputPath, - clientClassName: clientOrPluginKey, + clientClassName: clientOrPluginKey, }; - } - const settings = getExtensionSettings(extensionId); + } + const settings = getExtensionSettings(extensionId); const selectedPaths = openApiTreeProvider.getSelectedPaths(); - if (selectedPaths.length === 0) { - await vscode.window.showErrorMessage( - vscode.l10n.t("No endpoints selected, select endpoints first") - ); - return; - } - if(isClientType(workspaceGenerationType)) { - await regenerateClient(clientOrPluginKey, config, settings, selectedPaths); - } - if (isPluginType(workspaceGenerationType)) { - await regeneratePlugin(clientOrPluginKey, config, settings, selectedPaths); - } + if (selectedPaths.length === 0) { + await vscode.window.showErrorMessage( + vscode.l10n.t("No endpoints selected, select endpoints first") + ); + return; + } + if (isClientType(workspaceGenerationType)) { + await regenerateClient(clientOrPluginKey, config, settings, selectedPaths); + } + if (isPluginType(workspaceGenerationType)) { + await regeneratePlugin(clientOrPluginKey, config, settings, selectedPaths); + } }), registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { - const settings = getExtensionSettings(extensionId); + const settings = getExtensionSettings(extensionId); const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(KIOTA_WORKSPACE_FILE)); if (workspaceJson && workspaceJson.isDirty) { - await vscode.window.showInformationMessage( - vscode.l10n.t("Please save the workspace.json file before re-generation."), - vscode.l10n.t("OK") - ); - return; + await vscode.window.showInformationMessage( + vscode.l10n.t("Please save the workspace.json file before re-generation."), + vscode.l10n.t("OK") + ); + return; } if (isClientType(generationType)) { - await regenerateClient(clientKey, clientObject, settings); + await regenerateClient(clientKey, clientObject, settings); } if (isPluginType(generationType)) { await regeneratePlugin(clientKey, clientObject, settings); @@ -296,7 +289,7 @@ export async function activate( }), ); - async function generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { + async function generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { const pluginTypes = KiotaPluginType.ApiManifest; const result = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, @@ -330,13 +323,12 @@ export async function activate( }); return result; }); - if (result) - { + if (result) { await exportLogsAndShowErrors(result); } return result; } - async function generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { + async function generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { const pluginTypes = Array.isArray(config.pluginTypes) ? parsePluginType(config.pluginTypes) : [KiotaPluginType.ApiPlugin]; const result = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, @@ -370,17 +362,16 @@ export async function activate( }); return result; }); - if (result) - { + if (result) { await exportLogsAndShowErrors(result); } return result; } - async function generateClientAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { + async function generateClientAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { const language = - typeof config.language === "string" - ? parseGenerationLanguage(config.language) - : KiotaGenerationLanguage.CSharp; + typeof config.language === "string" + ? parseGenerationLanguage(config.language) + : KiotaGenerationLanguage.CSharp; const result = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, @@ -422,7 +413,7 @@ export async function activate( }); return result; }); - + let languagesInformation = await getLanguageInformationForDescription( context, openApiTreeProvider.descriptionUrl, @@ -432,8 +423,7 @@ export async function activate( dependenciesInfoProvider.update(languagesInformation, language); await vscode.commands.executeCommand(treeViewFocusCommand); } - if (result) - { + if (result) { await exportLogsAndShowErrors(result); } return result; @@ -443,24 +433,24 @@ export async function activate( const clientNameOrPluginName = config.clientClassName || config.pluginName; openApiTreeProvider.refreshView(); const workspaceJsonPath = getWorkspaceJsonPath(); - await loadLockFile({fsPath: workspaceJsonPath}, openApiTreeProvider, clientNameOrPluginName ); + await loadLockFile({ fsPath: workspaceJsonPath }, openApiTreeProvider, clientNameOrPluginName); await vscode.commands.executeCommand('kiota.workspace.refresh'); openApiTreeProvider.resetInitialState(); await updateTreeViewIcons(treeViewId, false, true); } - async function regenerateClient(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]): Promise { + async function regenerateClient(clientKey: string, clientObject: any, settings: ExtensionSettings, selectedPaths?: string[]): Promise { const language = - typeof clientObject.language === "string" - ? parseGenerationLanguage(clientObject.language) - : KiotaGenerationLanguage.CSharp; - await vscode.window.withProgress({ + typeof clientObject.language === "string" + ? parseGenerationLanguage(clientObject.language) + : KiotaGenerationLanguage.CSharp; + await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, - title: vscode.l10n.t("Re-generating client...") + title: vscode.l10n.t("Re-generating client...") }, async (progress, _) => { const result = await generateClient( context, - clientObject.descriptionLocation ? clientObject.descriptionLocation: openApiTreeProvider.descriptionUrl, + clientObject.descriptionLocation ? clientObject.descriptionLocation : openApiTreeProvider.descriptionUrl, clientObject.outputPath, language, selectedPaths ? selectedPaths : clientObject.includePatterns, @@ -470,21 +460,21 @@ export async function activate( clientObject.usesBackingStore ? clientObject.usesBackingStore : settings.backingStore, true, // clearCache true, // cleanOutput - clientObject.excludeBackwardCompatible ? clientObject.excludeBackwardCompatible : settings.excludeBackwardCompatible , - clientObject.disabledValidationRules ? clientObject.disabledValidationRules : settings.disableValidationRules, + clientObject.excludeBackwardCompatible ? clientObject.excludeBackwardCompatible : settings.excludeBackwardCompatible, + clientObject.disabledValidationRules ? clientObject.disabledValidationRules : settings.disableValidationRules, settings.languagesSerializationConfiguration[language].serializers, settings.languagesSerializationConfiguration[language].deserializers, clientObject.structuredMimeTypes ? clientObject.structuredMimeTypes : settings.structuredMimeTypes, clientObject.includeAdditionalData ? clientObject.includeAdditionalData : settings.includeAdditionalData, ConsumerOperation.Edit - ); - return result; + ); + return result; }); - void vscode.window.showInformationMessage(`Client ${clientKey} re-generated successfully.`); - openApiTreeProvider.resetInitialState(); + void vscode.window.showInformationMessage(`Client ${clientKey} re-generated successfully.`); + openApiTreeProvider.resetInitialState(); } - async function regeneratePlugin(clientKey: string, clientObject:any, settings: ExtensionSettings, selectedPaths?: string[]) { - const pluginTypes = Array.isArray(clientObject.types) ? parsePluginType(clientObject.types) : [KiotaPluginType.ApiPlugin]; + async function regeneratePlugin(clientKey: string, clientObject: any, settings: ExtensionSettings, selectedPaths?: string[]) { + const pluginTypes = Array.isArray(clientObject.types) ? parsePluginType(clientObject.types) : [KiotaPluginType.ApiPlugin]; await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, @@ -493,7 +483,7 @@ export async function activate( const start = performance.now(); const result = await generatePlugin( context, - clientObject.descriptionLocation ? clientObject.descriptionLocation: openApiTreeProvider.descriptionUrl, + clientObject.descriptionLocation ? clientObject.descriptionLocation : openApiTreeProvider.descriptionUrl, clientObject.outputPath, pluginTypes, selectedPaths ? selectedPaths : clientObject.includePatterns, @@ -579,6 +569,7 @@ export async function activate( context.subscriptions.push(disposable); } + function openTreeViewWithProgress(callback: () => Promise): Thenable { return vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, @@ -602,11 +593,11 @@ function registerCommandWithTelemetry(reporter: TelemetryReporter, command: stri async function showUpgradeWarningMessage(clientPath: string, context: vscode.ExtensionContext): Promise { const kiotaVersion = context.extension.packageJSON.kiotaVersion.toLocaleLowerCase(); const lockFilePath = path.join(clientPath, KIOTA_WORKSPACE_FILE); - if(!fs.existsSync(lockFilePath)) { + if (!fs.existsSync(lockFilePath)) { return; } const lockFileData = await vscode.workspace.fs.readFile(vscode.Uri.file(lockFilePath)); - const lockFile = JSON.parse(lockFileData.toString()) as {kiotaVersion: string}; + const lockFile = JSON.parse(lockFileData.toString()) as { kiotaVersion: string }; const clientVersion = lockFile.kiotaVersion.toLocaleLowerCase(); if (clientVersion.toLocaleLowerCase() !== kiotaVersion) { await vscode.window.showWarningMessage(vscode.l10n.t("Client will be upgraded from version {0} to {1}, upgrade your dependencies", clientVersion, kiotaVersion)); @@ -622,7 +613,7 @@ async function loadEditPaths(clientOrPluginKey: string, clientObject: any, openA await openTreeViewWithProgress(() => openApiTreeProvider.loadEditPaths(clientOrPluginKey, clientObject)); } -async function exportLogsAndShowErrors(result: KiotaLogEntry[]) : Promise { +async function exportLogsAndShowErrors(result: KiotaLogEntry[]): Promise { const errorMessages = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error) : []; @@ -701,4 +692,4 @@ async function checkForSuccess(results: KiotaLogEntry[]) { // This method is called when your extension is deactivated -export function deactivate() {} +export function deactivate() { } From b587e7052725b22b54e3b1cd5ff54b939bbc84c3 Mon Sep 17 00:00:00 2001 From: thewahome Date: Tue, 13 Aug 2024 17:58:33 +0300 Subject: [PATCH 123/150] extract open api tree node commands --- .../src/commands/OpenApiTreeNodeCommand.ts | 13 +++++++++++++ vscode/microsoft-kiota/src/extension.ts | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 vscode/microsoft-kiota/src/commands/OpenApiTreeNodeCommand.ts diff --git a/vscode/microsoft-kiota/src/commands/OpenApiTreeNodeCommand.ts b/vscode/microsoft-kiota/src/commands/OpenApiTreeNodeCommand.ts new file mode 100644 index 0000000000..ba8e111fd9 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/OpenApiTreeNodeCommand.ts @@ -0,0 +1,13 @@ +import * as vscode from "vscode"; +import { OpenApiTreeNode } from "../openApiTreeProvider"; + +export class OpenApiTreeNodeCommand { + constructor() { } + + public openDocumentPage(openApiTreeNode: OpenApiTreeNode) { + if (openApiTreeNode.documentationUrl) { + vscode.env.openExternal(vscode.Uri.parse(openApiTreeNode.documentationUrl)); + } + } + +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 52730ff284..567e062eb4 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -7,6 +7,8 @@ import * as vscode from "vscode"; import { CodeLensProvider } from "./codelensProvider"; import { KiotaStatusCommand } from "./commands/KiotaStatusCommand"; +import { OpenApiTreeNodeCommand } from "./commands/OpenApiTreeNodeCommand"; + import { KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; import { DependenciesViewProvider } from "./dependenciesViewProvider"; import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; @@ -58,6 +60,8 @@ export async function activate( context.extensionUri ); const kiotaStatusCommand = new KiotaStatusCommand(); + const openApiTreeNodeCommand = new OpenApiTreeNodeCommand(); + const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); let codeLensProvider = new CodeLensProvider(); @@ -97,7 +101,7 @@ export async function activate( vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider), registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, - (x: OpenApiTreeNode) => x.documentationUrl && vscode.env.openExternal(vscode.Uri.parse(x.documentationUrl)) + (x: OpenApiTreeNode) => openApiTreeNodeCommand.openDocumentPage(x) ), registerCommandWithTelemetry(reporter, `${treeViewId}.addToSelectedEndpoints`, From 06e61fadd94571e21f1ae959dd734de033d009cd Mon Sep 17 00:00:00 2001 From: thewahome Date: Tue, 13 Aug 2024 18:49:05 +0300 Subject: [PATCH 124/150] generate command extraction --- .../src/commands/GenerateCommand.ts | 260 +++++++++++++++ .../src/commands/GeneratedOutputState.ts | 4 + vscode/microsoft-kiota/src/extension.ts | 314 +----------------- vscode/microsoft-kiota/src/utilities/file.ts | 28 ++ .../microsoft-kiota/src/utilities/logging.ts | 48 +++ .../src/utilities/messaging.ts | 24 ++ 6 files changed, 380 insertions(+), 298 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/GenerateCommand.ts create mode 100644 vscode/microsoft-kiota/src/commands/GeneratedOutputState.ts create mode 100644 vscode/microsoft-kiota/src/utilities/file.ts create mode 100644 vscode/microsoft-kiota/src/utilities/logging.ts create mode 100644 vscode/microsoft-kiota/src/utilities/messaging.ts diff --git a/vscode/microsoft-kiota/src/commands/GenerateCommand.ts b/vscode/microsoft-kiota/src/commands/GenerateCommand.ts new file mode 100644 index 0000000000..3e346d7e43 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/GenerateCommand.ts @@ -0,0 +1,260 @@ +import * as vscode from "vscode"; +import { ExtensionContext } from "vscode"; + +import { extensionId, treeViewFocusCommand, treeViewId } from "../constants"; +import { DependenciesViewProvider } from '../dependenciesViewProvider'; +import { ExtensionSettings, getExtensionSettings } from "../extensionSettings"; +import { generateClient } from '../generateClient'; +import { generatePlugin } from '../generatePlugin'; +import { getLanguageInformation, getLanguageInformationForDescription } from "../getLanguageInformation"; +import { + ConsumerOperation, + getLogEntriesForLevel, KiotaGenerationLanguage, KiotaLogEntry, KiotaPluginType, + LogLevel, parseGenerationLanguage, parsePluginType +} from "../kiotaInterop"; +import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { GenerateState, generateSteps, GenerationType, parseGenerationType } from "../steps"; +import { getWorkspaceJsonDirectory, getWorkspaceJsonPath, updateTreeViewIcons } from "../util"; +import { exportLogsAndShowErrors } from '../utilities/logging'; +import { showUpgradeWarningMessage } from "../utilities/messaging"; +import { GeneratedOutputState } from './GeneratedOutputState'; +import { loadLockFile } from "../utilities/file"; + +export class GenerateCommand { + private _context: ExtensionContext; + private _openApiTreeProvider: OpenApiTreeProvider; + + constructor(context: ExtensionContext) { + this._context = context; + this._openApiTreeProvider = new OpenApiTreeProvider(this._context, () => getExtensionSettings(extensionId)); + } + + public async run() { + const selectedPaths = this._openApiTreeProvider.getSelectedPaths(); + if (selectedPaths.length === 0) { + await vscode.window.showErrorMessage( + vscode.l10n.t("No endpoints selected, select endpoints first") + ); + return; + } + + let languagesInformation = await getLanguageInformation(this._context); + let config: Partial; + config = await generateSteps( + { + clientClassName: this._openApiTreeProvider.clientClassName, + clientNamespaceName: this._openApiTreeProvider.clientNamespaceName, + language: this._openApiTreeProvider.language, + outputPath: this._openApiTreeProvider.outputPath, + }, + languagesInformation + ); + const generationType = parseGenerationType(config.generationType); + const outputPath = typeof config.outputPath === "string" + ? config.outputPath + : "./output"; + await showUpgradeWarningMessage(this._context, outputPath); + if (!this._openApiTreeProvider.descriptionUrl) { + await vscode.window.showErrorMessage( + vscode.l10n.t("No description found, select a description first") + ); + return; + } + + const settings = getExtensionSettings(extensionId); + let result; + switch (generationType) { + case GenerationType.Client: + result = await this.generateClientAndRefreshUI(config, settings, outputPath, selectedPaths); + break; + case GenerationType.Plugin: + result = await this.generatePluginAndRefreshUI(config, settings, outputPath, selectedPaths); + break; + case GenerationType.ApiManifest: + result = await this.generateManifestAndRefreshUI(config, settings, outputPath, selectedPaths); + break; + default: + await vscode.window.showErrorMessage( + vscode.l10n.t("Invalid generation type") + ); + return; + } + if (result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) { + // Save state before opening the new window + void this._context.workspaceState.update('generatedOutput', { + outputPath, + config, + clientClassName: config.clientClassName || config.pluginName + } as GeneratedOutputState); + if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) { + await vscode.commands.executeCommand('vscode.openFolder', vscode.Uri.file(config.workingDirectory ?? getWorkspaceJsonDirectory()), true); + } else { + await this.displayGenerationResults(config, outputPath); + } + } + } + + public async displayGenerationResults(config: Partial, _outputPath: string) { + const clientNameOrPluginName = config.clientClassName || config.pluginName; + this._openApiTreeProvider.refreshView(); + const workspaceJsonPath = getWorkspaceJsonPath(); + await loadLockFile({ fsPath: workspaceJsonPath }, this._openApiTreeProvider, clientNameOrPluginName); + await vscode.commands.executeCommand('kiota.workspace.refresh'); + this._openApiTreeProvider.resetInitialState(); + await updateTreeViewIcons(treeViewId, false, true); + } + + async generateClientAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { + const language = + typeof config.language === "string" + ? parseGenerationLanguage(config.language) + : KiotaGenerationLanguage.CSharp; + const result = await vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Generating client...") + }, async (progress, _) => { + const start = performance.now(); + const result = await generateClient( + this._context, + this._openApiTreeProvider.descriptionUrl, + outputPath, + language, + selectedPaths, + [], + typeof config.clientClassName === "string" + ? config.clientClassName + : "ApiClient", + typeof config.clientNamespaceName === "string" + ? config.clientNamespaceName + : "ApiSdk", + settings.backingStore, + settings.clearCache, + settings.cleanOutput, + settings.excludeBackwardCompatible, + settings.disableValidationRules, + settings.languagesSerializationConfiguration[language].serializers, + settings.languagesSerializationConfiguration[language].deserializers, + settings.structuredMimeTypes, + settings.includeAdditionalData, + ConsumerOperation.Add, + config.workingDirectory + ); + // TODO: uncomment when telemetry is implemented + + /* + const duration = performance.now() - start; + const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; + + reporter.sendRawTelemetryEvent(`${extensionId}.generateClient.completed`, { + "language": generationLanguageToString(language), + "errorsCount": errorsCount.toString(), + }, { + "duration": duration, + }); */ + return result; + }); + + let languagesInformation = await getLanguageInformationForDescription( + this._context, + this._openApiTreeProvider.descriptionUrl, + settings.clearCache + ); + if (languagesInformation) { + const dependenciesInfoProvider = new DependenciesViewProvider( + this._context.extensionUri + ); + dependenciesInfoProvider.update(languagesInformation, language); + await vscode.commands.executeCommand(treeViewFocusCommand); + } + if (result) { + await exportLogsAndShowErrors(result); + } + return result; + } + + async generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { + const pluginTypes = Array.isArray(config.pluginTypes) ? parsePluginType(config.pluginTypes) : [KiotaPluginType.ApiPlugin]; + const result = await vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Generating plugin...") + }, async (progress, _) => { + const start = performance.now(); + const result = await generatePlugin( + this._context, + this._openApiTreeProvider.descriptionUrl, + outputPath, + pluginTypes, + selectedPaths, + [], + typeof config.pluginName === "string" + ? config.pluginName + : "ApiClient", + settings.clearCache, + settings.cleanOutput, + settings.disableValidationRules, + ConsumerOperation.Add, + config.workingDirectory + ); + /* + // TODO: uncomment when telemetry is implemented + + const duration = performance.now() - start; + const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; + reporter.sendRawTelemetryEvent(`${extensionId}.generatePlugin.completed`, { + "pluginType": pluginTypes.toString(), + "errorsCount": errorsCount.toString(), + }, { + "duration": duration, + }); + */ + return result; + }); + if (result) { + await exportLogsAndShowErrors(result); + } + return result; + } + + async generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { + const pluginTypes = KiotaPluginType.ApiManifest; + const result = await vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Generating manifest...") + }, async (progress, _) => { + const start = performance.now(); + const result = await generatePlugin( + this._context, + this._openApiTreeProvider.descriptionUrl, + outputPath, + [pluginTypes], + selectedPaths, + [], + typeof config.pluginName === "string" + ? config.pluginName + : "ApiClient", + settings.clearCache, + settings.cleanOutput, + settings.disableValidationRules, + ConsumerOperation.Add, + config.workingDirectory + ); + // TODO: uncomment when telemetry is implemented + /* const duration = performance.now() - start; + const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; + reporter.sendRawTelemetryEvent(`${extensionId}.generateManifest.completed`, { + "pluginType": pluginTypes.toString(), + "errorsCount": errorsCount.toString(), + }, { + "duration": duration, + }); */ + return result; + }); + if (result) { + await exportLogsAndShowErrors(result); + } + return result; + } +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/commands/GeneratedOutputState.ts b/vscode/microsoft-kiota/src/commands/GeneratedOutputState.ts new file mode 100644 index 0000000000..58bbf97446 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/GeneratedOutputState.ts @@ -0,0 +1,4 @@ +export interface GeneratedOutputState { + outputPath: string; + clientClassName: string; +} diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 567e062eb4..215f4af98f 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -1,7 +1,7 @@ // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below import TelemetryReporter from '@vscode/extension-telemetry'; -import * as fs from 'fs'; + import * as path from 'path'; import * as vscode from "vscode"; @@ -9,13 +9,14 @@ import { CodeLensProvider } from "./codelensProvider"; import { KiotaStatusCommand } from "./commands/KiotaStatusCommand"; import { OpenApiTreeNodeCommand } from "./commands/OpenApiTreeNodeCommand"; -import { KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; +import { GenerateCommand } from './commands/GenerateCommand'; +import { GeneratedOutputState } from './commands/GeneratedOutputState'; +import { KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewId } from "./constants"; import { DependenciesViewProvider } from "./dependenciesViewProvider"; import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; import { generateClient } from "./generateClient"; import { generatePlugin } from "./generatePlugin"; import { getKiotaVersion } from "./getKiotaVersion"; -import { getLanguageInformation, getLanguageInformationForDescription } from "./getLanguageInformation"; import { ClientOrPluginProperties, ConsumerOperation, @@ -23,45 +24,40 @@ import { KiotaLogEntry, KiotaPluginType, LogLevel, - generationLanguageToString, getLogEntriesForLevel, parseGenerationLanguage, - parsePluginType, + parsePluginType } from "./kiotaInterop"; import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider"; import { searchDescription } from "./searchDescription"; -import { GenerateState, GenerationType, filterSteps, generateSteps, parseGenerationType, searchSteps } from "./steps"; +import { GenerateState, filterSteps, searchSteps } from "./steps"; import { updateClients } from "./updateClients"; -import { getWorkspaceJsonDirectory, getWorkspaceJsonPath, isClientType, isPluginType, updateTreeViewIcons } from "./util"; +import { isClientType, isPluginType, updateTreeViewIcons } from "./util"; +import { loadLockFile, openTreeViewWithProgress } from './utilities/file'; +import { exportLogsAndShowErrors, kiotaOutputChannel } from './utilities/logging'; +import { showUpgradeWarningMessage } from './utilities/messaging'; import { loadTreeView } from "./workspaceTreeProvider"; let kiotaStatusBarItem: vscode.StatusBarItem; -let kiotaOutputChannel: vscode.LogOutputChannel; let clientOrPluginKey: string; let clientOrPluginObject: ClientOrPluginProperties; let workspaceGenerationType: string; let config: Partial; -interface GeneratedOutputState { - outputPath: string; - clientClassName: string; -} // This method is called when your extension is activated // Your extension is activated the very first time the command is executed export async function activate( context: vscode.ExtensionContext ): Promise { - kiotaOutputChannel = vscode.window.createOutputChannel("Kiota", { - log: true, - }); const openApiTreeProvider = new OpenApiTreeProvider(context, () => getExtensionSettings(extensionId)); const dependenciesInfoProvider = new DependenciesViewProvider( context.extensionUri ); const kiotaStatusCommand = new KiotaStatusCommand(); const openApiTreeNodeCommand = new OpenApiTreeNodeCommand(); - + const generateCommand = new GenerateCommand(context); + const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); let codeLensProvider = new CodeLensProvider(); @@ -120,77 +116,13 @@ export async function activate( (x: OpenApiTreeNode) => openApiTreeProvider.select(x, false, true) ), registerCommandWithTelemetry(reporter, - `${treeViewId}.generateClient`, - async () => { - const selectedPaths = openApiTreeProvider.getSelectedPaths(); - if (selectedPaths.length === 0) { - await vscode.window.showErrorMessage( - vscode.l10n.t("No endpoints selected, select endpoints first") - ); - return; - } - - let languagesInformation = await getLanguageInformation(context); - config = await generateSteps( - { - clientClassName: openApiTreeProvider.clientClassName, - clientNamespaceName: openApiTreeProvider.clientNamespaceName, - language: openApiTreeProvider.language, - outputPath: openApiTreeProvider.outputPath, - }, - languagesInformation - ); - const generationType = parseGenerationType(config.generationType); - const outputPath = typeof config.outputPath === "string" - ? config.outputPath - : "./output"; - await showUpgradeWarningMessage(outputPath, context); - if (!openApiTreeProvider.descriptionUrl) { - await vscode.window.showErrorMessage( - vscode.l10n.t("No description found, select a description first") - ); - return; - } - - const settings = getExtensionSettings(extensionId); - workspaceGenerationType = config.generationType as string; - let result; - switch (generationType) { - case GenerationType.Client: - result = await generateClientAndRefreshUI(config, settings, outputPath, selectedPaths); - break; - case GenerationType.Plugin: - result = await generatePluginAndRefreshUI(config, settings, outputPath, selectedPaths); - break; - case GenerationType.ApiManifest: - result = await generateManifestAndRefreshUI(config, settings, outputPath, selectedPaths); - break; - default: - await vscode.window.showErrorMessage( - vscode.l10n.t("Invalid generation type") - ); - return; - } - if (result && getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length === 0) { - // Save state before opening the new window - void context.workspaceState.update('generatedOutput', { - outputPath, - config, - clientClassName: config.clientClassName || config.pluginName - } as GeneratedOutputState); - if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) { - await vscode.commands.executeCommand('vscode.openFolder', vscode.Uri.file(config.workingDirectory ?? getWorkspaceJsonDirectory()), true); - } else { - await displayGenerationResults(context, openApiTreeProvider, config, outputPath); - } - } - } + `${treeViewId}.generateClient`, () => generateCommand.run() ), vscode.workspace.onDidChangeWorkspaceFolders(async () => { const generatedOutput = context.workspaceState.get('generatedOutput'); if (generatedOutput) { const { outputPath } = generatedOutput; - await displayGenerationResults(context, openApiTreeProvider, config, outputPath); + await generateCommand.displayGenerationResults(config, outputPath); // Clear the state void context.workspaceState.update('generatedOutput', undefined); } @@ -293,155 +225,6 @@ export async function activate( }), ); - async function generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { - const pluginTypes = KiotaPluginType.ApiManifest; - const result = await vscode.window.withProgress({ - location: vscode.ProgressLocation.Notification, - cancellable: false, - title: vscode.l10n.t("Generating manifest...") - }, async (progress, _) => { - const start = performance.now(); - const result = await generatePlugin( - context, - openApiTreeProvider.descriptionUrl, - outputPath, - [pluginTypes], - selectedPaths, - [], - typeof config.pluginName === "string" - ? config.pluginName - : "ApiClient", - settings.clearCache, - settings.cleanOutput, - settings.disableValidationRules, - ConsumerOperation.Add, - config.workingDirectory - ); - const duration = performance.now() - start; - const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; - reporter.sendRawTelemetryEvent(`${extensionId}.generateManifest.completed`, { - "pluginType": pluginTypes.toString(), - "errorsCount": errorsCount.toString(), - }, { - "duration": duration, - }); - return result; - }); - if (result) { - await exportLogsAndShowErrors(result); - } - return result; - } - async function generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { - const pluginTypes = Array.isArray(config.pluginTypes) ? parsePluginType(config.pluginTypes) : [KiotaPluginType.ApiPlugin]; - const result = await vscode.window.withProgress({ - location: vscode.ProgressLocation.Notification, - cancellable: false, - title: vscode.l10n.t("Generating plugin...") - }, async (progress, _) => { - const start = performance.now(); - const result = await generatePlugin( - context, - openApiTreeProvider.descriptionUrl, - outputPath, - pluginTypes, - selectedPaths, - [], - typeof config.pluginName === "string" - ? config.pluginName - : "ApiClient", - settings.clearCache, - settings.cleanOutput, - settings.disableValidationRules, - ConsumerOperation.Add, - config.workingDirectory - ); - const duration = performance.now() - start; - const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; - reporter.sendRawTelemetryEvent(`${extensionId}.generatePlugin.completed`, { - "pluginType": pluginTypes.toString(), - "errorsCount": errorsCount.toString(), - }, { - "duration": duration, - }); - return result; - }); - if (result) { - await exportLogsAndShowErrors(result); - } - return result; - } - async function generateClientAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { - const language = - typeof config.language === "string" - ? parseGenerationLanguage(config.language) - : KiotaGenerationLanguage.CSharp; - const result = await vscode.window.withProgress({ - location: vscode.ProgressLocation.Notification, - cancellable: false, - title: vscode.l10n.t("Generating client...") - }, async (progress, _) => { - const start = performance.now(); - const result = await generateClient( - context, - openApiTreeProvider.descriptionUrl, - outputPath, - language, - selectedPaths, - [], - typeof config.clientClassName === "string" - ? config.clientClassName - : "ApiClient", - typeof config.clientNamespaceName === "string" - ? config.clientNamespaceName - : "ApiSdk", - settings.backingStore, - settings.clearCache, - settings.cleanOutput, - settings.excludeBackwardCompatible, - settings.disableValidationRules, - settings.languagesSerializationConfiguration[language].serializers, - settings.languagesSerializationConfiguration[language].deserializers, - settings.structuredMimeTypes, - settings.includeAdditionalData, - ConsumerOperation.Add, - config.workingDirectory - ); - const duration = performance.now() - start; - const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; - reporter.sendRawTelemetryEvent(`${extensionId}.generateClient.completed`, { - "language": generationLanguageToString(language), - "errorsCount": errorsCount.toString(), - }, { - "duration": duration, - }); - return result; - }); - - let languagesInformation = await getLanguageInformationForDescription( - context, - openApiTreeProvider.descriptionUrl, - settings.clearCache - ); - if (languagesInformation) { - dependenciesInfoProvider.update(languagesInformation, language); - await vscode.commands.executeCommand(treeViewFocusCommand); - } - if (result) { - await exportLogsAndShowErrors(result); - } - return result; - } - - async function displayGenerationResults(context: vscode.ExtensionContext, openApiTreeProvider: OpenApiTreeProvider, config: any, outputPath: string) { - const clientNameOrPluginName = config.clientClassName || config.pluginName; - openApiTreeProvider.refreshView(); - const workspaceJsonPath = getWorkspaceJsonPath(); - await loadLockFile({ fsPath: workspaceJsonPath }, openApiTreeProvider, clientNameOrPluginName); - await vscode.commands.executeCommand('kiota.workspace.refresh'); - openApiTreeProvider.resetInitialState(); - await updateTreeViewIcons(treeViewId, false, true); - } async function regenerateClient(clientKey: string, clientObject: any, settings: ExtensionSettings, selectedPaths?: string[]): Promise { const language = typeof clientObject.language === "string" @@ -536,7 +319,7 @@ export async function activate( } const existingLockFileUris = await vscode.workspace.findFiles(`**/${KIOTA_WORKSPACE_FILE}`); if (existingLockFileUris.length > 0) { - await Promise.all(existingLockFileUris.map(x => path.dirname(x.fsPath)).map(x => showUpgradeWarningMessage(x, context))); + await Promise.all(existingLockFileUris.map(x => path.dirname(x.fsPath)).map(x => showUpgradeWarningMessage(context, x))); } await updateStatusBarItem(context); try { @@ -574,17 +357,7 @@ export async function activate( context.subscriptions.push(disposable); } -function openTreeViewWithProgress(callback: () => Promise): Thenable { - return vscode.window.withProgress({ - location: vscode.ProgressLocation.Notification, - cancellable: false, - title: vscode.l10n.t("Loading...") - }, async (progress, _) => { - const result = await callback(); - await vscode.commands.executeCommand(treeViewFocusCommand); - return result; - }); -} + function registerCommandWithTelemetry(reporter: TelemetryReporter, command: string, callback: (...args: any[]) => any, thisArg?: any): vscode.Disposable { return vscode.commands.registerCommand(command, (...args: any[]) => { const splatCommand = command.split('/'); @@ -594,65 +367,10 @@ function registerCommandWithTelemetry(reporter: TelemetryReporter, command: stri }, thisArg); } -async function showUpgradeWarningMessage(clientPath: string, context: vscode.ExtensionContext): Promise { - const kiotaVersion = context.extension.packageJSON.kiotaVersion.toLocaleLowerCase(); - const lockFilePath = path.join(clientPath, KIOTA_WORKSPACE_FILE); - if (!fs.existsSync(lockFilePath)) { - return; - } - const lockFileData = await vscode.workspace.fs.readFile(vscode.Uri.file(lockFilePath)); - const lockFile = JSON.parse(lockFileData.toString()) as { kiotaVersion: string }; - const clientVersion = lockFile.kiotaVersion.toLocaleLowerCase(); - if (clientVersion.toLocaleLowerCase() !== kiotaVersion) { - await vscode.window.showWarningMessage(vscode.l10n.t("Client will be upgraded from version {0} to {1}, upgrade your dependencies", clientVersion, kiotaVersion)); - } -} - -async function loadLockFile(node: { fsPath: string }, openApiTreeProvider: OpenApiTreeProvider, clientOrPluginName?: string): Promise { - await openTreeViewWithProgress(() => openApiTreeProvider.loadLockFile(node.fsPath, clientOrPluginName)); - await updateTreeViewIcons(treeViewId, true); -} - async function loadEditPaths(clientOrPluginKey: string, clientObject: any, openApiTreeProvider: OpenApiTreeProvider): Promise { await openTreeViewWithProgress(() => openApiTreeProvider.loadEditPaths(clientOrPluginKey, clientObject)); } -async function exportLogsAndShowErrors(result: KiotaLogEntry[]): Promise { - const errorMessages = result - ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error) - : []; - - result.forEach((element) => { - logFromLogLevel(element); - }); - if (errorMessages.length > 0) { - await Promise.all(errorMessages.map((element) => { - return vscode.window.showErrorMessage(element.message); - })); - } -} - -function logFromLogLevel(entry: KiotaLogEntry): void { - switch (entry.level) { - case LogLevel.critical: - case LogLevel.error: - kiotaOutputChannel.error(entry.message); - break; - case LogLevel.warning: - kiotaOutputChannel.warn(entry.message); - break; - case LogLevel.debug: - kiotaOutputChannel.debug(entry.message); - break; - case LogLevel.trace: - kiotaOutputChannel.trace(entry.message); - break; - default: - kiotaOutputChannel.info(entry.message); - break; - } -} - async function updateStatusBarItem(context: vscode.ExtensionContext): Promise { try { const version = await getKiotaVersion(context, kiotaOutputChannel); diff --git a/vscode/microsoft-kiota/src/utilities/file.ts b/vscode/microsoft-kiota/src/utilities/file.ts new file mode 100644 index 0000000000..87f6e18b77 --- /dev/null +++ b/vscode/microsoft-kiota/src/utilities/file.ts @@ -0,0 +1,28 @@ +import * as vscode from "vscode"; + +import { treeViewFocusCommand, treeViewId } from "../constants"; +import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { updateTreeViewIcons } from "../util"; + +async function loadLockFile(node: { fsPath: string }, openApiTreeProvider: OpenApiTreeProvider, clientOrPluginName?: string): Promise { + await openTreeViewWithProgress(() => openApiTreeProvider.loadLockFile(node.fsPath, clientOrPluginName)); + await updateTreeViewIcons(treeViewId, true); +} + +function openTreeViewWithProgress(callback: () => Promise): Thenable { + return vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Loading...") + }, async (progress, _) => { + const result = await callback(); + await vscode.commands.executeCommand(treeViewFocusCommand); + return result; + }); +} + +export { + loadLockFile, + openTreeViewWithProgress, +}; + diff --git a/vscode/microsoft-kiota/src/utilities/logging.ts b/vscode/microsoft-kiota/src/utilities/logging.ts new file mode 100644 index 0000000000..319d530714 --- /dev/null +++ b/vscode/microsoft-kiota/src/utilities/logging.ts @@ -0,0 +1,48 @@ +import * as vscode from "vscode"; +import { getLogEntriesForLevel, KiotaLogEntry, LogLevel } from "../kiotaInterop"; + +let kiotaOutputChannel: vscode.LogOutputChannel; +kiotaOutputChannel = vscode.window.createOutputChannel("Kiota", { + log: true, +}); + +async function exportLogsAndShowErrors(result: KiotaLogEntry[]): Promise { + const errorMessages = result + ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error) + : []; + + result.forEach((element) => { + logFromLogLevel(element); + }); + if (errorMessages.length > 0) { + await Promise.all(errorMessages.map((element) => { + return vscode.window.showErrorMessage(element.message); + })); + } +} + +function logFromLogLevel(entry: KiotaLogEntry): void { + switch (entry.level) { + case LogLevel.critical: + case LogLevel.error: + kiotaOutputChannel.error(entry.message); + break; + case LogLevel.warning: + kiotaOutputChannel.warn(entry.message); + break; + case LogLevel.debug: + kiotaOutputChannel.debug(entry.message); + break; + case LogLevel.trace: + kiotaOutputChannel.trace(entry.message); + break; + default: + kiotaOutputChannel.info(entry.message); + break; + } +} + +export { + kiotaOutputChannel, + exportLogsAndShowErrors, +}; \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/utilities/messaging.ts b/vscode/microsoft-kiota/src/utilities/messaging.ts new file mode 100644 index 0000000000..b6cd2743a6 --- /dev/null +++ b/vscode/microsoft-kiota/src/utilities/messaging.ts @@ -0,0 +1,24 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import * as vscode from "vscode"; +import { ExtensionContext } from 'vscode'; + +import { KIOTA_WORKSPACE_FILE } from '../constants'; + +async function showUpgradeWarningMessage(context: ExtensionContext, clientPath: string): Promise { + const kiotaVersion = context.extension.packageJSON.kiotaVersion.toLocaleLowerCase(); + const lockFilePath = path.join(clientPath, KIOTA_WORKSPACE_FILE); + if (!fs.existsSync(lockFilePath)) { + return; + } + const lockFileData = await vscode.workspace.fs.readFile(vscode.Uri.file(lockFilePath)); + const lockFile = JSON.parse(lockFileData.toString()) as { kiotaVersion: string }; + const clientVersion = lockFile.kiotaVersion.toLocaleLowerCase(); + if (clientVersion.toLocaleLowerCase() !== kiotaVersion) { + await vscode.window.showWarningMessage(vscode.l10n.t("Client will be upgraded from version {0} to {1}, upgrade your dependencies", clientVersion, kiotaVersion)); + } +} + +export { + showUpgradeWarningMessage +}; \ No newline at end of file From c850a241fd5d5b9ab1d9ac6831c08b9159e1455c Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 07:37:03 +0300 Subject: [PATCH 125/150] use abstract class to ensure consistency --- vscode/microsoft-kiota/src/commands/Command.ts | 7 +++++++ .../microsoft-kiota/src/commands/GenerateCommand.ts | 9 ++++++--- .../src/commands/KiotaStatusCommand.ts | 6 ++++-- .../src/commands/OpenApiTreeNodeCommand.ts | 11 +++++++---- vscode/microsoft-kiota/src/extension.ts | 6 +++--- 5 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/Command.ts diff --git a/vscode/microsoft-kiota/src/commands/Command.ts b/vscode/microsoft-kiota/src/commands/Command.ts new file mode 100644 index 0000000000..c50d5ede4d --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/Command.ts @@ -0,0 +1,7 @@ +export abstract class Command { + public toString():string { + return this.constructor.name; + } + + abstract execute(args: unknown):void; +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/commands/GenerateCommand.ts b/vscode/microsoft-kiota/src/commands/GenerateCommand.ts index 3e346d7e43..d108584cd9 100644 --- a/vscode/microsoft-kiota/src/commands/GenerateCommand.ts +++ b/vscode/microsoft-kiota/src/commands/GenerateCommand.ts @@ -19,17 +19,20 @@ import { exportLogsAndShowErrors } from '../utilities/logging'; import { showUpgradeWarningMessage } from "../utilities/messaging"; import { GeneratedOutputState } from './GeneratedOutputState'; import { loadLockFile } from "../utilities/file"; +import { Command } from "./Command"; + +export class GenerateCommand extends Command { -export class GenerateCommand { private _context: ExtensionContext; private _openApiTreeProvider: OpenApiTreeProvider; - constructor(context: ExtensionContext) { + public constructor(context: ExtensionContext) { + super(); this._context = context; this._openApiTreeProvider = new OpenApiTreeProvider(this._context, () => getExtensionSettings(extensionId)); } - public async run() { + public async execute() { const selectedPaths = this._openApiTreeProvider.getSelectedPaths(); if (selectedPaths.length === 0) { await vscode.window.showErrorMessage( diff --git a/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts b/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts index b3e8d8b65a..56c4dcb3e0 100644 --- a/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts +++ b/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts @@ -1,10 +1,12 @@ import * as vscode from "vscode"; +import { Command } from "./Command"; -export class KiotaStatusCommand { +export class KiotaStatusCommand extends Command { public constructor() { + super(); } - public async run(): Promise<() => Promise> { + public async execute(): Promise<() => Promise> { return async () => { const yesAnswer = vscode.l10n.t("Yes"); const response = await vscode.window.showInformationMessage( diff --git a/vscode/microsoft-kiota/src/commands/OpenApiTreeNodeCommand.ts b/vscode/microsoft-kiota/src/commands/OpenApiTreeNodeCommand.ts index ba8e111fd9..413676a5cc 100644 --- a/vscode/microsoft-kiota/src/commands/OpenApiTreeNodeCommand.ts +++ b/vscode/microsoft-kiota/src/commands/OpenApiTreeNodeCommand.ts @@ -1,13 +1,16 @@ import * as vscode from "vscode"; import { OpenApiTreeNode } from "../openApiTreeProvider"; +import { Command } from "./Command"; -export class OpenApiTreeNodeCommand { - constructor() { } +export class OpenApiTreeNodeCommand extends Command { + constructor() { + super(); + } - public openDocumentPage(openApiTreeNode: OpenApiTreeNode) { + execute(openApiTreeNode: OpenApiTreeNode): void { if (openApiTreeNode.documentationUrl) { vscode.env.openExternal(vscode.Uri.parse(openApiTreeNode.documentationUrl)); } } - + } \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 215f4af98f..86531250ea 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -89,7 +89,7 @@ export async function activate( `${extensionId}.selectLock`, (x) => loadLockFile(x, openApiTreeProvider) ), - registerCommandWithTelemetry(reporter, statusBarCommandId, await kiotaStatusCommand.run()), + registerCommandWithTelemetry(reporter, statusBarCommandId, await kiotaStatusCommand.execute()), vscode.window.registerWebviewViewProvider( dependenciesInfo, dependenciesInfoProvider @@ -97,7 +97,7 @@ export async function activate( vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider), registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, - (x: OpenApiTreeNode) => openApiTreeNodeCommand.openDocumentPage(x) + (x: OpenApiTreeNode) => openApiTreeNodeCommand.execute(x) ), registerCommandWithTelemetry(reporter, `${treeViewId}.addToSelectedEndpoints`, @@ -116,7 +116,7 @@ export async function activate( (x: OpenApiTreeNode) => openApiTreeProvider.select(x, false, true) ), registerCommandWithTelemetry(reporter, - `${treeViewId}.generateClient`, () => generateCommand.run() + `${treeViewId}.generateClient`, () => generateCommand.execute() ), vscode.workspace.onDidChangeWorkspaceFolders(async () => { const generatedOutput = context.workspaceState.get('generatedOutput'); From 71a53a81d586b4c839cc10e0b4107824374b61a6 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 07:45:18 +0300 Subject: [PATCH 126/150] create SearchOrOpenApiDescriptionCommand --- .../src/commands/GenerateCommand.ts | 4 +- .../SearchOrOpenApiDescriptionCommand.ts | 47 +++++++++++++++++++ vscode/microsoft-kiota/src/extension.ts | 30 ++---------- 3 files changed, 53 insertions(+), 28 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts diff --git a/vscode/microsoft-kiota/src/commands/GenerateCommand.ts b/vscode/microsoft-kiota/src/commands/GenerateCommand.ts index d108584cd9..a61a7bde76 100644 --- a/vscode/microsoft-kiota/src/commands/GenerateCommand.ts +++ b/vscode/microsoft-kiota/src/commands/GenerateCommand.ts @@ -26,10 +26,10 @@ export class GenerateCommand extends Command { private _context: ExtensionContext; private _openApiTreeProvider: OpenApiTreeProvider; - public constructor(context: ExtensionContext) { + public constructor(context: ExtensionContext, openApiTreeProvider: OpenApiTreeProvider) { super(); this._context = context; - this._openApiTreeProvider = new OpenApiTreeProvider(this._context, () => getExtensionSettings(extensionId)); + this._openApiTreeProvider = openApiTreeProvider; } public async execute() { diff --git a/vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts b/vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts new file mode 100644 index 0000000000..f39349c5c6 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts @@ -0,0 +1,47 @@ +import * as vscode from "vscode"; +import { ExtensionContext } from "vscode"; + +import { extensionId } from "../constants"; +import { getExtensionSettings } from "../extensionSettings"; +import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { searchDescription } from "../searchDescription"; +import { searchSteps } from "../steps"; +import { openTreeViewWithProgress } from "../utilities/file"; +import { Command } from "./Command"; + +export class SearchOrOpenApiDescriptionCommand extends Command { + private _context: ExtensionContext; + private _openApiTreeProvider: OpenApiTreeProvider; + + public constructor(context: ExtensionContext, openApiTreeProvider: OpenApiTreeProvider) { + super(); + this._context = context; + this._openApiTreeProvider = openApiTreeProvider; + } + + async execute(): Promise { + const yesAnswer = vscode.l10n.t("Yes, override it"); + if (!this._openApiTreeProvider.isEmpty() && this._openApiTreeProvider.hasChanges()) { + const response = await vscode.window.showWarningMessage( + vscode.l10n.t( + "Before adding a new API description, consider that your changes and current selection will be lost."), + yesAnswer, + vscode.l10n.t("Cancel") + ); + if (response !== yesAnswer) { + return; + } + } + const config = await searchSteps(x => vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Searching...") + }, (progress, _) => { + const settings = getExtensionSettings(extensionId); + return searchDescription(this._context, x, settings.clearCache); + })); + if (config.descriptionPath) { + await openTreeViewWithProgress(() => this._openApiTreeProvider.setDescriptionUrl(config.descriptionPath!)); + } + } +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 86531250ea..db5d2fc8ea 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -37,6 +37,7 @@ import { loadLockFile, openTreeViewWithProgress } from './utilities/file'; import { exportLogsAndShowErrors, kiotaOutputChannel } from './utilities/logging'; import { showUpgradeWarningMessage } from './utilities/messaging'; import { loadTreeView } from "./workspaceTreeProvider"; +import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDescriptionCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; @@ -56,7 +57,8 @@ export async function activate( ); const kiotaStatusCommand = new KiotaStatusCommand(); const openApiTreeNodeCommand = new OpenApiTreeNodeCommand(); - const generateCommand = new GenerateCommand(context); + const generateCommand = new GenerateCommand(context, openApiTreeProvider); + const searchOrOpenApiDescriptionCommand = new SearchOrOpenApiDescriptionCommand(context, openApiTreeProvider); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); @@ -129,31 +131,7 @@ export async function activate( }), registerCommandWithTelemetry(reporter, `${treeViewId}.searchOrOpenApiDescription`, - async () => { - const yesAnswer = vscode.l10n.t("Yes, override it"); - if (!openApiTreeProvider.isEmpty() && openApiTreeProvider.hasChanges()) { - const response = await vscode.window.showWarningMessage( - vscode.l10n.t( - "Before adding a new API description, consider that your changes and current selection will be lost."), - yesAnswer, - vscode.l10n.t("Cancel") - ); - if (response !== yesAnswer) { - return; - } - } - const config = await searchSteps(x => vscode.window.withProgress({ - location: vscode.ProgressLocation.Notification, - cancellable: false, - title: vscode.l10n.t("Searching...") - }, (progress, _) => { - const settings = getExtensionSettings(extensionId); - return searchDescription(context, x, settings.clearCache); - })); - if (config.descriptionPath) { - await openTreeViewWithProgress(() => openApiTreeProvider.setDescriptionUrl(config.descriptionPath!)); - } - } + () => searchOrOpenApiDescriptionCommand.execute() ), registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, async () => { const yesAnswer = vscode.l10n.t("Yes"); From f695e05ebda6feb22d256173ec0da028f3669b71 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 07:50:28 +0300 Subject: [PATCH 127/150] create close description command --- .../src/commands/CloseDescriptionCommand.ts | 28 +++++++++++++++++++ vscode/microsoft-kiota/src/extension.ts | 16 ++--------- 2 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts diff --git a/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts b/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts new file mode 100644 index 0000000000..acec1cfd44 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts @@ -0,0 +1,28 @@ +import * as vscode from "vscode"; + +import { treeViewId } from "../constants"; +import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { updateTreeViewIcons } from "../util"; +import { Command } from "./Command"; + +export class CloseDescriptionCommand extends Command { + private _openApiTreeProvider: OpenApiTreeProvider; + + public constructor(openApiTreeProvider: OpenApiTreeProvider) { + super(); + this._openApiTreeProvider = openApiTreeProvider; + } + + async execute(): Promise { + const yesAnswer = vscode.l10n.t("Yes"); + const response = await vscode.window.showInformationMessage( + vscode.l10n.t("Do you want to remove this API description?"), + yesAnswer, + vscode.l10n.t("No") + ); + if (response === yesAnswer) { + this._openApiTreeProvider.closeDescription(); + await updateTreeViewIcons(treeViewId, false); + } +} +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index db5d2fc8ea..375e70a82d 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -38,6 +38,7 @@ import { exportLogsAndShowErrors, kiotaOutputChannel } from './utilities/logging import { showUpgradeWarningMessage } from './utilities/messaging'; import { loadTreeView } from "./workspaceTreeProvider"; import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDescriptionCommand'; +import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; @@ -59,6 +60,7 @@ export async function activate( const openApiTreeNodeCommand = new OpenApiTreeNodeCommand(); const generateCommand = new GenerateCommand(context, openApiTreeProvider); const searchOrOpenApiDescriptionCommand = new SearchOrOpenApiDescriptionCommand(context, openApiTreeProvider); + const closeDescriptionCommand = new CloseDescriptionCommand(openApiTreeProvider); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); @@ -133,19 +135,7 @@ export async function activate( `${treeViewId}.searchOrOpenApiDescription`, () => searchOrOpenApiDescriptionCommand.execute() ), - registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, async () => { - const yesAnswer = vscode.l10n.t("Yes"); - const response = await vscode.window.showInformationMessage( - vscode.l10n.t("Do you want to remove this API description?"), - yesAnswer, - vscode.l10n.t("No") - ); - if (response === yesAnswer) { - openApiTreeProvider.closeDescription(); - await updateTreeViewIcons(treeViewId, false); - } - } - ), + registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, () => closeDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`, async () => { await filterSteps(openApiTreeProvider.filter, x => openApiTreeProvider.filter = x); From 5d4e9382af5c12a1ca6e95b4910a60e661583dfb Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 07:56:42 +0300 Subject: [PATCH 128/150] create FilterDescriptionCommand --- .../src/commands/FilterDescriptionCommand.ts | 18 ++++++++++++++++++ vscode/microsoft-kiota/src/extension.ts | 13 ++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts diff --git a/vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts b/vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts new file mode 100644 index 0000000000..8808def9ae --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts @@ -0,0 +1,18 @@ +import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { filterSteps } from "../steps"; +import { Command } from "./Command"; + +export class FilterDescriptionCommand extends Command { + private _openApiTreeProvider: OpenApiTreeProvider; + + constructor(openApiTreeProvider: OpenApiTreeProvider) { + super(); + this._openApiTreeProvider = openApiTreeProvider; + } + + async execute(): Promise { + await filterSteps(this._openApiTreeProvider.filter, + x => this._openApiTreeProvider.filter = x); + } + +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 375e70a82d..bab359486b 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -39,6 +39,7 @@ import { showUpgradeWarningMessage } from './utilities/messaging'; import { loadTreeView } from "./workspaceTreeProvider"; import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDescriptionCommand'; import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; +import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; @@ -61,6 +62,7 @@ export async function activate( const generateCommand = new GenerateCommand(context, openApiTreeProvider); const searchOrOpenApiDescriptionCommand = new SearchOrOpenApiDescriptionCommand(context, openApiTreeProvider); const closeDescriptionCommand = new CloseDescriptionCommand(openApiTreeProvider); + const filterDescriptionCommand = new FilterDescriptionCommand(openApiTreeProvider); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); @@ -131,16 +133,9 @@ export async function activate( void context.workspaceState.update('generatedOutput', undefined); } }), - registerCommandWithTelemetry(reporter, - `${treeViewId}.searchOrOpenApiDescription`, - () => searchOrOpenApiDescriptionCommand.execute() - ), + registerCommandWithTelemetry(reporter, `${treeViewId}.searchOrOpenApiDescription`, () => searchOrOpenApiDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, () => closeDescriptionCommand.execute()), - registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`, - async () => { - await filterSteps(openApiTreeProvider.filter, x => openApiTreeProvider.filter = x); - } - ), + registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`, () => filterDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { clientOrPluginKey = clientKey; clientOrPluginObject = clientObject; From fd2a93808a7b7ca02ef90ec3729835888a87621b Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 08:14:20 +0300 Subject: [PATCH 129/150] create EditPathsCommand --- .../src/commands/EditPathsCommand.ts | 31 +++++++++++++++++++ vscode/microsoft-kiota/src/extension.ts | 15 ++------- 2 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/EditPathsCommand.ts diff --git a/vscode/microsoft-kiota/src/commands/EditPathsCommand.ts b/vscode/microsoft-kiota/src/commands/EditPathsCommand.ts new file mode 100644 index 0000000000..9e9410695c --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/EditPathsCommand.ts @@ -0,0 +1,31 @@ +import { treeViewId } from "../constants"; +import { ClientOrPluginProperties } from "../kiotaInterop"; +import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { updateTreeViewIcons } from "../util"; +import { openTreeViewWithProgress } from "../utilities/file"; +import { Command } from "./Command"; + +export class EditPathsCommand extends Command { + + private _openApiTreeProvider: OpenApiTreeProvider; + private _clientKey: string; + private _clientObject: ClientOrPluginProperties; + + public constructor(openApiTreeProvider: OpenApiTreeProvider, clientKey: string, clientObject: ClientOrPluginProperties) { + super(); + this._openApiTreeProvider = openApiTreeProvider; + this._clientKey = clientKey; + this._clientObject = clientObject; + } + + async execute(): Promise { + await this.loadEditPaths(); + this._openApiTreeProvider.resetInitialState(); + await updateTreeViewIcons(treeViewId, false, true); + } + + async loadEditPaths() { + await openTreeViewWithProgress(() => this._openApiTreeProvider.loadEditPaths(this._clientKey, this._clientObject)); + } + +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index bab359486b..4e3d178cd8 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -40,6 +40,7 @@ import { loadTreeView } from "./workspaceTreeProvider"; import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDescriptionCommand'; import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; +import { EditPathsCommand } from './commands/EditPathsCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; @@ -63,6 +64,7 @@ export async function activate( const searchOrOpenApiDescriptionCommand = new SearchOrOpenApiDescriptionCommand(context, openApiTreeProvider); const closeDescriptionCommand = new CloseDescriptionCommand(openApiTreeProvider); const filterDescriptionCommand = new FilterDescriptionCommand(openApiTreeProvider); + const editPathsCommand = new EditPathsCommand(openApiTreeProvider, clientOrPluginKey, clientOrPluginObject); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); @@ -136,14 +138,7 @@ export async function activate( registerCommandWithTelemetry(reporter, `${treeViewId}.searchOrOpenApiDescription`, () => searchOrOpenApiDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, () => closeDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`, () => filterDescriptionCommand.execute()), - registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { - clientOrPluginKey = clientKey; - clientOrPluginObject = clientObject; - workspaceGenerationType = generationType; - await loadEditPaths(clientOrPluginKey, clientObject, openApiTreeProvider); - openApiTreeProvider.resetInitialState(); - await updateTreeViewIcons(treeViewId, false, true); - }), + registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async () => editPathsCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.regenerateButton`, async () => { if (!clientOrPluginKey || clientOrPluginKey === '') { clientOrPluginKey = config.clientClassName || config.pluginName || ''; @@ -330,10 +325,6 @@ function registerCommandWithTelemetry(reporter: TelemetryReporter, command: stri }, thisArg); } -async function loadEditPaths(clientOrPluginKey: string, clientObject: any, openApiTreeProvider: OpenApiTreeProvider): Promise { - await openTreeViewWithProgress(() => openApiTreeProvider.loadEditPaths(clientOrPluginKey, clientObject)); -} - async function updateStatusBarItem(context: vscode.ExtensionContext): Promise { try { const version = await getKiotaVersion(context, kiotaOutputChannel); From 202830afcfa195dc5ecc809d820f3d3b9e7d422a Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 08:54:16 +0300 Subject: [PATCH 130/150] create regenerate button command --- .../src/commands/RegenerateButtonCommand.ts | 138 ++++++++++++++++++ vscode/microsoft-kiota/src/extension.ts | 32 +--- 2 files changed, 142 insertions(+), 28 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/RegenerateButtonCommand.ts diff --git a/vscode/microsoft-kiota/src/commands/RegenerateButtonCommand.ts b/vscode/microsoft-kiota/src/commands/RegenerateButtonCommand.ts new file mode 100644 index 0000000000..5916cf0ca0 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/RegenerateButtonCommand.ts @@ -0,0 +1,138 @@ +import * as vscode from "vscode"; +import { ExtensionContext } from "vscode"; + +import { extensionId } from "../constants"; +import { ExtensionSettings, getExtensionSettings } from "../extensionSettings"; +import { generateClient } from "../generateClient"; +import { generatePlugin } from "../generatePlugin"; +import { + ClientObjectProperties, + ClientOrPluginProperties, ConsumerOperation, getLogEntriesForLevel, + KiotaGenerationLanguage, KiotaPluginType, parseGenerationLanguage, parsePluginType, + PluginObjectProperties +} from "../kiotaInterop"; +import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { GenerateState } from "../steps"; +import { isClientType, isPluginType } from "../util"; +import { Command } from "./Command"; + +export class RegenerateButtonCommand extends Command { + + private _context: ExtensionContext; + private _openApiTreeProvider: OpenApiTreeProvider; + private _clientKey: string; + private _clientObject: ClientOrPluginProperties; + private _workspaceGenerationType: string; + + public constructor(context: ExtensionContext, openApiTreeProvider: OpenApiTreeProvider, + clientKey: string, clientObject: ClientOrPluginProperties, workspaceGenerationType: string) { + super(); + this._context = context; + this._openApiTreeProvider = openApiTreeProvider; + this._clientKey = clientKey; + this._clientObject = clientObject; + this._workspaceGenerationType = workspaceGenerationType; + } + + async execute(config: Partial): Promise { + if (!this._clientKey || this._clientKey === '') { + this._clientKey = config.clientClassName || config.pluginName || ''; + } + if (!config) { + config = { + outputPath: this._clientObject.outputPath, + clientClassName: this._clientKey, + }; + } + const settings = getExtensionSettings(extensionId); + const selectedPaths = this._openApiTreeProvider.getSelectedPaths(); + if (selectedPaths.length === 0) { + await vscode.window.showErrorMessage( + vscode.l10n.t("No endpoints selected, select endpoints first") + ); + return; + } + if (isClientType(this._workspaceGenerationType)) { + await this.regenerateClient(settings, selectedPaths); + } + if (isPluginType(this._workspaceGenerationType)) { + await this.regeneratePlugin(settings, selectedPaths); + } + } + + async regenerateClient(settings: ExtensionSettings, selectedPaths?: string[]): Promise { + const clientObjectItem = this._clientObject as ClientObjectProperties; + const language = + typeof clientObjectItem.language === "string" + ? parseGenerationLanguage(clientObjectItem.language) + : KiotaGenerationLanguage.CSharp; + await vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Re-generating client...") + }, async (progress, _) => { + const result = await generateClient( + this._context, + this._clientObject.descriptionLocation ? this._clientObject.descriptionLocation : this._openApiTreeProvider.descriptionUrl, + this._clientObject.outputPath, + language, + selectedPaths ? selectedPaths : this._clientObject.includePatterns, + this._clientObject.excludePatterns ? this._clientObject.excludePatterns : [], + this._clientKey, + clientObjectItem.clientNamespaceName, + clientObjectItem.usesBackingStore ? clientObjectItem.usesBackingStore : settings.backingStore, + true, // clearCache + true, // cleanOutput + clientObjectItem.excludeBackwardCompatible ? clientObjectItem.excludeBackwardCompatible : settings.excludeBackwardCompatible, + clientObjectItem.disabledValidationRules ? clientObjectItem.disabledValidationRules : settings.disableValidationRules, + settings.languagesSerializationConfiguration[language].serializers, + settings.languagesSerializationConfiguration[language].deserializers, + clientObjectItem.structuredMimeTypes ? clientObjectItem.structuredMimeTypes : settings.structuredMimeTypes, + clientObjectItem.includeAdditionalData ? clientObjectItem.includeAdditionalData : settings.includeAdditionalData, + ConsumerOperation.Edit + ); + return result; + }); + void vscode.window.showInformationMessage(`Client ${this._clientKey} re-generated successfully.`); + this._openApiTreeProvider.resetInitialState(); + } + async regeneratePlugin(settings: ExtensionSettings, selectedPaths?: string[]) { + const clientObjectItem = this._clientObject as PluginObjectProperties; + + const pluginTypes = Array.isArray(clientObjectItem.types) ? parsePluginType(clientObjectItem.types) : [KiotaPluginType.ApiPlugin]; + await vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Re-generating plugin...") + }, async (progress, _) => { + const start = performance.now(); + const result = await generatePlugin( + this._context, + this._clientObject.descriptionLocation ? this._clientObject.descriptionLocation : this._openApiTreeProvider.descriptionUrl, + this._clientObject.outputPath, + pluginTypes, + selectedPaths ? selectedPaths : this._clientObject.includePatterns, + [], + this._clientKey, + settings.clearCache, + settings.cleanOutput, + settings.disableValidationRules, + ConsumerOperation.Edit + ); + + // TODO: uncomment when telemetry is implemented + + /* const duration = performance.now() - start; + const errorsCount = result ? getLogEntriesForLevel(result, vscode.LogLevel.critical, vscode.LogLevel.error).length : 0; + reporter.sendRawTelemetryEvent(`${extensionId}.re-generatePlugin.completed`, { + "pluginType": pluginTypes.toString(), + "errorsCount": errorsCount.toString(), + }, { + "duration": duration, + }); */ + return result; + }); + void vscode.window.showInformationMessage(`Plugin ${this._clientKey} re-generated successfully.`); + this._openApiTreeProvider.resetInitialState(); + } +} diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 4e3d178cd8..1a5154f3b0 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -41,6 +41,7 @@ import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDes import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; import { EditPathsCommand } from './commands/EditPathsCommand'; +import { RegenerateButtonCommand } from './commands/RegenerateButtonCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; @@ -65,6 +66,7 @@ export async function activate( const closeDescriptionCommand = new CloseDescriptionCommand(openApiTreeProvider); const filterDescriptionCommand = new FilterDescriptionCommand(openApiTreeProvider); const editPathsCommand = new EditPathsCommand(openApiTreeProvider, clientOrPluginKey, clientOrPluginObject); + const regenerateButtonCommand = new RegenerateButtonCommand(context, openApiTreeProvider, clientOrPluginKey, clientOrPluginObject, workspaceGenerationType); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); @@ -123,9 +125,7 @@ export async function activate( `${treeViewId}.removeAllFromSelectedEndpoints`, (x: OpenApiTreeNode) => openApiTreeProvider.select(x, false, true) ), - registerCommandWithTelemetry(reporter, - `${treeViewId}.generateClient`, () => generateCommand.execute() - ), + registerCommandWithTelemetry(reporter, `${treeViewId}.generateClient`, () => generateCommand.execute()), vscode.workspace.onDidChangeWorkspaceFolders(async () => { const generatedOutput = context.workspaceState.get('generatedOutput'); if (generatedOutput) { @@ -139,31 +139,7 @@ export async function activate( registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, () => closeDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`, () => filterDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async () => editPathsCommand.execute()), - registerCommandWithTelemetry(reporter, `${treeViewId}.regenerateButton`, async () => { - if (!clientOrPluginKey || clientOrPluginKey === '') { - clientOrPluginKey = config.clientClassName || config.pluginName || ''; - } - if (!config) { - config = { - outputPath: clientOrPluginObject.outputPath, - clientClassName: clientOrPluginKey, - }; - } - const settings = getExtensionSettings(extensionId); - const selectedPaths = openApiTreeProvider.getSelectedPaths(); - if (selectedPaths.length === 0) { - await vscode.window.showErrorMessage( - vscode.l10n.t("No endpoints selected, select endpoints first") - ); - return; - } - if (isClientType(workspaceGenerationType)) { - await regenerateClient(clientOrPluginKey, config, settings, selectedPaths); - } - if (isPluginType(workspaceGenerationType)) { - await regeneratePlugin(clientOrPluginKey, config, settings, selectedPaths); - } - }), + registerCommandWithTelemetry(reporter, `${treeViewId}.regenerateButton`, async () => regenerateButtonCommand.execute(config)), registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { const settings = getExtensionSettings(extensionId); const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(KIOTA_WORKSPACE_FILE)); From e52f966560b5cda8baaeb3ee3aba714ea4f53c07 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 09:07:34 +0300 Subject: [PATCH 131/150] create RegenerateCommand --- .../regenerate/RegenerateButtonCommand.ts | 58 ++++++++++++ .../commands/regenerate/RegenerateCommand.ts | 49 ++++++++++ .../regenerate.service.ts} | 58 +++--------- vscode/microsoft-kiota/src/extension.ts | 90 +------------------ 4 files changed, 120 insertions(+), 135 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts create mode 100644 vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts rename vscode/microsoft-kiota/src/commands/{RegenerateButtonCommand.ts => regenerate/regenerate.service.ts} (70%) diff --git a/vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts new file mode 100644 index 0000000000..940c6e57b7 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts @@ -0,0 +1,58 @@ +import * as vscode from "vscode"; +import { ExtensionContext } from "vscode"; + +import { extensionId } from "../../constants"; +import { getExtensionSettings } from "../../extensionSettings"; +import { ClientOrPluginProperties } from "../../kiotaInterop"; +import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { GenerateState } from "../../steps"; +import { isClientType, isPluginType } from "../../util"; +import { Command } from "../Command"; +import { RegenerateService } from "./regenerate.service"; + +export class RegenerateButtonCommand extends Command { + + private _context: ExtensionContext; + private _openApiTreeProvider: OpenApiTreeProvider; + private _clientKey: string; + private _clientObject: ClientOrPluginProperties; + private _workspaceGenerationType: string; + + public constructor(context: ExtensionContext, openApiTreeProvider: OpenApiTreeProvider, + clientKey: string, clientObject: ClientOrPluginProperties, workspaceGenerationType: string) { + super(); + this._context = context; + this._openApiTreeProvider = openApiTreeProvider; + this._clientKey = clientKey; + this._clientObject = clientObject; + this._workspaceGenerationType = workspaceGenerationType; + } + + async execute(config: Partial): Promise { + if (!this._clientKey || this._clientKey === '') { + this._clientKey = config.clientClassName || config.pluginName || ''; + } + if (!config) { + config = { + outputPath: this._clientObject.outputPath, + clientClassName: this._clientKey, + }; + } + const settings = getExtensionSettings(extensionId); + const selectedPaths = this._openApiTreeProvider.getSelectedPaths(); + if (selectedPaths.length === 0) { + await vscode.window.showErrorMessage( + vscode.l10n.t("No endpoints selected, select endpoints first") + ); + return; + } + + const regenerateService = new RegenerateService(this._context, this._openApiTreeProvider, this._clientKey, this._clientObject); + if (isClientType(this._workspaceGenerationType)) { + await regenerateService.regenerateClient(settings, selectedPaths); + } + if (isPluginType(this._workspaceGenerationType)) { + await regenerateService.regeneratePlugin(settings, selectedPaths); + } + } +} diff --git a/vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts new file mode 100644 index 0000000000..37edc6b80f --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts @@ -0,0 +1,49 @@ +import * as vscode from "vscode"; +import { ExtensionContext } from "vscode"; + +import { extensionId, KIOTA_WORKSPACE_FILE } from "../../constants"; +import { getExtensionSettings } from "../../extensionSettings"; +import { ClientOrPluginProperties } from "../../kiotaInterop"; +import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { isClientType, isPluginType } from "../../util"; +import { Command } from "../Command"; +import { RegenerateService } from "./regenerate.service"; + +export class RegenerateCommand extends Command { + + private _context: ExtensionContext; + private _openApiTreeProvider: OpenApiTreeProvider; + private _clientKey: string; + private _clientObject: ClientOrPluginProperties; + private _workspaceGenerationType: string; + + public constructor(context: ExtensionContext, openApiTreeProvider: OpenApiTreeProvider, + clientKey: string, clientObject: ClientOrPluginProperties, workspaceGenerationType: string) { + super(); + this._context = context; + this._openApiTreeProvider = openApiTreeProvider; + this._clientKey = clientKey; + this._clientObject = clientObject; + this._workspaceGenerationType = workspaceGenerationType; + } + + async execute(): Promise { + const settings = getExtensionSettings(extensionId); + const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(KIOTA_WORKSPACE_FILE)); + if (workspaceJson && workspaceJson.isDirty) { + await vscode.window.showInformationMessage( + vscode.l10n.t("Please save the workspace.json file before re-generation."), + vscode.l10n.t("OK") + ); + return; + } + + const regenerateService = new RegenerateService(this._context, this._openApiTreeProvider, this._clientKey, this._clientObject); + if (isClientType(this._workspaceGenerationType)) { + await regenerateService.regenerateClient(settings); + } + if (isPluginType(this._workspaceGenerationType)) { + await regenerateService.regeneratePlugin(settings); + } + } +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/commands/RegenerateButtonCommand.ts b/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts similarity index 70% rename from vscode/microsoft-kiota/src/commands/RegenerateButtonCommand.ts rename to vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts index 5916cf0ca0..ef02e795c4 100644 --- a/vscode/microsoft-kiota/src/commands/RegenerateButtonCommand.ts +++ b/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts @@ -1,63 +1,24 @@ import * as vscode from "vscode"; -import { ExtensionContext } from "vscode"; - -import { extensionId } from "../constants"; -import { ExtensionSettings, getExtensionSettings } from "../extensionSettings"; -import { generateClient } from "../generateClient"; -import { generatePlugin } from "../generatePlugin"; -import { - ClientObjectProperties, - ClientOrPluginProperties, ConsumerOperation, getLogEntriesForLevel, - KiotaGenerationLanguage, KiotaPluginType, parseGenerationLanguage, parsePluginType, - PluginObjectProperties -} from "../kiotaInterop"; -import { OpenApiTreeProvider } from "../openApiTreeProvider"; -import { GenerateState } from "../steps"; -import { isClientType, isPluginType } from "../util"; -import { Command } from "./Command"; -export class RegenerateButtonCommand extends Command { +import { ExtensionContext } from "vscode"; +import { ExtensionSettings } from "../../extensionSettings"; +import { generateClient } from "../../generateClient"; +import { generatePlugin } from "../../generatePlugin"; +import { ClientObjectProperties, parseGenerationLanguage, KiotaGenerationLanguage, ConsumerOperation, PluginObjectProperties, parsePluginType, KiotaPluginType, ClientOrPluginProperties } from "../../kiotaInterop"; +import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +export class RegenerateService { private _context: ExtensionContext; private _openApiTreeProvider: OpenApiTreeProvider; private _clientKey: string; private _clientObject: ClientOrPluginProperties; - private _workspaceGenerationType: string; public constructor(context: ExtensionContext, openApiTreeProvider: OpenApiTreeProvider, - clientKey: string, clientObject: ClientOrPluginProperties, workspaceGenerationType: string) { - super(); + clientKey: string, clientObject: ClientOrPluginProperties) { this._context = context; this._openApiTreeProvider = openApiTreeProvider; this._clientKey = clientKey; this._clientObject = clientObject; - this._workspaceGenerationType = workspaceGenerationType; - } - - async execute(config: Partial): Promise { - if (!this._clientKey || this._clientKey === '') { - this._clientKey = config.clientClassName || config.pluginName || ''; - } - if (!config) { - config = { - outputPath: this._clientObject.outputPath, - clientClassName: this._clientKey, - }; - } - const settings = getExtensionSettings(extensionId); - const selectedPaths = this._openApiTreeProvider.getSelectedPaths(); - if (selectedPaths.length === 0) { - await vscode.window.showErrorMessage( - vscode.l10n.t("No endpoints selected, select endpoints first") - ); - return; - } - if (isClientType(this._workspaceGenerationType)) { - await this.regenerateClient(settings, selectedPaths); - } - if (isPluginType(this._workspaceGenerationType)) { - await this.regeneratePlugin(settings, selectedPaths); - } } async regenerateClient(settings: ExtensionSettings, selectedPaths?: string[]): Promise { @@ -96,6 +57,7 @@ export class RegenerateButtonCommand extends Command { void vscode.window.showInformationMessage(`Client ${this._clientKey} re-generated successfully.`); this._openApiTreeProvider.resetInitialState(); } + async regeneratePlugin(settings: ExtensionSettings, selectedPaths?: string[]) { const clientObjectItem = this._clientObject as PluginObjectProperties; @@ -135,4 +97,4 @@ export class RegenerateButtonCommand extends Command { void vscode.window.showInformationMessage(`Plugin ${this._clientKey} re-generated successfully.`); this._openApiTreeProvider.resetInitialState(); } -} +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 1a5154f3b0..bf8b37e6c6 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -41,7 +41,7 @@ import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDes import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; import { EditPathsCommand } from './commands/EditPathsCommand'; -import { RegenerateButtonCommand } from './commands/RegenerateButtonCommand'; +import { RegenerateButtonCommand } from './commands/regenerate/RegenerateButtonCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; @@ -141,94 +141,10 @@ export async function activate( registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async () => editPathsCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.regenerateButton`, async () => regenerateButtonCommand.execute(config)), registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { - const settings = getExtensionSettings(extensionId); - const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(KIOTA_WORKSPACE_FILE)); - if (workspaceJson && workspaceJson.isDirty) { - await vscode.window.showInformationMessage( - vscode.l10n.t("Please save the workspace.json file before re-generation."), - vscode.l10n.t("OK") - ); - return; - } - if (isClientType(generationType)) { - await regenerateClient(clientKey, clientObject, settings); - } - if (isPluginType(generationType)) { - await regeneratePlugin(clientKey, clientObject, settings); - } - }), + } + ), ); - async function regenerateClient(clientKey: string, clientObject: any, settings: ExtensionSettings, selectedPaths?: string[]): Promise { - const language = - typeof clientObject.language === "string" - ? parseGenerationLanguage(clientObject.language) - : KiotaGenerationLanguage.CSharp; - await vscode.window.withProgress({ - location: vscode.ProgressLocation.Notification, - cancellable: false, - title: vscode.l10n.t("Re-generating client...") - }, async (progress, _) => { - const result = await generateClient( - context, - clientObject.descriptionLocation ? clientObject.descriptionLocation : openApiTreeProvider.descriptionUrl, - clientObject.outputPath, - language, - selectedPaths ? selectedPaths : clientObject.includePatterns, - clientObject.excludePatterns ? clientObject.excludePatterns : [], - clientKey, - clientObject.clientNamespaceName, - clientObject.usesBackingStore ? clientObject.usesBackingStore : settings.backingStore, - true, // clearCache - true, // cleanOutput - clientObject.excludeBackwardCompatible ? clientObject.excludeBackwardCompatible : settings.excludeBackwardCompatible, - clientObject.disabledValidationRules ? clientObject.disabledValidationRules : settings.disableValidationRules, - settings.languagesSerializationConfiguration[language].serializers, - settings.languagesSerializationConfiguration[language].deserializers, - clientObject.structuredMimeTypes ? clientObject.structuredMimeTypes : settings.structuredMimeTypes, - clientObject.includeAdditionalData ? clientObject.includeAdditionalData : settings.includeAdditionalData, - ConsumerOperation.Edit - ); - return result; - }); - void vscode.window.showInformationMessage(`Client ${clientKey} re-generated successfully.`); - openApiTreeProvider.resetInitialState(); - } - async function regeneratePlugin(clientKey: string, clientObject: any, settings: ExtensionSettings, selectedPaths?: string[]) { - const pluginTypes = Array.isArray(clientObject.types) ? parsePluginType(clientObject.types) : [KiotaPluginType.ApiPlugin]; - await vscode.window.withProgress({ - location: vscode.ProgressLocation.Notification, - cancellable: false, - title: vscode.l10n.t("Re-generating plugin...") - }, async (progress, _) => { - const start = performance.now(); - const result = await generatePlugin( - context, - clientObject.descriptionLocation ? clientObject.descriptionLocation : openApiTreeProvider.descriptionUrl, - clientObject.outputPath, - pluginTypes, - selectedPaths ? selectedPaths : clientObject.includePatterns, - [], - clientKey, - settings.clearCache, - settings.cleanOutput, - settings.disableValidationRules, - ConsumerOperation.Edit - ); - const duration = performance.now() - start; - const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; - reporter.sendRawTelemetryEvent(`${extensionId}.re-generatePlugin.completed`, { - "pluginType": pluginTypes.toString(), - "errorsCount": errorsCount.toString(), - }, { - "duration": duration, - }); - return result; - }); - void vscode.window.showInformationMessage(`Plugin ${clientKey} re-generated successfully.`); - openApiTreeProvider.resetInitialState(); - } - // create a new status bar item that we can now manage kiotaStatusBarItem = vscode.window.createStatusBarItem( vscode.StatusBarAlignment.Right, From 50da7c5408b888017f2956044419bb64baef8593 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 09:12:16 +0300 Subject: [PATCH 132/150] implement regenerate command --- vscode/microsoft-kiota/src/extension.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index bf8b37e6c6..2cb9a22797 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -42,6 +42,7 @@ import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; import { EditPathsCommand } from './commands/EditPathsCommand'; import { RegenerateButtonCommand } from './commands/regenerate/RegenerateButtonCommand'; +import { RegenerateCommand } from './commands/regenerate/RegenerateCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; @@ -59,6 +60,7 @@ export async function activate( const dependenciesInfoProvider = new DependenciesViewProvider( context.extensionUri ); + const kiotaStatusCommand = new KiotaStatusCommand(); const openApiTreeNodeCommand = new OpenApiTreeNodeCommand(); const generateCommand = new GenerateCommand(context, openApiTreeProvider); @@ -67,6 +69,7 @@ export async function activate( const filterDescriptionCommand = new FilterDescriptionCommand(openApiTreeProvider); const editPathsCommand = new EditPathsCommand(openApiTreeProvider, clientOrPluginKey, clientOrPluginObject); const regenerateButtonCommand = new RegenerateButtonCommand(context, openApiTreeProvider, clientOrPluginKey, clientOrPluginObject, workspaceGenerationType); + const regenerateCommand = new RegenerateCommand(context, openApiTreeProvider, clientOrPluginKey, clientOrPluginObject, workspaceGenerationType); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); @@ -140,9 +143,7 @@ export async function activate( registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`, () => filterDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async () => editPathsCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.regenerateButton`, async () => regenerateButtonCommand.execute(config)), - registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async (clientKey: string, clientObject: ClientOrPluginProperties, generationType: string) => { - } - ), + registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async () => regenerateCommand.execute()), ); // create a new status bar item that we can now manage From 6117e8797db1ad76e9e47ba3347d8b92e2f0e6fb Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 09:12:27 +0300 Subject: [PATCH 133/150] format extensions --- vscode/microsoft-kiota/src/extension.ts | 29 ++++++++----------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 2cb9a22797..918f1f6fd1 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -9,40 +9,29 @@ import { CodeLensProvider } from "./codelensProvider"; import { KiotaStatusCommand } from "./commands/KiotaStatusCommand"; import { OpenApiTreeNodeCommand } from "./commands/OpenApiTreeNodeCommand"; +import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; +import { EditPathsCommand } from './commands/EditPathsCommand'; +import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; import { GenerateCommand } from './commands/GenerateCommand'; import { GeneratedOutputState } from './commands/GeneratedOutputState'; +import { RegenerateButtonCommand } from './commands/regenerate/RegenerateButtonCommand'; +import { RegenerateCommand } from './commands/regenerate/RegenerateCommand'; +import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDescriptionCommand'; import { KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewId } from "./constants"; import { DependenciesViewProvider } from "./dependenciesViewProvider"; -import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; -import { generateClient } from "./generateClient"; -import { generatePlugin } from "./generatePlugin"; +import { getExtensionSettings } from "./extensionSettings"; import { getKiotaVersion } from "./getKiotaVersion"; import { ClientOrPluginProperties, - ConsumerOperation, - KiotaGenerationLanguage, - KiotaLogEntry, - KiotaPluginType, - LogLevel, - getLogEntriesForLevel, - parseGenerationLanguage, - parsePluginType + KiotaLogEntry } from "./kiotaInterop"; import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider"; -import { searchDescription } from "./searchDescription"; -import { GenerateState, filterSteps, searchSteps } from "./steps"; +import { GenerateState } from "./steps"; import { updateClients } from "./updateClients"; -import { isClientType, isPluginType, updateTreeViewIcons } from "./util"; import { loadLockFile, openTreeViewWithProgress } from './utilities/file'; import { exportLogsAndShowErrors, kiotaOutputChannel } from './utilities/logging'; import { showUpgradeWarningMessage } from './utilities/messaging'; import { loadTreeView } from "./workspaceTreeProvider"; -import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDescriptionCommand'; -import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; -import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; -import { EditPathsCommand } from './commands/EditPathsCommand'; -import { RegenerateButtonCommand } from './commands/regenerate/RegenerateButtonCommand'; -import { RegenerateCommand } from './commands/regenerate/RegenerateCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; From 4c1060eaeb9a4fd3ef1d25252cc4f91453099f55 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 10:00:27 +0300 Subject: [PATCH 134/150] open api tree node commands --- .../src/commands/GenerateCommand.ts | 2 +- .../AddAllToSelectedEndpointsCommand.ts | 16 +++++++ .../AddToSelectedEndpointsCommand.ts | 17 +++++++ .../OpenDocumentationPageCommand.ts} | 6 +-- .../RemoveAllFromSelectedEndpointsCommand.ts | 16 +++++++ .../RemoveFromSelectedEndpointsCommand.ts | 16 +++++++ vscode/microsoft-kiota/src/extension.ts | 47 ++++++++----------- 7 files changed, 88 insertions(+), 32 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts create mode 100644 vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts rename vscode/microsoft-kiota/src/commands/{OpenApiTreeNodeCommand.ts => open-api-tree-node/OpenDocumentationPageCommand.ts} (62%) create mode 100644 vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts create mode 100644 vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts diff --git a/vscode/microsoft-kiota/src/commands/GenerateCommand.ts b/vscode/microsoft-kiota/src/commands/GenerateCommand.ts index a61a7bde76..3f22cb52f7 100644 --- a/vscode/microsoft-kiota/src/commands/GenerateCommand.ts +++ b/vscode/microsoft-kiota/src/commands/GenerateCommand.ts @@ -21,7 +21,7 @@ import { GeneratedOutputState } from './GeneratedOutputState'; import { loadLockFile } from "../utilities/file"; import { Command } from "./Command"; -export class GenerateCommand extends Command { +export class GenerateClientCommand extends Command { private _context: ExtensionContext; private _openApiTreeProvider: OpenApiTreeProvider; diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts new file mode 100644 index 0000000000..fecbb33234 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts @@ -0,0 +1,16 @@ +import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { Command } from "../Command"; + +export class AddAllToSelectedEndpointsCommand extends Command { + private _openApiTreeProvider: OpenApiTreeProvider; + + constructor(openApiTreeProvider: OpenApiTreeProvider) { + super();; + this._openApiTreeProvider = openApiTreeProvider; + } + + execute(openApiTreeNode: OpenApiTreeNode): void { + this._openApiTreeProvider.select(openApiTreeNode, true, true); + } + +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts new file mode 100644 index 0000000000..4437963110 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts @@ -0,0 +1,17 @@ +import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { Command } from "../Command"; + +export class AddToSelectedEndpointsCommand extends Command { + + private _openApiTreeProvider: OpenApiTreeProvider; + + constructor(openApiTreeProvider: OpenApiTreeProvider) { + super();; + this._openApiTreeProvider = openApiTreeProvider; + } + + execute(openApiTreeNode: OpenApiTreeNode): void { + this._openApiTreeProvider.select(openApiTreeNode, true, false); + } + +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/commands/OpenApiTreeNodeCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/OpenDocumentationPageCommand.ts similarity index 62% rename from vscode/microsoft-kiota/src/commands/OpenApiTreeNodeCommand.ts rename to vscode/microsoft-kiota/src/commands/open-api-tree-node/OpenDocumentationPageCommand.ts index 413676a5cc..ecaa2d724f 100644 --- a/vscode/microsoft-kiota/src/commands/OpenApiTreeNodeCommand.ts +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/OpenDocumentationPageCommand.ts @@ -1,8 +1,8 @@ import * as vscode from "vscode"; -import { OpenApiTreeNode } from "../openApiTreeProvider"; -import { Command } from "./Command"; +import { OpenApiTreeNode } from "../../openApiTreeProvider"; +import { Command } from "../Command"; -export class OpenApiTreeNodeCommand extends Command { +export class OpenDocumentationPageCommand extends Command { constructor() { super(); } diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts new file mode 100644 index 0000000000..20143d3f88 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts @@ -0,0 +1,16 @@ +import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { Command } from "../Command"; + +export class RemoveAllFromSelectedEndpointsCommand extends Command { + private _openApiTreeProvider: OpenApiTreeProvider; + + constructor(openApiTreeProvider: OpenApiTreeProvider) { + super();; + this._openApiTreeProvider = openApiTreeProvider; + } + + execute(openApiTreeNode: OpenApiTreeNode): void { + this._openApiTreeProvider.select(openApiTreeNode, false, true); + } + +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts new file mode 100644 index 0000000000..cdc1c0883c --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts @@ -0,0 +1,16 @@ +import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { Command } from "../Command"; + +export class RemoveFromSelectedEndpointsCommand extends Command { + private _openApiTreeProvider: OpenApiTreeProvider; + + constructor(openApiTreeProvider: OpenApiTreeProvider) { + super();; + this._openApiTreeProvider = openApiTreeProvider; + } + + execute(openApiTreeNode: OpenApiTreeNode): void { + this._openApiTreeProvider.select(openApiTreeNode, false, false); + } + +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 918f1f6fd1..47b5d678bc 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -6,14 +6,16 @@ import * as path from 'path'; import * as vscode from "vscode"; import { CodeLensProvider } from "./codelensProvider"; -import { KiotaStatusCommand } from "./commands/KiotaStatusCommand"; -import { OpenApiTreeNodeCommand } from "./commands/OpenApiTreeNodeCommand"; - import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; import { EditPathsCommand } from './commands/EditPathsCommand'; import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; -import { GenerateCommand } from './commands/GenerateCommand'; +import { GenerateClientCommand } from './commands/GenerateCommand'; import { GeneratedOutputState } from './commands/GeneratedOutputState'; +import { KiotaStatusCommand } from "./commands/KiotaStatusCommand"; +import { AddToSelectedEndpointsCommand } from './commands/open-api-tree-node/AddToSelectedEndpointsCommand'; +import { OpenDocumentationPageCommand } from "./commands/open-api-tree-node/OpenDocumentationPageCommand"; +import { RemoveAllFromSelectedEndpointsCommand } from './commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand'; +import { RemoveFromSelectedEndpointsCommand } from './commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand'; import { RegenerateButtonCommand } from './commands/regenerate/RegenerateButtonCommand'; import { RegenerateCommand } from './commands/regenerate/RegenerateCommand'; import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDescriptionCommand'; @@ -51,14 +53,18 @@ export async function activate( ); const kiotaStatusCommand = new KiotaStatusCommand(); - const openApiTreeNodeCommand = new OpenApiTreeNodeCommand(); - const generateCommand = new GenerateCommand(context, openApiTreeProvider); + const openDocumentationPageCommand = new OpenDocumentationPageCommand(); + const generateClientCommand = new GenerateClientCommand(context, openApiTreeProvider); const searchOrOpenApiDescriptionCommand = new SearchOrOpenApiDescriptionCommand(context, openApiTreeProvider); const closeDescriptionCommand = new CloseDescriptionCommand(openApiTreeProvider); const filterDescriptionCommand = new FilterDescriptionCommand(openApiTreeProvider); const editPathsCommand = new EditPathsCommand(openApiTreeProvider, clientOrPluginKey, clientOrPluginObject); const regenerateButtonCommand = new RegenerateButtonCommand(context, openApiTreeProvider, clientOrPluginKey, clientOrPluginObject, workspaceGenerationType); const regenerateCommand = new RegenerateCommand(context, openApiTreeProvider, clientOrPluginKey, clientOrPluginObject, workspaceGenerationType); + const addToSelectedEndpointsCommand = new AddToSelectedEndpointsCommand(openApiTreeProvider); + const addAllToSelectedEndpointsCommand = new AddToSelectedEndpointsCommand(openApiTreeProvider); + const removeFromSelectedEndpointsCommand = new RemoveFromSelectedEndpointsCommand(openApiTreeProvider); + const removeAllFromSelectedEndpointsCommand = new RemoveAllFromSelectedEndpointsCommand(openApiTreeProvider); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); @@ -97,32 +103,17 @@ export async function activate( dependenciesInfoProvider ), vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider), - registerCommandWithTelemetry(reporter, - `${treeViewId}.openDocumentationPage`, - (x: OpenApiTreeNode) => openApiTreeNodeCommand.execute(x) - ), - registerCommandWithTelemetry(reporter, - `${treeViewId}.addToSelectedEndpoints`, - (x: OpenApiTreeNode) => openApiTreeProvider.select(x, true, false) - ), - registerCommandWithTelemetry(reporter, - `${treeViewId}.addAllToSelectedEndpoints`, - (x: OpenApiTreeNode) => openApiTreeProvider.select(x, true, true) - ), - registerCommandWithTelemetry(reporter, - `${treeViewId}.removeFromSelectedEndpoints`, - (x: OpenApiTreeNode) => openApiTreeProvider.select(x, false, false) - ), - registerCommandWithTelemetry(reporter, - `${treeViewId}.removeAllFromSelectedEndpoints`, - (x: OpenApiTreeNode) => openApiTreeProvider.select(x, false, true) - ), - registerCommandWithTelemetry(reporter, `${treeViewId}.generateClient`, () => generateCommand.execute()), + registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, (openApiTreeNode: OpenApiTreeNode) => openDocumentationPageCommand.execute(openApiTreeNode)), + registerCommandWithTelemetry(reporter, `${treeViewId}.addToSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => addToSelectedEndpointsCommand.execute(openApiTreeNode)), + registerCommandWithTelemetry(reporter, `${treeViewId}.addAllToSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => addAllToSelectedEndpointsCommand.execute(openApiTreeNode)), + registerCommandWithTelemetry(reporter, `${treeViewId}.removeFromSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => removeFromSelectedEndpointsCommand.execute(openApiTreeNode)), + registerCommandWithTelemetry(reporter, `${treeViewId}.removeAllFromSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => removeAllFromSelectedEndpointsCommand.execute(openApiTreeNode)), + registerCommandWithTelemetry(reporter, `${treeViewId}.generateClient`, () => generateClientCommand.execute()), vscode.workspace.onDidChangeWorkspaceFolders(async () => { const generatedOutput = context.workspaceState.get('generatedOutput'); if (generatedOutput) { const { outputPath } = generatedOutput; - await generateCommand.displayGenerationResults(config, outputPath); + await generateClientCommand.displayGenerationResults(config, outputPath); // Clear the state void context.workspaceState.update('generatedOutput', undefined); } From 239431f3f0714edfa3129cfc5a4d9236ff75b651 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 10:28:33 +0300 Subject: [PATCH 135/150] create update clients command --- ...ateCommand.ts => GenerateClientCommand.ts} | 0 .../src/commands/UpdateClientsCommand.ts | 64 +++++++++++++ vscode/microsoft-kiota/src/extension.ts | 94 +++---------------- .../src/utilities/status-bar.ts | 25 +++++ 4 files changed, 101 insertions(+), 82 deletions(-) rename vscode/microsoft-kiota/src/commands/{GenerateCommand.ts => GenerateClientCommand.ts} (100%) create mode 100644 vscode/microsoft-kiota/src/commands/UpdateClientsCommand.ts create mode 100644 vscode/microsoft-kiota/src/utilities/status-bar.ts diff --git a/vscode/microsoft-kiota/src/commands/GenerateCommand.ts b/vscode/microsoft-kiota/src/commands/GenerateClientCommand.ts similarity index 100% rename from vscode/microsoft-kiota/src/commands/GenerateCommand.ts rename to vscode/microsoft-kiota/src/commands/GenerateClientCommand.ts diff --git a/vscode/microsoft-kiota/src/commands/UpdateClientsCommand.ts b/vscode/microsoft-kiota/src/commands/UpdateClientsCommand.ts new file mode 100644 index 0000000000..60a0960d6d --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/UpdateClientsCommand.ts @@ -0,0 +1,64 @@ +import * as path from 'path'; +import * as vscode from "vscode"; +import { ExtensionContext, StatusBarItem } from 'vscode'; + +import { KIOTA_WORKSPACE_FILE, extensionId } from "../constants"; +import { getExtensionSettings } from "../extensionSettings"; +import { updateClients } from "../updateClients"; +import { exportLogsAndShowErrors, kiotaOutputChannel } from "../utilities/logging"; +import { showUpgradeWarningMessage } from "../utilities/messaging"; +import { updateStatusBarItem } from '../utilities/status-bar'; +import { Command } from "./Command"; + +export class UpdateClientsCommand extends Command { + + private _context: ExtensionContext; + + public constructor(context: ExtensionContext) { + super(); + this._context = context; + } + + async execute(kiotaStatusBarItem: StatusBarItem): Promise { + if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) { + await vscode.window.showErrorMessage( + vscode.l10n.t("No workspace folder found, open a folder first") + ); + return; + } + const existingLockFileUris = await vscode.workspace.findFiles(`**/${KIOTA_WORKSPACE_FILE}`); + if (existingLockFileUris.length > 0) { + await Promise.all(existingLockFileUris.map(x => path.dirname(x.fsPath)).map(x => showUpgradeWarningMessage(this._context, x))); + } + await updateStatusBarItem(this._context, kiotaStatusBarItem); + try { + kiotaOutputChannel.clear(); + kiotaOutputChannel.show(); + kiotaOutputChannel.info( + vscode.l10n.t("updating client with path {path}", { + path: vscode.workspace.workspaceFolders[0].uri.fsPath, + }) + ); + const res = await vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + cancellable: false, + title: vscode.l10n.t("Updating clients...") + }, (progress, _) => { + const settings = getExtensionSettings(extensionId); + return updateClients(this._context, settings.cleanOutput, settings.clearCache); + }); + if (res) { + await exportLogsAndShowErrors(res); + } + } catch (error) { + kiotaOutputChannel.error( + vscode.l10n.t("error updating the clients {error}"), + error + ); + await vscode.window.showErrorMessage( + vscode.l10n.t("error updating the clients {error}"), + error as string + ); + } + } +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 47b5d678bc..f9f4ca7732 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -1,15 +1,15 @@ // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below import TelemetryReporter from '@vscode/extension-telemetry'; - -import * as path from 'path'; import * as vscode from "vscode"; +import { commands } from 'vscode'; import { CodeLensProvider } from "./codelensProvider"; + import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; import { EditPathsCommand } from './commands/EditPathsCommand'; import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; -import { GenerateClientCommand } from './commands/GenerateCommand'; +import { GenerateClientCommand } from './commands/GenerateClientCommand'; import { GeneratedOutputState } from './commands/GeneratedOutputState'; import { KiotaStatusCommand } from "./commands/KiotaStatusCommand"; import { AddToSelectedEndpointsCommand } from './commands/open-api-tree-node/AddToSelectedEndpointsCommand'; @@ -19,20 +19,16 @@ import { RemoveFromSelectedEndpointsCommand } from './commands/open-api-tree-nod import { RegenerateButtonCommand } from './commands/regenerate/RegenerateButtonCommand'; import { RegenerateCommand } from './commands/regenerate/RegenerateCommand'; import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDescriptionCommand'; -import { KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewId } from "./constants"; +import { updateStatusBarItem } from './utilities/status-bar'; +import { UpdateClientsCommand } from './commands/UpdateClientsCommand'; + +import { dependenciesInfo, extensionId, statusBarCommandId, treeViewId } from "./constants"; import { DependenciesViewProvider } from "./dependenciesViewProvider"; import { getExtensionSettings } from "./extensionSettings"; -import { getKiotaVersion } from "./getKiotaVersion"; -import { - ClientOrPluginProperties, - KiotaLogEntry -} from "./kiotaInterop"; +import { ClientOrPluginProperties, KiotaLogEntry } from "./kiotaInterop"; import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider"; import { GenerateState } from "./steps"; -import { updateClients } from "./updateClients"; import { loadLockFile, openTreeViewWithProgress } from './utilities/file'; -import { exportLogsAndShowErrors, kiotaOutputChannel } from './utilities/logging'; -import { showUpgradeWarningMessage } from './utilities/messaging'; import { loadTreeView } from "./workspaceTreeProvider"; let kiotaStatusBarItem: vscode.StatusBarItem; @@ -65,6 +61,7 @@ export async function activate( const addAllToSelectedEndpointsCommand = new AddToSelectedEndpointsCommand(openApiTreeProvider); const removeFromSelectedEndpointsCommand = new RemoveFromSelectedEndpointsCommand(openApiTreeProvider); const removeAllFromSelectedEndpointsCommand = new RemoveAllFromSelectedEndpointsCommand(openApiTreeProvider); + const updateClientsCommand = new UpdateClientsCommand(context); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); @@ -103,7 +100,7 @@ export async function activate( dependenciesInfoProvider ), vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider), - registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, (openApiTreeNode: OpenApiTreeNode) => openDocumentationPageCommand.execute(openApiTreeNode)), + registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, (openApiTreeNode: OpenApiTreeNode) => openDocumentationPageCommand.execute(openApiTreeNode)), registerCommandWithTelemetry(reporter, `${treeViewId}.addToSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => addToSelectedEndpointsCommand.execute(openApiTreeNode)), registerCommandWithTelemetry(reporter, `${treeViewId}.addAllToSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => addAllToSelectedEndpointsCommand.execute(openApiTreeNode)), registerCommandWithTelemetry(reporter, `${treeViewId}.removeFromSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => removeFromSelectedEndpointsCommand.execute(openApiTreeNode)), @@ -135,57 +132,8 @@ export async function activate( context.subscriptions.push(kiotaStatusBarItem); // update status bar item once at start - await updateStatusBarItem(context); - let disposable = vscode.commands.registerCommand( - `${extensionId}.updateClients`, - async () => { - if ( - !vscode.workspace.workspaceFolders || - vscode.workspace.workspaceFolders.length === 0 - ) { - await vscode.window.showErrorMessage( - vscode.l10n.t("No workspace folder found, open a folder first") - ); - return; - } - const existingLockFileUris = await vscode.workspace.findFiles(`**/${KIOTA_WORKSPACE_FILE}`); - if (existingLockFileUris.length > 0) { - await Promise.all(existingLockFileUris.map(x => path.dirname(x.fsPath)).map(x => showUpgradeWarningMessage(context, x))); - } - await updateStatusBarItem(context); - try { - kiotaOutputChannel.clear(); - kiotaOutputChannel.show(); - kiotaOutputChannel.info( - vscode.l10n.t("updating client with path {path}", { - path: vscode.workspace.workspaceFolders[0].uri.fsPath, - }) - ); - const res = await vscode.window.withProgress({ - location: vscode.ProgressLocation.Notification, - cancellable: false, - title: vscode.l10n.t("Updating clients...") - }, (progress, _) => { - const settings = getExtensionSettings(extensionId); - return updateClients(context, settings.cleanOutput, settings.clearCache); - }); - if (res) { - await exportLogsAndShowErrors(res); - } - } catch (error) { - kiotaOutputChannel.error( - vscode.l10n.t("error updating the clients {error}"), - error - ); - await vscode.window.showErrorMessage( - vscode.l10n.t("error updating the clients {error}"), - error as string - ); - } - } - ); - - context.subscriptions.push(disposable); + await updateStatusBarItem(context, kiotaStatusBarItem); + context.subscriptions.push(commands.registerCommand(`${extensionId}.updateClients`, async () => updateClientsCommand.execute(kiotaStatusBarItem))); } @@ -198,24 +146,6 @@ function registerCommandWithTelemetry(reporter: TelemetryReporter, command: stri }, thisArg); } -async function updateStatusBarItem(context: vscode.ExtensionContext): Promise { - try { - const version = await getKiotaVersion(context, kiotaOutputChannel); - if (!version) { - throw new Error("kiota not found"); - } - kiotaStatusBarItem.text = `$(extensions-info-message) kiota ${version}`; - } catch (error) { - kiotaStatusBarItem.text = `$(extensions-warning-message) kiota ${vscode.l10n.t( - "not found" - )}`; - kiotaStatusBarItem.backgroundColor = new vscode.ThemeColor( - "statusBarItem.errorBackground" - ); - } - kiotaStatusBarItem.show(); -} - function getQueryParameters(uri: vscode.Uri): Record { const query = uri.query; if (!query) { diff --git a/vscode/microsoft-kiota/src/utilities/status-bar.ts b/vscode/microsoft-kiota/src/utilities/status-bar.ts new file mode 100644 index 0000000000..c866fd550f --- /dev/null +++ b/vscode/microsoft-kiota/src/utilities/status-bar.ts @@ -0,0 +1,25 @@ +import * as vscode from "vscode"; + +import { ExtensionContext, StatusBarItem } from "vscode"; +import { getKiotaVersion } from "../getKiotaVersion"; +import { kiotaOutputChannel } from "./logging"; + +async function updateStatusBarItem(context: ExtensionContext, kiotaStatusBarItem: StatusBarItem): Promise { + try { + const version = await getKiotaVersion(context, kiotaOutputChannel); + if (!version) { + throw new Error("kiota not found"); + } + kiotaStatusBarItem.text = `$(extensions-info-message) kiota ${version}`; + } catch (error) { + kiotaStatusBarItem.text = `$(extensions-warning-message) kiota ${vscode.l10n.t( + "not found" + )}`; + kiotaStatusBarItem.backgroundColor = new vscode.ThemeColor( + "statusBarItem.errorBackground" + ); + } + kiotaStatusBarItem.show(); +} + +export { updateStatusBarItem }; \ No newline at end of file From 1c9346c01cc31c8f8101ec8a4c41b0c57428fab8 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 10:38:57 +0300 Subject: [PATCH 136/150] create display generation results command --- .../DisplayGenerationResultsCommand.ts | 30 +++++++++++++ .../GenerateClientCommand.ts | 42 +++++++------------ .../generate-client/generation-results.ts | 22 ++++++++++ vscode/microsoft-kiota/src/extension.ts | 22 +++------- 4 files changed, 74 insertions(+), 42 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts rename vscode/microsoft-kiota/src/commands/{ => generate-client}/GenerateClientCommand.ts (85%) create mode 100644 vscode/microsoft-kiota/src/commands/generate-client/generation-results.ts diff --git a/vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts b/vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts new file mode 100644 index 0000000000..6467de8b66 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts @@ -0,0 +1,30 @@ +import { ExtensionContext } from "vscode"; + +import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { GenerateState } from "../../steps"; +import { Command } from "../Command"; +import { GeneratedOutputState } from "../GeneratedOutputState"; +import { displayGenerationResults } from "./generation-results"; + +export class DisplayGenerationResultsCommand extends Command { + private _context: ExtensionContext; + private _openApiTreeProvider: OpenApiTreeProvider; + + public constructor(context: ExtensionContext, openApiTreeProvider: OpenApiTreeProvider) { + super(); + this._context = context; + this._openApiTreeProvider = openApiTreeProvider; + } + + async execute(config: Partial): Promise { + const generatedOutput = this._context.workspaceState.get('generatedOutput'); + if (generatedOutput) { + const { outputPath } = generatedOutput; + await displayGenerationResults(config, outputPath, this._openApiTreeProvider); + // Clear the state + void this._context.workspaceState.update('generatedOutput', undefined); + } + } + + +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/commands/GenerateClientCommand.ts b/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts similarity index 85% rename from vscode/microsoft-kiota/src/commands/GenerateClientCommand.ts rename to vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts index 3f22cb52f7..297b7d7f0d 100644 --- a/vscode/microsoft-kiota/src/commands/GenerateClientCommand.ts +++ b/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts @@ -1,25 +1,25 @@ import * as vscode from "vscode"; import { ExtensionContext } from "vscode"; -import { extensionId, treeViewFocusCommand, treeViewId } from "../constants"; -import { DependenciesViewProvider } from '../dependenciesViewProvider'; -import { ExtensionSettings, getExtensionSettings } from "../extensionSettings"; -import { generateClient } from '../generateClient'; -import { generatePlugin } from '../generatePlugin'; -import { getLanguageInformation, getLanguageInformationForDescription } from "../getLanguageInformation"; +import { extensionId, treeViewFocusCommand } from "../../constants"; +import { DependenciesViewProvider } from '../../dependenciesViewProvider'; +import { ExtensionSettings, getExtensionSettings } from "../../extensionSettings"; +import { generateClient } from '../../generateClient'; +import { generatePlugin } from '../../generatePlugin'; +import { getLanguageInformation, getLanguageInformationForDescription } from "../../getLanguageInformation"; import { ConsumerOperation, getLogEntriesForLevel, KiotaGenerationLanguage, KiotaLogEntry, KiotaPluginType, LogLevel, parseGenerationLanguage, parsePluginType -} from "../kiotaInterop"; -import { OpenApiTreeProvider } from "../openApiTreeProvider"; -import { GenerateState, generateSteps, GenerationType, parseGenerationType } from "../steps"; -import { getWorkspaceJsonDirectory, getWorkspaceJsonPath, updateTreeViewIcons } from "../util"; -import { exportLogsAndShowErrors } from '../utilities/logging'; -import { showUpgradeWarningMessage } from "../utilities/messaging"; -import { GeneratedOutputState } from './GeneratedOutputState'; -import { loadLockFile } from "../utilities/file"; -import { Command } from "./Command"; +} from "../../kiotaInterop"; +import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { GenerateState, generateSteps, GenerationType, parseGenerationType } from "../../steps"; +import { getWorkspaceJsonDirectory } from "../../util"; +import { exportLogsAndShowErrors } from '../../utilities/logging'; +import { showUpgradeWarningMessage } from "../../utilities/messaging"; +import { Command } from "../Command"; +import { GeneratedOutputState } from '../GeneratedOutputState'; +import { displayGenerationResults } from "./generation-results"; export class GenerateClientCommand extends Command { @@ -92,21 +92,11 @@ export class GenerateClientCommand extends Command { if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) { await vscode.commands.executeCommand('vscode.openFolder', vscode.Uri.file(config.workingDirectory ?? getWorkspaceJsonDirectory()), true); } else { - await this.displayGenerationResults(config, outputPath); + await displayGenerationResults(config, outputPath, this._openApiTreeProvider); } } } - public async displayGenerationResults(config: Partial, _outputPath: string) { - const clientNameOrPluginName = config.clientClassName || config.pluginName; - this._openApiTreeProvider.refreshView(); - const workspaceJsonPath = getWorkspaceJsonPath(); - await loadLockFile({ fsPath: workspaceJsonPath }, this._openApiTreeProvider, clientNameOrPluginName); - await vscode.commands.executeCommand('kiota.workspace.refresh'); - this._openApiTreeProvider.resetInitialState(); - await updateTreeViewIcons(treeViewId, false, true); - } - async generateClientAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { const language = typeof config.language === "string" diff --git a/vscode/microsoft-kiota/src/commands/generate-client/generation-results.ts b/vscode/microsoft-kiota/src/commands/generate-client/generation-results.ts new file mode 100644 index 0000000000..172f75e45c --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/generate-client/generation-results.ts @@ -0,0 +1,22 @@ +import * as vscode from "vscode"; + +import { treeViewId } from "../../constants"; +import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { GenerateState } from "../../steps"; +import { getWorkspaceJsonPath, updateTreeViewIcons } from "../../util"; +import { loadLockFile } from "../../utilities/file"; + +async function displayGenerationResults(config: Partial, _outputPath: string, openApiTreeProvider: OpenApiTreeProvider) { + const clientNameOrPluginName = config.clientClassName || config.pluginName; + openApiTreeProvider.refreshView(); + const workspaceJsonPath = getWorkspaceJsonPath(); + await loadLockFile({ fsPath: workspaceJsonPath }, openApiTreeProvider, clientNameOrPluginName); + await vscode.commands.executeCommand('kiota.workspace.refresh'); + openApiTreeProvider.resetInitialState(); + await updateTreeViewIcons(treeViewId, false, true); +} + +export { + displayGenerationResults +}; + diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index f9f4ca7732..7ad9398c92 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -9,8 +9,7 @@ import { CodeLensProvider } from "./codelensProvider"; import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; import { EditPathsCommand } from './commands/EditPathsCommand'; import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; -import { GenerateClientCommand } from './commands/GenerateClientCommand'; -import { GeneratedOutputState } from './commands/GeneratedOutputState'; +import { GenerateClientCommand } from './commands/generate-client/GenerateClientCommand'; import { KiotaStatusCommand } from "./commands/KiotaStatusCommand"; import { AddToSelectedEndpointsCommand } from './commands/open-api-tree-node/AddToSelectedEndpointsCommand'; import { OpenDocumentationPageCommand } from "./commands/open-api-tree-node/OpenDocumentationPageCommand"; @@ -19,8 +18,8 @@ import { RemoveFromSelectedEndpointsCommand } from './commands/open-api-tree-nod import { RegenerateButtonCommand } from './commands/regenerate/RegenerateButtonCommand'; import { RegenerateCommand } from './commands/regenerate/RegenerateCommand'; import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDescriptionCommand'; -import { updateStatusBarItem } from './utilities/status-bar'; import { UpdateClientsCommand } from './commands/UpdateClientsCommand'; +import { updateStatusBarItem } from './utilities/status-bar'; import { dependenciesInfo, extensionId, statusBarCommandId, treeViewId } from "./constants"; import { DependenciesViewProvider } from "./dependenciesViewProvider"; @@ -30,6 +29,7 @@ import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider"; import { GenerateState } from "./steps"; import { loadLockFile, openTreeViewWithProgress } from './utilities/file'; import { loadTreeView } from "./workspaceTreeProvider"; +import { DisplayGenerationResultsCommand } from './commands/generate-client/DisplayGenerationResultsCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; @@ -62,6 +62,7 @@ export async function activate( const removeFromSelectedEndpointsCommand = new RemoveFromSelectedEndpointsCommand(openApiTreeProvider); const removeAllFromSelectedEndpointsCommand = new RemoveAllFromSelectedEndpointsCommand(openApiTreeProvider); const updateClientsCommand = new UpdateClientsCommand(context); + const displayGenerationResultsCommand = new DisplayGenerationResultsCommand(context, openApiTreeProvider); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); @@ -95,10 +96,7 @@ export async function activate( (x) => loadLockFile(x, openApiTreeProvider) ), registerCommandWithTelemetry(reporter, statusBarCommandId, await kiotaStatusCommand.execute()), - vscode.window.registerWebviewViewProvider( - dependenciesInfo, - dependenciesInfoProvider - ), + vscode.window.registerWebviewViewProvider(dependenciesInfo, dependenciesInfoProvider), vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider), registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, (openApiTreeNode: OpenApiTreeNode) => openDocumentationPageCommand.execute(openApiTreeNode)), registerCommandWithTelemetry(reporter, `${treeViewId}.addToSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => addToSelectedEndpointsCommand.execute(openApiTreeNode)), @@ -106,15 +104,7 @@ export async function activate( registerCommandWithTelemetry(reporter, `${treeViewId}.removeFromSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => removeFromSelectedEndpointsCommand.execute(openApiTreeNode)), registerCommandWithTelemetry(reporter, `${treeViewId}.removeAllFromSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => removeAllFromSelectedEndpointsCommand.execute(openApiTreeNode)), registerCommandWithTelemetry(reporter, `${treeViewId}.generateClient`, () => generateClientCommand.execute()), - vscode.workspace.onDidChangeWorkspaceFolders(async () => { - const generatedOutput = context.workspaceState.get('generatedOutput'); - if (generatedOutput) { - const { outputPath } = generatedOutput; - await generateClientCommand.displayGenerationResults(config, outputPath); - // Clear the state - void context.workspaceState.update('generatedOutput', undefined); - } - }), + vscode.workspace.onDidChangeWorkspaceFolders(async () => displayGenerationResultsCommand.execute(config)), registerCommandWithTelemetry(reporter, `${treeViewId}.searchOrOpenApiDescription`, () => searchOrOpenApiDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, () => closeDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`, () => filterDescriptionCommand.execute()), From 86fa5ec39fd2b07fa5c8b86d567a493db1bd5905 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 10:53:08 +0300 Subject: [PATCH 137/150] create select lock command --- .../src/commands/KiotaStatusCommand.ts | 22 ++++++------ .../src/commands/SelectLockCommand.ts | 16 +++++++++ vscode/microsoft-kiota/src/extension.ts | 35 +++++-------------- 3 files changed, 35 insertions(+), 38 deletions(-) create mode 100644 vscode/microsoft-kiota/src/commands/SelectLockCommand.ts diff --git a/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts b/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts index 56c4dcb3e0..38cdd628dd 100644 --- a/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts +++ b/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts @@ -6,17 +6,15 @@ export class KiotaStatusCommand extends Command { super(); } - public async execute(): Promise<() => Promise> { - return async () => { - const yesAnswer = vscode.l10n.t("Yes"); - const response = await vscode.window.showInformationMessage( - vscode.l10n.t("Open installation instructions for kiota?"), - yesAnswer, - vscode.l10n.t("No") - ); - if (response === yesAnswer) { - await vscode.env.openExternal(vscode.Uri.parse("https://aka.ms/get/kiota")); - } - }; + async execute() { + const yesAnswer = vscode.l10n.t("Yes"); + const response = await vscode.window.showInformationMessage( + vscode.l10n.t("Open installation instructions for kiota?"), + yesAnswer, + vscode.l10n.t("No") + ); + if (response === yesAnswer) { + await vscode.env.openExternal(vscode.Uri.parse("https://aka.ms/get/kiota")); + } } } \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/commands/SelectLockCommand.ts b/vscode/microsoft-kiota/src/commands/SelectLockCommand.ts new file mode 100644 index 0000000000..e40dc066e6 --- /dev/null +++ b/vscode/microsoft-kiota/src/commands/SelectLockCommand.ts @@ -0,0 +1,16 @@ +import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { loadLockFile } from "../utilities/file"; +import { Command } from "./Command"; + +export class SelectLockCommand extends Command { + private _openApiTreeProvider: OpenApiTreeProvider; + + constructor(openApiTreeProvider: OpenApiTreeProvider) { + super(); + this._openApiTreeProvider = openApiTreeProvider; + } + + execute(x: any): void { + void loadLockFile(x, this._openApiTreeProvider); + } +}; \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 7ad9398c92..0bccc24580 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -21,15 +21,16 @@ import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDes import { UpdateClientsCommand } from './commands/UpdateClientsCommand'; import { updateStatusBarItem } from './utilities/status-bar'; +import { DisplayGenerationResultsCommand } from './commands/generate-client/DisplayGenerationResultsCommand'; +import { SelectLockCommand } from './commands/SelectLockCommand'; import { dependenciesInfo, extensionId, statusBarCommandId, treeViewId } from "./constants"; import { DependenciesViewProvider } from "./dependenciesViewProvider"; import { getExtensionSettings } from "./extensionSettings"; -import { ClientOrPluginProperties, KiotaLogEntry } from "./kiotaInterop"; +import { ClientOrPluginProperties } from "./kiotaInterop"; import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider"; import { GenerateState } from "./steps"; -import { loadLockFile, openTreeViewWithProgress } from './utilities/file'; +import { openTreeViewWithProgress } from './utilities/file'; import { loadTreeView } from "./workspaceTreeProvider"; -import { DisplayGenerationResultsCommand } from './commands/generate-client/DisplayGenerationResultsCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; @@ -63,6 +64,7 @@ export async function activate( const removeAllFromSelectedEndpointsCommand = new RemoveAllFromSelectedEndpointsCommand(openApiTreeProvider); const updateClientsCommand = new UpdateClientsCommand(context); const displayGenerationResultsCommand = new DisplayGenerationResultsCommand(context, openApiTreeProvider); + const selectLockCommand = new SelectLockCommand(openApiTreeProvider); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); @@ -85,17 +87,11 @@ export async function activate( ); }; context.subscriptions.push( - vscode.window.registerUriHandler({ - handleUri - }), - + vscode.window.registerUriHandler({ handleUri }), vscode.languages.registerCodeLensProvider('json', codeLensProvider), reporter, - registerCommandWithTelemetry(reporter, - `${extensionId}.selectLock`, - (x) => loadLockFile(x, openApiTreeProvider) - ), - registerCommandWithTelemetry(reporter, statusBarCommandId, await kiotaStatusCommand.execute()), + registerCommandWithTelemetry(reporter, `${extensionId}.selectLock`, (x) => selectLockCommand.execute(x)), + registerCommandWithTelemetry(reporter, statusBarCommandId, async () => kiotaStatusCommand.execute()), vscode.window.registerWebviewViewProvider(dependenciesInfo, dependenciesInfoProvider), vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider), registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, (openApiTreeNode: OpenApiTreeNode) => openDocumentationPageCommand.execute(openApiTreeNode)), @@ -114,10 +110,7 @@ export async function activate( ); // create a new status bar item that we can now manage - kiotaStatusBarItem = vscode.window.createStatusBarItem( - vscode.StatusBarAlignment.Right, - 100 - ); + kiotaStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100); kiotaStatusBarItem.command = statusBarCommandId; context.subscriptions.push(kiotaStatusBarItem); @@ -149,16 +142,6 @@ function getQueryParameters(uri: vscode.Uri): Record { }); return parameters; } -async function checkForSuccess(results: KiotaLogEntry[]) { - for (const result of results) { - if (result && result.message) { - if (result.message.includes("Generation completed successfully")) { - void vscode.window.showInformationMessage('Generation completed successfully.'); - } - } - } -} - // This method is called when your extension is deactivated export function deactivate() { } From 1d89fb4ce62d3d0a84906024047d1e89b5b33b24 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 11:10:26 +0300 Subject: [PATCH 138/150] create uri handler --- vscode/microsoft-kiota/src/extension.ts | 43 +++------------ .../src/handlers/uri.handler.ts | 52 +++++++++++++++++++ 2 files changed, 59 insertions(+), 36 deletions(-) create mode 100644 vscode/microsoft-kiota/src/handlers/uri.handler.ts diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 0bccc24580..8d5f49fee9 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -9,6 +9,7 @@ import { CodeLensProvider } from "./codelensProvider"; import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; import { EditPathsCommand } from './commands/EditPathsCommand'; import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; +import { DisplayGenerationResultsCommand } from './commands/generate-client/DisplayGenerationResultsCommand'; import { GenerateClientCommand } from './commands/generate-client/GenerateClientCommand'; import { KiotaStatusCommand } from "./commands/KiotaStatusCommand"; import { AddToSelectedEndpointsCommand } from './commands/open-api-tree-node/AddToSelectedEndpointsCommand'; @@ -18,18 +19,17 @@ import { RemoveFromSelectedEndpointsCommand } from './commands/open-api-tree-nod import { RegenerateButtonCommand } from './commands/regenerate/RegenerateButtonCommand'; import { RegenerateCommand } from './commands/regenerate/RegenerateCommand'; import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDescriptionCommand'; +import { SelectLockCommand } from './commands/SelectLockCommand'; import { UpdateClientsCommand } from './commands/UpdateClientsCommand'; -import { updateStatusBarItem } from './utilities/status-bar'; -import { DisplayGenerationResultsCommand } from './commands/generate-client/DisplayGenerationResultsCommand'; -import { SelectLockCommand } from './commands/SelectLockCommand'; import { dependenciesInfo, extensionId, statusBarCommandId, treeViewId } from "./constants"; import { DependenciesViewProvider } from "./dependenciesViewProvider"; import { getExtensionSettings } from "./extensionSettings"; +import { UriHandler } from './handlers/uri.handler'; import { ClientOrPluginProperties } from "./kiotaInterop"; import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider"; import { GenerateState } from "./steps"; -import { openTreeViewWithProgress } from './utilities/file'; +import { updateStatusBarItem } from './utilities/status-bar'; import { loadTreeView } from "./workspaceTreeProvider"; let kiotaStatusBarItem: vscode.StatusBarItem; @@ -65,29 +65,14 @@ export async function activate( const updateClientsCommand = new UpdateClientsCommand(context); const displayGenerationResultsCommand = new DisplayGenerationResultsCommand(context, openApiTreeProvider); const selectLockCommand = new SelectLockCommand(openApiTreeProvider); + const uriHandler = new UriHandler(openApiTreeProvider); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); let codeLensProvider = new CodeLensProvider(); - const handleUri = async (uri: vscode.Uri) => { - if (uri.path === "/") { - return; - } - const queryParameters = getQueryParameters(uri); - if (uri.path.toLowerCase() === "/opendescription") { - reporter.sendTelemetryEvent("DeepLink.OpenDescription"); - const descriptionUrl = queryParameters["descriptionurl"]; - if (descriptionUrl) { - await openTreeViewWithProgress(() => openApiTreeProvider.setDescriptionUrl(descriptionUrl)); - return; - } - } - void vscode.window.showErrorMessage( - vscode.l10n.t("Invalid URL, please check the documentation for the supported URLs") - ); - }; + context.subscriptions.push( - vscode.window.registerUriHandler({ handleUri }), + vscode.window.registerUriHandler({ handleUri: uriHandler.handleUri }), vscode.languages.registerCodeLensProvider('json', codeLensProvider), reporter, registerCommandWithTelemetry(reporter, `${extensionId}.selectLock`, (x) => selectLockCommand.execute(x)), @@ -129,19 +114,5 @@ function registerCommandWithTelemetry(reporter: TelemetryReporter, command: stri }, thisArg); } -function getQueryParameters(uri: vscode.Uri): Record { - const query = uri.query; - if (!query) { - return {}; - } - const queryParameters = (query.startsWith('?') ? query.substring(1) : query).split("&"); - const parameters = {} as Record; - queryParameters.forEach((element) => { - const keyValue = element.split("="); - parameters[keyValue[0].toLowerCase()] = decodeURIComponent(keyValue[1]); - }); - return parameters; -} - // This method is called when your extension is deactivated export function deactivate() { } diff --git a/vscode/microsoft-kiota/src/handlers/uri.handler.ts b/vscode/microsoft-kiota/src/handlers/uri.handler.ts new file mode 100644 index 0000000000..10b97feaf0 --- /dev/null +++ b/vscode/microsoft-kiota/src/handlers/uri.handler.ts @@ -0,0 +1,52 @@ +import * as vscode from "vscode"; +import { openTreeViewWithProgress } from "../utilities/file"; +import { OpenApiTreeProvider } from "../openApiTreeProvider"; + +export class UriHandler { + private _openApiTreeProvider: OpenApiTreeProvider; + + constructor(private openApiTreeProvider: OpenApiTreeProvider) { + this._openApiTreeProvider = openApiTreeProvider; + } + + async handleUri(uri: vscode.Uri) { + if (uri.path === "/") { + return; + } + const queryParameters = this.getQueryParameters(uri); + if (uri.path.toLowerCase() === "/opendescription") { + + // TODO: uncomment when telemetry is implemented + // reporter.sendTelemetryEvent("DeepLink.OpenDescription"); + const descriptionUrl = queryParameters["descriptionurl"]; + if (descriptionUrl) { + await openTreeViewWithProgress(() => this._openApiTreeProvider.setDescriptionUrl(descriptionUrl)); + return; + } + } + void vscode.window.showErrorMessage( + vscode.l10n.t("Invalid URL, please check the documentation for the supported URLs") + ); + + }; + + getQueryParameters(uri: vscode.Uri): Record { + const query = uri.query; + if (!query) { + return {}; + } + const queryParameters = (query.startsWith('?') ? query.substring(1) : query).split("&"); + const parameters = {} as Record; + queryParameters.forEach((element) => { + const keyValue = element.split("="); + parameters[keyValue[0].toLowerCase()] = decodeURIComponent(keyValue[1]); + }); + return parameters; + } + +} + + + + + From d7dea433357b5cfa97d8f165ff6c5f5f825f1048 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 11:19:32 +0300 Subject: [PATCH 139/150] arrange providers in providers folder --- .../microsoft-kiota/src/commands/CloseDescriptionCommand.ts | 2 +- vscode/microsoft-kiota/src/commands/EditPathsCommand.ts | 2 +- .../src/commands/FilterDescriptionCommand.ts | 2 +- .../src/commands/SearchOrOpenApiDescriptionCommand.ts | 2 +- vscode/microsoft-kiota/src/commands/SelectLockCommand.ts | 2 +- .../generate-client/DisplayGenerationResultsCommand.ts | 2 +- .../src/commands/generate-client/GenerateClientCommand.ts | 4 ++-- .../src/commands/generate-client/generation-results.ts | 2 +- .../open-api-tree-node/AddAllToSelectedEndpointsCommand.ts | 2 +- .../open-api-tree-node/AddToSelectedEndpointsCommand.ts | 2 +- .../open-api-tree-node/OpenDocumentationPageCommand.ts | 2 +- .../RemoveAllFromSelectedEndpointsCommand.ts | 2 +- .../RemoveFromSelectedEndpointsCommand.ts | 2 +- .../src/commands/regenerate/RegenerateButtonCommand.ts | 2 +- .../src/commands/regenerate/RegenerateCommand.ts | 2 +- .../src/commands/regenerate/regenerate.service.ts | 4 ++-- vscode/microsoft-kiota/src/extension.ts | 6 +++--- vscode/microsoft-kiota/src/handlers/uri.handler.ts | 2 +- .../src/{ => providers}/dependenciesViewProvider.ts | 2 +- .../src/{ => providers}/openApiTreeProvider.ts | 0 .../src/{ => providers}/workspaceTreeProvider.ts | 0 vscode/microsoft-kiota/src/utilities/file.ts | 4 ++-- 22 files changed, 25 insertions(+), 25 deletions(-) rename vscode/microsoft-kiota/src/{ => providers}/dependenciesViewProvider.ts (95%) rename vscode/microsoft-kiota/src/{ => providers}/openApiTreeProvider.ts (100%) rename vscode/microsoft-kiota/src/{ => providers}/workspaceTreeProvider.ts (100%) diff --git a/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts b/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts index acec1cfd44..eaf360ef95 100644 --- a/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts +++ b/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts @@ -1,7 +1,7 @@ import * as vscode from "vscode"; import { treeViewId } from "../constants"; -import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; import { updateTreeViewIcons } from "../util"; import { Command } from "./Command"; diff --git a/vscode/microsoft-kiota/src/commands/EditPathsCommand.ts b/vscode/microsoft-kiota/src/commands/EditPathsCommand.ts index 9e9410695c..97ae3d5d80 100644 --- a/vscode/microsoft-kiota/src/commands/EditPathsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/EditPathsCommand.ts @@ -1,6 +1,6 @@ import { treeViewId } from "../constants"; import { ClientOrPluginProperties } from "../kiotaInterop"; -import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; import { updateTreeViewIcons } from "../util"; import { openTreeViewWithProgress } from "../utilities/file"; import { Command } from "./Command"; diff --git a/vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts b/vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts index 8808def9ae..b14896a060 100644 --- a/vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts +++ b/vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts @@ -1,4 +1,4 @@ -import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; import { filterSteps } from "../steps"; import { Command } from "./Command"; diff --git a/vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts b/vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts index f39349c5c6..758b28b321 100644 --- a/vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts +++ b/vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts @@ -3,7 +3,7 @@ import { ExtensionContext } from "vscode"; import { extensionId } from "../constants"; import { getExtensionSettings } from "../extensionSettings"; -import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; import { searchDescription } from "../searchDescription"; import { searchSteps } from "../steps"; import { openTreeViewWithProgress } from "../utilities/file"; diff --git a/vscode/microsoft-kiota/src/commands/SelectLockCommand.ts b/vscode/microsoft-kiota/src/commands/SelectLockCommand.ts index e40dc066e6..caf7ce84fa 100644 --- a/vscode/microsoft-kiota/src/commands/SelectLockCommand.ts +++ b/vscode/microsoft-kiota/src/commands/SelectLockCommand.ts @@ -1,4 +1,4 @@ -import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; import { loadLockFile } from "../utilities/file"; import { Command } from "./Command"; diff --git a/vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts b/vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts index 6467de8b66..d62ef80769 100644 --- a/vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts @@ -1,6 +1,6 @@ import { ExtensionContext } from "vscode"; -import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { GenerateState } from "../../steps"; import { Command } from "../Command"; import { GeneratedOutputState } from "../GeneratedOutputState"; diff --git a/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts b/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts index 297b7d7f0d..ceb8193b0f 100644 --- a/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts +++ b/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts @@ -2,7 +2,6 @@ import * as vscode from "vscode"; import { ExtensionContext } from "vscode"; import { extensionId, treeViewFocusCommand } from "../../constants"; -import { DependenciesViewProvider } from '../../dependenciesViewProvider'; import { ExtensionSettings, getExtensionSettings } from "../../extensionSettings"; import { generateClient } from '../../generateClient'; import { generatePlugin } from '../../generatePlugin'; @@ -12,7 +11,8 @@ import { getLogEntriesForLevel, KiotaGenerationLanguage, KiotaLogEntry, KiotaPluginType, LogLevel, parseGenerationLanguage, parsePluginType } from "../../kiotaInterop"; -import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { DependenciesViewProvider } from "../../providers/dependenciesViewProvider"; +import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { GenerateState, generateSteps, GenerationType, parseGenerationType } from "../../steps"; import { getWorkspaceJsonDirectory } from "../../util"; import { exportLogsAndShowErrors } from '../../utilities/logging'; diff --git a/vscode/microsoft-kiota/src/commands/generate-client/generation-results.ts b/vscode/microsoft-kiota/src/commands/generate-client/generation-results.ts index 172f75e45c..7ab98b9dfe 100644 --- a/vscode/microsoft-kiota/src/commands/generate-client/generation-results.ts +++ b/vscode/microsoft-kiota/src/commands/generate-client/generation-results.ts @@ -1,7 +1,7 @@ import * as vscode from "vscode"; import { treeViewId } from "../../constants"; -import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { GenerateState } from "../../steps"; import { getWorkspaceJsonPath, updateTreeViewIcons } from "../../util"; import { loadLockFile } from "../../utilities/file"; diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts index fecbb33234..00c348a600 100644 --- a/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts @@ -1,4 +1,4 @@ -import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { OpenApiTreeNode, OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { Command } from "../Command"; export class AddAllToSelectedEndpointsCommand extends Command { diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts index 4437963110..c2acc0f590 100644 --- a/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts @@ -1,4 +1,4 @@ -import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { OpenApiTreeNode, OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { Command } from "../Command"; export class AddToSelectedEndpointsCommand extends Command { diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/OpenDocumentationPageCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/OpenDocumentationPageCommand.ts index ecaa2d724f..0077086280 100644 --- a/vscode/microsoft-kiota/src/commands/open-api-tree-node/OpenDocumentationPageCommand.ts +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/OpenDocumentationPageCommand.ts @@ -1,5 +1,5 @@ import * as vscode from "vscode"; -import { OpenApiTreeNode } from "../../openApiTreeProvider"; +import { OpenApiTreeNode } from "../../providers/openApiTreeProvider"; import { Command } from "../Command"; export class OpenDocumentationPageCommand extends Command { diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts index 20143d3f88..780caa841d 100644 --- a/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts @@ -1,4 +1,4 @@ -import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { OpenApiTreeNode, OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { Command } from "../Command"; export class RemoveAllFromSelectedEndpointsCommand extends Command { diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts index cdc1c0883c..1290915fe2 100644 --- a/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts @@ -1,4 +1,4 @@ -import { OpenApiTreeNode, OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { OpenApiTreeNode, OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { Command } from "../Command"; export class RemoveFromSelectedEndpointsCommand extends Command { diff --git a/vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts index 940c6e57b7..5194fefde9 100644 --- a/vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts +++ b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts @@ -4,7 +4,7 @@ import { ExtensionContext } from "vscode"; import { extensionId } from "../../constants"; import { getExtensionSettings } from "../../extensionSettings"; import { ClientOrPluginProperties } from "../../kiotaInterop"; -import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { GenerateState } from "../../steps"; import { isClientType, isPluginType } from "../../util"; import { Command } from "../Command"; diff --git a/vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts index 37edc6b80f..db6677fbb7 100644 --- a/vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts +++ b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts @@ -4,7 +4,7 @@ import { ExtensionContext } from "vscode"; import { extensionId, KIOTA_WORKSPACE_FILE } from "../../constants"; import { getExtensionSettings } from "../../extensionSettings"; import { ClientOrPluginProperties } from "../../kiotaInterop"; -import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { isClientType, isPluginType } from "../../util"; import { Command } from "../Command"; import { RegenerateService } from "./regenerate.service"; diff --git a/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts b/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts index ef02e795c4..5495c10263 100644 --- a/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts +++ b/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts @@ -4,8 +4,8 @@ import { ExtensionContext } from "vscode"; import { ExtensionSettings } from "../../extensionSettings"; import { generateClient } from "../../generateClient"; import { generatePlugin } from "../../generatePlugin"; -import { ClientObjectProperties, parseGenerationLanguage, KiotaGenerationLanguage, ConsumerOperation, PluginObjectProperties, parsePluginType, KiotaPluginType, ClientOrPluginProperties } from "../../kiotaInterop"; -import { OpenApiTreeProvider } from "../../openApiTreeProvider"; +import { ClientObjectProperties, ClientOrPluginProperties, ConsumerOperation, KiotaGenerationLanguage, KiotaPluginType, PluginObjectProperties, parseGenerationLanguage, parsePluginType } from "../../kiotaInterop"; +import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; export class RegenerateService { private _context: ExtensionContext; diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 8d5f49fee9..56294dcc62 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -23,14 +23,14 @@ import { SelectLockCommand } from './commands/SelectLockCommand'; import { UpdateClientsCommand } from './commands/UpdateClientsCommand'; import { dependenciesInfo, extensionId, statusBarCommandId, treeViewId } from "./constants"; -import { DependenciesViewProvider } from "./dependenciesViewProvider"; import { getExtensionSettings } from "./extensionSettings"; import { UriHandler } from './handlers/uri.handler'; import { ClientOrPluginProperties } from "./kiotaInterop"; -import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider"; +import { DependenciesViewProvider } from './providers/dependenciesViewProvider'; +import { OpenApiTreeNode, OpenApiTreeProvider } from './providers/openApiTreeProvider'; +import { loadTreeView } from './providers/workspaceTreeProvider'; import { GenerateState } from "./steps"; import { updateStatusBarItem } from './utilities/status-bar'; -import { loadTreeView } from "./workspaceTreeProvider"; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; diff --git a/vscode/microsoft-kiota/src/handlers/uri.handler.ts b/vscode/microsoft-kiota/src/handlers/uri.handler.ts index 10b97feaf0..0b5260b7fd 100644 --- a/vscode/microsoft-kiota/src/handlers/uri.handler.ts +++ b/vscode/microsoft-kiota/src/handlers/uri.handler.ts @@ -1,6 +1,6 @@ import * as vscode from "vscode"; +import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; import { openTreeViewWithProgress } from "../utilities/file"; -import { OpenApiTreeProvider } from "../openApiTreeProvider"; export class UriHandler { private _openApiTreeProvider: OpenApiTreeProvider; diff --git a/vscode/microsoft-kiota/src/dependenciesViewProvider.ts b/vscode/microsoft-kiota/src/providers/dependenciesViewProvider.ts similarity index 95% rename from vscode/microsoft-kiota/src/dependenciesViewProvider.ts rename to vscode/microsoft-kiota/src/providers/dependenciesViewProvider.ts index f4855b723f..c937957196 100644 --- a/vscode/microsoft-kiota/src/dependenciesViewProvider.ts +++ b/vscode/microsoft-kiota/src/providers/dependenciesViewProvider.ts @@ -1,5 +1,5 @@ import * as vscode from 'vscode'; -import { generationLanguageToString, KiotaGenerationLanguage, LanguageInformation, LanguagesInformation } from './kiotaInterop'; +import { LanguageInformation, KiotaGenerationLanguage, LanguagesInformation, generationLanguageToString } from '../kiotaInterop'; export class DependenciesViewProvider implements vscode.WebviewViewProvider { private _view?: vscode.WebviewView; diff --git a/vscode/microsoft-kiota/src/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/providers/openApiTreeProvider.ts similarity index 100% rename from vscode/microsoft-kiota/src/openApiTreeProvider.ts rename to vscode/microsoft-kiota/src/providers/openApiTreeProvider.ts diff --git a/vscode/microsoft-kiota/src/workspaceTreeProvider.ts b/vscode/microsoft-kiota/src/providers/workspaceTreeProvider.ts similarity index 100% rename from vscode/microsoft-kiota/src/workspaceTreeProvider.ts rename to vscode/microsoft-kiota/src/providers/workspaceTreeProvider.ts diff --git a/vscode/microsoft-kiota/src/utilities/file.ts b/vscode/microsoft-kiota/src/utilities/file.ts index 87f6e18b77..6d47932f76 100644 --- a/vscode/microsoft-kiota/src/utilities/file.ts +++ b/vscode/microsoft-kiota/src/utilities/file.ts @@ -1,7 +1,7 @@ import * as vscode from "vscode"; import { treeViewFocusCommand, treeViewId } from "../constants"; -import { OpenApiTreeProvider } from "../openApiTreeProvider"; +import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; import { updateTreeViewIcons } from "../util"; async function loadLockFile(node: { fsPath: string }, openApiTreeProvider: OpenApiTreeProvider, clientOrPluginName?: string): Promise { @@ -23,6 +23,6 @@ function openTreeViewWithProgress(callback: () => Promise): Thenable { export { loadLockFile, - openTreeViewWithProgress, + openTreeViewWithProgress }; From a65e7a702fc841c369c87d8b40bf1f6acc650e90 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 11:21:41 +0300 Subject: [PATCH 140/150] move codelens to the providers folder --- vscode/microsoft-kiota/src/extension.ts | 3 +-- vscode/microsoft-kiota/src/{ => providers}/codelensProvider.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) rename vscode/microsoft-kiota/src/{ => providers}/codelensProvider.ts (96%) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 56294dcc62..65155837e2 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -4,8 +4,6 @@ import TelemetryReporter from '@vscode/extension-telemetry'; import * as vscode from "vscode"; import { commands } from 'vscode'; -import { CodeLensProvider } from "./codelensProvider"; - import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; import { EditPathsCommand } from './commands/EditPathsCommand'; import { FilterDescriptionCommand } from './commands/FilterDescriptionCommand'; @@ -26,6 +24,7 @@ import { dependenciesInfo, extensionId, statusBarCommandId, treeViewId } from ". import { getExtensionSettings } from "./extensionSettings"; import { UriHandler } from './handlers/uri.handler'; import { ClientOrPluginProperties } from "./kiotaInterop"; +import { CodeLensProvider } from "./providers/codelensProvider"; import { DependenciesViewProvider } from './providers/dependenciesViewProvider'; import { OpenApiTreeNode, OpenApiTreeProvider } from './providers/openApiTreeProvider'; import { loadTreeView } from './providers/workspaceTreeProvider'; diff --git a/vscode/microsoft-kiota/src/codelensProvider.ts b/vscode/microsoft-kiota/src/providers/codelensProvider.ts similarity index 96% rename from vscode/microsoft-kiota/src/codelensProvider.ts rename to vscode/microsoft-kiota/src/providers/codelensProvider.ts index 274fc46805..c54d718310 100644 --- a/vscode/microsoft-kiota/src/codelensProvider.ts +++ b/vscode/microsoft-kiota/src/providers/codelensProvider.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; import { l10n } from 'vscode'; -import { CLIENTS, KIOTA_WORKSPACE_FILE, PLUGINS } from './constants'; +import { CLIENTS, KIOTA_WORKSPACE_FILE, PLUGINS } from '../constants'; export class CodeLensProvider implements vscode.CodeLensProvider { public provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.ProviderResult { From 6d4b92ea0e618cccd4f412989671a26b4534f865 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 11:23:02 +0300 Subject: [PATCH 141/150] move getKiotaVersion to utilities folder --- vscode/microsoft-kiota/src/{ => utilities}/getKiotaVersion.ts | 2 +- vscode/microsoft-kiota/src/utilities/status-bar.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename vscode/microsoft-kiota/src/{ => utilities}/getKiotaVersion.ts (93%) diff --git a/vscode/microsoft-kiota/src/getKiotaVersion.ts b/vscode/microsoft-kiota/src/utilities/getKiotaVersion.ts similarity index 93% rename from vscode/microsoft-kiota/src/getKiotaVersion.ts rename to vscode/microsoft-kiota/src/utilities/getKiotaVersion.ts index a7756b37ab..66de511670 100644 --- a/vscode/microsoft-kiota/src/getKiotaVersion.ts +++ b/vscode/microsoft-kiota/src/utilities/getKiotaVersion.ts @@ -1,4 +1,4 @@ -import { connectToKiota } from "./kiotaInterop"; +import { connectToKiota } from "../kiotaInterop"; import * as rpc from "vscode-jsonrpc/node"; import * as vscode from "vscode"; diff --git a/vscode/microsoft-kiota/src/utilities/status-bar.ts b/vscode/microsoft-kiota/src/utilities/status-bar.ts index c866fd550f..7bada5c697 100644 --- a/vscode/microsoft-kiota/src/utilities/status-bar.ts +++ b/vscode/microsoft-kiota/src/utilities/status-bar.ts @@ -1,7 +1,7 @@ import * as vscode from "vscode"; import { ExtensionContext, StatusBarItem } from "vscode"; -import { getKiotaVersion } from "../getKiotaVersion"; +import { getKiotaVersion } from "./getKiotaVersion"; import { kiotaOutputChannel } from "./logging"; async function updateStatusBarItem(context: ExtensionContext, kiotaStatusBarItem: StatusBarItem): Promise { From 44b330d44ae4c554b4ea3abc8446c55968679d30 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 11:36:23 +0300 Subject: [PATCH 142/150] organise subscriptions --- vscode/microsoft-kiota/src/extension.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 65155837e2..849dbcba3d 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -2,7 +2,6 @@ // Import the module and reference it with the alias vscode in your code below import TelemetryReporter from '@vscode/extension-telemetry'; import * as vscode from "vscode"; -import { commands } from 'vscode'; import { CloseDescriptionCommand } from './commands/CloseDescriptionCommand'; import { EditPathsCommand } from './commands/EditPathsCommand'; @@ -65,32 +64,36 @@ export async function activate( const displayGenerationResultsCommand = new DisplayGenerationResultsCommand(context, openApiTreeProvider); const selectLockCommand = new SelectLockCommand(openApiTreeProvider); const uriHandler = new UriHandler(openApiTreeProvider); + const codeLensProvider = new CodeLensProvider(); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); - let codeLensProvider = new CodeLensProvider(); context.subscriptions.push( + reporter, + vscode.window.registerUriHandler({ handleUri: uriHandler.handleUri }), vscode.languages.registerCodeLensProvider('json', codeLensProvider), - reporter, - registerCommandWithTelemetry(reporter, `${extensionId}.selectLock`, (x) => selectLockCommand.execute(x)), - registerCommandWithTelemetry(reporter, statusBarCommandId, async () => kiotaStatusCommand.execute()), vscode.window.registerWebviewViewProvider(dependenciesInfo, dependenciesInfoProvider), vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider), + + registerCommandWithTelemetry(reporter, `${extensionId}.selectLock`, (x) => selectLockCommand.execute(x)), + registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async () => editPathsCommand.execute()), + registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async () => regenerateCommand.execute()), + registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, (openApiTreeNode: OpenApiTreeNode) => openDocumentationPageCommand.execute(openApiTreeNode)), registerCommandWithTelemetry(reporter, `${treeViewId}.addToSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => addToSelectedEndpointsCommand.execute(openApiTreeNode)), registerCommandWithTelemetry(reporter, `${treeViewId}.addAllToSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => addAllToSelectedEndpointsCommand.execute(openApiTreeNode)), registerCommandWithTelemetry(reporter, `${treeViewId}.removeFromSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => removeFromSelectedEndpointsCommand.execute(openApiTreeNode)), registerCommandWithTelemetry(reporter, `${treeViewId}.removeAllFromSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => removeAllFromSelectedEndpointsCommand.execute(openApiTreeNode)), registerCommandWithTelemetry(reporter, `${treeViewId}.generateClient`, () => generateClientCommand.execute()), - vscode.workspace.onDidChangeWorkspaceFolders(async () => displayGenerationResultsCommand.execute(config)), registerCommandWithTelemetry(reporter, `${treeViewId}.searchOrOpenApiDescription`, () => searchOrOpenApiDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, () => closeDescriptionCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`, () => filterDescriptionCommand.execute()), - registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async () => editPathsCommand.execute()), registerCommandWithTelemetry(reporter, `${treeViewId}.regenerateButton`, async () => regenerateButtonCommand.execute(config)), - registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async () => regenerateCommand.execute()), + + registerCommandWithTelemetry(reporter, statusBarCommandId, async () => kiotaStatusCommand.execute()), + vscode.workspace.onDidChangeWorkspaceFolders(async () => displayGenerationResultsCommand.execute(config)), ); // create a new status bar item that we can now manage @@ -100,7 +103,7 @@ export async function activate( // update status bar item once at start await updateStatusBarItem(context, kiotaStatusBarItem); - context.subscriptions.push(commands.registerCommand(`${extensionId}.updateClients`, async () => updateClientsCommand.execute(kiotaStatusBarItem))); + context.subscriptions.push(registerCommandWithTelemetry(reporter, `${extensionId}.updateClients`, async () => updateClientsCommand.execute(kiotaStatusBarItem))); } From c3ff57d5854d0a50b3fb36f3dc210c9f07735201 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 11:58:12 +0300 Subject: [PATCH 143/150] provide command name in command --- .../src/commands/CloseDescriptionCommand.ts | 4 +++ .../microsoft-kiota/src/commands/Command.ts | 4 +-- .../src/commands/EditPathsCommand.ts | 8 +++-- .../src/commands/FilterDescriptionCommand.ts | 9 +++-- .../SearchOrOpenApiDescriptionCommand.ts | 7 +++- .../src/commands/SelectLockCommand.ts | 6 ++++ .../src/commands/UpdateClientsCommand.ts | 5 ++- .../DisplayGenerationResultsCommand.ts | 8 +++-- .../generate-client/GenerateClientCommand.ts | 12 ++++--- .../AddAllToSelectedEndpointsCommand.ts | 6 ++++ .../AddToSelectedEndpointsCommand.ts | 5 +++ .../OpenDocumentationPageCommand.ts | 6 ++++ .../RemoveAllFromSelectedEndpointsCommand.ts | 7 +++- .../RemoveFromSelectedEndpointsCommand.ts | 6 ++++ .../regenerate/RegenerateButtonCommand.ts | 7 ++-- .../commands/regenerate/RegenerateCommand.ts | 7 +++- vscode/microsoft-kiota/src/extension.ts | 35 ++++++++++--------- 17 files changed, 106 insertions(+), 36 deletions(-) diff --git a/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts b/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts index eaf360ef95..4783cc9e26 100644 --- a/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts +++ b/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts @@ -13,6 +13,10 @@ export class CloseDescriptionCommand extends Command { this._openApiTreeProvider = openApiTreeProvider; } + public toString(): string { + return `${treeViewId}.closeDescription`; + } + async execute(): Promise { const yesAnswer = vscode.l10n.t("Yes"); const response = await vscode.window.showInformationMessage( diff --git a/vscode/microsoft-kiota/src/commands/Command.ts b/vscode/microsoft-kiota/src/commands/Command.ts index c50d5ede4d..5e5b4efcc0 100644 --- a/vscode/microsoft-kiota/src/commands/Command.ts +++ b/vscode/microsoft-kiota/src/commands/Command.ts @@ -1,7 +1,5 @@ export abstract class Command { - public toString():string { - return this.constructor.name; - } + public abstract toString():string; abstract execute(args: unknown):void; } \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/commands/EditPathsCommand.ts b/vscode/microsoft-kiota/src/commands/EditPathsCommand.ts index 97ae3d5d80..55478fe8fb 100644 --- a/vscode/microsoft-kiota/src/commands/EditPathsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/EditPathsCommand.ts @@ -1,4 +1,4 @@ -import { treeViewId } from "../constants"; +import { extensionId, treeViewId } from "../constants"; import { ClientOrPluginProperties } from "../kiotaInterop"; import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; import { updateTreeViewIcons } from "../util"; @@ -18,13 +18,17 @@ export class EditPathsCommand extends Command { this._clientObject = clientObject; } + public toString(): string { + return `${extensionId}.editPaths`; + } + async execute(): Promise { await this.loadEditPaths(); this._openApiTreeProvider.resetInitialState(); await updateTreeViewIcons(treeViewId, false, true); } - async loadEditPaths() { + private async loadEditPaths() { await openTreeViewWithProgress(() => this._openApiTreeProvider.loadEditPaths(this._clientKey, this._clientObject)); } diff --git a/vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts b/vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts index b14896a060..34364812ec 100644 --- a/vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts +++ b/vscode/microsoft-kiota/src/commands/FilterDescriptionCommand.ts @@ -1,15 +1,20 @@ +import { treeViewId } from "../constants"; import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; import { filterSteps } from "../steps"; import { Command } from "./Command"; export class FilterDescriptionCommand extends Command { private _openApiTreeProvider: OpenApiTreeProvider; - + constructor(openApiTreeProvider: OpenApiTreeProvider) { super(); this._openApiTreeProvider = openApiTreeProvider; } - + + public toString(): string { + return `${treeViewId}.filterDescription`; + } + async execute(): Promise { await filterSteps(this._openApiTreeProvider.filter, x => this._openApiTreeProvider.filter = x); diff --git a/vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts b/vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts index 758b28b321..ea95c83af7 100644 --- a/vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts +++ b/vscode/microsoft-kiota/src/commands/SearchOrOpenApiDescriptionCommand.ts @@ -1,7 +1,7 @@ import * as vscode from "vscode"; import { ExtensionContext } from "vscode"; -import { extensionId } from "../constants"; +import { extensionId, treeViewId } from "../constants"; import { getExtensionSettings } from "../extensionSettings"; import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; import { searchDescription } from "../searchDescription"; @@ -10,6 +10,7 @@ import { openTreeViewWithProgress } from "../utilities/file"; import { Command } from "./Command"; export class SearchOrOpenApiDescriptionCommand extends Command { + private _context: ExtensionContext; private _openApiTreeProvider: OpenApiTreeProvider; @@ -19,6 +20,10 @@ export class SearchOrOpenApiDescriptionCommand extends Command { this._openApiTreeProvider = openApiTreeProvider; } + public toString(): string { + return `${treeViewId}.searchOrOpenApiDescription`; + } + async execute(): Promise { const yesAnswer = vscode.l10n.t("Yes, override it"); if (!this._openApiTreeProvider.isEmpty() && this._openApiTreeProvider.hasChanges()) { diff --git a/vscode/microsoft-kiota/src/commands/SelectLockCommand.ts b/vscode/microsoft-kiota/src/commands/SelectLockCommand.ts index caf7ce84fa..1c4730b3da 100644 --- a/vscode/microsoft-kiota/src/commands/SelectLockCommand.ts +++ b/vscode/microsoft-kiota/src/commands/SelectLockCommand.ts @@ -1,8 +1,10 @@ +import { extensionId } from "../constants"; import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; import { loadLockFile } from "../utilities/file"; import { Command } from "./Command"; export class SelectLockCommand extends Command { + private _openApiTreeProvider: OpenApiTreeProvider; constructor(openApiTreeProvider: OpenApiTreeProvider) { @@ -10,6 +12,10 @@ export class SelectLockCommand extends Command { this._openApiTreeProvider = openApiTreeProvider; } + public toString(): string { + return `${extensionId}.selectLock`; + } + execute(x: any): void { void loadLockFile(x, this._openApiTreeProvider); } diff --git a/vscode/microsoft-kiota/src/commands/UpdateClientsCommand.ts b/vscode/microsoft-kiota/src/commands/UpdateClientsCommand.ts index 60a0960d6d..c314ceec58 100644 --- a/vscode/microsoft-kiota/src/commands/UpdateClientsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/UpdateClientsCommand.ts @@ -11,7 +11,6 @@ import { updateStatusBarItem } from '../utilities/status-bar'; import { Command } from "./Command"; export class UpdateClientsCommand extends Command { - private _context: ExtensionContext; public constructor(context: ExtensionContext) { @@ -19,6 +18,10 @@ export class UpdateClientsCommand extends Command { this._context = context; } + public toString(): string { + return `${extensionId}.updateClients`; + } + async execute(kiotaStatusBarItem: StatusBarItem): Promise { if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) { await vscode.window.showErrorMessage( diff --git a/vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts b/vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts index d62ef80769..30371ea66e 100644 --- a/vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/generate-client/DisplayGenerationResultsCommand.ts @@ -5,8 +5,10 @@ import { GenerateState } from "../../steps"; import { Command } from "../Command"; import { GeneratedOutputState } from "../GeneratedOutputState"; import { displayGenerationResults } from "./generation-results"; +import { extensionId } from "../../constants"; export class DisplayGenerationResultsCommand extends Command { + private _context: ExtensionContext; private _openApiTreeProvider: OpenApiTreeProvider; @@ -16,6 +18,10 @@ export class DisplayGenerationResultsCommand extends Command { this._openApiTreeProvider = openApiTreeProvider; } + public toString(): string { + return `${extensionId}.displayGenerationResults`; + } + async execute(config: Partial): Promise { const generatedOutput = this._context.workspaceState.get('generatedOutput'); if (generatedOutput) { @@ -25,6 +31,4 @@ export class DisplayGenerationResultsCommand extends Command { void this._context.workspaceState.update('generatedOutput', undefined); } } - - } \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts b/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts index ceb8193b0f..fb93127c8a 100644 --- a/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts +++ b/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts @@ -1,7 +1,7 @@ import * as vscode from "vscode"; import { ExtensionContext } from "vscode"; -import { extensionId, treeViewFocusCommand } from "../../constants"; +import { extensionId, treeViewFocusCommand, treeViewId } from "../../constants"; import { ExtensionSettings, getExtensionSettings } from "../../extensionSettings"; import { generateClient } from '../../generateClient'; import { generatePlugin } from '../../generatePlugin'; @@ -32,6 +32,10 @@ export class GenerateClientCommand extends Command { this._openApiTreeProvider = openApiTreeProvider; } + public toString(): string { + return `${treeViewId}.generateClient`; + } + public async execute() { const selectedPaths = this._openApiTreeProvider.getSelectedPaths(); if (selectedPaths.length === 0) { @@ -97,7 +101,7 @@ export class GenerateClientCommand extends Command { } } - async generateClientAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { + private async generateClientAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { const language = typeof config.language === "string" ? parseGenerationLanguage(config.language) @@ -166,7 +170,7 @@ export class GenerateClientCommand extends Command { return result; } - async generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { + private async generatePluginAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { const pluginTypes = Array.isArray(config.pluginTypes) ? parsePluginType(config.pluginTypes) : [KiotaPluginType.ApiPlugin]; const result = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, @@ -210,7 +214,7 @@ export class GenerateClientCommand extends Command { return result; } - async generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { + private async generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]): Promise { const pluginTypes = KiotaPluginType.ApiManifest; const result = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts index 00c348a600..21da8a1426 100644 --- a/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddAllToSelectedEndpointsCommand.ts @@ -1,13 +1,19 @@ +import { treeViewId } from "../../constants"; import { OpenApiTreeNode, OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { Command } from "../Command"; export class AddAllToSelectedEndpointsCommand extends Command { + private _openApiTreeProvider: OpenApiTreeProvider; constructor(openApiTreeProvider: OpenApiTreeProvider) { super();; this._openApiTreeProvider = openApiTreeProvider; } + + public toString(): string { + return `${treeViewId}.addAllToSelectedEndpoints`; + } execute(openApiTreeNode: OpenApiTreeNode): void { this._openApiTreeProvider.select(openApiTreeNode, true, true); diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts index c2acc0f590..78e76769ca 100644 --- a/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/AddToSelectedEndpointsCommand.ts @@ -1,3 +1,4 @@ +import { treeViewId } from "../../constants"; import { OpenApiTreeNode, OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { Command } from "../Command"; @@ -10,6 +11,10 @@ export class AddToSelectedEndpointsCommand extends Command { this._openApiTreeProvider = openApiTreeProvider; } + public toString(): string { + return `${treeViewId}.addToSelectedEndpoints`; + } + execute(openApiTreeNode: OpenApiTreeNode): void { this._openApiTreeProvider.select(openApiTreeNode, true, false); } diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/OpenDocumentationPageCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/OpenDocumentationPageCommand.ts index 0077086280..e52e512ce8 100644 --- a/vscode/microsoft-kiota/src/commands/open-api-tree-node/OpenDocumentationPageCommand.ts +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/OpenDocumentationPageCommand.ts @@ -1,12 +1,18 @@ import * as vscode from "vscode"; +import { treeViewId } from "../../constants"; import { OpenApiTreeNode } from "../../providers/openApiTreeProvider"; import { Command } from "../Command"; export class OpenDocumentationPageCommand extends Command { + constructor() { super(); } + public toString(): string { + return `${treeViewId}.openDocumentationPage`; + } + execute(openApiTreeNode: OpenApiTreeNode): void { if (openApiTreeNode.documentationUrl) { vscode.env.openExternal(vscode.Uri.parse(openApiTreeNode.documentationUrl)); diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts index 780caa841d..2bf1e862cb 100644 --- a/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveAllFromSelectedEndpointsCommand.ts @@ -1,3 +1,4 @@ +import { treeViewId } from "../../constants"; import { OpenApiTreeNode, OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { Command } from "../Command"; @@ -8,7 +9,11 @@ export class RemoveAllFromSelectedEndpointsCommand extends Command { super();; this._openApiTreeProvider = openApiTreeProvider; } - + + public toString(): string { + return `${treeViewId}.removeAllFromSelectedEndpoints`; + } + execute(openApiTreeNode: OpenApiTreeNode): void { this._openApiTreeProvider.select(openApiTreeNode, false, true); } diff --git a/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts index 1290915fe2..e2561331a6 100644 --- a/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts +++ b/vscode/microsoft-kiota/src/commands/open-api-tree-node/RemoveFromSelectedEndpointsCommand.ts @@ -1,7 +1,9 @@ +import { treeViewId } from "../../constants"; import { OpenApiTreeNode, OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { Command } from "../Command"; export class RemoveFromSelectedEndpointsCommand extends Command { + private _openApiTreeProvider: OpenApiTreeProvider; constructor(openApiTreeProvider: OpenApiTreeProvider) { @@ -9,6 +11,10 @@ export class RemoveFromSelectedEndpointsCommand extends Command { this._openApiTreeProvider = openApiTreeProvider; } + public toString(): string { + return `${treeViewId}.removeFromSelectedEndpoints`; + } + execute(openApiTreeNode: OpenApiTreeNode): void { this._openApiTreeProvider.select(openApiTreeNode, false, false); } diff --git a/vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts index 5194fefde9..036c807ddb 100644 --- a/vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts +++ b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateButtonCommand.ts @@ -1,7 +1,7 @@ import * as vscode from "vscode"; import { ExtensionContext } from "vscode"; -import { extensionId } from "../../constants"; +import { extensionId, treeViewId } from "../../constants"; import { getExtensionSettings } from "../../extensionSettings"; import { ClientOrPluginProperties } from "../../kiotaInterop"; import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; @@ -11,7 +11,6 @@ import { Command } from "../Command"; import { RegenerateService } from "./regenerate.service"; export class RegenerateButtonCommand extends Command { - private _context: ExtensionContext; private _openApiTreeProvider: OpenApiTreeProvider; private _clientKey: string; @@ -28,6 +27,10 @@ export class RegenerateButtonCommand extends Command { this._workspaceGenerationType = workspaceGenerationType; } + public toString(): string { + return `${treeViewId}.regenerateButton`; + } + async execute(config: Partial): Promise { if (!this._clientKey || this._clientKey === '') { this._clientKey = config.clientClassName || config.pluginName || ''; diff --git a/vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts index db6677fbb7..d956859e4b 100644 --- a/vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts +++ b/vscode/microsoft-kiota/src/commands/regenerate/RegenerateCommand.ts @@ -10,7 +10,8 @@ import { Command } from "../Command"; import { RegenerateService } from "./regenerate.service"; export class RegenerateCommand extends Command { - + + private _context: ExtensionContext; private _openApiTreeProvider: OpenApiTreeProvider; private _clientKey: string; @@ -27,6 +28,10 @@ export class RegenerateCommand extends Command { this._workspaceGenerationType = workspaceGenerationType; } + public toString(): string { + return `${extensionId}.regenerate`; + } + async execute(): Promise { const settings = getExtensionSettings(extensionId); const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(KIOTA_WORKSPACE_FILE)); diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 849dbcba3d..fdfbcf74ba 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -29,6 +29,7 @@ import { OpenApiTreeNode, OpenApiTreeProvider } from './providers/openApiTreePro import { loadTreeView } from './providers/workspaceTreeProvider'; import { GenerateState } from "./steps"; import { updateStatusBarItem } from './utilities/status-bar'; +import { AddAllToSelectedEndpointsCommand } from './commands/open-api-tree-node/AddAllToSelectedEndpointsCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; @@ -57,7 +58,7 @@ export async function activate( const regenerateButtonCommand = new RegenerateButtonCommand(context, openApiTreeProvider, clientOrPluginKey, clientOrPluginObject, workspaceGenerationType); const regenerateCommand = new RegenerateCommand(context, openApiTreeProvider, clientOrPluginKey, clientOrPluginObject, workspaceGenerationType); const addToSelectedEndpointsCommand = new AddToSelectedEndpointsCommand(openApiTreeProvider); - const addAllToSelectedEndpointsCommand = new AddToSelectedEndpointsCommand(openApiTreeProvider); + const addAllToSelectedEndpointsCommand = new AddAllToSelectedEndpointsCommand(openApiTreeProvider); const removeFromSelectedEndpointsCommand = new RemoveFromSelectedEndpointsCommand(openApiTreeProvider); const removeAllFromSelectedEndpointsCommand = new RemoveAllFromSelectedEndpointsCommand(openApiTreeProvider); const updateClientsCommand = new UpdateClientsCommand(context); @@ -68,7 +69,7 @@ export async function activate( const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); - + context.subscriptions.push( reporter, @@ -77,20 +78,20 @@ export async function activate( vscode.window.registerWebviewViewProvider(dependenciesInfo, dependenciesInfoProvider), vscode.window.registerTreeDataProvider(treeViewId, openApiTreeProvider), - registerCommandWithTelemetry(reporter, `${extensionId}.selectLock`, (x) => selectLockCommand.execute(x)), - registerCommandWithTelemetry(reporter, `${extensionId}.editPaths`, async () => editPathsCommand.execute()), - registerCommandWithTelemetry(reporter, `${extensionId}.regenerate`, async () => regenerateCommand.execute()), - - registerCommandWithTelemetry(reporter, `${treeViewId}.openDocumentationPage`, (openApiTreeNode: OpenApiTreeNode) => openDocumentationPageCommand.execute(openApiTreeNode)), - registerCommandWithTelemetry(reporter, `${treeViewId}.addToSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => addToSelectedEndpointsCommand.execute(openApiTreeNode)), - registerCommandWithTelemetry(reporter, `${treeViewId}.addAllToSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => addAllToSelectedEndpointsCommand.execute(openApiTreeNode)), - registerCommandWithTelemetry(reporter, `${treeViewId}.removeFromSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => removeFromSelectedEndpointsCommand.execute(openApiTreeNode)), - registerCommandWithTelemetry(reporter, `${treeViewId}.removeAllFromSelectedEndpoints`, (openApiTreeNode: OpenApiTreeNode) => removeAllFromSelectedEndpointsCommand.execute(openApiTreeNode)), - registerCommandWithTelemetry(reporter, `${treeViewId}.generateClient`, () => generateClientCommand.execute()), - registerCommandWithTelemetry(reporter, `${treeViewId}.searchOrOpenApiDescription`, () => searchOrOpenApiDescriptionCommand.execute()), - registerCommandWithTelemetry(reporter, `${treeViewId}.closeDescription`, () => closeDescriptionCommand.execute()), - registerCommandWithTelemetry(reporter, `${treeViewId}.filterDescription`, () => filterDescriptionCommand.execute()), - registerCommandWithTelemetry(reporter, `${treeViewId}.regenerateButton`, async () => regenerateButtonCommand.execute(config)), + registerCommandWithTelemetry(reporter, selectLockCommand.toString(), (x) => selectLockCommand.execute(x)), + registerCommandWithTelemetry(reporter, editPathsCommand.toString(), async () => editPathsCommand.execute()), + registerCommandWithTelemetry(reporter, regenerateCommand.toString(), async () => regenerateCommand.execute()), + + registerCommandWithTelemetry(reporter, openDocumentationPageCommand.toString(), (openApiTreeNode: OpenApiTreeNode) => openDocumentationPageCommand.execute(openApiTreeNode)), + registerCommandWithTelemetry(reporter, addToSelectedEndpointsCommand.toString(), (openApiTreeNode: OpenApiTreeNode) => addToSelectedEndpointsCommand.execute(openApiTreeNode)), + registerCommandWithTelemetry(reporter, addAllToSelectedEndpointsCommand.toString(), (openApiTreeNode: OpenApiTreeNode) => addAllToSelectedEndpointsCommand.execute(openApiTreeNode)), + registerCommandWithTelemetry(reporter, removeFromSelectedEndpointsCommand.toString(), (openApiTreeNode: OpenApiTreeNode) => removeFromSelectedEndpointsCommand.execute(openApiTreeNode)), + registerCommandWithTelemetry(reporter, removeAllFromSelectedEndpointsCommand.toString(), (openApiTreeNode: OpenApiTreeNode) => removeAllFromSelectedEndpointsCommand.execute(openApiTreeNode)), + registerCommandWithTelemetry(reporter, generateClientCommand.toString(), () => generateClientCommand.execute()), + registerCommandWithTelemetry(reporter, searchOrOpenApiDescriptionCommand.toString(), () => searchOrOpenApiDescriptionCommand.execute()), + registerCommandWithTelemetry(reporter, closeDescriptionCommand.toString(), () => closeDescriptionCommand.execute()), + registerCommandWithTelemetry(reporter, filterDescriptionCommand.toString(), () => filterDescriptionCommand.execute()), + registerCommandWithTelemetry(reporter, regenerateButtonCommand.toString(), async () => regenerateButtonCommand.execute(config)), registerCommandWithTelemetry(reporter, statusBarCommandId, async () => kiotaStatusCommand.execute()), vscode.workspace.onDidChangeWorkspaceFolders(async () => displayGenerationResultsCommand.execute(config)), @@ -103,7 +104,7 @@ export async function activate( // update status bar item once at start await updateStatusBarItem(context, kiotaStatusBarItem); - context.subscriptions.push(registerCommandWithTelemetry(reporter, `${extensionId}.updateClients`, async () => updateClientsCommand.execute(kiotaStatusBarItem))); + context.subscriptions.push(registerCommandWithTelemetry(reporter, updateClientsCommand.toString(), async () => updateClientsCommand.execute(kiotaStatusBarItem))); } From 07dbf836fb38451c44c1b0deb82931b27726b92f Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 13:41:03 +0300 Subject: [PATCH 144/150] extract reporter to reusable file --- .../generate-client/GenerateClientCommand.ts | 36 +++++++-------- .../commands/regenerate/regenerate.service.ts | 19 +++++--- vscode/microsoft-kiota/src/extension.ts | 6 ++- .../src/handlers/uri.handler.ts | 7 +-- vscode/microsoft-kiota/src/telemetry/index.ts | 45 +++++++++++++++++++ 5 files changed, 83 insertions(+), 30 deletions(-) create mode 100644 vscode/microsoft-kiota/src/telemetry/index.ts diff --git a/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts b/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts index fb93127c8a..1468ba107e 100644 --- a/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts +++ b/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts @@ -8,12 +8,14 @@ import { generatePlugin } from '../../generatePlugin'; import { getLanguageInformation, getLanguageInformationForDescription } from "../../getLanguageInformation"; import { ConsumerOperation, + generationLanguageToString, getLogEntriesForLevel, KiotaGenerationLanguage, KiotaLogEntry, KiotaPluginType, LogLevel, parseGenerationLanguage, parsePluginType } from "../../kiotaInterop"; import { DependenciesViewProvider } from "../../providers/dependenciesViewProvider"; import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { GenerateState, generateSteps, GenerationType, parseGenerationType } from "../../steps"; +import { Telemetry } from "../../telemetry"; import { getWorkspaceJsonDirectory } from "../../util"; import { exportLogsAndShowErrors } from '../../utilities/logging'; import { showUpgradeWarningMessage } from "../../utilities/messaging"; @@ -137,18 +139,17 @@ export class GenerateClientCommand extends Command { ConsumerOperation.Add, config.workingDirectory ); - // TODO: uncomment when telemetry is implemented - /* const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; - + const reporter = Telemetry.reporter; + reporter.sendRawTelemetryEvent(`${extensionId}.generateClient.completed`, { "language": generationLanguageToString(language), "errorsCount": errorsCount.toString(), }, { "duration": duration, - }); */ + }); return result; }); @@ -194,18 +195,16 @@ export class GenerateClientCommand extends Command { ConsumerOperation.Add, config.workingDirectory ); - /* - // TODO: uncomment when telemetry is implemented - + const duration = performance.now() - start; - const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; - reporter.sendRawTelemetryEvent(`${extensionId}.generatePlugin.completed`, { - "pluginType": pluginTypes.toString(), - "errorsCount": errorsCount.toString(), - }, { - "duration": duration, - }); - */ + const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; + const reporter = Telemetry.reporter; + reporter.sendRawTelemetryEvent(`${extensionId}.generatePlugin.completed`, { + "pluginType": pluginTypes.toString(), + "errorsCount": errorsCount.toString(), + }, { + "duration": duration, + }); return result; }); if (result) { @@ -238,15 +237,16 @@ export class GenerateClientCommand extends Command { ConsumerOperation.Add, config.workingDirectory ); - // TODO: uncomment when telemetry is implemented - /* const duration = performance.now() - start; + const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; + const reporter = Telemetry.reporter; + reporter.sendRawTelemetryEvent(`${extensionId}.generateManifest.completed`, { "pluginType": pluginTypes.toString(), "errorsCount": errorsCount.toString(), }, { "duration": duration, - }); */ + }); return result; }); if (result) { diff --git a/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts b/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts index 5495c10263..53d474223f 100644 --- a/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts +++ b/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts @@ -1,11 +1,17 @@ import * as vscode from "vscode"; - import { ExtensionContext } from "vscode"; + +import { extensionId } from "../../constants"; import { ExtensionSettings } from "../../extensionSettings"; import { generateClient } from "../../generateClient"; import { generatePlugin } from "../../generatePlugin"; -import { ClientObjectProperties, ClientOrPluginProperties, ConsumerOperation, KiotaGenerationLanguage, KiotaPluginType, PluginObjectProperties, parseGenerationLanguage, parsePluginType } from "../../kiotaInterop"; +import { + ClientObjectProperties, ClientOrPluginProperties, ConsumerOperation, getLogEntriesForLevel, + KiotaGenerationLanguage, KiotaPluginType, LogLevel, parseGenerationLanguage, parsePluginType, + PluginObjectProperties +} from "../../kiotaInterop"; import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; +import { Telemetry } from "../../telemetry"; export class RegenerateService { private _context: ExtensionContext; @@ -82,16 +88,15 @@ export class RegenerateService { ConsumerOperation.Edit ); - // TODO: uncomment when telemetry is implemented - - /* const duration = performance.now() - start; - const errorsCount = result ? getLogEntriesForLevel(result, vscode.LogLevel.critical, vscode.LogLevel.error).length : 0; + const duration = performance.now() - start; + const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; + const reporter = Telemetry.reporter; reporter.sendRawTelemetryEvent(`${extensionId}.re-generatePlugin.completed`, { "pluginType": pluginTypes.toString(), "errorsCount": errorsCount.toString(), }, { "duration": duration, - }); */ + }); return result; }); void vscode.window.showInformationMessage(`Plugin ${this._clientKey} re-generated successfully.`); diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index fdfbcf74ba..889612575d 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -19,6 +19,7 @@ import { SearchOrOpenApiDescriptionCommand } from './commands/SearchOrOpenApiDes import { SelectLockCommand } from './commands/SelectLockCommand'; import { UpdateClientsCommand } from './commands/UpdateClientsCommand'; +import { AddAllToSelectedEndpointsCommand } from './commands/open-api-tree-node/AddAllToSelectedEndpointsCommand'; import { dependenciesInfo, extensionId, statusBarCommandId, treeViewId } from "./constants"; import { getExtensionSettings } from "./extensionSettings"; import { UriHandler } from './handlers/uri.handler'; @@ -28,8 +29,8 @@ import { DependenciesViewProvider } from './providers/dependenciesViewProvider'; import { OpenApiTreeNode, OpenApiTreeProvider } from './providers/openApiTreeProvider'; import { loadTreeView } from './providers/workspaceTreeProvider'; import { GenerateState } from "./steps"; +import { Telemetry } from './telemetry'; import { updateStatusBarItem } from './utilities/status-bar'; -import { AddAllToSelectedEndpointsCommand } from './commands/open-api-tree-node/AddAllToSelectedEndpointsCommand'; let kiotaStatusBarItem: vscode.StatusBarItem; let clientOrPluginKey: string; @@ -67,7 +68,8 @@ export async function activate( const uriHandler = new UriHandler(openApiTreeProvider); const codeLensProvider = new CodeLensProvider(); - const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); + const reporter = Telemetry.reporter; + await loadTreeView(context); context.subscriptions.push( diff --git a/vscode/microsoft-kiota/src/handlers/uri.handler.ts b/vscode/microsoft-kiota/src/handlers/uri.handler.ts index 0b5260b7fd..a9292652fe 100644 --- a/vscode/microsoft-kiota/src/handlers/uri.handler.ts +++ b/vscode/microsoft-kiota/src/handlers/uri.handler.ts @@ -1,11 +1,12 @@ import * as vscode from "vscode"; import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; +import { Telemetry } from "../telemetry"; import { openTreeViewWithProgress } from "../utilities/file"; export class UriHandler { private _openApiTreeProvider: OpenApiTreeProvider; - constructor(private openApiTreeProvider: OpenApiTreeProvider) { + constructor(openApiTreeProvider: OpenApiTreeProvider) { this._openApiTreeProvider = openApiTreeProvider; } @@ -16,8 +17,8 @@ export class UriHandler { const queryParameters = this.getQueryParameters(uri); if (uri.path.toLowerCase() === "/opendescription") { - // TODO: uncomment when telemetry is implemented - // reporter.sendTelemetryEvent("DeepLink.OpenDescription"); + const reporter = Telemetry.reporter; + reporter.sendTelemetryEvent("DeepLink.OpenDescription"); const descriptionUrl = queryParameters["descriptionurl"]; if (descriptionUrl) { await openTreeViewWithProgress(() => this._openApiTreeProvider.setDescriptionUrl(descriptionUrl)); diff --git a/vscode/microsoft-kiota/src/telemetry/index.ts b/vscode/microsoft-kiota/src/telemetry/index.ts new file mode 100644 index 0000000000..bd3dba4b1c --- /dev/null +++ b/vscode/microsoft-kiota/src/telemetry/index.ts @@ -0,0 +1,45 @@ +import TelemetryReporter from '@vscode/extension-telemetry'; +import * as vscode from "vscode"; + +export class Telemetry { + + public static reporter: TelemetryReporter; + + public static async initialize() { + const telemetryInstrumentationKey = await Telemetry.getInstrumentationKey(); + Telemetry.reporter = new TelemetryReporter(telemetryInstrumentationKey); + } + + public static sendEvent(eventName: string, properties?: { [key: string]: string }) { + try { + Telemetry.reporter.sendTelemetryEvent(eventName, properties); + } catch { + } + } + + private static async getInstrumentationKey(): Promise { + // Step 1: Locate the package.json file + const packageJsonFiles = await vscode.workspace.findFiles('**/package.json', '**/node_modules/**'); + + if (packageJsonFiles.length > 0) { + const packageJsonUri = packageJsonFiles[0]; // Assuming the first found is the right one + + // Step 2: Read the file contents + const fileContents = await vscode.workspace.fs.readFile(packageJsonUri); + + // Step 3: Parse the JSON and access the telemetryInstrumentationKey + const packageJson = JSON.parse(fileContents.toString()); + const instrumentationKey = packageJson["telemetryInstrumentationKey"]; + + if (instrumentationKey) { + return instrumentationKey; + } else { + throw new Error('Instrumentation key not found!'); + } + } else { + throw new Error('package.json file not found!'); + } + } +} + +export const telemetry = Telemetry.initialize(); \ No newline at end of file From 9cf817113494a97d561f68ef60c578fc2e891ff1 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 16:37:13 +0300 Subject: [PATCH 145/150] fix imports --- .../src/commands/KiotaStatusCommand.ts | 8 +++++- .../src/providers/openApiTreeProvider.ts | 28 ++++++++----------- .../src/providers/workspaceTreeProvider.ts | 8 +++--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts b/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts index 38cdd628dd..981ce1fc29 100644 --- a/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts +++ b/vscode/microsoft-kiota/src/commands/KiotaStatusCommand.ts @@ -1,11 +1,17 @@ import * as vscode from "vscode"; + +import { extensionId } from "../constants"; import { Command } from "./Command"; export class KiotaStatusCommand extends Command { public constructor() { super(); } - + + public toString(): string { + return `${extensionId}.status`; + } + async execute() { const yesAnswer = vscode.l10n.t("Yes"); const response = await vscode.window.showInformationMessage( diff --git a/vscode/microsoft-kiota/src/providers/openApiTreeProvider.ts b/vscode/microsoft-kiota/src/providers/openApiTreeProvider.ts index c84ae71c3a..b2834e0b0c 100644 --- a/vscode/microsoft-kiota/src/providers/openApiTreeProvider.ts +++ b/vscode/microsoft-kiota/src/providers/openApiTreeProvider.ts @@ -4,21 +4,15 @@ import * as path from 'path'; import * as vscode from 'vscode'; import * as rpc from 'vscode-jsonrpc/node'; import * as crypto from 'crypto'; -import { - ClientObjectProperties, - ClientOrPluginProperties, - connectToKiota, - KiotaGetManifestDetailsConfiguration, - KiotaLogEntry, - KiotaManifestResult, - KiotaOpenApiNode, - KiotaShowConfiguration, - KiotaShowResult, - ConfigurationFile, - PluginObjectProperties } from './kiotaInterop'; -import { ExtensionSettings } from './extensionSettings'; -import { treeViewId } from './constants'; -import { updateTreeViewIcons } from './util'; + +import { treeViewId } from '../constants'; +import { ExtensionSettings } from '../extensionSettings'; +import { + ConfigurationFile, ClientOrPluginProperties, ClientObjectProperties, PluginObjectProperties, + KiotaLogEntry, KiotaOpenApiNode, connectToKiota, KiotaGetManifestDetailsConfiguration, KiotaManifestResult, + KiotaShowConfiguration, KiotaShowResult +} from '../kiotaInterop'; +import { updateTreeViewIcons } from '../util'; export class OpenApiTreeProvider implements vscode.TreeDataProvider { private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter(); @@ -244,7 +238,7 @@ export class OpenApiTreeProvider implements vscode.TreeDataProvider { public isWSPresent: boolean; From b16dfb86ab954d54b4e9cbe17c5157163cb5c118 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 17:43:12 +0300 Subject: [PATCH 146/150] new up the Telemetry importer --- .../commands/generate-client/GenerateClientCommand.ts | 11 +++++------ .../src/commands/regenerate/regenerate.service.ts | 4 ++-- vscode/microsoft-kiota/src/extension.ts | 5 ++--- vscode/microsoft-kiota/src/handlers/uri.handler.ts | 10 +++++++--- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts b/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts index 1468ba107e..0c73a0fb30 100644 --- a/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts +++ b/vscode/microsoft-kiota/src/commands/generate-client/GenerateClientCommand.ts @@ -1,5 +1,6 @@ import * as vscode from "vscode"; import { ExtensionContext } from "vscode"; +import TelemetryReporter from "@vscode/extension-telemetry"; import { extensionId, treeViewFocusCommand, treeViewId } from "../../constants"; import { ExtensionSettings, getExtensionSettings } from "../../extensionSettings"; @@ -15,7 +16,6 @@ import { import { DependenciesViewProvider } from "../../providers/dependenciesViewProvider"; import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; import { GenerateState, generateSteps, GenerationType, parseGenerationType } from "../../steps"; -import { Telemetry } from "../../telemetry"; import { getWorkspaceJsonDirectory } from "../../util"; import { exportLogsAndShowErrors } from '../../utilities/logging'; import { showUpgradeWarningMessage } from "../../utilities/messaging"; @@ -142,8 +142,7 @@ export class GenerateClientCommand extends Command { const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; - const reporter = Telemetry.reporter; - + const reporter = new TelemetryReporter(this._context.extension.packageJSON.telemetryInstrumentationKey); reporter.sendRawTelemetryEvent(`${extensionId}.generateClient.completed`, { "language": generationLanguageToString(language), "errorsCount": errorsCount.toString(), @@ -198,7 +197,7 @@ export class GenerateClientCommand extends Command { const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; - const reporter = Telemetry.reporter; + const reporter = new TelemetryReporter(this._context.extension.packageJSON.telemetryInstrumentationKey); reporter.sendRawTelemetryEvent(`${extensionId}.generatePlugin.completed`, { "pluginType": pluginTypes.toString(), "errorsCount": errorsCount.toString(), @@ -239,8 +238,8 @@ export class GenerateClientCommand extends Command { ); const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; - const reporter = Telemetry.reporter; - + const reporter = new TelemetryReporter(this._context.extension.packageJSON.telemetryInstrumentationKey); + reporter.sendRawTelemetryEvent(`${extensionId}.generateManifest.completed`, { "pluginType": pluginTypes.toString(), "errorsCount": errorsCount.toString(), diff --git a/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts b/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts index 53d474223f..0215567f92 100644 --- a/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts +++ b/vscode/microsoft-kiota/src/commands/regenerate/regenerate.service.ts @@ -1,5 +1,6 @@ import * as vscode from "vscode"; import { ExtensionContext } from "vscode"; +import TelemetryReporter from "@vscode/extension-telemetry"; import { extensionId } from "../../constants"; import { ExtensionSettings } from "../../extensionSettings"; @@ -11,7 +12,6 @@ import { PluginObjectProperties } from "../../kiotaInterop"; import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; -import { Telemetry } from "../../telemetry"; export class RegenerateService { private _context: ExtensionContext; @@ -90,7 +90,7 @@ export class RegenerateService { const duration = performance.now() - start; const errorsCount = result ? getLogEntriesForLevel(result, LogLevel.critical, LogLevel.error).length : 0; - const reporter = Telemetry.reporter; + const reporter = new TelemetryReporter(this._context.extension.packageJSON.telemetryInstrumentationKey); reporter.sendRawTelemetryEvent(`${extensionId}.re-generatePlugin.completed`, { "pluginType": pluginTypes.toString(), "errorsCount": errorsCount.toString(), diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 889612575d..ffe4a851bd 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -29,7 +29,6 @@ import { DependenciesViewProvider } from './providers/dependenciesViewProvider'; import { OpenApiTreeNode, OpenApiTreeProvider } from './providers/openApiTreeProvider'; import { loadTreeView } from './providers/workspaceTreeProvider'; import { GenerateState } from "./steps"; -import { Telemetry } from './telemetry'; import { updateStatusBarItem } from './utilities/status-bar'; let kiotaStatusBarItem: vscode.StatusBarItem; @@ -65,10 +64,10 @@ export async function activate( const updateClientsCommand = new UpdateClientsCommand(context); const displayGenerationResultsCommand = new DisplayGenerationResultsCommand(context, openApiTreeProvider); const selectLockCommand = new SelectLockCommand(openApiTreeProvider); - const uriHandler = new UriHandler(openApiTreeProvider); + const uriHandler = new UriHandler(context, openApiTreeProvider); const codeLensProvider = new CodeLensProvider(); - const reporter = Telemetry.reporter; + const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); diff --git a/vscode/microsoft-kiota/src/handlers/uri.handler.ts b/vscode/microsoft-kiota/src/handlers/uri.handler.ts index a9292652fe..8d70196c3d 100644 --- a/vscode/microsoft-kiota/src/handlers/uri.handler.ts +++ b/vscode/microsoft-kiota/src/handlers/uri.handler.ts @@ -1,13 +1,17 @@ +import TelemetryReporter from "@vscode/extension-telemetry"; import * as vscode from "vscode"; +import { ExtensionContext } from "vscode"; + import { OpenApiTreeProvider } from "../providers/openApiTreeProvider"; -import { Telemetry } from "../telemetry"; import { openTreeViewWithProgress } from "../utilities/file"; export class UriHandler { + private _context: ExtensionContext; private _openApiTreeProvider: OpenApiTreeProvider; - constructor(openApiTreeProvider: OpenApiTreeProvider) { + constructor(context: ExtensionContext, openApiTreeProvider: OpenApiTreeProvider,) { this._openApiTreeProvider = openApiTreeProvider; + this._context = context; } async handleUri(uri: vscode.Uri) { @@ -17,7 +21,7 @@ export class UriHandler { const queryParameters = this.getQueryParameters(uri); if (uri.path.toLowerCase() === "/opendescription") { - const reporter = Telemetry.reporter; + const reporter = new TelemetryReporter(this._context.extension.packageJSON.telemetryInstrumentationKey); reporter.sendTelemetryEvent("DeepLink.OpenDescription"); const descriptionUrl = queryParameters["descriptionurl"]; if (descriptionUrl) { From 10091c44df7c5cf1d929ba690ba9c57d6975fcd2 Mon Sep 17 00:00:00 2001 From: thewahome Date: Wed, 14 Aug 2024 17:46:46 +0300 Subject: [PATCH 147/150] remove telemetry folder --- vscode/microsoft-kiota/src/telemetry/index.ts | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 vscode/microsoft-kiota/src/telemetry/index.ts diff --git a/vscode/microsoft-kiota/src/telemetry/index.ts b/vscode/microsoft-kiota/src/telemetry/index.ts deleted file mode 100644 index bd3dba4b1c..0000000000 --- a/vscode/microsoft-kiota/src/telemetry/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -import TelemetryReporter from '@vscode/extension-telemetry'; -import * as vscode from "vscode"; - -export class Telemetry { - - public static reporter: TelemetryReporter; - - public static async initialize() { - const telemetryInstrumentationKey = await Telemetry.getInstrumentationKey(); - Telemetry.reporter = new TelemetryReporter(telemetryInstrumentationKey); - } - - public static sendEvent(eventName: string, properties?: { [key: string]: string }) { - try { - Telemetry.reporter.sendTelemetryEvent(eventName, properties); - } catch { - } - } - - private static async getInstrumentationKey(): Promise { - // Step 1: Locate the package.json file - const packageJsonFiles = await vscode.workspace.findFiles('**/package.json', '**/node_modules/**'); - - if (packageJsonFiles.length > 0) { - const packageJsonUri = packageJsonFiles[0]; // Assuming the first found is the right one - - // Step 2: Read the file contents - const fileContents = await vscode.workspace.fs.readFile(packageJsonUri); - - // Step 3: Parse the JSON and access the telemetryInstrumentationKey - const packageJson = JSON.parse(fileContents.toString()); - const instrumentationKey = packageJson["telemetryInstrumentationKey"]; - - if (instrumentationKey) { - return instrumentationKey; - } else { - throw new Error('Instrumentation key not found!'); - } - } else { - throw new Error('package.json file not found!'); - } - } -} - -export const telemetry = Telemetry.initialize(); \ No newline at end of file From 8f5f368f188f6630d457ba7931bfb06afed557a4 Mon Sep 17 00:00:00 2001 From: Elinor Date: Thu, 15 Aug 2024 12:23:39 +0300 Subject: [PATCH 148/150] Feat: Add migration dialog (#5144) --- .../microsoft-kiota/l10n/bundle.l10n.ar.json | 9 ++- .../microsoft-kiota/l10n/bundle.l10n.cs.json | 9 ++- .../microsoft-kiota/l10n/bundle.l10n.es.json | 9 ++- .../microsoft-kiota/l10n/bundle.l10n.fr.json | 9 ++- .../microsoft-kiota/l10n/bundle.l10n.it.json | 9 ++- .../microsoft-kiota/l10n/bundle.l10n.ja.json | 9 ++- .../microsoft-kiota/l10n/bundle.l10n.pl.json | 9 ++- .../microsoft-kiota/l10n/bundle.l10n.pt.json | 9 ++- .../microsoft-kiota/l10n/bundle.l10n.ru.json | 9 ++- .../microsoft-kiota/l10n/bundle.l10n.sw.json | 9 ++- .../microsoft-kiota/l10n/bundle.l10n.tr.json | 9 ++- .../l10n/bundle.l10n.zh-cn.json | 9 ++- vscode/microsoft-kiota/package.json | 17 ++++++ vscode/microsoft-kiota/package.nls.ar.json | 3 +- vscode/microsoft-kiota/package.nls.cs.json | 3 +- vscode/microsoft-kiota/package.nls.es.json | 4 +- vscode/microsoft-kiota/package.nls.fr.json | 4 +- vscode/microsoft-kiota/package.nls.it.json | 4 +- vscode/microsoft-kiota/package.nls.ja.json | 8 ++- vscode/microsoft-kiota/package.nls.json | 3 +- vscode/microsoft-kiota/package.nls.pl.json | 8 ++- vscode/microsoft-kiota/package.nls.pt.json | 4 +- vscode/microsoft-kiota/package.nls.ru.json | 16 +++++- vscode/microsoft-kiota/package.nls.sw.json | 4 +- vscode/microsoft-kiota/package.nls.tr.json | 8 ++- vscode/microsoft-kiota/src/constants.ts | 2 + vscode/microsoft-kiota/src/extension.ts | 18 +++++- .../src/migrateFromLockFile.ts | 56 ++++++++++++++++++- vscode/microsoft-kiota/src/util.ts | 28 ++++++++++ 29 files changed, 263 insertions(+), 35 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json index 441b9e14fb..62293e9155 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ar.json @@ -70,5 +70,12 @@ "Generating manifest...": "", "Generating plugin...": "", "Re-generating client...": "", - "Re-generating plugin...": "" + "Re-generating plugin...": "", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api clients migrated successfully!":"", + "Could not determine the workspace folder.": "لا يمكن تحديد مجلد مساحة العمل." } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json index 108bae1484..399db84bfc 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.cs.json @@ -70,5 +70,12 @@ "Generating manifest...": "Generování manifestu...", "Generating plugin...": "Generování pluginu...", "Re-generating client...": "Opětovné generování klienta...", - "Re-generating plugin...": "Opětovné generování pluginu..." + "Re-generating plugin...": "Opětovné generování pluginu...", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api clients migrated successfully!":"", + "Could not determine the workspace folder.": "Nepodařilo se určit složku pracovního prostoru." } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json index 417be3b3d3..92f9942590 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.es.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.es.json @@ -70,5 +70,12 @@ "Generating manifest...": "Generando manifesto...", "Generating plugin...": "Generando plugin...", "Re-generating client...": "Re-generando cliente...", - "Re-generating plugin...": "Re-generando plugin..." + "Re-generating plugin...": "Re-generando plugin...", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api clients migrated successfully!":"", + "Could not determine the workspace folder.": "No se pudo determinar la carpeta de espacio de trabajo." } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json index e639041a90..68cb0b95a6 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json @@ -70,5 +70,12 @@ "Generating manifest...": "Génération du manifeste...", "Generating plugin...": "Génération du composant...", "Re-generating client...": "Rafraichissement du client...", - "Re-generating plugin...": "Refraichissement du composant..." + "Re-generating plugin...": "Refraichissement du composant...", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api clients migrated successfully!":"", + "Could not determine the workspace folder.": "Impossible de déterminer le dossier de l'espace de travail." } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json index b10609f433..e4c3c0e301 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.it.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.it.json @@ -70,5 +70,12 @@ "Generating manifest...": "Generando il manifest...", "Generating plugin...": "Generando il plugin...", "Re-generating client...": "Ri-generando il client...", - "Re-generating plugin...": "Ri-generando il plugin..." + "Re-generating plugin...": "Ri-generando il plugin...", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api clients migrated successfully!":"", + "Could not determine the workspace folder.": "Impossibile determinare la cartella di lavoro." } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json index e248530e02..a2f3b17c96 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ja.json @@ -70,5 +70,12 @@ "Generating manifest...": "", "Generating plugin...": "", "Re-generating client...": "", - "Re-generating plugin...": "" + "Re-generating plugin...": "", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api clients migrated successfully!":"", + "Could not determine the workspace folder.": "ワークスペースフォルダを特定できませんでした。" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json index 828b872e19..df0f952569 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pl.json @@ -70,5 +70,12 @@ "Generating manifest...": "Generowanie manifestu...", "Generating plugin...": "Generowanie wtyczki", "Re-generating client...": "Ponowne generowanie klienta...", - "Re-generating plugin...": "Ponowne generowanie wtyczki..." + "Re-generating plugin...": "Ponowne generowanie wtyczki...", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api clients migrated successfully!":"", + "Could not determine the workspace folder.": "Nie można określić folderu przestrzeni roboczej." } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json index 7f9a96542f..f7e2ce2e15 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.pt.json @@ -70,5 +70,12 @@ "Generating manifest...": "Gerando o manifesto...", "Generating plugin...": "Gerando o plugin...", "Re-generating client...": "Regerando o cliente...", - "Re-generating plugin...": "Regerando o plugin..." + "Re-generating plugin...": "Regerando o plugin...", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api clients migrated successfully!":"", + "Could not determine the workspace folder.": "Não foi possível determinar a pasta de trabalho." } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json index 031b80012c..9b5e5c3145 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.ru.json @@ -69,5 +69,12 @@ "Generating manifest...": "Генерация манифеста...", "Generating plugin...": "Генерация плагина...", "Re-generating client...": "Перегенерация клиента...", - "Re-generating plugin...": "Перегенерация плагина..." + "Re-generating plugin...": "Перегенерация плагина...", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api clients migrated successfully!":"", + "Could not determine the workspace folder.": "Не удалось определить папку рабочего пространства." } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json index 1d1613baa8..e8f8e1e75a 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.sw.json @@ -70,5 +70,12 @@ "Generating manifest...": "Inatengeneza dhariri..", "Generating plugin...": "Inatengeneza programu-jalizi...", "Re-generating client...": "Inatengeneza mteja upya...", - "Re-generating plugin...": "Inatengeneza programu-jalizi upya ..." + "Re-generating plugin...": "Inatengeneza programu-jalizi upya ...", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api client migrateds successfully!":"", + "Could not determine the workspace folder.": "Haiwezekani kubaini folda ya kazi." } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json index 1db954277f..c252995721 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.tr.json @@ -70,5 +70,12 @@ "Generating manifest...": "", "Generating plugin...": "", "Re-generating client...": "", - "Re-generating plugin...": "" + "Re-generating plugin...": "", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api clients migrated successfully!":"", + "Could not determine the workspace folder.": "" } diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json index ffc8d9e7ec..fffd320503 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.zh-cn.json @@ -69,5 +69,12 @@ "Generating manifest...": "正在生成清单...", "Generating plugin...": "正在生成插件...", "Re-generating client...": "重新生成客户端...", - "Re-generating plugin...": "正在重新生成插件..." + "Re-generating plugin...": "正在重新生成插件...", + "Please migrate your API clients to Kiota workspace.":"", + "Remind me later":"", + "Migrating your API clients...":"", + "Migration completed, but no changes were detected.":"", + "Migration failed":"", + "Api clients migrated successfully!":"", + "Could not determine the workspace folder.": "无法确定工作区文件夹" } diff --git a/vscode/microsoft-kiota/package.json b/vscode/microsoft-kiota/package.json index d8b1eb9652..1c95006df8 100644 --- a/vscode/microsoft-kiota/package.json +++ b/vscode/microsoft-kiota/package.json @@ -234,6 +234,11 @@ "command": "kiota.selectLock", "group": "2_kiota@1", "when": "resourceLangId == json && resourceFilename =~ /workspace\\.json$/" + }, + { + "command": "kiota.migrateFromLockFile", + "when": "resourceExtname == .json && resourceFilename == kiota-lock.json", + "group": "navigation" } ], "view/title": [ @@ -315,6 +320,13 @@ "command": "kiota.openApiExplorer.removeAllFromSelectedEndpoints", "when": "false" } + ], + "editor/context": [ + { + "command": "kiota.migrateFromLockFile", + "when": "resourceExtname == .json && resourceFilename == kiota-lock.json", + "group": "navigation" + } ] }, "commands": [ @@ -413,7 +425,12 @@ { "command": "kiota.workspace.refresh", "title": "%kiota.openApiExplorer.refresh.title%" + }, + { + "command": "kiota.migrateFromLockFile", + "title": "%kiota.migrateClients.title%" } + ], "languages": [ { diff --git a/vscode/microsoft-kiota/package.nls.ar.json b/vscode/microsoft-kiota/package.nls.ar.json index 8f80d7c77a..fc42890243 100644 --- a/vscode/microsoft-kiota/package.nls.ar.json +++ b/vscode/microsoft-kiota/package.nls.ar.json @@ -28,5 +28,6 @@ "kiota.generate.includeAdditionalData.description": "سيتم تضمين خاصية 'Additional Data' للنماذج", "kiota.workspace.name": "", "kiota.openApiExplorer.regenerateButton.title": "", - "kiota.openApiExplorer.editPaths.title": "" + "kiota.openApiExplorer.editPaths.title": "", + "kiota.migrateClients.title": "" } diff --git a/vscode/microsoft-kiota/package.nls.cs.json b/vscode/microsoft-kiota/package.nls.cs.json index eebfa55d3d..f010aeb6f0 100644 --- a/vscode/microsoft-kiota/package.nls.cs.json +++ b/vscode/microsoft-kiota/package.nls.cs.json @@ -28,5 +28,6 @@ "kiota.generate.includeAdditionalData.description": "Bude zahrnuta vlastnost 'AdditionalData' pro modely", "kiota.workspace.name": "Můj pracovní prostor", "kiota.openApiExplorer.regenerateButton.title": "Znovu vygenerovat", - "kiota.openApiExplorer.editPaths.title": "Upravit cesty" + "kiota.openApiExplorer.editPaths.title": "Upravit cesty", + "kiota.migrateClients.title": "Migrovat API klienty" } diff --git a/vscode/microsoft-kiota/package.nls.es.json b/vscode/microsoft-kiota/package.nls.es.json index 60a2d1fdaa..2265e8f1a2 100644 --- a/vscode/microsoft-kiota/package.nls.es.json +++ b/vscode/microsoft-kiota/package.nls.es.json @@ -28,5 +28,7 @@ "kiota.generate.includeAdditionalData.description": "Incluirá la propiedad 'AdditionalData' para modelos.", "kiota.workspace.name": "Mi espacio de trabajo", "kiota.openApiExplorer.regenerateButton.title": "Re-generar", - "kiota.openApiExplorer.editPaths.title": "Editar ruta de acceso" + "kiota.openApiExplorer.editPaths.title": "Editar ruta de acceso", + "kiota.openApiExplorer.refresh.title": "Actualizar", + "kiota.migrateClients.title": "Migrar clientes del API" } diff --git a/vscode/microsoft-kiota/package.nls.fr.json b/vscode/microsoft-kiota/package.nls.fr.json index 6fc8376876..a21a66347a 100644 --- a/vscode/microsoft-kiota/package.nls.fr.json +++ b/vscode/microsoft-kiota/package.nls.fr.json @@ -28,5 +28,7 @@ "kiota.generate.includeAdditionalData.description": "Incluera la propriété 'AdditionalData' pour les modèles générés.", "kiota.workspace.name": "Mon espace de travail", "kiota.openApiExplorer.regenerateButton.title": "Générer de nouveau", - "kiota.openApiExplorer.editPaths.title": "Modifier les chemins" + "kiota.openApiExplorer.editPaths.title": "Modifier les chemins", + "kiota.openApiExplorer.refresh.title": "Rafraîchir", + "kiota.migrateClients.title": "Migrer les clients d'API" } diff --git a/vscode/microsoft-kiota/package.nls.it.json b/vscode/microsoft-kiota/package.nls.it.json index ac68bf7ec4..7f7155d26a 100644 --- a/vscode/microsoft-kiota/package.nls.it.json +++ b/vscode/microsoft-kiota/package.nls.it.json @@ -28,5 +28,7 @@ "kiota.generate.includeAdditionalData.description": "Includerà la proprietà 'AdditionalData' per i modelli", "kiota.workspace.name": "Il mio spazio di lavoro", "kiota.openApiExplorer.regenerateButton.title": "Rigener", - "kiota.openApiExplorer.editPaths.title": "Modifica i percorsi" + "kiota.openApiExplorer.editPaths.title": "Modifica i percorsi", + "kiota.openApiExplorer.refresh.title": "Aggiorna", + "kiota.migrateClients.title": "Migra i client API" } diff --git a/vscode/microsoft-kiota/package.nls.ja.json b/vscode/microsoft-kiota/package.nls.ja.json index 20e515b42a..9a6efa3282 100644 --- a/vscode/microsoft-kiota/package.nls.ja.json +++ b/vscode/microsoft-kiota/package.nls.ja.json @@ -26,7 +26,9 @@ "kiota.generate.deserializer.description": "デシリアライザの完全修飾クラス名", "kiota.generate.structuredMimeTypes.description": "構造化データモデル生成に使用するMIMEタイプと設定(RFC 9110のAcceptヘッダー表記)", "kiota.generate.includeAdditionalData.description": "モデルのための“AdditionalData”プロパティを含める", - "kiota.workspace.name": "My Workspace", - "kiota.openApiExplorer.regenerateButton.title": "Re-generate", - "kiota.openApiExplorer.editPaths.title": "Edit paths" + "kiota.workspace.name": "ワークスペース", + "kiota.openApiExplorer.regenerateButton.title": "再生成", + "kiota.openApiExplorer.editPaths.title": "パスを編集", + "kiota.openApiExplorer.refresh.title": "リフレッシュ", + "kiota.migrateClients.title": "APIクライアントを移行" } diff --git a/vscode/microsoft-kiota/package.nls.json b/vscode/microsoft-kiota/package.nls.json index 00e54d3cb5..5c7baf619a 100644 --- a/vscode/microsoft-kiota/package.nls.json +++ b/vscode/microsoft-kiota/package.nls.json @@ -30,5 +30,6 @@ "kiota.workspace.name": "My Workspace", "kiota.openApiExplorer.regenerateButton.title": "Re-generate", "kiota.openApiExplorer.editPaths.title": "Edit paths", - "kiota.openApiExplorer.refresh.title": "Refresh" + "kiota.openApiExplorer.refresh.title": "Refresh", + "kiota.migrateClients.title": "Migrate API clients" } diff --git a/vscode/microsoft-kiota/package.nls.pl.json b/vscode/microsoft-kiota/package.nls.pl.json index db57de062a..91b4870fb8 100644 --- a/vscode/microsoft-kiota/package.nls.pl.json +++ b/vscode/microsoft-kiota/package.nls.pl.json @@ -27,7 +27,9 @@ "kiota.generate.deserializer.description": "Pełne nazwy klas dla deserializatorów", "kiota.generate.structuredMimeTypes.description": "Typy MIME i preferencje do użycia dla generacji modeli danych strukturalnych. Zgodnie z notacją nagłówka Accept RFC9110.", "kiota.generate.includeAdditionalData.description": "Doda właściwości 'AdditionalData' do modeli", - "kiota.workspace.name": "My Workspace", - "kiota.openApiExplorer.regenerateButton.title": "Re-generate", - "kiota.openApiExplorer.editPaths.title": "Edit paths" + "kiota.workspace.name": "Moja przestrzeń robocza", + "kiota.openApiExplorer.regenerateButton.title": "Ponownie wygeneruj", + "kiota.openApiExplorer.editPaths.title": "Edytuj ścieżki", + "kiota.openApiExplorer.refresh.title": "Odśwież", + "kiota.migrateClients.title": "Migruj klientów API" } diff --git a/vscode/microsoft-kiota/package.nls.pt.json b/vscode/microsoft-kiota/package.nls.pt.json index 8128a1e643..76f1b780b8 100644 --- a/vscode/microsoft-kiota/package.nls.pt.json +++ b/vscode/microsoft-kiota/package.nls.pt.json @@ -28,5 +28,7 @@ "kiota.generate.includeAdditionalData.description": "Será incluído a propriedade 'AdditionalData' para modelos", "kiota.workspace.name": "Meu espaço de trabalho", "kiota.openApiExplorer.regenerateButton.title": "Gerar novamente", - "kiota.openApiExplorer.editPaths.title": "Modificar endpoints" + "kiota.openApiExplorer.editPaths.title": "Modificar endpoints", + "kiota.openApiExplorer.refresh.title": "Atualizar", + "kiota.migrateClients.title": "Migrar clientes de API" } diff --git a/vscode/microsoft-kiota/package.nls.ru.json b/vscode/microsoft-kiota/package.nls.ru.json index e5bde6083a..5e4db32ccc 100644 --- a/vscode/microsoft-kiota/package.nls.ru.json +++ b/vscode/microsoft-kiota/package.nls.ru.json @@ -16,5 +16,19 @@ "kiota.openApiExplorer.openDescription.title": "Открыть описание API", "kiota.searchLock.title": "Искать файл блокировки", "kiota.openApiExplorer.filterDescription.title": "Отфильтровать описание API", - "kiota.openApiExplorer.openDocumentationPage.title": "Открыть страницу документации" + "kiota.openApiExplorer.openDocumentationPage.title": "Открыть страницу документации", + "kiota.generate.backingStore.description": "Включить резервное хранилище для моделей", + "kiota.generate.excludeBackwardCompatible.description": "Исключить совместимые с предыдущими версиями и устаревшие активы из сгенерированного результата. Следует использовать для новых клиентов", + "kiota.cleanOutput.description": "Удалить все файлы из каталога вывода перед созданием файлов кода", + "kiota.generate.disabledValidationRules.description": "Правила проверки описания OpenAPI для отключения: \nDivergentResponseSchema\nGetWithBody\nInconsistentTypeFormatPair\nKnownAndNotSupportedFormats\nMissingDiscriminator\nMultipleServerEntries\nNoContentWithBody\nNoServerEntry\nUrlFormEncodedComplex\nValidationRuleSetExtensions\nAll", + "kiota.clearCache.description": "Очистить любые кэшированные данные", + "kiota.generate.serializer.description": "Полностью квалифицированные имена классов для сериализаторов", + "kiota.generate.deserializer.description": "Полностью квалифицированные имена классов для десериализаторов", + "kiota.generate.structuredMimeTypes.description": "Типы MIME и предпочтения для использования при создании структурированных моделей данных. Согласно нотации заголовка Accept RFC9110.", + "kiota.generate.includeAdditionalData.description": "Будет включено свойство 'Дополнительные данные' для моделей", + "kiota.workspace.name": "Мое рабочее пространство", + "kiota.openApiExplorer.regenerateButton.title": "Пересоздать", + "kiota.openApiExplorer.editPaths.title": "Изменить пути", + "kiota.openApiExplorer.refresh.title": "Обновить", + "kiota.migrateClients.title": "Перенести API-клиенты" } diff --git a/vscode/microsoft-kiota/package.nls.sw.json b/vscode/microsoft-kiota/package.nls.sw.json index 254f2975c7..b4946bacb8 100644 --- a/vscode/microsoft-kiota/package.nls.sw.json +++ b/vscode/microsoft-kiota/package.nls.sw.json @@ -20,5 +20,7 @@ "kiota.openApiExplorer.openFile.title": "fungua faili", "kiota.workspace.name": "Mahali pa kazi yangu", "kiota.openApiExplorer.regenerateButton.title": "Kuunda upya", - "kiota.openApiExplorer.editPaths.title": "Hariri pointi za mwisho" + "kiota.openApiExplorer.editPaths.title": "Hariri pointi za mwisho", + "kiota.openApiExplorer.refresh.title": "Sasisha", + "kiota.migrateClients.title": "Hamisha wateja wa API" } diff --git a/vscode/microsoft-kiota/package.nls.tr.json b/vscode/microsoft-kiota/package.nls.tr.json index 04006690ea..2956d11157 100644 --- a/vscode/microsoft-kiota/package.nls.tr.json +++ b/vscode/microsoft-kiota/package.nls.tr.json @@ -26,7 +26,9 @@ "kiota.generate.deserializer.description": "Seri durumdan çıkarma işlemleri için tam nitelikli sınıf adları", "kiota.generate.structuredMimeTypes.description": "Yapılandırılmış veri modeli oluşturmak için kullanılacak MIME türleri ve tercihi. RFC9110'a göre Başlık gösterimini kabul et.", "kiota.generate.includeAdditionalData.description": "Modeller için 'AdditionalData' özelliğini içerecektir", - "kiota.workspace.name": "My Workspace", - "kiota.openApiExplorer.regenerateButton.title": "Re-generate", - "kiota.openApiExplorer.editPaths.title": "Edit paths" + "kiota.workspace.name": "Çalışma Alanım", + "kiota.openApiExplorer.regenerateButton.title": "Yeniden oluştur", + "kiota.openApiExplorer.editPaths.title": "Yolları düzenle", + "kiota.openApiExplorer.refresh.title": "Yenile", + "kiota.migrateClients.title": "API istemcilerini taşı" } diff --git a/vscode/microsoft-kiota/src/constants.ts b/vscode/microsoft-kiota/src/constants.ts index c604466f7e..45c775da13 100644 --- a/vscode/microsoft-kiota/src/constants.ts +++ b/vscode/microsoft-kiota/src/constants.ts @@ -4,6 +4,7 @@ export const statusBarCommandId = `${extensionId}.status`; export const treeViewId = `${extensionId}.openApiExplorer`; export const treeViewFocusCommand = `${treeViewId}${focusCommandId}`; export const dependenciesInfo = `${extensionId}.dependenciesInfo`; +export const KIOTA_LOCK_FILE = "kiota-lock.json"; export const KIOTA_WORKSPACE_FILE = "workspace.json"; export const KIOTA_DIRECTORY = '.kiota'; export const CLIENTS = "clients"; @@ -11,4 +12,5 @@ export const PLUGINS = "plugins"; export const CLIENT = "client"; export const PLUGIN = "plugin"; export const APIMANIFEST = "apimanifest"; +export const REMIND_ME_LATER_FLAG = 'remindMeLater'; diff --git a/vscode/microsoft-kiota/src/extension.ts b/vscode/microsoft-kiota/src/extension.ts index 45576ea78b..c7cdc97884 100644 --- a/vscode/microsoft-kiota/src/extension.ts +++ b/vscode/microsoft-kiota/src/extension.ts @@ -28,8 +28,9 @@ import { ExtensionSettings, getExtensionSettings } from "./extensionSettings"; import { loadTreeView } from "./workspaceTreeProvider"; import { generatePlugin } from "./generatePlugin"; import { CodeLensProvider } from "./codelensProvider"; -import { KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; -import { getWorkspaceJsonDirectory, getWorkspaceJsonPath, isClientType, isPluginType, updateTreeViewIcons } from "./util"; +import { KIOTA_WORKSPACE_FILE, dependenciesInfo, extensionId, statusBarCommandId, treeViewFocusCommand, treeViewId } from "./constants"; +import { getWorkspaceJsonDirectory, getWorkspaceJsonPath, handleMigration, isClientType, isPluginType, updateTreeViewIcons } from "./util"; +import { checkForLockFileAndPrompt } from "./migrateFromLockFile"; let kiotaStatusBarItem: vscode.StatusBarItem; let kiotaOutputChannel: vscode.LogOutputChannel; @@ -57,6 +58,7 @@ export async function activate( ); const reporter = new TelemetryReporter(context.extension.packageJSON.telemetryInstrumentationKey); await loadTreeView(context); + await checkForLockFileAndPrompt(context); let codeLensProvider = new CodeLensProvider(); context.subscriptions.push( vscode.window.registerUriHandler({ @@ -294,7 +296,17 @@ export async function activate( await regeneratePlugin(clientKey, clientObject, settings); } }), - ); + registerCommandWithTelemetry(reporter, `${extensionId}.migrateFromLockFile`, async (uri: vscode.Uri) => { + const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri); + + if (!workspaceFolder) { + vscode.window.showErrorMessage(vscode.l10n.t("Could not determine the workspace folder.")); + return; + } + + await handleMigration(context, workspaceFolder); + }) +); async function generateManifestAndRefreshUI(config: Partial, settings: ExtensionSettings, outputPath: string, selectedPaths: string[]):Promise { const pluginTypes = KiotaPluginType.ApiManifest; diff --git a/vscode/microsoft-kiota/src/migrateFromLockFile.ts b/vscode/microsoft-kiota/src/migrateFromLockFile.ts index 33593b8590..9c77d8dfd1 100644 --- a/vscode/microsoft-kiota/src/migrateFromLockFile.ts +++ b/vscode/microsoft-kiota/src/migrateFromLockFile.ts @@ -1,6 +1,8 @@ -import { connectToKiota, KiotaLogEntry } from "./kiotaInterop"; +import { connectToKiota, KiotaLogEntry, LogLevel } from "./kiotaInterop"; import * as rpc from "vscode-jsonrpc/node"; import * as vscode from "vscode"; +import { KIOTA_LOCK_FILE } from "./constants"; +import { getWorkspaceJsonPath, handleMigration } from "./util"; export function migrateFromLockFile(context: vscode.ExtensionContext, lockFileDirectory: string): Promise { return connectToKiota(context, async (connection) => { @@ -13,4 +15,54 @@ export function migrateFromLockFile(context: vscode.ExtensionContext, lockFileDi ); return result; }); -}; \ No newline at end of file +}; + +export async function checkForLockFileAndPrompt(context: vscode.ExtensionContext) { + const workspaceFolders = vscode.workspace.workspaceFolders; + + if(workspaceFolders) { + const lockFile = await vscode.workspace.findFiles(`{**/${KIOTA_LOCK_FILE},${KIOTA_LOCK_FILE}}`); + + if (lockFile.length > 0) { + const result = await vscode.window.showInformationMessage( + vscode.l10n.t("Please migrate your API clients to Kiota workspace."), + vscode.l10n.t("OK"), + vscode.l10n.t("Remind me later") + ); + + if (result === vscode.l10n.t("OK")) { + await handleMigration(context, workspaceFolders![0]); + await vscode.commands.executeCommand('kiota.workspace.refresh'); + } + } + } + }; + +export function displayMigrationMessages(logEntries: KiotaLogEntry[]) { + const workspaceJsonUri = vscode.Uri.file(getWorkspaceJsonPath()); + const successEntries = logEntries.filter(entry => + entry.level === LogLevel.information && entry.message.includes("migrated successfully") + ); + + if (successEntries.length > 0) { + successEntries.forEach(entry => { + vscode.window.showInformationMessage(vscode.l10n.t("Api clients migrated successfully!")); + vscode.commands.executeCommand('kiota.workspace.refresh'); + vscode.commands.executeCommand('kiota.workspace.openWorkspaceFile', workspaceJsonUri); + }); + } else { + logEntries.forEach(entry => { + switch (entry.level) { + case LogLevel.warning: + vscode.window.showWarningMessage(vscode.l10n.t(entry.message)); + break; + case LogLevel.error: + case LogLevel.critical: + vscode.window.showErrorMessage(vscode.l10n.t(entry.message)); + break; + default: + break; + } + }); + } +} \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/util.ts b/vscode/microsoft-kiota/src/util.ts index 087dc03fde..cd67dd6d35 100644 --- a/vscode/microsoft-kiota/src/util.ts +++ b/vscode/microsoft-kiota/src/util.ts @@ -2,6 +2,7 @@ import * as vscode from 'vscode'; import * as path from 'path'; import * as fs from 'fs'; import { APIMANIFEST, CLIENT, CLIENTS, KIOTA_DIRECTORY, KIOTA_WORKSPACE_FILE, PLUGIN, PLUGINS } from './constants'; +import { migrateFromLockFile, displayMigrationMessages } from './migrateFromLockFile'; const clientTypes = [CLIENT, CLIENTS]; const pluginTypes = [PLUGIN, PLUGINS, APIMANIFEST]; @@ -66,4 +67,31 @@ export function findAppPackageDirectory(directory: string): string | null { } return null; +} + +export async function handleMigration( + context: vscode.ExtensionContext, + workspaceFolder: vscode.WorkspaceFolder +): Promise { + vscode.window.withProgress({ + location: vscode.ProgressLocation.Notification, + title: vscode.l10n.t("Migrating your API clients..."), + cancellable: false + }, async (progress) => { + progress.report({ increment: 0 }); + + try { + const migrationResult = await migrateFromLockFile(context, workspaceFolder.uri.fsPath); + + progress.report({ increment: 100 }); + + if (migrationResult && migrationResult.length > 0) { + displayMigrationMessages(migrationResult); + } else { + vscode.window.showWarningMessage(vscode.l10n.t("Migration completed, but no changes were detected.")); + } + } catch (error) { + vscode.window.showErrorMessage(vscode.l10n.t(`Migration failed: ${error}`)); + } + }); } \ No newline at end of file From acbb73f807abb83f51aeba602e46e9397182ab2e Mon Sep 17 00:00:00 2001 From: thewahome Date: Thu, 15 Aug 2024 13:21:01 +0300 Subject: [PATCH 149/150] enable execute to run sync and async --- .../microsoft-kiota/src/commands/CloseDescriptionCommand.ts | 2 +- vscode/microsoft-kiota/src/commands/Command.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts b/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts index 4783cc9e26..ba7962fc4d 100644 --- a/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts +++ b/vscode/microsoft-kiota/src/commands/CloseDescriptionCommand.ts @@ -28,5 +28,5 @@ export class CloseDescriptionCommand extends Command { this._openApiTreeProvider.closeDescription(); await updateTreeViewIcons(treeViewId, false); } -} + } } \ No newline at end of file diff --git a/vscode/microsoft-kiota/src/commands/Command.ts b/vscode/microsoft-kiota/src/commands/Command.ts index 5e5b4efcc0..589690b362 100644 --- a/vscode/microsoft-kiota/src/commands/Command.ts +++ b/vscode/microsoft-kiota/src/commands/Command.ts @@ -1,5 +1,5 @@ export abstract class Command { - public abstract toString():string; + public abstract toString(): string; - abstract execute(args: unknown):void; + abstract execute(args: unknown): Promise | void; } \ No newline at end of file From f47a10f2297a9003b284d795510ff8aa94cfc0bb Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 15 Aug 2024 10:02:53 -0400 Subject: [PATCH 150/150] chore: adds missing french translations --- vscode/microsoft-kiota/l10n/bundle.l10n.fr.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json index 68cb0b95a6..384df87256 100644 --- a/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json +++ b/vscode/microsoft-kiota/l10n/bundle.l10n.fr.json @@ -38,7 +38,7 @@ "No content found in the clipboard": "Aucun contenu trouvé dans le presse-papiers", "Invalid content found in the clipboard": "Contenu non valide trouvé dans le presse-papiers", "Select an API manifest key": "Sélectionnez une clé de manifeste d'API", - "Edit Paths":"Modifier les chemins", + "Edit Paths": "Modifier les chemins", "Re-generate": "Générer de nouveau", "Add an API description": "Ajouter une description d'API", "Search or paste a path to an API description": "Rechercher ou coller un chemin vers unde description d'API", @@ -71,11 +71,11 @@ "Generating plugin...": "Génération du composant...", "Re-generating client...": "Rafraichissement du client...", "Re-generating plugin...": "Refraichissement du composant...", - "Please migrate your API clients to Kiota workspace.":"", - "Remind me later":"", - "Migrating your API clients...":"", - "Migration completed, but no changes were detected.":"", - "Migration failed":"", - "Api clients migrated successfully!":"", + "Please migrate your API clients to Kiota workspace.": "Veuillez mettre vos clients d'API à jour vers l'expérience d'espace de travail Kiota.", + "Remind me later": "Me le rappeler plus tard", + "Migrating your API clients...": "Migration de vos clients en cours...", + "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." -} +} \ No newline at end of file