@salesforce/core 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +1 -1
- package/README.md +93 -44
- package/lib/config/authInfoConfig.d.ts +19 -0
- package/lib/config/authInfoConfig.js +35 -0
- package/lib/config/config.d.ts +87 -22
- package/lib/config/config.js +117 -65
- package/lib/config/configAggregator.d.ts +41 -35
- package/lib/config/configAggregator.js +102 -73
- package/lib/config/configFile.d.ts +2 -2
- package/lib/config/configFile.js +38 -29
- package/lib/config/configStore.d.ts +9 -9
- package/lib/config/configStore.js +17 -15
- package/lib/config/envVars.d.ts +15 -9
- package/lib/config/envVars.js +71 -47
- package/lib/config/orgUsersConfig.js +2 -0
- package/lib/config/sandboxOrgConfig.js +2 -0
- package/lib/config/sandboxProcessCache.d.ts +16 -0
- package/lib/config/sandboxProcessCache.js +38 -0
- package/lib/config/tokensConfig.d.ts +10 -0
- package/lib/config/tokensConfig.js +29 -0
- package/lib/config/ttlConfig.d.ts +34 -0
- package/lib/config/ttlConfig.js +50 -0
- package/lib/crypto/crypto.js +15 -22
- package/lib/crypto/keyChain.js +2 -3
- package/lib/crypto/keyChainImpl.d.ts +5 -3
- package/lib/crypto/keyChainImpl.js +58 -61
- package/lib/crypto/secureBuffer.d.ts +1 -1
- package/lib/deviceOauthService.d.ts +3 -3
- package/lib/deviceOauthService.js +27 -25
- package/lib/exported.d.ts +15 -12
- package/lib/exported.js +28 -16
- package/lib/global.d.ts +11 -3
- package/lib/global.js +39 -12
- package/lib/lifecycleEvents.d.ts +1 -1
- package/lib/lifecycleEvents.js +3 -0
- package/lib/logger.d.ts +19 -9
- package/lib/logger.js +112 -86
- package/lib/messages.d.ts +53 -36
- package/lib/messages.js +81 -91
- package/lib/org/authInfo.d.ts +56 -20
- package/lib/org/authInfo.js +232 -131
- package/lib/org/authRemover.d.ts +8 -7
- package/lib/org/authRemover.js +32 -28
- package/lib/org/connection.d.ts +13 -37
- package/lib/org/connection.js +78 -124
- package/lib/org/index.js +5 -1
- package/lib/org/org.d.ts +151 -48
- package/lib/org/org.js +468 -225
- package/lib/org/orgConfigProperties.d.ts +64 -3
- package/lib/org/orgConfigProperties.js +96 -4
- package/lib/org/permissionSetAssignment.js +4 -13
- package/lib/org/scratchOrgCache.d.ts +20 -0
- package/lib/org/scratchOrgCache.js +33 -0
- package/lib/org/scratchOrgCreate.d.ts +28 -17
- package/lib/org/scratchOrgCreate.js +125 -53
- package/lib/org/scratchOrgErrorCodes.d.ts +9 -3
- package/lib/org/scratchOrgErrorCodes.js +34 -17
- package/lib/org/scratchOrgFeatureDeprecation.js +1 -6
- package/lib/org/scratchOrgInfoApi.d.ts +21 -47
- package/lib/org/scratchOrgInfoApi.js +129 -63
- package/lib/org/scratchOrgInfoGenerator.d.ts +6 -5
- package/lib/org/scratchOrgInfoGenerator.js +76 -62
- package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -0
- package/lib/org/scratchOrgLifecycleEvents.js +41 -0
- package/lib/org/scratchOrgSettingsGenerator.d.ts +44 -21
- package/lib/org/scratchOrgSettingsGenerator.js +165 -98
- package/lib/org/scratchOrgTypes.d.ts +43 -0
- package/lib/org/scratchOrgTypes.js +9 -0
- package/lib/org/user.d.ts +1 -1
- package/lib/org/user.js +25 -34
- package/lib/schema/printer.d.ts +6 -0
- package/lib/schema/printer.js +34 -31
- package/lib/schema/validator.d.ts +12 -10
- package/lib/schema/validator.js +56 -76
- package/lib/{sfdxError.d.ts → sfError.d.ts} +12 -20
- package/lib/{sfdxError.js → sfError.js} +40 -30
- package/lib/{sfdxProject.d.ts → sfProject.d.ts} +75 -35
- package/lib/sfProject.js +651 -0
- package/lib/stateAggregator/accessors/aliasAccessor.d.ts +129 -0
- package/lib/stateAggregator/accessors/aliasAccessor.js +263 -0
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -0
- package/lib/stateAggregator/accessors/orgAccessor.js +240 -0
- package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -0
- package/lib/stateAggregator/accessors/sandboxAccessor.js +28 -0
- package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -0
- package/lib/stateAggregator/accessors/tokenAccessor.js +80 -0
- package/lib/stateAggregator/index.d.ts +4 -0
- package/lib/stateAggregator/index.js +27 -0
- package/lib/stateAggregator/stateAggregator.d.ts +25 -0
- package/lib/stateAggregator/stateAggregator.js +46 -0
- package/lib/status/myDomainResolver.d.ts +1 -1
- package/lib/status/myDomainResolver.js +4 -4
- package/lib/status/pollingClient.js +4 -4
- package/lib/status/streamingClient.d.ts +2 -2
- package/lib/status/streamingClient.js +58 -63
- package/lib/status/types.d.ts +2 -2
- package/lib/testSetup.d.ts +204 -75
- package/lib/testSetup.js +468 -164
- package/lib/util/cache.d.ts +2 -2
- package/lib/util/cache.js +6 -6
- package/lib/util/checkLightningDomain.js +3 -4
- package/lib/util/directoryWriter.d.ts +12 -0
- package/lib/util/directoryWriter.js +54 -0
- package/lib/util/getJwtAudienceUrl.js +1 -1
- package/lib/util/internal.d.ts +28 -2
- package/lib/util/internal.js +65 -8
- package/lib/util/jsonXmlTools.js +2 -4
- package/lib/util/mapKeys.d.ts +9 -9
- package/lib/util/mapKeys.js +13 -9
- package/lib/util/sfdc.d.ts +51 -51
- package/lib/util/sfdc.js +74 -79
- package/lib/util/sfdcUrl.d.ts +5 -19
- package/lib/util/sfdcUrl.js +40 -49
- package/lib/util/structuredWriter.d.ts +9 -0
- package/lib/util/structuredWriter.js +3 -0
- package/lib/util/zipWriter.d.ts +8 -6
- package/lib/util/zipWriter.js +13 -13
- package/lib/webOAuthServer.d.ts +20 -6
- package/lib/webOAuthServer.js +102 -56
- package/messageTransformer/messageTransformer.ts +93 -0
- package/messages/auth.md +9 -1
- package/messages/config.md +42 -6
- package/messages/connection.md +8 -0
- package/messages/core.md +10 -0
- package/messages/envVars.md +37 -3
- package/messages/org.md +21 -1
- package/messages/scratchOrgCreate.md +2 -6
- package/messages/scratchOrgErrorCodes.md +17 -1
- package/messages/scratchOrgInfoApi.md +9 -0
- package/messages/scratchOrgInfoGenerator.md +9 -1
- package/package.json +123 -46
- package/CHANGELOG.md +0 -1244
- package/lib/config/keychainConfig.d.ts +0 -19
- package/lib/config/keychainConfig.js +0 -43
- package/lib/globalInfo/accessors/aliasAccessor.d.ts +0 -83
- package/lib/globalInfo/accessors/aliasAccessor.js +0 -130
- package/lib/globalInfo/accessors/orgAccessor.d.ts +0 -13
- package/lib/globalInfo/accessors/orgAccessor.js +0 -45
- package/lib/globalInfo/accessors/tokenAccessor.d.ts +0 -13
- package/lib/globalInfo/accessors/tokenAccessor.js +0 -35
- package/lib/globalInfo/globalInfoConfig.d.ts +0 -36
- package/lib/globalInfo/globalInfoConfig.js +0 -105
- package/lib/globalInfo/index.d.ts +0 -6
- package/lib/globalInfo/index.js +0 -29
- package/lib/globalInfo/sfdxDataHandler.d.ts +0 -43
- package/lib/globalInfo/sfdxDataHandler.js +0 -217
- package/lib/globalInfo/types.d.ts +0 -39
- package/lib/globalInfo/types.js +0 -10
- package/lib/sfdxProject.js +0 -557
- package/lib/util/fs.d.ts +0 -201
- package/lib/util/fs.js +0 -378
package/LICENSE.txt
CHANGED
package/README.md
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/@salesforce/core)
|
|
2
2
|
[](https://circleci.com/gh/forcedotcom/sfdx-core)
|
|
3
3
|
|
|
4
|
+
- [Description](#description)
|
|
5
|
+
- [Usage](#usage)
|
|
6
|
+
- [Contributing](#contributing)
|
|
7
|
+
- [Using TestSetup](#using-testsetup)
|
|
8
|
+
- [Mocking Authorizations](#mocking-authorizations)
|
|
9
|
+
- [Mocking Config Files](#mocking-config-files)
|
|
10
|
+
- [Using the Built-in Sinon Sandboxes](#using-the-built-in-sinon-sandboxes)
|
|
11
|
+
- [Testing Expected Failures](#testing-expected-failures)
|
|
12
|
+
- [Testing Log Lines](#testing-log-lines)
|
|
13
|
+
|
|
4
14
|
# Description
|
|
5
15
|
|
|
6
|
-
The @salesforce/core library provides client-side management of Salesforce DX projects, org authentication, connections to Salesforce APIs, and other utilities. Much of the core functionality that powers the
|
|
16
|
+
The @salesforce/core library provides client-side management of Salesforce DX projects, org authentication, connections to Salesforce APIs, and other utilities. Much of the core functionality that powers the Salesforce CLI plugins comes from this library. You can use this functionality in your plugins too.
|
|
7
17
|
|
|
8
18
|
# Usage
|
|
9
19
|
|
|
@@ -13,37 +23,25 @@ See the [API documentation](https://forcedotcom.github.io/sfdx-core/).
|
|
|
13
23
|
|
|
14
24
|
If you are interested in contributing, please take a look at the [CONTRIBUTING](CONTRIBUTING.md) guide.
|
|
15
25
|
|
|
16
|
-
# Related Docs and Repositories
|
|
17
|
-
|
|
18
|
-
- [@salesforce/command](https://github.com/forcedotcom/cli-packages/tree/main/packages/command) - Contains base Salesforce CLI command, `SfdxCommand`.
|
|
19
|
-
- [@salesforce/plugin-generator](https://github.com/forcedotcom/sfdx-plugin-generate) - The generator plug-in for building plug-ins for Salesforce CLI.
|
|
20
|
-
|
|
21
26
|
# Using TestSetup
|
|
22
27
|
|
|
23
28
|
The Salesforce DX Core Library provides a unit testing utility to help with mocking and sand-boxing core components. This feature allows unit tests to execute without needing to make API calls to salesforce.com.
|
|
24
29
|
|
|
25
|
-
## Mocking
|
|
30
|
+
## Mocking Authorizations
|
|
26
31
|
|
|
27
32
|
Here you can mock authorization for a Salesforce scratch org.
|
|
28
33
|
|
|
29
34
|
```typescript
|
|
30
35
|
import { strictEqual } from 'assert';
|
|
31
|
-
import { MockTestOrgData,
|
|
36
|
+
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup';
|
|
32
37
|
import { AuthInfo } from '@salesforce/core';
|
|
33
38
|
|
|
34
|
-
const $$ = testSetup();
|
|
35
|
-
|
|
36
39
|
describe('Mocking Auth data', () => {
|
|
40
|
+
const $$ = new TestContext();
|
|
37
41
|
it('example', async () => {
|
|
38
42
|
const testData = new MockTestOrgData();
|
|
39
|
-
$$.
|
|
40
|
-
|
|
41
|
-
orgs: {
|
|
42
|
-
[testData.username]: await testData.getConfig(),
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
const auth: AuthInfo = await AuthInfo.create({ username: testData.username });
|
|
43
|
+
await $$.stubAuths(testData);
|
|
44
|
+
const auth = await AuthInfo.create({ username: testData.username });
|
|
47
45
|
strictEqual(auth.getUsername(), testData.username);
|
|
48
46
|
});
|
|
49
47
|
});
|
|
@@ -52,58 +50,86 @@ describe('Mocking Auth data', () => {
|
|
|
52
50
|
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
51
|
|
|
54
52
|
```typescript
|
|
55
|
-
import { AuthInfo, Connection,
|
|
56
|
-
import { MockTestOrgData,
|
|
53
|
+
import { AuthInfo, Connection, SfError } from '@salesforce/core';
|
|
54
|
+
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup';
|
|
57
55
|
import { AnyJson, ensureJsonMap, JsonMap } from '@salesforce/ts-types';
|
|
58
56
|
import { ensureString } from '@salesforce/ts-types';
|
|
59
57
|
import { deepStrictEqual } from 'assert';
|
|
60
58
|
import { QueryResult } from 'jsforce';
|
|
61
59
|
|
|
62
|
-
const $$ = testSetup();
|
|
63
|
-
|
|
64
60
|
describe('Mocking a force server call', () => {
|
|
61
|
+
const $$ = new TestContext();
|
|
65
62
|
it('example', async () => {
|
|
66
63
|
const records: AnyJson = { records: ['123456', '234567'] };
|
|
67
64
|
const testData = new MockTestOrgData();
|
|
68
|
-
$$.
|
|
69
|
-
contents: {
|
|
70
|
-
orgs: {
|
|
71
|
-
[testData.username]: await testData.getConfig(),
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
});
|
|
65
|
+
await $$.stubAuths(testData);
|
|
75
66
|
$$.fakeConnectionRequest = (request: AnyJson): Promise<AnyJson> => {
|
|
76
|
-
const _request
|
|
67
|
+
const _request = ensureJsonMap(request);
|
|
77
68
|
if (request && ensureString(_request.url).includes('Account')) {
|
|
78
69
|
return Promise.resolve(records);
|
|
79
70
|
} else {
|
|
80
|
-
return Promise.reject(new
|
|
71
|
+
return Promise.reject(new SfError(`Unexpected request: ${_request.url}`));
|
|
81
72
|
}
|
|
82
73
|
};
|
|
83
|
-
const connection
|
|
74
|
+
const connection = await Connection.create({
|
|
84
75
|
authInfo: await AuthInfo.create({ username: testData.username }),
|
|
85
76
|
});
|
|
86
|
-
const result
|
|
77
|
+
const result = await connection.query('select Id From Account');
|
|
87
78
|
deepStrictEqual(result, records);
|
|
88
79
|
});
|
|
89
80
|
});
|
|
90
81
|
```
|
|
91
82
|
|
|
83
|
+
## Mocking Config Files
|
|
84
|
+
|
|
85
|
+
You can mock the contents of various config files
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { strictEqual } from 'assert';
|
|
89
|
+
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup';
|
|
90
|
+
import { StateAggregator, OrgConfigProperties } from '@salesforce/core';
|
|
91
|
+
|
|
92
|
+
describe('Mocking Aliases', () => {
|
|
93
|
+
const $$ = new TestContext();
|
|
94
|
+
it('example', async () => {
|
|
95
|
+
const testData = new MockTestOrgData();
|
|
96
|
+
await $$.stubAliases({ myAlias: testData.username });
|
|
97
|
+
const alias = (await StateAggregator.getInstance()).aliases.get(testData.username);
|
|
98
|
+
strictEqual(alias, 'myAlias');
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('Mocking Config', () => {
|
|
103
|
+
it('example', async () => {
|
|
104
|
+
const testData = new MockTestOrgData();
|
|
105
|
+
await $$.stubConfig({ [OrgConfigProperties.TARGET_ORG]: testData.username });
|
|
106
|
+
const { value } = (await ConfigAggregator.create()).getInfo(OrgConfigProperties.TARGET_ORG);
|
|
107
|
+
strictEqual(value, testData.username);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('Mocking Arbitrary Config Files', () => {
|
|
112
|
+
it('example', async () => {
|
|
113
|
+
// MyConfigFile must extend the ConfigFile class in order for this to work properly.
|
|
114
|
+
$$.setConfigStubContents('MyConfigFile', { contents: { foo: 'bar' } });
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
92
119
|
## Using the Built-in Sinon Sandboxes
|
|
93
120
|
|
|
94
|
-
sfdx-core uses Sinon as its underlying mocking system. If you're unfamiliar with Sinon and
|
|
121
|
+
sfdx-core uses Sinon as its underlying mocking system. If you're unfamiliar with Sinon and its sandboxing concept you can find more information here:
|
|
95
122
|
https://sinonjs.org/
|
|
96
123
|
Sinon `stub`s and `spy`s must be cleaned up after test invocations. To ease the use of Sinon with sfdx core we've exposed our sandbox in TestSetup. After adding your own `stub`s and/or `spy`s they will automatically be cleaned up after each test using mocha's afterEach method.
|
|
97
124
|
|
|
98
125
|
```typescript
|
|
99
126
|
import { strictEqual } from 'assert';
|
|
100
127
|
|
|
101
|
-
import {
|
|
128
|
+
import { TestContext } from '@salesforce/core/lib/testSetup';
|
|
102
129
|
import * as os from 'os';
|
|
103
130
|
|
|
104
|
-
const $$ = testSetup();
|
|
105
|
-
|
|
106
131
|
describe('Using the built in Sinon sandbox.', () => {
|
|
132
|
+
const $$ = new TestContext();
|
|
107
133
|
it('example', async () => {
|
|
108
134
|
const unsupportedOS = 'LEO';
|
|
109
135
|
$$.SANDBOX.stub(os, 'platform').returns(unsupportedOS);
|
|
@@ -117,13 +143,13 @@ describe('Using the built in Sinon sandbox.', () => {
|
|
|
117
143
|
It's important to have negative tests that ensure proper error handling. With `shouldThrow` it's easy to test for expected async rejections.
|
|
118
144
|
|
|
119
145
|
```typescript
|
|
120
|
-
import {
|
|
146
|
+
import { SfError } from '@salesforce/core';
|
|
121
147
|
import { shouldThrow } from '@salesforce/core/lib/testSetup';
|
|
122
148
|
import { strictEqual } from 'assert';
|
|
123
149
|
|
|
124
150
|
class TestObject {
|
|
125
151
|
public static async method() {
|
|
126
|
-
throw new
|
|
152
|
+
throw new SfError('Error', 'ExpectedError');
|
|
127
153
|
}
|
|
128
154
|
}
|
|
129
155
|
|
|
@@ -138,17 +164,39 @@ describe('Testing for expected errors', () => {
|
|
|
138
164
|
});
|
|
139
165
|
```
|
|
140
166
|
|
|
167
|
+
You can also use `shouldThrowSync` for syncrhonous functions you expect to fail
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import { SfError } from '@salesforce/core';
|
|
171
|
+
import { shouldThrowSync } from '@salesforce/core/lib/testSetup';
|
|
172
|
+
import { strictEqual } from 'assert';
|
|
173
|
+
|
|
174
|
+
class TestObject {
|
|
175
|
+
public static method() {
|
|
176
|
+
throw new SfError('Error', 'ExpectedError');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
describe('Testing for expected errors', () => {
|
|
181
|
+
it('example', async () => {
|
|
182
|
+
try {
|
|
183
|
+
shouldThrowSync(() => TestObject.method());
|
|
184
|
+
} catch (e) {
|
|
185
|
+
strictEqual(e.name, 'ExpectedError');
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
141
191
|
## Testing Log Lines
|
|
142
192
|
|
|
143
193
|
It's also useful to check expected values and content from log lines. TestSetup configures the sfdx-core logger to use an in memory LogLine storage structure. These can be easily accessed from tests.
|
|
144
194
|
|
|
145
195
|
```typescript
|
|
146
196
|
import { Logger, LogLine } from '@salesforce/core';
|
|
147
|
-
import {
|
|
197
|
+
import { TestContext } from '@salesforce/core/lib/testSetup';
|
|
148
198
|
import { strictEqual } from 'assert';
|
|
149
199
|
|
|
150
|
-
const $$ = testSetup();
|
|
151
|
-
|
|
152
200
|
const TEST_STRING = 'foo was here';
|
|
153
201
|
|
|
154
202
|
class TestObject {
|
|
@@ -162,10 +210,11 @@ class TestObject {
|
|
|
162
210
|
}
|
|
163
211
|
|
|
164
212
|
describe('Testing log lines', () => {
|
|
213
|
+
const $$ = new TestContext();
|
|
165
214
|
it('example', async () => {
|
|
166
|
-
const obj
|
|
215
|
+
const obj = new TestObject($$.TEST_LOGGER);
|
|
167
216
|
obj.method();
|
|
168
|
-
const records
|
|
217
|
+
const records = $$.TEST_LOGGER.getBufferedRecords();
|
|
169
218
|
strictEqual(records.length, 1);
|
|
170
219
|
strictEqual(records[0].msg, TEST_STRING);
|
|
171
220
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AuthFields } from '../org';
|
|
2
|
+
import { ConfigFile } from './configFile';
|
|
3
|
+
/**
|
|
4
|
+
* An auth config file that stores information such as access tokens, usernames, etc.,
|
|
5
|
+
* in the global sfdx directory (~/.sfdx).
|
|
6
|
+
*
|
|
7
|
+
* ```
|
|
8
|
+
* const authInfo = await AuthInfoConfig.create(AuthInfoConfig.getOptions(username));
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare class AuthInfoConfig extends ConfigFile<ConfigFile.Options, AuthFields> {
|
|
12
|
+
protected static encryptedKeys: RegExp[];
|
|
13
|
+
/**
|
|
14
|
+
* Gets the config options for a given org ID.
|
|
15
|
+
*
|
|
16
|
+
* @param username The username for the org.
|
|
17
|
+
*/
|
|
18
|
+
static getOptions(username: string): ConfigFile.Options;
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuthInfoConfig = void 0;
|
|
10
|
+
const configFile_1 = require("./configFile");
|
|
11
|
+
/**
|
|
12
|
+
* An auth config file that stores information such as access tokens, usernames, etc.,
|
|
13
|
+
* in the global sfdx directory (~/.sfdx).
|
|
14
|
+
*
|
|
15
|
+
* ```
|
|
16
|
+
* const authInfo = await AuthInfoConfig.create(AuthInfoConfig.getOptions(username));
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class AuthInfoConfig extends configFile_1.ConfigFile {
|
|
20
|
+
/**
|
|
21
|
+
* Gets the config options for a given org ID.
|
|
22
|
+
*
|
|
23
|
+
* @param username The username for the org.
|
|
24
|
+
*/
|
|
25
|
+
static getOptions(username) {
|
|
26
|
+
return {
|
|
27
|
+
isGlobal: true,
|
|
28
|
+
isState: true,
|
|
29
|
+
filename: `${username}.json`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.AuthInfoConfig = AuthInfoConfig;
|
|
34
|
+
AuthInfoConfig.encryptedKeys = [/token/i, /password/i, /secret/i];
|
|
35
|
+
//# sourceMappingURL=authInfoConfig.js.map
|
package/lib/config/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonPrimitive } from '@salesforce/ts-types';
|
|
1
|
+
import { JsonPrimitive, Nullable } from '@salesforce/ts-types';
|
|
2
2
|
import { OrgConfigProperties } from '../org/orgConfigProperties';
|
|
3
3
|
import { ConfigFile } from './configFile';
|
|
4
4
|
import { ConfigContents, ConfigValue } from './configStore';
|
|
@@ -51,94 +51,137 @@ export interface ConfigPropertyMetaInput {
|
|
|
51
51
|
*/
|
|
52
52
|
failedMessage: string | ((value: ConfigValue) => string);
|
|
53
53
|
}
|
|
54
|
+
export declare enum SfConfigProperties {
|
|
55
|
+
/**
|
|
56
|
+
* Disables telemetry reporting
|
|
57
|
+
*/
|
|
58
|
+
DISABLE_TELEMETRY = "disable-telemetry"
|
|
59
|
+
}
|
|
60
|
+
export declare const SF_ALLOWED_PROPERTIES: {
|
|
61
|
+
key: SfConfigProperties;
|
|
62
|
+
description: string;
|
|
63
|
+
input: {
|
|
64
|
+
validator: (value: ConfigValue) => boolean;
|
|
65
|
+
failedMessage: string;
|
|
66
|
+
};
|
|
67
|
+
}[];
|
|
54
68
|
export declare enum SfdxPropertyKeys {
|
|
55
69
|
/**
|
|
56
70
|
* Username associated with the default dev hub org.
|
|
57
71
|
*
|
|
58
72
|
* @deprecated Replaced by OrgConfigProperties.TARGET_DEV_HUB in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
|
|
73
|
+
* will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
|
|
59
74
|
*/
|
|
60
75
|
DEFAULT_DEV_HUB_USERNAME = "defaultdevhubusername",
|
|
61
76
|
/**
|
|
62
77
|
* Username associate with the default org.
|
|
63
78
|
*
|
|
64
79
|
* @deprecated Replaced by OrgConfigProperties.TARGET_ORG in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
|
|
80
|
+
* will remain in v3 for the foreseeable future so that `sfdx-core` can map between `sf` and `sfdx` config values
|
|
65
81
|
*/
|
|
66
82
|
DEFAULT_USERNAME = "defaultusername",
|
|
67
83
|
/**
|
|
68
84
|
* The sid for the debugger configuration.
|
|
85
|
+
*
|
|
86
|
+
* @deprecated Replaced by OrgConfigProperties.ORG_ISV_DEBUGGER_SID in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
|
|
69
87
|
*/
|
|
70
88
|
ISV_DEBUGGER_SID = "isvDebuggerSid",
|
|
71
89
|
/**
|
|
72
90
|
* The url for the debugger configuration.
|
|
91
|
+
*
|
|
92
|
+
* @deprecated Replaced by OrgConfigProperties.ORG_ISV_DEBUGGER_URL in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
|
|
73
93
|
*/
|
|
74
94
|
ISV_DEBUGGER_URL = "isvDebuggerUrl",
|
|
75
95
|
/**
|
|
76
96
|
* The api version
|
|
97
|
+
*
|
|
98
|
+
* @deprecated Replaced by OrgConfigProperties.ORG_API_VERSION in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
|
|
77
99
|
*/
|
|
78
100
|
API_VERSION = "apiVersion",
|
|
79
101
|
/**
|
|
80
102
|
* Disables telemetry reporting
|
|
103
|
+
*
|
|
104
|
+
* @deprecated Replaced by SfPropertyKeys.DISABLE_TELEMETRY in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
|
|
81
105
|
*/
|
|
82
106
|
DISABLE_TELEMETRY = "disableTelemetry",
|
|
83
107
|
/**
|
|
84
108
|
* Custom templates repo or local location.
|
|
109
|
+
*
|
|
110
|
+
* @deprecated Replaced by OrgConfigProperties.ORG_CUSTOM_METADATA_TEMPLATES in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
|
|
85
111
|
*/
|
|
86
112
|
CUSTOM_ORG_METADATA_TEMPLATES = "customOrgMetadataTemplates",
|
|
87
113
|
/**
|
|
88
114
|
* allows users to override the 10,000 result query limit
|
|
115
|
+
*
|
|
116
|
+
* @deprecated Replaced by OrgConfigProperties.ORG_MAX_QUERY_LIMIT in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
|
|
89
117
|
*/
|
|
90
118
|
MAX_QUERY_LIMIT = "maxQueryLimit",
|
|
91
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* @deprecated
|
|
121
|
+
*/
|
|
92
122
|
REST_DEPLOY = "restDeploy",
|
|
93
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated Replaced by OrgConfigProperties.ORG_INSTANCE_URL in v3 {@link https://github.com/forcedotcom/sfdx-core/blob/v3/MIGRATING_V2-V3.md#config}
|
|
125
|
+
*/
|
|
94
126
|
INSTANCE_URL = "instanceUrl"
|
|
95
127
|
}
|
|
96
128
|
export declare const SFDX_ALLOWED_PROPERTIES: ({
|
|
97
129
|
key: SfdxPropertyKeys;
|
|
98
130
|
description: string;
|
|
131
|
+
newKey: OrgConfigProperties;
|
|
132
|
+
deprecated: boolean;
|
|
99
133
|
input: {
|
|
100
134
|
validator: (value: ConfigValue) => boolean;
|
|
101
135
|
failedMessage: string;
|
|
102
136
|
};
|
|
137
|
+
encrypted?: undefined;
|
|
103
138
|
hidden?: undefined;
|
|
104
|
-
|
|
105
|
-
|
|
139
|
+
} | {
|
|
140
|
+
key: SfdxPropertyKeys;
|
|
141
|
+
newKey: OrgConfigProperties;
|
|
142
|
+
deprecated: boolean;
|
|
143
|
+
description: string;
|
|
144
|
+
input?: undefined;
|
|
106
145
|
encrypted?: undefined;
|
|
146
|
+
hidden?: undefined;
|
|
107
147
|
} | {
|
|
108
148
|
key: SfdxPropertyKeys;
|
|
149
|
+
newKey: OrgConfigProperties;
|
|
150
|
+
deprecated: boolean;
|
|
109
151
|
description: string;
|
|
110
|
-
|
|
152
|
+
encrypted: boolean;
|
|
111
153
|
input: {
|
|
112
154
|
validator: (value: ConfigValue) => boolean;
|
|
113
155
|
failedMessage: string;
|
|
114
156
|
};
|
|
115
|
-
|
|
116
|
-
deprecated?: undefined;
|
|
117
|
-
encrypted?: undefined;
|
|
157
|
+
hidden?: undefined;
|
|
118
158
|
} | {
|
|
119
159
|
key: SfdxPropertyKeys;
|
|
120
|
-
newKey:
|
|
160
|
+
newKey: SfConfigProperties;
|
|
121
161
|
deprecated: boolean;
|
|
122
162
|
description: string;
|
|
123
|
-
input
|
|
124
|
-
|
|
163
|
+
input: {
|
|
164
|
+
validator: (value: ConfigValue) => boolean;
|
|
165
|
+
failedMessage: string;
|
|
166
|
+
};
|
|
125
167
|
encrypted?: undefined;
|
|
168
|
+
hidden?: undefined;
|
|
126
169
|
} | {
|
|
127
170
|
key: SfdxPropertyKeys;
|
|
128
171
|
description: string;
|
|
129
|
-
|
|
172
|
+
hidden: boolean;
|
|
173
|
+
newKey: string;
|
|
174
|
+
deprecated: boolean;
|
|
130
175
|
input: {
|
|
131
176
|
validator: (value: ConfigValue) => boolean;
|
|
132
177
|
failedMessage: string;
|
|
133
178
|
};
|
|
134
|
-
|
|
135
|
-
newKey?: undefined;
|
|
136
|
-
deprecated?: undefined;
|
|
179
|
+
encrypted?: undefined;
|
|
137
180
|
})[];
|
|
138
181
|
export declare const SfProperty: {
|
|
139
182
|
[index: string]: ConfigPropertyMeta;
|
|
140
183
|
};
|
|
141
|
-
export
|
|
184
|
+
export type ConfigProperties = {
|
|
142
185
|
[index: string]: JsonPrimitive;
|
|
143
186
|
};
|
|
144
187
|
/**
|
|
@@ -186,6 +229,7 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
186
229
|
* Clear all the configured properties both local and global.
|
|
187
230
|
*/
|
|
188
231
|
static clear(): Promise<void>;
|
|
232
|
+
static getPropertyConfigMeta(propertyName: string): Nullable<ConfigPropertyMeta>;
|
|
189
233
|
private static propertyConfigMap;
|
|
190
234
|
/**
|
|
191
235
|
* Read, assign, and return the config contents.
|
|
@@ -202,7 +246,7 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
202
246
|
* DO NOT CALL - The config file needs to encrypt values which can only be done asynchronously.
|
|
203
247
|
* Call {@link SfdxConfig.write} instead.
|
|
204
248
|
*
|
|
205
|
-
* **Throws** *{@link
|
|
249
|
+
* **Throws** *{@link SfError}{ name: 'InvalidWriteError' }* Always.
|
|
206
250
|
*
|
|
207
251
|
* @param newContents Contents to write
|
|
208
252
|
*/
|
|
@@ -210,8 +254,8 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
210
254
|
/**
|
|
211
255
|
* Sets a value for a property.
|
|
212
256
|
*
|
|
213
|
-
* **Throws** *{@link
|
|
214
|
-
* **Throws** *{@link
|
|
257
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
|
|
258
|
+
* **Throws** *{@link SfError}{ name: 'InvalidConfigValueError' }* If the input validator fails.
|
|
215
259
|
*
|
|
216
260
|
* @param key The property to set.
|
|
217
261
|
* @param value The value of the property.
|
|
@@ -220,7 +264,7 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
220
264
|
/**
|
|
221
265
|
* Unsets a value for a property.
|
|
222
266
|
*
|
|
223
|
-
* **Throws** *{@link
|
|
267
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* If the input validator fails.
|
|
224
268
|
*
|
|
225
269
|
* @param key The property to unset.
|
|
226
270
|
*/
|
|
@@ -228,7 +272,7 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
228
272
|
/**
|
|
229
273
|
* Get an individual property config.
|
|
230
274
|
*
|
|
231
|
-
* **Throws** *{@link
|
|
275
|
+
* **Throws** *{@link SfError}{ name: 'UnknownConfigKeyError' }* An attempt to get a property that's not supported.
|
|
232
276
|
*
|
|
233
277
|
* @param propertyName The name of the property.
|
|
234
278
|
*/
|
|
@@ -244,3 +288,24 @@ export declare class Config extends ConfigFile<ConfigFile.Options, ConfigPropert
|
|
|
244
288
|
*/
|
|
245
289
|
private cryptProperties;
|
|
246
290
|
}
|
|
291
|
+
export declare class SfdxConfig {
|
|
292
|
+
private options;
|
|
293
|
+
private config;
|
|
294
|
+
private sfdxPath;
|
|
295
|
+
constructor(options: ConfigFile.Options, config: Config);
|
|
296
|
+
/**
|
|
297
|
+
* If Global.SFDX_INTEROPERABILITY is enabled, merge the sfdx config into the sf config
|
|
298
|
+
*/
|
|
299
|
+
merge(config: ConfigProperties): ConfigProperties | undefined;
|
|
300
|
+
write(config?: import("@salesforce/ts-types").JsonMap): Promise<void>;
|
|
301
|
+
private readSync;
|
|
302
|
+
private getSfdxPath;
|
|
303
|
+
/**
|
|
304
|
+
* If toNew is specified: migrate all deprecated configs with a newKey to the newKey.
|
|
305
|
+
* - For example, defaultusername will be renamed to target-org.
|
|
306
|
+
*
|
|
307
|
+
* If toOld is specified: migrate all deprecated configs back to their original key.
|
|
308
|
+
* - For example, target-org will be renamed to defaultusername.
|
|
309
|
+
*/
|
|
310
|
+
private translate;
|
|
311
|
+
}
|