@salesforce/core 3.7.6 → 3.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +4 -4
- package/lib/config/config.d.ts +5 -5
- package/lib/config/config.js +5 -5
- package/lib/config/configAggregator.d.ts +2 -2
- package/lib/config/configAggregator.js +2 -2
- package/lib/config/configFile.d.ts +2 -2
- package/lib/config/configFile.js +7 -7
- package/lib/config/configStore.js +5 -5
- package/lib/crypto/keyChainImpl.js +2 -2
- package/lib/deviceOauthService.js +2 -2
- package/lib/exported.d.ts +2 -2
- package/lib/exported.js +9 -6
- package/lib/globalInfo/accessors/aliasAccessor.js +2 -2
- package/lib/logger.d.ts +3 -3
- package/lib/logger.js +9 -9
- package/lib/messages.d.ts +2 -2
- package/lib/messages.js +4 -4
- package/lib/org/authInfo.d.ts +1 -1
- package/lib/org/authInfo.js +4 -4
- package/lib/org/authRemover.d.ts +2 -2
- package/lib/org/authRemover.js +2 -2
- package/lib/org/connection.d.ts +1 -1
- package/lib/org/connection.js +4 -4
- package/lib/org/org.d.ts +4 -4
- package/lib/org/org.js +13 -13
- package/lib/org/permissionSetAssignment.js +2 -2
- package/lib/org/scratchOrgCreate.js +4 -4
- package/lib/org/scratchOrgErrorCodes.js +6 -6
- package/lib/org/scratchOrgInfoApi.js +16 -16
- package/lib/org/scratchOrgInfoGenerator.d.ts +3 -3
- package/lib/org/scratchOrgInfoGenerator.js +17 -17
- package/lib/org/scratchOrgSettingsGenerator.js +2 -2
- package/lib/org/user.js +4 -4
- package/lib/schema/printer.js +2 -2
- package/lib/schema/validator.d.ts +4 -4
- package/lib/schema/validator.js +9 -9
- package/lib/{sfdxError.d.ts → sfError.d.ts} +14 -9
- package/lib/{sfdxError.js → sfError.js} +20 -14
- package/lib/{sfdxProject.d.ts → sfProject.d.ts} +37 -27
- package/lib/{sfdxProject.js → sfProject.js} +75 -63
- package/lib/status/pollingClient.js +3 -3
- package/lib/status/streamingClient.d.ts +2 -2
- package/lib/status/streamingClient.js +6 -6
- package/lib/testSetup.d.ts +4 -4
- package/lib/testSetup.js +8 -8
- package/lib/util/fs.js +7 -7
- package/lib/util/internal.d.ts +2 -2
- package/lib/util/internal.js +2 -2
- package/lib/util/sfdcUrl.d.ts +2 -2
- package/lib/util/sfdcUrl.js +2 -2
- package/lib/webOAuthServer.js +10 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [3.7.7](https://github.com/forcedotcom/sfdx-core/compare/v3.7.6...v3.7.7) (2022-03-01)
|
|
6
|
+
|
|
5
7
|
### [3.7.6](https://github.com/forcedotcom/sfdx-core/compare/v4.0.0...v3.7.6) (2022-02-28)
|
|
6
8
|
|
|
7
9
|
## [4.0.0](https://github.com/forcedotcom/sfdx-core/compare/v2.35.2...v4.0.0) (2022-02-28)
|
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ describe('Mocking Auth data', () => {
|
|
|
52
52
|
After having a valid AuthInfo object you can then create fake connections to a Salesforce.com scratch org. This allows for writing tests that can validate result responses for SOQL queries and REST endpoints.
|
|
53
53
|
|
|
54
54
|
```typescript
|
|
55
|
-
import { AuthInfo, Connection,
|
|
55
|
+
import { AuthInfo, Connection, SfError } from '@salesforce/core';
|
|
56
56
|
import { MockTestOrgData, testSetup } from '@salesforce/core/lib/testSetup';
|
|
57
57
|
import { AnyJson, ensureJsonMap, JsonMap } from '@salesforce/ts-types';
|
|
58
58
|
import { ensureString } from '@salesforce/ts-types';
|
|
@@ -77,7 +77,7 @@ describe('Mocking a force server call', () => {
|
|
|
77
77
|
if (request && ensureString(_request.url).includes('Account')) {
|
|
78
78
|
return Promise.resolve(records);
|
|
79
79
|
} else {
|
|
80
|
-
return Promise.reject(new
|
|
80
|
+
return Promise.reject(new SfError(`Unexpected request: ${_request.url}`));
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
const connection: Connection = await Connection.create({
|
|
@@ -117,13 +117,13 @@ describe('Using the built in Sinon sandbox.', () => {
|
|
|
117
117
|
It's important to have negative tests that ensure proper error handling. With `shouldThrow` it's easy to test for expected async rejections.
|
|
118
118
|
|
|
119
119
|
```typescript
|
|
120
|
-
import {
|
|
120
|
+
import { SfError } from '@salesforce/core';
|
|
121
121
|
import { shouldThrow } from '@salesforce/core/lib/testSetup';
|
|
122
122
|
import { strictEqual } from 'assert';
|
|
123
123
|
|
|
124
124
|
class TestObject {
|
|
125
125
|
public static async method() {
|
|
126
|
-
throw new
|
|
126
|
+
throw new SfError('Error', 'ExpectedError');
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
package/lib/config/config.d.ts
CHANGED
|
@@ -202,7 +202,7 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
202
202
|
* DO NOT CALL - The config file needs to encrypt values which can only be done asynchronously.
|
|
203
203
|
* Call {@link SfdxConfig.write} instead.
|
|
204
204
|
*
|
|
205
|
-
* **Throws** *{@link
|
|
205
|
+
* **Throws** *{@link SfError}{ name: 'InvalidWriteError' }* Always.
|
|
206
206
|
*
|
|
207
207
|
* @param newContents Contents to write
|
|
208
208
|
*/
|
|
@@ -210,8 +210,8 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
210
210
|
/**
|
|
211
211
|
* Sets a value for a property.
|
|
212
212
|
*
|
|
213
|
-
* **Throws** *{@link
|
|
214
|
-
* **Throws** *{@link
|
|
213
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
|
|
214
|
+
* **Throws** *{@link SfError}{ name: 'InvalidConfigValueError' }* If the input validator fails.
|
|
215
215
|
*
|
|
216
216
|
* @param key The property to set.
|
|
217
217
|
* @param value The value of the property.
|
|
@@ -220,7 +220,7 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
220
220
|
/**
|
|
221
221
|
* Unsets a value for a property.
|
|
222
222
|
*
|
|
223
|
-
* **Throws** *{@link
|
|
223
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* If the input validator fails.
|
|
224
224
|
*
|
|
225
225
|
* @param key The property to unset.
|
|
226
226
|
*/
|
|
@@ -228,7 +228,7 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
228
228
|
/**
|
|
229
229
|
* Get an individual property config.
|
|
230
230
|
*
|
|
231
|
-
* **Throws** *{@link
|
|
231
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
|
|
232
232
|
*
|
|
233
233
|
* @param propertyName The name of the property.
|
|
234
234
|
*/
|
package/lib/config/config.js
CHANGED
|
@@ -308,7 +308,7 @@ class Config extends configFile_1.ConfigFile {
|
|
|
308
308
|
* DO NOT CALL - The config file needs to encrypt values which can only be done asynchronously.
|
|
309
309
|
* Call {@link SfdxConfig.write} instead.
|
|
310
310
|
*
|
|
311
|
-
* **Throws** *{@link
|
|
311
|
+
* **Throws** *{@link SfError}{ name: 'InvalidWriteError' }* Always.
|
|
312
312
|
*
|
|
313
313
|
* @param newContents Contents to write
|
|
314
314
|
*/
|
|
@@ -319,8 +319,8 @@ class Config extends configFile_1.ConfigFile {
|
|
|
319
319
|
/**
|
|
320
320
|
* Sets a value for a property.
|
|
321
321
|
*
|
|
322
|
-
* **Throws** *{@link
|
|
323
|
-
* **Throws** *{@link
|
|
322
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
|
|
323
|
+
* **Throws** *{@link SfError}{ name: 'InvalidConfigValueError' }* If the input validator fails.
|
|
324
324
|
*
|
|
325
325
|
* @param key The property to set.
|
|
326
326
|
* @param value The value of the property.
|
|
@@ -355,7 +355,7 @@ class Config extends configFile_1.ConfigFile {
|
|
|
355
355
|
/**
|
|
356
356
|
* Unsets a value for a property.
|
|
357
357
|
*
|
|
358
|
-
* **Throws** *{@link
|
|
358
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* If the input validator fails.
|
|
359
359
|
*
|
|
360
360
|
* @param key The property to unset.
|
|
361
361
|
*/
|
|
@@ -372,7 +372,7 @@ class Config extends configFile_1.ConfigFile {
|
|
|
372
372
|
/**
|
|
373
373
|
* Get an individual property config.
|
|
374
374
|
*
|
|
375
|
-
* **Throws** *{@link
|
|
375
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
|
|
376
376
|
*
|
|
377
377
|
* @param propertyName The name of the property.
|
|
378
378
|
*/
|
|
@@ -88,7 +88,7 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
|
|
|
88
88
|
/**
|
|
89
89
|
* Get a resolved config property.
|
|
90
90
|
*
|
|
91
|
-
* **Throws** *{@link
|
|
91
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
|
|
92
92
|
*
|
|
93
93
|
* @param key The key of the property.
|
|
94
94
|
*/
|
|
@@ -96,7 +96,7 @@ export declare class ConfigAggregator extends AsyncOptionalCreatable<JsonMap> {
|
|
|
96
96
|
/**
|
|
97
97
|
* Get a resolved config property meta.
|
|
98
98
|
*
|
|
99
|
-
* **Throws** *{@link
|
|
99
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
|
|
100
100
|
*
|
|
101
101
|
* @param key The key of the property.
|
|
102
102
|
*/
|
|
@@ -100,7 +100,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
100
100
|
/**
|
|
101
101
|
* Get a resolved config property.
|
|
102
102
|
*
|
|
103
|
-
* **Throws** *{@link
|
|
103
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
|
|
104
104
|
*
|
|
105
105
|
* @param key The key of the property.
|
|
106
106
|
*/
|
|
@@ -115,7 +115,7 @@ class ConfigAggregator extends kit_1.AsyncOptionalCreatable {
|
|
|
115
115
|
/**
|
|
116
116
|
* Get a resolved config property meta.
|
|
117
117
|
*
|
|
118
|
-
* **Throws** *{@link
|
|
118
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
|
|
119
119
|
*
|
|
120
120
|
* @param key The key of the property.
|
|
121
121
|
*/
|
|
@@ -78,7 +78,7 @@ export declare class ConfigFile<T extends ConfigFile.Options = ConfigFile.Option
|
|
|
78
78
|
* Read the config file and set the config contents. Returns the config contents of the config file. As an
|
|
79
79
|
* optimization, files are only read once per process and updated in memory and via `write()`. To force
|
|
80
80
|
* a read from the filesystem pass `force=true`.
|
|
81
|
-
* **Throws** *{@link
|
|
81
|
+
* **Throws** *{@link SfError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
|
|
82
82
|
*
|
|
83
83
|
* @param [throwOnNotFound = false] Optionally indicate if a throw should occur on file read.
|
|
84
84
|
* @param [force = false] Optionally force the file to be read from disk even when already read within the process.
|
|
@@ -88,7 +88,7 @@ export declare class ConfigFile<T extends ConfigFile.Options = ConfigFile.Option
|
|
|
88
88
|
* Read the config file and set the config contents. Returns the config contents of the config file. As an
|
|
89
89
|
* optimization, files are only read once per process and updated in memory and via `write()`. To force
|
|
90
90
|
* a read from the filesystem pass `force=true`.
|
|
91
|
-
* **Throws** *{@link
|
|
91
|
+
* **Throws** *{@link SfError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
|
|
92
92
|
*
|
|
93
93
|
* @param [throwOnNotFound = false] Optionally indicate if a throw should occur on file read.
|
|
94
94
|
* @param [force = false] Optionally force the file to be read from disk even when already read within the process.
|
package/lib/config/configFile.js
CHANGED
|
@@ -13,7 +13,7 @@ const path_1 = require("path");
|
|
|
13
13
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
14
14
|
const global_1 = require("../global");
|
|
15
15
|
const logger_1 = require("../logger");
|
|
16
|
-
const
|
|
16
|
+
const sfError_1 = require("../sfError");
|
|
17
17
|
const fs_2 = require("../util/fs");
|
|
18
18
|
const internal_1 = require("../util/internal");
|
|
19
19
|
const configStore_1 = require("./configStore");
|
|
@@ -65,7 +65,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
65
65
|
*/
|
|
66
66
|
static getFileName() {
|
|
67
67
|
// Can not have abstract static methods, so throw a runtime error.
|
|
68
|
-
throw new
|
|
68
|
+
throw new sfError_1.SfError('Unknown filename for config file.');
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Returns the default options for the config file.
|
|
@@ -135,7 +135,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
135
135
|
* Read the config file and set the config contents. Returns the config contents of the config file. As an
|
|
136
136
|
* optimization, files are only read once per process and updated in memory and via `write()`. To force
|
|
137
137
|
* a read from the filesystem pass `force=true`.
|
|
138
|
-
* **Throws** *{@link
|
|
138
|
+
* **Throws** *{@link SfError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
|
|
139
139
|
*
|
|
140
140
|
* @param [throwOnNotFound = false] Optionally indicate if a throw should occur on file read.
|
|
141
141
|
* @param [force = false] Optionally force the file to be read from disk even when already read within the process.
|
|
@@ -170,7 +170,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
170
170
|
* Read the config file and set the config contents. Returns the config contents of the config file. As an
|
|
171
171
|
* optimization, files are only read once per process and updated in memory and via `write()`. To force
|
|
172
172
|
* a read from the filesystem pass `force=true`.
|
|
173
|
-
* **Throws** *{@link
|
|
173
|
+
* **Throws** *{@link SfError}{ name: 'UnexpectedJsonFileFormat' }* There was a problem reading or parsing the file.
|
|
174
174
|
*
|
|
175
175
|
* @param [throwOnNotFound = false] Optionally indicate if a throw should occur on file read.
|
|
176
176
|
* @param [force = false] Optionally force the file to be read from disk even when already read within the process.
|
|
@@ -270,7 +270,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
270
270
|
if (exists) {
|
|
271
271
|
return await fs_2.fs.unlink(this.getPath());
|
|
272
272
|
}
|
|
273
|
-
throw new
|
|
273
|
+
throw new sfError_1.SfError(`Target file doesn't exist. path: ${this.getPath()}`, 'TargetFileNotFound');
|
|
274
274
|
}
|
|
275
275
|
/**
|
|
276
276
|
* Delete the config file if it exists.
|
|
@@ -283,7 +283,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
283
283
|
if (exists) {
|
|
284
284
|
return fs_2.fs.unlinkSync(this.getPath());
|
|
285
285
|
}
|
|
286
|
-
throw new
|
|
286
|
+
throw new sfError_1.SfError(`Target file doesn't exist. path: ${this.getPath()}`, 'TargetFileNotFound');
|
|
287
287
|
}
|
|
288
288
|
/**
|
|
289
289
|
* Returns the absolute path to the config file.
|
|
@@ -295,7 +295,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
295
295
|
getPath() {
|
|
296
296
|
if (!this.path) {
|
|
297
297
|
if (!this.options.filename) {
|
|
298
|
-
throw new
|
|
298
|
+
throw new sfError_1.SfError('The ConfigOptions filename parameter is invalid.', 'InvalidParameter');
|
|
299
299
|
}
|
|
300
300
|
const _isGlobal = (0, ts_types_1.isBoolean)(this.options.isGlobal) && this.options.isGlobal;
|
|
301
301
|
const _isState = (0, ts_types_1.isBoolean)(this.options.isState) && this.options.isState;
|
|
@@ -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
|
|
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.
|
|
@@ -287,18 +287,18 @@ class BaseConfigStore extends kit_1.AsyncOptionalCreatable {
|
|
|
287
287
|
if (!value)
|
|
288
288
|
return;
|
|
289
289
|
if (!this.crypto)
|
|
290
|
-
throw new
|
|
290
|
+
throw new sfError_1.SfError('crypto is not initialized', 'CryptoNotInitializedError');
|
|
291
291
|
if (!(0, ts_types_2.isString)(value))
|
|
292
|
-
throw new
|
|
292
|
+
throw new sfError_1.SfError(`can only encrypt strings but found: ${typeof value} : ${value}`, 'InvalidCryptoValueError');
|
|
293
293
|
return this.crypto.isEncrypted(value) ? value : this.crypto.encrypt(value);
|
|
294
294
|
}
|
|
295
295
|
decrypt(value) {
|
|
296
296
|
if (!value)
|
|
297
297
|
return;
|
|
298
298
|
if (!this.crypto)
|
|
299
|
-
throw new
|
|
299
|
+
throw new sfError_1.SfError('crypto is not initialized', 'CryptoNotInitializedError');
|
|
300
300
|
if (!(0, ts_types_2.isString)(value))
|
|
301
|
-
throw new
|
|
301
|
+
throw new sfError_1.SfError(`can only encrypt strings but found: ${typeof value} : ${value}`, 'InvalidCryptoValueError');
|
|
302
302
|
return this.crypto.isEncrypted(value) ? this.crypto.decrypt(value) : value;
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
@@ -58,9 +58,9 @@ const _isExe = (mode, gid, uid) => {
|
|
|
58
58
|
/**
|
|
59
59
|
* Private helper to validate that a program exists on the file system and is executable.
|
|
60
60
|
*
|
|
61
|
-
* **Throws** *{@link
|
|
61
|
+
* **Throws** *{@link SfError}{ name: 'MissingCredentialProgramError' }* When the OS credential program isn't found.
|
|
62
62
|
*
|
|
63
|
-
* **Throws** *{@link
|
|
63
|
+
* **Throws** *{@link SfError}{ name: 'CredentialProgramAccessError' }* When the OS credential program isn't accessible.
|
|
64
64
|
*
|
|
65
65
|
* @param programPath The absolute path of the program.
|
|
66
66
|
* @param fsIfc The file system interface.
|
|
@@ -15,7 +15,7 @@ const kit_1 = require("@salesforce/kit");
|
|
|
15
15
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
16
16
|
const logger_1 = require("./logger");
|
|
17
17
|
const authInfo_1 = require("./org/authInfo");
|
|
18
|
-
const
|
|
18
|
+
const sfError_1 = require("./sfError");
|
|
19
19
|
const connection_1 = require("./org/connection");
|
|
20
20
|
const messages_1 = require("./messages");
|
|
21
21
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
@@ -29,7 +29,7 @@ async function makeRequest(options) {
|
|
|
29
29
|
const rawResponse = await new transport_1.default().httpRequest(options);
|
|
30
30
|
const response = (0, kit_1.parseJsonMap)(rawResponse.body);
|
|
31
31
|
if (response.error) {
|
|
32
|
-
const err = new
|
|
32
|
+
const err = new sfError_1.SfError('Request Failed.');
|
|
33
33
|
err.data = Object.assign(response, { status: rawResponse.statusCode });
|
|
34
34
|
throw err;
|
|
35
35
|
}
|
package/lib/exported.d.ts
CHANGED
|
@@ -19,10 +19,10 @@ export { Fields, FieldValue, LoggerLevel, LoggerLevelValue, LogLine, LoggerOptio
|
|
|
19
19
|
export { Messages } from './messages';
|
|
20
20
|
export { Org, SandboxProcessObject, StatusEvent, SandboxEvents, SandboxUserAuthResponse, SandboxUserAuthRequest, SandboxRequest, OrgTypes, ResultEvent, ScratchOrgRequest, } from './org';
|
|
21
21
|
export { OrgConfigProperties, ORG_CONFIG_ALLOWED_PROPERTIES } from './org/orgConfigProperties';
|
|
22
|
-
export { PackageDir, NamedPackageDir, PackageDirDependency, SfdxProject, SfdxProjectJson } from './
|
|
22
|
+
export { PackageDir, NamedPackageDir, PackageDirDependency, SfProject, SfProjectJson, SfdxProject, SfdxProjectJson, } from './sfProject';
|
|
23
23
|
export { SchemaPrinter } from './schema/printer';
|
|
24
24
|
export { SchemaValidator } from './schema/validator';
|
|
25
|
-
export { SfdxError } from './
|
|
25
|
+
export { SfError, SfdxError } from './sfError';
|
|
26
26
|
export { PollingClient } from './status/pollingClient';
|
|
27
27
|
export { CometClient, CometSubscription, StreamingClient, StatusResult } from './status/streamingClient';
|
|
28
28
|
export { MyDomainResolver } from './status/myDomainResolver';
|
package/lib/exported.js
CHANGED
|
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.scratchOrgCreate = exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.ConfigAggregator = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.SfInfoKeys = exports.GlobalInfo = exports.BaseConfigStore = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.envVars = exports.ConfigFile = void 0;
|
|
19
|
+
exports.scratchOrgCreate = exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfdxError = exports.SfError = exports.SchemaValidator = exports.SchemaPrinter = exports.SfdxProjectJson = exports.SfdxProject = exports.SfProjectJson = exports.SfProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.ConfigAggregator = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.SfInfoKeys = exports.GlobalInfo = exports.BaseConfigStore = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.envVars = exports.ConfigFile = void 0;
|
|
20
20
|
const messages_1 = require("./messages");
|
|
21
21
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
22
22
|
var configFile_1 = require("./config/configFile");
|
|
@@ -71,15 +71,18 @@ Object.defineProperty(exports, "OrgTypes", { enumerable: true, get: function ()
|
|
|
71
71
|
var orgConfigProperties_1 = require("./org/orgConfigProperties");
|
|
72
72
|
Object.defineProperty(exports, "OrgConfigProperties", { enumerable: true, get: function () { return orgConfigProperties_1.OrgConfigProperties; } });
|
|
73
73
|
Object.defineProperty(exports, "ORG_CONFIG_ALLOWED_PROPERTIES", { enumerable: true, get: function () { return orgConfigProperties_1.ORG_CONFIG_ALLOWED_PROPERTIES; } });
|
|
74
|
-
var
|
|
75
|
-
Object.defineProperty(exports, "
|
|
76
|
-
Object.defineProperty(exports, "
|
|
74
|
+
var sfProject_1 = require("./sfProject");
|
|
75
|
+
Object.defineProperty(exports, "SfProject", { enumerable: true, get: function () { return sfProject_1.SfProject; } });
|
|
76
|
+
Object.defineProperty(exports, "SfProjectJson", { enumerable: true, get: function () { return sfProject_1.SfProjectJson; } });
|
|
77
|
+
Object.defineProperty(exports, "SfdxProject", { enumerable: true, get: function () { return sfProject_1.SfdxProject; } });
|
|
78
|
+
Object.defineProperty(exports, "SfdxProjectJson", { enumerable: true, get: function () { return sfProject_1.SfdxProjectJson; } });
|
|
77
79
|
var printer_1 = require("./schema/printer");
|
|
78
80
|
Object.defineProperty(exports, "SchemaPrinter", { enumerable: true, get: function () { return printer_1.SchemaPrinter; } });
|
|
79
81
|
var validator_1 = require("./schema/validator");
|
|
80
82
|
Object.defineProperty(exports, "SchemaValidator", { enumerable: true, get: function () { return validator_1.SchemaValidator; } });
|
|
81
|
-
var
|
|
82
|
-
Object.defineProperty(exports, "
|
|
83
|
+
var sfError_1 = require("./sfError");
|
|
84
|
+
Object.defineProperty(exports, "SfError", { enumerable: true, get: function () { return sfError_1.SfError; } });
|
|
85
|
+
Object.defineProperty(exports, "SfdxError", { enumerable: true, get: function () { return sfError_1.SfdxError; } });
|
|
83
86
|
var pollingClient_1 = require("./status/pollingClient");
|
|
84
87
|
Object.defineProperty(exports, "PollingClient", { enumerable: true, get: function () { return pollingClient_1.PollingClient; } });
|
|
85
88
|
var streamingClient_1 = require("./status/streamingClient");
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.AliasAccessor = void 0;
|
|
10
|
-
const
|
|
10
|
+
const sfError_1 = require("../../sfError");
|
|
11
11
|
const types_1 = require("../types");
|
|
12
12
|
class AliasAccessor {
|
|
13
13
|
constructor(globalInfo) {
|
|
@@ -121,7 +121,7 @@ class AliasAccessor {
|
|
|
121
121
|
return entity;
|
|
122
122
|
const aliaseeName = (_a = entity.username) !== null && _a !== void 0 ? _a : entity.user;
|
|
123
123
|
if (!aliaseeName) {
|
|
124
|
-
throw new
|
|
124
|
+
throw new sfError_1.SfError(`Invalid aliasee, it must contain a user or username property: ${JSON.stringify(entity)}`);
|
|
125
125
|
}
|
|
126
126
|
return aliaseeName;
|
|
127
127
|
}
|
package/lib/logger.d.ts
CHANGED
|
@@ -174,7 +174,7 @@ export declare class Logger {
|
|
|
174
174
|
*
|
|
175
175
|
* @param optionsOrName A set of `LoggerOptions` or name to use with the default options.
|
|
176
176
|
*
|
|
177
|
-
* **Throws** *{@link
|
|
177
|
+
* **Throws** *{@link SfError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
|
|
178
178
|
* `Logger`.
|
|
179
179
|
*/
|
|
180
180
|
constructor(optionsOrName: LoggerOptions | string);
|
|
@@ -211,7 +211,7 @@ export declare class Logger {
|
|
|
211
211
|
*
|
|
212
212
|
* @param {string} levelName The level name to convert to a `LoggerLevel` enum value.
|
|
213
213
|
*
|
|
214
|
-
* **Throws** *{@link
|
|
214
|
+
* **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
|
|
215
215
|
* @see {@Link LoggerLevel}
|
|
216
216
|
*/
|
|
217
217
|
static getLevelByName(levelName: string): LoggerLevelValue;
|
|
@@ -249,7 +249,7 @@ export declare class Logger {
|
|
|
249
249
|
*
|
|
250
250
|
* @param {LoggerLevelValue} [level] The logger level.
|
|
251
251
|
*
|
|
252
|
-
* **Throws** *{@link
|
|
252
|
+
* **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
|
|
253
253
|
* was invalid.
|
|
254
254
|
*
|
|
255
255
|
* ```
|
package/lib/logger.js
CHANGED
|
@@ -17,7 +17,7 @@ const kit_1 = require("@salesforce/kit");
|
|
|
17
17
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
18
18
|
const Debug = require("debug");
|
|
19
19
|
const global_1 = require("./global");
|
|
20
|
-
const
|
|
20
|
+
const sfError_1 = require("./sfError");
|
|
21
21
|
const fs_1 = require("./util/fs");
|
|
22
22
|
/**
|
|
23
23
|
* Standard `Logger` levels.
|
|
@@ -68,7 +68,7 @@ class Logger {
|
|
|
68
68
|
*
|
|
69
69
|
* @param optionsOrName A set of `LoggerOptions` or name to use with the default options.
|
|
70
70
|
*
|
|
71
|
-
* **Throws** *{@link
|
|
71
|
+
* **Throws** *{@link SfError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
|
|
72
72
|
* `Logger`.
|
|
73
73
|
*/
|
|
74
74
|
constructor(optionsOrName) {
|
|
@@ -102,7 +102,7 @@ class Logger {
|
|
|
102
102
|
options = optionsOrName;
|
|
103
103
|
}
|
|
104
104
|
if (Logger.rootLogger && options.name === Logger.ROOT_NAME) {
|
|
105
|
-
throw new
|
|
105
|
+
throw new sfError_1.SfError('Can not create another root logger.', 'RedundantRootLoggerError');
|
|
106
106
|
}
|
|
107
107
|
// Inspect format to know what logging format to use then delete from options to
|
|
108
108
|
// ensure it doesn't conflict with Bunyan.
|
|
@@ -198,13 +198,13 @@ class Logger {
|
|
|
198
198
|
*
|
|
199
199
|
* @param {string} levelName The level name to convert to a `LoggerLevel` enum value.
|
|
200
200
|
*
|
|
201
|
-
* **Throws** *{@link
|
|
201
|
+
* **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
|
|
202
202
|
* @see {@Link LoggerLevel}
|
|
203
203
|
*/
|
|
204
204
|
static getLevelByName(levelName) {
|
|
205
205
|
levelName = levelName.toUpperCase();
|
|
206
206
|
if (!(0, ts_types_1.isKeyOf)(LoggerLevel, levelName)) {
|
|
207
|
-
throw new
|
|
207
|
+
throw new sfError_1.SfError(`Invalid log level "${levelName}".`, 'UnrecognizedLoggerLevelNameError');
|
|
208
208
|
}
|
|
209
209
|
return LoggerLevel[levelName];
|
|
210
210
|
}
|
|
@@ -243,7 +243,7 @@ class Logger {
|
|
|
243
243
|
await fs_1.fs.writeFile(logFile, '', { mode: fs_1.fs.DEFAULT_USER_FILE_MODE });
|
|
244
244
|
}
|
|
245
245
|
catch (err3) {
|
|
246
|
-
throw
|
|
246
|
+
throw sfError_1.SfError.wrap(err3);
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
// avoid multiple streams to same log file
|
|
@@ -283,7 +283,7 @@ class Logger {
|
|
|
283
283
|
fs_1.fs.writeFileSync(logFile, '', { mode: fs_1.fs.DEFAULT_USER_FILE_MODE });
|
|
284
284
|
}
|
|
285
285
|
catch (err3) {
|
|
286
|
-
throw
|
|
286
|
+
throw sfError_1.SfError.wrap(err3);
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
// avoid multiple streams to same log file
|
|
@@ -319,7 +319,7 @@ class Logger {
|
|
|
319
319
|
*
|
|
320
320
|
* @param {LoggerLevelValue} [level] The logger level.
|
|
321
321
|
*
|
|
322
|
-
* **Throws** *{@link
|
|
322
|
+
* **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
|
|
323
323
|
* was invalid.
|
|
324
324
|
*
|
|
325
325
|
* ```
|
|
@@ -452,7 +452,7 @@ class Logger {
|
|
|
452
452
|
*/
|
|
453
453
|
child(name, fields = {}) {
|
|
454
454
|
if (!name) {
|
|
455
|
-
throw new
|
|
455
|
+
throw new sfError_1.SfError('LoggerNameRequired');
|
|
456
456
|
}
|
|
457
457
|
fields.log = name;
|
|
458
458
|
const child = new Logger(name);
|
package/lib/messages.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyJson } from '@salesforce/ts-types';
|
|
2
|
-
import {
|
|
2
|
+
import { SfError } from './sfError';
|
|
3
3
|
export declare type Tokens = Array<string | boolean | number | null | undefined>;
|
|
4
4
|
/**
|
|
5
5
|
* A loader function to return messages.
|
|
@@ -247,6 +247,6 @@ export declare class Messages<T extends string> {
|
|
|
247
247
|
* @param exitCodeOrCause The exit code which will be used by SfdxCommand or he underlying error that caused this error to be raised.
|
|
248
248
|
* @param cause The underlying error that caused this error to be raised.
|
|
249
249
|
*/
|
|
250
|
-
createError(key: T, tokens?: Tokens, actionTokens?: Tokens, exitCodeOrCause?: number | Error, cause?: Error):
|
|
250
|
+
createError(key: T, tokens?: Tokens, actionTokens?: Tokens, exitCodeOrCause?: number | Error, cause?: Error): SfError;
|
|
251
251
|
private getMessageWithMap;
|
|
252
252
|
}
|
package/lib/messages.js
CHANGED
|
@@ -13,7 +13,7 @@ const path = require("path");
|
|
|
13
13
|
const util = require("util");
|
|
14
14
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
15
15
|
const kit_1 = require("@salesforce/kit");
|
|
16
|
-
const
|
|
16
|
+
const sfError_1 = require("./sfError");
|
|
17
17
|
class Key {
|
|
18
18
|
constructor(packageName, bundleName) {
|
|
19
19
|
this.packageName = packageName;
|
|
@@ -57,7 +57,7 @@ const markdownLoader = (filePath, fileContents) => {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
|
-
// use error instead of
|
|
60
|
+
// use error instead of SfError because messages.js should have no internal dependencies.
|
|
61
61
|
throw new Error(`Invalid markdown message file: ${filePath}\nThe line "# <key>" must be immediately followed by the message on a new line.`);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -217,7 +217,7 @@ class Messages {
|
|
|
217
217
|
if (!fileContents || fileContents.trim().length === 0) {
|
|
218
218
|
// messages.js should have no internal dependencies.
|
|
219
219
|
const error = new Error(`Invalid message file: ${filePath}. No content.`);
|
|
220
|
-
error.name = '
|
|
220
|
+
error.name = 'SfError';
|
|
221
221
|
throw error;
|
|
222
222
|
}
|
|
223
223
|
const map = parser(filePath, fileContents);
|
|
@@ -456,7 +456,7 @@ class Messages {
|
|
|
456
456
|
catch (e) {
|
|
457
457
|
/* just ignore if actions aren't found */
|
|
458
458
|
}
|
|
459
|
-
return new
|
|
459
|
+
return new sfError_1.SfError(errMessage, errName, errActions, exitCodeOrCause, cause);
|
|
460
460
|
}
|
|
461
461
|
getMessageWithMap(key, tokens = [], map) {
|
|
462
462
|
// Allow nested keys for better grouping
|
package/lib/org/authInfo.d.ts
CHANGED
|
@@ -253,7 +253,7 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
|
|
|
253
253
|
*
|
|
254
254
|
* @param options Options to be used for creating an OAuth2 instance.
|
|
255
255
|
*
|
|
256
|
-
* **Throws** *{@link
|
|
256
|
+
* **Throws** *{@link SfError}{ name: 'NamedOrgNotFoundError' }* Org information does not exist.
|
|
257
257
|
* @returns {Promise<AuthInfo>}
|
|
258
258
|
*/
|
|
259
259
|
private initAuthOptions;
|
package/lib/org/authInfo.js
CHANGED
|
@@ -18,7 +18,7 @@ const jwt = require("jsonwebtoken");
|
|
|
18
18
|
const config_1 = require("../config/config");
|
|
19
19
|
const configAggregator_1 = require("../config/configAggregator");
|
|
20
20
|
const logger_1 = require("../logger");
|
|
21
|
-
const
|
|
21
|
+
const sfError_1 = require("../sfError");
|
|
22
22
|
const fs_1 = require("../util/fs");
|
|
23
23
|
const sfdc_1 = require("../util/sfdc");
|
|
24
24
|
const globalInfo_1 = require("../globalInfo");
|
|
@@ -236,7 +236,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
236
236
|
static parseSfdxAuthUrl(sfdxAuthUrl) {
|
|
237
237
|
const match = sfdxAuthUrl.match(/^force:\/\/([a-zA-Z0-9._-]+):([a-zA-Z0-9._-]*):([a-zA-Z0-9._-]+={0,2})@([a-zA-Z0-9._-]+)/);
|
|
238
238
|
if (!match) {
|
|
239
|
-
throw new
|
|
239
|
+
throw new sfError_1.SfError('Invalid SFDX auth URL. Must be in the format "force://<clientId>:<clientSecret>:<refreshToken>@<instanceUrl>". Note that the SFDX auth URL uses the "force" protocol, and not "http" or "https". Also note that the "instanceUrl" inside the SFDX auth URL doesn\'t include the protocol ("https://").', 'INVALID_SFDX_AUTH_URL');
|
|
240
240
|
}
|
|
241
241
|
const [, clientId, clientSecret, refreshToken, loginUrl] = match;
|
|
242
242
|
return {
|
|
@@ -489,7 +489,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
489
489
|
*
|
|
490
490
|
* @param options Options to be used for creating an OAuth2 instance.
|
|
491
491
|
*
|
|
492
|
-
* **Throws** *{@link
|
|
492
|
+
* **Throws** *{@link SfError}{ name: 'NamedOrgNotFoundError' }* Org information does not exist.
|
|
493
493
|
* @returns {Promise<AuthInfo>}
|
|
494
494
|
*/
|
|
495
495
|
async initAuthOptions(options) {
|
|
@@ -768,7 +768,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
768
768
|
catch (err) {
|
|
769
769
|
errorMsg = `${bodyAsString}`;
|
|
770
770
|
}
|
|
771
|
-
throw new
|
|
771
|
+
throw new sfError_1.SfError(errorMsg);
|
|
772
772
|
}
|
|
773
773
|
}
|
|
774
774
|
exports.AuthInfo = AuthInfo;
|
package/lib/org/authRemover.d.ts
CHANGED
|
@@ -39,8 +39,8 @@ export declare class AuthRemover extends AsyncOptionalCreatable {
|
|
|
39
39
|
removeAllAuths(): Promise<void>;
|
|
40
40
|
/**
|
|
41
41
|
* Finds authorization files for username/alias in the global .sfdx folder
|
|
42
|
-
* **Throws** *{@link
|
|
43
|
-
* **Throws** *{@link
|
|
42
|
+
* **Throws** *{@link SfError}{ name: 'TargetOrgNotSetError' }* if no target-org
|
|
43
|
+
* **Throws** *{@link SfError}{ name: 'NamedOrgNotFoundError' }* if specified user is not found
|
|
44
44
|
*
|
|
45
45
|
* @param usernameOrAlias username or alias of the auth you want to find, defaults to the configured target-org
|
|
46
46
|
* @returns {Promise<SfOrg>}
|
package/lib/org/authRemover.js
CHANGED
|
@@ -66,8 +66,8 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
|
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Finds authorization files for username/alias in the global .sfdx folder
|
|
69
|
-
* **Throws** *{@link
|
|
70
|
-
* **Throws** *{@link
|
|
69
|
+
* **Throws** *{@link SfError}{ name: 'TargetOrgNotSetError' }* if no target-org
|
|
70
|
+
* **Throws** *{@link SfError}{ name: 'NamedOrgNotFoundError' }* if specified user is not found
|
|
71
71
|
*
|
|
72
72
|
* @param usernameOrAlias username or alias of the auth you want to find, defaults to the configured target-org
|
|
73
73
|
* @returns {Promise<SfOrg>}
|
package/lib/org/connection.d.ts
CHANGED
|
@@ -123,7 +123,7 @@ export declare class Connection<S extends Schema = Schema> extends JSForceConnec
|
|
|
123
123
|
/**
|
|
124
124
|
* Set the API version for all connection requests.
|
|
125
125
|
*
|
|
126
|
-
* **Throws** *{@link
|
|
126
|
+
* **Throws** *{@link SfError}{ name: 'IncorrectAPIVersionError' }* Incorrect API version.
|
|
127
127
|
*
|
|
128
128
|
* @param version The API version.
|
|
129
129
|
*/
|