@salesforce/core 4.0.0 → 4.1.0

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 (151) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +93 -44
  3. package/lib/config/authInfoConfig.d.ts +19 -0
  4. package/lib/config/authInfoConfig.js +35 -0
  5. package/lib/config/config.d.ts +87 -22
  6. package/lib/config/config.js +117 -65
  7. package/lib/config/configAggregator.d.ts +41 -35
  8. package/lib/config/configAggregator.js +102 -73
  9. package/lib/config/configFile.d.ts +2 -2
  10. package/lib/config/configFile.js +38 -29
  11. package/lib/config/configStore.d.ts +9 -9
  12. package/lib/config/configStore.js +17 -15
  13. package/lib/config/envVars.d.ts +15 -9
  14. package/lib/config/envVars.js +71 -47
  15. package/lib/config/orgUsersConfig.js +2 -0
  16. package/lib/config/sandboxOrgConfig.js +2 -0
  17. package/lib/config/sandboxProcessCache.d.ts +16 -0
  18. package/lib/config/sandboxProcessCache.js +38 -0
  19. package/lib/config/tokensConfig.d.ts +10 -0
  20. package/lib/config/tokensConfig.js +29 -0
  21. package/lib/config/ttlConfig.d.ts +34 -0
  22. package/lib/config/ttlConfig.js +50 -0
  23. package/lib/crypto/crypto.js +15 -22
  24. package/lib/crypto/keyChain.js +2 -3
  25. package/lib/crypto/keyChainImpl.d.ts +5 -3
  26. package/lib/crypto/keyChainImpl.js +58 -61
  27. package/lib/crypto/secureBuffer.d.ts +1 -1
  28. package/lib/deviceOauthService.d.ts +3 -3
  29. package/lib/deviceOauthService.js +27 -25
  30. package/lib/exported.d.ts +15 -12
  31. package/lib/exported.js +28 -16
  32. package/lib/global.d.ts +11 -3
  33. package/lib/global.js +39 -12
  34. package/lib/lifecycleEvents.d.ts +1 -1
  35. package/lib/lifecycleEvents.js +3 -0
  36. package/lib/logger.d.ts +19 -9
  37. package/lib/logger.js +112 -86
  38. package/lib/messages.d.ts +53 -36
  39. package/lib/messages.js +81 -91
  40. package/lib/org/authInfo.d.ts +56 -20
  41. package/lib/org/authInfo.js +232 -131
  42. package/lib/org/authRemover.d.ts +8 -7
  43. package/lib/org/authRemover.js +32 -28
  44. package/lib/org/connection.d.ts +13 -37
  45. package/lib/org/connection.js +78 -124
  46. package/lib/org/index.js +5 -1
  47. package/lib/org/org.d.ts +151 -48
  48. package/lib/org/org.js +468 -225
  49. package/lib/org/orgConfigProperties.d.ts +64 -3
  50. package/lib/org/orgConfigProperties.js +96 -4
  51. package/lib/org/permissionSetAssignment.js +4 -13
  52. package/lib/org/scratchOrgCache.d.ts +20 -0
  53. package/lib/org/scratchOrgCache.js +33 -0
  54. package/lib/org/scratchOrgCreate.d.ts +28 -17
  55. package/lib/org/scratchOrgCreate.js +125 -53
  56. package/lib/org/scratchOrgErrorCodes.d.ts +9 -3
  57. package/lib/org/scratchOrgErrorCodes.js +34 -17
  58. package/lib/org/scratchOrgFeatureDeprecation.js +1 -6
  59. package/lib/org/scratchOrgInfoApi.d.ts +21 -47
  60. package/lib/org/scratchOrgInfoApi.js +129 -63
  61. package/lib/org/scratchOrgInfoGenerator.d.ts +6 -5
  62. package/lib/org/scratchOrgInfoGenerator.js +76 -62
  63. package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -0
  64. package/lib/org/scratchOrgLifecycleEvents.js +41 -0
  65. package/lib/org/scratchOrgSettingsGenerator.d.ts +44 -21
  66. package/lib/org/scratchOrgSettingsGenerator.js +165 -98
  67. package/lib/org/scratchOrgTypes.d.ts +43 -0
  68. package/lib/org/scratchOrgTypes.js +9 -0
  69. package/lib/org/user.d.ts +1 -1
  70. package/lib/org/user.js +25 -34
  71. package/lib/schema/printer.d.ts +6 -0
  72. package/lib/schema/printer.js +34 -31
  73. package/lib/schema/validator.d.ts +12 -10
  74. package/lib/schema/validator.js +56 -76
  75. package/lib/{sfdxError.d.ts → sfError.d.ts} +12 -20
  76. package/lib/{sfdxError.js → sfError.js} +40 -30
  77. package/lib/{sfdxProject.d.ts → sfProject.d.ts} +75 -35
  78. package/lib/sfProject.js +651 -0
  79. package/lib/stateAggregator/accessors/aliasAccessor.d.ts +129 -0
  80. package/lib/stateAggregator/accessors/aliasAccessor.js +263 -0
  81. package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -0
  82. package/lib/stateAggregator/accessors/orgAccessor.js +240 -0
  83. package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -0
  84. package/lib/stateAggregator/accessors/sandboxAccessor.js +28 -0
  85. package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -0
  86. package/lib/stateAggregator/accessors/tokenAccessor.js +80 -0
  87. package/lib/stateAggregator/index.d.ts +4 -0
  88. package/lib/stateAggregator/index.js +27 -0
  89. package/lib/stateAggregator/stateAggregator.d.ts +25 -0
  90. package/lib/stateAggregator/stateAggregator.js +46 -0
  91. package/lib/status/myDomainResolver.d.ts +1 -1
  92. package/lib/status/myDomainResolver.js +4 -4
  93. package/lib/status/pollingClient.js +4 -4
  94. package/lib/status/streamingClient.d.ts +2 -2
  95. package/lib/status/streamingClient.js +58 -63
  96. package/lib/status/types.d.ts +2 -2
  97. package/lib/testSetup.d.ts +204 -75
  98. package/lib/testSetup.js +468 -164
  99. package/lib/util/cache.d.ts +2 -2
  100. package/lib/util/cache.js +6 -6
  101. package/lib/util/checkLightningDomain.js +3 -4
  102. package/lib/util/directoryWriter.d.ts +12 -0
  103. package/lib/util/directoryWriter.js +54 -0
  104. package/lib/util/getJwtAudienceUrl.js +1 -1
  105. package/lib/util/internal.d.ts +28 -2
  106. package/lib/util/internal.js +65 -8
  107. package/lib/util/jsonXmlTools.js +2 -4
  108. package/lib/util/mapKeys.d.ts +9 -9
  109. package/lib/util/mapKeys.js +13 -9
  110. package/lib/util/sfdc.d.ts +51 -51
  111. package/lib/util/sfdc.js +74 -79
  112. package/lib/util/sfdcUrl.d.ts +5 -19
  113. package/lib/util/sfdcUrl.js +40 -49
  114. package/lib/util/structuredWriter.d.ts +9 -0
  115. package/lib/util/structuredWriter.js +3 -0
  116. package/lib/util/zipWriter.d.ts +8 -6
  117. package/lib/util/zipWriter.js +13 -13
  118. package/lib/webOAuthServer.d.ts +20 -6
  119. package/lib/webOAuthServer.js +102 -56
  120. package/messageTransformer/messageTransformer.ts +93 -0
  121. package/messages/auth.md +9 -1
  122. package/messages/config.md +42 -6
  123. package/messages/connection.md +8 -0
  124. package/messages/core.md +10 -0
  125. package/messages/envVars.md +37 -3
  126. package/messages/org.md +21 -1
  127. package/messages/scratchOrgCreate.md +2 -6
  128. package/messages/scratchOrgErrorCodes.md +17 -1
  129. package/messages/scratchOrgInfoApi.md +9 -0
  130. package/messages/scratchOrgInfoGenerator.md +9 -1
  131. package/package.json +123 -46
  132. package/CHANGELOG.md +0 -1244
  133. package/lib/config/keychainConfig.d.ts +0 -19
  134. package/lib/config/keychainConfig.js +0 -43
  135. package/lib/globalInfo/accessors/aliasAccessor.d.ts +0 -83
  136. package/lib/globalInfo/accessors/aliasAccessor.js +0 -130
  137. package/lib/globalInfo/accessors/orgAccessor.d.ts +0 -13
  138. package/lib/globalInfo/accessors/orgAccessor.js +0 -45
  139. package/lib/globalInfo/accessors/tokenAccessor.d.ts +0 -13
  140. package/lib/globalInfo/accessors/tokenAccessor.js +0 -35
  141. package/lib/globalInfo/globalInfoConfig.d.ts +0 -36
  142. package/lib/globalInfo/globalInfoConfig.js +0 -105
  143. package/lib/globalInfo/index.d.ts +0 -6
  144. package/lib/globalInfo/index.js +0 -29
  145. package/lib/globalInfo/sfdxDataHandler.d.ts +0 -43
  146. package/lib/globalInfo/sfdxDataHandler.js +0 -217
  147. package/lib/globalInfo/types.d.ts +0 -39
  148. package/lib/globalInfo/types.js +0 -10
  149. package/lib/sfdxProject.js +0 -557
  150. package/lib/util/fs.d.ts +0 -201
  151. package/lib/util/fs.js +0 -378
@@ -11,7 +11,7 @@ const kit_1 = require("@salesforce/kit");
11
11
  const ts_types_1 = require("@salesforce/ts-types");
12
12
  const ts_types_2 = require("@salesforce/ts-types");
13
13
  const crypto_1 = require("../crypto/crypto");
14
- const sfdxError_1 = require("../sfdxError");
14
+ const sfError_1 = require("../sfError");
15
15
  /**
16
16
  * An abstract class that implements all the config management functions but
17
17
  * none of the storage functions.
@@ -28,7 +28,7 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
28
28
  constructor(options) {
29
29
  super(options);
30
30
  this.statics = this.constructor;
31
- this.options = options || {};
31
+ this.options = options ?? {};
32
32
  this.setContents(this.initialContents());
33
33
  }
34
34
  /**
@@ -183,6 +183,8 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
183
183
  async awaitEach(actionFn) {
184
184
  const entries = this.entries();
185
185
  for (const entry of entries) {
186
+ // prevent ConfigFile collision bug
187
+ // eslint-disable-next-line no-await-in-loop
186
188
  await actionFn(entry[0], entry[1]);
187
189
  }
188
190
  }
@@ -198,16 +200,14 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
198
200
  *
199
201
  * @param obj The object.
200
202
  */
201
- // eslint-disable-next-line @typescript-eslint/ban-types
202
203
  setContentsFromObject(obj) {
203
- this.contents = {};
204
+ this.contents = (this.hasEncryption() ? this.recursiveEncrypt(obj) : {});
204
205
  Object.entries(obj).forEach(([key, value]) => {
205
206
  this.setMethod(this.contents, key, value);
206
207
  });
207
208
  }
208
209
  getEncryptedKeys() {
209
- var _a, _b;
210
- return [...(((_a = this.options) === null || _a === void 0 ? void 0 : _a.encryptedKeys) || []), ...(((_b = this.statics) === null || _b === void 0 ? void 0 : _b.encryptedKeys) || [])];
210
+ return [...(this.options?.encryptedKeys ?? []), ...(this.statics?.encryptedKeys || [])];
211
211
  }
212
212
  /**
213
213
  * This config file has encrypted keys and it should attempt to encrypt them.
@@ -219,15 +219,18 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
219
219
  }
220
220
  // Allows extended classes the ability to override the set method. i.e. maybe they want
221
221
  // nested object set from kit.
222
+ // eslint-disable-next-line class-methods-use-this
222
223
  setMethod(contents, key, value) {
223
224
  (0, kit_1.set)(contents, key, value);
224
225
  }
225
226
  // Allows extended classes the ability to override the get method. i.e. maybe they want
226
227
  // nested object get from ts-types.
227
228
  // NOTE: Key must stay string to be reliably overwritten.
229
+ // eslint-disable-next-line class-methods-use-this
228
230
  getMethod(contents, key) {
229
231
  return (0, ts_types_2.get)(contents, key);
230
232
  }
233
+ // eslint-disable-next-line class-methods-use-this
231
234
  initialContents() {
232
235
  return {};
233
236
  }
@@ -269,7 +272,7 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
269
272
  const dotAccessor = /\.([a-zA-Z0-9@._-]+)$/;
270
273
  const singleQuoteAccessor = /\['([a-zA-Z0-9@._-]+)'\]$/;
271
274
  const doubleQuoteAccessor = /\["([a-zA-Z0-9@._-]+)"\]$/;
272
- const matcher = dotAccessor.exec(key) || singleQuoteAccessor.exec(key) || doubleQuoteAccessor.exec(key);
275
+ const matcher = dotAccessor.exec(key) ?? singleQuoteAccessor.exec(key) ?? doubleQuoteAccessor.exec(key);
273
276
  return matcher ? matcher[1] : key;
274
277
  }
275
278
  // Any keys named the following should be encrypted/decrypted
@@ -287,18 +290,18 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
287
290
  if (!value)
288
291
  return;
289
292
  if (!this.crypto)
290
- throw new sfdxError_1.SfdxError('crypto is not initialized', 'CryptoNotInitializedError');
293
+ throw new sfError_1.SfError('crypto is not initialized', 'CryptoNotInitializedError');
291
294
  if (!(0, ts_types_2.isString)(value))
292
- throw new sfdxError_1.SfdxError(`can only encrypt strings but found: ${typeof value} : ${value}`, 'InvalidCryptoValueError');
295
+ throw new sfError_1.SfError(`can only encrypt strings but found: ${typeof value} : ${value.toString()}`, 'InvalidCryptoValueError');
293
296
  return this.crypto.isEncrypted(value) ? value : this.crypto.encrypt(value);
294
297
  }
295
298
  decrypt(value) {
296
299
  if (!value)
297
300
  return;
298
301
  if (!this.crypto)
299
- throw new sfdxError_1.SfdxError('crypto is not initialized', 'CryptoNotInitializedError');
302
+ throw new sfError_1.SfError('crypto is not initialized', 'CryptoNotInitializedError');
300
303
  if (!(0, ts_types_2.isString)(value))
301
- throw new sfdxError_1.SfdxError(`can only encrypt strings but found: ${typeof value} : ${value}`, 'InvalidCryptoValueError');
304
+ throw new sfError_1.SfError(`can only encrypt strings but found: ${typeof value} : ${value.toString()}`, 'InvalidCryptoValueError');
302
305
  return this.crypto.isEncrypted(value) ? this.crypto.decrypt(value) : value;
303
306
  }
304
307
  /**
@@ -339,13 +342,12 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
339
342
  this.recursiveCrypto(method, [...keyPaths, key, newKey], value);
340
343
  }
341
344
  }
342
- else {
343
- if (this.isCryptoKey(key)) {
344
- data[key] = method(value);
345
- }
345
+ else if (this.isCryptoKey(key)) {
346
+ data[key] = method(value);
346
347
  }
347
348
  }
348
349
  }
349
350
  exports.BaseConfigStore = BaseConfigStore;
351
+ // If encryptedKeys is an array of RegExps, they should not contain the /g (global) or /y (sticky) flags to avoid stateful issues.
350
352
  BaseConfigStore.encryptedKeys = [];
351
353
  //# sourceMappingURL=configStore.js.map
@@ -25,7 +25,10 @@ export declare enum EnvironmentVariable {
25
25
  'SFDX_IMPROVED_CODE_COVERAGE' = "SFDX_IMPROVED_CODE_COVERAGE",
26
26
  'SFDX_INSTANCE_URL' = "SFDX_INSTANCE_URL",
27
27
  'SFDX_JSON_TO_STDOUT' = "SFDX_JSON_TO_STDOUT",
28
+ 'SFDX_DISABLE_LOG_FILE' = "SFDX_DISABLE_LOG_FILE",
28
29
  'SFDX_LOG_LEVEL' = "SFDX_LOG_LEVEL",
30
+ 'SFDX_LOG_ROTATION_COUNT' = "SFDX_LOG_ROTATION_COUNT",
31
+ 'SFDX_LOG_ROTATION_PERIOD' = "SFDX_LOG_ROTATION_PERIOD",
29
32
  'SFDX_MAX_QUERY_LIMIT' = "SFDX_MAX_QUERY_LIMIT",
30
33
  'SFDX_MDAPI_TEMP_DIR' = "SFDX_MDAPI_TEMP_DIR",
31
34
  'SFDX_NPM_REGISTRY' = "SFDX_NPM_REGISTRY",
@@ -44,7 +47,7 @@ export declare enum EnvironmentVariable {
44
47
  'SF_TARGET_ORG' = "SF_TARGET_ORG",
45
48
  'SF_TARGET_DEV_HUB' = "SF_TARGET_DEV_HUB",
46
49
  'SF_ACCESS_TOKEN' = "SF_ACCESS_TOKEN",
47
- 'SF_API_VERSION' = "SF_API_VERSION",
50
+ 'SF_ORG_API_VERSION' = "SF_ORG_API_VERSION",
48
51
  'SF_AUDIENCE_URL' = "SF_AUDIENCE_URL",
49
52
  'SF_CODE_COVERAGE_REQUIREMENT' = "SF_CODE_COVERAGE_REQUIREMENT",
50
53
  'SF_CONTENT_TYPE' = "SF_CONTENT_TYPE",
@@ -55,10 +58,13 @@ export declare enum EnvironmentVariable {
55
58
  'SF_DNS_TIMEOUT' = "SF_DNS_TIMEOUT",
56
59
  'SF_DOMAIN_RETRY' = "SF_DOMAIN_RETRY",
57
60
  'SF_IMPROVED_CODE_COVERAGE' = "SF_IMPROVED_CODE_COVERAGE",
58
- 'SF_INSTANCE_URL' = "SF_INSTANCE_URL",
61
+ 'SF_ORG_INSTANCE_URL' = "SF_ORG_INSTANCE_URL",
59
62
  'SF_JSON_TO_STDOUT' = "SF_JSON_TO_STDOUT",
63
+ 'SF_DISABLE_LOG_FILE' = "SF_DISABLE_LOG_FILE",
60
64
  'SF_LOG_LEVEL' = "SF_LOG_LEVEL",
61
- 'SF_MAX_QUERY_LIMIT' = "SF_MAX_QUERY_LIMIT",
65
+ 'SF_LOG_ROTATION_COUNT' = "SF_LOG_ROTATION_COUNT",
66
+ 'SF_LOG_ROTATION_PERIOD' = "SF_LOG_ROTATION_PERIOD",
67
+ 'SF_ORG_MAX_QUERY_LIMIT' = "SF_ORG_MAX_QUERY_LIMIT",
62
68
  'SF_MDAPI_TEMP_DIR' = "SF_MDAPI_TEMP_DIR",
63
69
  'SF_NPM_REGISTRY' = "SF_NPM_REGISTRY",
64
70
  'SF_PRECOMPILE_ENABLE' = "SF_PRECOMPILE_ENABLE",
@@ -73,22 +79,22 @@ export declare enum EnvironmentVariable {
73
79
  'SF_INSTALLER' = "SF_INSTALLER",
74
80
  'SF_ENV' = "SF_ENV"
75
81
  }
76
- declare type EnvMetaData = {
82
+ type EnvMetaData = {
77
83
  description: string;
84
+ /** the env has been renamed. synonymOf points to the new env */
78
85
  synonymOf: Nullable<string>;
79
86
  };
80
- declare type EnvType = {
87
+ type EnvType = {
81
88
  [key in EnvironmentVariable]: EnvMetaData;
82
89
  };
83
90
  export declare const SUPPORTED_ENV_VARS: EnvType;
84
91
  export declare class EnvVars extends Env {
85
92
  constructor(env?: NodeJS.ProcessEnv);
93
+ static propertyToEnvName(property: string, prefix?: string): string;
86
94
  private static defaultPrefix;
87
- propertyToEnvName(property: string, prefix?: string | undefined): string;
88
- setPropertyFromEnv(property: string, prefix?: string | undefined): void;
89
- getPropertyFromEnv<T>(property: string, prefix?: string | undefined): T | undefined;
95
+ getPropertyFromEnv<T>(property: string, prefix?: string): Nullable<T>;
90
96
  asDictionary(): Dictionary<unknown>;
91
- asMap(): Map<string, string>;
97
+ asMap(): Map<string, unknown>;
92
98
  private resolve;
93
99
  private get;
94
100
  }
@@ -11,9 +11,8 @@ const path_1 = require("path");
11
11
  const change_case_1 = require("change-case");
12
12
  const kit_1 = require("@salesforce/kit");
13
13
  const messages_1 = require("../messages");
14
- const global_1 = require("../global");
15
- messages_1.Messages.importMessagesDirectory((0, path_1.join)(__dirname));
16
- const messages = messages_1.Messages.loadMessages('@salesforce/core', 'envVars');
14
+ const lifecycleEvents_1 = require("../lifecycleEvents");
15
+ const messages = new messages_1.Messages('@salesforce/core', 'envVars', new Map([["forceOpenUrl", "Web page that opens in your browser when you connect to an org. For example, to open Lightning Experience, set to \"lightning\"."], ["forceShowSpinner", "Set to true to show a spinner animation on the command line when running asynchronous CLI commands. Default is false."], ["forceSpinnerDelay", "Speed of the spinner in milliseconds. Default is 60."], ["httpProxy", "HTTP URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy."], ["httpsProxy", "HTTPS URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy."], ["nodeExtraCaCerts", "Fully qualified path to your self-signed certificate. Will be installed after you run \"sfdx update\"."], ["nodeTlsRejectUnauthorized", "Set to 0 to allow Node.js to use the self-signed certificate in the certificate chain."], ["sfdxAccessToken", "Specifies an access token when using the auth:accesstoken:store command."], ["sfdxApiVersion", "The API version for a specific project or all projects. Default value is the API version of your Dev Hub. Overrides the apiVersion config value."], ["sfdxAudienceUrl", "URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you\u2019re logging into."], ["sfdxCodeCoverageRequirement", "Code coverage percentages that are displayed in green when you run force:apex:test:\\* with the --codecoverage parameter."], ["sfdxContentType", "Set to JSON so that all CLI commands output results in JSON format."], ["sfdxDefaultdevhubusername", "Username or alias of your default Dev Hub org. Overrides the defaultdevhubusername configuration value."], ["sfdxDefaultusername", "Username or alias of your default org. Overrides the defaultusername configuration value."], ["sfdxDisableAutoupdate", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfdxAutoupdateDisable", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfdxDisableSourceMemberPolling", "Set to true to disable polling of your org\u2019s SourceMember object when you run the force:source:push|pull commands. Default value is false."], ["sfdxDisableTelemetry", "Set to true to disable Salesforce CLI from collecting usage information, user environment information, and crash reports. Default value is false. Overrides the disableTelemetry configration variable."], ["sfdxDnsTimeout", "Number of seconds that the force:org:\\* commands wait for a response when checking whether an org is connected. Default value is 3."], ["sfdxDomainRetry", "Time, in seconds, that Salesforce CLI waits for the Lightning Experience custom domain to resolve and become available in a scratch org. Default value is 240."], ["sfdxImprovedCodeCoverage", "Set to true to scope Apex test results to the classes entered during a test run when running force:apex:test:\\*."], ["sfdxInstanceUrl", "URL of the Salesforce instance that is hosting your org. Default value is https://login.salesforce.com. Overrides the instanceUrl configuration value."], ["sfdxJsonToStdout", "Set to true to send messages resulting from failed Salesforce CLI commands to stdout instead of stderr."], ["sfdxDisableLogFile", "Set to true to disable log file writing"], ["sfdxLogLevel", "Level of messages that the CLI writes to the log file. Valid values are trace, debug, info, warn, error, fatal. Default value is warn."], ["sfdxLogRotationCount", "The default rotation period for logs. Example '1d' will rotate logs daily (at midnight)."], ["sfdxLogRotationPeriod", "The number of backup rotated log files to keep. Example: '3' will have the base sf.log file, and the past 3 (period) log files."], ["sfdxMaxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default value is 10,000. Overrides the maxQueryLimit configuration value."], ["sfdxMdapiTempDir", "Directory that contains files (in metadata format) when running certain Salesforce CLI commands, such as force:source:\\*."], ["sfdxNpmRegistry", "URL to a private npm server, where all packages that you publish are private."], ["sfdxPrecompileEnable", "Set to true to enable Apex pre-compile before the tests are run with the force:apex:test:run command. Default is false."], ["sfdxProjectAutoupdateDisableForPackageCreate", "Set to true to disable automatic updates to sfdx-project.json when running force:package:create."], ["sfdxProjectAutoupdateDisableForPackageVersionCreate", "Set to true to disable automatic updates to sfdx-project.json when running force:package:version:create."], ["sfdxRestDeploy", "Set to true to make Salesforce CLI use the Metadata REST API for deployments. By default, the CLI uses SOAP."], ["sfdxSourceMemberPollingTimeout", "Number of seconds you want the force:source:push command to keep polling the SourceMember object before the command times out."], ["sfdxUseGenericUnixKeychain", "(Linux and macOS only) Set to true if you want to use the generic UNIX keychain instead of the Linux libsecret library or macOS keychain."], ["sfdxUseProgressBar", "Set to false to disable the progress bar when running force:mdapi:deploy, force:source:deploy, or force:source:push."], ["sfdxLazyLoadModules", "Set to true to enable lazy loading of sfdx modules"], ["sfdxS3Host", "URL to S3 host"], ["sfdxUpdateInstructions", "Text that describes how to update sfdx"], ["sfdxInstaller", "Boolean indicating that the installer is running"], ["sfdxEnv", "Describes if sfdx is in \"demo\" mode"], ["sfTargetOrg", "Username or alias of your default org. Overrides the target-org configuration variable."], ["sfTargetDevHub", "Username or alias of your default Dev Hub org. Overrides the target-dev-hub configuration variable."], ["sfAccessToken", "Specifies an access token when using a login command that uses access tokens."], ["sfOrgApiVersion", "API version for a specific project or all projects. Default value is the API version of your Dev Hub. Overrides the apiVersion configuration variable."], ["sfAudienceUrl", "URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you\u2019re logging into."], ["sfCodeCoverageRequirement", "Code coverage percentages that are displayed in green when you run the Apex test CLIcommands with the --code-coverage flag."], ["sfContentType", "Set to JSON so that all CLI commands output results in JSON format."], ["sfDisableAutoupdate", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfAutoupdateDisable", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfDisableSourceMemberPolling", "Set to true to disable polling of your org\u2019s SourceMember object when you run the commands to push and pull source. Default value is false."], ["sfDisableTelemetry", "Set to true to disable Salesforce CLI from collecting usage information, user environment information, and crash reports. Default value is false. Overrides the disableTelemetry configration variable."], ["sfDnsTimeout", "Number of seconds that the env commands wait for a response when checking whether an org is connected. Default value is 3."], ["sfDomainRetry", "Time, in seconds, that Salesforce CLI waits for the Lightning Experience custom domain to resolve and become available in a scratch org. Default value is 240."], ["sfImprovedCodeCoverage", "Set to true to scope Apex test results to the classes entered during a test run when running the Apex test commands."], ["sfOrgInstanceUrl", "URL of the Salesforce instance that is hosting your org. Default value is https://login.salesforce.com. Overrides the instanceUrl configuration variable."], ["sfJsonToStdout", "Set to true to send messages resulting from failed Salesforce CLI commands to stdout instead of stderr."], ["sfDisableLogFile", "Set to true to disable log file writing"], ["sfLogLevel", "Level of messages that the CLI writes to the log file. Valid values are trace, debug, info, warn, error, fatal. Default value is warn."], ["sfLogRotationCount", "The default rotation period for logs. Example '1d' will rotate logs daily (at midnight)."], ["sfLogRotationPeriod", "The number of backup rotated log files to keep. Example: '3' will have the base sf.log file, and the past 3 (period) log files."], ["sfOrgMaxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default value is 10,000. Overrides the maxQueryLimit configuration variable."], ["sfMdapiTempDir", "Directory that contains files (in metadata format) when running certain Salesforce CLI commands."], ["sfNpmRegistry", "URL to a private npm server, where all packages that you publish are private."], ["sfPrecompileEnable", "Set to true to enable Apex pre-compile before the tests are run with the Apex test run command. Default is false."], ["sfProjectAutoupdateDisableForPackageCreate", "Set to true to disable automatic updates to sfdx-project.json when running the package create command."], ["sfProjectAutoupdateDisableForPackageVersionCreate", "Set to true to disable automatic updates to sfdx-project.json when running the package version create command."], ["sfSourceMemberPollingTimeout", "Number of seconds you want the source push command to keep polling the SourceMember object before the command times out."], ["sfUseGenericUnixKeychain", "(Linux and macOS only) Set to true if you want to use the generic UNIX keychain instead of the Linux libsecret library or macOS keychain."], ["sfUseProgressBar", "Set to false to disable the progress bar when running the metadata deploy command."], ["sfLazyLoadModules", "Set to true to enable lazy loading of sf modules"], ["sfS3Host", "URL to S3 host"], ["sfUpdateInstructions", "Text that describes how to update sf"], ["sfInstaller", "Boolean indicating that the installer is running"], ["sfEnv", "Describes if sf is in \"demo\" mode"], ["deprecatedEnv", "Deprecated environment variable: %s. Please use %s instead."], ["deprecatedEnvDisagreement", "Deprecated environment variable: %s. Please use %s instead.\n\nYour environment has both variables populated, and with different values. The value from %s will be used."]]));
17
16
  var EnvironmentVariable;
18
17
  (function (EnvironmentVariable) {
19
18
  EnvironmentVariable["FORCE_OPEN_URL"] = "FORCE_OPEN_URL";
@@ -39,7 +38,10 @@ var EnvironmentVariable;
39
38
  EnvironmentVariable["SFDX_IMPROVED_CODE_COVERAGE"] = "SFDX_IMPROVED_CODE_COVERAGE";
40
39
  EnvironmentVariable["SFDX_INSTANCE_URL"] = "SFDX_INSTANCE_URL";
41
40
  EnvironmentVariable["SFDX_JSON_TO_STDOUT"] = "SFDX_JSON_TO_STDOUT";
41
+ EnvironmentVariable["SFDX_DISABLE_LOG_FILE"] = "SFDX_DISABLE_LOG_FILE";
42
42
  EnvironmentVariable["SFDX_LOG_LEVEL"] = "SFDX_LOG_LEVEL";
43
+ EnvironmentVariable["SFDX_LOG_ROTATION_COUNT"] = "SFDX_LOG_ROTATION_COUNT";
44
+ EnvironmentVariable["SFDX_LOG_ROTATION_PERIOD"] = "SFDX_LOG_ROTATION_PERIOD";
43
45
  EnvironmentVariable["SFDX_MAX_QUERY_LIMIT"] = "SFDX_MAX_QUERY_LIMIT";
44
46
  EnvironmentVariable["SFDX_MDAPI_TEMP_DIR"] = "SFDX_MDAPI_TEMP_DIR";
45
47
  EnvironmentVariable["SFDX_NPM_REGISTRY"] = "SFDX_NPM_REGISTRY";
@@ -58,7 +60,7 @@ var EnvironmentVariable;
58
60
  EnvironmentVariable["SF_TARGET_ORG"] = "SF_TARGET_ORG";
59
61
  EnvironmentVariable["SF_TARGET_DEV_HUB"] = "SF_TARGET_DEV_HUB";
60
62
  EnvironmentVariable["SF_ACCESS_TOKEN"] = "SF_ACCESS_TOKEN";
61
- EnvironmentVariable["SF_API_VERSION"] = "SF_API_VERSION";
63
+ EnvironmentVariable["SF_ORG_API_VERSION"] = "SF_ORG_API_VERSION";
62
64
  EnvironmentVariable["SF_AUDIENCE_URL"] = "SF_AUDIENCE_URL";
63
65
  EnvironmentVariable["SF_CODE_COVERAGE_REQUIREMENT"] = "SF_CODE_COVERAGE_REQUIREMENT";
64
66
  EnvironmentVariable["SF_CONTENT_TYPE"] = "SF_CONTENT_TYPE";
@@ -69,10 +71,13 @@ var EnvironmentVariable;
69
71
  EnvironmentVariable["SF_DNS_TIMEOUT"] = "SF_DNS_TIMEOUT";
70
72
  EnvironmentVariable["SF_DOMAIN_RETRY"] = "SF_DOMAIN_RETRY";
71
73
  EnvironmentVariable["SF_IMPROVED_CODE_COVERAGE"] = "SF_IMPROVED_CODE_COVERAGE";
72
- EnvironmentVariable["SF_INSTANCE_URL"] = "SF_INSTANCE_URL";
74
+ EnvironmentVariable["SF_ORG_INSTANCE_URL"] = "SF_ORG_INSTANCE_URL";
73
75
  EnvironmentVariable["SF_JSON_TO_STDOUT"] = "SF_JSON_TO_STDOUT";
76
+ EnvironmentVariable["SF_DISABLE_LOG_FILE"] = "SF_DISABLE_LOG_FILE";
74
77
  EnvironmentVariable["SF_LOG_LEVEL"] = "SF_LOG_LEVEL";
75
- EnvironmentVariable["SF_MAX_QUERY_LIMIT"] = "SF_MAX_QUERY_LIMIT";
78
+ EnvironmentVariable["SF_LOG_ROTATION_COUNT"] = "SF_LOG_ROTATION_COUNT";
79
+ EnvironmentVariable["SF_LOG_ROTATION_PERIOD"] = "SF_LOG_ROTATION_PERIOD";
80
+ EnvironmentVariable["SF_ORG_MAX_QUERY_LIMIT"] = "SF_ORG_MAX_QUERY_LIMIT";
76
81
  EnvironmentVariable["SF_MDAPI_TEMP_DIR"] = "SF_MDAPI_TEMP_DIR";
77
82
  EnvironmentVariable["SF_NPM_REGISTRY"] = "SF_NPM_REGISTRY";
78
83
  EnvironmentVariable["SF_PRECOMPILE_ENABLE"] = "SF_PRECOMPILE_ENABLE";
@@ -124,7 +129,7 @@ exports.SUPPORTED_ENV_VARS = {
124
129
  },
125
130
  [EnvironmentVariable.SFDX_API_VERSION]: {
126
131
  description: getMessage(EnvironmentVariable.SFDX_API_VERSION),
127
- synonymOf: EnvironmentVariable.SF_API_VERSION,
132
+ synonymOf: EnvironmentVariable.SF_ORG_API_VERSION,
128
133
  },
129
134
  [EnvironmentVariable.SFDX_AUDIENCE_URL]: {
130
135
  description: getMessage(EnvironmentVariable.SFDX_AUDIENCE_URL),
@@ -176,19 +181,31 @@ exports.SUPPORTED_ENV_VARS = {
176
181
  },
177
182
  [EnvironmentVariable.SFDX_INSTANCE_URL]: {
178
183
  description: getMessage(EnvironmentVariable.SFDX_INSTANCE_URL),
179
- synonymOf: EnvironmentVariable.SF_INSTANCE_URL,
184
+ synonymOf: EnvironmentVariable.SF_ORG_INSTANCE_URL,
180
185
  },
181
186
  [EnvironmentVariable.SFDX_JSON_TO_STDOUT]: {
182
187
  description: getMessage(EnvironmentVariable.SFDX_JSON_TO_STDOUT),
183
188
  synonymOf: EnvironmentVariable.SF_JSON_TO_STDOUT,
184
189
  },
190
+ [EnvironmentVariable.SFDX_DISABLE_LOG_FILE]: {
191
+ description: getMessage(EnvironmentVariable.SFDX_DISABLE_LOG_FILE),
192
+ synonymOf: EnvironmentVariable.SF_DISABLE_LOG_FILE,
193
+ },
185
194
  [EnvironmentVariable.SFDX_LOG_LEVEL]: {
186
195
  description: getMessage(EnvironmentVariable.SFDX_LOG_LEVEL),
187
196
  synonymOf: EnvironmentVariable.SF_LOG_LEVEL,
188
197
  },
198
+ [EnvironmentVariable.SFDX_LOG_ROTATION_COUNT]: {
199
+ description: getMessage(EnvironmentVariable.SFDX_LOG_ROTATION_COUNT),
200
+ synonymOf: EnvironmentVariable.SF_LOG_ROTATION_COUNT,
201
+ },
202
+ [EnvironmentVariable.SFDX_LOG_ROTATION_PERIOD]: {
203
+ description: getMessage(EnvironmentVariable.SFDX_LOG_ROTATION_PERIOD),
204
+ synonymOf: EnvironmentVariable.SF_LOG_ROTATION_PERIOD,
205
+ },
189
206
  [EnvironmentVariable.SFDX_MAX_QUERY_LIMIT]: {
190
207
  description: getMessage(EnvironmentVariable.SFDX_MAX_QUERY_LIMIT),
191
- synonymOf: EnvironmentVariable.SF_MAX_QUERY_LIMIT,
208
+ synonymOf: EnvironmentVariable.SF_ORG_MAX_QUERY_LIMIT,
192
209
  },
193
210
  [EnvironmentVariable.SFDX_MDAPI_TEMP_DIR]: {
194
211
  description: getMessage(EnvironmentVariable.SFDX_MDAPI_TEMP_DIR),
@@ -212,7 +229,8 @@ exports.SUPPORTED_ENV_VARS = {
212
229
  },
213
230
  [EnvironmentVariable.SFDX_REST_DEPLOY]: {
214
231
  description: getMessage(EnvironmentVariable.SFDX_REST_DEPLOY),
215
- synonymOf: null,
232
+ // this is not an "official" env var, but it supports the env=>config naming convention for the config that lives in plugin-deploy-retrieve
233
+ synonymOf: 'SF_ORG_METADATA_REST_DEPLOY',
216
234
  },
217
235
  [EnvironmentVariable.SFDX_SOURCE_MEMBER_POLLING_TIMEOUT]: {
218
236
  description: getMessage(EnvironmentVariable.SFDX_SOURCE_MEMBER_POLLING_TIMEOUT),
@@ -259,8 +277,8 @@ exports.SUPPORTED_ENV_VARS = {
259
277
  description: getMessage(EnvironmentVariable.SF_ACCESS_TOKEN),
260
278
  synonymOf: null,
261
279
  },
262
- [EnvironmentVariable.SF_API_VERSION]: {
263
- description: getMessage(EnvironmentVariable.SF_API_VERSION),
280
+ [EnvironmentVariable.SF_ORG_API_VERSION]: {
281
+ description: getMessage(EnvironmentVariable.SF_ORG_API_VERSION),
264
282
  synonymOf: null,
265
283
  },
266
284
  [EnvironmentVariable.SF_AUDIENCE_URL]: {
@@ -303,20 +321,32 @@ exports.SUPPORTED_ENV_VARS = {
303
321
  description: getMessage(EnvironmentVariable.SF_IMPROVED_CODE_COVERAGE),
304
322
  synonymOf: null,
305
323
  },
306
- [EnvironmentVariable.SF_INSTANCE_URL]: {
307
- description: getMessage(EnvironmentVariable.SF_INSTANCE_URL),
324
+ [EnvironmentVariable.SF_ORG_INSTANCE_URL]: {
325
+ description: getMessage(EnvironmentVariable.SF_ORG_INSTANCE_URL),
308
326
  synonymOf: null,
309
327
  },
310
328
  [EnvironmentVariable.SF_JSON_TO_STDOUT]: {
311
329
  description: getMessage(EnvironmentVariable.SF_JSON_TO_STDOUT),
312
330
  synonymOf: null,
313
331
  },
332
+ [EnvironmentVariable.SF_DISABLE_LOG_FILE]: {
333
+ description: getMessage(EnvironmentVariable.SF_DISABLE_LOG_FILE),
334
+ synonymOf: null,
335
+ },
314
336
  [EnvironmentVariable.SF_LOG_LEVEL]: {
315
337
  description: getMessage(EnvironmentVariable.SF_LOG_LEVEL),
316
338
  synonymOf: null,
317
339
  },
318
- [EnvironmentVariable.SF_MAX_QUERY_LIMIT]: {
319
- description: getMessage(EnvironmentVariable.SF_MAX_QUERY_LIMIT),
340
+ [EnvironmentVariable.SF_LOG_ROTATION_COUNT]: {
341
+ description: getMessage(EnvironmentVariable.SF_LOG_ROTATION_COUNT),
342
+ synonymOf: null,
343
+ },
344
+ [EnvironmentVariable.SF_LOG_ROTATION_PERIOD]: {
345
+ description: getMessage(EnvironmentVariable.SF_LOG_ROTATION_PERIOD),
346
+ synonymOf: null,
347
+ },
348
+ [EnvironmentVariable.SF_ORG_MAX_QUERY_LIMIT]: {
349
+ description: getMessage(EnvironmentVariable.SF_ORG_MAX_QUERY_LIMIT),
320
350
  synonymOf: null,
321
351
  },
322
352
  [EnvironmentVariable.SF_MDAPI_TEMP_DIR]: {
@@ -377,55 +407,49 @@ class EnvVars extends kit_1.Env {
377
407
  super(env);
378
408
  this.resolve();
379
409
  }
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()) {
410
+ static propertyToEnvName(property, prefix = EnvVars.defaultPrefix()) {
388
411
  return `${prefix || ''}${(0, change_case_1.snakeCase)(property).toUpperCase()}`;
389
412
  }
390
- setPropertyFromEnv(property, prefix = EnvVars.defaultPrefix()) {
391
- const envName = this.propertyToEnvName(property, prefix);
392
- const value = this.getString(envName);
393
- if (value) {
394
- this.setString(property, value);
395
- }
413
+ static defaultPrefix() {
414
+ return 'SF_';
396
415
  }
397
416
  getPropertyFromEnv(property, prefix = EnvVars.defaultPrefix()) {
398
- const envName = this.propertyToEnvName(property, prefix);
417
+ const envName = EnvVars.propertyToEnvName(property, prefix);
399
418
  return this.get(envName);
400
419
  }
401
420
  asDictionary() {
402
- return this.entries().reduce((accumulator, [key, value]) => {
403
- accumulator[key] = value;
404
- return accumulator;
405
- }, {});
421
+ return Object.fromEntries(this.entries());
406
422
  }
407
423
  asMap() {
408
- return this.entries().reduce((accumulator, [key, value]) => {
409
- accumulator.set(key, value);
410
- return accumulator;
411
- }, new Map());
424
+ return new Map(this.entries());
412
425
  }
413
426
  resolve() {
427
+ // iterate everything in the real environment
428
+ const corrections = new Map();
414
429
  this.entries().forEach(([key, value]) => {
415
- if (exports.SUPPORTED_ENV_VARS[key]) {
416
- // cross populate value to synonym if synonym exists
417
- if (exports.SUPPORTED_ENV_VARS[key].synonymOf) {
418
- const synonym = exports.SUPPORTED_ENV_VARS[key].synonymOf;
419
- // set synonym only if it is in the map and running in interoperability mode
420
- if (synonym && global_1.Global.SFDX_INTEROPERABILITY) {
421
- this.setString(synonym, value);
430
+ if (exports.SUPPORTED_ENV_VARS[key]?.synonymOf) {
431
+ // we are looking at an "old" key that has a new name
432
+ // if the new key has a value set, use that for the old key, too
433
+ const newEnvName = exports.SUPPORTED_ENV_VARS[key].synonymOf;
434
+ if (newEnvName) {
435
+ const valueOfNewName = this.getString(newEnvName);
436
+ if (!valueOfNewName) {
437
+ void lifecycleEvents_1.Lifecycle.getInstance().emitWarning(messages.getMessage('deprecatedEnv', [key, newEnvName]));
438
+ corrections.set(newEnvName, value);
439
+ }
440
+ else if (valueOfNewName !== value) {
441
+ void lifecycleEvents_1.Lifecycle.getInstance().emitWarning(messages.getMessage('deprecatedEnvDisagreement', [key, newEnvName, newEnvName]));
442
+ corrections.set(key, valueOfNewName ?? value);
422
443
  }
423
444
  }
424
445
  }
425
446
  });
447
+ corrections.forEach((v, k) => {
448
+ this.setString(k, v);
449
+ });
426
450
  }
427
451
  get(envName) {
428
- return this.asDictionary()[envName];
452
+ return this.asMap().get(envName);
429
453
  }
430
454
  }
431
455
  exports.EnvVars = EnvVars;
@@ -7,6 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.OrgUsersConfig = void 0;
10
+ const global_1 = require("../global");
10
11
  const configFile_1 = require("./configFile");
11
12
  /**
12
13
  * A config file that stores usernames for an org.
@@ -33,6 +34,7 @@ class OrgUsersConfig extends configFile_1.ConfigFile {
33
34
  isState: true,
34
35
  filename: `${orgId}.json`,
35
36
  orgId,
37
+ stateFolder: global_1.Global.SFDX_STATE_FOLDER,
36
38
  };
37
39
  }
38
40
  }
@@ -7,6 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.SandboxOrgConfig = void 0;
10
+ const global_1 = require("../global");
10
11
  const configFile_1 = require("./configFile");
11
12
  /**
12
13
  * A config file that stores usernames for an org.
@@ -33,6 +34,7 @@ class SandboxOrgConfig extends configFile_1.ConfigFile {
33
34
  isState: true,
34
35
  filename: `${orgId}.sandbox.json`,
35
36
  orgId,
37
+ stateFolder: global_1.Global.SFDX_STATE_FOLDER,
36
38
  };
37
39
  }
38
40
  }
@@ -0,0 +1,16 @@
1
+ import { SandboxProcessObject, SandboxRequest } from '../org';
2
+ import { TTLConfig } from './ttlConfig';
3
+ export type SandboxRequestCacheEntry = {
4
+ alias?: string;
5
+ setDefault: boolean;
6
+ prodOrgUsername: string;
7
+ sandboxProcessObject: Partial<SandboxProcessObject>;
8
+ sandboxRequest: Partial<SandboxRequest>;
9
+ tracksSource?: boolean;
10
+ };
11
+ export declare class SandboxRequestCache extends TTLConfig<TTLConfig.Options, SandboxRequestCacheEntry> {
12
+ static getDefaultOptions(): TTLConfig.Options;
13
+ static unset(key: string): Promise<void>;
14
+ static set(key: string, sandboxProcessObject: SandboxRequestCacheEntry): Promise<void>;
15
+ static getFileName(): string;
16
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SandboxRequestCache = void 0;
4
+ /*
5
+ * Copyright (c) 2020, salesforce.com, inc.
6
+ * All rights reserved.
7
+ * Licensed under the BSD 3-Clause license.
8
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
+ */
10
+ const kit_1 = require("@salesforce/kit");
11
+ const global_1 = require("../global");
12
+ const ttlConfig_1 = require("./ttlConfig");
13
+ class SandboxRequestCache extends ttlConfig_1.TTLConfig {
14
+ static getDefaultOptions() {
15
+ return {
16
+ isGlobal: true,
17
+ isState: true,
18
+ filename: SandboxRequestCache.getFileName(),
19
+ stateFolder: global_1.Global.SF_STATE_FOLDER,
20
+ ttl: kit_1.Duration.days(14),
21
+ };
22
+ }
23
+ static async unset(key) {
24
+ const cache = await SandboxRequestCache.create();
25
+ cache.unset(key);
26
+ await cache.write();
27
+ }
28
+ static async set(key, sandboxProcessObject) {
29
+ const cache = await SandboxRequestCache.create();
30
+ cache.set(key, sandboxProcessObject);
31
+ await cache.write();
32
+ }
33
+ static getFileName() {
34
+ return 'sandbox-create-cache.json';
35
+ }
36
+ }
37
+ exports.SandboxRequestCache = SandboxRequestCache;
38
+ //# sourceMappingURL=sandboxProcessCache.js.map
@@ -0,0 +1,10 @@
1
+ import { Optional } from '@salesforce/ts-types';
2
+ import { SfTokens } from '../stateAggregator';
3
+ import { ConfigFile } from './configFile';
4
+ import { ConfigContents, ConfigValue } from './configStore';
5
+ export declare class TokensConfig extends ConfigFile<ConfigFile.Options, SfTokens> {
6
+ protected static encryptedKeys: RegExp[];
7
+ static getDefaultOptions(): ConfigFile.Options;
8
+ protected getMethod(contents: ConfigContents, key: string): Optional<ConfigValue>;
9
+ protected setMethod(contents: ConfigContents, key: string, value?: ConfigValue): void;
10
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2022, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
+ */
8
+ /* eslint-disable class-methods-use-this */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.TokensConfig = void 0;
11
+ const configFile_1 = require("./configFile");
12
+ class TokensConfig extends configFile_1.ConfigFile {
13
+ static getDefaultOptions() {
14
+ return {
15
+ isGlobal: true,
16
+ isState: true,
17
+ filename: 'tokens.json',
18
+ };
19
+ }
20
+ getMethod(contents, key) {
21
+ return contents[key];
22
+ }
23
+ setMethod(contents, key, value) {
24
+ contents[key] = value;
25
+ }
26
+ }
27
+ exports.TokensConfig = TokensConfig;
28
+ TokensConfig.encryptedKeys = [/token/i, /password/i, /secret/i];
29
+ //# sourceMappingURL=tokensConfig.js.map
@@ -0,0 +1,34 @@
1
+ import { Duration } from '@salesforce/kit';
2
+ import { JsonMap, Nullable } from '@salesforce/ts-types';
3
+ import { ConfigFile } from './configFile';
4
+ /**
5
+ * A Time To Live configuration file where each entry is timestamped and removed once the TTL has expired.
6
+ *
7
+ * @example
8
+ * ```
9
+ * import { Duration } from '@salesforce/kit';
10
+ * const config = await TTLConfig.create({
11
+ * isGlobal: false,
12
+ * ttl: Duration.days(1)
13
+ * });
14
+ * ```
15
+ */
16
+ export declare class TTLConfig<T extends TTLConfig.Options, P extends JsonMap> extends ConfigFile<T, TTLConfig.Contents<P>> {
17
+ set(key: string, value: Partial<TTLConfig.Entry<P>>): void;
18
+ getLatestEntry(): Nullable<[string, TTLConfig.Entry<P>]>;
19
+ getLatestKey(): Nullable<string>;
20
+ isExpired(dateTime: number, value: P & {
21
+ timestamp: string;
22
+ }): boolean;
23
+ protected init(): Promise<void>;
24
+ private timestamp;
25
+ }
26
+ export declare namespace TTLConfig {
27
+ type Options = ConfigFile.Options & {
28
+ ttl: Duration;
29
+ };
30
+ type Entry<T extends JsonMap> = T & {
31
+ timestamp: string;
32
+ };
33
+ type Contents<T extends JsonMap> = Record<string, Entry<T>>;
34
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2022, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.TTLConfig = void 0;
10
+ const configFile_1 = require("./configFile");
11
+ /**
12
+ * A Time To Live configuration file where each entry is timestamped and removed once the TTL has expired.
13
+ *
14
+ * @example
15
+ * ```
16
+ * import { Duration } from '@salesforce/kit';
17
+ * const config = await TTLConfig.create({
18
+ * isGlobal: false,
19
+ * ttl: Duration.days(1)
20
+ * });
21
+ * ```
22
+ */
23
+ class TTLConfig extends configFile_1.ConfigFile {
24
+ set(key, value) {
25
+ super.set(key, this.timestamp(value));
26
+ }
27
+ getLatestEntry() {
28
+ const entries = this.entries();
29
+ const sorted = entries.sort(([, valueA], [, valueB]) => new Date(valueB.timestamp).getTime() - new Date(valueA.timestamp).getTime());
30
+ return sorted.length > 0 ? sorted[0] : null;
31
+ }
32
+ getLatestKey() {
33
+ const [key] = this.getLatestEntry() ?? [null];
34
+ return key;
35
+ }
36
+ isExpired(dateTime, value) {
37
+ return dateTime - new Date(value.timestamp).getTime() > this.options.ttl.milliseconds;
38
+ }
39
+ async init() {
40
+ const contents = await this.read(this.options.throwOnNotFound);
41
+ const date = new Date().getTime();
42
+ this.setContents(Object.fromEntries(Object.entries(contents).filter(([, value]) => !this.isExpired(date, value))));
43
+ }
44
+ // eslint-disable-next-line class-methods-use-this
45
+ timestamp(value) {
46
+ return { ...value, timestamp: new Date().toISOString() };
47
+ }
48
+ }
49
+ exports.TTLConfig = TTLConfig;
50
+ //# sourceMappingURL=ttlConfig.js.map