@salesforce/core 5.0.1-v5-beta.0 → 5.1.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.
@@ -14,7 +14,7 @@ const logger_1 = require("./logger");
14
14
  /**
15
15
  * the odds of running are 1 in CLEAN_ODDS
16
16
  * ex: CLEAN_ODDS=100 implies 1 in 100
17
- * ex: CLEAN_ODDS=100 implies 1 in 1 (run every time)
17
+ * ex: CLEAN_ODDS=1 implies 1 in 1 (run every time)
18
18
  * */
19
19
  const CLEAN_ODDS = 100;
20
20
  const MAX_FILE_AGE_DAYS = 7;
@@ -149,7 +149,7 @@ class Connection extends jsforce_1.Connection {
149
149
  ...exports.SFDX_HTTP_HEADERS,
150
150
  ...lowercasedHeaders,
151
151
  };
152
- this.logger.debug(`request: ${JSON.stringify(httpRequest)}`);
152
+ this.logger.getRawLogger().debug(httpRequest, 'request');
153
153
  return super.request(httpRequest, options);
154
154
  }
155
155
  /**
package/lib/org/org.js CHANGED
@@ -94,14 +94,14 @@ class Org extends kit_1.AsyncOptionalCreatable {
94
94
  async: false,
95
95
  interval: kit_1.Duration.seconds(30),
96
96
  }) {
97
- this.logger.debug(`CreateSandbox called with SandboxRequest: ${JSON.stringify(sandboxReq, undefined, 2)}`);
97
+ this.logger.debug(sandboxReq, 'CreateSandbox called with SandboxRequest');
98
98
  const createResult = await this.connection.tooling.create('SandboxInfo', sandboxReq);
99
- this.logger.debug(`Return from calling tooling.create: ${JSON.stringify(createResult, undefined, 2)}`);
99
+ this.logger.debug(createResult, 'Return from calling tooling.create');
100
100
  if (Array.isArray(createResult) || !createResult.success) {
101
101
  throw messages.createError('sandboxInfoCreateFailed', [JSON.stringify(createResult)]);
102
102
  }
103
103
  const sandboxCreationProgress = await this.querySandboxProcessBySandboxInfoId(createResult.id);
104
- this.logger.debug(`Return from calling singleRecordQuery with tooling: ${JSON.stringify(sandboxCreationProgress, undefined, 2)}`);
104
+ this.logger.debug(sandboxCreationProgress, 'Return from calling singleRecordQuery with tooling');
105
105
  const isAsync = !!options.async;
106
106
  if (isAsync) {
107
107
  // The user didn't want us to poll, so simply return the status
@@ -109,7 +109,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
109
109
  return sandboxCreationProgress;
110
110
  }
111
111
  const [wait, pollInterval] = this.validateWaitOptions(options);
112
- this.logger.debug(`create - pollStatusAndAuth sandboxProcessObj ${JSON.stringify(sandboxCreationProgress, undefined, 2)}, max wait time of ${wait.minutes} minutes`);
112
+ this.logger.debug(sandboxCreationProgress, `create - pollStatusAndAuth sandboxProcessObj, max wait time of ${wait.minutes} minutes`);
113
113
  return this.pollStatusAndAuth({
114
114
  sandboxProcessObj: sandboxCreationProgress,
115
115
  wait,
@@ -125,7 +125,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
125
125
  */
126
126
  async cloneSandbox(sandboxReq, sourceSandboxName, options) {
127
127
  sandboxReq.SourceId = (await this.querySandboxProcessBySandboxName(sourceSandboxName)).SandboxInfoId;
128
- this.logger.debug('Clone sandbox sourceId %s', sandboxReq.SourceId);
128
+ this.logger.debug(`Clone sandbox sourceId ${sandboxReq.SourceId}`);
129
129
  return this.createSandbox(sandboxReq, options);
130
130
  }
131
131
  /**
@@ -141,7 +141,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
141
141
  async: false,
142
142
  interval: kit_1.Duration.seconds(30),
143
143
  }) {
144
- this.logger.debug(`ResumeSandbox called with ResumeSandboxRequest: ${JSON.stringify(resumeSandboxRequest, undefined, 2)}`);
144
+ this.logger.debug(resumeSandboxRequest, 'ResumeSandbox called with ResumeSandboxRequest');
145
145
  let sandboxCreationProgress;
146
146
  // seed the sandboxCreationProgress via the resumeSandboxRequest options
147
147
  if (resumeSandboxRequest.SandboxName) {
@@ -155,7 +155,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
155
155
  resumeSandboxRequest.SandboxName ?? resumeSandboxRequest.SandboxProcessObjId,
156
156
  ]);
157
157
  }
158
- this.logger.debug(`Return from calling singleRecordQuery with tooling: ${JSON.stringify(sandboxCreationProgress, undefined, 2)}`);
158
+ this.logger.debug(sandboxCreationProgress, 'Return from calling singleRecordQuery with tooling');
159
159
  if (!sandboxIsResumable(sandboxCreationProgress.Status)) {
160
160
  throw messages.createError('sandboxNotResumable', [
161
161
  sandboxCreationProgress.SandboxName,
@@ -172,7 +172,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
172
172
  if (sandboxInfo) {
173
173
  await lifecycleEvents_1.Lifecycle.getInstance().emit(SandboxEvents.EVENT_AUTH, sandboxInfo);
174
174
  try {
175
- this.logger.debug(`sandbox signup complete with ${JSON.stringify(sandboxInfo, undefined, 2)}`);
175
+ this.logger.debug(sandboxInfo, 'sandbox signup complete');
176
176
  await this.writeSandboxAuthFile(sandboxCreationProgress, sandboxInfo);
177
177
  return sandboxCreationProgress;
178
178
  }
@@ -184,7 +184,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
184
184
  await lifecycleEvents_1.Lifecycle.getInstance().emit(SandboxEvents.EVENT_ASYNC_RESULT, sandboxCreationProgress);
185
185
  throw messages.createError('sandboxCreateNotComplete');
186
186
  }
187
- this.logger.debug(`resume - pollStatusAndAuth sandboxProcessObj ${JSON.stringify(sandboxCreationProgress, undefined, 2)}, max wait time of ${wait.minutes} minutes`);
187
+ this.logger.debug(sandboxCreationProgress, `resume - pollStatusAndAuth sandboxProcessObj, max wait time of ${wait.minutes} minutes`);
188
188
  return this.pollStatusAndAuth({
189
189
  sandboxProcessObj: sandboxCreationProgress,
190
190
  wait,
@@ -752,7 +752,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
752
752
  */
753
753
  async init() {
754
754
  const stateAggregator = await stateAggregator_1.StateAggregator.getInstance();
755
- this.logger = await logger_1.Logger.child('Org');
755
+ this.logger = (await logger_1.Logger.child('Org')).getRawLogger();
756
756
  this.configAggregator = this.options.aggregator ? this.options.aggregator : await configAggregator_1.ConfigAggregator.create();
757
757
  if (!this.options.connection) {
758
758
  if (this.options.aliasOrUsername == null) {
@@ -809,7 +809,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
809
809
  interval: kit_1.Duration.seconds(30),
810
810
  }) {
811
811
  const [wait, pollInterval] = this.validateWaitOptions(options);
812
- this.logger.debug(`AuthWithRetries sandboxProcessObj ${JSON.stringify(sandboxProcessObj, undefined, 2)}, max wait time of ${wait.minutes} minutes`);
812
+ this.logger.debug(sandboxProcessObj, `AuthWithRetries sandboxProcessObj, max wait time of ${wait.minutes} minutes`);
813
813
  return this.pollStatusAndAuth({
814
814
  sandboxProcessObj,
815
815
  wait,
@@ -824,10 +824,10 @@ class Org extends kit_1.AsyncOptionalCreatable {
824
824
  */
825
825
  async queryLatestSandboxProcessBySandboxName(sandboxNameIn) {
826
826
  const { tooling } = this.getConnection();
827
- this.logger.debug('QueryLatestSandboxProcessBySandboxName called with SandboxName: %s ', sandboxNameIn);
827
+ this.logger.debug(`QueryLatestSandboxProcessBySandboxName called with SandboxName: ${sandboxNameIn}`);
828
828
  const queryStr = `SELECT Id, Status, SandboxName, SandboxInfoId, LicenseType, CreatedDate, CopyProgress, SandboxOrganization, SourceId, Description, EndDate FROM SandboxProcess WHERE SandboxName='${sandboxNameIn}' AND Status != 'D' ORDER BY CreatedDate DESC LIMIT 1`;
829
829
  const queryResult = await tooling.query(queryStr);
830
- this.logger.debug('Return from calling queryToolingApi: %s ', queryResult);
830
+ this.logger.debug(queryResult, 'Return from calling queryToolingApi');
831
831
  if (queryResult?.records?.length === 1) {
832
832
  return queryResult.records[0];
833
833
  }
@@ -898,7 +898,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
898
898
  }
899
899
  if (sandboxInfoId) {
900
900
  const deleteResult = await this.destroySandbox(prodOrg, sandboxInfoId);
901
- this.logger.debug('Return from calling tooling.delete: ', deleteResult);
901
+ this.logger.debug(deleteResult, 'Return from calling tooling.delete');
902
902
  }
903
903
  // cleanup remaining artifacts
904
904
  await this.remove();
@@ -1015,10 +1015,11 @@ class Org extends kit_1.AsyncOptionalCreatable {
1015
1015
  await stateAggregator.sandboxes.remove(this.getOrgId());
1016
1016
  }
1017
1017
  async writeSandboxAuthFile(sandboxProcessObj, sandboxRes) {
1018
- this.logger.debug(`writeSandboxAuthFile sandboxProcessObj: ${JSON.stringify(sandboxProcessObj)}, sandboxRes: ${JSON.stringify(sandboxRes)}`);
1018
+ this.logger.debug(sandboxProcessObj, 'writeSandboxAuthFile sandboxProcessObj');
1019
+ this.logger.debug(sandboxRes, 'writeSandboxAuthFile sandboxRes');
1019
1020
  if (sandboxRes.authUserName) {
1020
1021
  const productionAuthFields = this.connection.getAuthInfoFields();
1021
- this.logger.debug('Result from getAuthInfoFields: AuthFields', productionAuthFields);
1022
+ this.logger.debug(productionAuthFields, 'Result from getAuthInfoFields: AuthFields');
1022
1023
  // let's do headless auth via jwt (if we have privateKey) or web auth
1023
1024
  const oauth2Options = {
1024
1025
  loginUrl: sandboxRes.loginUrl,
@@ -1039,7 +1040,11 @@ class Org extends kit_1.AsyncOptionalCreatable {
1039
1040
  oauth2Options,
1040
1041
  parentUsername: productionAuthFields.username,
1041
1042
  });
1042
- this.logger.debug('Creating AuthInfo for sandbox', sandboxRes.authUserName, productionAuthFields.username, oauth2Options);
1043
+ this.logger.debug({
1044
+ sandboxResAuthUsername: sandboxRes.authUserName,
1045
+ productionAuthFieldsUsername: productionAuthFields.username,
1046
+ ...oauth2Options,
1047
+ }, 'Creating AuthInfo for sandbox');
1043
1048
  // save auth info for new sandbox
1044
1049
  await authInfo.save();
1045
1050
  const sandboxOrgId = authInfo.getFields().orgId;
@@ -1069,7 +1074,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
1069
1074
  }
1070
1075
  }
1071
1076
  async pollStatusAndAuth(options) {
1072
- this.logger.debug('PollStatusAndAuth called with SandboxProcessObject', options.sandboxProcessObj, options.wait.minutes, options.pollInterval.seconds);
1077
+ this.logger.debug(options, 'PollStatusAndAuth called with SandboxProcessObject');
1073
1078
  let remainingWait = options.wait;
1074
1079
  let waitingOnAuth = false;
1075
1080
  const pollingClient = await pollingClient_1.PollingClient.create({
@@ -1080,7 +1085,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
1080
1085
  if (sandboxInfo) {
1081
1086
  await lifecycleEvents_1.Lifecycle.getInstance().emit(SandboxEvents.EVENT_AUTH, sandboxInfo);
1082
1087
  try {
1083
- this.logger.debug('sandbox signup complete with', sandboxInfo);
1088
+ this.logger.debug(sandboxInfo, 'sandbox signup complete with');
1084
1089
  await this.writeSandboxAuthFile(sandboxProcessObj, sandboxInfo);
1085
1090
  return { completed: true, payload: sandboxProcessObj };
1086
1091
  }
@@ -1142,7 +1147,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
1142
1147
  sandboxName: sandboxProcessObj.SandboxName,
1143
1148
  callbackUrl,
1144
1149
  };
1145
- this.logger.debug('Calling sandboxAuth with SandboxUserAuthRequest', sandboxReq);
1150
+ this.logger.debug(sandboxReq, 'Calling sandboxAuth with SandboxUserAuthRequest');
1146
1151
  // eslint-disable-next-line no-underscore-dangle
1147
1152
  const url = `${this.connection.tooling._baseUrl()}/sandboxAuth`;
1148
1153
  const params = {
@@ -1152,7 +1157,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
1152
1157
  body: JSON.stringify(sandboxReq),
1153
1158
  };
1154
1159
  const result = await this.connection.tooling.request(params);
1155
- this.logger.debug('Result of calling sandboxAuth', result);
1160
+ this.logger.debug(result, 'Result of calling sandboxAuth');
1156
1161
  return result;
1157
1162
  }
1158
1163
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "5.0.1-v5-beta.0",
3
+ "version": "5.1.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",
@@ -75,9 +75,9 @@
75
75
  "chai-string": "^1.5.0",
76
76
  "eslint": "^8.44.0",
77
77
  "eslint-config-prettier": "^8.8.0",
78
- "eslint-config-salesforce": "^2.0.1",
78
+ "eslint-config-salesforce": "^2.0.2",
79
79
  "eslint-config-salesforce-license": "^0.2.0",
80
- "eslint-config-salesforce-typescript": "^1.1.1",
80
+ "eslint-config-salesforce-typescript": "^1.1.2",
81
81
  "eslint-plugin-header": "^3.1.1",
82
82
  "eslint-plugin-import": "^2.27.5",
83
83
  "eslint-plugin-jsdoc": "^43.2.0",