Skip to content

Commit

Permalink
fix: use correct field for clone requests (#623)
Browse files Browse the repository at this point in the history
* fix: use correct field for clone requests

* refactor: return promises
  • Loading branch information
mshanemc authored Jul 26, 2022
1 parent 89722c5 commit 2372f03
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/org/org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export type SandboxProcessObject = {
export type SandboxRequest = {
SandboxName: string;
LicenseType?: string;
/** Should match a SandboxInfoId, not a SandboxProcessId */
SourceId?: string;
Description?: string;
};
Expand Down Expand Up @@ -236,16 +237,16 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
/**
*
* @param sandboxReq SandboxRequest options to create the sandbox with
* @param sandboxName
* @param sourceSandboxName the name of the sandbox that your new sandbox will be based on
* @param options Wait: The amount of time to wait before timing out, defaults to 0, Interval: The time interval between polling defaults to 30 seconds
* @returns {SandboxProcessObject} the newly created sandbox process object
*/
public async cloneSandbox(
sandboxReq: SandboxRequest,
sandboxName: string,
sourceSandboxName: string,
options: { wait?: Duration; interval?: Duration }
): Promise<SandboxProcessObject> {
sandboxReq.SourceId = (await this.querySandboxProcessBySandboxName(sandboxName)).Id;
sandboxReq.SourceId = (await this.querySandboxProcessBySandboxName(sourceSandboxName)).SandboxInfoId;
this.logger.debug('Clone sandbox sourceId %s', sandboxReq.SourceId);
return this.createSandbox(sandboxReq, options);
}
Expand Down Expand Up @@ -368,7 +369,7 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
* @ignore
*/
public async retrieveOrgUsersConfig(): Promise<OrgUsersConfig> {
return await OrgUsersConfig.create(OrgUsersConfig.getOptions(this.getOrgId()));
return OrgUsersConfig.create(OrgUsersConfig.getOptions(this.getOrgId()));
}

/**
Expand Down Expand Up @@ -397,7 +398,7 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
*
*/
public async isSandbox(): Promise<boolean> {
return await (await StateAggregator.getInstance()).sandboxes.hasFile(this.getOrgId());
return (await StateAggregator.getInstance()).sandboxes.hasFile(this.getOrgId());
}
/**
* Check that this org is a scratch org by asking the dev hub if it knows about it.
Expand Down Expand Up @@ -803,7 +804,7 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
* results in a warning.
*/
public async retrieveMaxApiVersion(): Promise<string> {
return await this.getConnection().retrieveMaxApiVersion();
return this.getConnection().retrieveMaxApiVersion();
}

/**
Expand Down Expand Up @@ -881,7 +882,7 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
* @private
*/
public async querySandboxProcessBySandboxName(name: string): Promise<SandboxProcessObject> {
return await this.querySandboxProcess(`SandboxName='${name}'`);
return this.querySandboxProcess(`SandboxName='${name}'`);
}

/**
Expand All @@ -891,7 +892,7 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
* @private
*/
public async querySandboxProcessBySandboxInfoId(id: string): Promise<SandboxProcessObject> {
return await this.querySandboxProcess(`SandboxInfoId='${id}'`);
return this.querySandboxProcess(`SandboxInfoId='${id}'`);
}

/**
Expand All @@ -901,7 +902,7 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
* @private
*/
public async querySandboxProcessById(id: string): Promise<SandboxProcessObject> {
return await this.querySandboxProcess(`Id='${id}'`);
return this.querySandboxProcess(`Id='${id}'`);
}

/**
Expand Down Expand Up @@ -1347,7 +1348,7 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
*/
private async querySandboxProcess(where: string): Promise<SandboxProcessObject> {
const queryStr = `SELECT Id, Status, SandboxName, SandboxInfoId, LicenseType, CreatedDate, CopyProgress, SandboxOrganization, SourceId, Description, EndDate FROM SandboxProcess WHERE ${where} AND Status != 'D'`;
return await this.connection.singleRecordQuery(queryStr, {
return this.connection.singleRecordQuery(queryStr, {
tooling: true,
});
}
Expand Down

0 comments on commit 2372f03

Please sign in to comment.