@salesforce/core 3.7.3 → 3.7.4

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/logger.js CHANGED
@@ -204,7 +204,7 @@ class Logger {
204
204
  */
205
205
  static getLevelByName(levelName) {
206
206
  levelName = levelName.toUpperCase();
207
- if (!ts_types_1.isKeyOf(LoggerLevel, levelName)) {
207
+ if (!(0, ts_types_1.isKeyOf)(LoggerLevel, levelName)) {
208
208
  throw new sfdxError_1.SfdxError(`Invalid log level "${levelName}".`, 'UnrecognizedLoggerLevelNameError');
209
209
  }
210
210
  return LoggerLevel[levelName];
@@ -434,7 +434,7 @@ class Logger {
434
434
  }
435
435
  // close file streams, flush buffer to disk
436
436
  // eslint-disable-next-line @typescript-eslint/unbound-method
437
- if (entry.type === 'file' && entry.stream && ts_types_1.isFunction(entry.stream.end)) {
437
+ if (entry.type === 'file' && entry.stream && (0, ts_types_1.isFunction)(entry.stream.end)) {
438
438
  entry.stream.end();
439
439
  }
440
440
  });
@@ -501,7 +501,7 @@ class Logger {
501
501
  debugCallback(cb) {
502
502
  if (this.getLevel() === LoggerLevel.DEBUG || process.env.DEBUG) {
503
503
  const result = cb();
504
- if (ts_types_1.isArray(result)) {
504
+ if ((0, ts_types_1.isArray)(result)) {
505
505
  this.bunyan.debug(this.applyFilters(LoggerLevel.DEBUG, ...result));
506
506
  }
507
507
  else {
@@ -562,18 +562,18 @@ class Logger {
562
562
  stream: new stream_1.Writable({
563
563
  write: (chunk, encoding, next) => {
564
564
  try {
565
- const json = kit_1.parseJsonMap(chunk.toString());
566
- const logLevel = ts_types_1.ensureNumber(json.level);
565
+ const json = (0, kit_1.parseJsonMap)(chunk.toString());
566
+ const logLevel = (0, ts_types_1.ensureNumber)(json.level);
567
567
  if (this.getLevel() <= logLevel) {
568
568
  let debuggerName = 'core';
569
- if (ts_types_1.isString(json.log)) {
569
+ if ((0, ts_types_1.isString)(json.log)) {
570
570
  debuggerName = json.log;
571
571
  if (!debuggers[debuggerName]) {
572
572
  debuggers[debuggerName] = Debug(`${this.getName()}:${debuggerName}`);
573
573
  }
574
574
  }
575
575
  const level = LoggerLevel[logLevel];
576
- ts_types_1.ensure(debuggers[debuggerName])(`${level} ${json.msg}`);
576
+ (0, ts_types_1.ensure)(debuggers[debuggerName])(`${level} ${json.msg}`);
577
577
  }
578
578
  }
579
579
  catch (err) {
@@ -665,7 +665,7 @@ const FILTERED_KEYS = [
665
665
  // SFDX code and plugins should never show tokens or connect app information in the logs
666
666
  const _filter = (...args) => {
667
667
  return args.map((arg) => {
668
- if (ts_types_1.isArray(arg)) {
668
+ if ((0, ts_types_1.isArray)(arg)) {
669
669
  return _filter(...arg);
670
670
  }
671
671
  if (arg) {
@@ -674,10 +674,10 @@ const _filter = (...args) => {
674
674
  if (arg instanceof Buffer) {
675
675
  _arg = '<Buffer>';
676
676
  }
677
- else if (ts_types_1.isObject(arg)) {
677
+ else if ((0, ts_types_1.isObject)(arg)) {
678
678
  _arg = JSON.stringify(arg);
679
679
  }
680
- else if (ts_types_1.isString(arg)) {
680
+ else if ((0, ts_types_1.isString)(arg)) {
681
681
  _arg = arg;
682
682
  }
683
683
  else {
@@ -688,7 +688,7 @@ const _filter = (...args) => {
688
688
  let expElement = key;
689
689
  let expName = key;
690
690
  // Filtered keys can be strings or objects containing regular expression components.
691
- if (ts_types_1.isPlainObject(key)) {
691
+ if ((0, ts_types_1.isPlainObject)(key)) {
692
692
  expElement = key.regex;
693
693
  expName = key.name;
694
694
  }
@@ -702,7 +702,7 @@ const _filter = (...args) => {
702
702
  });
703
703
  _arg = _arg.replace(/(00D\w{12,15})![.\w]*/, `<${HIDDEN}>`);
704
704
  // return an object if an object was logged; otherwise return the filtered string.
705
- return ts_types_1.isObject(arg) ? kit_1.parseJson(_arg) : _arg;
705
+ return (0, ts_types_1.isObject)(arg) ? (0, kit_1.parseJson)(_arg) : _arg;
706
706
  }
707
707
  else {
708
708
  return arg;
package/lib/messages.js CHANGED
@@ -67,16 +67,17 @@ const jsAndJsonLoader = (filePath, fileContents) => {
67
67
  let json;
68
68
  try {
69
69
  json = JSON.parse(fileContents);
70
- if (!ts_types_1.isObject(json)) {
70
+ if (!(0, ts_types_1.isObject)(json)) {
71
71
  // Bubble up
72
72
  throw new Error(`Unexpected token. Found returned content type '${typeof json}'.`);
73
73
  }
74
74
  }
75
75
  catch (err) {
76
76
  // Provide a nicer error message for a common JSON parse error; Unexpected token
77
- if (err.message.startsWith('Unexpected token')) {
78
- const parseError = new Error(`Invalid JSON content in message file: ${filePath}\n${err.message}`);
79
- parseError.name = err.name;
77
+ const error = err;
78
+ if (error.message.startsWith('Unexpected token')) {
79
+ const parseError = new Error(`Invalid JSON content in message file: ${filePath}\n${error.message}`);
80
+ parseError.name = error.name;
80
81
  throw parseError;
81
82
  }
82
83
  throw err;
@@ -275,7 +276,7 @@ class Messages {
275
276
  if (!packageName) {
276
277
  const errMessage = `Invalid or missing package.json file at '${moduleMessagesDirPath}'. If not using a package.json, pass in a packageName.`;
277
278
  try {
278
- packageName = ts_types_1.asString(ts_types_1.ensureJsonMap(Messages.readFile(path.join(moduleMessagesDirPath, 'package.json'))).name);
279
+ packageName = (0, ts_types_1.asString)((0, ts_types_1.ensureJsonMap)(Messages.readFile(path.join(moduleMessagesDirPath, 'package.json'))).name);
279
280
  if (!packageName) {
280
281
  throw new kit_1.NamedError('MissingPackageName', errMessage);
281
282
  }
@@ -446,7 +447,7 @@ class Messages {
446
447
  // 'myMessageError' -> `MyMessageError`
447
448
  // 'error.myMessage' -> `MyMessageError`
448
449
  // 'errors.myMessage' -> `MyMessageError`
449
- const errName = `${kit_1.upperFirst(key.replace(/^errors*\./, ''))}${/Error$/.exec(key) ? '' : 'Error'}`;
450
+ const errName = `${(0, kit_1.upperFirst)(key.replace(/^errors*\./, ''))}${/Error$/.exec(key) ? '' : 'Error'}`;
450
451
  const errMessage = this.getMessage(key, tokens);
451
452
  let errActions;
452
453
  try {
@@ -464,7 +465,7 @@ class Messages {
464
465
  const parentKey = group[1];
465
466
  const childKey = group[2];
466
467
  const childObject = map.get(parentKey);
467
- if (childObject && ts_types_1.isJsonMap(childObject)) {
468
+ if (childObject && (0, ts_types_1.isJsonMap)(childObject)) {
468
469
  const childMap = new Map(Object.entries(childObject));
469
470
  return this.getMessageWithMap(childKey, tokens, childMap);
470
471
  }
@@ -474,9 +475,9 @@ class Messages {
474
475
  throw new kit_1.NamedError('MissingMessageError', `Missing message ${this.bundleName}:${key} for locale ${Messages.getLocale()}.`);
475
476
  }
476
477
  const msg = map.get(key);
477
- const messages = (ts_types_1.isArray(msg) ? msg : [msg]);
478
+ const messages = ((0, ts_types_1.isArray)(msg) ? msg : [msg]);
478
479
  return messages.map((message) => {
479
- ts_types_1.ensureString(message);
480
+ (0, ts_types_1.ensureString)(message);
480
481
  return util.format(message, ...tokens);
481
482
  });
482
483
  }
@@ -149,7 +149,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
149
149
  const orgs = Object.values(globalInfo.orgs.getAll());
150
150
  const final = [];
151
151
  for (const org of orgs) {
152
- const username = ts_types_1.ensureString(org.username);
152
+ const username = (0, ts_types_1.ensureString)(org.username);
153
153
  const aliases = (_a = globalInfo.aliases.getAll(username)) !== null && _a !== void 0 ? _a : undefined;
154
154
  // Get a list of configuration values that are set to either the username or one
155
155
  // of the aliases
@@ -170,7 +170,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
170
170
  accessToken: authInfo.getConnectionOptions().accessToken,
171
171
  oauthMethod: authInfo.isJwt() ? 'jwt' : authInfo.isOauth() ? 'web' : 'token',
172
172
  isExpired: Boolean(devHubUsername) && expirationDate
173
- ? new Date(ts_types_1.ensureString(expirationDate)).getTime() < new Date().getTime()
173
+ ? new Date((0, ts_types_1.ensureString)(expirationDate)).getTime() < new Date().getTime()
174
174
  : 'unknown',
175
175
  });
176
176
  }
@@ -196,13 +196,14 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
196
196
  static async hasAuthentications() {
197
197
  try {
198
198
  const auths = (await globalInfo_1.GlobalInfo.getInstance()).orgs.getAll();
199
- return !kit_1.isEmpty(auths);
199
+ return !(0, kit_1.isEmpty)(auths);
200
200
  }
201
201
  catch (err) {
202
- if (err.name === 'OrgDataNotAvailableError' || err.code === 'ENOENT') {
202
+ const error = err;
203
+ if (error.name === 'OrgDataNotAvailableError' || error.code === 'ENOENT') {
203
204
  return false;
204
205
  }
205
- throw err;
206
+ throw error;
206
207
  }
207
208
  }
208
209
  /**
@@ -217,7 +218,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
217
218
  // The state parameter allows the redirectUri callback listener to ignore request
218
219
  // that don't contain the state value.
219
220
  const params = {
220
- state: crypto_1.randomBytes(Math.ceil(6)).toString('hex'),
221
+ state: (0, crypto_1.randomBytes)(Math.ceil(6)).toString('hex'),
221
222
  prompt: 'login',
222
223
  // Default connected app is 'refresh_token api web'
223
224
  scope: options.scope || kit_1.env.getString('SFDX_AUTH_SCOPES', 'refresh_token api web'),
@@ -286,7 +287,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
286
287
  */
287
288
  async save(authData) {
288
289
  this.update(authData);
289
- const username = ts_types_1.ensure(this.getUsername());
290
+ const username = (0, ts_types_1.ensure)(this.getUsername());
290
291
  if (sfdc_1.sfdc.matchesAccessToken(username)) {
291
292
  this.logger.debug('Username is an accesstoken. Skip saving authinfo to disk.');
292
293
  return this;
@@ -303,7 +304,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
303
304
  */
304
305
  update(authData) {
305
306
  // todo move into configstore
306
- if (authData && ts_types_1.isPlainObject(authData)) {
307
+ if (authData && (0, ts_types_1.isPlainObject)(authData)) {
307
308
  this.username = authData.username || this.username;
308
309
  const existingFields = this.globalInfo.orgs.get(this.getUsername());
309
310
  const mergedFields = Object.assign({}, existingFields || {}, authData);
@@ -373,8 +374,8 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
373
374
  */
374
375
  getOrgFrontDoorUrl() {
375
376
  const authFields = this.getFields(true);
376
- const base = ts_types_1.ensureString(authFields.instanceUrl).replace(/\/+$/, '');
377
- const accessToken = ts_types_1.ensureString(authFields.accessToken);
377
+ const base = (0, ts_types_1.ensureString)(authFields.instanceUrl).replace(/\/+$/, '');
378
+ const accessToken = (0, ts_types_1.ensureString)(authFields.accessToken);
378
379
  return `${base}/secur/frontdoor.jsp?sid=${accessToken}`;
379
380
  }
380
381
  /**
@@ -390,12 +391,12 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
390
391
  */
391
392
  getSfdxAuthUrl() {
392
393
  const decryptedFields = this.getFields(true);
393
- const instanceUrl = ts_types_1.ensure(decryptedFields.instanceUrl, 'undefined instanceUrl').replace(/^https?:\/\//, '');
394
+ const instanceUrl = (0, ts_types_1.ensure)(decryptedFields.instanceUrl, 'undefined instanceUrl').replace(/^https?:\/\//, '');
394
395
  let sfdxAuthUrl = 'force://';
395
396
  if (decryptedFields.clientId) {
396
397
  sfdxAuthUrl += `${decryptedFields.clientId}:${decryptedFields.clientSecret || ''}:`;
397
398
  }
398
- sfdxAuthUrl += `${ts_types_1.ensure(decryptedFields.refreshToken, 'undefined refreshToken')}@${instanceUrl}`;
399
+ sfdxAuthUrl += `${(0, ts_types_1.ensure)(decryptedFields.refreshToken, 'undefined refreshToken')}@${instanceUrl}`;
399
400
  return sfdxAuthUrl;
400
401
  }
401
402
  /**
@@ -414,7 +415,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
414
415
  catch {
415
416
  config = await config_1.Config.create({ isGlobal: true });
416
417
  }
417
- const username = ts_types_1.ensureString(this.getUsername());
418
+ const username = (0, ts_types_1.ensureString)(this.getUsername());
418
419
  const alias = this.globalInfo.aliases.get(username);
419
420
  const value = alias !== null && alias !== void 0 ? alias : username;
420
421
  if (options.org) {
@@ -453,12 +454,12 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
453
454
  throw messages.createError('authInfoOverwriteError');
454
455
  }
455
456
  }
456
- const oauthUsername = username || ts_types_1.getString(authOptions, 'username');
457
+ const oauthUsername = username || (0, ts_types_1.getString)(authOptions, 'username');
457
458
  if (oauthUsername) {
458
459
  this.username = oauthUsername;
459
460
  } // Else it will be set in initAuthOptions below.
460
461
  // If the username is an access token, use that for auth and don't persist
461
- if (ts_types_1.isString(oauthUsername) && sfdc_1.sfdc.matchesAccessToken(oauthUsername)) {
462
+ if ((0, ts_types_1.isString)(oauthUsername) && sfdc_1.sfdc.matchesAccessToken(oauthUsername)) {
462
463
  // Need to initAuthOptions the logger and authInfoCrypto since we don't call init()
463
464
  this.logger = await logger_1.Logger.child('AuthInfo');
464
465
  const aggregator = await configAggregator_1.ConfigAggregator.create();
@@ -480,7 +481,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
480
481
  }
481
482
  }
482
483
  getInstanceUrl(options, aggregator) {
483
- const instanceUrl = ts_types_1.getString(options, 'instanceUrl') || aggregator.getPropertyValue('instanceUrl');
484
+ const instanceUrl = (0, ts_types_1.getString)(options, 'instanceUrl') || aggregator.getPropertyValue('instanceUrl');
484
485
  return instanceUrl || sfdcUrl_1.SfdcUrl.PRODUCTION;
485
486
  }
486
487
  /**
@@ -497,10 +498,10 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
497
498
  // If options were passed, use those before checking cache and reading an auth file.
498
499
  let authConfig;
499
500
  if (options) {
500
- options = kit_1.cloneJson(options);
501
+ options = (0, kit_1.cloneJson)(options);
501
502
  if (this.isTokenOptions(options)) {
502
503
  authConfig = options;
503
- const userInfo = await this.retrieveUserInfo(ts_types_1.ensureString(options.instanceUrl), ts_types_1.ensureString(options.accessToken));
504
+ const userInfo = await this.retrieveUserInfo((0, ts_types_1.ensureString)(options.instanceUrl), (0, ts_types_1.ensureString)(options.accessToken));
504
505
  this.update({ username: userInfo === null || userInfo === void 0 ? void 0 : userInfo.username, orgId: userInfo === null || userInfo === void 0 ? void 0 : userInfo.organizationId });
505
506
  }
506
507
  else {
@@ -514,14 +515,14 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
514
515
  // Grab whatever flow is defined
515
516
  Object.assign(options, {
516
517
  clientSecret: parentFields.clientSecret,
517
- privateKey: parentFields.privateKey ? path_1.resolve(parentFields.privateKey) : parentFields.privateKey,
518
+ privateKey: parentFields.privateKey ? (0, path_1.resolve)(parentFields.privateKey) : parentFields.privateKey,
518
519
  });
519
520
  }
520
521
  }
521
522
  // jwt flow
522
523
  // Support both sfdx and jsforce private key values
523
524
  if (!options.privateKey && options.privateKeyFile) {
524
- options.privateKey = path_1.resolve(options.privateKeyFile);
525
+ options.privateKey = (0, path_1.resolve)(options.privateKeyFile);
525
526
  }
526
527
  if (options.privateKey) {
527
528
  authConfig = await this.buildJwtConfig(options);
@@ -565,6 +566,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
565
566
  // A callback function for a connection to refresh an access token. This is used
566
567
  // both for a JWT connection and an OAuth connection.
567
568
  async refreshFn(conn, callback) {
569
+ var _a;
568
570
  this.logger.info('Access token has expired. Updating...');
569
571
  try {
570
572
  const fields = this.getFields(true);
@@ -573,19 +575,20 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
573
575
  return await callback(null, fields.accessToken);
574
576
  }
575
577
  catch (err) {
576
- if (err.message && err.message.includes('Data Not Available')) {
578
+ const error = err;
579
+ if ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('Data Not Available')) {
577
580
  // Set cause to keep original stacktrace
578
- return await callback(messages.createError('orgDataNotAvailableError', [this.getUsername()], [], err));
581
+ return await callback(messages.createError('orgDataNotAvailableError', [this.getUsername()], [], error));
579
582
  }
580
- return await callback(err);
583
+ return await callback(error);
581
584
  }
582
585
  }
583
586
  // Build OAuth config for a JWT auth flow
584
587
  async buildJwtConfig(options) {
585
- const privateKeyContents = await fs_1.fs.readFile(ts_types_1.ensure(options.privateKey), 'utf8');
588
+ const privateKeyContents = await fs_1.fs.readFile((0, ts_types_1.ensure)(options.privateKey), 'utf8');
586
589
  const { loginUrl = sfdcUrl_1.SfdcUrl.PRODUCTION } = options;
587
590
  const url = new sfdcUrl_1.SfdcUrl(loginUrl);
588
- const createdOrgInstance = ts_types_1.getString(options, 'createdOrgInstance', '').trim().toLowerCase();
591
+ const createdOrgInstance = (0, ts_types_1.getString)(options, 'createdOrgInstance', '').trim().toLowerCase();
589
592
  const audienceUrl = await url.getJwtAudienceUrl(createdOrgInstance);
590
593
  const jwtToken = jwt.sign({
591
594
  iss: options.clientId,
@@ -598,19 +601,19 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
598
601
  const oauth2 = new JwtOAuth2({ loginUrl: options.loginUrl });
599
602
  let authFieldsBuilder;
600
603
  try {
601
- authFieldsBuilder = ts_types_1.ensureJsonMap(await oauth2.jwtAuthorize(jwtToken));
604
+ authFieldsBuilder = (0, ts_types_1.ensureJsonMap)(await oauth2.jwtAuthorize(jwtToken));
602
605
  }
603
606
  catch (err) {
604
607
  throw messages.createError('jwtAuthError', [err.message]);
605
608
  }
606
609
  const authFields = {
607
- accessToken: ts_types_1.asString(authFieldsBuilder.access_token),
608
- orgId: parseIdUrl(ts_types_1.ensureString(authFieldsBuilder.id)).orgId,
610
+ accessToken: (0, ts_types_1.asString)(authFieldsBuilder.access_token),
611
+ orgId: parseIdUrl((0, ts_types_1.ensureString)(authFieldsBuilder.id)).orgId,
609
612
  loginUrl: options.loginUrl,
610
613
  privateKey: options.privateKey,
611
614
  clientId: options.clientId,
612
615
  };
613
- const instanceUrl = ts_types_1.ensureString(authFieldsBuilder.instance_url);
616
+ const instanceUrl = (0, ts_types_1.ensureString)(authFieldsBuilder.instance_url);
614
617
  const sfdcUrl = new sfdcUrl_1.SfdcUrl(instanceUrl);
615
618
  try {
616
619
  // Check if the url is resolvable. This can fail when my-domains have not been replicated.
@@ -637,7 +640,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
637
640
  const oauth2 = new jsforce_1.OAuth2(options);
638
641
  let authFieldsBuilder;
639
642
  try {
640
- authFieldsBuilder = await oauth2.refreshToken(ts_types_1.ensure(options.refreshToken));
643
+ authFieldsBuilder = await oauth2.refreshToken((0, ts_types_1.ensure)(options.refreshToken));
641
644
  }
642
645
  catch (err) {
643
646
  throw messages.createError('refreshTokenAuthError', [err.message]);
@@ -648,7 +651,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
648
651
  if (!username) {
649
652
  // @ts-ignore
650
653
  const userInfo = await this.retrieveUserInfo(authFieldsBuilder.instance_url, authFieldsBuilder.access_token);
651
- username = ts_types_1.ensureString(userInfo === null || userInfo === void 0 ? void 0 : userInfo.username);
654
+ username = (0, ts_types_1.ensureString)(userInfo === null || userInfo === void 0 ? void 0 : userInfo.username);
652
655
  }
653
656
  return {
654
657
  orgId,
@@ -680,7 +683,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
680
683
  let authFields;
681
684
  try {
682
685
  this.logger.info(`Exchanging auth code for access token using loginUrl: ${options.loginUrl}`);
683
- authFields = await oauth2.requestToken(ts_types_1.ensure(options.authCode));
686
+ authFields = await oauth2.requestToken((0, ts_types_1.ensure)(options.authCode));
684
687
  }
685
688
  catch (err) {
686
689
  throw messages.createError('authCodeExchangeError', [err.message]);
@@ -713,7 +716,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
713
716
  // but we don't want to create circular dependencies or lots of snowflakes
714
717
  // within this file to support it.
715
718
  const apiVersion = 'v51.0'; // hardcoding to v51.0 just for this call is okay.
716
- const instance = ts_types_1.ensure(instanceUrl);
719
+ const instance = (0, ts_types_1.ensure)(instanceUrl);
717
720
  const baseUrl = new sfdcUrl_1.SfdcUrl(instance);
718
721
  const userInfoUrl = `${baseUrl}services/oauth2/userinfo`;
719
722
  const headers = Object.assign({ Authorization: `Bearer ${accessToken}` }, connection_1.SFDX_HTTP_HEADERS);
@@ -724,7 +727,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
724
727
  this.throwUserGetException(response);
725
728
  }
726
729
  else {
727
- const userInfoJson = kit_1.parseJsonMap(response.body);
730
+ const userInfoJson = (0, kit_1.parseJsonMap)(response.body);
728
731
  const url = `${baseUrl}/services/data/${apiVersion}/sobjects/User/${userInfoJson.user_id}`;
729
732
  this.logger.info(`Sending request for User SObject after successful auth code exchange to URL: ${url}`);
730
733
  response = await new transport_1.default().httpRequest({ url, method: 'GET', headers });
@@ -733,7 +736,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
733
736
  }
734
737
  else {
735
738
  // eslint-disable-next-line camelcase
736
- userInfoJson.preferred_username = kit_1.parseJsonMap(response.body).Username;
739
+ userInfoJson.preferred_username = (0, kit_1.parseJsonMap)(response.body).Username;
737
740
  }
738
741
  return { username: userInfoJson.preferred_username, organizationId: userInfoJson.organization_id };
739
742
  }
@@ -751,16 +754,16 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
751
754
  throwUserGetException(response) {
752
755
  var _a;
753
756
  let errorMsg = '';
754
- const bodyAsString = ts_types_1.getString(response, 'body', JSON.stringify({ message: 'UNKNOWN', errorCode: 'UNKNOWN' }));
757
+ const bodyAsString = (0, ts_types_1.getString)(response, 'body', JSON.stringify({ message: 'UNKNOWN', errorCode: 'UNKNOWN' }));
755
758
  try {
756
- const body = kit_1.parseJson(bodyAsString);
757
- if (ts_types_1.isArray(body)) {
759
+ const body = (0, kit_1.parseJson)(bodyAsString);
760
+ if ((0, ts_types_1.isArray)(body)) {
758
761
  errorMsg = body
759
- .map((line) => { var _a; return (_a = ts_types_1.getString(line, 'message')) !== null && _a !== void 0 ? _a : ts_types_1.getString(line, 'errorCode', 'UNKNOWN'); })
762
+ .map((line) => { var _a; return (_a = (0, ts_types_1.getString)(line, 'message')) !== null && _a !== void 0 ? _a : (0, ts_types_1.getString)(line, 'errorCode', 'UNKNOWN'); })
760
763
  .join(os.EOL);
761
764
  }
762
765
  else {
763
- errorMsg = (_a = ts_types_1.getString(body, 'message')) !== null && _a !== void 0 ? _a : ts_types_1.getString(body, 'errorCode', 'UNKNOWN');
766
+ errorMsg = (_a = (0, ts_types_1.getString)(body, 'message')) !== null && _a !== void 0 ? _a : (0, ts_types_1.getString)(body, 'errorCode', 'UNKNOWN');
764
767
  }
765
768
  }
766
769
  catch (err) {
@@ -86,7 +86,7 @@ class Connection extends jsforce_1.Connection {
86
86
  if (!baseOptions.version) {
87
87
  // Set the API version obtained from the config aggregator.
88
88
  const configAggregator = options.configAggregator || (await configAggregator_1.ConfigAggregator.create());
89
- baseOptions.version = ts_types_1.asString(configAggregator.getInfo('apiVersion').value);
89
+ baseOptions.version = (0, ts_types_1.asString)(configAggregator.getInfo('apiVersion').value);
90
90
  }
91
91
  const providedOptions = options.authInfo.getConnectionOptions();
92
92
  // Get connection options from auth info and create a new jsForce connection
@@ -173,7 +173,7 @@ class Connection extends jsforce_1.Connection {
173
173
  * @param options HTTP API request options.
174
174
  */
175
175
  request(request, options) {
176
- const httpRequest = ts_types_1.isString(request) ? { method: 'GET', url: request } : request;
176
+ const httpRequest = (0, ts_types_1.isString)(request) ? { method: 'GET', url: request } : request;
177
177
  httpRequest.headers = Object.assign({}, exports.SFDX_HTTP_HEADERS, httpRequest.headers);
178
178
  this.logger.debug(`request: ${JSON.stringify(httpRequest)}`);
179
179
  // The "as" is a workaround for the jsforce typings.
@@ -226,7 +226,7 @@ class Connection extends jsforce_1.Connection {
226
226
  await this.isResolvable();
227
227
  const versions = await this.request(`${this.instanceUrl}/services/data`);
228
228
  this.logger.debug(`response for org versions: ${versions.map((item) => item.version).join(',')}`);
229
- const max = ts_types_1.ensure(kit_1.maxBy(versions, (version) => version.version));
229
+ const max = (0, ts_types_1.ensure)((0, kit_1.maxBy)(versions, (version) => version.version));
230
230
  return max.version;
231
231
  }
232
232
  /**
@@ -237,11 +237,12 @@ class Connection extends jsforce_1.Connection {
237
237
  this.setApiVersion(await this.retrieveMaxApiVersion());
238
238
  }
239
239
  catch (err) {
240
- if (err.name === exports.DNS_ERROR_NAME) {
241
- throw err; // throws on DNS connection errors
240
+ const error = err;
241
+ if (error.name === exports.DNS_ERROR_NAME) {
242
+ throw error; // throws on DNS connection errors
242
243
  }
243
244
  // Don't fail if we can't use the latest, just use the default
244
- this.logger.warn('Failed to set the latest API version:', err);
245
+ this.logger.warn('Failed to set the latest API version:', error);
245
246
  }
246
247
  }
247
248
  /**
@@ -367,10 +368,10 @@ class Connection extends jsforce_1.Connection {
367
368
  async loadInstanceApiVersion() {
368
369
  const authFileFields = this.options.authInfo.getFields();
369
370
  const lastCheckedDateString = authFileFields.instanceApiVersionLastRetrieved;
370
- let version = ts_types_1.getString(authFileFields, 'instanceApiVersion');
371
+ let version = (0, ts_types_1.getString)(authFileFields, 'instanceApiVersion');
371
372
  let lastChecked;
372
373
  try {
373
- if (lastCheckedDateString && ts_types_1.isString(lastCheckedDateString)) {
374
+ if (lastCheckedDateString && (0, ts_types_1.isString)(lastCheckedDateString)) {
374
375
  lastChecked = Date.parse(lastCheckedDateString);
375
376
  }
376
377
  }
package/lib/org/org.js CHANGED
@@ -124,7 +124,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
124
124
  let dataPath;
125
125
  try {
126
126
  const rootFolder = await config_1.Config.resolveRootFolder(false);
127
- dataPath = path_1.join(rootFolder, global_1.Global.SFDX_STATE_FOLDER, orgDataPath ? orgDataPath : 'orgs');
127
+ dataPath = (0, path_1.join)(rootFolder, global_1.Global.SFDX_STATE_FOLDER, orgDataPath ? orgDataPath : 'orgs');
128
128
  this.logger.debug(`cleaning data for path: ${dataPath}`);
129
129
  }
130
130
  catch (err) {
@@ -193,7 +193,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
193
193
  const DEV_HUB_SOQL = `SELECT CreatedDate,Edition,ExpirationDate FROM ActiveScratchOrg WHERE ScratchOrg='${trimmedId}'`;
194
194
  try {
195
195
  const results = await devHubConnection.query(DEV_HUB_SOQL);
196
- if (ts_types_1.getNumber(results, 'records.length') !== 1) {
196
+ if ((0, ts_types_1.getNumber)(results, 'records.length') !== 1) {
197
197
  throw new sfdxError_1.SfdxError('No results', 'NoResultsError');
198
198
  }
199
199
  }
@@ -213,7 +213,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
213
213
  return this;
214
214
  }
215
215
  else if (this.getField(Org.Fields.DEV_HUB_USERNAME)) {
216
- const devHubUsername = ts_types_1.ensureString(this.getField(Org.Fields.DEV_HUB_USERNAME));
216
+ const devHubUsername = (0, ts_types_1.ensureString)(this.getField(Org.Fields.DEV_HUB_USERNAME));
217
217
  return Org.create({
218
218
  connection: await connection_1.Connection.create({
219
219
  authInfo: await authInfo_1.AuthInfo.create({ username: devHubUsername }),
@@ -230,7 +230,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
230
230
  */
231
231
  isDevHubOrg() {
232
232
  const isDevHub = this.getField(Org.Fields.IS_DEV_HUB);
233
- if (ts_types_1.isBoolean(isDevHub)) {
233
+ if ((0, ts_types_1.isBoolean)(isDevHub)) {
234
234
  return isDevHub;
235
235
  }
236
236
  else {
@@ -279,7 +279,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
279
279
  */
280
280
  async determineIfDevHubOrg(forceServerCheck = false) {
281
281
  const cachedIsDevHub = this.getField(Org.Fields.IS_DEV_HUB);
282
- if (!forceServerCheck && ts_types_1.isBoolean(cachedIsDevHub)) {
282
+ if (!forceServerCheck && (0, ts_types_1.isBoolean)(cachedIsDevHub)) {
283
283
  return cachedIsDevHub;
284
284
  }
285
285
  if (this.isDevHubOrg()) {
@@ -295,7 +295,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
295
295
  catch (err) {
296
296
  /* Not a dev hub */
297
297
  }
298
- const username = ts_types_1.ensure(this.getUsername());
298
+ const username = (0, ts_types_1.ensure)(this.getUsername());
299
299
  const authInfo = await authInfo_1.AuthInfo.create({ username });
300
300
  await authInfo.save({ isDevHub });
301
301
  // Reset the connection with the updated auth file
@@ -311,7 +311,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
311
311
  */
312
312
  isScratch() {
313
313
  const isScratch = this.getField(Org.Fields.IS_SCRATCH);
314
- if (ts_types_1.isBoolean(isScratch)) {
314
+ if ((0, ts_types_1.isBoolean)(isScratch)) {
315
315
  return isScratch;
316
316
  }
317
317
  else {
@@ -397,8 +397,8 @@ class Org extends kit_1.AsyncOptionalCreatable {
397
397
  async readUserAuthFiles() {
398
398
  const config = await this.retrieveOrgUsersConfig();
399
399
  const contents = await config.read();
400
- const thisUsername = ts_types_1.ensure(this.getUsername());
401
- const usernames = ts_types_1.ensureJsonArray(contents.usernames || [thisUsername]);
400
+ const thisUsername = (0, ts_types_1.ensure)(this.getUsername());
401
+ const usernames = (0, ts_types_1.ensureJsonArray)(contents.usernames || [thisUsername]);
402
402
  return Promise.all(usernames.map((username) => {
403
403
  if (username === thisUsername) {
404
404
  return authInfo_1.AuthInfo.create({
@@ -406,7 +406,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
406
406
  });
407
407
  }
408
408
  else {
409
- return authInfo_1.AuthInfo.create({ username: ts_types_1.ensureString(username) });
409
+ return authInfo_1.AuthInfo.create({ username: (0, ts_types_1.ensureString)(username) });
410
410
  }
411
411
  }));
412
412
  }
@@ -431,18 +431,18 @@ class Org extends kit_1.AsyncOptionalCreatable {
431
431
  if (!auth) {
432
432
  throw new sfdxError_1.SfdxError('Missing auth info', 'MissingAuthInfo');
433
433
  }
434
- const authInfo = ts_types_1.isString(auth) ? await authInfo_1.AuthInfo.create({ username: auth }) : auth;
434
+ const authInfo = (0, ts_types_1.isString)(auth) ? await authInfo_1.AuthInfo.create({ username: auth }) : auth;
435
435
  this.logger.debug(`adding username ${authInfo.getFields().username}`);
436
436
  const orgConfig = await this.retrieveOrgUsersConfig();
437
437
  const contents = await orgConfig.read();
438
438
  // TODO: This is kind of screwy because contents values can be `AnyJson | object`...
439
439
  // needs config refactoring to improve
440
440
  const usernames = contents.usernames || [];
441
- if (!ts_types_1.isArray(usernames)) {
441
+ if (!(0, ts_types_1.isArray)(usernames)) {
442
442
  throw new sfdxError_1.SfdxError('Usernames is not an array', 'UnexpectedDataFormat');
443
443
  }
444
444
  let shouldUpdate = false;
445
- const thisUsername = ts_types_1.ensure(this.getUsername());
445
+ const thisUsername = (0, ts_types_1.ensure)(this.getUsername());
446
446
  if (!usernames.includes(thisUsername)) {
447
447
  usernames.push(thisUsername);
448
448
  shouldUpdate = true;
@@ -469,7 +469,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
469
469
  if (!auth) {
470
470
  throw new sfdxError_1.SfdxError('Missing auth info', 'MissingAuthInfoError');
471
471
  }
472
- const authInfo = ts_types_1.isString(auth) ? await authInfo_1.AuthInfo.create({ username: auth }) : auth;
472
+ const authInfo = (0, ts_types_1.isString)(auth) ? await authInfo_1.AuthInfo.create({ username: auth }) : auth;
473
473
  this.logger.debug(`removing username ${authInfo.getFields().username}`);
474
474
  const orgConfig = await this.retrieveOrgUsersConfig();
475
475
  const contents = await orgConfig.read();
@@ -830,6 +830,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
830
830
  * pollInterval: Duration to sleep between poll events, default 30 seconds
831
831
  */
832
832
  async pollStatusAndAuth(options) {
833
+ var _a;
833
834
  const { sandboxProcessObj, retries, shouldPoll, pollInterval } = options;
834
835
  this.logger.debug('PollStatusAndAuth called with SandboxProcessObject%s, retries %s', sandboxProcessObj, retries);
835
836
  const lifecycle = lifecycleEvents_1.Lifecycle.getInstance();
@@ -844,12 +845,13 @@ class Org extends kit_1.AsyncOptionalCreatable {
844
845
  pollFinished = true;
845
846
  }
846
847
  catch (err) {
848
+ const error = err;
847
849
  this.logger.debug('Exception while calling writeSandboxAuthFile %s', err);
848
- if ((err === null || err === void 0 ? void 0 : err.name) === 'JWTAuthError' && (err === null || err === void 0 ? void 0 : err.stack.includes("user hasn't approved"))) {
850
+ if ((error === null || error === void 0 ? void 0 : error.name) === 'JWTAuthError' && ((_a = error === null || error === void 0 ? void 0 : error.stack) === null || _a === void 0 ? void 0 : _a.includes("user hasn't approved"))) {
849
851
  waitingOnAuth = true;
850
852
  }
851
853
  else {
852
- throw sfdxError_1.SfdxError.wrap(err);
854
+ throw sfdxError_1.SfdxError.wrap(error);
853
855
  }
854
856
  }
855
857
  }
@@ -863,7 +865,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
863
865
  retries,
864
866
  waitingOnAuth,
865
867
  }),
866
- await kit_1.sleep(pollInterval),
868
+ await (0, kit_1.sleep)(pollInterval),
867
869
  ]);
868
870
  const polledSandboxProcessObj = await this.querySandboxProcess(sandboxProcessObj.SandboxInfoId);
869
871
  return this.pollStatusAndAuth({
@@ -933,14 +935,15 @@ class Org extends kit_1.AsyncOptionalCreatable {
933
935
  return result;
934
936
  }
935
937
  catch (err) {
938
+ const error = err;
936
939
  // There are cases where the endDate is set before the sandbox has actually completed.
937
940
  // In that case, the sandboxAuth call will throw a specific exception.
938
- if ((err === null || err === void 0 ? void 0 : err.name) === 'INVALID_STATUS') {
939
- this.logger.debug('Error while authenticating the user %s', err === null || err === void 0 ? void 0 : err.toString());
941
+ if ((error === null || error === void 0 ? void 0 : error.name) === 'INVALID_STATUS') {
942
+ this.logger.debug('Error while authenticating the user %s', error === null || error === void 0 ? void 0 : error.toString());
940
943
  }
941
944
  else {
942
945
  // If it fails for any unexpected reason, just pass that through
943
- throw sfdxError_1.SfdxError.wrap(err);
946
+ throw sfdxError_1.SfdxError.wrap(error);
944
947
  }
945
948
  }
946
949
  }