Skip to content

Commit

Permalink
add types
Browse files Browse the repository at this point in the history
  • Loading branch information
ElinorW committed May 21, 2024
1 parent 07ceaa4 commit 77cba1e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
27 changes: 14 additions & 13 deletions vscode/microsoft-kiota/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as path from 'path';
import * as fs from 'fs';
import { OpenApiTreeNode, OpenApiTreeProvider } from "./openApiTreeProvider";
import {
ClientOrPluginProperties,
ConsumerOperation,
generationLanguageToString,
getLogEntriesForLevel,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
25 changes: 24 additions & 1 deletion vscode/microsoft-kiota/src/kiotaInterop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,27 @@ export interface GenerationConfiguration {
usesBackingStore: boolean;
pluginTypes: KiotaPluginType[];
operation: ConsumerOperation;
}
}

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;

0 comments on commit 77cba1e

Please sign in to comment.