Skip to content

Commit

Permalink
chore: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Sep 29, 2023
1 parent 209aac0 commit 6a78a03
Show file tree
Hide file tree
Showing 2 changed files with 392 additions and 219 deletions.
43 changes: 33 additions & 10 deletions src/org/org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export enum SandboxEvents {
EVENT_RESULT = 'result',
EVENT_AUTH = 'auth',
EVENT_RESUME = 'resume',
EVENT_MULTIPLE_SBX_PROCESSES = 'multipleMatchingSbxProcesses',
}

export interface SandboxUserAuthResponse {
Expand Down Expand Up @@ -246,11 +247,11 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
}

/**
* resume a sandbox creation from a production org
* 'this' needs to be a production org with sandbox licenses available
* Resume a sandbox creation from a production org.
* `this` needs to be a production org with sandbox licenses available.
*
* @param resumeSandboxRequest SandboxRequest options to create the sandbox with
* @param options Wait: The amount of time to wait (default: 30 minutes) before timing out,
* @param options Wait: The amount of time to wait (default: 0 minutes) before timing out,
* Interval: The time interval (default: 30 seconds) between polling
*/
public async resumeSandbox(
Expand All @@ -264,10 +265,23 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
this.logger.debug(resumeSandboxRequest, 'ResumeSandbox called with ResumeSandboxRequest');
let sandboxCreationProgress: SandboxProcessObject;
// seed the sandboxCreationProgress via the resumeSandboxRequest options
if (resumeSandboxRequest.SandboxName) {
sandboxCreationProgress = await this.querySandboxProcessBySandboxName(resumeSandboxRequest.SandboxName);
} else if (resumeSandboxRequest.SandboxProcessObjId) {
if (resumeSandboxRequest.SandboxProcessObjId) {
sandboxCreationProgress = await this.querySandboxProcessById(resumeSandboxRequest.SandboxProcessObjId);
} else if (resumeSandboxRequest.SandboxName) {
try {
// There can be multiple sandbox processes returned when querying by name. Use the most recent
// process and fire a warning event with all processes.
sandboxCreationProgress = await this.querySandboxProcessBySandboxName(resumeSandboxRequest.SandboxName);
} catch (err) {
if (err instanceof SfError && err.name === 'SingleRecordQuery_MultipleRecords' && err.data) {
const sbxProcesses = err.data as SandboxProcessObject[];
// 0 index will always be the most recently created process since the query sorts on created date desc.
sandboxCreationProgress = sbxProcesses[0];
await Lifecycle.getInstance().emit(SandboxEvents.EVENT_MULTIPLE_SBX_PROCESSES, sbxProcesses);
} else {
throw err;
}
}
} else {
throw messages.createError('sandboxNotFound', [
resumeSandboxRequest.SandboxName ?? resumeSandboxRequest.SandboxProcessObjId,
Expand Down Expand Up @@ -1377,10 +1391,19 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
* @private
*/
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 this.connection.singleRecordQuery(queryStr, {
tooling: true,
});
const soql = `SELECT Id, Status, SandboxName, SandboxInfoId, LicenseType, CreatedDate, CopyProgress, SandboxOrganization, SourceId, Description, EndDate FROM SandboxProcess WHERE ${where} ORDER BY CreatedDate DESC`;
const result = (await this.connection.tooling.query<SandboxProcessObject>(soql)).records.filter(
(item) => !item.Status.startsWith('Del')
);
if (result.length === 0) {
throw new SfError(`No record found for ${soql}`, SingleRecordQueryErrors.NoRecords);
}
if (result.length > 1) {
const err = new SfError('The query returned more than 1 record', SingleRecordQueryErrors.MultipleRecords);
err.data = result;
throw err;
}
return result[0];
}
/**
* determines if the sandbox has successfully been created
Expand Down
Loading

4 comments on commit 6a78a03

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - ubuntu-latest

Benchmark suite Current: 6a78a03 Previous: 813353c Ratio
Child logger creation 536289 ops/sec (±0.69%) 485875 ops/sec (±10.82%) 0.91
Logging a string on root logger 548639 ops/sec (±8.73%) 632052 ops/sec (±9.87%) 1.15
Logging an object on root logger 318573 ops/sec (±17.55%) 485860 ops/sec (±10.36%) 1.53
Logging an object with a message on root logger 261965 ops/sec (±12.20%) 291157 ops/sec (±10.85%) 1.11
Logging an object with a redacted prop on root logger 7558 ops/sec (±201.55%) 23706 ops/sec (±184.76%) 3.14
Logging a nested 3-level object on root logger 199093 ops/sec (±12.72%) 282294 ops/sec (±9.32%) 1.42

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Logger Benchmarks - ubuntu-latest'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 6a78a03 Previous: 813353c Ratio
Logging an object with a redacted prop on root logger 7558 ops/sec (±201.55%) 23706 ops/sec (±184.76%) 3.14

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - windows-latest

Benchmark suite Current: 6a78a03 Previous: 813353c Ratio
Child logger creation 497775 ops/sec (±2.80%) 414569 ops/sec (±15.83%) 0.83
Logging a string on root logger 574859 ops/sec (±14.07%) 731381 ops/sec (±10.03%) 1.27
Logging an object on root logger 372189 ops/sec (±17.86%) 308590 ops/sec (±21.35%) 0.83
Logging an object with a message on root logger 272201 ops/sec (±17.31%) 167468 ops/sec (±23.60%) 0.62
Logging an object with a redacted prop on root logger 236962 ops/sec (±24.17%) 171100 ops/sec (±24.54%) 0.72
Logging a nested 3-level object on root logger 13052 ops/sec (±186.94%) 129025 ops/sec (±23.83%) 9.89

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Logger Benchmarks - windows-latest'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 6a78a03 Previous: 813353c Ratio
Logging a nested 3-level object on root logger 13052 ops/sec (±186.94%) 129025 ops/sec (±23.83%) 9.89

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.