@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.
- package/LICENSE.txt +1 -1
- package/README.md +93 -44
- package/lib/config/aliasesConfig.d.ts +12 -0
- package/lib/config/aliasesConfig.js +28 -0
- 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/configGroup.d.ts +141 -0
- package/lib/config/configGroup.js +225 -0
- 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 +466 -220
- 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/{globalInfo → stateAggregator}/accessors/aliasAccessor.d.ts +27 -12
- package/lib/{globalInfo → stateAggregator}/accessors/aliasAccessor.js +47 -31
- 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 +206 -75
- package/lib/testSetup.js +463 -165
- 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 +121 -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/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/lib/messages.js
CHANGED
|
@@ -13,16 +13,8 @@ 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
|
|
17
|
-
|
|
18
|
-
constructor(packageName, bundleName) {
|
|
19
|
-
this.packageName = packageName;
|
|
20
|
-
this.bundleName = bundleName;
|
|
21
|
-
}
|
|
22
|
-
toString() {
|
|
23
|
-
return `${this.packageName}:${this.bundleName}`;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
16
|
+
const sfError_1 = require("./sfError");
|
|
17
|
+
const getKey = (packageName, bundleName) => `${packageName}:${bundleName}`;
|
|
26
18
|
const REGEXP_NO_CONTENT = /^\s*$/g;
|
|
27
19
|
const REGEXP_NO_CONTENT_SECTION = /^#\s*/gm;
|
|
28
20
|
const REGEXP_MD_IS_LIST_ROW = /^[*-]\s+|^ {2}/;
|
|
@@ -57,7 +49,7 @@ const markdownLoader = (filePath, fileContents) => {
|
|
|
57
49
|
}
|
|
58
50
|
}
|
|
59
51
|
else {
|
|
60
|
-
// use error instead of
|
|
52
|
+
// use error instead of SfError because messages.js should have no internal dependencies.
|
|
61
53
|
throw new Error(`Invalid markdown message file: ${filePath}\nThe line "# <key>" must be immediately followed by the message on a new line.`);
|
|
62
54
|
}
|
|
63
55
|
}
|
|
@@ -148,7 +140,7 @@ const jsAndJsonLoader = (filePath, fileContents) => {
|
|
|
148
140
|
*
|
|
149
141
|
* // Now you can use the messages from anywhere in your code or file.
|
|
150
142
|
* // If using importMessageDirectory, the bundle name is the file name.
|
|
151
|
-
* const messages: Messages = Messages.
|
|
143
|
+
* const messages: Messages = Messages.loadMessages(packageName, bundleName);
|
|
152
144
|
*
|
|
153
145
|
* // Messages now contains all the message in the bundleName file.
|
|
154
146
|
* messages.getMessage('authInfoCreationError');
|
|
@@ -158,7 +150,7 @@ class Messages {
|
|
|
158
150
|
/**
|
|
159
151
|
* Create a new messages bundle.
|
|
160
152
|
*
|
|
161
|
-
* **Note:** Use {Messages.
|
|
153
|
+
* **Note:** Use {Messages.loadMessages} unless you are writing your own loader function.
|
|
162
154
|
*
|
|
163
155
|
* @param bundleName The bundle name.
|
|
164
156
|
* @param locale The locale.
|
|
@@ -177,14 +169,14 @@ class Messages {
|
|
|
177
169
|
return 'en_US';
|
|
178
170
|
}
|
|
179
171
|
/**
|
|
180
|
-
* Set a custom loader function for a package and bundle that will be called on {@link Messages.
|
|
172
|
+
* Set a custom loader function for a package and bundle that will be called on {@link Messages.loadMessages}.
|
|
181
173
|
*
|
|
182
174
|
* @param packageName The npm package name.
|
|
183
175
|
* @param bundle The name of the bundle.
|
|
184
176
|
* @param loader The loader function.
|
|
185
177
|
*/
|
|
186
178
|
static setLoaderFunction(packageName, bundle, loader) {
|
|
187
|
-
this.loaders.set(
|
|
179
|
+
this.loaders.set(getKey(packageName, bundle), loader);
|
|
188
180
|
}
|
|
189
181
|
/**
|
|
190
182
|
* Generate a file loading function. Use {@link Messages.importMessageFile} unless
|
|
@@ -217,7 +209,7 @@ class Messages {
|
|
|
217
209
|
if (!fileContents || fileContents.trim().length === 0) {
|
|
218
210
|
// messages.js should have no internal dependencies.
|
|
219
211
|
const error = new Error(`Invalid message file: ${filePath}. No content.`);
|
|
220
|
-
error.name = '
|
|
212
|
+
error.name = 'SfError';
|
|
221
213
|
throw error;
|
|
222
214
|
}
|
|
223
215
|
const map = parser(filePath, fileContents);
|
|
@@ -239,7 +231,7 @@ class Messages {
|
|
|
239
231
|
}
|
|
240
232
|
/**
|
|
241
233
|
* Import all json and js files in a messages directory. Use the file name as the bundle key when
|
|
242
|
-
* {@link Messages.
|
|
234
|
+
* {@link Messages.loadMessages} is called. By default, we're assuming the moduleDirectoryPart is a
|
|
243
235
|
* typescript project and will truncate to root path (where the package.json file is). If your messages
|
|
244
236
|
* directory is in another spot or you are not using typescript, pass in false for truncateToProjectPath.
|
|
245
237
|
*
|
|
@@ -304,83 +296,33 @@ class Messages {
|
|
|
304
296
|
* Load messages for a given package and bundle. If the bundle is not already cached, use the loader function
|
|
305
297
|
* created from {@link Messages.setLoaderFunction} or {@link Messages.importMessagesDirectory}.
|
|
306
298
|
*
|
|
307
|
-
* **NOTE: Use {@link Messages.load} instead for safe message validation and usage.**
|
|
308
|
-
*
|
|
309
299
|
* ```typescript
|
|
310
300
|
* Messages.importMessagesDirectory(__dirname);
|
|
311
|
-
* const messages = Messages.
|
|
301
|
+
* const messages = Messages.loadMessages('packageName', 'bundleName');
|
|
312
302
|
* ```
|
|
313
303
|
*
|
|
314
304
|
* @param packageName The name of the npm package.
|
|
315
305
|
* @param bundleName The name of the bundle to load.
|
|
316
306
|
*/
|
|
317
307
|
static loadMessages(packageName, bundleName) {
|
|
318
|
-
const key =
|
|
319
|
-
let messages;
|
|
320
|
-
if (this.isCached(packageName, bundleName)) {
|
|
321
|
-
messages = this.bundles.get(key.toString());
|
|
322
|
-
}
|
|
323
|
-
else if (this.loaders.has(key.toString())) {
|
|
324
|
-
const loader = this.loaders.get(key.toString());
|
|
325
|
-
if (loader) {
|
|
326
|
-
messages = loader(Messages.getLocale());
|
|
327
|
-
this.bundles.set(key.toString(), messages);
|
|
328
|
-
messages = this.bundles.get(key.toString());
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
if (messages) {
|
|
332
|
-
return messages;
|
|
333
|
-
}
|
|
334
|
-
// Don't use messages inside messages
|
|
335
|
-
throw new kit_1.NamedError('MissingBundleError', `Missing bundle ${key.toString()} for locale ${Messages.getLocale()}.`);
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Load messages for a given package and bundle. If the bundle is not already cached, use the loader function
|
|
339
|
-
* created from {@link Messages.setLoaderFunction} or {@link Messages.importMessagesDirectory}.
|
|
340
|
-
*
|
|
341
|
-
* The message keys that will be used must be passed in for validation. This prevents runtime errors if messages are used but not defined.
|
|
342
|
-
*
|
|
343
|
-
* **NOTE: This should be defined at the top of the file so validation is done at load time rather than runtime.**
|
|
344
|
-
*
|
|
345
|
-
* ```typescript
|
|
346
|
-
* Messages.importMessagesDirectory(__dirname);
|
|
347
|
-
* const messages = Messages.load('packageName', 'bundleName', [
|
|
348
|
-
* 'messageKey1',
|
|
349
|
-
* 'messageKey2',
|
|
350
|
-
* ]);
|
|
351
|
-
* ```
|
|
352
|
-
*
|
|
353
|
-
* @param packageName The name of the npm package.
|
|
354
|
-
* @param bundleName The name of the bundle to load.
|
|
355
|
-
* @param keys The message keys that will be used.
|
|
356
|
-
*/
|
|
357
|
-
static load(packageName, bundleName, keys) {
|
|
358
|
-
const key = new Key(packageName, bundleName);
|
|
308
|
+
const key = getKey(packageName, bundleName);
|
|
359
309
|
let messages;
|
|
360
310
|
if (this.isCached(packageName, bundleName)) {
|
|
361
|
-
messages = this.bundles.get(key
|
|
311
|
+
messages = this.bundles.get(key);
|
|
362
312
|
}
|
|
363
|
-
else if (this.loaders.has(key
|
|
364
|
-
const loader = this.loaders.get(key
|
|
313
|
+
else if (this.loaders.has(key)) {
|
|
314
|
+
const loader = this.loaders.get(key);
|
|
365
315
|
if (loader) {
|
|
366
316
|
messages = loader(Messages.getLocale());
|
|
367
|
-
this.bundles.set(key
|
|
368
|
-
messages = this.bundles.get(key
|
|
317
|
+
this.bundles.set(key, messages);
|
|
318
|
+
messages = this.bundles.get(key);
|
|
369
319
|
}
|
|
370
320
|
}
|
|
371
321
|
if (messages) {
|
|
372
|
-
// Type guard on key length, but do a runtime check.
|
|
373
|
-
if (!keys || keys.length === 0) {
|
|
374
|
-
throw new kit_1.NamedError('MissingKeysError', 'Can not load messages without providing the message keys that will be used.');
|
|
375
|
-
}
|
|
376
|
-
// Get all messages to validate they are actually present
|
|
377
|
-
for (const messageKey of keys) {
|
|
378
|
-
messages.getMessage(messageKey);
|
|
379
|
-
}
|
|
380
322
|
return messages;
|
|
381
323
|
}
|
|
382
324
|
// Don't use messages inside messages
|
|
383
|
-
throw new kit_1.NamedError('MissingBundleError', `Missing bundle ${key
|
|
325
|
+
throw new kit_1.NamedError('MissingBundleError', `Missing bundle ${key} for locale ${Messages.getLocale()}.`);
|
|
384
326
|
}
|
|
385
327
|
/**
|
|
386
328
|
* Check if a bundle already been loaded.
|
|
@@ -389,7 +331,7 @@ class Messages {
|
|
|
389
331
|
* @param bundleName The bundle name.
|
|
390
332
|
*/
|
|
391
333
|
static isCached(packageName, bundleName) {
|
|
392
|
-
return this.bundles.has(
|
|
334
|
+
return this.bundles.has(getKey(packageName, bundleName));
|
|
393
335
|
}
|
|
394
336
|
/**
|
|
395
337
|
* Get a message using a message key and use the tokens as values for tokenization.
|
|
@@ -438,25 +380,74 @@ class Messages {
|
|
|
438
380
|
* @param key The key of the error message.
|
|
439
381
|
* @param tokens The error message tokens.
|
|
440
382
|
* @param actionTokens The action messages tokens.
|
|
441
|
-
* @param exitCodeOrCause The exit code which will be used by SfdxCommand or
|
|
383
|
+
* @param exitCodeOrCause The exit code which will be used by SfdxCommand or the underlying error that caused this error to be raised.
|
|
442
384
|
* @param cause The underlying error that caused this error to be raised.
|
|
443
385
|
*/
|
|
444
386
|
createError(key, tokens = [], actionTokens = [], exitCodeOrCause, cause) {
|
|
387
|
+
const { message, name, actions } = this.formatMessageContents({
|
|
388
|
+
type: 'error',
|
|
389
|
+
key,
|
|
390
|
+
tokens,
|
|
391
|
+
actionTokens,
|
|
392
|
+
});
|
|
393
|
+
return new sfError_1.SfError(message, name, actions, exitCodeOrCause, cause);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Convenience method to create warning using message labels.
|
|
397
|
+
*
|
|
398
|
+
* `warning.name` will be the upper-cased key, remove prefixed `warning.` and will always end in Warning.
|
|
399
|
+
* `warning.actions` will be loaded using `${key}.actions` if available.
|
|
400
|
+
*
|
|
401
|
+
* @param key The key of the warning message.
|
|
402
|
+
* @param tokens The warning message tokens.
|
|
403
|
+
* @param actionTokens The action messages tokens.
|
|
404
|
+
*/
|
|
405
|
+
createWarning(key, tokens = [], actionTokens = []) {
|
|
406
|
+
return this.formatMessageContents({ type: 'warning', key, tokens, actionTokens });
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Convenience method to create info using message labels.
|
|
410
|
+
*
|
|
411
|
+
* `info.name` will be the upper-cased key, remove prefixed `info.` and will always end in Info.
|
|
412
|
+
* `info.actions` will be loaded using `${key}.actions` if available.
|
|
413
|
+
*
|
|
414
|
+
* @param key The key of the warning message.
|
|
415
|
+
* @param tokens The warning message tokens.
|
|
416
|
+
* @param actionTokens The action messages tokens.
|
|
417
|
+
*/
|
|
418
|
+
createInfo(key, tokens = [], actionTokens = []) {
|
|
419
|
+
return this.formatMessageContents({ type: 'info', key, tokens, actionTokens });
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Formats message contents given a message type, key, tokens and actions tokens
|
|
423
|
+
*
|
|
424
|
+
* `<type>.name` will be the upper-cased key, remove prefixed `<type>.` and will always end in 'Error | Warning | Info.
|
|
425
|
+
* `<type>.actions` will be loaded using `${key}.actions` if available.
|
|
426
|
+
*
|
|
427
|
+
* @param type The type of the message set must 'error' | 'warning' | 'info'.
|
|
428
|
+
* @param key The key of the warning message.
|
|
429
|
+
* @param tokens The warning message tokens.
|
|
430
|
+
* @param actionTokens The action messages tokens.
|
|
431
|
+
* @param preserveName Do not require that the name end in the type ('error' | 'warning' | 'info').
|
|
432
|
+
*/
|
|
433
|
+
formatMessageContents({ type, key, tokens = [], actionTokens = [], preserveName = false, }) {
|
|
434
|
+
const label = (0, kit_1.upperFirst)(type);
|
|
435
|
+
const labelRegExp = new RegExp(`${label}$`);
|
|
436
|
+
const searchValue = type === 'error' ? /^error.*\./ : new RegExp(`^${type}.`);
|
|
445
437
|
// Convert key to name:
|
|
446
|
-
// 'myMessage' -> `
|
|
438
|
+
// 'myMessage' -> `MyMessageWarning`
|
|
447
439
|
// 'myMessageError' -> `MyMessageError`
|
|
448
|
-
// '
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
let errActions;
|
|
440
|
+
// 'warning.myMessage' -> `MyMessageWarning`
|
|
441
|
+
const name = `${(0, kit_1.upperFirst)(key.replace(searchValue, ''))}${labelRegExp.exec(key) || preserveName ? '' : label}`;
|
|
442
|
+
const message = this.getMessage(key, tokens);
|
|
443
|
+
let actions;
|
|
453
444
|
try {
|
|
454
|
-
|
|
445
|
+
actions = this.getMessageWithMap(`${key}.actions`, actionTokens, this.messages);
|
|
455
446
|
}
|
|
456
447
|
catch (e) {
|
|
457
448
|
/* just ignore if actions aren't found */
|
|
458
449
|
}
|
|
459
|
-
return
|
|
450
|
+
return { message, name, actions };
|
|
460
451
|
}
|
|
461
452
|
getMessageWithMap(key, tokens = [], map) {
|
|
462
453
|
// Allow nested keys for better grouping
|
|
@@ -470,12 +461,12 @@ class Messages {
|
|
|
470
461
|
return this.getMessageWithMap(childKey, tokens, childMap);
|
|
471
462
|
}
|
|
472
463
|
}
|
|
473
|
-
|
|
464
|
+
const msg = map.get(key);
|
|
465
|
+
if (!msg) {
|
|
474
466
|
// Don't use messages inside messages
|
|
475
467
|
throw new kit_1.NamedError('MissingMessageError', `Missing message ${this.bundleName}:${key} for locale ${Messages.getLocale()}.`);
|
|
476
468
|
}
|
|
477
|
-
const
|
|
478
|
-
const messages = ((0, ts_types_1.isArray)(msg) ? msg : [msg]);
|
|
469
|
+
const messages = (0, kit_1.ensureArray)(msg);
|
|
479
470
|
return messages.map((message) => {
|
|
480
471
|
(0, ts_types_1.ensureString)(message);
|
|
481
472
|
return util.format(message, ...tokens);
|
|
@@ -496,7 +487,6 @@ Messages.bundles = new Map();
|
|
|
496
487
|
* @param filePath read file target.
|
|
497
488
|
* @ignore
|
|
498
489
|
*/
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
};
|
|
490
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
491
|
+
Messages.readFile = (filePath) => require(filePath);
|
|
502
492
|
//# sourceMappingURL=messages.js.map
|
package/lib/org/authInfo.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { AsyncOptionalCreatable } from '@salesforce/kit';
|
|
2
2
|
import { Nullable } from '@salesforce/ts-types';
|
|
3
|
-
import {
|
|
3
|
+
import { JwtOAuth2Config, OAuth2 } from 'jsforce';
|
|
4
4
|
import { Connection } from './connection';
|
|
5
|
-
|
|
6
|
-
privateKey?: string;
|
|
7
|
-
privateKeyFile?: string;
|
|
8
|
-
authCode?: string;
|
|
9
|
-
refreshToken?: string;
|
|
10
|
-
loginUrl?: string;
|
|
11
|
-
};
|
|
5
|
+
import { Org } from './org';
|
|
12
6
|
/**
|
|
13
7
|
* Fields for authorization, org, and local information.
|
|
14
8
|
*/
|
|
15
|
-
export
|
|
9
|
+
export type AuthFields = {
|
|
16
10
|
accessToken?: string;
|
|
17
11
|
alias?: string;
|
|
18
12
|
authCode?: string;
|
|
@@ -37,8 +31,15 @@ export declare type AuthFields = {
|
|
|
37
31
|
usernames?: string[];
|
|
38
32
|
userProfileName?: string;
|
|
39
33
|
expirationDate?: string;
|
|
34
|
+
tracksSource?: boolean;
|
|
35
|
+
[Org.Fields.NAME]?: string;
|
|
36
|
+
[Org.Fields.INSTANCE_NAME]?: string;
|
|
37
|
+
[Org.Fields.NAMESPACE_PREFIX]?: Nullable<string>;
|
|
38
|
+
[Org.Fields.IS_SANDBOX]?: boolean;
|
|
39
|
+
[Org.Fields.IS_SCRATCH]?: boolean;
|
|
40
|
+
[Org.Fields.TRIAL_EXPIRATION_DATE]?: Nullable<string>;
|
|
40
41
|
};
|
|
41
|
-
export
|
|
42
|
+
export type OrgAuthorization = {
|
|
42
43
|
orgId: string;
|
|
43
44
|
username: string;
|
|
44
45
|
oauthMethod: 'jwt' | 'web' | 'token' | 'unknown';
|
|
@@ -46,6 +47,7 @@ export declare type OrgAuthorization = {
|
|
|
46
47
|
configs: Nullable<string[]>;
|
|
47
48
|
isScratchOrg?: boolean;
|
|
48
49
|
isDevHub?: boolean;
|
|
50
|
+
isSandbox?: boolean;
|
|
49
51
|
instanceUrl?: string;
|
|
50
52
|
accessToken?: string;
|
|
51
53
|
error?: string;
|
|
@@ -59,18 +61,24 @@ export interface AccessTokenOptions {
|
|
|
59
61
|
loginUrl?: string;
|
|
60
62
|
instanceUrl?: string;
|
|
61
63
|
}
|
|
64
|
+
export type AuthSideEffects = {
|
|
65
|
+
alias?: string;
|
|
66
|
+
setDefault: boolean;
|
|
67
|
+
setDefaultDevHub: boolean;
|
|
68
|
+
setTracksSource?: boolean;
|
|
69
|
+
};
|
|
62
70
|
/**
|
|
63
71
|
* A function to update a refresh token when the access token is expired.
|
|
64
72
|
*/
|
|
65
|
-
export
|
|
73
|
+
export type RefreshFn = (conn: Connection, callback: (err: Nullable<Error>, accessToken?: string, res?: Record<string, unknown>) => Promise<void>) => Promise<void>;
|
|
66
74
|
/**
|
|
67
75
|
* Options for {@link Connection}.
|
|
68
76
|
*/
|
|
69
|
-
export
|
|
77
|
+
export type ConnectionOptions = AuthFields & {
|
|
70
78
|
/**
|
|
71
79
|
* OAuth options.
|
|
72
80
|
*/
|
|
73
|
-
oauth2?: Partial<
|
|
81
|
+
oauth2?: Partial<JwtOAuth2Config>;
|
|
74
82
|
/**
|
|
75
83
|
* Refresh token callback.
|
|
76
84
|
*/
|
|
@@ -78,8 +86,7 @@ export declare type ConnectionOptions = AuthFields & {
|
|
|
78
86
|
};
|
|
79
87
|
export declare const DEFAULT_CONNECTED_APP_INFO: {
|
|
80
88
|
clientId: string;
|
|
81
|
-
|
|
82
|
-
legacyClientSecret: string;
|
|
89
|
+
clientSecret: string;
|
|
83
90
|
};
|
|
84
91
|
/**
|
|
85
92
|
* Handles persistence and fetching of user authentication information using
|
|
@@ -118,7 +125,7 @@ export declare const DEFAULT_CONNECTED_APP_INFO: {
|
|
|
118
125
|
export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
|
|
119
126
|
private usingAccessToken;
|
|
120
127
|
private logger;
|
|
121
|
-
private
|
|
128
|
+
private stateAggregator;
|
|
122
129
|
private username;
|
|
123
130
|
private options;
|
|
124
131
|
/**
|
|
@@ -153,7 +160,7 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
|
|
|
153
160
|
*
|
|
154
161
|
* @param options The options to generate the URL.
|
|
155
162
|
*/
|
|
156
|
-
static getAuthorizationUrl(options:
|
|
163
|
+
static getAuthorizationUrl(options: JwtOAuth2Config & {
|
|
157
164
|
scope?: string;
|
|
158
165
|
}, oauth2?: OAuth2): string;
|
|
159
166
|
/**
|
|
@@ -166,6 +173,19 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
|
|
|
166
173
|
* @param sfdxAuthUrl
|
|
167
174
|
*/
|
|
168
175
|
static parseSfdxAuthUrl(sfdxAuthUrl: string): Pick<AuthFields, 'clientId' | 'clientSecret' | 'refreshToken' | 'loginUrl'>;
|
|
176
|
+
/**
|
|
177
|
+
* Given a set of decrypted fields and an authInfo, determine if the org belongs to an available
|
|
178
|
+
* dev hub.
|
|
179
|
+
*
|
|
180
|
+
* @param fields
|
|
181
|
+
* @param orgAuthInfo
|
|
182
|
+
*/
|
|
183
|
+
static identifyPossibleScratchOrgs(fields: AuthFields, orgAuthInfo: AuthInfo): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Find all dev hubs available in the local environment.
|
|
186
|
+
*/
|
|
187
|
+
static getDevHubAuthInfos(): Promise<OrgAuthorization[]>;
|
|
188
|
+
private static queryScratchOrg;
|
|
169
189
|
/**
|
|
170
190
|
* Get the username.
|
|
171
191
|
*/
|
|
@@ -225,6 +245,14 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
|
|
|
225
245
|
* **See** [SFDX Authorization](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_auth.htm#cli_reference_force_auth)
|
|
226
246
|
*/
|
|
227
247
|
getSfdxAuthUrl(): string;
|
|
248
|
+
/**
|
|
249
|
+
* Convenience function to handle typical side effects encountered when dealing with an AuthInfo.
|
|
250
|
+
* Given the values supplied in parameter sideEffects, this function will set auth alias, default auth
|
|
251
|
+
* and default dev hub.
|
|
252
|
+
*
|
|
253
|
+
* @param sideEffects - instance of AuthSideEffects
|
|
254
|
+
*/
|
|
255
|
+
handleAliasAndDefaultSettings(sideEffects: AuthSideEffects): Promise<void>;
|
|
228
256
|
/**
|
|
229
257
|
* Set the target-env (default) or the target-dev-hub to the alias if
|
|
230
258
|
* it exists otherwise to the username. Method will try to set the local
|
|
@@ -253,14 +281,16 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
|
|
|
253
281
|
*
|
|
254
282
|
* @param options Options to be used for creating an OAuth2 instance.
|
|
255
283
|
*
|
|
256
|
-
* **Throws** *{@link
|
|
284
|
+
* **Throws** *{@link SfError}{ name: 'NamedOrgNotFoundError' }* Org information does not exist.
|
|
257
285
|
* @returns {Promise<AuthInfo>}
|
|
258
286
|
*/
|
|
259
287
|
private initAuthOptions;
|
|
260
288
|
private loadDecryptedAuthFromConfig;
|
|
261
289
|
private isTokenOptions;
|
|
262
290
|
private refreshFn;
|
|
263
|
-
private
|
|
291
|
+
private readJwtKey;
|
|
292
|
+
private authJwt;
|
|
293
|
+
private tryJwtAuth;
|
|
264
294
|
private buildRefreshTokenConfig;
|
|
265
295
|
/**
|
|
266
296
|
* Performs an authCode exchange but the Oauth2 feature of jsforce is extended to include a code_challenge
|
|
@@ -277,6 +307,12 @@ export declare class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
|
|
|
277
307
|
* @private
|
|
278
308
|
*/
|
|
279
309
|
private throwUserGetException;
|
|
310
|
+
/**
|
|
311
|
+
* Returns `true` if the org is a Dev Hub.
|
|
312
|
+
*
|
|
313
|
+
* Check access to the ScratchOrgInfo object to determine if the org is a dev hub.
|
|
314
|
+
*/
|
|
315
|
+
private determineIfDevHub;
|
|
280
316
|
}
|
|
281
317
|
export declare namespace AuthInfo {
|
|
282
318
|
/**
|
|
@@ -290,7 +326,7 @@ export declare namespace AuthInfo {
|
|
|
290
326
|
/**
|
|
291
327
|
* OAuth options.
|
|
292
328
|
*/
|
|
293
|
-
oauth2Options?:
|
|
329
|
+
oauth2Options?: JwtOAuth2Config;
|
|
294
330
|
/**
|
|
295
331
|
* Options for the access token auth.
|
|
296
332
|
*/
|