Skip to content

Commit

Permalink
feat!: make AuthInfo.getFields return readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Oct 12, 2023
1 parent 57d56ce commit 41423d6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/org/authInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,10 @@ export class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
* Get the authorization fields.
*
* @param decrypt Decrypt the fields.
*
* Returns a ReadOnly object of the fields. If you need to modify the fields, use AuthInfo.update()
*/
public getFields(decrypt?: boolean): AuthFields {
public getFields(decrypt?: boolean): Readonly<AuthFields> {
return this.stateAggregator.orgs.get(this.username, decrypt) ?? {};
}

Expand Down
3 changes: 1 addition & 2 deletions src/org/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,7 @@ export class User extends AsyncCreatable<User.Options> {
});

// Update the auth info object with created user id.
const newUserAuthFields: AuthFields = newUserAuthInfo.getFields();
newUserAuthFields.userId = refreshTokenSecret.userId;
newUserAuthInfo.update({ userId: refreshTokenSecret.userId });

// Make sure we can connect and if so save the auth info.
await this.describeUserAndSave(newUserAuthInfo);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/org/authInfoTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ describe('AuthInfo', () => {
});

// delete the client secret
delete authInfo.getFields().clientSecret;
authInfo.update({ clientSecret: undefined });
const instanceUrl = testOrg.instanceUrl.replace('https://', '');
expect(authInfo.getSfdxAuthUrl()).to.contain(`force://PlatformCLI::${testOrg.refreshToken}@${instanceUrl}`);
});
Expand Down

4 comments on commit 41423d6

@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: 41423d6 Previous: 57d56ce Ratio
Child logger creation 538580 ops/sec (±0.62%) 531040 ops/sec (±0.44%) 0.99
Logging a string on root logger 522971 ops/sec (±8.70%) 451216 ops/sec (±11.25%) 0.86
Logging an object on root logger 311491 ops/sec (±23.25%) 315458 ops/sec (±14.19%) 1.01
Logging an object with a message on root logger 304568 ops/sec (±15.56%) 233624 ops/sec (±10.88%) 0.77
Logging an object with a redacted prop on root logger 9280 ops/sec (±198.46%) 262983 ops/sec (±14.39%) 28.34
Logging a nested 3-level object on root logger 216510 ops/sec (±21.32%) 3501 ops/sec (±212.85%) 0.01617015380351947

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: 41423d6 Previous: 57d56ce Ratio
Logging an object with a redacted prop on root logger 9280 ops/sec (±198.46%) 262983 ops/sec (±14.39%) 28.34

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: 41423d6 Previous: 57d56ce Ratio
Child logger creation 447672 ops/sec (±5.94%) 469189 ops/sec (±6.36%) 1.05
Logging a string on root logger 696436 ops/sec (±15.93%) 604484 ops/sec (±13.38%) 0.87
Logging an object on root logger 347814 ops/sec (±16.27%) 415660 ops/sec (±15.34%) 1.20
Logging an object with a message on root logger 139842 ops/sec (±25.37%) 261242 ops/sec (±12.69%) 1.87
Logging an object with a redacted prop on root logger 170629 ops/sec (±23.76%) 12185 ops/sec (±186.83%) 0.07141224528069672
Logging a nested 3-level object on root logger 124069 ops/sec (±22.57%) 284729 ops/sec (±7.62%) 2.29

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: 41423d6 Previous: 57d56ce Ratio
Logging a nested 3-level object on root logger 124069 ops/sec (±22.57%) 284729 ops/sec (±7.62%) 2.29

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

Please sign in to comment.