@salesforce/core 6.7.7-qa.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -647,22 +647,22 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
647
647
  // If options were passed, use those before checking cache and reading an auth file.
648
648
  let authConfig;
649
649
  if (options) {
650
- const clonedOptions = structuredClone(options);
651
- if (this.isTokenOptions(clonedOptions)) {
652
- authConfig = clonedOptions;
653
- const userInfo = await this.retrieveUserInfo((0, ts_types_1.ensureString)(clonedOptions.instanceUrl), (0, ts_types_1.ensureString)(clonedOptions.accessToken));
650
+ options = structuredClone(options);
651
+ if (this.isTokenOptions(options)) {
652
+ authConfig = options;
653
+ const userInfo = await this.retrieveUserInfo((0, ts_types_1.ensureString)(options.instanceUrl), (0, ts_types_1.ensureString)(options.accessToken));
654
654
  this.update({ username: userInfo?.username, orgId: userInfo?.organizationId });
655
655
  }
656
656
  else {
657
657
  if (this.options.parentUsername) {
658
658
  const parentFields = await this.loadDecryptedAuthFromConfig(this.options.parentUsername);
659
- clonedOptions.clientId = parentFields.clientId;
659
+ options.clientId = parentFields.clientId;
660
660
  if (process.env.SFDX_CLIENT_SECRET) {
661
- clonedOptions.clientSecret = process.env.SFDX_CLIENT_SECRET;
661
+ options.clientSecret = process.env.SFDX_CLIENT_SECRET;
662
662
  }
663
663
  else {
664
664
  // Grab whatever flow is defined
665
- Object.assign(clonedOptions, {
665
+ Object.assign(options, {
666
666
  clientSecret: parentFields.clientSecret,
667
667
  privateKey: parentFields.privateKey ? (0, node_path_1.resolve)(parentFields.privateKey) : parentFields.privateKey,
668
668
  });
@@ -670,22 +670,22 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
670
670
  }
671
671
  // jwt flow
672
672
  // Support both sfdx and jsforce private key values
673
- if (!clonedOptions.privateKey && clonedOptions.privateKeyFile) {
674
- clonedOptions.privateKey = (0, node_path_1.resolve)(clonedOptions.privateKeyFile);
673
+ if (!options.privateKey && options.privateKeyFile) {
674
+ options.privateKey = (0, node_path_1.resolve)(options.privateKeyFile);
675
675
  }
676
- if (clonedOptions.privateKey) {
677
- authConfig = await this.authJwt(clonedOptions);
676
+ if (options.privateKey) {
677
+ authConfig = await this.authJwt(options);
678
678
  }
679
- else if (!clonedOptions.authCode && clonedOptions.refreshToken) {
679
+ else if (!options.authCode && options.refreshToken) {
680
680
  // refresh token flow (from sfdxUrl or OAuth refreshFn)
681
- authConfig = await this.buildRefreshTokenConfig(clonedOptions);
681
+ authConfig = await this.buildRefreshTokenConfig(options);
682
682
  }
683
683
  else if (this.options.oauth2 instanceof jsforce_node_1.OAuth2) {
684
684
  // authcode exchange / web auth flow
685
- authConfig = await this.exchangeToken(clonedOptions, this.options.oauth2);
685
+ authConfig = await this.exchangeToken(options, this.options.oauth2);
686
686
  }
687
687
  else {
688
- authConfig = await this.exchangeToken(clonedOptions);
688
+ authConfig = await this.exchangeToken(options);
689
689
  }
690
690
  }
691
691
  authConfig.isDevHub = await this.determineIfDevHub((0, ts_types_1.ensureString)(authConfig.instanceUrl), (0, ts_types_1.ensureString)(authConfig.accessToken));
package/lib/sfError.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AnyJson, JsonMap } from '@salesforce/ts-types';
1
+ import { AnyJson } from '@salesforce/ts-types';
2
2
  export type SfErrorOptions<T extends ErrorDataProperties = ErrorDataProperties> = {
3
3
  message: string;
4
4
  exitCode?: number;
@@ -10,6 +10,14 @@ export type SfErrorOptions<T extends ErrorDataProperties = ErrorDataProperties>
10
10
  actions?: string[];
11
11
  };
12
12
  type ErrorDataProperties = AnyJson;
13
+ type SfErrorToObjectResult = {
14
+ name: string;
15
+ message: string;
16
+ exitCode: number;
17
+ actions?: string[];
18
+ context?: string;
19
+ data?: ErrorDataProperties;
20
+ };
13
21
  /**
14
22
  * A generalized sfdx error which also contains an action. The action is used in the
15
23
  * CLI to help guide users past the error.
@@ -77,6 +85,6 @@ export declare class SfError<T extends ErrorDataProperties = ErrorDataProperties
77
85
  /**
78
86
  * Convert an {@link SfError} state to an object. Returns a plain object representing the state of this error.
79
87
  */
80
- toObject(): JsonMap;
88
+ toObject(): SfErrorToObjectResult;
81
89
  }
82
90
  export {};
package/lib/sfError.js CHANGED
@@ -60,7 +60,9 @@ class SfError extends Error {
60
60
  super(message);
61
61
  this.name = name;
62
62
  this.cause = exitCodeOrCause instanceof Error ? exitCodeOrCause : cause;
63
- this.actions = actions;
63
+ if (actions?.length) {
64
+ this.actions = actions;
65
+ }
64
66
  if (typeof exitCodeOrCause === 'number') {
65
67
  this.exitCode = exitCodeOrCause;
66
68
  }
@@ -77,8 +79,12 @@ class SfError extends Error {
77
79
  /** like the constructor, but takes an typed object and let you also set context and data properties */
78
80
  static create(inputs) {
79
81
  const error = new SfError(inputs.message, inputs.name, inputs.actions, inputs.exitCode, inputs.cause);
80
- error.data = inputs.data;
81
- error.context = inputs.context;
82
+ if (inputs.data) {
83
+ error.data = inputs.data;
84
+ }
85
+ if (inputs.context) {
86
+ error.context = inputs.context;
87
+ }
82
88
  return error;
83
89
  }
84
90
  /**
@@ -134,7 +140,7 @@ class SfError extends Error {
134
140
  name: this.name,
135
141
  message: this.message ?? this.name,
136
142
  exitCode: this.exitCode,
137
- actions: this.actions,
143
+ ...(this.actions?.length ? { actions: this.actions } : {}),
138
144
  ...(this.context ? { context: this.context } : {}),
139
145
  ...(this.data ? { data: this.data } : {}),
140
146
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "6.7.7-qa.1",
3
+ "version": "7.0.0",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",