@salesforce/core 3.23.8 → 3.24.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [3.24.1](https://github.com/forcedotcom/sfdx-core/compare/v3.24.0...v3.24.1) (2022-07-21)
6
+
7
+ ### Bug Fixes
8
+
9
+ - bump jsforce ([#622](https://github.com/forcedotcom/sfdx-core/issues/622)) ([c7b53b7](https://github.com/forcedotcom/sfdx-core/commit/c7b53b73977012f81e029a15f39c3fb35bc1041d))
10
+
11
+ ## [3.24.0](https://github.com/forcedotcom/sfdx-core/compare/v3.23.9...v3.24.0) (2022-07-14)
12
+
13
+ ### Features
14
+
15
+ - org.scratchOrgCreate uses all options except hub ([045a7aa](https://github.com/forcedotcom/sfdx-core/commit/045a7aa56c97323aa8b3191c4879cd1b43f0cfb1))
16
+
17
+ ### Bug Fixes
18
+
19
+ - align messages/files ([5a5f04d](https://github.com/forcedotcom/sfdx-core/commit/5a5f04d3ea8ffb30fdbbfe2c83824ec56a56ec34))
20
+ - load messages by name ([7c3a2d9](https://github.com/forcedotcom/sfdx-core/commit/7c3a2d9d84f9553bb9cf1bc369b49ca46100484e))
21
+ - use named messages always ([2bb25a9](https://github.com/forcedotcom/sfdx-core/commit/2bb25a9c24fcb7146e363783ea81bc3708060a18))
22
+
23
+ ### [3.23.9](https://github.com/forcedotcom/sfdx-core/compare/v3.23.8...v3.23.9) (2022-07-14)
24
+
5
25
  ### [3.23.8](https://github.com/forcedotcom/sfdx-core/compare/v3.23.7...v3.23.8) (2022-07-13)
6
26
 
7
27
  ### Bug Fixes
@@ -245,7 +245,7 @@ class Config extends configFile_1.ConfigFile {
245
245
  constructor(options) {
246
246
  super(Object.assign({
247
247
  isGlobal: false,
248
- }, options !== null && options !== void 0 ? options : {}, {
248
+ }, options ?? {}, {
249
249
  // Don't let consumers of config override this. If they really really want to,
250
250
  // they can extend this class.
251
251
  isState: true,
@@ -319,7 +319,7 @@ class Config extends configFile_1.ConfigFile {
319
319
  }
320
320
  static getPropertyConfigMeta(propertyName) {
321
321
  const prop = Config.propertyConfigMap()[propertyName];
322
- if ((prop === null || prop === void 0 ? void 0 : prop.deprecated) && (prop === null || prop === void 0 ? void 0 : prop.newKey)) {
322
+ if (prop?.deprecated && prop?.newKey) {
323
323
  return Config.propertyConfigMap()[prop.newKey];
324
324
  }
325
325
  return prop;
@@ -400,7 +400,7 @@ class Config extends configFile_1.ConfigFile {
400
400
  super.set(property.key, value);
401
401
  }
402
402
  else {
403
- let valueError = (value === null || value === void 0 ? void 0 : value.toString()) || '';
403
+ let valueError = value?.toString() || '';
404
404
  if (property.input.failedMessage) {
405
405
  valueError = (0, ts_types_1.isString)(property.input.failedMessage)
406
406
  ? property.input.failedMessage
@@ -460,8 +460,7 @@ class Config extends configFile_1.ConfigFile {
460
460
  */
461
461
  async cryptProperties(encrypt) {
462
462
  const hasEncryptedProperties = this.entries().some(([key]) => {
463
- var _a;
464
- return !!((_a = Config.propertyConfigMap()[key]) === null || _a === void 0 ? void 0 : _a.encrypted);
463
+ return !!Config.propertyConfigMap()[key]?.encrypted;
465
464
  });
466
465
  if (hasEncryptedProperties) {
467
466
  await this.initCrypto();
@@ -553,12 +552,11 @@ class SfdxConfig {
553
552
  * - For example, target-org will be renamed to defaultusername.
554
553
  */
555
554
  translate(contents, direction) {
556
- var _a;
557
555
  const translated = {};
558
556
  for (const [key, value] of Object.entries(contents)) {
559
557
  const propConfig = direction === 'toNew'
560
558
  ? this.config.getPropertyConfig(key)
561
- : (_a = Config.getAllowedProperties().find((c) => c.newKey === key)) !== null && _a !== void 0 ? _a : {};
559
+ : Config.getAllowedProperties().find((c) => c.newKey === key) ?? {};
562
560
  if (propConfig.deprecated && propConfig.newKey) {
563
561
  const normalizedKey = direction === 'toNew' ? propConfig.newKey : propConfig.key;
564
562
  translated[normalizedKey] = value;
@@ -65,7 +65,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
65
65
  if (ConfigAggregator.encrypted) {
66
66
  await config.loadProperties();
67
67
  }
68
- if (options === null || options === void 0 ? void 0 : options.customConfigMeta) {
68
+ if (options?.customConfigMeta) {
69
69
  config_1.Config.addAllowedProperties(options.customConfigMeta);
70
70
  }
71
71
  return ConfigAggregator.instance;
@@ -137,7 +137,6 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
137
137
  * @param throwOnDeprecation True, if you want an error throw when reading a deprecated config
138
138
  */
139
139
  getInfo(key, throwOnDeprecation = false) {
140
- var _a;
141
140
  const meta = this.getPropertyMeta(key);
142
141
  if (throwOnDeprecation && meta.deprecated && meta.newKey) {
143
142
  throw messages.createError('deprecatedConfigKey', [key, meta.newKey]);
@@ -151,7 +150,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
151
150
  isLocal: () => location === "Local" /* LOCAL */,
152
151
  isGlobal: () => location === "Global" /* GLOBAL */,
153
152
  isEnvVar: () => location === "Environment" /* ENVIRONMENT */,
154
- deprecated: (_a = meta.deprecated) !== null && _a !== void 0 ? _a : false,
153
+ deprecated: meta.deprecated ?? false,
155
154
  };
156
155
  }
157
156
  /**
@@ -332,14 +331,14 @@ class SfdxConfigAggregator extends ConfigAggregator {
332
331
  if (SfdxConfigAggregator.encrypted) {
333
332
  await config.loadProperties();
334
333
  }
335
- if (options === null || options === void 0 ? void 0 : options.customConfigMeta) {
334
+ if (options?.customConfigMeta) {
336
335
  config_1.Config.addAllowedProperties(options.customConfigMeta);
337
336
  }
338
337
  return SfdxConfigAggregator.instance;
339
338
  }
340
339
  getPropertyMeta(key) {
341
340
  const match = this.getAllowedProperties().find((element) => key === element.key);
342
- if ((match === null || match === void 0 ? void 0 : match.deprecated) && (match === null || match === void 0 ? void 0 : match.newKey)) {
341
+ if (match?.deprecated && match?.newKey) {
343
342
  return this.getPropertyMeta(match.newKey);
344
343
  }
345
344
  else if (match) {
@@ -370,10 +369,9 @@ class SfdxConfigAggregator extends ConfigAggregator {
370
369
  });
371
370
  }
372
371
  translate(key, direction = 'toNew') {
373
- var _a;
374
372
  const propConfig = direction === 'toNew'
375
373
  ? this.getPropertyMeta(key)
376
- : (_a = config_1.Config.getAllowedProperties().find((c) => c.newKey === key)) !== null && _a !== void 0 ? _a : {};
374
+ : config_1.Config.getAllowedProperties().find((c) => c.newKey === key) ?? {};
377
375
  return propConfig.key || key;
378
376
  }
379
377
  }
@@ -205,8 +205,7 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
205
205
  });
206
206
  }
207
207
  getEncryptedKeys() {
208
- var _a, _b;
209
- return [...(((_a = this.options) === null || _a === void 0 ? void 0 : _a.encryptedKeys) || []), ...(((_b = this.statics) === null || _b === void 0 ? void 0 : _b.encryptedKeys) || [])];
208
+ return [...(this.options?.encryptedKeys || []), ...(this.statics?.encryptedKeys || [])];
210
209
  }
211
210
  /**
212
211
  * This config file has encrypted keys and it should attempt to encrypt them.
@@ -408,9 +408,8 @@ class EnvVars extends kit_1.Env {
408
408
  return 'SFDX_';
409
409
  }
410
410
  getPropertyFromEnv(property, prefix = EnvVars.defaultPrefix()) {
411
- var _a;
412
411
  const envName = EnvVars.propertyToEnvName(property, prefix);
413
- const synonym = (_a = exports.SUPPORTED_ENV_VARS[envName]) === null || _a === void 0 ? void 0 : _a.synonymOf;
412
+ const synonym = exports.SUPPORTED_ENV_VARS[envName]?.synonymOf;
414
413
  return this.get(envName) || this.get(synonym);
415
414
  }
416
415
  asDictionary() {
@@ -1,7 +1,7 @@
1
1
  import { AsyncCreatable } from '@salesforce/kit';
2
- import { OAuth2Config } from 'jsforce/lib/oauth2';
2
+ import { OAuth2Config } from 'jsforce';
3
3
  import { JsonMap, Nullable } from '@salesforce/ts-types';
4
- import { AuthInfo } from './org/authInfo';
4
+ import { AuthInfo } from './org';
5
5
  export interface DeviceCodeResponse extends JsonMap {
6
6
  device_code: string;
7
7
  interval: number;
@@ -14,9 +14,8 @@ const kit_1 = require("@salesforce/kit");
14
14
  const ts_types_1 = require("@salesforce/ts-types");
15
15
  const FormData = require("form-data");
16
16
  const logger_1 = require("./logger");
17
- const authInfo_1 = require("./org/authInfo");
17
+ const org_1 = require("./org");
18
18
  const sfError_1 = require("./sfError");
19
- const connection_1 = require("./org/connection");
20
19
  const messages_1 = require("./messages");
21
20
  messages_1.Messages.importMessagesDirectory(__dirname);
22
21
  const messages = messages_1.Messages.load('@salesforce/core', 'auth', ['pollingTimeout']);
@@ -59,9 +58,9 @@ class DeviceOauthService extends kit_1.AsyncCreatable {
59
58
  this.pollingCount = 0;
60
59
  this.options = options;
61
60
  if (!this.options.clientId)
62
- this.options.clientId = authInfo_1.DEFAULT_CONNECTED_APP_INFO.clientId;
61
+ this.options.clientId = org_1.DEFAULT_CONNECTED_APP_INFO.clientId;
63
62
  if (!this.options.loginUrl)
64
- this.options.loginUrl = authInfo_1.AuthInfo.getDefaultInstanceUrl();
63
+ this.options.loginUrl = org_1.AuthInfo.getDefaultInstanceUrl();
65
64
  }
66
65
  /**
67
66
  * Begin the authorization flow by requesting the login
@@ -90,7 +89,7 @@ class DeviceOauthService extends kit_1.AsyncCreatable {
90
89
  * @returns {Promise<AuthInfo>}
91
90
  */
92
91
  async authorizeAndSave(approval) {
93
- const authInfo = await authInfo_1.AuthInfo.create({
92
+ const authInfo = await org_1.AuthInfo.create({
94
93
  oauth2Options: {
95
94
  loginUrl: approval.instance_url,
96
95
  refreshToken: approval.refresh_token,
@@ -113,7 +112,7 @@ class DeviceOauthService extends kit_1.AsyncCreatable {
113
112
  form.append('scope', DeviceOauthService.SCOPE);
114
113
  return {
115
114
  url,
116
- headers: { ...connection_1.SFDX_HTTP_HEADERS, ...form.getHeaders() },
115
+ headers: { ...org_1.SFDX_HTTP_HEADERS, ...form.getHeaders() },
117
116
  method: 'POST',
118
117
  body: form.getBuffer(),
119
118
  };
@@ -125,7 +124,7 @@ class DeviceOauthService extends kit_1.AsyncCreatable {
125
124
  form.append('code', code);
126
125
  return {
127
126
  url,
128
- headers: { ...connection_1.SFDX_HTTP_HEADERS, ...form.getHeaders() },
127
+ headers: { ...org_1.SFDX_HTTP_HEADERS, ...form.getHeaders() },
129
128
  method: 'POST',
130
129
  body: form.getBuffer(),
131
130
  };
@@ -1,16 +1,8 @@
1
1
  import { AsyncOptionalCreatable } from '@salesforce/kit';
2
2
  import { Nullable } from '@salesforce/ts-types';
3
- import { OAuth2, OAuth2Config as JsforceOAuth2Config } from 'jsforce';
3
+ import { JwtOAuth2Config, OAuth2 } from 'jsforce';
4
4
  import { Connection } from './connection';
5
5
  import { Org } from './org';
6
- export declare type OAuth2Config = JsforceOAuth2Config & {
7
- privateKey?: string;
8
- privateKeyFile?: string;
9
- authCode?: string;
10
- refreshToken?: string;
11
- loginUrl?: string;
12
- username?: string;
13
- };
14
6
  /**
15
7
  * Fields for authorization, org, and local information.
16
8
  */
@@ -86,7 +78,7 @@ export declare type ConnectionOptions = AuthFields & {
86
78
  /**
87
79
  * OAuth options.
88
80
  */
89
- oauth2?: Partial<OAuth2Config>;
81
+ oauth2?: Partial<JwtOAuth2Config>;
90
82
  /**
91
83
  * Refresh token callback.
92
84
  */
@@ -169,7 +161,7 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
169
161
  *
170
162
  * @param options The options to generate the URL.
171
163
  */
172
- static getAuthorizationUrl(options: OAuth2Config & {
164
+ static getAuthorizationUrl(options: JwtOAuth2Config & {
173
165
  scope?: string;
174
166
  }, oauth2?: OAuth2): string;
175
167
  /**
@@ -335,7 +327,7 @@ export declare namespace AuthInfo {
335
327
  /**
336
328
  * OAuth options.
337
329
  */
338
- oauth2Options?: OAuth2Config;
330
+ oauth2Options?: JwtOAuth2Config;
339
331
  /**
340
332
  * Options for the access token auth.
341
333
  */
@@ -40,20 +40,6 @@ const messages = messages_1.Messages.load('@salesforce/core', 'core', [
40
40
  'authCodeExchangeError',
41
41
  'missingClientId',
42
42
  ]);
43
- // Extend OAuth2 to add JWT Bearer Token Flow support.
44
- class JwtOAuth2 extends jsforce_1.OAuth2 {
45
- constructor(options) {
46
- super(options);
47
- }
48
- jwtAuthorize(innerToken) {
49
- // @ts-ignore
50
- return super._postParams({
51
- // eslint-disable-next-line camelcase
52
- grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
53
- assertion: innerToken,
54
- });
55
- }
56
- }
57
43
  // parses the id field returned from jsForce oauth2 methods to get
58
44
  // user ID and org ID.
59
45
  function parseIdUrl(idUrl) {
@@ -144,14 +130,13 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
144
130
  * @returns {Promise<OrgAuthorization[]>}
145
131
  */
146
132
  static async listAllAuthorizations(orgAuthFilter = (orgAuth) => !!orgAuth) {
147
- var _a;
148
133
  const stateAggregator = await stateAggregator_1.StateAggregator.getInstance();
149
134
  const config = (await configAggregator_1.ConfigAggregator.create()).getConfigInfo();
150
135
  const orgs = await stateAggregator.orgs.readAll();
151
136
  const final = [];
152
137
  for (const org of orgs) {
153
138
  const username = (0, ts_types_1.ensureString)(org.username);
154
- const aliases = (_a = stateAggregator.aliases.getAll(username)) !== null && _a !== void 0 ? _a : undefined;
139
+ const aliases = stateAggregator.aliases.getAll(username) ?? undefined;
155
140
  // Get a list of configuration values that are set to either the username or one
156
141
  // of the aliases
157
142
  const configs = config
@@ -296,7 +281,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
296
281
  * Find all dev hubs available in the local environment.
297
282
  */
298
283
  static async getDevHubAuthInfos() {
299
- return await AuthInfo.listAllAuthorizations((possibleHub) => { var _a; return (_a = possibleHub === null || possibleHub === void 0 ? void 0 : possibleHub.isDevHub) !== null && _a !== void 0 ? _a : false; });
284
+ return await AuthInfo.listAllAuthorizations((possibleHub) => possibleHub?.isDevHub ?? false);
300
285
  }
301
286
  static async queryScratchOrg(devHubUsername, scratchOrgId) {
302
287
  const devHubOrg = await org_1.Org.create({ aliasOrUsername: devHubUsername });
@@ -409,8 +394,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
409
394
  return opts;
410
395
  }
411
396
  getClientId() {
412
- var _a;
413
- return ((_a = this.getFields()) === null || _a === void 0 ? void 0 : _a.clientId) || exports.DEFAULT_CONNECTED_APP_INFO.legacyClientId;
397
+ return this.getFields()?.clientId || exports.DEFAULT_CONNECTED_APP_INFO.legacyClientId;
414
398
  }
415
399
  getRedirectUri() {
416
400
  return 'http://localhost:1717/OauthRedirect';
@@ -421,8 +405,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
421
405
  * @param decrypt Decrypt the fields.
422
406
  */
423
407
  getFields(decrypt) {
424
- var _a;
425
- return (_a = this.stateAggregator.orgs.get(this.username, decrypt)) !== null && _a !== void 0 ? _a : {};
408
+ return this.stateAggregator.orgs.get(this.username, decrypt) ?? {};
426
409
  }
427
410
  /**
428
411
  * Get the org front door (used for web based oauth flows)
@@ -498,7 +481,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
498
481
  }
499
482
  const username = (0, ts_types_1.ensureString)(this.getUsername());
500
483
  const alias = this.stateAggregator.aliases.get(username);
501
- const value = alias !== null && alias !== void 0 ? alias : username;
484
+ const value = alias ?? username;
502
485
  if (options.org) {
503
486
  config.set(orgConfigProperties_1.OrgConfigProperties.TARGET_ORG, value);
504
487
  }
@@ -522,7 +505,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
522
505
  async init() {
523
506
  this.stateAggregator = await stateAggregator_1.StateAggregator.getInstance();
524
507
  const username = this.options.username;
525
- const authOptions = (this.options.oauth2Options || this.options.accessTokenOptions);
508
+ const authOptions = this.options.oauth2Options || this.options.accessTokenOptions;
526
509
  // Must specify either username and/or options
527
510
  if (!username && !authOptions) {
528
511
  throw messages.createError('authInfoCreationError');
@@ -534,7 +517,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
534
517
  throw messages.createError('authInfoOverwriteError');
535
518
  }
536
519
  }
537
- const oauthUsername = username || (authOptions === null || authOptions === void 0 ? void 0 : authOptions.username);
520
+ const oauthUsername = username || authOptions?.username;
538
521
  if (oauthUsername) {
539
522
  this.username = oauthUsername;
540
523
  await this.stateAggregator.orgs.read(oauthUsername, false, false);
@@ -562,9 +545,8 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
562
545
  }
563
546
  }
564
547
  getInstanceUrl(options, aggregator) {
565
- var _a;
566
- const instanceUrl = (_a = options === null || options === void 0 ? void 0 : options.instanceUrl) !== null && _a !== void 0 ? _a : aggregator.getPropertyValue(orgConfigProperties_1.OrgConfigProperties.ORG_INSTANCE_URL);
567
- return instanceUrl !== null && instanceUrl !== void 0 ? instanceUrl : sfdcUrl_1.SfdcUrl.PRODUCTION;
548
+ const instanceUrl = options?.instanceUrl ?? aggregator.getPropertyValue(orgConfigProperties_1.OrgConfigProperties.ORG_INSTANCE_URL);
549
+ return instanceUrl ?? sfdcUrl_1.SfdcUrl.PRODUCTION;
568
550
  }
569
551
  /**
570
552
  * Initialize this AuthInfo instance with the specified options. If options are not provided, initialize it from cache
@@ -584,7 +566,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
584
566
  if (this.isTokenOptions(options)) {
585
567
  authConfig = options;
586
568
  const userInfo = await this.retrieveUserInfo((0, ts_types_1.ensureString)(options.instanceUrl), (0, ts_types_1.ensureString)(options.accessToken));
587
- this.update({ username: userInfo === null || userInfo === void 0 ? void 0 : userInfo.username, orgId: userInfo === null || userInfo === void 0 ? void 0 : userInfo.organizationId });
569
+ this.update({ username: userInfo?.username, orgId: userInfo?.organizationId });
588
570
  }
589
571
  else {
590
572
  if (this.options.parentUsername) {
@@ -651,7 +633,6 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
651
633
  // A callback function for a connection to refresh an access token. This is used
652
634
  // both for a JWT connection and an OAuth connection.
653
635
  async refreshFn(conn, callback) {
654
- var _a;
655
636
  this.logger.info('Access token has expired. Updating...');
656
637
  try {
657
638
  const fields = this.getFields(true);
@@ -661,7 +642,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
661
642
  }
662
643
  catch (err) {
663
644
  const error = err;
664
- if ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('Data Not Available')) {
645
+ if (error?.message?.includes('Data Not Available')) {
665
646
  // Set cause to keep original stacktrace
666
647
  return await callback(messages.createError('orgDataNotAvailableError', [this.getUsername()], [], error));
667
648
  }
@@ -673,14 +654,13 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
673
654
  }
674
655
  // Build OAuth config for a JWT auth flow
675
656
  async authJwt(options) {
676
- var _a;
677
657
  if (!options.clientId) {
678
658
  throw messages.createError('missingClientId');
679
659
  }
680
660
  const privateKeyContents = await this.readJwtKey((0, ts_types_1.ensureString)(options.privateKey));
681
661
  const { loginUrl = sfdcUrl_1.SfdcUrl.PRODUCTION } = options;
682
662
  const url = new sfdcUrl_1.SfdcUrl(loginUrl);
683
- const createdOrgInstance = ((_a = this.getFields().createdOrgInstance) !== null && _a !== void 0 ? _a : '').trim().toLowerCase();
663
+ const createdOrgInstance = (this.getFields().createdOrgInstance ?? '').trim().toLowerCase();
684
664
  const audienceUrl = await url.getJwtAudienceUrl(createdOrgInstance);
685
665
  let authFieldsBuilder;
686
666
  const authErrors = [];
@@ -729,7 +709,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
729
709
  }, privateKeyContents, {
730
710
  algorithm: 'RS256',
731
711
  });
732
- const oauth2 = new JwtOAuth2({ loginUrl });
712
+ const oauth2 = new jsforce_1.JwtOAuth2({ loginUrl });
733
713
  return (0, ts_types_1.ensureJsonMap)(await oauth2.jwtAuthorize(jwtToken));
734
714
  }
735
715
  // Build OAuth config for a refresh token auth flow
@@ -756,15 +736,13 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
756
736
  let username = this.getUsername();
757
737
  if (!username) {
758
738
  const userInfo = await this.retrieveUserInfo(authFieldsBuilder.instance_url, authFieldsBuilder.access_token);
759
- username = (0, ts_types_1.ensureString)(userInfo === null || userInfo === void 0 ? void 0 : userInfo.username);
739
+ username = (0, ts_types_1.ensureString)(userInfo?.username);
760
740
  }
761
741
  return {
762
742
  orgId,
763
743
  username,
764
744
  accessToken: authFieldsBuilder.access_token,
765
- // @ts-ignore TODO: need better typings for jsforce
766
745
  instanceUrl: authFieldsBuilder.instance_url,
767
- // @ts-ignore TODO: need better typings for jsforce
768
746
  loginUrl: options.loginUrl || authFieldsBuilder.instance_url,
769
747
  refreshToken: options.refreshToken,
770
748
  clientId: options.clientId,
@@ -793,7 +771,6 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
793
771
  catch (err) {
794
772
  throw messages.createError('authCodeExchangeError', [err.message]);
795
773
  }
796
- // @ts-ignore TODO: need better typings for jsforce
797
774
  const { orgId } = parseIdUrl(authFields.id);
798
775
  let username = this.getUsername();
799
776
  // Only need to query for the username if it isn't known. For example, a new auth code exchange
@@ -801,15 +778,13 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
801
778
  if (!username) {
802
779
  // @ts-ignore
803
780
  const userInfo = await this.retrieveUserInfo(authFields.instance_url, authFields.access_token);
804
- username = userInfo === null || userInfo === void 0 ? void 0 : userInfo.username;
781
+ username = userInfo?.username;
805
782
  }
806
783
  return {
807
784
  accessToken: authFields.access_token,
808
- // @ts-ignore TODO: need better typings for jsforce
809
785
  instanceUrl: authFields.instance_url,
810
786
  orgId,
811
787
  username,
812
- // @ts-ignore TODO: need better typings for jsforce
813
788
  loginUrl: options.loginUrl || authFields.instance_url,
814
789
  refreshToken: authFields.refresh_token,
815
790
  clientId: options.clientId,
@@ -857,16 +832,15 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
857
832
  * @private
858
833
  */
859
834
  throwUserGetException(response) {
860
- var _a, _b, _c;
861
835
  let errorMsg = '';
862
- const bodyAsString = (_a = response.body) !== null && _a !== void 0 ? _a : JSON.stringify({ message: 'UNKNOWN', errorCode: 'UNKNOWN' });
836
+ const bodyAsString = response.body ?? JSON.stringify({ message: 'UNKNOWN', errorCode: 'UNKNOWN' });
863
837
  try {
864
838
  const body = (0, kit_1.parseJson)(bodyAsString);
865
839
  if ((0, ts_types_1.isArray)(body)) {
866
- errorMsg = body.map((line) => { var _a, _b; return (_b = (_a = line.message) !== null && _a !== void 0 ? _a : line.errorCode) !== null && _b !== void 0 ? _b : 'UNKNOWN'; }).join(os.EOL);
840
+ errorMsg = body.map((line) => line.message ?? line.errorCode ?? 'UNKNOWN').join(os.EOL);
867
841
  }
868
842
  else {
869
- errorMsg = (_c = (_b = body.message) !== null && _b !== void 0 ? _b : body.errorCode) !== null && _c !== void 0 ? _c : 'UNKNOWN';
843
+ errorMsg = body.message ?? body.errorCode ?? 'UNKNOWN';
870
844
  }
871
845
  }
872
846
  catch (err) {
@@ -63,14 +63,10 @@ export declare class Connection<S extends Schema = Schema> extends JSForceConnec
63
63
  */
64
64
  init(): Promise<void>;
65
65
  /**
66
- * TODO: This should be moved into JSForce V2 once ready
67
- * this is only a temporary solution to support both REST and SOAP APIs
68
- *
69
66
  * deploy a zipped buffer from the SDRL with REST or SOAP
70
67
  *
71
68
  * @param zipInput data to deploy
72
69
  * @param options JSForce deploy options + a boolean for rest
73
- * @param callback
74
70
  */
75
71
  deploy(zipInput: Buffer, options: DeployOptionsWithRest): Promise<DeployResultLocator<AsyncResult & Schema>>;
76
72
  /**
@@ -86,13 +82,12 @@ export declare class Connection<S extends Schema = Schema> extends JSForceConnec
86
82
  */
87
83
  baseUrl(): string;
88
84
  /**
89
- * TODO: This should be moved into JSForce V2 once ready
90
- * this is only a temporary solution to support both REST and SOAP APIs
91
- *
92
- * Will deploy a recently validated deploy request
85
+ * Will deploy a recently validated deploy request - directly calling jsforce now that this is supported.
86
+ * WARNING: will always return a string from jsforce, the type is JsonCollection to support backwards compatibility
93
87
  *
94
88
  * @param options.id = the deploy ID that's been validated already from a previous checkOnly deploy request
95
89
  * @param options.rest = a boolean whether or not to use the REST API
90
+ * @deprecated use {@link Connection.metadata#deployRecentValidation} instead - the jsforce implementation, instead of this wrapper
96
91
  */
97
92
  deployRecentValidation(options: recentValidationOptions): Promise<JsonCollection>;
98
93
  /**
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.SingleRecordQueryErrors = exports.Connection = exports.DNS_ERROR_NAME = exports.SFDX_HTTP_HEADERS = void 0;
10
10
  /* eslint-disable @typescript-eslint/ban-ts-comment */
11
11
  const url_1 = require("url");
12
- const FormData = require("form-data");
13
12
  const kit_1 = require("@salesforce/kit");
14
13
  const ts_types_1 = require("@salesforce/ts-types");
15
14
  const jsforce_1 = require("jsforce");
@@ -75,9 +74,8 @@ class Connection extends jsforce_1.Connection {
75
74
  * @param options Constructor options.
76
75
  */
77
76
  static async create(options) {
78
- var _a, _b;
79
77
  const baseOptions = {
80
- version: (_a = options.connectionOptions) === null || _a === void 0 ? void 0 : _a.version,
78
+ version: options.connectionOptions?.version,
81
79
  callOptions: {
82
80
  client: clientId,
83
81
  },
@@ -101,7 +99,7 @@ class Connection extends jsforce_1.Connection {
101
99
  }
102
100
  }
103
101
  else {
104
- conn.logger.debug(`The org-api-version ${baseOptions.version} was found from ${((_b = options.connectionOptions) === null || _b === void 0 ? void 0 : _b.version) ? 'passed in options' : 'config'}`);
102
+ conn.logger.debug(`The org-api-version ${baseOptions.version} was found from ${options.connectionOptions?.version ? 'passed in options' : 'config'}`);
105
103
  }
106
104
  }
107
105
  catch (err) {
@@ -122,14 +120,10 @@ class Connection extends jsforce_1.Connection {
122
120
  this.logger = this.tooling._logger = await logger_1.Logger.child('connection');
123
121
  }
124
122
  /**
125
- * TODO: This should be moved into JSForce V2 once ready
126
- * this is only a temporary solution to support both REST and SOAP APIs
127
- *
128
123
  * deploy a zipped buffer from the SDRL with REST or SOAP
129
124
  *
130
125
  * @param zipInput data to deploy
131
126
  * @param options JSForce deploy options + a boolean for rest
132
- * @param callback
133
127
  */
134
128
  async deploy(zipInput, options) {
135
129
  const rest = options.rest;
@@ -138,27 +132,7 @@ class Connection extends jsforce_1.Connection {
138
132
  if (rest) {
139
133
  this.logger.debug('deploy with REST');
140
134
  await this.refreshAuth();
141
- const headers = {
142
- Authorization: this && `OAuth ${this.accessToken}`,
143
- 'Sforce-Call-Options': 'client=sfdx-core',
144
- };
145
- const client = this.oauth2 && this.oauth2.clientId;
146
- if (client) {
147
- headers.clientId = client;
148
- }
149
- const form = new FormData();
150
- // Add the zip file
151
- form.append('file', zipInput, {
152
- contentType: 'application/zip',
153
- filename: 'package.xml',
154
- });
155
- // Add the deploy options
156
- form.append('entity_content', JSON.stringify({ deployOptions: options }), {
157
- contentType: 'application/json',
158
- });
159
- const url = `${this.baseUrl()}/metadata/deployRequest`;
160
- const httpRequest = { method: 'POST', url, headers, body: form };
161
- return this.request(httpRequest);
135
+ return this.metadata.deployRest(zipInput, options);
162
136
  }
163
137
  else {
164
138
  this.logger.debug('deploy with SOAP');
@@ -176,7 +150,6 @@ class Connection extends jsforce_1.Connection {
176
150
  const httpRequest = (0, ts_types_1.isString)(request) ? { method: 'GET', url: request } : request;
177
151
  httpRequest.headers = Object.assign({}, exports.SFDX_HTTP_HEADERS, httpRequest.headers);
178
152
  this.logger.debug(`request: ${JSON.stringify(httpRequest)}`);
179
- // The "as" is a workaround for the jsforce typings.
180
153
  return super.request(httpRequest, options);
181
154
  }
182
155
  /**
@@ -187,37 +160,17 @@ class Connection extends jsforce_1.Connection {
187
160
  return super._baseUrl();
188
161
  }
189
162
  /**
190
- * TODO: This should be moved into JSForce V2 once ready
191
- * this is only a temporary solution to support both REST and SOAP APIs
192
- *
193
- * Will deploy a recently validated deploy request
163
+ * Will deploy a recently validated deploy request - directly calling jsforce now that this is supported.
164
+ * WARNING: will always return a string from jsforce, the type is JsonCollection to support backwards compatibility
194
165
  *
195
166
  * @param options.id = the deploy ID that's been validated already from a previous checkOnly deploy request
196
167
  * @param options.rest = a boolean whether or not to use the REST API
168
+ * @deprecated use {@link Connection.metadata#deployRecentValidation} instead - the jsforce implementation, instead of this wrapper
197
169
  */
198
170
  async deployRecentValidation(options) {
199
- const rest = options.rest;
200
- delete options.rest;
201
- if (rest) {
202
- const url = `${this.baseUrl()}/metadata/deployRequest`;
203
- const messageBody = JSON.stringify({
204
- validatedDeployRequestId: options.id,
205
- });
206
- const requestInfo = {
207
- method: 'POST',
208
- url,
209
- body: messageBody,
210
- };
211
- const requestOptions = { headers: 'json' };
212
- return this.request(requestInfo, requestOptions);
213
- }
214
- else {
215
- // the _invoke is private in jsforce, we can call the SOAP deployRecentValidation like this
216
- // @ts-ignore
217
- return this.metadata['_invoke']('deployRecentValidation', {
218
- validationId: options.id,
219
- });
220
- }
171
+ // REST returns an object with an id property, SOAP returns the id as a string directly. That is now handled
172
+ // in jsforce, so we have to cast a string as unkown as JsonCollection to support backwards compatibility.
173
+ return (await this.metadata.deployRecentValidation(options));
221
174
  }
222
175
  /**
223
176
  * Retrieves the highest api version that is supported by the target server instance.
@@ -249,8 +202,7 @@ class Connection extends jsforce_1.Connection {
249
202
  * Verify that instance has a reachable DNS entry, otherwise will throw error
250
203
  */
251
204
  async isResolvable() {
252
- var _a;
253
- if (!((_a = this.options.connectionOptions) === null || _a === void 0 ? void 0 : _a.instanceUrl)) {
205
+ if (!this.options.connectionOptions?.instanceUrl) {
254
206
  throw messages.createError('noInstanceUrlError');
255
207
  }
256
208
  const resolver = await myDomainResolver_1.MyDomainResolver.create({
package/lib/org/org.d.ts CHANGED
@@ -68,7 +68,7 @@ export declare type ResumeSandboxRequest = {
68
68
  SandboxName?: string;
69
69
  SandboxProcessObjId?: string;
70
70
  };
71
- export declare type ScratchOrgRequest = Pick<ScratchOrgCreateOptions, 'connectedAppConsumerKey' | 'durationDays' | 'nonamespace' | 'noancestors' | 'wait' | 'retry' | 'apiversion' | 'definitionjson' | 'definitionfile' | 'orgConfig' | 'clientSecret'>;
71
+ export declare type ScratchOrgRequest = Omit<ScratchOrgCreateOptions, 'hubOrg'>;
72
72
  export declare type SandboxFields = {
73
73
  sandboxOrgId: string;
74
74
  prodOrgUsername: string;