@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
@@ -1,12 +1,12 @@
1
- import { JsonMap, Nullable, Optional } from '@salesforce/ts-types';
1
+ import { Dictionary, JsonMap, Nullable, Optional } from '@salesforce/ts-types';
2
2
  import { ConfigFile } from './config/configFile';
3
3
  import { ConfigContents } from './config/configStore';
4
- export declare type PackageDirDependency = {
4
+ export type PackageDirDependency = {
5
5
  [k: string]: unknown;
6
6
  package: string;
7
7
  versionNumber?: string;
8
8
  };
9
- export declare type PackageDir = {
9
+ export type PackageDir = {
10
10
  ancestorId?: string;
11
11
  ancestorVersion?: string;
12
12
  default?: boolean;
@@ -23,7 +23,7 @@ export declare type PackageDir = {
23
23
  versionName?: string;
24
24
  versionNumber?: string;
25
25
  };
26
- export declare type NamedPackageDir = PackageDir & {
26
+ export type NamedPackageDir = PackageDir & {
27
27
  /**
28
28
  * The [normalized](https://nodejs.org/api/path.html#path_path_normalize_path) path used as the package name.
29
29
  */
@@ -33,7 +33,7 @@ export declare type NamedPackageDir = PackageDir & {
33
33
  */
34
34
  fullPath: string;
35
35
  };
36
- export declare type ProjectJson = ConfigContents & {
36
+ export type ProjectJson = ConfigContents & {
37
37
  packageDirectories: PackageDir[];
38
38
  namespace?: string;
39
39
  sourceApiVersion?: string;
@@ -54,7 +54,7 @@ export declare type ProjectJson = ConfigContents & {
54
54
  * be in a top level property that represents your project or plugin.
55
55
  *
56
56
  * ```
57
- * const project = await SfdxProject.resolve();
57
+ * const project = await SfProject.resolve();
58
58
  * const projectJson = await project.resolveProjectConfig();
59
59
  * const myPluginProperties = projectJson.get('myplugin') || {};
60
60
  * myPluginProperties.myprop = 'someValue';
@@ -64,7 +64,7 @@ export declare type ProjectJson = ConfigContents & {
64
64
  *
65
65
  * **See** [force:project:create](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_create_new.htm)
66
66
  */
67
- export declare class SfdxProjectJson extends ConfigFile {
67
+ export declare class SfProjectJson extends ConfigFile {
68
68
  static BLOCKLIST: string[];
69
69
  static getFileName(): string;
70
70
  static getDefaultOptions(isGlobal?: boolean): ConfigFile.Options;
@@ -80,7 +80,7 @@ export declare class SfdxProjectJson extends ConfigFile {
80
80
  * Set the `SFDX_PROJECT_JSON_VALIDATION` environment variable to `true` to throw an error when schema validation fails.
81
81
  * A warning is logged by default when the file is invalid.
82
82
  *
83
- * ***See*** [sfdx-project.schema.json] (https://raw.githubusercontent.com/forcedotcom/schemas/master/schemas/sfdx-project.schema.json)
83
+ * ***See*** [sfdx-project.schema.json] ((https://github.com/forcedotcom/schemas/blob/main/sfdx-project.schema.json)
84
84
  */
85
85
  schemaValidate(): Promise<void>;
86
86
  /**
@@ -94,7 +94,7 @@ export declare class SfdxProjectJson extends ConfigFile {
94
94
  * Set the `SFDX_PROJECT_JSON_VALIDATION` environment variable to `true` to throw an error when schema validation fails.
95
95
  * A warning is logged by default when the file is invalid.
96
96
  *
97
- * ***See*** [sfdx-project.schema.json] (https://raw.githubusercontent.com/forcedotcom/schemas/master/schemas/sfdx-project.schema.json)
97
+ * ***See*** [sfdx-project.schema.json] ((https://github.com/forcedotcom/schemas/blob/main/sfdx-project.schema.json)
98
98
  */
99
99
  schemaValidateSync(): void;
100
100
  /**
@@ -115,7 +115,7 @@ export declare class SfdxProjectJson extends ConfigFile {
115
115
  */
116
116
  getUniquePackageDirectories(): NamedPackageDir[];
117
117
  /**
118
- * Get a list of the unique package names from within sfdx-project.json. Use {@link SfdxProject.getUniquePackageDirectories}
118
+ * Get a list of the unique package names from within sfdx-project.json. Use {@link SfProject.getUniquePackageDirectories}
119
119
  * for data other than the names.
120
120
  */
121
121
  getUniquePackageNames(): string[];
@@ -127,55 +127,80 @@ export declare class SfdxProjectJson extends ConfigFile {
127
127
  * Has multiple package directories (MPD) defined in the project.
128
128
  */
129
129
  hasMultiplePackages(): boolean;
130
+ /**
131
+ * Has at least one package alias defined in the project.
132
+ */
133
+ hasPackageAliases(): Promise<boolean>;
134
+ /**
135
+ * Get package aliases defined in the project.
136
+ */
137
+ getPackageAliases(): Nullable<Dictionary<string>>;
138
+ /**
139
+ * Add a package alias to the project.
140
+ * If the alias already exists, it will be overwritten.
141
+ *
142
+ * @param alias
143
+ * @param id
144
+ */
145
+ addPackageAlias(alias: string, id: string): void;
146
+ /**
147
+ * Add a package directory to the project.
148
+ * If the package directory already exists, the new directory
149
+ * properties will be merged with the existing properties.
150
+ *
151
+ * @param packageDir
152
+ */
153
+ addPackageDirectory(packageDir: NamedPackageDir): void;
130
154
  private doesPackageExist;
131
155
  private validateKeys;
132
156
  }
133
157
  /**
134
- * Represents an SFDX project directory. This directory contains a {@link SfdxProjectJson} config file as well as
158
+ * Represents an SFDX project directory. This directory contains a {@link SfProjectJson} config file as well as
135
159
  * a hidden .sfdx folder that contains all the other local project config files.
136
160
  *
137
161
  * ```
138
- * const project = await SfdxProject.resolve();
162
+ * const project = await SfProject.resolve();
139
163
  * const projectJson = await project.resolveProjectConfig();
140
164
  * console.log(projectJson.sfdcLoginUrl);
141
165
  * ```
142
166
  */
143
- export declare class SfdxProject {
167
+ export declare class SfProject {
144
168
  private path;
145
169
  private static instances;
146
170
  private projectConfig;
147
- private sfdxProjectJson;
148
- private sfdxProjectJsonGlobal;
171
+ private sfProjectJson;
172
+ private sfProjectJsonGlobal;
149
173
  private packageDirectories?;
150
174
  private activePackage;
175
+ private packageAliases;
151
176
  /**
152
- * Do not directly construct instances of this class -- use {@link SfdxProject.resolve} instead.
177
+ * Do not directly construct instances of this class -- use {@link SfProject.resolve} instead.
153
178
  *
154
179
  * @ignore
155
180
  */
156
- private constructor();
181
+ protected constructor(path: string);
157
182
  /**
158
183
  * Get a Project from a given path or from the working directory.
159
184
  *
160
185
  * @param path The path of the project.
161
186
  *
162
- * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
187
+ * **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
163
188
  */
164
- static resolve(path?: string): Promise<SfdxProject>;
189
+ static resolve(path?: string): Promise<SfProject>;
165
190
  /**
166
191
  * Get a Project from a given path or from the working directory.
167
192
  *
168
193
  * @param path The path of the project.
169
194
  *
170
- * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
195
+ * **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
171
196
  */
172
- static getInstance(path?: string): SfdxProject;
197
+ static getInstance(path?: string): SfProject;
173
198
  /**
174
199
  * Performs an upward directory search for an sfdx project file. Returns the absolute path to the project.
175
200
  *
176
201
  * @param dir The directory path to start traversing from.
177
202
  *
178
- * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
203
+ * **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
179
204
  *
180
205
  * **See** {@link traverseForFile}
181
206
  *
@@ -187,7 +212,7 @@ export declare class SfdxProject {
187
212
  *
188
213
  * @param dir The directory path to start traversing from.
189
214
  *
190
- * **Throws** *{@link SfdxError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
215
+ * **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
191
216
  *
192
217
  * **See** {@link traverseForFileSync}
193
218
  *
@@ -202,24 +227,24 @@ export declare class SfdxProject {
202
227
  * Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults
203
228
  * that are not checked in to the project specific file.
204
229
  *
205
- * *Note:* When reading values from {@link SfdxProjectJson}, it is recommended to use
206
- * {@link SfdxProject.resolveProjectConfig} instead.
230
+ * *Note:* When reading values from {@link SfProjectJson}, it is recommended to use
231
+ * {@link SfProject.resolveProjectConfig} instead.
207
232
  *
208
233
  * @param isGlobal True to get the global project file, otherwise the local project config.
209
234
  */
210
- retrieveSfdxProjectJson(isGlobal?: boolean): Promise<SfdxProjectJson>;
235
+ retrieveSfProjectJson(isGlobal?: boolean): Promise<SfProjectJson>;
211
236
  /**
212
237
  * Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults
213
238
  * that are not checked in to the project specific file.
214
239
  *
215
- * *Note:* When reading values from {@link SfdxProjectJson}, it is recommended to use
216
- * {@link SfdxProject.resolveProjectConfig} instead.
240
+ * *Note:* When reading values from {@link SfProjectJson}, it is recommended to use
241
+ * {@link SfProject.resolveProjectConfig} instead.
217
242
  *
218
- * This is the sync method of {@link SfdxProject.resolveSfdxProjectJson}
243
+ * This is the sync method of {@link SfProject.resolveSfProjectJson}
219
244
  *
220
245
  * @param isGlobal True to get the global project file, otherwise the local project config.
221
246
  */
222
- getSfdxProjectJson(isGlobal?: boolean): SfdxProjectJson;
247
+ getSfProjectJson(isGlobal?: boolean): SfProjectJson;
223
248
  /**
224
249
  * Returns a read-only list of `packageDirectories` within sfdx-project.json, first reading
225
250
  * and validating the file if necessary. i.e. modifying this array will not affect the
@@ -238,7 +263,7 @@ export declare class SfdxProject {
238
263
  */
239
264
  getUniquePackageDirectories(): NamedPackageDir[];
240
265
  /**
241
- * Get a list of the unique package names from within sfdx-project.json. Use {@link SfdxProject.getUniquePackageDirectories}
266
+ * Get a list of the unique package names from within sfdx-project.json. Use {@link SfProject.getUniquePackageDirectories}
242
267
  * for data other than the names.
243
268
  */
244
269
  getUniquePackageNames(): string[];
@@ -260,6 +285,12 @@ export declare class SfdxProject {
260
285
  * @param packageName Name of the package directory. E.g., 'force-app'
261
286
  */
262
287
  getPackage(packageName: string): Optional<NamedPackageDir>;
288
+ /**
289
+ * Returns the package directory.
290
+ *
291
+ * @param packageName Name of the package directory. E.g., 'force-app'
292
+ */
293
+ findPackage(predicate: (packageDir: NamedPackageDir) => boolean): Optional<NamedPackageDir>;
263
294
  /**
264
295
  * Returns the absolute path of the package directory ending with the path separator.
265
296
  * E.g., /Users/jsmith/projects/ebikes-lwc/force-app/
@@ -284,7 +315,7 @@ export declare class SfdxProject {
284
315
  * Set the currently activated package on the project. This has no implication on sfdx-project.json
285
316
  * but is useful for keeping track of package and source specific options in a process.
286
317
  *
287
- * @param pkgName The package name to activate. E.g. 'force-app'
318
+ * @param packageName The package name to activate. E.g. 'force-app'
288
319
  */
289
320
  setActivePackage(packageName: Nullable<string>): void;
290
321
  /**
@@ -293,15 +324,24 @@ export declare class SfdxProject {
293
324
  */
294
325
  getDefaultPackage(): NamedPackageDir;
295
326
  /**
296
- * The project config is resolved from local and global {@link SfdxProjectJson},
327
+ * The project config is resolved from local and global {@link SfProjectJson},
297
328
  * {@link ConfigAggregator}, and a set of defaults. It is recommended to use
298
- * this when reading values from SfdxProjectJson.
329
+ * this when reading values from SfProjectJson.
299
330
  *
300
- * The global {@link SfdxProjectJson} is used to allow the user to provide default values they
331
+ * The global {@link SfProjectJson} is used to allow the user to provide default values they
301
332
  * may not want checked into their project's source.
302
333
  *
303
334
  * @returns A resolved config object that contains a bunch of different
304
335
  * properties, including some 3rd party custom properties.
305
336
  */
306
337
  resolveProjectConfig(): Promise<JsonMap>;
338
+ hasPackageAliases(): Promise<boolean>;
339
+ /**
340
+ * Returns a read-only list of `packageDirectories` within sfdx-project.json, first reading
341
+ * and validating the file if necessary. i.e. modifying this array will not affect the
342
+ * sfdx-project.json file.
343
+ */
344
+ getPackageAliases(): Nullable<Dictionary<string>>;
345
+ getPackageIdFromAlias(alias: string): Optional<string>;
346
+ getAliasesFromPackageId(id: string): string[];
307
347
  }