Skip to content

Commit

Permalink
feat: call Mulesoft ACD extension with command "mule-dx-api.open-api-…
Browse files Browse the repository at this point in the history
…project" and OAS document vscode URI when new OAS doc created
  • Loading branch information
daphne-sfdc committed Jan 31, 2025
1 parent 6bb329e commit 7331fbd
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,23 @@ export class ApexActionController {
);
}
}

// Step 8: Call Mulesoft extension if installed
if (await this.isCommandAvailable('mule-dx-api.open-api-project')) {
try {
const yamlUri = vscode.Uri.file(this.replaceXmlToYaml(fullPath[1]));
await vscode.commands.executeCommand('mule-dx-api.open-api-project', yamlUri);
console.log('mule-dx-api.open-api-project command executed successfully');
} catch (error) {
telemetryService.sendEventData('mule-dx-api.open-api-project command could not be executed', {
error: error.message
});
console.error('mule-dx-api.open-api-project command could not be executed', error);
}
} else {
telemetryService.sendEventData('mule-dx-api.open-api-project command not found');
console.log('mule-dx-api.open-api-project command not found');
}
}
);

Expand Down Expand Up @@ -503,4 +520,14 @@ export class ApexActionController {
diffWindowName
);
};

/**
* Checks if a VSCode command is available.
* @param commandId Command ID of the VSCode command to check
* @returns boolean - true if the command is available, false otherwise
*/
private isCommandAvailable = async (commandId: string): Promise<boolean> => {
const commands = await vscode.commands.getCommands(true);
return commands.includes(commandId);
};
}

0 comments on commit 7331fbd

Please sign in to comment.