Skip to content

Commit

Permalink
chore: use max api version from connection
Browse files Browse the repository at this point in the history
  • Loading branch information
CristiCanizales committed Jan 17, 2025
1 parent 7e27550 commit 7db4e7b
Showing 1 changed file with 2 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { AuthFields, AuthInfo } from '@salesforce/core-bundle';
import { ConfigUtil, notificationService, workspaceUtils } from '@salesforce/salesforcedx-utils-vscode';
import { notificationService, WorkspaceContextUtil, workspaceUtils } from '@salesforce/salesforcedx-utils-vscode';
import { RegistryAccess } from '@salesforce/source-deploy-retrieve-bundle';
import { XMLBuilder, XMLParser } from 'fast-xml-parser';
import * as fs from 'fs';
Expand Down Expand Up @@ -245,7 +244,7 @@ export class ApexActionController {
const baseName = path.basename(fullPath).split('.')[0];
const safeOasSpec = oasSpec.replaceAll('"', ''').replaceAll('type: Id', 'type: string');
const { description, version } = this.extractInfoProperties(safeOasSpec);
const orgVersion = await this.getOrgVersion();
const orgVersion = await (await WorkspaceContextUtil.getInstance().getConnection()).retrieveMaxApiVersion();
if (!orgVersion) {
throw new Error(nls.localize('error_retrieving_org_version'));
}
Expand Down Expand Up @@ -299,23 +298,6 @@ export class ApexActionController {
return builder.build(jsonObj);
};

private getOrgVersion = async (): Promise<string | undefined> => {
const username = await ConfigUtil.getUsername();
if (!username) {
throw new Error(nls.localize('error_retrieving_target_org'));
}
const authFields = await this.getAuthFieldsFor(username);
return authFields.instanceApiVersion;
};

private getAuthFieldsFor = async (username: string): Promise<AuthFields> => {
const authInfo: AuthInfo = await AuthInfo.create({
username
});

return authInfo.getFields();
};

private isVersionGte = (version: string, targetVersion: string): boolean => {
const major = parseInt(version.split('.')[0], 10);
const targetMajor = parseInt(targetVersion.split('.')[0], 10);
Expand Down

0 comments on commit 7db4e7b

Please sign in to comment.