@salesforce/core 4.0.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 (153) 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 +87 -22
  8. package/lib/config/config.js +117 -65
  9. package/lib/config/configAggregator.d.ts +41 -35
  10. package/lib/config/configAggregator.js +102 -73
  11. package/lib/config/configFile.d.ts +2 -2
  12. package/lib/config/configFile.js +38 -29
  13. package/lib/config/configGroup.d.ts +141 -0
  14. package/lib/config/configGroup.js +225 -0
  15. package/lib/config/configStore.d.ts +9 -9
  16. package/lib/config/configStore.js +17 -15
  17. package/lib/config/envVars.d.ts +15 -9
  18. package/lib/config/envVars.js +71 -47
  19. package/lib/config/orgUsersConfig.js +2 -0
  20. package/lib/config/sandboxOrgConfig.js +2 -0
  21. package/lib/config/sandboxProcessCache.d.ts +16 -0
  22. package/lib/config/sandboxProcessCache.js +38 -0
  23. package/lib/config/tokensConfig.d.ts +10 -0
  24. package/lib/config/tokensConfig.js +29 -0
  25. package/lib/config/ttlConfig.d.ts +34 -0
  26. package/lib/config/ttlConfig.js +50 -0
  27. package/lib/crypto/crypto.js +15 -22
  28. package/lib/crypto/keyChain.js +2 -3
  29. package/lib/crypto/keyChainImpl.d.ts +5 -3
  30. package/lib/crypto/keyChainImpl.js +58 -61
  31. package/lib/crypto/secureBuffer.d.ts +1 -1
  32. package/lib/deviceOauthService.d.ts +3 -3
  33. package/lib/deviceOauthService.js +27 -25
  34. package/lib/exported.d.ts +15 -12
  35. package/lib/exported.js +28 -16
  36. package/lib/global.d.ts +11 -3
  37. package/lib/global.js +39 -12
  38. package/lib/lifecycleEvents.d.ts +1 -1
  39. package/lib/lifecycleEvents.js +3 -0
  40. package/lib/logger.d.ts +19 -9
  41. package/lib/logger.js +112 -86
  42. package/lib/messages.d.ts +53 -36
  43. package/lib/messages.js +81 -91
  44. package/lib/org/authInfo.d.ts +56 -20
  45. package/lib/org/authInfo.js +232 -131
  46. package/lib/org/authRemover.d.ts +8 -7
  47. package/lib/org/authRemover.js +32 -28
  48. package/lib/org/connection.d.ts +13 -37
  49. package/lib/org/connection.js +78 -124
  50. package/lib/org/index.js +5 -1
  51. package/lib/org/org.d.ts +151 -48
  52. package/lib/org/org.js +466 -220
  53. package/lib/org/orgConfigProperties.d.ts +64 -3
  54. package/lib/org/orgConfigProperties.js +96 -4
  55. package/lib/org/permissionSetAssignment.js +4 -13
  56. package/lib/org/scratchOrgCache.d.ts +20 -0
  57. package/lib/org/scratchOrgCache.js +33 -0
  58. package/lib/org/scratchOrgCreate.d.ts +28 -17
  59. package/lib/org/scratchOrgCreate.js +125 -53
  60. package/lib/org/scratchOrgErrorCodes.d.ts +9 -3
  61. package/lib/org/scratchOrgErrorCodes.js +34 -17
  62. package/lib/org/scratchOrgFeatureDeprecation.js +1 -6
  63. package/lib/org/scratchOrgInfoApi.d.ts +21 -47
  64. package/lib/org/scratchOrgInfoApi.js +129 -63
  65. package/lib/org/scratchOrgInfoGenerator.d.ts +6 -5
  66. package/lib/org/scratchOrgInfoGenerator.js +76 -62
  67. package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -0
  68. package/lib/org/scratchOrgLifecycleEvents.js +41 -0
  69. package/lib/org/scratchOrgSettingsGenerator.d.ts +44 -21
  70. package/lib/org/scratchOrgSettingsGenerator.js +165 -98
  71. package/lib/org/scratchOrgTypes.d.ts +43 -0
  72. package/lib/org/scratchOrgTypes.js +9 -0
  73. package/lib/org/user.d.ts +1 -1
  74. package/lib/org/user.js +25 -34
  75. package/lib/schema/printer.d.ts +6 -0
  76. package/lib/schema/printer.js +34 -31
  77. package/lib/schema/validator.d.ts +12 -10
  78. package/lib/schema/validator.js +56 -76
  79. package/lib/{sfdxError.d.ts → sfError.d.ts} +12 -20
  80. package/lib/{sfdxError.js → sfError.js} +40 -30
  81. package/lib/{sfdxProject.d.ts → sfProject.d.ts} +75 -35
  82. package/lib/sfProject.js +651 -0
  83. package/lib/{globalInfo → stateAggregator}/accessors/aliasAccessor.d.ts +27 -12
  84. package/lib/{globalInfo → stateAggregator}/accessors/aliasAccessor.js +47 -31
  85. package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -0
  86. package/lib/stateAggregator/accessors/orgAccessor.js +240 -0
  87. package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -0
  88. package/lib/stateAggregator/accessors/sandboxAccessor.js +28 -0
  89. package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -0
  90. package/lib/stateAggregator/accessors/tokenAccessor.js +80 -0
  91. package/lib/stateAggregator/index.d.ts +4 -0
  92. package/lib/stateAggregator/index.js +27 -0
  93. package/lib/stateAggregator/stateAggregator.d.ts +25 -0
  94. package/lib/stateAggregator/stateAggregator.js +46 -0
  95. package/lib/status/myDomainResolver.d.ts +1 -1
  96. package/lib/status/myDomainResolver.js +4 -4
  97. package/lib/status/pollingClient.js +4 -4
  98. package/lib/status/streamingClient.d.ts +2 -2
  99. package/lib/status/streamingClient.js +58 -63
  100. package/lib/status/types.d.ts +2 -2
  101. package/lib/testSetup.d.ts +206 -75
  102. package/lib/testSetup.js +463 -165
  103. package/lib/util/cache.d.ts +2 -2
  104. package/lib/util/cache.js +6 -6
  105. package/lib/util/checkLightningDomain.js +3 -4
  106. package/lib/util/directoryWriter.d.ts +12 -0
  107. package/lib/util/directoryWriter.js +54 -0
  108. package/lib/util/getJwtAudienceUrl.js +1 -1
  109. package/lib/util/internal.d.ts +28 -2
  110. package/lib/util/internal.js +65 -8
  111. package/lib/util/jsonXmlTools.js +2 -4
  112. package/lib/util/mapKeys.d.ts +9 -9
  113. package/lib/util/mapKeys.js +13 -9
  114. package/lib/util/sfdc.d.ts +51 -51
  115. package/lib/util/sfdc.js +74 -79
  116. package/lib/util/sfdcUrl.d.ts +5 -19
  117. package/lib/util/sfdcUrl.js +40 -49
  118. package/lib/util/structuredWriter.d.ts +9 -0
  119. package/lib/util/structuredWriter.js +3 -0
  120. package/lib/util/zipWriter.d.ts +8 -6
  121. package/lib/util/zipWriter.js +13 -13
  122. package/lib/webOAuthServer.d.ts +20 -6
  123. package/lib/webOAuthServer.js +102 -56
  124. package/messageTransformer/messageTransformer.ts +93 -0
  125. package/messages/auth.md +9 -1
  126. package/messages/config.md +42 -6
  127. package/messages/connection.md +8 -0
  128. package/messages/core.md +10 -0
  129. package/messages/envVars.md +37 -3
  130. package/messages/org.md +21 -1
  131. package/messages/scratchOrgCreate.md +2 -6
  132. package/messages/scratchOrgErrorCodes.md +17 -1
  133. package/messages/scratchOrgInfoApi.md +9 -0
  134. package/messages/scratchOrgInfoGenerator.md +9 -1
  135. package/package.json +121 -46
  136. package/CHANGELOG.md +0 -1244
  137. package/lib/config/keychainConfig.d.ts +0 -19
  138. package/lib/config/keychainConfig.js +0 -43
  139. package/lib/globalInfo/accessors/orgAccessor.d.ts +0 -13
  140. package/lib/globalInfo/accessors/orgAccessor.js +0 -45
  141. package/lib/globalInfo/accessors/tokenAccessor.d.ts +0 -13
  142. package/lib/globalInfo/accessors/tokenAccessor.js +0 -35
  143. package/lib/globalInfo/globalInfoConfig.d.ts +0 -36
  144. package/lib/globalInfo/globalInfoConfig.js +0 -105
  145. package/lib/globalInfo/index.d.ts +0 -6
  146. package/lib/globalInfo/index.js +0 -29
  147. package/lib/globalInfo/sfdxDataHandler.d.ts +0 -43
  148. package/lib/globalInfo/sfdxDataHandler.js +0 -217
  149. package/lib/globalInfo/types.d.ts +0 -39
  150. package/lib/globalInfo/types.js +0 -10
  151. package/lib/sfdxProject.js +0 -557
  152. package/lib/util/fs.d.ts +0 -201
  153. package/lib/util/fs.js +0 -378
@@ -0,0 +1,141 @@
1
+ import { Dictionary, JsonMap, Optional } from '@salesforce/ts-types';
2
+ import { ConfigFile } from './configFile';
3
+ import { ConfigContents, ConfigEntry, ConfigValue } from './configStore';
4
+ /**
5
+ * A config file that stores config values in groups. e.g. to store different config
6
+ * values for different commands, without having manually manipulate the config.
7
+ *
8
+ * **Note:** All config methods are overwritten to use the {@link ConfigGroup.setDefaultGroup}.
9
+ *
10
+ * ```
11
+ * class MyPluginConfig extends ConfigGroup<ConfigGroup.Options> {
12
+ * public static getFileName(): string {
13
+ * return 'myPluginConfigFilename.json';
14
+ * }
15
+ * }
16
+ * const myConfig = await MyPluginConfig.create(ConfigGroup.getOptions('all'));
17
+ * myConfig.setDefaultGroup('myCommand'); // Can be set in your command's init.
18
+ * myConfig.set('mykey', 'myvalue'); // Sets 'myKey' for the 'myCommand' group.
19
+ * myConfig.setInGroup('myKey', 'myvalue', 'all'); // Manually set in another group.
20
+ * await myConfig.write();
21
+ * ```
22
+ */
23
+ export declare class ConfigGroup<T extends ConfigGroup.Options> extends ConfigFile<T> {
24
+ protected defaultGroup: string;
25
+ /**
26
+ * Get ConfigGroup specific options, such as the default group.
27
+ *
28
+ * @param defaultGroup The default group to use when creating the config.
29
+ * @param filename The filename of the config file. Uses the static {@link getFileName} by default.
30
+ */
31
+ static getOptions(defaultGroup: string, filename?: string): ConfigGroup.Options;
32
+ /**
33
+ * Sets the default group for all {@link BaseConfigStore} methods to use.
34
+ * **Throws** *{@link SfError}{ name: 'MissingGroupName' }* The group parameter is null or undefined.
35
+ *
36
+ * @param group The group.
37
+ */
38
+ setDefaultGroup(group: string): void;
39
+ /**
40
+ * Set a group of entries in a bulk save. Returns The new properties that were saved.
41
+ *
42
+ * @param newEntries An object representing the aliases to set.
43
+ * @param group The group the property belongs to.
44
+ */
45
+ updateValues(newEntries: Dictionary<ConfigValue>, group?: string): Promise<Dictionary<ConfigValue>>;
46
+ /**
47
+ * Set a value on a group. Returns the promise resolved when the value is set.
48
+ *
49
+ * @param key The key.
50
+ * @param value The value.
51
+ * @param group The group.
52
+ */
53
+ updateValue(key: string, value: ConfigValue, group?: string): Promise<void>;
54
+ /**
55
+ * Gets an array of key value pairs.
56
+ */
57
+ entries(): ConfigEntry[];
58
+ /**
59
+ * Returns a specified element from ConfigGroup. Returns the associated value.
60
+ *
61
+ * @param key The key.
62
+ */
63
+ get(key: string): Optional<ConfigValue>;
64
+ /**
65
+ * Returns a boolean if an element with the specified key exists in the default group.
66
+ *
67
+ * @param {string} key The key.
68
+ */
69
+ has(key: string): boolean;
70
+ /**
71
+ * Returns an array of the keys from the default group.
72
+ */
73
+ keys(): string[];
74
+ /**
75
+ * Returns an array of the values from the default group.
76
+ */
77
+ values(): ConfigValue[];
78
+ /**
79
+ * Add or updates an element with the specified key in the default group.
80
+ *
81
+ * @param key The key.
82
+ * @param value The value.
83
+ */
84
+ set(key: string, value: ConfigValue): ConfigContents;
85
+ /**
86
+ * Removes an element with the specified key from the default group. Returns `true` if the item was deleted.
87
+ *
88
+ * @param key The key.
89
+ */
90
+ unset(key: string): boolean;
91
+ /**
92
+ * Remove all key value pairs from the default group.
93
+ */
94
+ clear(): void;
95
+ /**
96
+ * Get all config contents for a group.
97
+ *
98
+ * @param {string} [group = 'default'] The group.
99
+ */
100
+ getGroup(group?: string): Optional<ConfigContents>;
101
+ /**
102
+ * Returns the value associated to the key and group, or undefined if there is none.
103
+ *
104
+ * @param key The key.
105
+ * @param group The group. Defaults to the default group.
106
+ */
107
+ getInGroup(key: string, group?: string): Optional<ConfigValue>;
108
+ /**
109
+ * Convert the config object to a json object.
110
+ */
111
+ toObject(): JsonMap;
112
+ /**
113
+ * Convert an object to a {@link ConfigContents} and set it as the config contents.
114
+ *
115
+ * @param {object} obj The object.
116
+ */
117
+ setContentsFromObject<U extends object>(obj: U): void;
118
+ /**
119
+ * Sets the value for the key and group in the config object.
120
+ *
121
+ * @param key The key.
122
+ * @param value The value.
123
+ * @param group The group. Uses the default group if not specified.
124
+ */
125
+ setInGroup(key: string, value?: ConfigValue, group?: string): ConfigContents;
126
+ /**
127
+ * Initialize the asynchronous dependencies.
128
+ */
129
+ init(): Promise<void>;
130
+ }
131
+ export declare namespace ConfigGroup {
132
+ /**
133
+ * Options when creating the config file.
134
+ */
135
+ interface Options extends ConfigFile.Options {
136
+ /**
137
+ * The default group for properties to go into.
138
+ */
139
+ defaultGroup?: string;
140
+ }
141
+ }
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2020, 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.ConfigGroup = void 0;
10
+ const ts_types_1 = require("@salesforce/ts-types");
11
+ const sfError_1 = require("../sfError");
12
+ const configFile_1 = require("./configFile");
13
+ /**
14
+ * A config file that stores config values in groups. e.g. to store different config
15
+ * values for different commands, without having manually manipulate the config.
16
+ *
17
+ * **Note:** All config methods are overwritten to use the {@link ConfigGroup.setDefaultGroup}.
18
+ *
19
+ * ```
20
+ * class MyPluginConfig extends ConfigGroup<ConfigGroup.Options> {
21
+ * public static getFileName(): string {
22
+ * return 'myPluginConfigFilename.json';
23
+ * }
24
+ * }
25
+ * const myConfig = await MyPluginConfig.create(ConfigGroup.getOptions('all'));
26
+ * myConfig.setDefaultGroup('myCommand'); // Can be set in your command's init.
27
+ * myConfig.set('mykey', 'myvalue'); // Sets 'myKey' for the 'myCommand' group.
28
+ * myConfig.setInGroup('myKey', 'myvalue', 'all'); // Manually set in another group.
29
+ * await myConfig.write();
30
+ * ```
31
+ */
32
+ class ConfigGroup extends configFile_1.ConfigFile {
33
+ constructor() {
34
+ super(...arguments);
35
+ this.defaultGroup = 'default';
36
+ }
37
+ /**
38
+ * Get ConfigGroup specific options, such as the default group.
39
+ *
40
+ * @param defaultGroup The default group to use when creating the config.
41
+ * @param filename The filename of the config file. Uses the static {@link getFileName} by default.
42
+ */
43
+ static getOptions(defaultGroup, filename) {
44
+ const options = configFile_1.ConfigFile.getDefaultOptions(true, filename);
45
+ const configGroupOptions = { defaultGroup };
46
+ Object.assign(configGroupOptions, options);
47
+ return configGroupOptions;
48
+ }
49
+ /**
50
+ * Sets the default group for all {@link BaseConfigStore} methods to use.
51
+ * **Throws** *{@link SfError}{ name: 'MissingGroupName' }* The group parameter is null or undefined.
52
+ *
53
+ * @param group The group.
54
+ */
55
+ setDefaultGroup(group) {
56
+ if (!group) {
57
+ throw new sfError_1.SfError('null or undefined group', 'MissingGroupName');
58
+ }
59
+ this.defaultGroup = group;
60
+ }
61
+ /**
62
+ * Set a group of entries in a bulk save. Returns The new properties that were saved.
63
+ *
64
+ * @param newEntries An object representing the aliases to set.
65
+ * @param group The group the property belongs to.
66
+ */
67
+ async updateValues(newEntries, group) {
68
+ // Make sure the contents are loaded
69
+ await this.read();
70
+ Object.entries(newEntries).forEach(([key, val]) => this.setInGroup(key, val, group ?? this.defaultGroup));
71
+ await this.write();
72
+ return newEntries;
73
+ }
74
+ /**
75
+ * Set a value on a group. Returns the promise resolved when the value is set.
76
+ *
77
+ * @param key The key.
78
+ * @param value The value.
79
+ * @param group The group.
80
+ */
81
+ async updateValue(key, value, group) {
82
+ // Make sure the content is loaded
83
+ await this.read();
84
+ this.setInGroup(key, value, group ?? this.defaultGroup);
85
+ // Then save it
86
+ await this.write();
87
+ }
88
+ /**
89
+ * Gets an array of key value pairs.
90
+ */
91
+ entries() {
92
+ const group = this.getGroup();
93
+ if (group) {
94
+ return (0, ts_types_1.definiteEntriesOf)(group);
95
+ }
96
+ return [];
97
+ }
98
+ /**
99
+ * Returns a specified element from ConfigGroup. Returns the associated value.
100
+ *
101
+ * @param key The key.
102
+ */
103
+ get(key) {
104
+ return this.getInGroup(key);
105
+ }
106
+ /**
107
+ * Returns a boolean if an element with the specified key exists in the default group.
108
+ *
109
+ * @param {string} key The key.
110
+ */
111
+ has(key) {
112
+ const group = this.getGroup();
113
+ return !!group && super.has(this.defaultGroup) && !!group[key];
114
+ }
115
+ /**
116
+ * Returns an array of the keys from the default group.
117
+ */
118
+ keys() {
119
+ return Object.keys(this.getGroup(this.defaultGroup) ?? {});
120
+ }
121
+ /**
122
+ * Returns an array of the values from the default group.
123
+ */
124
+ values() {
125
+ return (0, ts_types_1.definiteValuesOf)(this.getGroup(this.defaultGroup) ?? {});
126
+ }
127
+ /**
128
+ * Add or updates an element with the specified key in the default group.
129
+ *
130
+ * @param key The key.
131
+ * @param value The value.
132
+ */
133
+ set(key, value) {
134
+ return this.setInGroup(key, value, this.defaultGroup);
135
+ }
136
+ /**
137
+ * Removes an element with the specified key from the default group. Returns `true` if the item was deleted.
138
+ *
139
+ * @param key The key.
140
+ */
141
+ unset(key) {
142
+ const groupContents = this.getGroup(this.defaultGroup);
143
+ if (groupContents) {
144
+ delete groupContents[key];
145
+ return true;
146
+ }
147
+ return false;
148
+ }
149
+ /**
150
+ * Remove all key value pairs from the default group.
151
+ */
152
+ clear() {
153
+ delete this.getContents()[this.defaultGroup];
154
+ }
155
+ /**
156
+ * Get all config contents for a group.
157
+ *
158
+ * @param {string} [group = 'default'] The group.
159
+ */
160
+ getGroup(group = this.defaultGroup) {
161
+ return (0, ts_types_1.getJsonMap)(this.getContents(), group) ?? undefined;
162
+ }
163
+ /**
164
+ * Returns the value associated to the key and group, or undefined if there is none.
165
+ *
166
+ * @param key The key.
167
+ * @param group The group. Defaults to the default group.
168
+ */
169
+ getInGroup(key, group) {
170
+ const groupContents = this.getGroup(group);
171
+ if (groupContents) {
172
+ return groupContents[key];
173
+ }
174
+ }
175
+ /**
176
+ * Convert the config object to a json object.
177
+ */
178
+ toObject() {
179
+ return this.getContents();
180
+ }
181
+ /**
182
+ * Convert an object to a {@link ConfigContents} and set it as the config contents.
183
+ *
184
+ * @param {object} obj The object.
185
+ */
186
+ // eslint-disable-next-line @typescript-eslint/ban-types
187
+ setContentsFromObject(obj) {
188
+ const contents = new Map(Object.entries(obj));
189
+ Array.from(contents.entries()).forEach(([groupKey, groupContents]) => {
190
+ if (groupContents) {
191
+ Object.entries(groupContents).forEach(([contentKey, contentValue]) => {
192
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
193
+ this.setInGroup(contentKey, contentValue, groupKey);
194
+ });
195
+ }
196
+ });
197
+ }
198
+ /**
199
+ * Sets the value for the key and group in the config object.
200
+ *
201
+ * @param key The key.
202
+ * @param value The value.
203
+ * @param group The group. Uses the default group if not specified.
204
+ */
205
+ setInGroup(key, value, group) {
206
+ group = group ?? this.defaultGroup;
207
+ if (!super.has(group)) {
208
+ super.set(group, {});
209
+ }
210
+ const content = this.getGroup(group) ?? {};
211
+ this.setMethod(content, key, value);
212
+ return content;
213
+ }
214
+ /**
215
+ * Initialize the asynchronous dependencies.
216
+ */
217
+ async init() {
218
+ await super.init();
219
+ if (this.options.defaultGroup) {
220
+ this.setDefaultGroup(this.options.defaultGroup);
221
+ }
222
+ }
223
+ }
224
+ exports.ConfigGroup = ConfigGroup;
225
+ //# sourceMappingURL=configGroup.js.map
@@ -4,16 +4,16 @@ import { Crypto } from '../crypto/crypto';
4
4
  /**
5
5
  * The allowed types stored in a config store.
6
6
  */
7
- export declare type ConfigValue = AnyJson;
7
+ export type ConfigValue = AnyJson;
8
8
  /**
9
9
  * The type of entries in a config store defined by the key and value type of {@link ConfigContents}.
10
10
  */
11
- export declare type ConfigEntry = [string, ConfigValue];
11
+ export type ConfigEntry = [string, ConfigValue];
12
12
  /**
13
13
  * The type of content a config stores.
14
14
  */
15
- export declare type ConfigContents = Dictionary<ConfigValue>;
16
- export declare type Key<P extends ConfigContents> = Extract<keyof P, string>;
15
+ export type ConfigContents<T = ConfigValue> = Dictionary<T>;
16
+ export type Key<P extends ConfigContents> = Extract<keyof P, string>;
17
17
  /**
18
18
  * An interface for a config object with a persistent store.
19
19
  */
@@ -68,7 +68,7 @@ export declare abstract class BaseConfigStore<T extends BaseConfigStore.Options
68
68
  * If the value is an object, a clone will be returned.
69
69
  */
70
70
  get<K extends Key<P>>(key: K, decrypt?: boolean): P[K];
71
- get<T = ConfigValue>(key: string, decrypt?: boolean): T;
71
+ get<V = ConfigValue>(key: string, decrypt?: boolean): V;
72
72
  /**
73
73
  * Returns the list of keys that contain a value.
74
74
  *
@@ -93,7 +93,7 @@ export declare abstract class BaseConfigStore<T extends BaseConfigStore.Options
93
93
  * @param value The value.
94
94
  */
95
95
  set<K extends Key<P>>(key: K, value: P[K]): void;
96
- set<T = ConfigValue>(key: string, value: T): void;
96
+ set<V = ConfigValue>(key: string, value: V): void;
97
97
  /**
98
98
  * Updates the value for the key in the config object. If the value is an object, it
99
99
  * will be merged with the existing object.
@@ -102,7 +102,7 @@ export declare abstract class BaseConfigStore<T extends BaseConfigStore.Options
102
102
  * @param value The value.
103
103
  */
104
104
  update<K extends Key<P>>(key: K, value: Partial<P[K]>): void;
105
- update<T = ConfigValue>(key: string, value: Partial<T>): void;
105
+ update<V = ConfigValue>(key: string, value: Partial<V>): void;
106
106
  /**
107
107
  * Returns `true` if an element in the config object existed and has been removed, or `false` if the element does not
108
108
  * exist. {@link BaseConfigStore.has} will return false afterwards.
@@ -166,7 +166,7 @@ export declare abstract class BaseConfigStore<T extends BaseConfigStore.Options
166
166
  *
167
167
  * @param obj The object.
168
168
  */
169
- setContentsFromObject<U extends object>(obj: U): void;
169
+ setContentsFromObject<U extends JsonMap>(obj: U): void;
170
170
  protected getEncryptedKeys(): Array<string | RegExp>;
171
171
  /**
172
172
  * This config file has encrypted keys and it should attempt to encrypt them.
@@ -204,7 +204,7 @@ export declare abstract class BaseConfigStore<T extends BaseConfigStore.Options
204
204
  * @param keyPaths: The complete path of the (nested) data
205
205
  * @param data: The current (nested) data being worked on.
206
206
  */
207
- protected recursiveEncrypt<T extends JsonMap>(data: T, parentKey?: string): T;
207
+ protected recursiveEncrypt<J extends JsonMap>(data: J, parentKey?: string): J;
208
208
  /**
209
209
  * Decrypt all values in a nested JsonMap.
210
210
  *
@@ -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
  }