@salesforce/core 4.3.5 → 4.3.6

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.
@@ -192,6 +192,11 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
192
192
  * Find all dev hubs available in the local environment.
193
193
  */
194
194
  static getDevHubAuthInfos(): Promise<OrgAuthorization[]>;
195
+ /**
196
+ * Checks active scratch orgs to match by the ScratchOrg field (the 15-char org id)
197
+ * if you pass an 18-char scratchOrgId, it will be trimmed to 15-char for query purposes
198
+ * Throws is no matching scratch org is found
199
+ */
195
200
  private static queryScratchOrg;
196
201
  /**
197
202
  * Get the username.
@@ -270,11 +270,22 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
270
270
  static async getDevHubAuthInfos() {
271
271
  return AuthInfo.listAllAuthorizations((possibleHub) => possibleHub?.isDevHub ?? false);
272
272
  }
273
+ /**
274
+ * Checks active scratch orgs to match by the ScratchOrg field (the 15-char org id)
275
+ * if you pass an 18-char scratchOrgId, it will be trimmed to 15-char for query purposes
276
+ * Throws is no matching scratch org is found
277
+ */
273
278
  static async queryScratchOrg(devHubUsername, scratchOrgId) {
274
279
  const devHubOrg = await org_1.Org.create({ aliasOrUsername: devHubUsername });
280
+ const trimmedId = (0, sfdc_1.trimTo15)(scratchOrgId);
275
281
  const conn = devHubOrg.getConnection();
276
- const data = await conn.singleRecordQuery(`select Id, ExpirationDate from ScratchOrgInfo where ScratchOrg = '${(0, sfdc_1.trimTo15)(scratchOrgId)}'`);
277
- return data;
282
+ const data = await conn.query(`select Id, ExpirationDate, ScratchOrg from ScratchOrgInfo where ScratchOrg = '${trimmedId}' and Status = 'Active'`);
283
+ // where ScratchOrg='00DDE00000485Lg' will return a record for both 00DDE00000485Lg and 00DDE00000485LG.
284
+ // this is our way of enforcing case sensitivity on a 15-char Id (which is unfortunately how ScratchOrgInfo stores it)
285
+ const result = data.records.filter((r) => r.ScratchOrg === trimmedId)[0];
286
+ if (result)
287
+ return result;
288
+ throw new sfError_1.SfError(`DevHub ${devHubUsername} has no active scratch orgs that match ${trimmedId}`, 'NoActiveScratchOrgFound');
278
289
  }
279
290
  /**
280
291
  * Get the username.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "4.3.5",
3
+ "version": "4.3.6",
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",
@@ -68,8 +68,8 @@
68
68
  "@types/lodash": "^4.14.195",
69
69
  "@types/proper-lockfile": "^4.1.2",
70
70
  "@types/shelljs": "0.8.12",
71
- "@typescript-eslint/eslint-plugin": "^5.59.9",
72
- "@typescript-eslint/parser": "^5.59.11",
71
+ "@typescript-eslint/eslint-plugin": "^5.60.1",
72
+ "@typescript-eslint/parser": "^5.60.1",
73
73
  "benchmark": "^2.1.4",
74
74
  "chai": "^4.3.7",
75
75
  "chai-string": "^1.5.0",