@salesforce/core 4.0.0-v3.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +93 -44
  3. package/lib/config/aliasesConfig.d.ts +12 -0
  4. package/lib/config/aliasesConfig.js +28 -0
  5. package/lib/config/authInfoConfig.d.ts +19 -0
  6. package/lib/config/authInfoConfig.js +35 -0
  7. package/lib/config/config.d.ts +181 -48
  8. package/lib/config/config.js +382 -159
  9. package/lib/config/configAggregator.d.ts +59 -42
  10. package/lib/config/configAggregator.js +135 -82
  11. package/lib/config/configFile.d.ts +2 -2
  12. package/lib/config/configFile.js +40 -31
  13. package/lib/config/configGroup.d.ts +9 -9
  14. package/lib/config/configGroup.js +13 -11
  15. package/lib/config/configStore.d.ts +9 -9
  16. package/lib/config/configStore.js +29 -26
  17. package/lib/config/envVars.d.ts +102 -0
  18. package/lib/config/envVars.js +457 -0
  19. package/lib/config/orgUsersConfig.d.ts +8 -0
  20. package/lib/config/orgUsersConfig.js +12 -0
  21. package/lib/config/sandboxOrgConfig.d.ts +8 -0
  22. package/lib/config/sandboxOrgConfig.js +12 -0
  23. package/lib/config/sandboxProcessCache.d.ts +16 -0
  24. package/lib/config/sandboxProcessCache.js +38 -0
  25. package/lib/config/tokensConfig.d.ts +10 -0
  26. package/lib/config/tokensConfig.js +29 -0
  27. package/lib/config/ttlConfig.d.ts +34 -0
  28. package/lib/config/ttlConfig.js +50 -0
  29. package/lib/crypto/crypto.js +29 -16
  30. package/lib/crypto/keyChain.js +4 -4
  31. package/lib/crypto/keyChainImpl.d.ts +5 -3
  32. package/lib/crypto/keyChainImpl.js +65 -66
  33. package/lib/crypto/secureBuffer.d.ts +1 -1
  34. package/lib/crypto/secureBuffer.js +1 -1
  35. package/lib/deviceOauthService.d.ts +5 -5
  36. package/lib/deviceOauthService.js +37 -33
  37. package/lib/exported.d.ts +22 -15
  38. package/lib/exported.js +49 -25
  39. package/lib/global.d.ts +17 -3
  40. package/lib/global.js +46 -13
  41. package/lib/lifecycleEvents.d.ts +39 -2
  42. package/lib/lifecycleEvents.js +77 -3
  43. package/lib/logger.d.ts +21 -11
  44. package/lib/logger.js +121 -105
  45. package/lib/messages.d.ts +53 -36
  46. package/lib/messages.js +89 -97
  47. package/lib/org/authInfo.d.ts +84 -72
  48. package/lib/org/authInfo.js +326 -320
  49. package/lib/org/authRemover.d.ts +16 -23
  50. package/lib/org/authRemover.js +62 -60
  51. package/lib/org/connection.d.ts +33 -59
  52. package/lib/org/connection.js +129 -190
  53. package/lib/org/index.js +6 -2
  54. package/lib/org/org.d.ts +263 -38
  55. package/lib/org/org.js +734 -149
  56. package/lib/org/orgConfigProperties.d.ts +69 -0
  57. package/lib/org/orgConfigProperties.js +121 -0
  58. package/lib/org/permissionSetAssignment.js +6 -15
  59. package/lib/org/scratchOrgCache.d.ts +20 -0
  60. package/lib/org/scratchOrgCache.js +33 -0
  61. package/lib/org/scratchOrgCreate.d.ts +54 -0
  62. package/lib/org/scratchOrgCreate.js +214 -0
  63. package/lib/org/scratchOrgErrorCodes.d.ts +10 -0
  64. package/lib/org/scratchOrgErrorCodes.js +79 -0
  65. package/lib/org/scratchOrgFeatureDeprecation.d.ts +26 -0
  66. package/lib/org/scratchOrgFeatureDeprecation.js +105 -0
  67. package/lib/org/scratchOrgInfoApi.d.ts +68 -0
  68. package/lib/org/scratchOrgInfoApi.js +416 -0
  69. package/lib/org/scratchOrgInfoGenerator.d.ts +64 -0
  70. package/lib/org/scratchOrgInfoGenerator.js +237 -0
  71. package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -0
  72. package/lib/org/scratchOrgLifecycleEvents.js +41 -0
  73. package/lib/org/scratchOrgSettingsGenerator.d.ts +79 -0
  74. package/lib/org/scratchOrgSettingsGenerator.js +277 -0
  75. package/lib/org/scratchOrgTypes.d.ts +43 -0
  76. package/lib/{status/client.js → org/scratchOrgTypes.js} +1 -1
  77. package/lib/org/user.d.ts +7 -2
  78. package/lib/org/user.js +78 -54
  79. package/lib/schema/printer.d.ts +6 -0
  80. package/lib/schema/printer.js +49 -46
  81. package/lib/schema/validator.d.ts +12 -10
  82. package/lib/schema/validator.js +56 -76
  83. package/lib/{sfdxError.d.ts → sfError.d.ts} +12 -15
  84. package/lib/{sfdxError.js → sfError.js} +42 -24
  85. package/lib/{sfdxProject.d.ts → sfProject.d.ts} +75 -35
  86. package/lib/sfProject.js +651 -0
  87. package/lib/stateAggregator/accessors/aliasAccessor.d.ts +98 -0
  88. package/lib/stateAggregator/accessors/aliasAccessor.js +146 -0
  89. package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -0
  90. package/lib/stateAggregator/accessors/orgAccessor.js +240 -0
  91. package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -0
  92. package/lib/stateAggregator/accessors/sandboxAccessor.js +28 -0
  93. package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -0
  94. package/lib/stateAggregator/accessors/tokenAccessor.js +80 -0
  95. package/lib/stateAggregator/index.d.ts +4 -0
  96. package/lib/stateAggregator/index.js +27 -0
  97. package/lib/stateAggregator/stateAggregator.d.ts +25 -0
  98. package/lib/stateAggregator/stateAggregator.js +46 -0
  99. package/lib/status/myDomainResolver.d.ts +1 -1
  100. package/lib/status/myDomainResolver.js +10 -10
  101. package/lib/status/pollingClient.d.ts +2 -6
  102. package/lib/status/pollingClient.js +38 -64
  103. package/lib/status/streamingClient.d.ts +5 -80
  104. package/lib/status/streamingClient.js +74 -94
  105. package/lib/status/types.d.ts +89 -0
  106. package/lib/status/types.js +18 -0
  107. package/lib/testSetup.d.ts +212 -79
  108. package/lib/testSetup.js +478 -182
  109. package/lib/util/cache.d.ts +11 -0
  110. package/lib/util/cache.js +70 -0
  111. package/lib/util/checkLightningDomain.d.ts +1 -0
  112. package/lib/util/checkLightningDomain.js +29 -0
  113. package/lib/util/directoryWriter.d.ts +12 -0
  114. package/lib/util/directoryWriter.js +54 -0
  115. package/lib/util/getJwtAudienceUrl.d.ts +4 -0
  116. package/lib/util/getJwtAudienceUrl.js +19 -0
  117. package/lib/util/internal.d.ts +28 -2
  118. package/lib/util/internal.js +65 -8
  119. package/lib/util/jsonXmlTools.d.ts +14 -0
  120. package/lib/util/jsonXmlTools.js +39 -0
  121. package/lib/util/mapKeys.d.ts +14 -0
  122. package/lib/util/mapKeys.js +52 -0
  123. package/lib/util/sfdc.d.ts +51 -63
  124. package/lib/util/sfdc.js +75 -127
  125. package/lib/util/sfdcUrl.d.ts +64 -0
  126. package/lib/util/sfdcUrl.js +197 -0
  127. package/lib/util/structuredWriter.d.ts +9 -0
  128. package/lib/util/structuredWriter.js +3 -0
  129. package/lib/util/zipWriter.d.ts +16 -0
  130. package/lib/util/zipWriter.js +68 -0
  131. package/lib/webOAuthServer.d.ts +20 -7
  132. package/lib/webOAuthServer.js +107 -60
  133. package/messageTransformer/messageTransformer.ts +93 -0
  134. package/messages/auth.md +11 -3
  135. package/messages/config.md +94 -6
  136. package/messages/connection.md +8 -0
  137. package/messages/core.json +3 -3
  138. package/messages/core.md +11 -1
  139. package/messages/envVars.md +313 -0
  140. package/messages/org.md +64 -0
  141. package/messages/scratchOrgCreate.md +23 -0
  142. package/messages/scratchOrgErrorCodes.md +115 -0
  143. package/messages/scratchOrgFeatureDeprecation.md +11 -0
  144. package/messages/scratchOrgInfoApi.md +20 -0
  145. package/messages/scratchOrgInfoGenerator.md +27 -0
  146. package/messages/user.md +12 -0
  147. package/package.json +138 -66
  148. package/CHANGELOG.md +0 -699
  149. package/lib/config/aliases.d.ts +0 -56
  150. package/lib/config/aliases.js +0 -96
  151. package/lib/config/globalInfoConfig.d.ts +0 -74
  152. package/lib/config/globalInfoConfig.js +0 -144
  153. package/lib/config/keychainConfig.d.ts +0 -19
  154. package/lib/config/keychainConfig.js +0 -43
  155. package/lib/config/sfdxDataHandler.d.ts +0 -36
  156. package/lib/config/sfdxDataHandler.js +0 -165
  157. package/lib/sfdxProject.js +0 -546
  158. package/lib/status/client.d.ts +0 -15
  159. package/lib/util/fs.d.ts +0 -198
  160. package/lib/util/fs.js +0 -374
package/lib/exported.d.ts CHANGED
@@ -1,31 +1,38 @@
1
- export { OAuth2Options } from 'jsforce';
2
- export { Aliases, AliasGroup } from './config/aliases';
1
+ export { OAuth2Config } from 'jsforce';
3
2
  export { ConfigFile } from './config/configFile';
4
- export { ConfigGroup } from './config/configGroup';
5
- export { BaseConfigStore, ConfigContents, ConfigEntry, ConfigStore, ConfigValue } from './config/configStore';
6
- export { GlobalInfo, SfEntry, SfInfo, SfInfoKeys, SfOrg, SfOrgs, SfToken, SfTokens } from './config/globalInfoConfig';
3
+ export { TTLConfig } from './config/ttlConfig';
4
+ export { envVars, EnvironmentVariable, SUPPORTED_ENV_VARS, EnvVars } from './config/envVars';
5
+ export { ConfigContents, ConfigEntry, ConfigStore, ConfigValue } from './config/configStore';
6
+ export { SfTokens, StateAggregator } from './stateAggregator';
7
7
  export { DeviceOauthService, DeviceCodeResponse, DeviceCodePollingResponse } from './deviceOauthService';
8
8
  export { OrgUsersConfig } from './config/orgUsersConfig';
9
- export { ConfigPropertyMeta, ConfigPropertyMetaInput, Config } from './config/config';
9
+ export { ConfigPropertyMeta, ConfigPropertyMetaInput, Config, SfdxPropertyKeys, SfConfigProperties, SFDX_ALLOWED_PROPERTIES, SF_ALLOWED_PROPERTIES, } from './config/config';
10
+ export { SandboxRequestCacheEntry, SandboxRequestCache } from './config/sandboxProcessCache';
10
11
  export { ConfigInfo, ConfigAggregator } from './config/configAggregator';
11
- export { AuthFields, AuthInfo, OAuth2WithVerifier, SfdcUrl, getJwtAudienceUrl } from './org/authInfo';
12
+ export { AuthFields, AuthInfo, AuthSideEffects, OrgAuthorization } from './org/authInfo';
12
13
  export { AuthRemover } from './org/authRemover';
13
14
  export { Connection, SFDX_HTTP_HEADERS } from './org/connection';
14
15
  export { Mode, Global } from './global';
15
16
  export { Lifecycle } from './lifecycleEvents';
16
17
  export { WebOAuthServer } from './webOAuthServer';
18
+ export { SfdcUrl } from './util/sfdcUrl';
19
+ export { getJwtAudienceUrl } from './util/getJwtAudienceUrl';
17
20
  export { Fields, FieldValue, LoggerLevel, LoggerLevelValue, LogLine, LoggerOptions, LoggerStream, Logger, } from './logger';
18
- export { Messages } from './messages';
19
- export { Org } from './org/org';
20
- export { PackageDir, NamedPackageDir, PackageDirDependency, SfdxProject, SfdxProjectJson } from './sfdxProject';
21
- export { SchemaPrinter } from './schema/printer';
21
+ export { Messages, StructuredMessage } from './messages';
22
+ export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, ResumeSandboxRequest, OrgTypes, ResultEvent, ScratchOrgRequest, } from './org';
23
+ export { OrgConfigProperties, ORG_CONFIG_ALLOWED_PROPERTIES } from './org/orgConfigProperties';
24
+ export { PackageDir, NamedPackageDir, PackageDirDependency, SfProject, SfProjectJson } from './sfProject';
22
25
  export { SchemaValidator } from './schema/validator';
23
- export { SfdxError } from './sfdxError';
24
- export { StatusResult } from './status/client';
26
+ export { SchemaPrinter } from './schema/printer';
27
+ export { SfError } from './sfError';
25
28
  export { PollingClient } from './status/pollingClient';
26
- export { CometClient, CometSubscription, StreamingClient } from './status/streamingClient';
29
+ export { CometClient, CometSubscription, StreamingClient, StatusResult } from './status/streamingClient';
27
30
  export { MyDomainResolver } from './status/myDomainResolver';
28
31
  export { DefaultUserFields, REQUIRED_FIELDS, User, UserFields } from './org/user';
29
32
  export { PermissionSetAssignment, PermissionSetAssignmentFields } from './org/permissionSetAssignment';
30
- export * from './util/fs';
33
+ export { ScratchOrgCreateOptions, ScratchOrgCreateResult, scratchOrgCreate, scratchOrgResume, } from './org/scratchOrgCreate';
34
+ export { ScratchOrgInfo } from './org/scratchOrgTypes';
35
+ export { ScratchOrgLifecycleEvent, scratchOrgLifecycleEventName, scratchOrgLifecycleStages, } from './org/scratchOrgLifecycleEvents';
36
+ export { ScratchOrgCache } from './org/scratchOrgCache';
31
37
  export * from './util/sfdc';
38
+ export * from './util/sfdcUrl';
package/lib/exported.js CHANGED
@@ -7,42 +7,49 @@
7
7
  */
8
8
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
9
  if (k2 === undefined) k2 = k;
10
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
11
15
  }) : (function(o, m, k, k2) {
12
16
  if (k2 === undefined) k2 = k;
13
17
  o[k2] = m[k];
14
18
  }));
15
19
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
21
  };
18
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.scratchOrgLifecycleEventName = exports.scratchOrgResume = exports.scratchOrgCreate = exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfError = exports.SchemaPrinter = exports.SchemaValidator = 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.SandboxRequestCache = exports.SF_ALLOWED_PROPERTIES = exports.SFDX_ALLOWED_PROPERTIES = exports.SfConfigProperties = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.StateAggregator = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.envVars = exports.TTLConfig = exports.ConfigFile = void 0;
24
+ exports.ScratchOrgCache = exports.scratchOrgLifecycleStages = void 0;
19
25
  const messages_1 = require("./messages");
20
- messages_1.Messages.importMessagesDirectory(__dirname);
21
- var aliases_1 = require("./config/aliases");
22
- Object.defineProperty(exports, "Aliases", { enumerable: true, get: function () { return aliases_1.Aliases; } });
23
- Object.defineProperty(exports, "AliasGroup", { enumerable: true, get: function () { return aliases_1.AliasGroup; } });
24
26
  var configFile_1 = require("./config/configFile");
25
27
  Object.defineProperty(exports, "ConfigFile", { enumerable: true, get: function () { return configFile_1.ConfigFile; } });
26
- var configGroup_1 = require("./config/configGroup");
27
- Object.defineProperty(exports, "ConfigGroup", { enumerable: true, get: function () { return configGroup_1.ConfigGroup; } });
28
- var configStore_1 = require("./config/configStore");
29
- Object.defineProperty(exports, "BaseConfigStore", { enumerable: true, get: function () { return configStore_1.BaseConfigStore; } });
30
- var globalInfoConfig_1 = require("./config/globalInfoConfig");
31
- Object.defineProperty(exports, "GlobalInfo", { enumerable: true, get: function () { return globalInfoConfig_1.GlobalInfo; } });
32
- Object.defineProperty(exports, "SfInfoKeys", { enumerable: true, get: function () { return globalInfoConfig_1.SfInfoKeys; } });
28
+ var ttlConfig_1 = require("./config/ttlConfig");
29
+ Object.defineProperty(exports, "TTLConfig", { enumerable: true, get: function () { return ttlConfig_1.TTLConfig; } });
30
+ var envVars_1 = require("./config/envVars");
31
+ Object.defineProperty(exports, "envVars", { enumerable: true, get: function () { return envVars_1.envVars; } });
32
+ Object.defineProperty(exports, "EnvironmentVariable", { enumerable: true, get: function () { return envVars_1.EnvironmentVariable; } });
33
+ Object.defineProperty(exports, "SUPPORTED_ENV_VARS", { enumerable: true, get: function () { return envVars_1.SUPPORTED_ENV_VARS; } });
34
+ Object.defineProperty(exports, "EnvVars", { enumerable: true, get: function () { return envVars_1.EnvVars; } });
35
+ var stateAggregator_1 = require("./stateAggregator");
36
+ Object.defineProperty(exports, "StateAggregator", { enumerable: true, get: function () { return stateAggregator_1.StateAggregator; } });
33
37
  var deviceOauthService_1 = require("./deviceOauthService");
34
38
  Object.defineProperty(exports, "DeviceOauthService", { enumerable: true, get: function () { return deviceOauthService_1.DeviceOauthService; } });
35
39
  var orgUsersConfig_1 = require("./config/orgUsersConfig");
36
40
  Object.defineProperty(exports, "OrgUsersConfig", { enumerable: true, get: function () { return orgUsersConfig_1.OrgUsersConfig; } });
37
41
  var config_1 = require("./config/config");
38
42
  Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } });
43
+ Object.defineProperty(exports, "SfdxPropertyKeys", { enumerable: true, get: function () { return config_1.SfdxPropertyKeys; } });
44
+ Object.defineProperty(exports, "SfConfigProperties", { enumerable: true, get: function () { return config_1.SfConfigProperties; } });
45
+ Object.defineProperty(exports, "SFDX_ALLOWED_PROPERTIES", { enumerable: true, get: function () { return config_1.SFDX_ALLOWED_PROPERTIES; } });
46
+ Object.defineProperty(exports, "SF_ALLOWED_PROPERTIES", { enumerable: true, get: function () { return config_1.SF_ALLOWED_PROPERTIES; } });
47
+ var sandboxProcessCache_1 = require("./config/sandboxProcessCache");
48
+ Object.defineProperty(exports, "SandboxRequestCache", { enumerable: true, get: function () { return sandboxProcessCache_1.SandboxRequestCache; } });
39
49
  var configAggregator_1 = require("./config/configAggregator");
40
50
  Object.defineProperty(exports, "ConfigAggregator", { enumerable: true, get: function () { return configAggregator_1.ConfigAggregator; } });
41
51
  var authInfo_1 = require("./org/authInfo");
42
52
  Object.defineProperty(exports, "AuthInfo", { enumerable: true, get: function () { return authInfo_1.AuthInfo; } });
43
- Object.defineProperty(exports, "OAuth2WithVerifier", { enumerable: true, get: function () { return authInfo_1.OAuth2WithVerifier; } });
44
- Object.defineProperty(exports, "SfdcUrl", { enumerable: true, get: function () { return authInfo_1.SfdcUrl; } });
45
- Object.defineProperty(exports, "getJwtAudienceUrl", { enumerable: true, get: function () { return authInfo_1.getJwtAudienceUrl; } });
46
53
  var authRemover_1 = require("./org/authRemover");
47
54
  Object.defineProperty(exports, "AuthRemover", { enumerable: true, get: function () { return authRemover_1.AuthRemover; } });
48
55
  var connection_1 = require("./org/connection");
@@ -55,22 +62,31 @@ var lifecycleEvents_1 = require("./lifecycleEvents");
55
62
  Object.defineProperty(exports, "Lifecycle", { enumerable: true, get: function () { return lifecycleEvents_1.Lifecycle; } });
56
63
  var webOAuthServer_1 = require("./webOAuthServer");
57
64
  Object.defineProperty(exports, "WebOAuthServer", { enumerable: true, get: function () { return webOAuthServer_1.WebOAuthServer; } });
65
+ var sfdcUrl_1 = require("./util/sfdcUrl");
66
+ Object.defineProperty(exports, "SfdcUrl", { enumerable: true, get: function () { return sfdcUrl_1.SfdcUrl; } });
67
+ var getJwtAudienceUrl_1 = require("./util/getJwtAudienceUrl");
68
+ Object.defineProperty(exports, "getJwtAudienceUrl", { enumerable: true, get: function () { return getJwtAudienceUrl_1.getJwtAudienceUrl; } });
58
69
  var logger_1 = require("./logger");
59
70
  Object.defineProperty(exports, "LoggerLevel", { enumerable: true, get: function () { return logger_1.LoggerLevel; } });
60
71
  Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
61
72
  var messages_2 = require("./messages");
62
73
  Object.defineProperty(exports, "Messages", { enumerable: true, get: function () { return messages_2.Messages; } });
63
- var org_1 = require("./org/org");
74
+ var org_1 = require("./org");
64
75
  Object.defineProperty(exports, "Org", { enumerable: true, get: function () { return org_1.Org; } });
65
- var sfdxProject_1 = require("./sfdxProject");
66
- Object.defineProperty(exports, "SfdxProject", { enumerable: true, get: function () { return sfdxProject_1.SfdxProject; } });
67
- Object.defineProperty(exports, "SfdxProjectJson", { enumerable: true, get: function () { return sfdxProject_1.SfdxProjectJson; } });
68
- var printer_1 = require("./schema/printer");
69
- Object.defineProperty(exports, "SchemaPrinter", { enumerable: true, get: function () { return printer_1.SchemaPrinter; } });
76
+ Object.defineProperty(exports, "SandboxEvents", { enumerable: true, get: function () { return org_1.SandboxEvents; } });
77
+ Object.defineProperty(exports, "OrgTypes", { enumerable: true, get: function () { return org_1.OrgTypes; } });
78
+ var orgConfigProperties_1 = require("./org/orgConfigProperties");
79
+ Object.defineProperty(exports, "OrgConfigProperties", { enumerable: true, get: function () { return orgConfigProperties_1.OrgConfigProperties; } });
80
+ Object.defineProperty(exports, "ORG_CONFIG_ALLOWED_PROPERTIES", { enumerable: true, get: function () { return orgConfigProperties_1.ORG_CONFIG_ALLOWED_PROPERTIES; } });
81
+ var sfProject_1 = require("./sfProject");
82
+ Object.defineProperty(exports, "SfProject", { enumerable: true, get: function () { return sfProject_1.SfProject; } });
83
+ Object.defineProperty(exports, "SfProjectJson", { enumerable: true, get: function () { return sfProject_1.SfProjectJson; } });
70
84
  var validator_1 = require("./schema/validator");
71
85
  Object.defineProperty(exports, "SchemaValidator", { enumerable: true, get: function () { return validator_1.SchemaValidator; } });
72
- var sfdxError_1 = require("./sfdxError");
73
- Object.defineProperty(exports, "SfdxError", { enumerable: true, get: function () { return sfdxError_1.SfdxError; } });
86
+ var printer_1 = require("./schema/printer");
87
+ Object.defineProperty(exports, "SchemaPrinter", { enumerable: true, get: function () { return printer_1.SchemaPrinter; } });
88
+ var sfError_1 = require("./sfError");
89
+ Object.defineProperty(exports, "SfError", { enumerable: true, get: function () { return sfError_1.SfError; } });
74
90
  var pollingClient_1 = require("./status/pollingClient");
75
91
  Object.defineProperty(exports, "PollingClient", { enumerable: true, get: function () { return pollingClient_1.PollingClient; } });
76
92
  var streamingClient_1 = require("./status/streamingClient");
@@ -84,7 +100,15 @@ Object.defineProperty(exports, "REQUIRED_FIELDS", { enumerable: true, get: funct
84
100
  Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_1.User; } });
85
101
  var permissionSetAssignment_1 = require("./org/permissionSetAssignment");
86
102
  Object.defineProperty(exports, "PermissionSetAssignment", { enumerable: true, get: function () { return permissionSetAssignment_1.PermissionSetAssignment; } });
103
+ var scratchOrgCreate_1 = require("./org/scratchOrgCreate");
104
+ Object.defineProperty(exports, "scratchOrgCreate", { enumerable: true, get: function () { return scratchOrgCreate_1.scratchOrgCreate; } });
105
+ Object.defineProperty(exports, "scratchOrgResume", { enumerable: true, get: function () { return scratchOrgCreate_1.scratchOrgResume; } });
106
+ var scratchOrgLifecycleEvents_1 = require("./org/scratchOrgLifecycleEvents");
107
+ Object.defineProperty(exports, "scratchOrgLifecycleEventName", { enumerable: true, get: function () { return scratchOrgLifecycleEvents_1.scratchOrgLifecycleEventName; } });
108
+ Object.defineProperty(exports, "scratchOrgLifecycleStages", { enumerable: true, get: function () { return scratchOrgLifecycleEvents_1.scratchOrgLifecycleStages; } });
109
+ var scratchOrgCache_1 = require("./org/scratchOrgCache");
110
+ Object.defineProperty(exports, "ScratchOrgCache", { enumerable: true, get: function () { return scratchOrgCache_1.ScratchOrgCache; } });
87
111
  // Utility sub-modules
88
- __exportStar(require("./util/fs"), exports);
89
112
  __exportStar(require("./util/sfdc"), exports);
113
+ __exportStar(require("./util/sfdcUrl"), exports);
90
114
  //# sourceMappingURL=exported.js.map
package/lib/global.d.ts CHANGED
@@ -14,6 +14,12 @@ export declare enum Mode {
14
14
  * Global constants, methods, and configuration.
15
15
  */
16
16
  export declare class Global {
17
+ /**
18
+ * Enable interoperability between `.sfdx` and `.sf`.
19
+ *
20
+ * When @salesforce/core@v2 is deprecated and no longer used, this can be removed.
21
+ */
22
+ static SFDX_INTEROPERABILITY: boolean;
17
23
  /**
18
24
  * The global folder in which sfdx state is stored.
19
25
  */
@@ -22,18 +28,26 @@ export declare class Global {
22
28
  * The global folder in which sf state is stored.
23
29
  */
24
30
  static readonly SF_STATE_FOLDER = ".sf";
31
+ /**
32
+ * The preferred global folder in which state is stored.
33
+ */
34
+ static readonly STATE_FOLDER = ".sfdx";
25
35
  /**
26
36
  * The full system path to the global sfdx state folder.
27
37
  *
28
38
  * **See** {@link Global.SFDX_STATE_FOLDER}
29
39
  */
30
- static readonly SFDX_DIR: string;
40
+ static get SFDX_DIR(): string;
31
41
  /**
32
42
  * The full system path to the global sf state folder.
33
43
  *
34
- * **See** {@link Global.SF_STATE_FOLDER}
44
+ * **See** {@link Global.SF_STATE_FOLDER}
45
+ */
46
+ static get SF_DIR(): string;
47
+ /**
48
+ * The full system path to the preferred global state folder
35
49
  */
36
- static readonly SF_DIR: string;
50
+ static get DIR(): string;
37
51
  /**
38
52
  * The full system path to the global log file.
39
53
  */
package/lib/global.js CHANGED
@@ -7,10 +7,11 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.Global = exports.Mode = void 0;
10
+ const fs = require("fs");
10
11
  const os = require("os");
11
12
  const path = require("path");
12
13
  const kit_1 = require("@salesforce/kit");
13
- const fs_1 = require("./util/fs");
14
+ const sfError_1 = require("./sfError");
14
15
  /**
15
16
  * Represents an environment mode. Supports `production`, `development`, `demo`, and `test`
16
17
  * with the default mode being `production`.
@@ -28,6 +29,28 @@ var Mode;
28
29
  * Global constants, methods, and configuration.
29
30
  */
30
31
  class Global {
32
+ /**
33
+ * The full system path to the global sfdx state folder.
34
+ *
35
+ * **See** {@link Global.SFDX_STATE_FOLDER}
36
+ */
37
+ static get SFDX_DIR() {
38
+ return path.join(os.homedir(), Global.SFDX_STATE_FOLDER);
39
+ }
40
+ /**
41
+ * The full system path to the global sf state folder.
42
+ *
43
+ * **See** {@link Global.SF_STATE_FOLDER}
44
+ */
45
+ static get SF_DIR() {
46
+ return path.join(os.homedir(), Global.SF_STATE_FOLDER);
47
+ }
48
+ /**
49
+ * The full system path to the preferred global state folder
50
+ */
51
+ static get DIR() {
52
+ return path.join(os.homedir(), Global.SFDX_STATE_FOLDER);
53
+ }
31
54
  /**
32
55
  * Gets the current mode environment variable as a {@link Mode} instance.
33
56
  *
@@ -46,10 +69,26 @@ class Global {
46
69
  */
47
70
  static async createDir(dirPath) {
48
71
  dirPath = dirPath ? path.join(Global.SFDX_DIR, dirPath) : Global.SFDX_DIR;
49
- await fs_1.fs.mkdirp(dirPath, fs_1.fs.DEFAULT_USER_DIR_MODE);
72
+ try {
73
+ if (process.platform === 'win32') {
74
+ await fs.promises.mkdir(dirPath, { recursive: true });
75
+ }
76
+ else {
77
+ await fs.promises.mkdir(dirPath, { recursive: true, mode: 0o700 });
78
+ }
79
+ }
80
+ catch (error) {
81
+ throw new sfError_1.SfError(`Failed to create directory or set permissions for: ${dirPath}`);
82
+ }
50
83
  }
51
84
  }
52
85
  exports.Global = Global;
86
+ /**
87
+ * Enable interoperability between `.sfdx` and `.sf`.
88
+ *
89
+ * When @salesforce/core@v2 is deprecated and no longer used, this can be removed.
90
+ */
91
+ Global.SFDX_INTEROPERABILITY = kit_1.env.getBoolean('SF_SFDX_INTEROPERABILITY', true);
53
92
  /**
54
93
  * The global folder in which sfdx state is stored.
55
94
  */
@@ -59,19 +98,13 @@ Global.SFDX_STATE_FOLDER = '.sfdx';
59
98
  */
60
99
  Global.SF_STATE_FOLDER = '.sf';
61
100
  /**
62
- * The full system path to the global sfdx state folder.
63
- *
64
- * **See** {@link Global.SFDX_STATE_FOLDER}
65
- */
66
- Global.SFDX_DIR = path.join(os.homedir(), Global.SFDX_STATE_FOLDER);
67
- /**
68
- * The full system path to the global sf state folder.
69
- *
70
- * **See** {@link Global.SF_STATE_FOLDER}
101
+ * The preferred global folder in which state is stored.
71
102
  */
72
- Global.SF_DIR = path.join(os.homedir(), Global.SF_STATE_FOLDER);
103
+ Global.STATE_FOLDER = Global.SFDX_STATE_FOLDER;
73
104
  /**
74
105
  * The full system path to the global log file.
75
106
  */
76
- Global.LOG_FILE_PATH = path.join(Global.SFDX_DIR, 'sfdx.log');
107
+ // member ordering conflicts with the TS use-before-declaration error
108
+ // eslint-disable-next-line @typescript-eslint/member-ordering
109
+ Global.LOG_FILE_PATH = path.join(Global.SF_DIR, 'sf.log');
77
110
  //# sourceMappingURL=global.js.map
@@ -1,5 +1,5 @@
1
1
  import { AnyJson } from '@salesforce/ts-types';
2
- declare type callback = (data: any) => Promise<void>;
2
+ type callback = (data: any) => Promise<void>;
3
3
  /**
4
4
  * An asynchronous event listener and emitter that follows the singleton pattern. The singleton pattern allows lifecycle
5
5
  * events to be emitted from deep within a library and still be consumed by any other library or tool. It allows other
@@ -16,16 +16,29 @@ declare type callback = (data: any) => Promise<void>;
16
16
  *
17
17
  * // Deep in the deploy code, fire the event for all libraries and plugins to hear.
18
18
  * Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed);
19
+ *
20
+ * // if you don't need to await anything
21
+ * use `void Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed)` ;
19
22
  * ```
20
23
  */
21
24
  export declare class Lifecycle {
22
- private debug;
23
25
  private readonly listeners;
26
+ static readonly telemetryEventName = "telemetry";
27
+ static readonly warningEventName = "warning";
28
+ private debug;
24
29
  private constructor();
30
+ /**
31
+ * return the package.json version of the sfdx-core library.
32
+ */
33
+ static staticVersion(): string;
25
34
  /**
26
35
  * Retrieve the singleton instance of this class so that all listeners and emitters can interact from any library or tool
27
36
  */
28
37
  static getInstance(): Lifecycle;
38
+ /**
39
+ * return the package.json version of the sfdx-core library.
40
+ */
41
+ version(): string;
29
42
  /**
30
43
  * Remove all listeners for a given event
31
44
  *
@@ -38,6 +51,18 @@ export declare class Lifecycle {
38
51
  * @param eventName The name of the event to get listeners of
39
52
  */
40
53
  getListeners(eventName: string): callback[];
54
+ /**
55
+ * Create a listener for the `telemetry` event
56
+ *
57
+ * @param cb The callback function to run when the event is emitted
58
+ */
59
+ onTelemetry(cb: (data: Record<string, unknown>) => Promise<void>): void;
60
+ /**
61
+ * Create a listener for the `warning` event
62
+ *
63
+ * @param cb The callback function to run when the event is emitted
64
+ */
65
+ onWarning(cb: (warning: string) => Promise<void>): void;
41
66
  /**
42
67
  * Create a new listener for a given event
43
68
  *
@@ -45,6 +70,18 @@ export declare class Lifecycle {
45
70
  * @param cb The callback function to run when the event is emitted
46
71
  */
47
72
  on<T = AnyJson>(eventName: string, cb: (data: T) => Promise<void>): void;
73
+ /**
74
+ * Emit a `telemetry` event, causing all callback functions to be run in the order they were registered
75
+ *
76
+ * @param data The data to emit
77
+ */
78
+ emitTelemetry(data: AnyJson): Promise<void>;
79
+ /**
80
+ * Emit a `warning` event, causing all callback functions to be run in the order they were registered
81
+ *
82
+ * @param data The warning (string) to emit
83
+ */
84
+ emitWarning(warning: string): Promise<void>;
48
85
  /**
49
86
  * Emit a given event, causing all callback functions to be run in the order they were registered
50
87
  *
@@ -8,6 +8,11 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.Lifecycle = void 0;
10
10
  const Debug = require("debug");
11
+ const semver_1 = require("semver");
12
+ // needed for TS to not put everything inside /lib/src
13
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14
+ // @ts-ignore
15
+ const pjson = require("../package.json");
11
16
  /**
12
17
  * An asynchronous event listener and emitter that follows the singleton pattern. The singleton pattern allows lifecycle
13
18
  * events to be emitted from deep within a library and still be consumed by any other library or tool. It allows other
@@ -24,12 +29,21 @@ const Debug = require("debug");
24
29
  *
25
30
  * // Deep in the deploy code, fire the event for all libraries and plugins to hear.
26
31
  * Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed);
32
+ *
33
+ * // if you don't need to await anything
34
+ * use `void Lifecycle.getInstance().emit('deploy-metadata', metadataToBeDeployed)` ;
27
35
  * ```
28
36
  */
29
37
  class Lifecycle {
30
- constructor() {
38
+ constructor(listeners = {}) {
39
+ this.listeners = listeners;
31
40
  this.debug = Debug(`sfdx:${this.constructor.name}`);
32
- this.listeners = {};
41
+ }
42
+ /**
43
+ * return the package.json version of the sfdx-core library.
44
+ */
45
+ static staticVersion() {
46
+ return pjson.version;
33
47
  }
34
48
  /**
35
49
  * Retrieve the singleton instance of this class so that all listeners and emitters can interact from any library or tool
@@ -52,10 +66,30 @@ class Lifecycle {
52
66
  //
53
67
  // Nothing should EVER be removed, even across major versions.
54
68
  if (!global.salesforceCoreLifecycle) {
69
+ // it's not been loaded yet (basic singleton pattern)
55
70
  global.salesforceCoreLifecycle = new Lifecycle();
56
71
  }
72
+ else if (
73
+ // an older version was loaded that should be replaced
74
+ (0, semver_1.compare)(global.salesforceCoreLifecycle.version(), Lifecycle.staticVersion()) === -1) {
75
+ const oldInstance = global.salesforceCoreLifecycle;
76
+ // use the newer version and transfer any listeners from the old version
77
+ // object spread keeps them from being references
78
+ global.salesforceCoreLifecycle = new Lifecycle({ ...oldInstance.listeners });
79
+ // clean up any listeners on the old version
80
+ Object.keys(oldInstance.listeners).map((eventName) => {
81
+ oldInstance.removeAllListeners(eventName);
82
+ });
83
+ }
57
84
  return global.salesforceCoreLifecycle;
58
85
  }
86
+ /**
87
+ * return the package.json version of the sfdx-core library.
88
+ */
89
+ // eslint-disable-next-line class-methods-use-this
90
+ version() {
91
+ return pjson.version;
92
+ }
59
93
  /**
60
94
  * Remove all listeners for a given event
61
95
  *
@@ -79,6 +113,22 @@ class Lifecycle {
79
113
  return [];
80
114
  }
81
115
  }
116
+ /**
117
+ * Create a listener for the `telemetry` event
118
+ *
119
+ * @param cb The callback function to run when the event is emitted
120
+ */
121
+ onTelemetry(cb) {
122
+ this.on(Lifecycle.telemetryEventName, cb);
123
+ }
124
+ /**
125
+ * Create a listener for the `warning` event
126
+ *
127
+ * @param cb The callback function to run when the event is emitted
128
+ */
129
+ onWarning(cb) {
130
+ this.on(Lifecycle.warningEventName, cb);
131
+ }
82
132
  /**
83
133
  * Create a new listener for a given event
84
134
  *
@@ -93,6 +143,27 @@ class Lifecycle {
93
143
  listeners.push(cb);
94
144
  this.listeners[eventName] = listeners;
95
145
  }
146
+ /**
147
+ * Emit a `telemetry` event, causing all callback functions to be run in the order they were registered
148
+ *
149
+ * @param data The data to emit
150
+ */
151
+ async emitTelemetry(data) {
152
+ return this.emit(Lifecycle.telemetryEventName, data);
153
+ }
154
+ /**
155
+ * Emit a `warning` event, causing all callback functions to be run in the order they were registered
156
+ *
157
+ * @param data The warning (string) to emit
158
+ */
159
+ async emitWarning(warning) {
160
+ // if there are no listeners, warnings should go to the node process so they're not lost
161
+ // this also preserves behavior in UT where there's a spy on process.emitWarning
162
+ if (this.getListeners(Lifecycle.warningEventName).length === 0) {
163
+ process.emitWarning(warning);
164
+ }
165
+ return this.emit(Lifecycle.warningEventName, warning);
166
+ }
96
167
  /**
97
168
  * Emit a given event, causing all callback functions to be run in the order they were registered
98
169
  *
@@ -101,15 +172,18 @@ class Lifecycle {
101
172
  */
102
173
  async emit(eventName, data) {
103
174
  const listeners = this.getListeners(eventName);
104
- if (listeners.length === 0) {
175
+ if (listeners.length === 0 && eventName !== Lifecycle.warningEventName) {
105
176
  this.debug(`A lifecycle event with the name ${eventName} does not exist. An event must be registered before it can be emitted.`);
106
177
  }
107
178
  else {
108
179
  for (const cb of listeners) {
180
+ // eslint-disable-next-line no-await-in-loop
109
181
  await cb(data);
110
182
  }
111
183
  }
112
184
  }
113
185
  }
114
186
  exports.Lifecycle = Lifecycle;
187
+ Lifecycle.telemetryEventName = 'telemetry';
188
+ Lifecycle.warningEventName = 'warning';
115
189
  //# sourceMappingURL=lifecycleEvents.js.map
package/lib/logger.d.ts CHANGED
@@ -6,7 +6,7 @@ import { Writable } from 'stream';
6
6
  * @param input The input to be serialized.
7
7
  * **See** {@link https://github.com/forcedotcom/node-bunyan#serializers|Bunyan Serializers API}
8
8
  */
9
- export declare type Serializer = (input: unknown) => unknown;
9
+ export type Serializer = (input: unknown) => unknown;
10
10
  /**
11
11
  * A collection of named `Serializer`s.
12
12
  *
@@ -62,7 +62,7 @@ export declare enum LoggerLevel {
62
62
  FATAL = 60
63
63
  }
64
64
  /**
65
- * `Logger` format types.
65
+ * `Logger` format types.
66
66
  */
67
67
  export declare enum LoggerFormat {
68
68
  JSON = 0,
@@ -99,7 +99,7 @@ export interface LoggerStream {
99
99
  /**
100
100
  * Any numeric `Logger` level.
101
101
  */
102
- export declare type LoggerLevelValue = LoggerLevel | number;
102
+ export type LoggerLevelValue = LoggerLevel | number;
103
103
  /**
104
104
  * A collection of named `FieldValue`s.
105
105
  *
@@ -111,7 +111,7 @@ export interface Fields {
111
111
  /**
112
112
  * All possible field value types.
113
113
  */
114
- export declare type FieldValue = string | number | boolean;
114
+ export type FieldValue = string | number | boolean;
115
115
  /**
116
116
  * Log line interface
117
117
  */
@@ -144,13 +144,13 @@ export interface LogLine {
144
144
  * ```
145
145
  * **See** https://github.com/forcedotcom/node-bunyan
146
146
  *
147
- * **See** https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_cli_log_messages.htm
147
+ * **See** https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_log_messages.htm
148
148
  */
149
149
  export declare class Logger {
150
150
  /**
151
151
  * The name of the root sfdx `Logger`.
152
152
  */
153
- static readonly ROOT_NAME = "sfdx";
153
+ static readonly ROOT_NAME = "sf";
154
154
  /**
155
155
  * The default `LoggerLevel` when constructing new `Logger` instances.
156
156
  */
@@ -163,6 +163,17 @@ export declare class Logger {
163
163
  static readonly LEVEL_NAMES: string[];
164
164
  private static readonly lifecycle;
165
165
  private static rootLogger?;
166
+ /**
167
+ * The default rotation period for logs. Example '1d' will rotate logs daily (at midnight).
168
+ * See 'period' docs here: https://github.com/forcedotcom/node-bunyan#stream-type-rotating-file
169
+ */
170
+ readonly logRotationPeriod: string;
171
+ /**
172
+ * The number of backup rotated log files to keep.
173
+ * Example: '3' will have the base sf.log file, and the past 3 (period) log files.
174
+ * See 'count' docs here: https://github.com/forcedotcom/node-bunyan#stream-type-rotating-file
175
+ */
176
+ readonly logRotationCount: number;
166
177
  /**
167
178
  * Whether debug is enabled for this Logger.
168
179
  */
@@ -174,7 +185,7 @@ export declare class Logger {
174
185
  *
175
186
  * @param optionsOrName A set of `LoggerOptions` or name to use with the default options.
176
187
  *
177
- * **Throws** *{@link SfdxError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
188
+ * **Throws** *{@link SfError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
178
189
  * `Logger`.
179
190
  */
180
191
  constructor(optionsOrName: LoggerOptions | string);
@@ -211,7 +222,7 @@ export declare class Logger {
211
222
  *
212
223
  * @param {string} levelName The level name to convert to a `LoggerLevel` enum value.
213
224
  *
214
- * **Throws** *{@link SfdxError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
225
+ * **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
215
226
  * @see {@Link LoggerLevel}
216
227
  */
217
228
  static getLevelByName(levelName: string): LoggerLevelValue;
@@ -249,7 +260,7 @@ export declare class Logger {
249
260
  *
250
261
  * @param {LoggerLevelValue} [level] The logger level.
251
262
  *
252
- * **Throws** *{@link SfdxError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
263
+ * **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
253
264
  * was invalid.
254
265
  *
255
266
  * ```
@@ -299,8 +310,7 @@ export declare class Logger {
299
310
  /**
300
311
  * Close the logger, including any streams, and remove all listeners.
301
312
  *
302
- * @param fn A function with signature `(stream: LoggerStream) => void` to call for each stream with
303
- * the stream as an arg.
313
+ * @param fn A function with signature `(stream: LoggerStream) => void` to call for each stream with the stream as an arg.
304
314
  */
305
315
  close(fn?: (stream: LoggerStream) => void): void;
306
316
  /**