@salesforce/core 6.2.2 → 6.2.3-qa.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/lib/org/org.d.ts CHANGED
@@ -284,7 +284,14 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
284
284
  * Some organization information is locally cached, such as if the org name or if it is a scratch org.
285
285
  * This method populates/updates the filesystem from information retrieved from the org.
286
286
  */
287
- updateLocalInformation(): Promise<void>;
287
+ updateLocalInformation(): Promise<{
288
+ name: string;
289
+ instanceName: string;
290
+ namespacePrefix: string | null;
291
+ isSandbox: boolean;
292
+ isScratch: boolean;
293
+ trailExpirationDate: string | null;
294
+ } | undefined>;
288
295
  /**
289
296
  * Refreshes the auth for this org's instance by calling HTTP GET on the baseUrl of the connection object.
290
297
  */
@@ -546,7 +553,7 @@ export declare namespace Org {
546
553
  */
547
554
  IS_SCRATCH = "isScratch",
548
555
  /**
549
- * Is the current org a dev hub org. e.g. Organization has IsSandbox == true and TrialExpirationDate == null.
556
+ * Is the current org a sandbox (not a scratch org on a non-prod instance), but an actual Sandbox org). e.g. Organization has IsSandbox == true and TrialExpirationDate == null.
550
557
  */
551
558
  IS_SANDBOX = "isSandbox",
552
559
  /**
package/lib/org/org.js CHANGED
@@ -484,12 +484,12 @@ class Org extends kit_1.AsyncOptionalCreatable {
484
484
  * using {@link Org.retrieveOrganizationInformation}.
485
485
  */
486
486
  async determineIfScratch() {
487
- let cache = this.getField(Org.Fields.IS_SCRATCH);
488
- if (!cache) {
489
- await this.updateLocalInformation();
490
- cache = this.getField(Org.Fields.IS_SCRATCH);
487
+ const cache = this.getField(Org.Fields.IS_SCRATCH);
488
+ if (cache !== undefined) {
489
+ return cache;
491
490
  }
492
- return cache;
491
+ const updated = await this.updateLocalInformation();
492
+ return updated?.isScratch === true;
493
493
  }
494
494
  /**
495
495
  * Returns `true` if the org is a sandbox.
@@ -499,12 +499,12 @@ class Org extends kit_1.AsyncOptionalCreatable {
499
499
  * using {@link Org.retrieveOrganizationInformation}.
500
500
  */
501
501
  async determineIfSandbox() {
502
- let cache = this.getField(Org.Fields.IS_SANDBOX);
503
- if (!cache) {
504
- await this.updateLocalInformation();
505
- cache = this.getField(Org.Fields.IS_SANDBOX);
502
+ const cache = this.getField(Org.Fields.IS_SANDBOX);
503
+ if (cache !== undefined) {
504
+ return cache;
506
505
  }
507
- return cache;
506
+ const updated = await this.updateLocalInformation();
507
+ return updated?.isSandbox === true;
508
508
  }
509
509
  /**
510
510
  * Retrieve a handful of fields from the Organization table in Salesforce. If this does not have the
@@ -523,18 +523,18 @@ class Org extends kit_1.AsyncOptionalCreatable {
523
523
  const username = this.getUsername();
524
524
  if (username) {
525
525
  const organization = await this.retrieveOrganizationInformation();
526
- const isScratch = organization.IsSandbox && Boolean(organization.TrialExpirationDate);
527
- const isSandbox = organization.IsSandbox && !organization.TrialExpirationDate;
528
- const stateAggregator = await stateAggregator_1.StateAggregator.getInstance();
529
- stateAggregator.orgs.update(username, {
526
+ const updateFields = {
530
527
  [Org.Fields.NAME]: organization.Name,
531
528
  [Org.Fields.INSTANCE_NAME]: organization.InstanceName,
532
529
  [Org.Fields.NAMESPACE_PREFIX]: organization.NamespacePrefix,
533
- [Org.Fields.IS_SANDBOX]: isSandbox,
534
- [Org.Fields.IS_SCRATCH]: isScratch,
530
+ [Org.Fields.IS_SANDBOX]: organization.IsSandbox && Boolean(organization.TrialExpirationDate),
531
+ [Org.Fields.IS_SCRATCH]: organization.IsSandbox && !organization.TrialExpirationDate,
535
532
  [Org.Fields.TRIAL_EXPIRATION_DATE]: organization.TrialExpirationDate,
536
- });
533
+ };
534
+ const stateAggregator = await stateAggregator_1.StateAggregator.getInstance();
535
+ stateAggregator.orgs.update(username, updateFields);
537
536
  await stateAggregator.orgs.write(username);
537
+ return updateFields;
538
538
  }
539
539
  }
540
540
  /**
@@ -698,11 +698,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
698
698
  * Returns a map of requested fields.
699
699
  */
700
700
  getFields(keys) {
701
- const json = {};
702
- return keys.reduce((map, key) => {
703
- map[key] = this.getField(key);
704
- return map;
705
- }, json);
701
+ return Object.fromEntries(keys.map((key) => [key, this.getField(key)]));
706
702
  }
707
703
  /**
708
704
  * Returns the JSForce connection for the org.
@@ -1294,7 +1290,7 @@ exports.Org = Org;
1294
1290
  */
1295
1291
  Fields["IS_SCRATCH"] = "isScratch";
1296
1292
  /**
1297
- * Is the current org a dev hub org. e.g. Organization has IsSandbox == true and TrialExpirationDate == null.
1293
+ * Is the current org a sandbox (not a scratch org on a non-prod instance), but an actual Sandbox org). e.g. Organization has IsSandbox == true and TrialExpirationDate == null.
1298
1294
  */
1299
1295
  Fields["IS_SANDBOX"] = "isSandbox";
1300
1296
  /**
@@ -181,7 +181,11 @@ const authorizeScratchOrg = async (options) => {
181
181
  clientId: scratchOrgInfoComplete.ConnectedAppConsumerKey,
182
182
  createdOrgInstance: scratchOrgInfoComplete.SignupInstance,
183
183
  isDevHub: false,
184
- snapshot: scratchOrgInfoComplete.Snapshot,
184
+ isScratch: true,
185
+ isSandbox: false,
186
+ // omit optional fields unless they are present
187
+ ...(scratchOrgInfoComplete.Namespace ? { namespacePrefix: scratchOrgInfoComplete.Namespace } : {}),
188
+ ...(scratchOrgInfoComplete.Snapshot ? { snapshot: scratchOrgInfoComplete.Snapshot } : {}),
185
189
  });
186
190
  return authInfo;
187
191
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "6.2.2",
3
+ "version": "6.2.3-qa.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",