@salesforce/core 3.7.6 → 3.7.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +4 -4
  3. package/lib/config/config.d.ts +7 -5
  4. package/lib/config/config.js +14 -9
  5. package/lib/config/configAggregator.d.ts +2 -2
  6. package/lib/config/configAggregator.js +2 -2
  7. package/lib/config/configFile.d.ts +2 -2
  8. package/lib/config/configFile.js +22 -20
  9. package/lib/config/configStore.js +5 -5
  10. package/lib/config/keychainConfig.js +4 -3
  11. package/lib/crypto/keyChainImpl.js +12 -10
  12. package/lib/deviceOauthService.js +2 -2
  13. package/lib/exported.d.ts +3 -4
  14. package/lib/exported.js +9 -7
  15. package/lib/global.js +2 -2
  16. package/lib/globalInfo/accessors/aliasAccessor.js +2 -2
  17. package/lib/globalInfo/sfdxDataHandler.d.ts +1 -1
  18. package/lib/globalInfo/sfdxDataHandler.js +5 -4
  19. package/lib/logger.d.ts +3 -3
  20. package/lib/logger.js +21 -19
  21. package/lib/messages.d.ts +42 -3
  22. package/lib/messages.js +55 -12
  23. package/lib/org/authInfo.d.ts +1 -1
  24. package/lib/org/authInfo.js +6 -6
  25. package/lib/org/authRemover.d.ts +2 -2
  26. package/lib/org/authRemover.js +2 -2
  27. package/lib/org/connection.d.ts +1 -1
  28. package/lib/org/connection.js +4 -4
  29. package/lib/org/org.d.ts +4 -4
  30. package/lib/org/org.js +16 -16
  31. package/lib/org/permissionSetAssignment.js +2 -2
  32. package/lib/org/scratchOrgCreate.js +4 -4
  33. package/lib/org/scratchOrgErrorCodes.js +6 -6
  34. package/lib/org/scratchOrgInfoApi.js +16 -16
  35. package/lib/org/scratchOrgInfoGenerator.d.ts +3 -3
  36. package/lib/org/scratchOrgInfoGenerator.js +17 -17
  37. package/lib/org/scratchOrgSettingsGenerator.js +2 -2
  38. package/lib/org/user.js +4 -4
  39. package/lib/schema/printer.js +2 -2
  40. package/lib/schema/validator.d.ts +4 -4
  41. package/lib/schema/validator.js +13 -13
  42. package/lib/{sfdxError.d.ts → sfError.d.ts} +14 -14
  43. package/lib/{sfdxError.js → sfError.js} +20 -21
  44. package/lib/{sfdxProject.d.ts → sfProject.d.ts} +37 -27
  45. package/lib/{sfdxProject.js → sfProject.js} +77 -65
  46. package/lib/status/pollingClient.js +3 -3
  47. package/lib/status/streamingClient.d.ts +2 -2
  48. package/lib/status/streamingClient.js +6 -6
  49. package/lib/testSetup.d.ts +4 -4
  50. package/lib/testSetup.js +8 -8
  51. package/lib/util/internal.d.ts +28 -2
  52. package/lib/util/internal.js +64 -6
  53. package/lib/util/sfdcUrl.d.ts +2 -2
  54. package/lib/util/sfdcUrl.js +2 -2
  55. package/lib/webOAuthServer.js +10 -10
  56. package/package.json +5 -5
  57. package/lib/util/fs.d.ts +0 -201
  58. package/lib/util/fs.js +0 -378
package/lib/org/org.js CHANGED
@@ -8,6 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.Org = exports.SandboxEvents = exports.OrgTypes = void 0;
10
10
  const path_1 = require("path");
11
+ const fs = require("fs");
11
12
  const kit_1 = require("@salesforce/kit");
12
13
  const ts_types_1 = require("@salesforce/ts-types");
13
14
  const config_1 = require("../config/config");
@@ -17,8 +18,7 @@ const sandboxOrgConfig_1 = require("../config/sandboxOrgConfig");
17
18
  const global_1 = require("../global");
18
19
  const lifecycleEvents_1 = require("../lifecycleEvents");
19
20
  const logger_1 = require("../logger");
20
- const sfdxError_1 = require("../sfdxError");
21
- const fs_1 = require("../util/fs");
21
+ const sfError_1 = require("../sfError");
22
22
  const sfdc_1 = require("../util/sfdc");
23
23
  const webOAuthServer_1 = require("../webOAuthServer");
24
24
  const messages_1 = require("../messages");
@@ -147,7 +147,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
147
147
  }
148
148
  throw err;
149
149
  }
150
- return this.manageDelete(async () => await fs_1.fs.remove(dataPath), dataPath, throwWhenRemoveFails);
150
+ return this.manageDelete(async () => await fs.promises.rmdir(dataPath), dataPath, throwWhenRemoveFails);
151
151
  }
152
152
  /**
153
153
  * @ignore
@@ -187,9 +187,9 @@ class Org extends kit_1.AsyncOptionalCreatable {
187
187
  /**
188
188
  * Check that this org is a scratch org by asking the dev hub if it knows about it.
189
189
  *
190
- * **Throws** *{@link SfdxError}{ name: 'NotADevHubError' }* Not a Dev Hub.
190
+ * **Throws** *{@link SfError}{ name: 'NotADevHubError' }* Not a Dev Hub.
191
191
  *
192
- * **Throws** *{@link SfdxError}{ name: 'NoResultsError' }* No results.
192
+ * **Throws** *{@link SfError}{ name: 'NoResultsError' }* No results.
193
193
  *
194
194
  * @param devHubUsernameOrAlias The username or alias of the dev hub org.
195
195
  */
@@ -205,7 +205,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
205
205
  try {
206
206
  const results = await devHubConnection.query(DEV_HUB_SOQL);
207
207
  if ((0, ts_types_1.getNumber)(results, 'records.length') !== 1) {
208
- throw new sfdxError_1.SfdxError('No results', 'NoResultsError');
208
+ throw new sfError_1.SfError('No results', 'NoResultsError');
209
209
  }
210
210
  }
211
211
  catch (err) {
@@ -440,7 +440,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
440
440
  */
441
441
  async addUsername(auth) {
442
442
  if (!auth) {
443
- throw new sfdxError_1.SfdxError('Missing auth info', 'MissingAuthInfo');
443
+ throw new sfError_1.SfError('Missing auth info', 'MissingAuthInfo');
444
444
  }
445
445
  const authInfo = (0, ts_types_1.isString)(auth) ? await authInfo_1.AuthInfo.create({ username: auth }) : auth;
446
446
  this.logger.debug(`adding username ${authInfo.getFields().username}`);
@@ -450,7 +450,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
450
450
  // needs config refactoring to improve
451
451
  const usernames = contents.usernames || [];
452
452
  if (!(0, ts_types_1.isArray)(usernames)) {
453
- throw new sfdxError_1.SfdxError('Usernames is not an array', 'UnexpectedDataFormat');
453
+ throw new sfError_1.SfError('Usernames is not an array', 'UnexpectedDataFormat');
454
454
  }
455
455
  let shouldUpdate = false;
456
456
  const thisUsername = (0, ts_types_1.ensure)(this.getUsername());
@@ -472,13 +472,13 @@ class Org extends kit_1.AsyncOptionalCreatable {
472
472
  /**
473
473
  * Removes a username from the user config for this object. For convenience `this` object is returned.
474
474
  *
475
- * **Throws** *{@link SfdxError}{ name: 'MissingAuthInfoError' }* Auth info is missing.
475
+ * **Throws** *{@link SfError}{ name: 'MissingAuthInfoError' }* Auth info is missing.
476
476
  *
477
477
  * @param {AuthInfo | string} auth The AuthInfo containing the username to remove.
478
478
  */
479
479
  async removeUsername(auth) {
480
480
  if (!auth) {
481
- throw new sfdxError_1.SfdxError('Missing auth info', 'MissingAuthInfoError');
481
+ throw new sfError_1.SfError('Missing auth info', 'MissingAuthInfoError');
482
482
  }
483
483
  const authInfo = (0, ts_types_1.isString)(auth) ? await authInfo_1.AuthInfo.create({ username: auth }) : auth;
484
484
  this.logger.debug(`removing username ${authInfo.getFields().username}`);
@@ -586,7 +586,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
586
586
  throw messages.createError('noUsernameFound');
587
587
  }
588
588
  this.connection = await connection_1.Connection.create({
589
- // If no username is provided or resolvable from an alias, AuthInfo will throw an SfdxError.
589
+ // If no username is provided or resolvable from an alias, AuthInfo will throw an SfError.
590
590
  authInfo: await authInfo_1.AuthInfo.create({ username, isDevHub: this.options.isDevHub }),
591
591
  });
592
592
  }
@@ -596,10 +596,10 @@ class Org extends kit_1.AsyncOptionalCreatable {
596
596
  this.orgId = this.getField(Org.Fields.ORG_ID);
597
597
  }
598
598
  /**
599
- * **Throws** *{@link SfdxError}{ name: 'NotSupportedError' }* Throws an unsupported error.
599
+ * **Throws** *{@link SfError}{ name: 'NotSupportedError' }* Throws an unsupported error.
600
600
  */
601
601
  getDefaultOptions() {
602
- throw new sfdxError_1.SfdxError('Not Supported', 'NotSupportedError');
602
+ throw new sfError_1.SfError('Not Supported', 'NotSupportedError');
603
603
  }
604
604
  async queryProduction(org, field, value) {
605
605
  return org.connection.singleRecordQuery(`SELECT SandboxInfoId FROM SandboxProcess WHERE ${field} ='${value}' AND Status NOT IN ('D', 'E')`, { tooling: true });
@@ -850,11 +850,11 @@ class Org extends kit_1.AsyncOptionalCreatable {
850
850
  catch (err) {
851
851
  const error = err;
852
852
  this.logger.debug('Exception while calling writeSandboxAuthFile %s', err);
853
- 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"))) {
853
+ 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"))) {
854
854
  waitingOnAuth = true;
855
855
  }
856
856
  else {
857
- throw sfdxError_1.SfdxError.wrap(error);
857
+ throw sfError_1.SfError.wrap(error);
858
858
  }
859
859
  }
860
860
  }
@@ -946,7 +946,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
946
946
  }
947
947
  else {
948
948
  // If it fails for any unexpected reason, just pass that through
949
- throw sfdxError_1.SfdxError.wrap(error);
949
+ throw sfError_1.SfError.wrap(error);
950
950
  }
951
951
  }
952
952
  }
@@ -12,7 +12,7 @@ const kit_1 = require("@salesforce/kit");
12
12
  const ts_types_1 = require("@salesforce/ts-types");
13
13
  const logger_1 = require("../logger");
14
14
  const messages_1 = require("../messages");
15
- const sfdxError_1 = require("../sfdxError");
15
+ const sfError_1 = require("../sfError");
16
16
  messages_1.Messages.importMessagesDirectory(__dirname);
17
17
  const messages = messages_1.Messages.load('@salesforce/core', 'permissionSetAssignment', [
18
18
  'errorsEncounteredCreatingAssignment',
@@ -86,7 +86,7 @@ class PermissionSetAssignment {
86
86
  errors.forEach((_message) => {
87
87
  message = `${message}${_message}${os_1.EOL}`;
88
88
  });
89
- throw new sfdxError_1.SfdxError(message, 'errorsEncounteredCreatingAssignment');
89
+ throw new sfError_1.SfError(message, 'errorsEncounteredCreatingAssignment');
90
90
  }
91
91
  else {
92
92
  throw messages.createError('notSuccessfulButNoErrorsReported');
@@ -12,8 +12,8 @@ const ts_types_1 = require("@salesforce/ts-types");
12
12
  const messages_1 = require("../messages");
13
13
  const logger_1 = require("../logger");
14
14
  const configAggregator_1 = require("../config/configAggregator");
15
- const sfdxProject_1 = require("../sfdxProject");
16
- const sfdxError_1 = require("../sfdxError");
15
+ const sfProject_1 = require("../sfProject");
16
+ const sfError_1 = require("../sfError");
17
17
  const org_1 = require("./org");
18
18
  const scratchOrgInfoApi_1 = require("./scratchOrgInfoApi");
19
19
  const scratchOrgSettingsGenerator_1 = require("./scratchOrgSettingsGenerator");
@@ -115,7 +115,7 @@ const scratchOrgCreate = async (options) => {
115
115
  exports.scratchOrgCreate = scratchOrgCreate;
116
116
  const getSignupTargetLoginUrl = async () => {
117
117
  try {
118
- const project = await sfdxProject_1.SfdxProject.resolve();
118
+ const project = await sfProject_1.SfProject.resolve();
119
119
  const projectJson = await project.resolveProjectConfig();
120
120
  return projectJson.signupTargetLoginUrl;
121
121
  }
@@ -136,7 +136,7 @@ const updateRevisionCounterToZero = async (scratchOrg) => {
136
136
  scratchOrg.getOrgId(),
137
137
  scratchOrg.getUsername(),
138
138
  ]);
139
- throw new sfdxError_1.SfdxError(message, 'SourceStatusResetFailure');
139
+ throw new sfError_1.SfError(message, 'SourceStatusResetFailure');
140
140
  }
141
141
  };
142
142
  //# sourceMappingURL=scratchOrgCreate.js.map
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.checkScratchOrgInfoForErrors = void 0;
10
10
  const messages_1 = require("../messages");
11
- const sfdxError_1 = require("../sfdxError");
11
+ const sfError_1 = require("../sfError");
12
12
  const WORKSPACE_CONFIG_FILENAME = 'sfdx-project.json';
13
13
  messages_1.Messages.importMessagesDirectory(__dirname);
14
14
  const messages = messages_1.Messages.loadMessages('@salesforce/core', 'scratchOrgErrorCodes');
@@ -36,7 +36,7 @@ const optionalErrorCodeMessage = (errorCode, args) => {
36
36
  };
37
37
  const checkScratchOrgInfoForErrors = (orgInfo, hubUsername, logger) => {
38
38
  if (!orgInfo) {
39
- throw new sfdxError_1.SfdxError('No scratch org info found.', 'ScratchOrgInfoNotFound');
39
+ throw new sfError_1.SfError('No scratch org info found.', 'ScratchOrgInfoNotFound');
40
40
  }
41
41
  if (orgInfo.Status === 'Active') {
42
42
  return orgInfo;
@@ -44,19 +44,19 @@ const checkScratchOrgInfoForErrors = (orgInfo, hubUsername, logger) => {
44
44
  if (orgInfo.Status === 'Error' && orgInfo.ErrorCode) {
45
45
  const message = optionalErrorCodeMessage(orgInfo.ErrorCode, [WORKSPACE_CONFIG_FILENAME]);
46
46
  if (message) {
47
- throw new sfdxError_1.SfdxError(message, 'RemoteOrgSignupFailed', [
47
+ throw new sfError_1.SfError(message, 'RemoteOrgSignupFailed', [
48
48
  namedMessages.getMessage('SignupFailedActionError', [orgInfo.ErrorCode]),
49
49
  ]);
50
50
  }
51
- throw new sfdxError_1.SfdxError(namedMessages.getMessage('SignupFailedError', [orgInfo.ErrorCode]));
51
+ throw new sfError_1.SfError(namedMessages.getMessage('SignupFailedError', [orgInfo.ErrorCode]));
52
52
  }
53
53
  if (orgInfo.Status === 'Error') {
54
54
  // Maybe the request object can help the user somehow
55
55
  logger.error('No error code on signup error! Logging request.');
56
56
  logger.error(orgInfo);
57
- throw new sfdxError_1.SfdxError(namedMessages.getMessage('SignupFailedUnknownError', [orgInfo.Id, hubUsername]), 'signupFailedUnknown');
57
+ throw new sfError_1.SfError(namedMessages.getMessage('SignupFailedUnknownError', [orgInfo.Id, hubUsername]), 'signupFailedUnknown');
58
58
  }
59
- throw new sfdxError_1.SfdxError(namedMessages.getMessage('SignupUnexpectedError'), 'UnexpectedSignupStatus');
59
+ throw new sfError_1.SfError(namedMessages.getMessage('SignupUnexpectedError'), 'UnexpectedSignupStatus');
60
60
  };
61
61
  exports.checkScratchOrgInfoForErrors = checkScratchOrgInfoForErrors;
62
62
  //# sourceMappingURL=scratchOrgErrorCodes.js.map
@@ -13,7 +13,7 @@ const ts_retry_promise_1 = require("ts-retry-promise");
13
13
  const logger_1 = require("../logger");
14
14
  const mapKeys_1 = require("../util/mapKeys");
15
15
  const messages_1 = require("../messages");
16
- const sfdxError_1 = require("../sfdxError");
16
+ const sfError_1 = require("../sfError");
17
17
  const sfdcUrl_1 = require("../util/sfdcUrl");
18
18
  const pollingClient_1 = require("../status/pollingClient");
19
19
  const myDomainResolver_1 = require("../status/myDomainResolver");
@@ -188,13 +188,13 @@ const checkOrgDoesntExist = async (scratchOrgInfo) => {
188
188
  await authInfo_1.AuthInfo.create({ username: username.toLowerCase() });
189
189
  }
190
190
  catch (error) {
191
- const sfdxError = sfdxError_1.SfdxError.wrap(error);
191
+ const sfError = sfError_1.SfError.wrap(error);
192
192
  // if an AuthInfo couldn't be created that means no AuthFile exists.
193
- if (sfdxError.name === 'NamedOrgNotFound') {
193
+ if (sfError.name === 'NamedOrgNotFound') {
194
194
  return;
195
195
  }
196
196
  // Something unexpected
197
- throw sfdxError;
197
+ throw sfError;
198
198
  }
199
199
  // An org file already exists
200
200
  throw errorCodes.createError('C-1007');
@@ -216,11 +216,11 @@ const requestScratchOrgCreation = async (hubOrg, scratchOrgRequest, settings) =>
216
216
  // We do not allow you to specify the old and the new way of doing post create settings
217
217
  if (scratchOrgRequest.orgPreferences && settings.hasSettings()) {
218
218
  // This is not allowed
219
- throw new sfdxError_1.SfdxError('SignupDuplicateSettingsSpecifiedError');
219
+ throw new sfError_1.SfError('SignupDuplicateSettingsSpecifiedError');
220
220
  }
221
221
  // deprecated old style orgPreferences
222
222
  if (scratchOrgRequest.orgPreferences) {
223
- throw new sfdxError_1.SfdxError(messages.getMessage('DeprecatedPrefFormat'));
223
+ throw new sfError_1.SfError(messages.getMessage('DeprecatedPrefFormat'));
224
224
  }
225
225
  const scratchOrgInfo = (0, mapKeys_1.default)(scratchOrgRequest, kit_1.upperFirst, true);
226
226
  await checkOrgDoesntExist(scratchOrgInfo); // throw if it does exist.
@@ -231,9 +231,9 @@ const requestScratchOrgCreation = async (hubOrg, scratchOrgRequest, settings) =>
231
231
  // this is a jsforce error which contains the property "fields" which regular error don't
232
232
  const jsForceError = error;
233
233
  if (jsForceError.errorCode === 'REQUIRED_FIELD_MISSING') {
234
- throw new sfdxError_1.SfdxError(messages.getMessage('SignupFieldsMissingError', [jsForceError.fields.toString()]));
234
+ throw new sfError_1.SfError(messages.getMessage('SignupFieldsMissingError', [jsForceError.fields.toString()]));
235
235
  }
236
- throw sfdxError_1.SfdxError.wrap(jsForceError);
236
+ throw sfError_1.SfError.wrap(jsForceError);
237
237
  }
238
238
  };
239
239
  exports.requestScratchOrgCreation = requestScratchOrgCreation;
@@ -288,9 +288,9 @@ timeout = kit_1.Duration.minutes(15)) => {
288
288
  catch (error) {
289
289
  const err = error;
290
290
  if (err.message) {
291
- throw sfdxError_1.SfdxError.wrap(err);
291
+ throw sfError_1.SfError.wrap(err);
292
292
  }
293
- throw new sfdxError_1.SfdxError(`The scratch org did not complete within ${timeout.minutes} minutes`, 'orgCreationTimeout', [
293
+ throw new sfError_1.SfError(`The scratch org did not complete within ${timeout.minutes} minutes`, 'orgCreationTimeout', [
294
294
  'Try your force:org:create command again with a longer --wait value',
295
295
  ]);
296
296
  }
@@ -315,7 +315,7 @@ const deploySettingsAndResolveUrl = async (scratchOrgAuthInfo, apiVersion, orgSe
315
315
  await orgSettings.deploySettingsViaFolder(scratchOrg, apiVersion);
316
316
  }
317
317
  catch (error) {
318
- throw sfdxError_1.SfdxError.wrap(error);
318
+ throw sfError_1.SfError.wrap(error);
319
319
  }
320
320
  }
321
321
  const { instanceUrl } = scratchOrgAuthInfo.getFields();
@@ -331,17 +331,17 @@ const deploySettingsAndResolveUrl = async (scratchOrgAuthInfo, apiVersion, orgSe
331
331
  await resolver.resolve();
332
332
  }
333
333
  catch (error) {
334
- const sfdxError = sfdxError_1.SfdxError.wrap(error);
334
+ const sfError = sfError_1.SfError.wrap(error);
335
335
  logger.debug('processScratchOrgInfoResult - err: %s', error);
336
- if (sfdxError.name === 'MyDomainResolverTimeoutError') {
337
- sfdxError.setData({
336
+ if (sfError.name === 'MyDomainResolverTimeoutError') {
337
+ sfError.setData({
338
338
  orgId: scratchOrgAuthInfo.getFields().orgId,
339
339
  username: scratchOrgAuthInfo.getFields().username,
340
340
  instanceUrl,
341
341
  });
342
- logger.debug('processScratchOrgInfoResult - err data: %s', sfdxError.data);
342
+ logger.debug('processScratchOrgInfoResult - err data: %s', sfError.data);
343
343
  }
344
- throw sfdxError;
344
+ throw sfError;
345
345
  }
346
346
  return scratchOrgAuthInfo;
347
347
  }
@@ -1,4 +1,4 @@
1
- import { SfdxProjectJson } from '../sfdxProject';
1
+ import { SfProjectJson } from '../sfProject';
2
2
  import { Org } from './org';
3
3
  import { ScratchOrgInfo } from './scratchOrgInfoApi';
4
4
  declare type PartialScratchOrgInfo = Pick<ScratchOrgInfo, 'ConnectedAppConsumerKey' | 'AuthCode' | 'Snapshot' | 'Status' | 'LoginUrl' | 'SignupEmail' | 'SignupUsername' | 'SignupInstance' | 'Username'>;
@@ -14,10 +14,10 @@ export interface ScratchOrgInfoPayload extends PartialScratchOrgInfo {
14
14
  * Generates the package2AncestorIds scratch org property
15
15
  *
16
16
  * @param scratchOrgInfo - the scratchOrgInfo passed in by the user
17
- * @param projectJson - sfdxProjectJson
17
+ * @param projectJson - sfProjectJson
18
18
  * @param hubOrg - the hub org, in case we need to do queries
19
19
  */
20
- export declare const getAncestorIds: (scratchOrgInfo: ScratchOrgInfoPayload, projectJson: SfdxProjectJson, hubOrg: Org) => Promise<string>;
20
+ export declare const getAncestorIds: (scratchOrgInfo: ScratchOrgInfoPayload, projectJson: SfProjectJson, hubOrg: Org) => Promise<string>;
21
21
  /**
22
22
  * Takes in a scratchOrgInfo and fills in the missing fields
23
23
  *
@@ -11,10 +11,10 @@ const fs_1 = require("fs");
11
11
  const kit_1 = require("@salesforce/kit");
12
12
  const ts_types_1 = require("@salesforce/ts-types");
13
13
  const sfdc_1 = require("../util/sfdc");
14
- const sfdxProject_1 = require("../sfdxProject");
14
+ const sfProject_1 = require("../sfProject");
15
15
  const webOAuthServer_1 = require("../webOAuthServer");
16
16
  const messages_1 = require("../messages");
17
- const sfdxError_1 = require("../sfdxError");
17
+ const sfError_1 = require("../sfError");
18
18
  const scratchOrgFeatureDeprecation_1 = require("./scratchOrgFeatureDeprecation");
19
19
  const defaultConnectedAppInfo = {
20
20
  clientId: 'PlatformCLI',
@@ -38,12 +38,12 @@ const SNAPSHOT_UNSUPPORTED_OPTIONS = [
38
38
  // executed within the ctor and also after parsing/normalization of the definition file.
39
39
  const optionsValidator = (key, scratchOrgInfoPayload) => {
40
40
  if (key.toLowerCase() === 'durationdays') {
41
- throw new sfdxError_1.SfdxError('unrecognizedScratchOrgOption', 'durationDays');
41
+ throw new sfError_1.SfError('unrecognizedScratchOrgOption', 'durationDays');
42
42
  }
43
43
  if (key.toLowerCase() === 'snapshot') {
44
44
  const foundInvalidFields = SNAPSHOT_UNSUPPORTED_OPTIONS.filter((invalidField) => invalidField in scratchOrgInfoPayload);
45
45
  if (foundInvalidFields.length > 0) {
46
- throw new sfdxError_1.SfdxError(messages.getMessage('unsupportedSnapshotOrgCreateOptions', [foundInvalidFields.join(', ')]), 'orgSnapshot');
46
+ throw new sfError_1.SfError(messages.getMessage('unsupportedSnapshotOrgCreateOptions', [foundInvalidFields.join(', ')]), 'orgSnapshot');
47
47
  }
48
48
  }
49
49
  };
@@ -51,12 +51,12 @@ const optionsValidator = (key, scratchOrgInfoPayload) => {
51
51
  * Generates the package2AncestorIds scratch org property
52
52
  *
53
53
  * @param scratchOrgInfo - the scratchOrgInfo passed in by the user
54
- * @param projectJson - sfdxProjectJson
54
+ * @param projectJson - sfProjectJson
55
55
  * @param hubOrg - the hub org, in case we need to do queries
56
56
  */
57
57
  const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
58
58
  if (Reflect.has(scratchOrgInfo, 'package2AncestorIds')) {
59
- throw new sfdxError_1.SfdxError(messages.getMessage('Package2AncestorsIdsKeyNotSupportedError'), 'DeprecationError');
59
+ throw new sfError_1.SfError(messages.getMessage('Package2AncestorsIdsKeyNotSupportedError'), 'DeprecationError');
60
60
  }
61
61
  const packagesWithAncestors = (await projectJson.getPackageDirectories())
62
62
  // check that the package has any ancestor types (id or version)
@@ -83,7 +83,7 @@ const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
83
83
  .singleRecordQuery(`SELECT Id, IsReleased FROM Package2Version WHERE Package2Id = '${packageId}' AND MajorVersion = ${major} AND MinorVersion = ${minor} AND PatchVersion = ${patch} and IsReleased = true`, { tooling: true });
84
84
  }
85
85
  catch (err) {
86
- throw new sfdxError_1.SfdxError(messages.getMessage('NoMatchingAncestorError', [packageDir.ancestorVersion, packageDir.package]), 'NoMatchingAncestorError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorVersion])]);
86
+ throw new sfError_1.SfError(messages.getMessage('NoMatchingAncestorError', [packageDir.ancestorVersion, packageDir.package]), 'NoMatchingAncestorError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorVersion])]);
87
87
  }
88
88
  if (packageDir.ancestorId && packageDir.ancestorId !== releasedAncestor.Id) {
89
89
  throw messages.createError('AncestorIdVersionMismatchError', [
@@ -108,7 +108,7 @@ const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
108
108
  if (packageDir.ancestorId && (packageAliases === null || packageAliases === void 0 ? void 0 : packageAliases[packageDir.ancestorId])) {
109
109
  return packageAliases[packageDir.ancestorId];
110
110
  }
111
- throw new sfdxError_1.SfdxError(`Invalid ancestorId ${packageDir.ancestorId}`, 'InvalidAncestorId');
111
+ throw new sfError_1.SfError(`Invalid ancestorId ${packageDir.ancestorId}`, 'InvalidAncestorId');
112
112
  }));
113
113
  return Array.from(new Set(ancestorIds)).join(';');
114
114
  };
@@ -123,25 +123,25 @@ exports.getAncestorIds = getAncestorIds;
123
123
  */
124
124
  const generateScratchOrgInfo = async ({ hubOrg, scratchOrgInfoPayload, nonamespace, ignoreAncestorIds, }) => {
125
125
  var _a, _b;
126
- let sfdxProject;
126
+ let sfProject;
127
127
  try {
128
- sfdxProject = await sfdxProject_1.SfdxProjectJson.create({});
128
+ sfProject = await sfProject_1.SfProjectJson.create({});
129
129
  }
130
130
  catch (e) {
131
131
  // project is not required
132
132
  }
133
133
  scratchOrgInfoPayload.orgName = (_a = scratchOrgInfoPayload.orgName) !== null && _a !== void 0 ? _a : 'Company';
134
134
  scratchOrgInfoPayload.package2AncestorIds =
135
- !ignoreAncestorIds && (sfdxProject === null || sfdxProject === void 0 ? void 0 : sfdxProject.hasPackages())
136
- ? await (0, exports.getAncestorIds)(scratchOrgInfoPayload, sfdxProject, hubOrg)
135
+ !ignoreAncestorIds && (sfProject === null || sfProject === void 0 ? void 0 : sfProject.hasPackages())
136
+ ? await (0, exports.getAncestorIds)(scratchOrgInfoPayload, sfProject, hubOrg)
137
137
  : '';
138
138
  // Use the Hub org's client ID value, if one wasn't provided to us, or the default
139
139
  if (!scratchOrgInfoPayload.connectedAppConsumerKey) {
140
140
  scratchOrgInfoPayload.connectedAppConsumerKey =
141
141
  (_b = hubOrg.getConnection().getAuthInfoFields().clientId) !== null && _b !== void 0 ? _b : defaultConnectedAppInfo.clientId;
142
142
  }
143
- if (!nonamespace && (sfdxProject === null || sfdxProject === void 0 ? void 0 : sfdxProject.get('namespace'))) {
144
- scratchOrgInfoPayload.namespace = sfdxProject.get('namespace');
143
+ if (!nonamespace && (sfProject === null || sfProject === void 0 ? void 0 : sfProject.get('namespace'))) {
144
+ scratchOrgInfoPayload.namespace = sfProject.get('namespace');
145
145
  }
146
146
  // we already have the info, and want to get rid of configApi, so this doesn't use that
147
147
  scratchOrgInfoPayload.connectedAppCallbackUrl = `http://localhost:${await webOAuthServer_1.WebOAuthServer.determineOauthPort()}/OauthRedirect`;
@@ -181,15 +181,15 @@ const getScratchOrgInfoPayload = async (options) => {
181
181
  catch (err) {
182
182
  const error = err;
183
183
  if (error.name === 'JsonParseError') {
184
- throw new sfdxError_1.SfdxError(`An error occurred parsing ${options.definitionfile}`);
184
+ throw new sfError_1.SfError(`An error occurred parsing ${options.definitionfile}`);
185
185
  }
186
- throw sfdxError_1.SfdxError.wrap(error);
186
+ throw sfError_1.SfError.wrap(error);
187
187
  }
188
188
  }
189
189
  // scratchOrgInfoPayload must be heads down camelcase.
190
190
  const upperCaseKey = sfdc_1.sfdc.findUpperCaseKeys(scratchOrgInfoPayload);
191
191
  if (upperCaseKey) {
192
- throw new sfdxError_1.SfdxError('InvalidJsonCasing', upperCaseKey);
192
+ throw new sfError_1.SfError('InvalidJsonCasing', upperCaseKey);
193
193
  }
194
194
  // Now run the fully resolved user input against the validator
195
195
  Object.keys(scratchOrgInfoPayload).forEach((key) => {
@@ -12,7 +12,7 @@ const kit_1 = require("@salesforce/kit");
12
12
  const ts_types_1 = require("@salesforce/ts-types");
13
13
  const js2xmlparser = require("js2xmlparser");
14
14
  const logger_1 = require("../logger");
15
- const sfdxError_1 = require("../sfdxError");
15
+ const sfError_1 = require("../sfError");
16
16
  const jsonXmlTools_1 = require("../util/jsonXmlTools");
17
17
  const zipWriter_1 = require("../util/zipWriter");
18
18
  const pollingClient_1 = require("../status/pollingClient");
@@ -107,7 +107,7 @@ class SettingsGenerator {
107
107
  const failures = (Array.isArray(componentFailures) ? componentFailures : [componentFailures])
108
108
  .map((failure) => failure.problem)
109
109
  .join('\n');
110
- const error = new sfdxError_1.SfdxError(`A scratch org was created with username ${username}, but the settings failed to deploy due to: \n${failures}`, 'ProblemDeployingSettings');
110
+ const error = new sfError_1.SfError(`A scratch org was created with username ${username}, but the settings failed to deploy due to: \n${failures}`, 'ProblemDeployingSettings');
111
111
  error.setData(result);
112
112
  throw error;
113
113
  }
package/lib/org/user.js CHANGED
@@ -14,7 +14,7 @@ const http_api_1 = require("jsforce/lib/http-api");
14
14
  const logger_1 = require("../logger");
15
15
  const messages_1 = require("../messages");
16
16
  const secureBuffer_1 = require("../crypto/secureBuffer");
17
- const sfdxError_1 = require("../sfdxError");
17
+ const sfError_1 = require("../sfError");
18
18
  const sfdc_1 = require("../util/sfdc");
19
19
  const connection_1 = require("./connection");
20
20
  const permissionSetAssignment_1 = require("./permissionSetAssignment");
@@ -185,11 +185,11 @@ class User extends kit_1.AsyncCreatable {
185
185
  static generatePasswordUtf8(passwordCondition = { length: 13, complexity: 5 }) {
186
186
  if (!PASSWORD_COMPLEXITY[passwordCondition.complexity]) {
187
187
  const msg = messages.getMessage('complexityOutOfBound');
188
- throw new sfdxError_1.SfdxError(msg, 'complexityOutOfBound');
188
+ throw new sfError_1.SfError(msg, 'complexityOutOfBound');
189
189
  }
190
190
  if (passwordCondition.length < 8 || passwordCondition.length > 1000) {
191
191
  const msg = messages.getMessage('lengthOutOfBound');
192
- throw new sfdxError_1.SfdxError(msg, 'lengthOutOfBound');
192
+ throw new sfError_1.SfError(msg, 'lengthOutOfBound');
193
193
  }
194
194
  let password = [];
195
195
  ['SYMBOLS', 'NUMBERS', 'UPPER', 'LOWER'].forEach((charSet) => {
@@ -407,7 +407,7 @@ class User extends kit_1.AsyncCreatable {
407
407
  }
408
408
  }
409
409
  this.logger.debug(message);
410
- throw new sfdxError_1.SfdxError(message, 'UserCreateHttpError');
410
+ throw new sfError_1.SfError(message, 'UserCreateHttpError');
411
411
  }
412
412
  fields.id = (0, ts_types_1.ensureString)(responseBody.id);
413
413
  await this.updateRequiredUserFields(fields);
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.SchemaPrinter = exports.SchemaPropertyRenderer = void 0;
10
10
  const ts_types_1 = require("@salesforce/ts-types");
11
- const sfdxError_1 = require("../sfdxError");
11
+ const sfError_1 = require("../sfError");
12
12
  /**
13
13
  * Renders schema properties. By default, this is simply an identity transform. Subclasses may provide more
14
14
  * interesting decorations of each values, such as ANSI coloring.
@@ -78,7 +78,7 @@ class SchemaPrinter {
78
78
  // No need to add to messages, since this should never happen. In fact,
79
79
  // this will cause a test failure if there is a command that uses a schema
80
80
  // with no properties defined.
81
- throw new sfdxError_1.SfdxError('There is no purpose to print a schema with no properties or items');
81
+ throw new sfError_1.SfError('There is no purpose to print a schema with no properties or items');
82
82
  }
83
83
  const startLevel = 0;
84
84
  const add = this.addFn(startLevel);
@@ -27,8 +27,8 @@ export declare class SchemaValidator {
27
27
  * Performs validation of JSON data against the schema located at the `schemaPath` value provided
28
28
  * at instantiation.
29
29
  *
30
- * **Throws** *{@link SfdxError}{ name: 'ValidationSchemaFieldError' }* If there are known validations errors.
31
- * **Throws** *{@link SfdxError}{ name: 'ValidationSchemaUnknownError' }* If there are unknown validations errors.
30
+ * **Throws** *{@link SfError}{ name: 'ValidationSchemaFieldError' }* If there are known validations errors.
31
+ * **Throws** *{@link SfError}{ name: 'ValidationSchemaUnknownError' }* If there are unknown validations errors.
32
32
  *
33
33
  * @param json A JSON value to validate against this instance's target schema.
34
34
  * @returns The validated JSON data.
@@ -38,8 +38,8 @@ export declare class SchemaValidator {
38
38
  * Performs validation of JSON data against the schema located at the `schemaPath` value provided
39
39
  * at instantiation.
40
40
  *
41
- * **Throws** *{@link SfdxError}{ name: 'ValidationSchemaFieldError' }* If there are known validations errors.
42
- * **Throws** *{@link SfdxError}{ name: 'ValidationSchemaUnknownError' }* If there are unknown validations errors.
41
+ * **Throws** *{@link SfError}{ name: 'ValidationSchemaFieldError' }* If there are known validations errors.
42
+ * **Throws** *{@link SfError}{ name: 'ValidationSchemaUnknownError' }* If there are unknown validations errors.
43
43
  *
44
44
  * @param json A JSON value to validate against this instance's target schema.
45
45
  * @returns The validated JSON data.
@@ -8,11 +8,11 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.SchemaValidator = void 0;
10
10
  const path = require("path");
11
+ const fs = require("fs");
11
12
  const kit_1 = require("@salesforce/kit");
12
13
  const ts_types_1 = require("@salesforce/ts-types");
13
14
  const validator = require("jsen");
14
- const sfdxError_1 = require("../sfdxError");
15
- const fs_1 = require("../util/fs");
15
+ const sfError_1 = require("../sfError");
16
16
  /**
17
17
  * Loads a JSON schema and performs validations against JSON objects.
18
18
  */
@@ -33,7 +33,7 @@ class SchemaValidator {
33
33
  */
34
34
  async load() {
35
35
  if (!this.schema) {
36
- this.schema = await fs_1.fs.readJsonMap(this.schemaPath);
36
+ this.schema = (0, kit_1.parseJsonMap)(await fs.promises.readFile(this.schemaPath, 'utf8'));
37
37
  this.logger.debug(`Schema loaded for ${this.schemaPath}`);
38
38
  }
39
39
  return this.schema;
@@ -43,7 +43,7 @@ class SchemaValidator {
43
43
  */
44
44
  loadSync() {
45
45
  if (!this.schema) {
46
- this.schema = fs_1.fs.readJsonMapSync(this.schemaPath);
46
+ this.schema = (0, kit_1.parseJsonMap)(fs.readFileSync(this.schemaPath, 'utf8'));
47
47
  this.logger.debug(`Schema loaded for ${this.schemaPath}`);
48
48
  }
49
49
  return this.schema;
@@ -52,8 +52,8 @@ class SchemaValidator {
52
52
  * Performs validation of JSON data against the schema located at the `schemaPath` value provided
53
53
  * at instantiation.
54
54
  *
55
- * **Throws** *{@link SfdxError}{ name: 'ValidationSchemaFieldError' }* If there are known validations errors.
56
- * **Throws** *{@link SfdxError}{ name: 'ValidationSchemaUnknownError' }* If there are unknown validations errors.
55
+ * **Throws** *{@link SfError}{ name: 'ValidationSchemaFieldError' }* If there are known validations errors.
56
+ * **Throws** *{@link SfError}{ name: 'ValidationSchemaUnknownError' }* If there are unknown validations errors.
57
57
  *
58
58
  * @param json A JSON value to validate against this instance's target schema.
59
59
  * @returns The validated JSON data.
@@ -66,8 +66,8 @@ class SchemaValidator {
66
66
  * Performs validation of JSON data against the schema located at the `schemaPath` value provided
67
67
  * at instantiation.
68
68
  *
69
- * **Throws** *{@link SfdxError}{ name: 'ValidationSchemaFieldError' }* If there are known validations errors.
70
- * **Throws** *{@link SfdxError}{ name: 'ValidationSchemaUnknownError' }* If there are unknown validations errors.
69
+ * **Throws** *{@link SfError}{ name: 'ValidationSchemaFieldError' }* If there are known validations errors.
70
+ * **Throws** *{@link SfError}{ name: 'ValidationSchemaUnknownError' }* If there are unknown validations errors.
71
71
  *
72
72
  * @param json A JSON value to validate against this instance's target schema.
73
73
  * @returns The validated JSON data.
@@ -85,10 +85,10 @@ class SchemaValidator {
85
85
  if (!validate(json)) {
86
86
  if (validate.errors) {
87
87
  const errors = this.getErrorsText(validate.errors, schema);
88
- throw new sfdxError_1.SfdxError(`Validation errors:\n${errors}`, 'ValidationSchemaFieldError');
88
+ throw new sfError_1.SfError(`Validation errors:\n${errors}`, 'ValidationSchemaFieldError');
89
89
  }
90
90
  else {
91
- throw new sfdxError_1.SfdxError('Unknown schema validation error', 'ValidationSchemaUnknownError');
91
+ throw new sfError_1.SfError('Unknown schema validation error', 'ValidationSchemaUnknownError');
92
92
  }
93
93
  }
94
94
  return validate.build(json);
@@ -112,7 +112,7 @@ class SchemaValidator {
112
112
  externalSchemas[externalSchema.id] = externalSchema;
113
113
  }
114
114
  else {
115
- throw new sfdxError_1.SfdxError(`Unexpected external schema id type: ${typeof externalSchema.id}`, 'ValidationSchemaTypeError');
115
+ throw new sfError_1.SfError(`Unexpected external schema id type: ${typeof externalSchema.id}`, 'ValidationSchemaTypeError');
116
116
  }
117
117
  });
118
118
  return externalSchemas;
@@ -125,11 +125,11 @@ class SchemaValidator {
125
125
  loadExternalSchema(uri) {
126
126
  const schemaPath = path.join(this.schemasDir, `${uri}.json`);
127
127
  try {
128
- return fs_1.fs.readJsonMapSync(schemaPath);
128
+ return (0, kit_1.parseJsonMap)(fs.readFileSync(schemaPath, 'utf8'));
129
129
  }
130
130
  catch (err) {
131
131
  if (err.code === 'ENOENT') {
132
- throw new sfdxError_1.SfdxError(`Schema not found: ${schemaPath}`, 'ValidationSchemaNotFound');
132
+ throw new sfError_1.SfError(`Schema not found: ${schemaPath}`, 'ValidationSchemaNotFound');
133
133
  }
134
134
  throw err;
135
135
  }