@salesforce/core 3.30.14 → 3.31.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.
Files changed (153) hide show
  1. package/LICENSE.txt +11 -11
  2. package/README.md +222 -227
  3. package/lib/config/aliasesConfig.d.ts +12 -12
  4. package/lib/config/aliasesConfig.js +27 -27
  5. package/lib/config/authInfoConfig.d.ts +19 -19
  6. package/lib/config/authInfoConfig.js +34 -34
  7. package/lib/config/config.d.ts +311 -311
  8. package/lib/config/config.js +574 -574
  9. package/lib/config/configAggregator.d.ts +232 -232
  10. package/lib/config/configAggregator.js +379 -379
  11. package/lib/config/configFile.d.ts +199 -199
  12. package/lib/config/configFile.js +340 -340
  13. package/lib/config/configGroup.d.ts +141 -141
  14. package/lib/config/configGroup.js +224 -224
  15. package/lib/config/configStore.d.ts +241 -241
  16. package/lib/config/configStore.js +352 -352
  17. package/lib/config/envVars.d.ts +101 -101
  18. package/lib/config/envVars.js +456 -456
  19. package/lib/config/orgUsersConfig.d.ts +31 -31
  20. package/lib/config/orgUsersConfig.js +41 -41
  21. package/lib/config/sandboxOrgConfig.d.ts +37 -37
  22. package/lib/config/sandboxOrgConfig.js +50 -50
  23. package/lib/config/sandboxProcessCache.d.ts +16 -16
  24. package/lib/config/sandboxProcessCache.js +37 -37
  25. package/lib/config/tokensConfig.d.ts +10 -10
  26. package/lib/config/tokensConfig.js +28 -28
  27. package/lib/config/ttlConfig.d.ts +34 -34
  28. package/lib/config/ttlConfig.js +54 -54
  29. package/lib/crypto/crypto.d.ts +54 -54
  30. package/lib/crypto/crypto.js +220 -220
  31. package/lib/crypto/keyChain.d.ts +8 -8
  32. package/lib/crypto/keyChain.js +61 -61
  33. package/lib/crypto/keyChainImpl.d.ts +116 -116
  34. package/lib/crypto/keyChainImpl.js +486 -486
  35. package/lib/crypto/secureBuffer.d.ts +46 -46
  36. package/lib/crypto/secureBuffer.js +82 -82
  37. package/lib/deviceOauthService.d.ts +71 -71
  38. package/lib/deviceOauthService.js +191 -191
  39. package/lib/exported.d.ts +38 -38
  40. package/lib/exported.js +118 -118
  41. package/lib/global.d.ts +70 -70
  42. package/lib/global.js +109 -109
  43. package/lib/lifecycleEvents.d.ts +93 -93
  44. package/lib/lifecycleEvents.js +188 -188
  45. package/lib/logger.d.ts +381 -381
  46. package/lib/logger.js +734 -734
  47. package/lib/messages.d.ts +291 -291
  48. package/lib/messages.js +543 -543
  49. package/lib/org/authInfo.d.ts +344 -344
  50. package/lib/org/authInfo.js +892 -892
  51. package/lib/org/authRemover.d.ts +88 -88
  52. package/lib/org/authRemover.js +182 -182
  53. package/lib/org/connection.d.ts +197 -197
  54. package/lib/org/connection.js +395 -395
  55. package/lib/org/index.d.ts +6 -6
  56. package/lib/org/index.js +28 -28
  57. package/lib/org/org.d.ts +558 -558
  58. package/lib/org/org.js +1267 -1267
  59. package/lib/org/orgConfigProperties.d.ts +69 -69
  60. package/lib/org/orgConfigProperties.js +136 -136
  61. package/lib/org/permissionSetAssignment.d.ts +35 -35
  62. package/lib/org/permissionSetAssignment.js +125 -125
  63. package/lib/org/scratchOrgCache.d.ts +20 -20
  64. package/lib/org/scratchOrgCache.js +32 -32
  65. package/lib/org/scratchOrgCreate.d.ts +54 -54
  66. package/lib/org/scratchOrgCreate.js +216 -216
  67. package/lib/org/scratchOrgErrorCodes.d.ts +10 -10
  68. package/lib/org/scratchOrgErrorCodes.js +88 -88
  69. package/lib/org/scratchOrgFeatureDeprecation.d.ts +26 -26
  70. package/lib/org/scratchOrgFeatureDeprecation.js +109 -109
  71. package/lib/org/scratchOrgInfoApi.d.ts +68 -68
  72. package/lib/org/scratchOrgInfoApi.js +413 -413
  73. package/lib/org/scratchOrgInfoGenerator.d.ts +64 -64
  74. package/lib/org/scratchOrgInfoGenerator.js +241 -241
  75. package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -10
  76. package/lib/org/scratchOrgLifecycleEvents.js +40 -40
  77. package/lib/org/scratchOrgSettingsGenerator.d.ts +78 -78
  78. package/lib/org/scratchOrgSettingsGenerator.js +276 -276
  79. package/lib/org/scratchOrgTypes.d.ts +43 -43
  80. package/lib/org/scratchOrgTypes.js +8 -8
  81. package/lib/org/user.d.ts +187 -187
  82. package/lib/org/user.js +448 -448
  83. package/lib/schema/printer.d.ts +79 -79
  84. package/lib/schema/printer.js +260 -260
  85. package/lib/schema/validator.d.ts +70 -70
  86. package/lib/schema/validator.js +169 -169
  87. package/lib/sfError.d.ts +73 -73
  88. package/lib/sfError.js +136 -136
  89. package/lib/sfProject.d.ts +357 -357
  90. package/lib/sfProject.js +671 -671
  91. package/lib/stateAggregator/accessors/aliasAccessor.d.ts +98 -98
  92. package/lib/stateAggregator/accessors/aliasAccessor.js +145 -145
  93. package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -101
  94. package/lib/stateAggregator/accessors/orgAccessor.js +240 -240
  95. package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -8
  96. package/lib/stateAggregator/accessors/sandboxAccessor.js +27 -27
  97. package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -63
  98. package/lib/stateAggregator/accessors/tokenAccessor.js +79 -79
  99. package/lib/stateAggregator/index.d.ts +4 -4
  100. package/lib/stateAggregator/index.js +26 -26
  101. package/lib/stateAggregator/stateAggregator.d.ts +25 -25
  102. package/lib/stateAggregator/stateAggregator.js +45 -45
  103. package/lib/status/myDomainResolver.d.ts +66 -66
  104. package/lib/status/myDomainResolver.js +124 -124
  105. package/lib/status/pollingClient.d.ts +85 -85
  106. package/lib/status/pollingClient.js +115 -115
  107. package/lib/status/streamingClient.d.ts +244 -244
  108. package/lib/status/streamingClient.js +436 -436
  109. package/lib/status/types.d.ts +89 -89
  110. package/lib/status/types.js +17 -17
  111. package/lib/testSetup.d.ts +553 -530
  112. package/lib/testSetup.js +871 -727
  113. package/lib/util/cache.d.ts +11 -11
  114. package/lib/util/cache.js +69 -69
  115. package/lib/util/checkLightningDomain.d.ts +1 -1
  116. package/lib/util/checkLightningDomain.js +28 -28
  117. package/lib/util/directoryWriter.d.ts +12 -12
  118. package/lib/util/directoryWriter.js +53 -53
  119. package/lib/util/getJwtAudienceUrl.d.ts +4 -4
  120. package/lib/util/getJwtAudienceUrl.js +18 -18
  121. package/lib/util/internal.d.ts +58 -58
  122. package/lib/util/internal.js +118 -118
  123. package/lib/util/jsonXmlTools.d.ts +14 -14
  124. package/lib/util/jsonXmlTools.js +38 -38
  125. package/lib/util/mapKeys.d.ts +14 -14
  126. package/lib/util/mapKeys.js +51 -51
  127. package/lib/util/sfdc.d.ts +52 -52
  128. package/lib/util/sfdc.js +85 -85
  129. package/lib/util/sfdcUrl.d.ts +72 -72
  130. package/lib/util/sfdcUrl.js +215 -215
  131. package/lib/util/structuredWriter.d.ts +9 -9
  132. package/lib/util/structuredWriter.js +2 -2
  133. package/lib/util/zipWriter.d.ts +16 -16
  134. package/lib/util/zipWriter.js +67 -67
  135. package/lib/webOAuthServer.d.ts +156 -156
  136. package/lib/webOAuthServer.js +388 -388
  137. package/messages/auth.md +37 -37
  138. package/messages/config.md +156 -156
  139. package/messages/connection.md +30 -30
  140. package/messages/core.json +20 -20
  141. package/messages/core.md +67 -67
  142. package/messages/encryption.md +85 -85
  143. package/messages/envVars.md +303 -303
  144. package/messages/org.md +63 -63
  145. package/messages/permissionSetAssignment.md +31 -31
  146. package/messages/scratchOrgCreate.md +23 -23
  147. package/messages/scratchOrgErrorCodes.md +115 -115
  148. package/messages/scratchOrgFeatureDeprecation.md +11 -11
  149. package/messages/scratchOrgInfoApi.md +15 -15
  150. package/messages/scratchOrgInfoGenerator.md +23 -23
  151. package/messages/streaming.md +23 -23
  152. package/messages/user.md +35 -35
  153. package/package.json +97 -97
package/lib/messages.d.ts CHANGED
@@ -1,291 +1,291 @@
1
- import { AnyJson } from '@salesforce/ts-types';
2
- import { SfError } from './sfError';
3
- export declare type Tokens = Array<string | boolean | number | null | undefined>;
4
- export declare type StructuredMessage = {
5
- message: string;
6
- name: string;
7
- actions?: string[];
8
- };
9
- /**
10
- * A loader function to return messages.
11
- *
12
- * @param locale The local set by the framework.
13
- */
14
- export declare type LoaderFunction<T extends string> = (locale: string) => Messages<T>;
15
- export declare type StoredMessage = string | string[] | {
16
- [s: string]: StoredMessage;
17
- };
18
- export declare type StoredMessageMap = Map<string, StoredMessage>;
19
- /**
20
- * The core message framework manages messages and allows them to be accessible by
21
- * all plugins and consumers of sfdx-core. It is set up to handle localization down
22
- * the road at no additional effort to the consumer. Messages can be used for
23
- * anything from user output (like the console), to error messages, to returned
24
- * data from a method.
25
- *
26
- * Messages are loaded from loader functions. The loader functions will only run
27
- * when a message is required. This prevents all messages from being loaded into memory at
28
- * application startup. The functions can load from memory, a file, or a server.
29
- *
30
- * In the beginning of your app or file, add the loader functions to be used later. If using
31
- * json or js files in a root messages directory (`<moduleRoot>/messages`), load the entire directory
32
- * automatically with {@link Messages.importMessagesDirectory}. Message files must be the following formates.
33
- *
34
- * A `.json` file:
35
- * ```json
36
- * {
37
- * "msgKey": "A message displayed in the user",
38
- * "msgGroup": {
39
- * "anotherMsgKey": "Another message displayed to the user"
40
- * },
41
- * "listOfMessage": ["message1", "message2"]
42
- * }
43
- * ```
44
- *
45
- * A `.js` file:
46
- * ```javascript
47
- * module.exports = {
48
- * msgKey: 'A message displayed in the user',
49
- * msgGroup: {
50
- * anotherMsgKey: 'Another message displayed to the user'
51
- * },
52
- * listOfMessage: ['message1', 'message2']
53
- * }
54
- * ```
55
- *
56
- * A `.md` file:
57
- * ```markdown
58
- * # msgKey
59
- * A message displayed in the user
60
- *
61
- * # msgGroup.anotherMsgKey
62
- * Another message displayed to the user
63
- *
64
- * # listOfMessage
65
- * - message1
66
- * - message2
67
- * ```
68
- *
69
- * The values support [util.format](https://nodejs.org/api/util.html#util_util_format_format_args) style strings
70
- * that apply the tokens passed into {@link Message.getMessage}
71
- *
72
- * **Note:** When running unit tests individually, you may see errors that the messages aren't found.
73
- * This is because `index.js` isn't loaded when tests run like they are when the package is required.
74
- * To allow tests to run, import the message directory in each test (it will only
75
- * do it once) or load the message file the test depends on individually.
76
- *
77
- * ```typescript
78
- * // Create loader functions for all files in the messages directory
79
- * Messages.importMessagesDirectory(__dirname);
80
- *
81
- * // Now you can use the messages from anywhere in your code or file.
82
- * // If using importMessageDirectory, the bundle name is the file name.
83
- * const messages: Messages = Messages.load(packageName, bundleName);
84
- *
85
- * // Messages now contains all the message in the bundleName file.
86
- * messages.getMessage('authInfoCreationError');
87
- * ```
88
- */
89
- export declare class Messages<T extends string> {
90
- private messages;
91
- private static loaders;
92
- private static bundles;
93
- /**
94
- * The locale of the messages in this bundle.
95
- */
96
- readonly locale: string;
97
- /**
98
- * The bundle name.
99
- */
100
- readonly bundleName: string;
101
- /**
102
- * Create a new messages bundle.
103
- *
104
- * **Note:** Use {Messages.load} unless you are writing your own loader function.
105
- *
106
- * @param bundleName The bundle name.
107
- * @param locale The locale.
108
- * @param messages The messages. Can not be modified once created.
109
- */
110
- constructor(bundleName: string, locale: string, messages: StoredMessageMap);
111
- /**
112
- * Internal readFile. Exposed for unit testing. Do not use util/fs.readFile as messages.js
113
- * should have no internal dependencies.
114
- *
115
- * @param filePath read file target.
116
- * @ignore
117
- */
118
- static readFile: (filePath: string) => AnyJson;
119
- /**
120
- * Get the locale. This will always return 'en_US' but will return the
121
- * machine's locale in the future.
122
- */
123
- static getLocale(): string;
124
- /**
125
- * Set a custom loader function for a package and bundle that will be called on {@link Messages.load}.
126
- *
127
- * @param packageName The npm package name.
128
- * @param bundle The name of the bundle.
129
- * @param loader The loader function.
130
- */
131
- static setLoaderFunction(packageName: string, bundle: string, loader: LoaderFunction<string>): void;
132
- /**
133
- * Generate a file loading function. Use {@link Messages.importMessageFile} unless
134
- * overriding the bundleName is required, then manually pass the loader
135
- * function to {@link Messages.setLoaderFunction}.
136
- *
137
- * @param bundleName The name of the bundle.
138
- * @param filePath The messages file path.
139
- */
140
- static generateFileLoaderFunction(bundleName: string, filePath: string): LoaderFunction<string>;
141
- /**
142
- * Add a single message file to the list of loading functions using the file name as the bundle name.
143
- * The loader will only be added if the bundle name is not already taken.
144
- *
145
- * @param packageName The npm package name.
146
- * @param filePath The path of the file.
147
- */
148
- static importMessageFile(packageName: string, filePath: string): void;
149
- /**
150
- * Import all json and js files in a messages directory. Use the file name as the bundle key when
151
- * {@link Messages.load} is called. By default, we're assuming the moduleDirectoryPart is a
152
- * typescript project and will truncate to root path (where the package.json file is). If your messages
153
- * directory is in another spot or you are not using typescript, pass in false for truncateToProjectPath.
154
- *
155
- * ```
156
- * // e.g. If your message directory is in the project root, you would do:
157
- * Messages.importMessagesDirectory(__dirname);
158
- * ```
159
- *
160
- * @param moduleDirectoryPath The path to load the messages folder.
161
- * @param truncateToProjectPath Will look for the messages directory in the project root (where the package.json file is located).
162
- * i.e., the module is typescript and the messages folder is in the top level of the module directory.
163
- * @param packageName The npm package name. Figured out from the root directory's package.json.
164
- */
165
- static importMessagesDirectory(moduleDirectoryPath: string, truncateToProjectPath?: boolean, packageName?: string): void;
166
- /**
167
- * Load messages for a given package and bundle. If the bundle is not already cached, use the loader function
168
- * created from {@link Messages.setLoaderFunction} or {@link Messages.importMessagesDirectory}.
169
- *
170
- * **NOTE: Use {@link Messages.load} instead for safe message validation and usage.**
171
- *
172
- * ```typescript
173
- * Messages.importMessagesDirectory(__dirname);
174
- * const messages = Messages.load('packageName', 'bundleName');
175
- * ```
176
- *
177
- * @param packageName The name of the npm package.
178
- * @param bundleName The name of the bundle to load.
179
- */
180
- static loadMessages(packageName: string, bundleName: string): Messages<string>;
181
- /**
182
- * Load messages for a given package and bundle. If the bundle is not already cached, use the loader function
183
- * created from {@link Messages.setLoaderFunction} or {@link Messages.importMessagesDirectory}.
184
- *
185
- * The message keys that will be used must be passed in for validation. This prevents runtime errors if messages are used but not defined.
186
- *
187
- * **NOTE: This should be defined at the top of the file so validation is done at load time rather than runtime.**
188
- *
189
- * ```typescript
190
- * Messages.importMessagesDirectory(__dirname);
191
- * const messages = Messages.load('packageName', 'bundleName', [
192
- * 'messageKey1',
193
- * 'messageKey2',
194
- * ]);
195
- * ```
196
- *
197
- * @param packageName The name of the npm package.
198
- * @param bundleName The name of the bundle to load.
199
- * @param keys The message keys that will be used.
200
- */
201
- static load<T extends string>(packageName: string, bundleName: string, keys: [T, ...T[]]): Messages<T>;
202
- /**
203
- * Check if a bundle already been loaded.
204
- *
205
- * @param packageName The npm package name.
206
- * @param bundleName The bundle name.
207
- */
208
- static isCached(packageName: string, bundleName: string): boolean;
209
- /**
210
- * Get a message using a message key and use the tokens as values for tokenization.
211
- *
212
- * If the key happens to be an array of messages, it will combine with OS.EOL.
213
- *
214
- * @param key The key of the message.
215
- * @param tokens The values to substitute in the message.
216
- *
217
- * **See** https://nodejs.org/api/util.html#util_util_format_format_args
218
- */
219
- getMessage(key: T, tokens?: Tokens): string;
220
- /**
221
- * Get messages using a message key and use the tokens as values for tokenization.
222
- *
223
- * This will return all messages if the key is an array in the messages file.
224
- *
225
- * ```json
226
- * {
227
- * "myKey": [ "message1", "message2" ]
228
- * }
229
- * ```
230
- *
231
- * ```markdown
232
- * # myKey
233
- * * message1
234
- * * message2
235
- * ```
236
- *
237
- * @param key The key of the messages.
238
- * @param tokens The values to substitute in the message.
239
- *
240
- * **See** https://nodejs.org/api/util.html#util_util_format_format_args
241
- */
242
- getMessages(key: T, tokens?: Tokens): string[];
243
- /**
244
- * Convenience method to create errors using message labels.
245
- *
246
- * `error.name` will be the upper-cased key, remove prefixed `error.` and will always end in Error.
247
- * `error.actions` will be loaded using `${key}.actions` if available.
248
- *
249
- * @param key The key of the error message.
250
- * @param tokens The error message tokens.
251
- * @param actionTokens The action messages tokens.
252
- * @param exitCodeOrCause The exit code which will be used by SfdxCommand or the underlying error that caused this error to be raised.
253
- * @param cause The underlying error that caused this error to be raised.
254
- */
255
- createError(key: T, tokens?: Tokens, actionTokens?: Tokens, exitCodeOrCause?: number | Error, cause?: Error): SfError;
256
- /**
257
- * Convenience method to create warning using message labels.
258
- *
259
- * `warning.name` will be the upper-cased key, remove prefixed `warning.` and will always end in Warning.
260
- * `warning.actions` will be loaded using `${key}.actions` if available.
261
- *
262
- * @param key The key of the warning message.
263
- * @param tokens The warning message tokens.
264
- * @param actionTokens The action messages tokens.
265
- */
266
- createWarning(key: T, tokens?: Tokens, actionTokens?: Tokens): StructuredMessage;
267
- /**
268
- * Convenience method to create info using message labels.
269
- *
270
- * `info.name` will be the upper-cased key, remove prefixed `info.` and will always end in Info.
271
- * `info.actions` will be loaded using `${key}.actions` if available.
272
- *
273
- * @param key The key of the warning message.
274
- * @param tokens The warning message tokens.
275
- * @param actionTokens The action messages tokens.
276
- */
277
- createInfo(key: T, tokens?: Tokens, actionTokens?: Tokens): StructuredMessage;
278
- /**
279
- * Formats message contents given a message type, key, tokens and actions tokens
280
- *
281
- * `<type>.name` will be the upper-cased key, remove prefixed `<type>.` and will always end in 'Error | Warning | Info.
282
- * `<type>.actions` will be loaded using `${key}.actions` if available.
283
- *
284
- * @param type The type of the message set must 'error' | 'warning' | 'info'.
285
- * @param key The key of the warning message.
286
- * @param tokens The warning message tokens.
287
- * @param actionTokens The action messages tokens.
288
- */
289
- private formatMessageContents;
290
- private getMessageWithMap;
291
- }
1
+ import { AnyJson } from '@salesforce/ts-types';
2
+ import { SfError } from './sfError';
3
+ export declare type Tokens = Array<string | boolean | number | null | undefined>;
4
+ export declare type StructuredMessage = {
5
+ message: string;
6
+ name: string;
7
+ actions?: string[];
8
+ };
9
+ /**
10
+ * A loader function to return messages.
11
+ *
12
+ * @param locale The local set by the framework.
13
+ */
14
+ export declare type LoaderFunction<T extends string> = (locale: string) => Messages<T>;
15
+ export declare type StoredMessage = string | string[] | {
16
+ [s: string]: StoredMessage;
17
+ };
18
+ export declare type StoredMessageMap = Map<string, StoredMessage>;
19
+ /**
20
+ * The core message framework manages messages and allows them to be accessible by
21
+ * all plugins and consumers of sfdx-core. It is set up to handle localization down
22
+ * the road at no additional effort to the consumer. Messages can be used for
23
+ * anything from user output (like the console), to error messages, to returned
24
+ * data from a method.
25
+ *
26
+ * Messages are loaded from loader functions. The loader functions will only run
27
+ * when a message is required. This prevents all messages from being loaded into memory at
28
+ * application startup. The functions can load from memory, a file, or a server.
29
+ *
30
+ * In the beginning of your app or file, add the loader functions to be used later. If using
31
+ * json or js files in a root messages directory (`<moduleRoot>/messages`), load the entire directory
32
+ * automatically with {@link Messages.importMessagesDirectory}. Message files must be the following formates.
33
+ *
34
+ * A `.json` file:
35
+ * ```json
36
+ * {
37
+ * "msgKey": "A message displayed in the user",
38
+ * "msgGroup": {
39
+ * "anotherMsgKey": "Another message displayed to the user"
40
+ * },
41
+ * "listOfMessage": ["message1", "message2"]
42
+ * }
43
+ * ```
44
+ *
45
+ * A `.js` file:
46
+ * ```javascript
47
+ * module.exports = {
48
+ * msgKey: 'A message displayed in the user',
49
+ * msgGroup: {
50
+ * anotherMsgKey: 'Another message displayed to the user'
51
+ * },
52
+ * listOfMessage: ['message1', 'message2']
53
+ * }
54
+ * ```
55
+ *
56
+ * A `.md` file:
57
+ * ```markdown
58
+ * # msgKey
59
+ * A message displayed in the user
60
+ *
61
+ * # msgGroup.anotherMsgKey
62
+ * Another message displayed to the user
63
+ *
64
+ * # listOfMessage
65
+ * - message1
66
+ * - message2
67
+ * ```
68
+ *
69
+ * The values support [util.format](https://nodejs.org/api/util.html#util_util_format_format_args) style strings
70
+ * that apply the tokens passed into {@link Message.getMessage}
71
+ *
72
+ * **Note:** When running unit tests individually, you may see errors that the messages aren't found.
73
+ * This is because `index.js` isn't loaded when tests run like they are when the package is required.
74
+ * To allow tests to run, import the message directory in each test (it will only
75
+ * do it once) or load the message file the test depends on individually.
76
+ *
77
+ * ```typescript
78
+ * // Create loader functions for all files in the messages directory
79
+ * Messages.importMessagesDirectory(__dirname);
80
+ *
81
+ * // Now you can use the messages from anywhere in your code or file.
82
+ * // If using importMessageDirectory, the bundle name is the file name.
83
+ * const messages: Messages = Messages.load(packageName, bundleName);
84
+ *
85
+ * // Messages now contains all the message in the bundleName file.
86
+ * messages.getMessage('authInfoCreationError');
87
+ * ```
88
+ */
89
+ export declare class Messages<T extends string> {
90
+ private messages;
91
+ private static loaders;
92
+ private static bundles;
93
+ /**
94
+ * The locale of the messages in this bundle.
95
+ */
96
+ readonly locale: string;
97
+ /**
98
+ * The bundle name.
99
+ */
100
+ readonly bundleName: string;
101
+ /**
102
+ * Create a new messages bundle.
103
+ *
104
+ * **Note:** Use {Messages.load} unless you are writing your own loader function.
105
+ *
106
+ * @param bundleName The bundle name.
107
+ * @param locale The locale.
108
+ * @param messages The messages. Can not be modified once created.
109
+ */
110
+ constructor(bundleName: string, locale: string, messages: StoredMessageMap);
111
+ /**
112
+ * Internal readFile. Exposed for unit testing. Do not use util/fs.readFile as messages.js
113
+ * should have no internal dependencies.
114
+ *
115
+ * @param filePath read file target.
116
+ * @ignore
117
+ */
118
+ static readFile: (filePath: string) => AnyJson;
119
+ /**
120
+ * Get the locale. This will always return 'en_US' but will return the
121
+ * machine's locale in the future.
122
+ */
123
+ static getLocale(): string;
124
+ /**
125
+ * Set a custom loader function for a package and bundle that will be called on {@link Messages.load}.
126
+ *
127
+ * @param packageName The npm package name.
128
+ * @param bundle The name of the bundle.
129
+ * @param loader The loader function.
130
+ */
131
+ static setLoaderFunction(packageName: string, bundle: string, loader: LoaderFunction<string>): void;
132
+ /**
133
+ * Generate a file loading function. Use {@link Messages.importMessageFile} unless
134
+ * overriding the bundleName is required, then manually pass the loader
135
+ * function to {@link Messages.setLoaderFunction}.
136
+ *
137
+ * @param bundleName The name of the bundle.
138
+ * @param filePath The messages file path.
139
+ */
140
+ static generateFileLoaderFunction(bundleName: string, filePath: string): LoaderFunction<string>;
141
+ /**
142
+ * Add a single message file to the list of loading functions using the file name as the bundle name.
143
+ * The loader will only be added if the bundle name is not already taken.
144
+ *
145
+ * @param packageName The npm package name.
146
+ * @param filePath The path of the file.
147
+ */
148
+ static importMessageFile(packageName: string, filePath: string): void;
149
+ /**
150
+ * Import all json and js files in a messages directory. Use the file name as the bundle key when
151
+ * {@link Messages.load} is called. By default, we're assuming the moduleDirectoryPart is a
152
+ * typescript project and will truncate to root path (where the package.json file is). If your messages
153
+ * directory is in another spot or you are not using typescript, pass in false for truncateToProjectPath.
154
+ *
155
+ * ```
156
+ * // e.g. If your message directory is in the project root, you would do:
157
+ * Messages.importMessagesDirectory(__dirname);
158
+ * ```
159
+ *
160
+ * @param moduleDirectoryPath The path to load the messages folder.
161
+ * @param truncateToProjectPath Will look for the messages directory in the project root (where the package.json file is located).
162
+ * i.e., the module is typescript and the messages folder is in the top level of the module directory.
163
+ * @param packageName The npm package name. Figured out from the root directory's package.json.
164
+ */
165
+ static importMessagesDirectory(moduleDirectoryPath: string, truncateToProjectPath?: boolean, packageName?: string): void;
166
+ /**
167
+ * Load messages for a given package and bundle. If the bundle is not already cached, use the loader function
168
+ * created from {@link Messages.setLoaderFunction} or {@link Messages.importMessagesDirectory}.
169
+ *
170
+ * **NOTE: Use {@link Messages.load} instead for safe message validation and usage.**
171
+ *
172
+ * ```typescript
173
+ * Messages.importMessagesDirectory(__dirname);
174
+ * const messages = Messages.load('packageName', 'bundleName');
175
+ * ```
176
+ *
177
+ * @param packageName The name of the npm package.
178
+ * @param bundleName The name of the bundle to load.
179
+ */
180
+ static loadMessages(packageName: string, bundleName: string): Messages<string>;
181
+ /**
182
+ * Load messages for a given package and bundle. If the bundle is not already cached, use the loader function
183
+ * created from {@link Messages.setLoaderFunction} or {@link Messages.importMessagesDirectory}.
184
+ *
185
+ * The message keys that will be used must be passed in for validation. This prevents runtime errors if messages are used but not defined.
186
+ *
187
+ * **NOTE: This should be defined at the top of the file so validation is done at load time rather than runtime.**
188
+ *
189
+ * ```typescript
190
+ * Messages.importMessagesDirectory(__dirname);
191
+ * const messages = Messages.load('packageName', 'bundleName', [
192
+ * 'messageKey1',
193
+ * 'messageKey2',
194
+ * ]);
195
+ * ```
196
+ *
197
+ * @param packageName The name of the npm package.
198
+ * @param bundleName The name of the bundle to load.
199
+ * @param keys The message keys that will be used.
200
+ */
201
+ static load<T extends string>(packageName: string, bundleName: string, keys: [T, ...T[]]): Messages<T>;
202
+ /**
203
+ * Check if a bundle already been loaded.
204
+ *
205
+ * @param packageName The npm package name.
206
+ * @param bundleName The bundle name.
207
+ */
208
+ static isCached(packageName: string, bundleName: string): boolean;
209
+ /**
210
+ * Get a message using a message key and use the tokens as values for tokenization.
211
+ *
212
+ * If the key happens to be an array of messages, it will combine with OS.EOL.
213
+ *
214
+ * @param key The key of the message.
215
+ * @param tokens The values to substitute in the message.
216
+ *
217
+ * **See** https://nodejs.org/api/util.html#util_util_format_format_args
218
+ */
219
+ getMessage(key: T, tokens?: Tokens): string;
220
+ /**
221
+ * Get messages using a message key and use the tokens as values for tokenization.
222
+ *
223
+ * This will return all messages if the key is an array in the messages file.
224
+ *
225
+ * ```json
226
+ * {
227
+ * "myKey": [ "message1", "message2" ]
228
+ * }
229
+ * ```
230
+ *
231
+ * ```markdown
232
+ * # myKey
233
+ * * message1
234
+ * * message2
235
+ * ```
236
+ *
237
+ * @param key The key of the messages.
238
+ * @param tokens The values to substitute in the message.
239
+ *
240
+ * **See** https://nodejs.org/api/util.html#util_util_format_format_args
241
+ */
242
+ getMessages(key: T, tokens?: Tokens): string[];
243
+ /**
244
+ * Convenience method to create errors using message labels.
245
+ *
246
+ * `error.name` will be the upper-cased key, remove prefixed `error.` and will always end in Error.
247
+ * `error.actions` will be loaded using `${key}.actions` if available.
248
+ *
249
+ * @param key The key of the error message.
250
+ * @param tokens The error message tokens.
251
+ * @param actionTokens The action messages tokens.
252
+ * @param exitCodeOrCause The exit code which will be used by SfdxCommand or the underlying error that caused this error to be raised.
253
+ * @param cause The underlying error that caused this error to be raised.
254
+ */
255
+ createError(key: T, tokens?: Tokens, actionTokens?: Tokens, exitCodeOrCause?: number | Error, cause?: Error): SfError;
256
+ /**
257
+ * Convenience method to create warning using message labels.
258
+ *
259
+ * `warning.name` will be the upper-cased key, remove prefixed `warning.` and will always end in Warning.
260
+ * `warning.actions` will be loaded using `${key}.actions` if available.
261
+ *
262
+ * @param key The key of the warning message.
263
+ * @param tokens The warning message tokens.
264
+ * @param actionTokens The action messages tokens.
265
+ */
266
+ createWarning(key: T, tokens?: Tokens, actionTokens?: Tokens): StructuredMessage;
267
+ /**
268
+ * Convenience method to create info using message labels.
269
+ *
270
+ * `info.name` will be the upper-cased key, remove prefixed `info.` and will always end in Info.
271
+ * `info.actions` will be loaded using `${key}.actions` if available.
272
+ *
273
+ * @param key The key of the warning message.
274
+ * @param tokens The warning message tokens.
275
+ * @param actionTokens The action messages tokens.
276
+ */
277
+ createInfo(key: T, tokens?: Tokens, actionTokens?: Tokens): StructuredMessage;
278
+ /**
279
+ * Formats message contents given a message type, key, tokens and actions tokens
280
+ *
281
+ * `<type>.name` will be the upper-cased key, remove prefixed `<type>.` and will always end in 'Error | Warning | Info.
282
+ * `<type>.actions` will be loaded using `${key}.actions` if available.
283
+ *
284
+ * @param type The type of the message set must 'error' | 'warning' | 'info'.
285
+ * @param key The key of the warning message.
286
+ * @param tokens The warning message tokens.
287
+ * @param actionTokens The action messages tokens.
288
+ */
289
+ private formatMessageContents;
290
+ private getMessageWithMap;
291
+ }