@salesforce/core 3.7.9 → 3.8.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [3.8.0](https://github.com/forcedotcom/sfdx-core/compare/v3.7.9...v3.8.0) (2022-03-09)
6
+
7
+ ### Features
8
+
9
+ - add handle side effect function to authinfo ([64c78e7](https://github.com/forcedotcom/sfdx-core/commit/64c78e74bc5e1cfb748fd2d64e4b1e8fc1062bf6))
10
+
5
11
  ### [3.7.9](https://github.com/forcedotcom/sfdx-core/compare/v3.7.8...v3.7.9) (2022-03-04)
6
12
 
7
13
  ### Bug Fixes
package/lib/exported.d.ts CHANGED
@@ -7,7 +7,7 @@ export { DeviceOauthService, DeviceCodeResponse, DeviceCodePollingResponse } fro
7
7
  export { OrgUsersConfig } from './config/orgUsersConfig';
8
8
  export { ConfigPropertyMeta, ConfigPropertyMetaInput, Config, SfdxPropertyKeys, SFDX_ALLOWED_PROPERTIES, } from './config/config';
9
9
  export { ConfigInfo, ConfigAggregator } from './config/configAggregator';
10
- export { AuthFields, AuthInfo, OrgAuthorization } from './org/authInfo';
10
+ export { AuthFields, AuthInfo, AuthSideEffects, OrgAuthorization } from './org/authInfo';
11
11
  export { AuthRemover } from './org/authRemover';
12
12
  export { Connection, SFDX_HTTP_HEADERS } from './org/connection';
13
13
  export { Mode, Global } from './global';
@@ -59,6 +59,11 @@ export interface AccessTokenOptions {
59
59
  loginUrl?: string;
60
60
  instanceUrl?: string;
61
61
  }
62
+ export declare type AuthSideEffects = {
63
+ alias: string;
64
+ setDefault: boolean;
65
+ setDefaultDevHub: boolean;
66
+ };
62
67
  /**
63
68
  * A function to update a refresh token when the access token is expired.
64
69
  */
@@ -225,6 +230,14 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
225
230
  * **See** [SFDX Authorization](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_auth.htm#cli_reference_force_auth)
226
231
  */
227
232
  getSfdxAuthUrl(): string;
233
+ /**
234
+ * Convenience function to handle typical side effects encountered when dealing with an AuthInfo.
235
+ * Given the values supplied in parameter sideEffects, this functions will set auth alias, default auth
236
+ * and default dev hub.
237
+ *
238
+ * @param sideEffects - instance of AuthSideEffects
239
+ */
240
+ handleAliasAndDefaultSettings(sideEffects: AuthSideEffects): Promise<void>;
228
241
  /**
229
242
  * Set the target-env (default) or the target-dev-hub to the alias if
230
243
  * it exists otherwise to the username. Method will try to set the local
@@ -398,6 +398,22 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
398
398
  sfdxAuthUrl += `${(0, ts_types_1.ensure)(decryptedFields.refreshToken, 'undefined refreshToken')}@${instanceUrl}`;
399
399
  return sfdxAuthUrl;
400
400
  }
401
+ /**
402
+ * Convenience function to handle typical side effects encountered when dealing with an AuthInfo.
403
+ * Given the values supplied in parameter sideEffects, this functions will set auth alias, default auth
404
+ * and default dev hub.
405
+ *
406
+ * @param sideEffects - instance of AuthSideEffects
407
+ */
408
+ async handleAliasAndDefaultSettings(sideEffects) {
409
+ if (sideEffects.alias)
410
+ await this.setAlias(sideEffects.alias);
411
+ if (sideEffects.setDefault)
412
+ await this.setAsDefault({ org: true });
413
+ if (sideEffects.setDefaultDevHub)
414
+ await this.setAsDefault({ devHub: true });
415
+ await this.save();
416
+ }
401
417
  /**
402
418
  * Set the target-env (default) or the target-dev-hub to the alias if
403
419
  * it exists otherwise to the username. Method will try to set the local
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "3.7.9",
3
+ "version": "3.8.0",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",