@salesforce/core 3.23.8 → 3.23.9

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/org.js CHANGED
@@ -90,7 +90,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
90
90
  constructor(options) {
91
91
  super(options);
92
92
  this.status = Org.Status.UNKNOWN;
93
- this.options = options !== null && options !== void 0 ? options : {};
93
+ this.options = options ?? {};
94
94
  }
95
95
  /**
96
96
  * create a sandbox from a production org
@@ -151,7 +151,6 @@ class Org extends kit_1.AsyncOptionalCreatable {
151
151
  async: false,
152
152
  interval: kit_1.Duration.seconds(30),
153
153
  }) {
154
- var _a;
155
154
  this.logger.debug(`ResumeSandbox called with ResumeSandboxRequest: ${resumeSandboxRequest}`);
156
155
  let sandboxCreationProgress;
157
156
  // seed the sandboxCreationProgress via the resumeSandboxRequest options
@@ -163,7 +162,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
163
162
  }
164
163
  else {
165
164
  throw messages.createError('sandboxNotFound', [
166
- (_a = resumeSandboxRequest.SandboxName) !== null && _a !== void 0 ? _a : resumeSandboxRequest.SandboxProcessObjId,
165
+ resumeSandboxRequest.SandboxName ?? resumeSandboxRequest.SandboxProcessObjId,
167
166
  ]);
168
167
  }
169
168
  this.logger.debug(`Return from calling singleRecordQuery with tooling: ${sandboxCreationProgress}`);
@@ -529,11 +528,10 @@ class Org extends kit_1.AsyncOptionalCreatable {
529
528
  * Reads and returns the content of all user auth files for this org as an array.
530
529
  */
531
530
  async readUserAuthFiles() {
532
- var _a;
533
531
  const config = await this.retrieveOrgUsersConfig();
534
532
  const contents = await config.read();
535
533
  const thisUsername = (0, ts_types_1.ensure)(this.getUsername());
536
- const usernames = (0, ts_types_1.ensureJsonArray)((_a = contents.usernames) !== null && _a !== void 0 ? _a : [thisUsername]);
534
+ const usernames = (0, ts_types_1.ensureJsonArray)(contents.usernames ?? [thisUsername]);
537
535
  return Promise.all(usernames.map((username) => {
538
536
  if (username === thisUsername) {
539
537
  return authInfo_1.AuthInfo.create({
@@ -563,7 +561,6 @@ class Org extends kit_1.AsyncOptionalCreatable {
563
561
  * @param {AuthInfo | string} auth The AuthInfo for the username to add.
564
562
  */
565
563
  async addUsername(auth) {
566
- var _a;
567
564
  if (!auth) {
568
565
  throw new sfError_1.SfError('Missing auth info', 'MissingAuthInfo');
569
566
  }
@@ -573,7 +570,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
573
570
  const contents = await orgConfig.read();
574
571
  // TODO: This is kind of screwy because contents values can be `AnyJson | object`...
575
572
  // needs config refactoring to improve
576
- const usernames = (_a = contents.usernames) !== null && _a !== void 0 ? _a : [];
573
+ const usernames = contents.usernames ?? [];
577
574
  if (!(0, ts_types_1.isArray)(usernames)) {
578
575
  throw new sfError_1.SfError('Usernames is not an array', 'UnexpectedDataFormat');
579
576
  }
@@ -602,7 +599,6 @@ class Org extends kit_1.AsyncOptionalCreatable {
602
599
  * @param {AuthInfo | string} auth The AuthInfo containing the username to remove.
603
600
  */
604
601
  async removeUsername(auth) {
605
- var _a;
606
602
  if (!auth) {
607
603
  throw new sfError_1.SfError('Missing auth info', 'MissingAuthInfoError');
608
604
  }
@@ -611,7 +607,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
611
607
  const orgConfig = await this.retrieveOrgUsersConfig();
612
608
  const contents = await orgConfig.read();
613
609
  const targetUser = authInfo.getFields().username;
614
- const usernames = ((_a = contents.usernames) !== null && _a !== void 0 ? _a : []);
610
+ const usernames = (contents.usernames ?? []);
615
611
  contents.usernames = usernames.filter((username) => username !== targetUser);
616
612
  await orgConfig.write();
617
613
  return this;
@@ -652,8 +648,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
652
648
  * Returns the orgId for this org.
653
649
  */
654
650
  getOrgId() {
655
- var _a;
656
- return (_a = this.orgId) !== null && _a !== void 0 ? _a : this.getField(Org.Fields.ORG_ID);
651
+ return this.orgId ?? this.getField(Org.Fields.ORG_ID);
657
652
  }
658
653
  /**
659
654
  * Returns for the config aggregator.
@@ -807,13 +802,12 @@ class Org extends kit_1.AsyncOptionalCreatable {
807
802
  * @returns {SandboxProcessObject} The SandboxProcessObject for the sandbox
808
803
  */
809
804
  async queryLatestSandboxProcessBySandboxName(sandboxNameIn) {
810
- var _a;
811
805
  const { tooling } = this.getConnection();
812
806
  this.logger.debug('QueryLatestSandboxProcessBySandboxName called with SandboxName: %s ', sandboxNameIn);
813
807
  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`;
814
808
  const queryResult = await tooling.query(queryStr);
815
809
  this.logger.debug('Return from calling queryToolingApi: %s ', queryResult);
816
- if (((_a = queryResult === null || queryResult === void 0 ? void 0 : queryResult.records) === null || _a === void 0 ? void 0 : _a.length) === 1) {
810
+ if (queryResult?.records?.length === 1) {
817
811
  return queryResult.records[0];
818
812
  }
819
813
  else if (queryResult.records && queryResult.records.length > 1) {
@@ -839,18 +833,17 @@ class Org extends kit_1.AsyncOptionalCreatable {
839
833
  * @private
840
834
  */
841
835
  async deleteSandbox(prodOrg) {
842
- var _a, _b;
843
836
  const sandbox = await this.getSandboxConfig(this.getOrgId());
844
- prodOrg !== null && prodOrg !== void 0 ? prodOrg : (prodOrg = await Org.create({
837
+ prodOrg ?? (prodOrg = await Org.create({
845
838
  aggregator: this.configAggregator,
846
- aliasOrUsername: sandbox === null || sandbox === void 0 ? void 0 : sandbox.prodOrgUsername,
839
+ aliasOrUsername: sandbox?.prodOrgUsername,
847
840
  }));
848
- let sandboxInfoId = sandbox === null || sandbox === void 0 ? void 0 : sandbox.sandboxInfoId;
841
+ let sandboxInfoId = sandbox?.sandboxInfoId;
849
842
  if (!sandboxInfoId) {
850
843
  let result;
851
844
  try {
852
845
  // grab sandboxName from config or try to calculate from the sandbox username
853
- const sandboxName = (_a = sandbox === null || sandbox === void 0 ? void 0 : sandbox.sandboxName) !== null && _a !== void 0 ? _a : ((_b = this.getUsername()) !== null && _b !== void 0 ? _b : '').split(`${prodOrg.getUsername()}.`)[1];
846
+ const sandboxName = sandbox?.sandboxName ?? (this.getUsername() ?? '').split(`${prodOrg.getUsername()}.`)[1];
854
847
  if (!sandboxName) {
855
848
  this.logger.debug('Sandbox name is not available');
856
849
  // jump to query by orgId
@@ -896,7 +889,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
896
889
  */
897
890
  async deleteScratchOrg(devHub) {
898
891
  // if we didn't get a devHub, we'll get it from the this org
899
- devHub !== null && devHub !== void 0 ? devHub : (devHub = await this.getDevHubOrg());
892
+ devHub ?? (devHub = await this.getDevHubOrg());
900
893
  if (!devHub) {
901
894
  throw messages.createError('noDevHubFound');
902
895
  }
@@ -980,8 +973,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
980
973
  await Promise.all(authInfos
981
974
  .map((auth) => auth.getFields().username)
982
975
  .map(async (username) => {
983
- var _a;
984
- const aliasKeys = (_a = (username && stateAggregator.aliases.getAll(username))) !== null && _a !== void 0 ? _a : [];
976
+ const aliasKeys = (username && stateAggregator.aliases.getAll(username)) ?? [];
985
977
  stateAggregator.aliases.unsetAll(username);
986
978
  const orgForUser = username === this.getUsername()
987
979
  ? this
@@ -1063,7 +1055,6 @@ class Org extends kit_1.AsyncOptionalCreatable {
1063
1055
  let waitingOnAuth = false;
1064
1056
  const pollingClient = await pollingClient_1.PollingClient.create({
1065
1057
  poll: async () => {
1066
- var _a;
1067
1058
  const sandboxProcessObj = await this.querySandboxProcessBySandboxInfoId(options.sandboxProcessObj.SandboxInfoId);
1068
1059
  // check to see if sandbox can authenticate via sandboxAuth endpoint
1069
1060
  const sandboxInfo = await this.sandboxSignupComplete(sandboxProcessObj);
@@ -1077,7 +1068,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
1077
1068
  catch (err) {
1078
1069
  const error = err;
1079
1070
  this.logger.debug('Exception while calling writeSandboxAuthFile', err);
1080
- 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"))) {
1071
+ if (error?.name === 'JwtAuthError' && error?.stack?.includes("user hasn't approved")) {
1081
1072
  waitingOnAuth = true;
1082
1073
  }
1083
1074
  else {
@@ -1148,8 +1139,8 @@ class Org extends kit_1.AsyncOptionalCreatable {
1148
1139
  const error = err;
1149
1140
  // There are cases where the endDate is set before the sandbox has actually completed.
1150
1141
  // In that case, the sandboxAuth call will throw a specific exception.
1151
- if ((error === null || error === void 0 ? void 0 : error.name) === 'INVALID_STATUS') {
1152
- this.logger.debug('Error while authenticating the user', error === null || error === void 0 ? void 0 : error.toString());
1142
+ if (error?.name === 'INVALID_STATUS') {
1143
+ this.logger.debug('Error while authenticating the user', error?.toString());
1153
1144
  }
1154
1145
  else {
1155
1146
  // If it fails for any unexpected reason, just pass that through
@@ -1158,9 +1149,8 @@ class Org extends kit_1.AsyncOptionalCreatable {
1158
1149
  }
1159
1150
  }
1160
1151
  validateWaitOptions(options) {
1161
- var _a, _b;
1162
- const wait = (_a = options.wait) !== null && _a !== void 0 ? _a : kit_1.Duration.minutes(30);
1163
- const interval = (_b = options.interval) !== null && _b !== void 0 ? _b : kit_1.Duration.seconds(30);
1152
+ const wait = options.wait ?? kit_1.Duration.minutes(30);
1153
+ const interval = options.interval ?? kit_1.Duration.seconds(30);
1164
1154
  let pollInterval = options.async ? kit_1.Duration.seconds(0) : interval;
1165
1155
  // pollInterval cannot be > wait.
1166
1156
  pollInterval = pollInterval.seconds > wait.seconds ? wait : pollInterval;
@@ -49,7 +49,6 @@ class PermissionSetAssignment {
49
49
  * @param permSetString An array of permission set names.
50
50
  */
51
51
  async create(id, permSetString) {
52
- var _a;
53
52
  if (!id) {
54
53
  throw messages.createError('userIdRequired');
55
54
  }
@@ -62,7 +61,7 @@ class PermissionSetAssignment {
62
61
  query += ` AND NamespacePrefix='${nsPrefix}'`;
63
62
  }
64
63
  const result = await this.org.getConnection().query(query);
65
- const permissionSetId = (_a = result === null || result === void 0 ? void 0 : result.records[0]) === null || _a === void 0 ? void 0 : _a.Id;
64
+ const permissionSetId = result?.records[0]?.Id;
66
65
  if (!permissionSetId) {
67
66
  if (nsPrefix) {
68
67
  throw messages.createError('assignCommandPermissionSetNotFoundForNSError', [permSetName, nsPrefix]);
@@ -56,7 +56,6 @@ const validateRetry = (retry) => {
56
56
  }
57
57
  };
58
58
  const scratchOrgResume = async (jobId) => {
59
- var _a, _b, _c;
60
59
  const [logger, cache] = await Promise.all([
61
60
  logger_1.Logger.child('scratchOrgResume'),
62
61
  scratchOrgCache_1.ScratchOrgCache.create(),
@@ -72,7 +71,7 @@ const scratchOrgResume = async (jobId) => {
72
71
  await (0, scratchOrgErrorCodes_1.validateScratchOrgInfoForResume)({ jobId, scratchOrgInfo: soi, cache, hubUsername });
73
72
  // At this point, the scratch org is "good".
74
73
  // Some hubs have all the usernames set to `null`
75
- const username = (_a = soi.Username) !== null && _a !== void 0 ? _a : soi.SignupUsername;
74
+ const username = soi.Username ?? soi.SignupUsername;
76
75
  // re-auth only if the org isn't in StateAggregator
77
76
  const stateAggregator = await stateAggregator_1.StateAggregator.getInstance();
78
77
  const scratchOrgAuthInfo = (await stateAggregator.orgs.exists(username))
@@ -90,15 +89,17 @@ const scratchOrgResume = async (jobId) => {
90
89
  settingsGenerator.extract({ ...soi, ...definitionjson });
91
90
  const [authInfo] = await Promise.all([
92
91
  (0, scratchOrgInfoApi_1.resolveUrl)(scratchOrgAuthInfo),
93
- (0, scratchOrgInfoApi_1.deploySettings)(scratchOrg, settingsGenerator, (_b = apiVersion !== null && apiVersion !== void 0 ? apiVersion : new configAggregator_1.ConfigAggregator().getPropertyValue('apiVersion')) !== null && _b !== void 0 ? _b : (await scratchOrg.retrieveMaxApiVersion())),
92
+ (0, scratchOrgInfoApi_1.deploySettings)(scratchOrg, settingsGenerator, apiVersion ??
93
+ new configAggregator_1.ConfigAggregator().getPropertyValue('apiVersion') ??
94
+ (await scratchOrg.retrieveMaxApiVersion())),
94
95
  ]);
95
96
  await scratchOrgAuthInfo.handleAliasAndDefaultSettings({
96
97
  alias,
97
- setDefault: setDefault !== null && setDefault !== void 0 ? setDefault : false,
98
+ setDefault: setDefault ?? false,
98
99
  setDefaultDevHub: false,
99
- setTracksSource: tracksSource !== null && tracksSource !== void 0 ? tracksSource : true,
100
+ setTracksSource: tracksSource ?? true,
100
101
  });
101
- cache.unset((_c = soi.Id) !== null && _c !== void 0 ? _c : jobId);
102
+ cache.unset(soi.Id ?? jobId);
102
103
  const authFields = authInfo.getFields();
103
104
  await Promise.all([(0, scratchOrgLifecycleEvents_1.emit)({ stage: 'done', scratchOrgInfo: soi }), cache.write(), (0, scratchOrgLifecycleEvents_1.emitPostOrgCreate)(authFields)]);
104
105
  return {
@@ -111,7 +112,6 @@ const scratchOrgResume = async (jobId) => {
111
112
  };
112
113
  exports.scratchOrgResume = scratchOrgResume;
113
114
  const scratchOrgCreate = async (options) => {
114
- var _a, _b, _c;
115
115
  const logger = await logger_1.Logger.child('scratchOrgCreate');
116
116
  logger.debug('scratchOrgCreate');
117
117
  await (0, scratchOrgLifecycleEvents_1.emit)({ stage: 'prepare request' });
@@ -146,7 +146,7 @@ const scratchOrgCreate = async (options) => {
146
146
  const cache = await scratchOrgCache_1.ScratchOrgCache.create();
147
147
  cache.set(scratchOrgInfoId, {
148
148
  hubUsername: hubOrg.getUsername(),
149
- hubBaseUrl: (_a = hubOrg.getField(org_1.Org.Fields.INSTANCE_URL)) === null || _a === void 0 ? void 0 : _a.toString(),
149
+ hubBaseUrl: hubOrg.getField(org_1.Org.Fields.INSTANCE_URL)?.toString(),
150
150
  definitionjson: { ...(definitionjson ? JSON.parse(definitionjson) : {}), ...orgConfig, ...settings },
151
151
  clientSecret,
152
152
  alias,
@@ -174,14 +174,16 @@ const scratchOrgCreate = async (options) => {
174
174
  });
175
175
  // we'll need this scratch org connection later;
176
176
  const scratchOrg = await org_1.Org.create({
177
- aliasOrUsername: (_b = soi.Username) !== null && _b !== void 0 ? _b : soi.SignupUsername,
177
+ aliasOrUsername: soi.Username ?? soi.SignupUsername,
178
178
  });
179
179
  const username = scratchOrg.getUsername();
180
180
  logger.debug(`scratch org username ${username}`);
181
181
  await (0, scratchOrgLifecycleEvents_1.emit)({ stage: 'deploy settings', scratchOrgInfo: soi });
182
182
  const [authInfo] = await Promise.all([
183
183
  (0, scratchOrgInfoApi_1.resolveUrl)(scratchOrgAuthInfo),
184
- (0, scratchOrgInfoApi_1.deploySettings)(scratchOrg, settingsGenerator, (_c = apiversion !== null && apiversion !== void 0 ? apiversion : new configAggregator_1.ConfigAggregator().getPropertyValue('org-api-version')) !== null && _c !== void 0 ? _c : (await scratchOrg.retrieveMaxApiVersion())),
184
+ (0, scratchOrgInfoApi_1.deploySettings)(scratchOrg, settingsGenerator, apiversion ??
185
+ new configAggregator_1.ConfigAggregator().getPropertyValue('org-api-version') ??
186
+ (await scratchOrg.retrieveMaxApiVersion())),
185
187
  ]);
186
188
  await scratchOrgAuthInfo.handleAliasAndDefaultSettings({
187
189
  ...{
@@ -198,7 +200,7 @@ const scratchOrgCreate = async (options) => {
198
200
  username,
199
201
  scratchOrgInfo: soi,
200
202
  authInfo,
201
- authFields: authInfo === null || authInfo === void 0 ? void 0 : authInfo.getFields(),
203
+ authFields: authInfo?.getFields(),
202
204
  warnings,
203
205
  };
204
206
  };
@@ -46,7 +46,7 @@ const getOrgInstanceAuthority = function (scratchOrgInfoComplete, hubOrgLoginUrl
46
46
  // For Falcon sandboxes, try the LoginURL instead; createdOrgInstance will not yield a valid URL
47
47
  altUrl = scratchOrgInfoComplete.LoginUrl;
48
48
  }
49
- return signupTargetLoginUrlConfig !== null && signupTargetLoginUrlConfig !== void 0 ? signupTargetLoginUrlConfig : altUrl;
49
+ return signupTargetLoginUrlConfig ?? altUrl;
50
50
  };
51
51
  /**
52
52
  * Returns OAuth2Options object
@@ -63,7 +63,7 @@ const buildOAuth2Options = async (options) => {
63
63
  logger.debug(`isJwtFlow: ${isJwtFlow}`);
64
64
  if (isJwtFlow && !process.env.SFDX_CLIENT_SECRET) {
65
65
  oauth2Options.privateKeyFile = options.hubOrg.getConnection().getAuthInfoFields().privateKey;
66
- const retries = (options === null || options === void 0 ? void 0 : options.retry) || kit_1.env.getNumber('SFDX_JWT_AUTH_RETRY_ATTEMPTS') || 0;
66
+ const retries = options?.retry || kit_1.env.getNumber('SFDX_JWT_AUTH_RETRY_ATTEMPTS') || 0;
67
67
  const timeoutInSeconds = kit_1.env.getNumber('SFDX_JWT_AUTH_RETRY_TIMEOUT') || 300;
68
68
  const timeout = kit_1.Duration.seconds(timeoutInSeconds).milliseconds;
69
69
  const delay = retries ? timeout / retries : 1000;
@@ -153,7 +153,6 @@ exports.queryScratchOrgInfo = queryScratchOrgInfo;
153
153
  * @returns {Promise<AuthInfo>}
154
154
  */
155
155
  const authorizeScratchOrg = async (options) => {
156
- var _a;
157
156
  const { scratchOrgInfoComplete, hubOrg, clientSecret, signupTargetLoginUrlConfig, retry } = options;
158
157
  await (0, scratchOrgLifecycleEvents_1.emit)({ stage: 'authenticate', scratchOrgInfo: scratchOrgInfoComplete });
159
158
  const logger = await logger_1.Logger.child('authorizeScratchOrg');
@@ -179,7 +178,7 @@ const authorizeScratchOrg = async (options) => {
179
178
  });
180
179
  await authInfo.save({
181
180
  devHubUsername: hubOrg.getUsername(),
182
- created: new Date((_a = scratchOrgInfoComplete.CreatedDate) !== null && _a !== void 0 ? _a : new Date()).valueOf().toString(),
181
+ created: new Date(scratchOrgInfoComplete.CreatedDate ?? new Date()).valueOf().toString(),
183
182
  expirationDate: scratchOrgInfoComplete.ExpirationDate,
184
183
  clientId: scratchOrgInfoComplete.ConnectedAppConsumerKey,
185
184
  createdOrgInstance: scratchOrgInfoComplete.SignupInstance,
@@ -65,7 +65,6 @@ const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
65
65
  return '';
66
66
  }
67
67
  const ancestorIds = await Promise.all(packagesWithAncestors.map(async (packageDir) => {
68
- var _a, _b, _c;
69
68
  // ancestorID can be 05i, or 04t, alias; OR "ancestorVersion": "4.6.0.1"
70
69
  // according to docs, 05i is not ok: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev2gp_config_file.htm
71
70
  if (packageDir.ancestorVersion) {
@@ -74,7 +73,7 @@ const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
74
73
  }
75
74
  // package can be an ID, but not according to docs
76
75
  const packageAliases = projectJson.get('packageAliases');
77
- const packageId = (_a = packageAliases[(0, ts_types_1.ensureString)(packageDir.package)]) !== null && _a !== void 0 ? _a : packageDir.package;
76
+ const packageId = packageAliases[(0, ts_types_1.ensureString)(packageDir.package)] ?? packageDir.package;
78
77
  const [major, minor, patch] = packageDir.ancestorVersion.split('.');
79
78
  let releasedAncestor;
80
79
  try {
@@ -93,11 +92,11 @@ const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
93
92
  }
94
93
  return releasedAncestor.Id;
95
94
  }
96
- if ((_b = packageDir === null || packageDir === void 0 ? void 0 : packageDir.ancestorId) === null || _b === void 0 ? void 0 : _b.startsWith('05i')) {
95
+ if (packageDir?.ancestorId?.startsWith('05i')) {
97
96
  // if it's already a 05i return it, otherwise query for it
98
97
  return packageDir.ancestorId;
99
98
  }
100
- if ((_c = packageDir === null || packageDir === void 0 ? void 0 : packageDir.ancestorId) === null || _c === void 0 ? void 0 : _c.startsWith('04t')) {
99
+ if (packageDir?.ancestorId?.startsWith('04t')) {
101
100
  // query for the Id
102
101
  return (await hubOrg
103
102
  .getConnection()
@@ -105,7 +104,7 @@ const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
105
104
  }
106
105
  // ancestorID can be an alias get it from projectJson
107
106
  const packageAliases = projectJson.get('packageAliases');
108
- if (packageDir.ancestorId && (packageAliases === null || packageAliases === void 0 ? void 0 : packageAliases[packageDir.ancestorId])) {
107
+ if (packageDir.ancestorId && packageAliases?.[packageDir.ancestorId]) {
109
108
  return packageAliases[packageDir.ancestorId];
110
109
  }
111
110
  throw new sfError_1.SfError(`Invalid ancestorId ${packageDir.ancestorId}`, 'InvalidAncestorId');
@@ -122,7 +121,6 @@ exports.getAncestorIds = getAncestorIds;
122
121
  * @param ignoreAncestorIds true if the sfdx-project.json ancestorId keys should be ignored
123
122
  */
124
123
  const generateScratchOrgInfo = async ({ hubOrg, scratchOrgInfoPayload, nonamespace, ignoreAncestorIds, }) => {
125
- var _a, _b;
126
124
  let sfProject;
127
125
  try {
128
126
  sfProject = await sfProject_1.SfProjectJson.create({});
@@ -130,17 +128,17 @@ const generateScratchOrgInfo = async ({ hubOrg, scratchOrgInfoPayload, nonamespa
130
128
  catch (e) {
131
129
  // project is not required
132
130
  }
133
- scratchOrgInfoPayload.orgName = (_a = scratchOrgInfoPayload.orgName) !== null && _a !== void 0 ? _a : 'Company';
131
+ scratchOrgInfoPayload.orgName = scratchOrgInfoPayload.orgName ?? 'Company';
134
132
  scratchOrgInfoPayload.package2AncestorIds =
135
- !ignoreAncestorIds && (sfProject === null || sfProject === void 0 ? void 0 : sfProject.hasPackages())
133
+ !ignoreAncestorIds && sfProject?.hasPackages()
136
134
  ? await (0, exports.getAncestorIds)(scratchOrgInfoPayload, sfProject, hubOrg)
137
135
  : '';
138
136
  // Use the Hub org's client ID value, if one wasn't provided to us, or the default
139
137
  if (!scratchOrgInfoPayload.connectedAppConsumerKey) {
140
138
  scratchOrgInfoPayload.connectedAppConsumerKey =
141
- (_b = hubOrg.getConnection().getAuthInfoFields().clientId) !== null && _b !== void 0 ? _b : defaultConnectedAppInfo.clientId;
139
+ hubOrg.getConnection().getAuthInfoFields().clientId ?? defaultConnectedAppInfo.clientId;
142
140
  }
143
- if (!nonamespace && (sfProject === null || sfProject === void 0 ? void 0 : sfProject.get('namespace'))) {
141
+ if (!nonamespace && sfProject?.get('namespace')) {
144
142
  scratchOrgInfoPayload.namespace = sfProject.get('namespace');
145
143
  }
146
144
  // we already have the info, and want to get rid of configApi, so this doesn't use that
@@ -164,11 +162,10 @@ exports.generateScratchOrgInfo = generateScratchOrgInfo;
164
162
  warnings: string[];
165
163
  */
166
164
  const getScratchOrgInfoPayload = async (options) => {
167
- var _a;
168
165
  let warnings = [];
169
166
  // orgConfig input overrides definitionjson (-j option; hidden/deprecated)
170
167
  const definitionJson = options.definitionjson ? JSON.parse(options.definitionjson) : {};
171
- const orgConfigInput = { ...definitionJson, ...((_a = options.orgConfig) !== null && _a !== void 0 ? _a : {}) };
168
+ const orgConfigInput = { ...definitionJson, ...(options.orgConfig ?? {}) };
172
169
  let scratchOrgInfoPayload = orgConfigInput;
173
170
  // the -f option
174
171
  if (options.definitionfile) {
@@ -141,11 +141,11 @@ class SettingsGenerator {
141
141
  this.allBusinessProcesses = [];
142
142
  this.logger = logger_1.Logger.childFromRoot('SettingsGenerator');
143
143
  // If SFDX_MDAPI_TEMP_DIR is set, copy settings to that dir for people to inspect.
144
- const mdApiTmpDir = (options === null || options === void 0 ? void 0 : options.mdApiTmpDir) || kit_1.env.getString('SFDX_MDAPI_TEMP_DIR');
145
- this.shapeDirName = (options === null || options === void 0 ? void 0 : options.shapeDirName) || `shape_${Date.now()}`;
144
+ const mdApiTmpDir = options?.mdApiTmpDir || kit_1.env.getString('SFDX_MDAPI_TEMP_DIR');
145
+ this.shapeDirName = options?.shapeDirName || `shape_${Date.now()}`;
146
146
  this.packageFilePath = path.join(this.shapeDirName, 'package.xml');
147
147
  let storePath;
148
- if (!(options === null || options === void 0 ? void 0 : options.asDirectory)) {
148
+ if (!options?.asDirectory) {
149
149
  storePath = mdApiTmpDir ? path.join(mdApiTmpDir, `${this.shapeDirName}.zip`) : undefined;
150
150
  this.writer = new zipWriter_1.ZipWriter(storePath);
151
151
  }
package/lib/org/user.js CHANGED
@@ -225,10 +225,10 @@ class User extends kit_1.AsyncCreatable {
225
225
  this.logger.debug(`Attempting to set password for userId: ${info.getFields().userId} username: ${info.getFields().username}`);
226
226
  const userConnection = await connection_1.Connection.create({ authInfo: info });
227
227
  return new Promise((resolve, reject) => {
228
+ // no promises in async method
228
229
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
229
230
  password.value(async (buffer) => {
230
231
  try {
231
- // @ts-ignore TODO: expose `soap` on Connection however appropriate
232
232
  const soap = userConnection.soap;
233
233
  await soap.setPassword((0, ts_types_1.ensureString)(info.getFields().userId), buffer.toString('utf8'));
234
234
  this.logger.debug(`Set password for userId: ${info.getFields().userId}`);
@@ -293,7 +293,6 @@ class User extends kit_1.AsyncCreatable {
293
293
  * ```
294
294
  */
295
295
  async createUser(fields) {
296
- var _a;
297
296
  // Create a user and get a refresh token
298
297
  const refreshTokenSecret = await this.createUserInternal(fields);
299
298
  // Create the initial auth info
@@ -302,7 +301,7 @@ class User extends kit_1.AsyncCreatable {
302
301
  // Setup oauth options for the new user
303
302
  const oauthOptions = {
304
303
  // Communities users require the instance for auth
305
- loginUrl: (_a = adminUserAuthFields.instanceUrl) !== null && _a !== void 0 ? _a : adminUserAuthFields.loginUrl,
304
+ loginUrl: adminUserAuthFields.instanceUrl ?? adminUserAuthFields.loginUrl,
306
305
  refreshToken: refreshTokenSecret.buffer.value((buffer) => buffer.toString('utf8')),
307
306
  clientId: adminUserAuthFields.clientId,
308
307
  clientSecret: adminUserAuthFields.clientSecret,
package/lib/sfProject.js CHANGED
@@ -525,7 +525,6 @@ class SfProject {
525
525
  * properties, including some 3rd party custom properties.
526
526
  */
527
527
  async resolveProjectConfig() {
528
- var _a;
529
528
  if (!this.projectConfig) {
530
529
  // Do fs operations in parallel
531
530
  const [global, local, configAggregator] = await Promise.all([
@@ -539,7 +538,7 @@ class SfProject {
539
538
  Object.assign(this.projectConfig, configAggregator.getConfig());
540
539
  // we don't have a login url yet, so use instanceUrl from config or default
541
540
  if (!this.projectConfig.sfdcLoginUrl) {
542
- this.projectConfig.sfdcLoginUrl = (_a = configAggregator.getConfig()['org-instance-url']) !== null && _a !== void 0 ? _a : sfdcUrl_1.SfdcUrl.PRODUCTION;
541
+ this.projectConfig.sfdcLoginUrl = configAggregator.getConfig()['org-instance-url'] ?? sfdcUrl_1.SfdcUrl.PRODUCTION;
543
542
  }
544
543
  // LEGACY - Allow override of sfdcLoginUrl via env var FORCE_SFDC_LOGIN_URL
545
544
  if (process.env.FORCE_SFDC_LOGIN_URL) {
@@ -36,8 +36,7 @@ class GlobalInfoAliasAccessor {
36
36
  * @param entity the aliasable entity that you want to get the alias of
37
37
  */
38
38
  get(entity) {
39
- var _a;
40
- return (_a = this.getAll(entity).find((alias) => alias)) !== null && _a !== void 0 ? _a : null;
39
+ return this.getAll(entity).find((alias) => alias) ?? null;
41
40
  }
42
41
  /**
43
42
  * Returns the value that corresponds to the given alias if it exists
@@ -45,8 +44,7 @@ class GlobalInfoAliasAccessor {
45
44
  * @param alias the alias that corresponds to a value
46
45
  */
47
46
  getValue(alias) {
48
- var _a;
49
- return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
47
+ return this.getAll()[alias] ?? null;
50
48
  }
51
49
  /**
52
50
  * Returns the username that corresponds to the given alias if it exists
@@ -54,8 +52,7 @@ class GlobalInfoAliasAccessor {
54
52
  * @param alias the alias that corresponds to a username
55
53
  */
56
54
  getUsername(alias) {
57
- var _a;
58
- return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
55
+ return this.getAll()[alias] ?? null;
59
56
  }
60
57
  /**
61
58
  * If the provided string is an alias, it returns the corresponding value.
@@ -68,8 +65,7 @@ class GlobalInfoAliasAccessor {
68
65
  * @param valueOrAlias a string that might be a value or might be an alias
69
66
  */
70
67
  resolveValue(valueOrAlias) {
71
- var _a;
72
- return (_a = this.getValue(valueOrAlias)) !== null && _a !== void 0 ? _a : valueOrAlias;
68
+ return this.getValue(valueOrAlias) ?? valueOrAlias;
73
69
  }
74
70
  /**
75
71
  * If the provided string is an alias, it returns the corresponding username.
@@ -82,8 +78,7 @@ class GlobalInfoAliasAccessor {
82
78
  * @param usernameOrAlias a string that might be a username or might be an alias
83
79
  */
84
80
  resolveUsername(usernameOrAlias) {
85
- var _a;
86
- return (_a = this.getUsername(usernameOrAlias)) !== null && _a !== void 0 ? _a : usernameOrAlias;
81
+ return this.getUsername(usernameOrAlias) ?? usernameOrAlias;
87
82
  }
88
83
  /**
89
84
  * Set an alias for the given aliasable entity
@@ -121,10 +116,9 @@ class GlobalInfoAliasAccessor {
121
116
  * Returns the username of given aliasable entity
122
117
  */
123
118
  getNameOf(entity) {
124
- var _a;
125
119
  if (typeof entity === 'string')
126
120
  return entity;
127
- const aliaseeName = (_a = entity.username) !== null && _a !== void 0 ? _a : entity.user;
121
+ const aliaseeName = entity.username ?? entity.user;
128
122
  if (!aliaseeName) {
129
123
  throw new sfError_1.SfError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
130
124
  }
@@ -153,8 +147,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
153
147
  * @param entity the aliasable entity that you want to get the alias of
154
148
  */
155
149
  get(entity) {
156
- var _a;
157
- return (_a = this.getAll(entity).find((alias) => alias)) !== null && _a !== void 0 ? _a : null;
150
+ return this.getAll(entity).find((alias) => alias) ?? null;
158
151
  }
159
152
  /**
160
153
  * Returns the value that corresponds to the given alias if it exists
@@ -162,8 +155,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
162
155
  * @param alias the alias that corresponds to a value
163
156
  */
164
157
  getValue(alias) {
165
- var _a;
166
- return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
158
+ return this.getAll()[alias] ?? null;
167
159
  }
168
160
  /**
169
161
  * Returns the username that corresponds to the given alias if it exists
@@ -171,8 +163,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
171
163
  * @param alias the alias that corresponds to a username
172
164
  */
173
165
  getUsername(alias) {
174
- var _a;
175
- return (_a = this.getAll()[alias]) !== null && _a !== void 0 ? _a : null;
166
+ return this.getAll()[alias] ?? null;
176
167
  }
177
168
  /**
178
169
  * If the provided string is an alias, it returns the corresponding value.
@@ -185,8 +176,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
185
176
  * @param valueOrAlias a string that might be a value or might be an alias
186
177
  */
187
178
  resolveValue(valueOrAlias) {
188
- var _a;
189
- return (_a = this.getValue(valueOrAlias)) !== null && _a !== void 0 ? _a : valueOrAlias;
179
+ return this.getValue(valueOrAlias) ?? valueOrAlias;
190
180
  }
191
181
  /**
192
182
  * If the provided string is an alias, it returns the corresponding username.
@@ -199,8 +189,7 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
199
189
  * @param usernameOrAlias a string that might be a username or might be an alias
200
190
  */
201
191
  resolveUsername(usernameOrAlias) {
202
- var _a;
203
- return (_a = this.getUsername(usernameOrAlias)) !== null && _a !== void 0 ? _a : usernameOrAlias;
192
+ return this.getUsername(usernameOrAlias) ?? usernameOrAlias;
204
193
  }
205
194
  /**
206
195
  * If the provided string is an alias, return it.
@@ -212,10 +201,9 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
212
201
  * @param usernameOrAlias a string that might be a username or might be an alias
213
202
  */
214
203
  resolveAlias(usernameOrAlias) {
215
- var _a;
216
204
  if (this.has(usernameOrAlias))
217
205
  return usernameOrAlias;
218
- return (_a = Object.entries(this.getAll()).find(([, username]) => username === usernameOrAlias)) === null || _a === void 0 ? void 0 : _a[0];
206
+ return Object.entries(this.getAll()).find(([, username]) => username === usernameOrAlias)?.[0];
219
207
  }
220
208
  /**
221
209
  * Set an alias for the given aliasable entity
@@ -260,10 +248,9 @@ class AliasAccessor extends kit_1.AsyncOptionalCreatable {
260
248
  * Returns the username of given aliasable entity
261
249
  */
262
250
  getNameOf(entity) {
263
- var _a;
264
251
  if (typeof entity === 'string')
265
252
  return entity;
266
- const aliaseeName = (_a = entity.username) !== null && _a !== void 0 ? _a : entity.user;
253
+ const aliaseeName = entity.username ?? entity.user;
267
254
  if (!aliaseeName) {
268
255
  throw new sfError_1.SfError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
269
256
  }
@@ -35,15 +35,13 @@ class GlobalInfoOrgAccessor {
35
35
  return !!this.getAll()[username];
36
36
  }
37
37
  set(username, org) {
38
- var _a;
39
38
  // For legacy, and to keep things standard, some things wants the username in auth info.
40
- (_a = org.username) !== null && _a !== void 0 ? _a : (org.username = username);
39
+ org.username ?? (org.username = username);
41
40
  this.globalInfo.set(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
42
41
  }
43
42
  update(username, org) {
44
- var _a;
45
43
  // For legacy, and to keep things standard, some things wants the username in auth info.
46
- (_a = org.username) !== null && _a !== void 0 ? _a : (org.username = username);
44
+ org.username ?? (org.username = username);
47
45
  this.globalInfo.update(`${types_1.SfInfoKeys.ORGS}["${username}"]`, org);
48
46
  }
49
47
  unset(username) {
@@ -176,17 +174,16 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
176
174
  * @param org
177
175
  */
178
176
  set(username, org) {
179
- var _a, _b;
180
177
  const config = this.configs.get(username);
181
178
  if (config) {
182
179
  config.setContentsFromObject(org);
183
180
  const contents = config.getContents();
184
- (_a = contents.username) !== null && _a !== void 0 ? _a : (contents.username = username);
181
+ contents.username ?? (contents.username = username);
185
182
  this.contents.set(username, contents);
186
183
  }
187
184
  else {
188
185
  // @ts-ignore
189
- (_b = org.username) !== null && _b !== void 0 ? _b : (org.username = username);
186
+ org.username ?? (org.username = username);
190
187
  this.contents.set(username, org);
191
188
  }
192
189
  }
@@ -207,8 +204,7 @@ class BaseOrgAccessor extends kit_1.AsyncOptionalCreatable {
207
204
  * @param username
208
205
  */
209
206
  async remove(username) {
210
- var _a;
211
- await ((_a = this.configs.get(username)) === null || _a === void 0 ? void 0 : _a.unlink());
207
+ await this.configs.get(username)?.unlink();
212
208
  this.configs.delete(username);
213
209
  this.contents.delete(username);
214
210
  }