@salesforce/core 8.32.0 → 8.32.2
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/authInfo.js +5 -1
- package/lib/org/connection.js +5 -3
- package/package.json +1 -1
package/lib/org/authInfo.js
CHANGED
|
@@ -443,6 +443,10 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
443
443
|
*/
|
|
444
444
|
update(authData) {
|
|
445
445
|
if (authData && (0, ts_types_1.isPlainObject)(authData)) {
|
|
446
|
+
if (authData.instanceApiVersion && !(0, sfdc_1.validateApiVersion)(authData.instanceApiVersion)) {
|
|
447
|
+
this.logger.warn(`Ignoring invalid instanceApiVersion "${authData.instanceApiVersion}" (expected format: "XX.0")`);
|
|
448
|
+
authData.instanceApiVersion = undefined;
|
|
449
|
+
}
|
|
446
450
|
this.username = authData.username ?? this.username;
|
|
447
451
|
this.stateAggregator.orgs.update(this.username, authData);
|
|
448
452
|
this.logger.info(`Updated auth info for username: ${this.username}`);
|
|
@@ -1041,7 +1045,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
1041
1045
|
const apiVersion = 'v51.0'; // hardcoding to v51.0 just for this call is okay.
|
|
1042
1046
|
const instance = (0, ts_types_1.ensure)(instanceUrl);
|
|
1043
1047
|
const baseUrl = new sfdcUrl_1.SfdcUrl(instance);
|
|
1044
|
-
const scratchOrgInfoUrl = `${baseUrl.toString()}
|
|
1048
|
+
const scratchOrgInfoUrl = `${baseUrl.toString()}services/data/${apiVersion}/query?q=SELECT%20Id%20FROM%20ScratchOrgInfo%20limit%201`;
|
|
1045
1049
|
const headers = Object.assign({ Authorization: `Bearer ${accessToken}` }, connection_1.SFDX_HTTP_HEADERS);
|
|
1046
1050
|
try {
|
|
1047
1051
|
const res = await new transport_1.default().httpRequest({ url: scratchOrgInfoUrl, method: 'GET', headers });
|
package/lib/org/connection.js
CHANGED
|
@@ -205,8 +205,7 @@ class Connection extends jsforce_node_1.Connection {
|
|
|
205
205
|
if (error.name === exports.DNS_ERROR_NAME) {
|
|
206
206
|
throw error; // throws on DNS connection errors
|
|
207
207
|
}
|
|
208
|
-
|
|
209
|
-
this.logger.warn('Failed to set the latest API version:', error);
|
|
208
|
+
this.logger.warn(`Failed to set the latest API version (${error.name}: ${error.message}). Using default: v${this.version}`);
|
|
210
209
|
}
|
|
211
210
|
}
|
|
212
211
|
/**
|
|
@@ -382,7 +381,10 @@ class Connection extends jsforce_node_1.Connection {
|
|
|
382
381
|
const has24HoursPastSinceLastCheck = now.getTime() - lastChecked > kit_1.Duration.hours(24).milliseconds;
|
|
383
382
|
this.logger.debug(`API version cache last checked on ${lastCheckedDateString ?? '<undefined>'} (now is ${now.toLocaleString()})`);
|
|
384
383
|
if (!has24HoursPastSinceLastCheck && version) {
|
|
385
|
-
|
|
384
|
+
if (!(0, sfdc_1.validateApiVersion)(version)) {
|
|
385
|
+
this.logger.warn(`Cached instanceApiVersion "${version}" is invalid (expected format: "XX.0"). Ignoring cache and re-fetching.`);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
386
388
|
this.logger.debug(`Using cached API version: ${version}`);
|
|
387
389
|
return version;
|
|
388
390
|
}
|