@salesforce/core 3.7.4 → 3.7.7

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 (77) hide show
  1. package/CHANGELOG.md +219 -0
  2. package/README.md +4 -4
  3. package/lib/config/config.d.ts +5 -5
  4. package/lib/config/config.js +5 -5
  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 +7 -7
  9. package/lib/config/configStore.js +7 -6
  10. package/lib/config/envVars.d.ts +20 -5
  11. package/lib/config/envVars.js +70 -5
  12. package/lib/crypto/keyChainImpl.js +2 -3
  13. package/lib/deviceOauthService.js +2 -2
  14. package/lib/exported.d.ts +6 -4
  15. package/lib/exported.js +13 -6
  16. package/lib/globalInfo/accessors/aliasAccessor.js +2 -2
  17. package/lib/lifecycleEvents.js +1 -1
  18. package/lib/logger.d.ts +3 -3
  19. package/lib/logger.js +9 -10
  20. package/lib/messages.d.ts +2 -2
  21. package/lib/messages.js +4 -4
  22. package/lib/org/authInfo.d.ts +1 -1
  23. package/lib/org/authInfo.js +6 -7
  24. package/lib/org/authRemover.d.ts +2 -2
  25. package/lib/org/authRemover.js +2 -2
  26. package/lib/org/connection.d.ts +7 -2
  27. package/lib/org/connection.js +17 -4
  28. package/lib/org/org.d.ts +16 -6
  29. package/lib/org/org.js +52 -49
  30. package/lib/org/permissionSetAssignment.js +2 -2
  31. package/lib/org/scratchOrgCreate.d.ts +43 -0
  32. package/lib/org/scratchOrgCreate.js +142 -0
  33. package/lib/org/scratchOrgErrorCodes.d.ts +4 -0
  34. package/lib/org/scratchOrgErrorCodes.js +62 -0
  35. package/lib/org/scratchOrgFeatureDeprecation.d.ts +26 -0
  36. package/lib/org/scratchOrgFeatureDeprecation.js +110 -0
  37. package/lib/org/scratchOrgInfoApi.d.ts +94 -0
  38. package/lib/org/scratchOrgInfoApi.js +350 -0
  39. package/lib/org/scratchOrgInfoGenerator.d.ts +63 -0
  40. package/lib/org/scratchOrgInfoGenerator.js +223 -0
  41. package/lib/org/scratchOrgSettingsGenerator.d.ts +56 -0
  42. package/lib/org/scratchOrgSettingsGenerator.js +210 -0
  43. package/lib/org/user.js +8 -7
  44. package/lib/schema/printer.js +2 -2
  45. package/lib/schema/validator.d.ts +4 -4
  46. package/lib/schema/validator.js +9 -9
  47. package/lib/{sfdxError.d.ts → sfError.d.ts} +14 -9
  48. package/lib/{sfdxError.js → sfError.js} +20 -14
  49. package/lib/{sfdxProject.d.ts → sfProject.d.ts} +37 -27
  50. package/lib/{sfdxProject.js → sfProject.js} +75 -63
  51. package/lib/status/pollingClient.d.ts +2 -2
  52. package/lib/status/pollingClient.js +10 -4
  53. package/lib/status/streamingClient.d.ts +1 -1
  54. package/lib/status/streamingClient.js +6 -6
  55. package/lib/testSetup.d.ts +4 -4
  56. package/lib/testSetup.js +8 -8
  57. package/lib/util/fs.js +7 -7
  58. package/lib/util/internal.d.ts +2 -2
  59. package/lib/util/internal.js +2 -2
  60. package/lib/util/jsonXmlTools.d.ts +14 -0
  61. package/lib/util/jsonXmlTools.js +41 -0
  62. package/lib/util/mapKeys.d.ts +14 -0
  63. package/lib/util/mapKeys.js +48 -0
  64. package/lib/util/sfdcUrl.d.ts +2 -2
  65. package/lib/util/sfdcUrl.js +2 -2
  66. package/lib/util/zipWriter.d.ts +14 -0
  67. package/lib/util/zipWriter.js +68 -0
  68. package/lib/webOAuthServer.js +11 -11
  69. package/messages/envVars.md +53 -13
  70. package/messages/org.md +4 -0
  71. package/messages/scratchOrgCreate.md +27 -0
  72. package/messages/scratchOrgErrorCodes.md +99 -0
  73. package/messages/scratchOrgFeatureDeprecation.md +11 -0
  74. package/messages/scratchOrgInfoApi.md +11 -0
  75. package/messages/scratchOrgInfoGenerator.md +19 -0
  76. package/messages/user.md +4 -0
  77. package/package.json +5 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = void 0;
3
+ exports.envVars = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = void 0;
4
4
  /*
5
5
  * Copyright (c) 2020, salesforce.com, inc.
6
6
  * All rights reserved.
@@ -50,6 +50,11 @@ var EnvironmentVariable;
50
50
  EnvironmentVariable["SFDX_SOURCE_MEMBER_POLLING_TIMEOUT"] = "SFDX_SOURCE_MEMBER_POLLING_TIMEOUT";
51
51
  EnvironmentVariable["SFDX_USE_GENERIC_UNIX_KEYCHAIN"] = "SFDX_USE_GENERIC_UNIX_KEYCHAIN";
52
52
  EnvironmentVariable["SFDX_USE_PROGRESS_BAR"] = "SFDX_USE_PROGRESS_BAR";
53
+ EnvironmentVariable["SFDX_LAZY_LOAD_MODULES"] = "SFDX_LAZY_LOAD_MODULES";
54
+ EnvironmentVariable["SFDX_S3_HOST"] = "SFDX_S3_HOST";
55
+ EnvironmentVariable["SFDX_UPDATE_INSTRUCTIONS"] = "SFDX_UPDATE_INSTRUCTIONS";
56
+ EnvironmentVariable["SFDX_INSTALLER"] = "SFDX_INSTALLER";
57
+ EnvironmentVariable["SFDX_ENV"] = "SFDX_ENV";
53
58
  EnvironmentVariable["SF_TARGET_ORG"] = "SF_TARGET_ORG";
54
59
  EnvironmentVariable["SF_TARGET_DEV_HUB"] = "SF_TARGET_DEV_HUB";
55
60
  EnvironmentVariable["SF_ACCESS_TOKEN"] = "SF_ACCESS_TOKEN";
@@ -76,6 +81,11 @@ var EnvironmentVariable;
76
81
  EnvironmentVariable["SF_SOURCE_MEMBER_POLLING_TIMEOUT"] = "SF_SOURCE_MEMBER_POLLING_TIMEOUT";
77
82
  EnvironmentVariable["SF_USE_GENERIC_UNIX_KEYCHAIN"] = "SF_USE_GENERIC_UNIX_KEYCHAIN";
78
83
  EnvironmentVariable["SF_USE_PROGRESS_BAR"] = "SF_USE_PROGRESS_BAR";
84
+ EnvironmentVariable["SF_LAZY_LOAD_MODULES"] = "SF_LAZY_LOAD_MODULES";
85
+ EnvironmentVariable["SF_S3_HOST"] = "SF_S3_HOST";
86
+ EnvironmentVariable["SF_UPDATE_INSTRUCTIONS"] = "SF_UPDATE_INSTRUCTIONS";
87
+ EnvironmentVariable["SF_INSTALLER"] = "SF_INSTALLER";
88
+ EnvironmentVariable["SF_ENV"] = "SF_ENV";
79
89
  })(EnvironmentVariable = exports.EnvironmentVariable || (exports.EnvironmentVariable = {}));
80
90
  const getMessage = (environmentVariable) => messages.getMessage((0, change_case_1.camelCase)(environmentVariable));
81
91
  exports.SUPPORTED_ENV_VARS = {
@@ -216,6 +226,26 @@ exports.SUPPORTED_ENV_VARS = {
216
226
  description: getMessage(EnvironmentVariable.SFDX_USE_PROGRESS_BAR),
217
227
  synonymOf: EnvironmentVariable.SF_USE_PROGRESS_BAR,
218
228
  },
229
+ [EnvironmentVariable.SFDX_LAZY_LOAD_MODULES]: {
230
+ description: getMessage(EnvironmentVariable.SFDX_USE_PROGRESS_BAR),
231
+ synonymOf: EnvironmentVariable.SF_LAZY_LOAD_MODULES,
232
+ },
233
+ [EnvironmentVariable.SFDX_S3_HOST]: {
234
+ description: getMessage(EnvironmentVariable.SFDX_S3_HOST),
235
+ synonymOf: EnvironmentVariable.SF_S3_HOST,
236
+ },
237
+ [EnvironmentVariable.SFDX_UPDATE_INSTRUCTIONS]: {
238
+ description: getMessage(EnvironmentVariable.SFDX_UPDATE_INSTRUCTIONS),
239
+ synonymOf: null,
240
+ },
241
+ [EnvironmentVariable.SFDX_INSTALLER]: {
242
+ description: getMessage(EnvironmentVariable.SFDX_INSTALLER),
243
+ synonymOf: null,
244
+ },
245
+ [EnvironmentVariable.SFDX_ENV]: {
246
+ description: getMessage(EnvironmentVariable.SFDX_ENV),
247
+ synonymOf: null,
248
+ },
219
249
  [EnvironmentVariable.SF_TARGET_ORG]: {
220
250
  description: getMessage(EnvironmentVariable.SF_TARGET_ORG),
221
251
  synonymOf: null,
@@ -321,22 +351,53 @@ exports.SUPPORTED_ENV_VARS = {
321
351
  description: getMessage(EnvironmentVariable.SF_USE_PROGRESS_BAR),
322
352
  synonymOf: null,
323
353
  },
354
+ [EnvironmentVariable.SF_LAZY_LOAD_MODULES]: {
355
+ description: getMessage(EnvironmentVariable.SF_LAZY_LOAD_MODULES),
356
+ synonymOf: null,
357
+ },
358
+ [EnvironmentVariable.SF_S3_HOST]: {
359
+ description: getMessage(EnvironmentVariable.SF_S3_HOST),
360
+ synonymOf: null,
361
+ },
362
+ [EnvironmentVariable.SF_UPDATE_INSTRUCTIONS]: {
363
+ description: getMessage(EnvironmentVariable.SF_UPDATE_INSTRUCTIONS),
364
+ synonymOf: null,
365
+ },
366
+ [EnvironmentVariable.SF_INSTALLER]: {
367
+ description: getMessage(EnvironmentVariable.SF_INSTALLER),
368
+ synonymOf: null,
369
+ },
370
+ [EnvironmentVariable.SF_ENV]: {
371
+ description: getMessage(EnvironmentVariable.SF_ENV),
372
+ synonymOf: null,
373
+ },
324
374
  };
325
375
  class EnvVars extends kit_1.Env {
326
- constructor() {
327
- super();
376
+ constructor(env = process.env) {
377
+ super(env);
328
378
  this.resolve();
329
379
  }
330
- propertyToEnvName(property, prefix = 'SFDX_') {
380
+ static defaultPrefix() {
381
+ if (process.argv[0].startsWith('sfdx'))
382
+ return 'SFDX_';
383
+ if (process.argv[0].startsWith('sf'))
384
+ return 'SF_';
385
+ return 'SFDX_';
386
+ }
387
+ propertyToEnvName(property, prefix = EnvVars.defaultPrefix()) {
331
388
  return `${prefix || ''}${(0, change_case_1.snakeCase)(property).toUpperCase()}`;
332
389
  }
333
- setPropertyFromEnv(property, prefix = 'SFDX_') {
390
+ setPropertyFromEnv(property, prefix = EnvVars.defaultPrefix()) {
334
391
  const envName = this.propertyToEnvName(property, prefix);
335
392
  const value = this.getString(envName);
336
393
  if (value) {
337
394
  this.setString(property, value);
338
395
  }
339
396
  }
397
+ getPropertyFromEnv(property, prefix = EnvVars.defaultPrefix()) {
398
+ const envName = this.propertyToEnvName(property, prefix);
399
+ return this.get(envName);
400
+ }
340
401
  asDictionary() {
341
402
  return this.entries().reduce((accumulator, [key, value]) => {
342
403
  accumulator[key] = value;
@@ -363,6 +424,10 @@ class EnvVars extends kit_1.Env {
363
424
  }
364
425
  });
365
426
  }
427
+ get(envName) {
428
+ return this.asDictionary()[envName];
429
+ }
366
430
  }
367
431
  exports.EnvVars = EnvVars;
432
+ exports.envVars = new EnvVars();
368
433
  //# sourceMappingURL=envVars.js.map
@@ -58,9 +58,9 @@ const _isExe = (mode, gid, uid) => {
58
58
  /**
59
59
  * Private helper to validate that a program exists on the file system and is executable.
60
60
  *
61
- * **Throws** *{@link SfdxError}{ name: 'MissingCredentialProgramError' }* When the OS credential program isn't found.
61
+ * **Throws** *{@link SfError}{ name: 'MissingCredentialProgramError' }* When the OS credential program isn't found.
62
62
  *
63
- * **Throws** *{@link SfdxError}{ name: 'CredentialProgramAccessError' }* When the OS credential program isn't accessible.
63
+ * **Throws** *{@link SfError}{ name: 'CredentialProgramAccessError' }* When the OS credential program isn't accessible.
64
64
  *
65
65
  * @param programPath The absolute path of the program.
66
66
  * @param fsIfc The file system interface.
@@ -216,7 +216,6 @@ const _linuxImpl = {
216
216
  // This is a workaround for linux.
217
217
  // Calling secret-tool too fast can cause it to return an unexpected error. (below)
218
218
  if (stderr != null && stderr.includes('invalid or unencryptable secret')) {
219
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
220
219
  // @ts-ignore TODO: make an error subclass with this field
221
220
  error.retry = true;
222
221
  // Throwing here allows us to perform a retry in KeychainAccess
@@ -15,7 +15,7 @@ const kit_1 = require("@salesforce/kit");
15
15
  const ts_types_1 = require("@salesforce/ts-types");
16
16
  const logger_1 = require("./logger");
17
17
  const authInfo_1 = require("./org/authInfo");
18
- const sfdxError_1 = require("./sfdxError");
18
+ const sfError_1 = require("./sfError");
19
19
  const connection_1 = require("./org/connection");
20
20
  const messages_1 = require("./messages");
21
21
  messages_1.Messages.importMessagesDirectory(__dirname);
@@ -29,7 +29,7 @@ async function makeRequest(options) {
29
29
  const rawResponse = await new transport_1.default().httpRequest(options);
30
30
  const response = (0, kit_1.parseJsonMap)(rawResponse.body);
31
31
  if (response.error) {
32
- const err = new sfdxError_1.SfdxError('Request Failed.');
32
+ const err = new sfError_1.SfError('Request Failed.');
33
33
  err.data = Object.assign(response, { status: rawResponse.statusCode });
34
34
  throw err;
35
35
  }
package/lib/exported.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { OAuth2Config } from 'jsforce';
2
2
  export { ConfigFile } from './config/configFile';
3
- export { EnvironmentVariable, SUPPORTED_ENV_VARS } from './config/envVars';
3
+ export { envVars, EnvironmentVariable, SUPPORTED_ENV_VARS, EnvVars } from './config/envVars';
4
4
  export { BaseConfigStore, ConfigContents, ConfigEntry, ConfigStore, ConfigValue } from './config/configStore';
5
5
  export { GlobalInfo, SfEntry, SfInfo, SfInfoKeys, SfOrg, SfOrgs, SfToken, SfTokens } from './globalInfo';
6
6
  export { DeviceOauthService, DeviceCodeResponse, DeviceCodePollingResponse } from './deviceOauthService';
@@ -17,17 +17,19 @@ export { SfdcUrl } from './util/sfdcUrl';
17
17
  export { getJwtAudienceUrl } from './util/getJwtAudienceUrl';
18
18
  export { Fields, FieldValue, LoggerLevel, LoggerLevelValue, LogLine, LoggerOptions, LoggerStream, Logger, } from './logger';
19
19
  export { Messages } from './messages';
20
- export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, OrgTypes, ResultEvent, } from './org';
20
+ export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, OrgTypes, ResultEvent, ScratchOrgRequest, } from './org';
21
21
  export { OrgConfigProperties, ORG_CONFIG_ALLOWED_PROPERTIES } from './org/orgConfigProperties';
22
- export { PackageDir, NamedPackageDir, PackageDirDependency, SfdxProject, SfdxProjectJson } from './sfdxProject';
22
+ export { PackageDir, NamedPackageDir, PackageDirDependency, SfProject, SfProjectJson, SfdxProject, SfdxProjectJson, } from './sfProject';
23
23
  export { SchemaPrinter } from './schema/printer';
24
24
  export { SchemaValidator } from './schema/validator';
25
- export { SfdxError } from './sfdxError';
25
+ export { SfError, SfdxError } from './sfError';
26
26
  export { PollingClient } from './status/pollingClient';
27
27
  export { CometClient, CometSubscription, StreamingClient, StatusResult } from './status/streamingClient';
28
28
  export { MyDomainResolver } from './status/myDomainResolver';
29
29
  export { DefaultUserFields, REQUIRED_FIELDS, User, UserFields } from './org/user';
30
30
  export { PermissionSetAssignment, PermissionSetAssignmentFields } from './org/permissionSetAssignment';
31
+ export { ScratchOrgCreateOptions, ScratchOrgCreateResult, scratchOrgCreate } from './org/scratchOrgCreate';
32
+ export { ScratchOrgInfo } from './org/scratchOrgInfoApi';
31
33
  export * from './util/fs';
32
34
  export * from './util/sfdc';
33
35
  export * from './util/sfdcUrl';
package/lib/exported.js CHANGED
@@ -16,14 +16,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.ConfigAggregator = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.SfInfoKeys = exports.GlobalInfo = exports.BaseConfigStore = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.ConfigFile = void 0;
19
+ exports.scratchOrgCreate = exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SfError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.SfProjectJson = exports.SfProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.ConfigAggregator = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.SfInfoKeys = exports.GlobalInfo = exports.BaseConfigStore = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.envVars = exports.ConfigFile = void 0;
20
20
  const messages_1 = require("./messages");
21
21
  messages_1.Messages.importMessagesDirectory(__dirname);
22
22
  var configFile_1 = require("./config/configFile");
23
23
  Object.defineProperty(exports, "ConfigFile", { enumerable: true, get: function () { return configFile_1.ConfigFile; } });
24
24
  var envVars_1 = require("./config/envVars");
25
+ Object.defineProperty(exports, "envVars", { enumerable: true, get: function () { return envVars_1.envVars; } });
25
26
  Object.defineProperty(exports, "EnvironmentVariable", { enumerable: true, get: function () { return envVars_1.EnvironmentVariable; } });
26
27
  Object.defineProperty(exports, "SUPPORTED_ENV_VARS", { enumerable: true, get: function () { return envVars_1.SUPPORTED_ENV_VARS; } });
28
+ Object.defineProperty(exports, "EnvVars", { enumerable: true, get: function () { return envVars_1.EnvVars; } });
27
29
  var configStore_1 = require("./config/configStore");
28
30
  Object.defineProperty(exports, "BaseConfigStore", { enumerable: true, get: function () { return configStore_1.BaseConfigStore; } });
29
31
  var globalInfo_1 = require("./globalInfo");
@@ -69,15 +71,18 @@ Object.defineProperty(exports, "OrgTypes", { enumerable: true, get: function ()
69
71
  var orgConfigProperties_1 = require("./org/orgConfigProperties");
70
72
  Object.defineProperty(exports, "OrgConfigProperties", { enumerable: true, get: function () { return orgConfigProperties_1.OrgConfigProperties; } });
71
73
  Object.defineProperty(exports, "ORG_CONFIG_ALLOWED_PROPERTIES", { enumerable: true, get: function () { return orgConfigProperties_1.ORG_CONFIG_ALLOWED_PROPERTIES; } });
72
- var sfdxProject_1 = require("./sfdxProject");
73
- Object.defineProperty(exports, "SfdxProject", { enumerable: true, get: function () { return sfdxProject_1.SfdxProject; } });
74
- Object.defineProperty(exports, "SfdxProjectJson", { enumerable: true, get: function () { return sfdxProject_1.SfdxProjectJson; } });
74
+ var sfProject_1 = require("./sfProject");
75
+ Object.defineProperty(exports, "SfProject", { enumerable: true, get: function () { return sfProject_1.SfProject; } });
76
+ Object.defineProperty(exports, "SfProjectJson", { enumerable: true, get: function () { return sfProject_1.SfProjectJson; } });
77
+ Object.defineProperty(exports, "SfdxProject", { enumerable: true, get: function () { return sfProject_1.SfdxProject; } });
78
+ Object.defineProperty(exports, "SfdxProjectJson", { enumerable: true, get: function () { return sfProject_1.SfdxProjectJson; } });
75
79
  var printer_1 = require("./schema/printer");
76
80
  Object.defineProperty(exports, "SchemaPrinter", { enumerable: true, get: function () { return printer_1.SchemaPrinter; } });
77
81
  var validator_1 = require("./schema/validator");
78
82
  Object.defineProperty(exports, "SchemaValidator", { enumerable: true, get: function () { return validator_1.SchemaValidator; } });
79
- var sfdxError_1 = require("./sfdxError");
80
- Object.defineProperty(exports, "SfdxError", { enumerable: true, get: function () { return sfdxError_1.SfdxError; } });
83
+ var sfError_1 = require("./sfError");
84
+ Object.defineProperty(exports, "SfError", { enumerable: true, get: function () { return sfError_1.SfError; } });
85
+ Object.defineProperty(exports, "SfdxError", { enumerable: true, get: function () { return sfError_1.SfdxError; } });
81
86
  var pollingClient_1 = require("./status/pollingClient");
82
87
  Object.defineProperty(exports, "PollingClient", { enumerable: true, get: function () { return pollingClient_1.PollingClient; } });
83
88
  var streamingClient_1 = require("./status/streamingClient");
@@ -91,6 +96,8 @@ Object.defineProperty(exports, "REQUIRED_FIELDS", { enumerable: true, get: funct
91
96
  Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_1.User; } });
92
97
  var permissionSetAssignment_1 = require("./org/permissionSetAssignment");
93
98
  Object.defineProperty(exports, "PermissionSetAssignment", { enumerable: true, get: function () { return permissionSetAssignment_1.PermissionSetAssignment; } });
99
+ var scratchOrgCreate_1 = require("./org/scratchOrgCreate");
100
+ Object.defineProperty(exports, "scratchOrgCreate", { enumerable: true, get: function () { return scratchOrgCreate_1.scratchOrgCreate; } });
94
101
  // Utility sub-modules
95
102
  __exportStar(require("./util/fs"), exports);
96
103
  __exportStar(require("./util/sfdc"), exports);
@@ -7,7 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.AliasAccessor = void 0;
10
- const sfdxError_1 = require("../../sfdxError");
10
+ const sfError_1 = require("../../sfError");
11
11
  const types_1 = require("../types");
12
12
  class AliasAccessor {
13
13
  constructor(globalInfo) {
@@ -121,7 +121,7 @@ class AliasAccessor {
121
121
  return entity;
122
122
  const aliaseeName = (_a = entity.username) !== null && _a !== void 0 ? _a : entity.user;
123
123
  if (!aliaseeName) {
124
- throw new sfdxError_1.SfdxError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
124
+ throw new sfError_1.SfError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
125
125
  }
126
126
  return aliaseeName;
127
127
  }
@@ -170,7 +170,7 @@ class Lifecycle {
170
170
  */
171
171
  async emit(eventName, data) {
172
172
  const listeners = this.getListeners(eventName);
173
- if (listeners.length === 0) {
173
+ if (listeners.length === 0 && eventName !== Lifecycle.warningEventName) {
174
174
  this.debug(`A lifecycle event with the name ${eventName} does not exist. An event must be registered before it can be emitted.`);
175
175
  }
176
176
  else {
package/lib/logger.d.ts CHANGED
@@ -174,7 +174,7 @@ export declare class Logger {
174
174
  *
175
175
  * @param optionsOrName A set of `LoggerOptions` or name to use with the default options.
176
176
  *
177
- * **Throws** *{@link SfdxError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
177
+ * **Throws** *{@link SfError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
178
178
  * `Logger`.
179
179
  */
180
180
  constructor(optionsOrName: LoggerOptions | string);
@@ -211,7 +211,7 @@ export declare class Logger {
211
211
  *
212
212
  * @param {string} levelName The level name to convert to a `LoggerLevel` enum value.
213
213
  *
214
- * **Throws** *{@link SfdxError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
214
+ * **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
215
215
  * @see {@Link LoggerLevel}
216
216
  */
217
217
  static getLevelByName(levelName: string): LoggerLevelValue;
@@ -249,7 +249,7 @@ export declare class Logger {
249
249
  *
250
250
  * @param {LoggerLevelValue} [level] The logger level.
251
251
  *
252
- * **Throws** *{@link SfdxError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
252
+ * **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
253
253
  * was invalid.
254
254
  *
255
255
  * ```
package/lib/logger.js CHANGED
@@ -11,14 +11,13 @@ const events_1 = require("events");
11
11
  const os = require("os");
12
12
  const path = require("path");
13
13
  const stream_1 = require("stream");
14
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15
14
  // @ts-ignore
16
15
  const Bunyan = require("@salesforce/bunyan");
17
16
  const kit_1 = require("@salesforce/kit");
18
17
  const ts_types_1 = require("@salesforce/ts-types");
19
18
  const Debug = require("debug");
20
19
  const global_1 = require("./global");
21
- const sfdxError_1 = require("./sfdxError");
20
+ const sfError_1 = require("./sfError");
22
21
  const fs_1 = require("./util/fs");
23
22
  /**
24
23
  * Standard `Logger` levels.
@@ -69,7 +68,7 @@ class Logger {
69
68
  *
70
69
  * @param optionsOrName A set of `LoggerOptions` or name to use with the default options.
71
70
  *
72
- * **Throws** *{@link SfdxError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
71
+ * **Throws** *{@link SfError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
73
72
  * `Logger`.
74
73
  */
75
74
  constructor(optionsOrName) {
@@ -103,7 +102,7 @@ class Logger {
103
102
  options = optionsOrName;
104
103
  }
105
104
  if (Logger.rootLogger && options.name === Logger.ROOT_NAME) {
106
- throw new sfdxError_1.SfdxError('Can not create another root logger.', 'RedundantRootLoggerError');
105
+ throw new sfError_1.SfError('Can not create another root logger.', 'RedundantRootLoggerError');
107
106
  }
108
107
  // Inspect format to know what logging format to use then delete from options to
109
108
  // ensure it doesn't conflict with Bunyan.
@@ -199,13 +198,13 @@ class Logger {
199
198
  *
200
199
  * @param {string} levelName The level name to convert to a `LoggerLevel` enum value.
201
200
  *
202
- * **Throws** *{@link SfdxError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
201
+ * **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
203
202
  * @see {@Link LoggerLevel}
204
203
  */
205
204
  static getLevelByName(levelName) {
206
205
  levelName = levelName.toUpperCase();
207
206
  if (!(0, ts_types_1.isKeyOf)(LoggerLevel, levelName)) {
208
- throw new sfdxError_1.SfdxError(`Invalid log level "${levelName}".`, 'UnrecognizedLoggerLevelNameError');
207
+ throw new sfError_1.SfError(`Invalid log level "${levelName}".`, 'UnrecognizedLoggerLevelNameError');
209
208
  }
210
209
  return LoggerLevel[levelName];
211
210
  }
@@ -244,7 +243,7 @@ class Logger {
244
243
  await fs_1.fs.writeFile(logFile, '', { mode: fs_1.fs.DEFAULT_USER_FILE_MODE });
245
244
  }
246
245
  catch (err3) {
247
- throw sfdxError_1.SfdxError.wrap(err3);
246
+ throw sfError_1.SfError.wrap(err3);
248
247
  }
249
248
  }
250
249
  // avoid multiple streams to same log file
@@ -284,7 +283,7 @@ class Logger {
284
283
  fs_1.fs.writeFileSync(logFile, '', { mode: fs_1.fs.DEFAULT_USER_FILE_MODE });
285
284
  }
286
285
  catch (err3) {
287
- throw sfdxError_1.SfdxError.wrap(err3);
286
+ throw sfError_1.SfError.wrap(err3);
288
287
  }
289
288
  }
290
289
  // avoid multiple streams to same log file
@@ -320,7 +319,7 @@ class Logger {
320
319
  *
321
320
  * @param {LoggerLevelValue} [level] The logger level.
322
321
  *
323
- * **Throws** *{@link SfdxError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
322
+ * **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
324
323
  * was invalid.
325
324
  *
326
325
  * ```
@@ -453,7 +452,7 @@ class Logger {
453
452
  */
454
453
  child(name, fields = {}) {
455
454
  if (!name) {
456
- throw new sfdxError_1.SfdxError('LoggerNameRequired');
455
+ throw new sfError_1.SfError('LoggerNameRequired');
457
456
  }
458
457
  fields.log = name;
459
458
  const child = new Logger(name);
package/lib/messages.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AnyJson } from '@salesforce/ts-types';
2
- import { SfdxError } from './sfdxError';
2
+ import { SfError } from './sfError';
3
3
  export declare type Tokens = Array<string | boolean | number | null | undefined>;
4
4
  /**
5
5
  * A loader function to return messages.
@@ -247,6 +247,6 @@ export declare class Messages<T extends string> {
247
247
  * @param exitCodeOrCause The exit code which will be used by SfdxCommand or he underlying error that caused this error to be raised.
248
248
  * @param cause The underlying error that caused this error to be raised.
249
249
  */
250
- createError(key: T, tokens?: Tokens, actionTokens?: Tokens, exitCodeOrCause?: number | Error, cause?: Error): SfdxError;
250
+ createError(key: T, tokens?: Tokens, actionTokens?: Tokens, exitCodeOrCause?: number | Error, cause?: Error): SfError;
251
251
  private getMessageWithMap;
252
252
  }
package/lib/messages.js CHANGED
@@ -13,7 +13,7 @@ const path = require("path");
13
13
  const util = require("util");
14
14
  const ts_types_1 = require("@salesforce/ts-types");
15
15
  const kit_1 = require("@salesforce/kit");
16
- const sfdxError_1 = require("./sfdxError");
16
+ const sfError_1 = require("./sfError");
17
17
  class Key {
18
18
  constructor(packageName, bundleName) {
19
19
  this.packageName = packageName;
@@ -57,7 +57,7 @@ const markdownLoader = (filePath, fileContents) => {
57
57
  }
58
58
  }
59
59
  else {
60
- // use error instead of SfdxError because messages.js should have no internal dependencies.
60
+ // use error instead of SfError because messages.js should have no internal dependencies.
61
61
  throw new Error(`Invalid markdown message file: ${filePath}\nThe line "# <key>" must be immediately followed by the message on a new line.`);
62
62
  }
63
63
  }
@@ -217,7 +217,7 @@ class Messages {
217
217
  if (!fileContents || fileContents.trim().length === 0) {
218
218
  // messages.js should have no internal dependencies.
219
219
  const error = new Error(`Invalid message file: ${filePath}. No content.`);
220
- error.name = 'SfdxError';
220
+ error.name = 'SfError';
221
221
  throw error;
222
222
  }
223
223
  const map = parser(filePath, fileContents);
@@ -456,7 +456,7 @@ class Messages {
456
456
  catch (e) {
457
457
  /* just ignore if actions aren't found */
458
458
  }
459
- return new sfdxError_1.SfdxError(errMessage, errName, errActions, exitCodeOrCause, cause);
459
+ return new sfError_1.SfError(errMessage, errName, errActions, exitCodeOrCause, cause);
460
460
  }
461
461
  getMessageWithMap(key, tokens = [], map) {
462
462
  // Allow nested keys for better grouping
@@ -253,7 +253,7 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
253
253
  *
254
254
  * @param options Options to be used for creating an OAuth2 instance.
255
255
  *
256
- * **Throws** *{@link SfdxError}{ name: 'NamedOrgNotFoundError' }* Org information does not exist.
256
+ * **Throws** *{@link SfError}{ name: 'NamedOrgNotFoundError' }* Org information does not exist.
257
257
  * @returns {Promise<AuthInfo>}
258
258
  */
259
259
  private initAuthOptions;
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthInfo = exports.DEFAULT_CONNECTED_APP_INFO = void 0;
2
4
  /*
3
5
  * Copyright (c) 2020, salesforce.com, inc.
4
6
  * All rights reserved.
5
7
  * Licensed under the BSD 3-Clause license.
6
8
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
9
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.AuthInfo = exports.DEFAULT_CONNECTED_APP_INFO = void 0;
10
- /* eslint-disable @typescript-eslint/ban-ts-comment */
11
10
  const crypto_1 = require("crypto");
12
11
  const path_1 = require("path");
13
12
  const os = require("os");
@@ -19,7 +18,7 @@ const jwt = require("jsonwebtoken");
19
18
  const config_1 = require("../config/config");
20
19
  const configAggregator_1 = require("../config/configAggregator");
21
20
  const logger_1 = require("../logger");
22
- const sfdxError_1 = require("../sfdxError");
21
+ const sfError_1 = require("../sfError");
23
22
  const fs_1 = require("../util/fs");
24
23
  const sfdc_1 = require("../util/sfdc");
25
24
  const globalInfo_1 = require("../globalInfo");
@@ -237,7 +236,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
237
236
  static parseSfdxAuthUrl(sfdxAuthUrl) {
238
237
  const match = sfdxAuthUrl.match(/^force:\/\/([a-zA-Z0-9._-]+):([a-zA-Z0-9._-]*):([a-zA-Z0-9._-]+={0,2})@([a-zA-Z0-9._-]+)/);
239
238
  if (!match) {
240
- throw new sfdxError_1.SfdxError('Invalid SFDX auth URL. Must be in the format "force://<clientId>:<clientSecret>:<refreshToken>@<instanceUrl>". Note that the SFDX auth URL uses the "force" protocol, and not "http" or "https". Also note that the "instanceUrl" inside the SFDX auth URL doesn\'t include the protocol ("https://").', 'INVALID_SFDX_AUTH_URL');
239
+ throw new sfError_1.SfError('Invalid SFDX auth URL. Must be in the format "force://<clientId>:<clientSecret>:<refreshToken>@<instanceUrl>". Note that the SFDX auth URL uses the "force" protocol, and not "http" or "https". Also note that the "instanceUrl" inside the SFDX auth URL doesn\'t include the protocol ("https://").', 'INVALID_SFDX_AUTH_URL');
241
240
  }
242
241
  const [, clientId, clientSecret, refreshToken, loginUrl] = match;
243
242
  return {
@@ -490,7 +489,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
490
489
  *
491
490
  * @param options Options to be used for creating an OAuth2 instance.
492
491
  *
493
- * **Throws** *{@link SfdxError}{ name: 'NamedOrgNotFoundError' }* Org information does not exist.
492
+ * **Throws** *{@link SfError}{ name: 'NamedOrgNotFoundError' }* Org information does not exist.
494
493
  * @returns {Promise<AuthInfo>}
495
494
  */
496
495
  async initAuthOptions(options) {
@@ -769,7 +768,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
769
768
  catch (err) {
770
769
  errorMsg = `${bodyAsString}`;
771
770
  }
772
- throw new sfdxError_1.SfdxError(errorMsg);
771
+ throw new sfError_1.SfError(errorMsg);
773
772
  }
774
773
  }
775
774
  exports.AuthInfo = AuthInfo;
@@ -39,8 +39,8 @@ export declare class AuthRemover extends AsyncOptionalCreatable {
39
39
  removeAllAuths(): Promise<void>;
40
40
  /**
41
41
  * Finds authorization files for username/alias in the global .sfdx folder
42
- * **Throws** *{@link SfdxError}{ name: 'TargetOrgNotSetError' }* if no target-org
43
- * **Throws** *{@link SfdxError}{ name: 'NamedOrgNotFoundError' }* if specified user is not found
42
+ * **Throws** *{@link SfError}{ name: 'TargetOrgNotSetError' }* if no target-org
43
+ * **Throws** *{@link SfError}{ name: 'NamedOrgNotFoundError' }* if specified user is not found
44
44
  *
45
45
  * @param usernameOrAlias username or alias of the auth you want to find, defaults to the configured target-org
46
46
  * @returns {Promise<SfOrg>}
@@ -66,8 +66,8 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
66
66
  }
67
67
  /**
68
68
  * Finds authorization files for username/alias in the global .sfdx folder
69
- * **Throws** *{@link SfdxError}{ name: 'TargetOrgNotSetError' }* if no target-org
70
- * **Throws** *{@link SfdxError}{ name: 'NamedOrgNotFoundError' }* if specified user is not found
69
+ * **Throws** *{@link SfError}{ name: 'TargetOrgNotSetError' }* if no target-org
70
+ * **Throws** *{@link SfError}{ name: 'NamedOrgNotFoundError' }* if specified user is not found
71
71
  *
72
72
  * @param usernameOrAlias username or alias of the auth you want to find, defaults to the configured target-org
73
73
  * @returns {Promise<SfOrg>}
@@ -4,8 +4,8 @@ import { JsonCollection, JsonMap, Optional } from '@salesforce/ts-types';
4
4
  import { Connection as JSForceConnection, ConnectionConfig, HttpRequest, QueryOptions, QueryResult, Record, Schema } from 'jsforce';
5
5
  import { Tooling as JSForceTooling } from 'jsforce/lib/api/tooling';
6
6
  import { StreamPromise } from 'jsforce/lib/util/promise';
7
- import { AuthFields, AuthInfo } from '../org/authInfo';
8
7
  import { ConfigAggregator } from '../config/configAggregator';
8
+ import { AuthFields, AuthInfo } from './authInfo';
9
9
  export declare const SFDX_HTTP_HEADERS: {
10
10
  'content-type': string;
11
11
  'user-agent': string;
@@ -123,7 +123,7 @@ export declare class Connection<S extends Schema = Schema> extends JSForceConnec
123
123
  /**
124
124
  * Set the API version for all connection requests.
125
125
  *
126
- * **Throws** *{@link SfdxError}{ name: 'IncorrectAPIVersionError' }* Incorrect API version.
126
+ * **Throws** *{@link SfError}{ name: 'IncorrectAPIVersionError' }* Incorrect API version.
127
127
  *
128
128
  * @param version The API version.
129
129
  */
@@ -171,6 +171,11 @@ export declare class Connection<S extends Schema = Schema> extends JSForceConnec
171
171
  * @param options The query options.
172
172
  */
173
173
  singleRecordQuery<T extends Record>(soql: string, options?: SingleRecordQueryOptions): Promise<T>;
174
+ /**
175
+ * Executes a get request on the baseUrl to force an auth refresh
176
+ * Useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes
177
+ */
178
+ refreshAuth(): Promise<void>;
174
179
  private loadInstanceApiVersion;
175
180
  }
176
181
  export declare const SingleRecordQueryErrors: {
@@ -17,7 +17,7 @@ const tooling_1 = require("jsforce/lib/api/tooling");
17
17
  const myDomainResolver_1 = require("../status/myDomainResolver");
18
18
  const configAggregator_1 = require("../config/configAggregator");
19
19
  const logger_1 = require("../logger");
20
- const sfdxError_1 = require("../sfdxError");
20
+ const sfError_1 = require("../sfError");
21
21
  const sfdc_1 = require("../util/sfdc");
22
22
  const messages_1 = require("../messages");
23
23
  const lifecycleEvents_1 = require("../lifecycleEvents");
@@ -138,6 +138,7 @@ class Connection extends jsforce_1.Connection {
138
138
  delete options.rest;
139
139
  if (rest) {
140
140
  this.logger.debug('deploy with REST');
141
+ await this.refreshAuth();
141
142
  const headers = {
142
143
  Authorization: this && `OAuth ${this.accessToken}`,
143
144
  'Sforce-Call-Options': 'client=sfdx-core',
@@ -273,7 +274,7 @@ class Connection extends jsforce_1.Connection {
273
274
  /**
274
275
  * Set the API version for all connection requests.
275
276
  *
276
- * **Throws** *{@link SfdxError}{ name: 'IncorrectAPIVersionError' }* Incorrect API version.
277
+ * **Throws** *{@link SfError}{ name: 'IncorrectAPIVersionError' }* Incorrect API version.
277
278
  *
278
279
  * @param version The API version.
279
280
  */
@@ -356,15 +357,27 @@ class Connection extends jsforce_1.Connection {
356
357
  }) {
357
358
  const result = options.tooling ? await this.tooling.query(soql) : await this.query(soql);
358
359
  if (result.totalSize === 0) {
359
- throw new sfdxError_1.SfdxError(`No record found for ${soql}`, exports.SingleRecordQueryErrors.NoRecords);
360
+ throw new sfError_1.SfError(`No record found for ${soql}`, exports.SingleRecordQueryErrors.NoRecords);
360
361
  }
361
362
  if (result.totalSize > 1) {
362
- throw new sfdxError_1.SfdxError(options.returnChoicesOnMultiple
363
+ throw new sfError_1.SfError(options.returnChoicesOnMultiple
363
364
  ? `Multiple records found. ${result.records.map((item) => item[options.choiceField]).join(',')}`
364
365
  : 'The query returned more than 1 record', exports.SingleRecordQueryErrors.MultipleRecords);
365
366
  }
366
367
  return result.records[0];
367
368
  }
369
+ /**
370
+ * Executes a get request on the baseUrl to force an auth refresh
371
+ * Useful for the raw methods (request, requestRaw) that use the accessToken directly and don't handle refreshes
372
+ */
373
+ async refreshAuth() {
374
+ this.logger.debug('Refreshing auth for org.');
375
+ const requestInfo = {
376
+ url: this.baseUrl(),
377
+ method: 'GET',
378
+ };
379
+ await this.request(requestInfo);
380
+ }
368
381
  async loadInstanceApiVersion() {
369
382
  const authFileFields = this.options.authInfo.getFields();
370
383
  const lastCheckedDateString = authFileFields.instanceApiVersionLastRetrieved;