@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/logger.d.ts CHANGED
@@ -1,381 +1,381 @@
1
- /// <reference types="node" />
2
- import { Writable } from 'stream';
3
- /**
4
- * A Bunyan `Serializer` function.
5
- *
6
- * @param input The input to be serialized.
7
- * **See** {@link https://github.com/forcedotcom/node-bunyan#serializers|Bunyan Serializers API}
8
- */
9
- export declare type Serializer = (input: unknown) => unknown;
10
- /**
11
- * A collection of named `Serializer`s.
12
- *
13
- * **See** {@link https://github.com/forcedotcom/node-bunyan#serializers|Bunyan Serializers API}
14
- */
15
- export interface Serializers {
16
- [key: string]: Serializer;
17
- }
18
- /**
19
- * The common set of `Logger` options.
20
- */
21
- export interface LoggerOptions {
22
- /**
23
- * The logger name.
24
- */
25
- name: string;
26
- /**
27
- * The logger format type. Current options include LogFmt or JSON (default).
28
- */
29
- format?: LoggerFormat;
30
- /**
31
- * The logger's serializers.
32
- */
33
- serializers?: Serializers;
34
- /**
35
- * Whether or not to log source file, line, and function information.
36
- */
37
- src?: boolean;
38
- /**
39
- * The desired log level.
40
- */
41
- level?: LoggerLevelValue;
42
- /**
43
- * A stream to write to.
44
- */
45
- stream?: Writable;
46
- /**
47
- * An array of streams to write to.
48
- */
49
- streams?: LoggerStream[];
50
- }
51
- /**
52
- * Standard `Logger` levels.
53
- *
54
- * **See** {@link https://github.com/forcedotcom/node-bunyan#levels|Bunyan Levels}
55
- */
56
- export declare enum LoggerLevel {
57
- TRACE = 10,
58
- DEBUG = 20,
59
- INFO = 30,
60
- WARN = 40,
61
- ERROR = 50,
62
- FATAL = 60
63
- }
64
- /**
65
- * `Logger` format types.
66
- */
67
- export declare enum LoggerFormat {
68
- JSON = 0,
69
- LOGFMT = 1
70
- }
71
- /**
72
- * A Bunyan stream configuration.
73
- *
74
- * @see {@link https://github.com/forcedotcom/node-bunyan#streams|Bunyan Streams}
75
- */
76
- export interface LoggerStream {
77
- [key: string]: any;
78
- /**
79
- * The type of stream -- may be inferred from other properties.
80
- */
81
- type?: string;
82
- /**
83
- * The desired log level for the stream.
84
- */
85
- level?: LoggerLevelValue;
86
- /**
87
- * The stream to write to. Mutually exclusive with `path`.
88
- */
89
- stream?: Writable;
90
- /**
91
- * The name of the stream.
92
- */
93
- name?: string;
94
- /**
95
- * A log file path to write to. Mutually exclusive with `stream`.
96
- */
97
- path?: string;
98
- }
99
- /**
100
- * Any numeric `Logger` level.
101
- */
102
- export declare type LoggerLevelValue = LoggerLevel | number;
103
- /**
104
- * A collection of named `FieldValue`s.
105
- *
106
- * **See** {@link https://github.com/forcedotcom/node-bunyan#log-record-fields|Bunyan Log Record Fields}
107
- */
108
- export interface Fields {
109
- [key: string]: FieldValue;
110
- }
111
- /**
112
- * All possible field value types.
113
- */
114
- export declare type FieldValue = string | number | boolean;
115
- /**
116
- * Log line interface
117
- */
118
- export interface LogLine {
119
- name: string;
120
- hostname: string;
121
- pid: string;
122
- log: string;
123
- level: number;
124
- msg: string;
125
- time: string;
126
- v: number;
127
- }
128
- /**
129
- * A logging abstraction powered by {@link https://github.com/forcedotcom/node-bunyan|Bunyan} that provides both a default
130
- * logger configuration that will log to `sfdx.log`, and a way to create custom loggers based on the same foundation.
131
- *
132
- * ```
133
- * // Gets the root sfdx logger
134
- * const logger = await Logger.root();
135
- *
136
- * // Creates a child logger of the root sfdx logger with custom fields applied
137
- * const childLogger = await Logger.child('myRootChild', {tag: 'value'});
138
- *
139
- * // Creates a custom logger unaffiliated with the root logger
140
- * const myCustomLogger = new Logger('myCustomLogger');
141
- *
142
- * // Creates a child of a custom logger unaffiliated with the root logger with custom fields applied
143
- * const myCustomChildLogger = myCustomLogger.child('myCustomChild', {tag: 'value'});
144
- * ```
145
- * **See** https://github.com/forcedotcom/node-bunyan
146
- *
147
- * **See** https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_log_messages.htm
148
- */
149
- export declare class Logger {
150
- /**
151
- * The name of the root sfdx `Logger`.
152
- */
153
- static readonly ROOT_NAME = "sf";
154
- /**
155
- * The default `LoggerLevel` when constructing new `Logger` instances.
156
- */
157
- static readonly DEFAULT_LEVEL = LoggerLevel.WARN;
158
- /**
159
- * A list of all lower case `LoggerLevel` names.
160
- *
161
- * **See** {@link LoggerLevel}
162
- */
163
- static readonly LEVEL_NAMES: string[];
164
- private static readonly lifecycle;
165
- private static rootLogger?;
166
- /**
167
- * The default rotation period for logs. Example '1d' will rotate logs daily (at midnight).
168
- * See 'period' docs here: https://github.com/forcedotcom/node-bunyan#stream-type-rotating-file
169
- */
170
- readonly logRotationPeriod: string;
171
- /**
172
- * The number of backup rotated log files to keep.
173
- * Example: '3' will have the base sf.log file, and the past 3 (period) log files.
174
- * See 'count' docs here: https://github.com/forcedotcom/node-bunyan#stream-type-rotating-file
175
- */
176
- readonly logRotationCount: number;
177
- /**
178
- * Whether debug is enabled for this Logger.
179
- */
180
- debugEnabled: boolean;
181
- private bunyan;
182
- private readonly format;
183
- /**
184
- * Constructs a new `Logger`.
185
- *
186
- * @param optionsOrName A set of `LoggerOptions` or name to use with the default options.
187
- *
188
- * **Throws** *{@link SfError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
189
- * `Logger`.
190
- */
191
- constructor(optionsOrName: LoggerOptions | string);
192
- /**
193
- * Gets the root logger with the default level, file stream, and DEBUG enabled.
194
- */
195
- static root(): Promise<Logger>;
196
- /**
197
- * Gets the root logger with the default level, file stream, and DEBUG enabled.
198
- */
199
- static getRoot(): Logger;
200
- /**
201
- * Destroys the root `Logger`.
202
- *
203
- * @ignore
204
- */
205
- static destroyRoot(): void;
206
- /**
207
- * Create a child of the root logger, inheriting this instance's configuration such as `level`, `streams`, etc.
208
- *
209
- * @param name The name of the child logger.
210
- * @param fields Additional fields included in all log lines.
211
- */
212
- static child(name: string, fields?: Fields): Promise<Logger>;
213
- /**
214
- * Create a child of the root logger, inheriting this instance's configuration such as `level`, `streams`, etc.
215
- *
216
- * @param name The name of the child logger.
217
- * @param fields Additional fields included in all log lines.
218
- */
219
- static childFromRoot(name: string, fields?: Fields): Logger;
220
- /**
221
- * Gets a numeric `LoggerLevel` value by string name.
222
- *
223
- * @param {string} levelName The level name to convert to a `LoggerLevel` enum value.
224
- *
225
- * **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
226
- * @see {@Link LoggerLevel}
227
- */
228
- static getLevelByName(levelName: string): LoggerLevelValue;
229
- /**
230
- * Adds a stream.
231
- *
232
- * @param stream The stream configuration to add.
233
- * @param defaultLevel The default level of the stream.
234
- */
235
- addStream(stream: LoggerStream, defaultLevel?: LoggerLevelValue): void;
236
- /**
237
- * Adds a file stream to this logger. Resolved or rejected upon completion of the addition.
238
- *
239
- * @param logFile The path to the log file. If it doesn't exist it will be created.
240
- */
241
- addLogFileStream(logFile: string): Promise<void>;
242
- /**
243
- * Adds a file stream to this logger. Resolved or rejected upon completion of the addition.
244
- *
245
- * @param logFile The path to the log file. If it doesn't exist it will be created.
246
- */
247
- addLogFileStreamSync(logFile: string): void;
248
- /**
249
- * Gets the name of this logger.
250
- */
251
- getName(): string;
252
- /**
253
- * Gets the current level of this logger.
254
- */
255
- getLevel(): LoggerLevelValue;
256
- /**
257
- * Set the logging level of all streams for this logger. If a specific `level` is not provided, this method will
258
- * attempt to read it from the environment variable `SFDX_LOG_LEVEL`, and if not found,
259
- * {@link Logger.DEFAULT_LOG_LEVEL} will be used instead. For convenience `this` object is returned.
260
- *
261
- * @param {LoggerLevelValue} [level] The logger level.
262
- *
263
- * **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
264
- * was invalid.
265
- *
266
- * ```
267
- * // Sets the level from the environment or default value
268
- * logger.setLevel()
269
- *
270
- * // Set the level from the INFO enum
271
- * logger.setLevel(LoggerLevel.INFO)
272
- *
273
- * // Sets the level case-insensitively from a string value
274
- * logger.setLevel(Logger.getLevelByName('info'))
275
- * ```
276
- */
277
- setLevel(level?: LoggerLevelValue): Logger;
278
- /**
279
- * Gets the underlying Bunyan logger.
280
- */
281
- getBunyanLogger(): any;
282
- /**
283
- * Compares the requested log level with the current log level. Returns true if
284
- * the requested log level is greater than or equal to the current log level.
285
- *
286
- * @param level The requested log level to compare against the currently set log level.
287
- */
288
- shouldLog(level: LoggerLevelValue): boolean;
289
- /**
290
- * Use in-memory logging for this logger instance instead of any parent streams. Useful for testing.
291
- * For convenience this object is returned.
292
- *
293
- * **WARNING: This cannot be undone for this logger instance.**
294
- */
295
- useMemoryLogging(): Logger;
296
- /**
297
- * Gets an array of log line objects. Each element is an object that corresponds to a log line.
298
- */
299
- getBufferedRecords(): LogLine[];
300
- /**
301
- * Reads a text blob of all the log lines contained in memory or the log file.
302
- */
303
- readLogContentsAsText(): string;
304
- /**
305
- * Adds a filter to be applied to all logged messages.
306
- *
307
- * @param filter A function with signature `(...args: any[]) => any[]` that transforms log message arguments.
308
- */
309
- addFilter(filter: (...args: unknown[]) => unknown): void;
310
- /**
311
- * Close the logger, including any streams, and remove all listeners.
312
- *
313
- * @param fn A function with signature `(stream: LoggerStream) => void` to call for each stream with the stream as an arg.
314
- */
315
- close(fn?: (stream: LoggerStream) => void): void;
316
- /**
317
- * Create a child logger, typically to add a few log record fields. For convenience this object is returned.
318
- *
319
- * @param name The name of the child logger that is emitted w/ log line as `log:<name>`.
320
- * @param fields Additional fields included in all log lines for the child logger.
321
- */
322
- child(name: string, fields?: Fields): Logger;
323
- /**
324
- * Add a field to all log lines for this logger. For convenience `this` object is returned.
325
- *
326
- * @param name The name of the field to add.
327
- * @param value The value of the field to be logged.
328
- */
329
- addField(name: string, value: FieldValue): Logger;
330
- /**
331
- * Logs at `trace` level with filtering applied. For convenience `this` object is returned.
332
- *
333
- * @param args Any number of arguments to be logged.
334
- */
335
- trace(...args: any[]): Logger;
336
- /**
337
- * Logs at `debug` level with filtering applied. For convenience `this` object is returned.
338
- *
339
- * @param args Any number of arguments to be logged.
340
- */
341
- debug(...args: unknown[]): Logger;
342
- /**
343
- * Logs at `debug` level with filtering applied.
344
- *
345
- * @param cb A callback that returns on array objects to be logged.
346
- */
347
- debugCallback(cb: () => unknown[] | string): void;
348
- /**
349
- * Logs at `info` level with filtering applied. For convenience `this` object is returned.
350
- *
351
- * @param args Any number of arguments to be logged.
352
- */
353
- info(...args: unknown[]): Logger;
354
- /**
355
- * Logs at `warn` level with filtering applied. For convenience `this` object is returned.
356
- *
357
- * @param args Any number of arguments to be logged.
358
- */
359
- warn(...args: unknown[]): Logger;
360
- /**
361
- * Logs at `error` level with filtering applied. For convenience `this` object is returned.
362
- *
363
- * @param args Any number of arguments to be logged.
364
- */
365
- error(...args: unknown[]): Logger;
366
- /**
367
- * Logs at `fatal` level with filtering applied. For convenience `this` object is returned.
368
- *
369
- * @param args Any number of arguments to be logged.
370
- */
371
- fatal(...args: unknown[]): Logger;
372
- /**
373
- * Enables logging to stdout when the DEBUG environment variable is used. It uses the logger
374
- * name as the debug name, so you can do DEBUG=<logger-name> to filter the results to your logger.
375
- */
376
- enableDEBUG(): void;
377
- private applyFilters;
378
- private uncaughtExceptionHandler;
379
- private exitHandler;
380
- private createLogFmtFormatterStream;
381
- }
1
+ /// <reference types="node" />
2
+ import { Writable } from 'stream';
3
+ /**
4
+ * A Bunyan `Serializer` function.
5
+ *
6
+ * @param input The input to be serialized.
7
+ * **See** {@link https://github.com/forcedotcom/node-bunyan#serializers|Bunyan Serializers API}
8
+ */
9
+ export declare type Serializer = (input: unknown) => unknown;
10
+ /**
11
+ * A collection of named `Serializer`s.
12
+ *
13
+ * **See** {@link https://github.com/forcedotcom/node-bunyan#serializers|Bunyan Serializers API}
14
+ */
15
+ export interface Serializers {
16
+ [key: string]: Serializer;
17
+ }
18
+ /**
19
+ * The common set of `Logger` options.
20
+ */
21
+ export interface LoggerOptions {
22
+ /**
23
+ * The logger name.
24
+ */
25
+ name: string;
26
+ /**
27
+ * The logger format type. Current options include LogFmt or JSON (default).
28
+ */
29
+ format?: LoggerFormat;
30
+ /**
31
+ * The logger's serializers.
32
+ */
33
+ serializers?: Serializers;
34
+ /**
35
+ * Whether or not to log source file, line, and function information.
36
+ */
37
+ src?: boolean;
38
+ /**
39
+ * The desired log level.
40
+ */
41
+ level?: LoggerLevelValue;
42
+ /**
43
+ * A stream to write to.
44
+ */
45
+ stream?: Writable;
46
+ /**
47
+ * An array of streams to write to.
48
+ */
49
+ streams?: LoggerStream[];
50
+ }
51
+ /**
52
+ * Standard `Logger` levels.
53
+ *
54
+ * **See** {@link https://github.com/forcedotcom/node-bunyan#levels|Bunyan Levels}
55
+ */
56
+ export declare enum LoggerLevel {
57
+ TRACE = 10,
58
+ DEBUG = 20,
59
+ INFO = 30,
60
+ WARN = 40,
61
+ ERROR = 50,
62
+ FATAL = 60
63
+ }
64
+ /**
65
+ * `Logger` format types.
66
+ */
67
+ export declare enum LoggerFormat {
68
+ JSON = 0,
69
+ LOGFMT = 1
70
+ }
71
+ /**
72
+ * A Bunyan stream configuration.
73
+ *
74
+ * @see {@link https://github.com/forcedotcom/node-bunyan#streams|Bunyan Streams}
75
+ */
76
+ export interface LoggerStream {
77
+ [key: string]: any;
78
+ /**
79
+ * The type of stream -- may be inferred from other properties.
80
+ */
81
+ type?: string;
82
+ /**
83
+ * The desired log level for the stream.
84
+ */
85
+ level?: LoggerLevelValue;
86
+ /**
87
+ * The stream to write to. Mutually exclusive with `path`.
88
+ */
89
+ stream?: Writable;
90
+ /**
91
+ * The name of the stream.
92
+ */
93
+ name?: string;
94
+ /**
95
+ * A log file path to write to. Mutually exclusive with `stream`.
96
+ */
97
+ path?: string;
98
+ }
99
+ /**
100
+ * Any numeric `Logger` level.
101
+ */
102
+ export declare type LoggerLevelValue = LoggerLevel | number;
103
+ /**
104
+ * A collection of named `FieldValue`s.
105
+ *
106
+ * **See** {@link https://github.com/forcedotcom/node-bunyan#log-record-fields|Bunyan Log Record Fields}
107
+ */
108
+ export interface Fields {
109
+ [key: string]: FieldValue;
110
+ }
111
+ /**
112
+ * All possible field value types.
113
+ */
114
+ export declare type FieldValue = string | number | boolean;
115
+ /**
116
+ * Log line interface
117
+ */
118
+ export interface LogLine {
119
+ name: string;
120
+ hostname: string;
121
+ pid: string;
122
+ log: string;
123
+ level: number;
124
+ msg: string;
125
+ time: string;
126
+ v: number;
127
+ }
128
+ /**
129
+ * A logging abstraction powered by {@link https://github.com/forcedotcom/node-bunyan|Bunyan} that provides both a default
130
+ * logger configuration that will log to `sfdx.log`, and a way to create custom loggers based on the same foundation.
131
+ *
132
+ * ```
133
+ * // Gets the root sfdx logger
134
+ * const logger = await Logger.root();
135
+ *
136
+ * // Creates a child logger of the root sfdx logger with custom fields applied
137
+ * const childLogger = await Logger.child('myRootChild', {tag: 'value'});
138
+ *
139
+ * // Creates a custom logger unaffiliated with the root logger
140
+ * const myCustomLogger = new Logger('myCustomLogger');
141
+ *
142
+ * // Creates a child of a custom logger unaffiliated with the root logger with custom fields applied
143
+ * const myCustomChildLogger = myCustomLogger.child('myCustomChild', {tag: 'value'});
144
+ * ```
145
+ * **See** https://github.com/forcedotcom/node-bunyan
146
+ *
147
+ * **See** https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_log_messages.htm
148
+ */
149
+ export declare class Logger {
150
+ /**
151
+ * The name of the root sfdx `Logger`.
152
+ */
153
+ static readonly ROOT_NAME = "sf";
154
+ /**
155
+ * The default `LoggerLevel` when constructing new `Logger` instances.
156
+ */
157
+ static readonly DEFAULT_LEVEL = LoggerLevel.WARN;
158
+ /**
159
+ * A list of all lower case `LoggerLevel` names.
160
+ *
161
+ * **See** {@link LoggerLevel}
162
+ */
163
+ static readonly LEVEL_NAMES: string[];
164
+ private static readonly lifecycle;
165
+ private static rootLogger?;
166
+ /**
167
+ * The default rotation period for logs. Example '1d' will rotate logs daily (at midnight).
168
+ * See 'period' docs here: https://github.com/forcedotcom/node-bunyan#stream-type-rotating-file
169
+ */
170
+ readonly logRotationPeriod: string;
171
+ /**
172
+ * The number of backup rotated log files to keep.
173
+ * Example: '3' will have the base sf.log file, and the past 3 (period) log files.
174
+ * See 'count' docs here: https://github.com/forcedotcom/node-bunyan#stream-type-rotating-file
175
+ */
176
+ readonly logRotationCount: number;
177
+ /**
178
+ * Whether debug is enabled for this Logger.
179
+ */
180
+ debugEnabled: boolean;
181
+ private bunyan;
182
+ private readonly format;
183
+ /**
184
+ * Constructs a new `Logger`.
185
+ *
186
+ * @param optionsOrName A set of `LoggerOptions` or name to use with the default options.
187
+ *
188
+ * **Throws** *{@link SfError}{ name: 'RedundantRootLoggerError' }* More than one attempt is made to construct the root
189
+ * `Logger`.
190
+ */
191
+ constructor(optionsOrName: LoggerOptions | string);
192
+ /**
193
+ * Gets the root logger with the default level, file stream, and DEBUG enabled.
194
+ */
195
+ static root(): Promise<Logger>;
196
+ /**
197
+ * Gets the root logger with the default level, file stream, and DEBUG enabled.
198
+ */
199
+ static getRoot(): Logger;
200
+ /**
201
+ * Destroys the root `Logger`.
202
+ *
203
+ * @ignore
204
+ */
205
+ static destroyRoot(): void;
206
+ /**
207
+ * Create a child of the root logger, inheriting this instance's configuration such as `level`, `streams`, etc.
208
+ *
209
+ * @param name The name of the child logger.
210
+ * @param fields Additional fields included in all log lines.
211
+ */
212
+ static child(name: string, fields?: Fields): Promise<Logger>;
213
+ /**
214
+ * Create a child of the root logger, inheriting this instance's configuration such as `level`, `streams`, etc.
215
+ *
216
+ * @param name The name of the child logger.
217
+ * @param fields Additional fields included in all log lines.
218
+ */
219
+ static childFromRoot(name: string, fields?: Fields): Logger;
220
+ /**
221
+ * Gets a numeric `LoggerLevel` value by string name.
222
+ *
223
+ * @param {string} levelName The level name to convert to a `LoggerLevel` enum value.
224
+ *
225
+ * **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* The level name was not case-insensitively recognized as a valid `LoggerLevel` value.
226
+ * @see {@Link LoggerLevel}
227
+ */
228
+ static getLevelByName(levelName: string): LoggerLevelValue;
229
+ /**
230
+ * Adds a stream.
231
+ *
232
+ * @param stream The stream configuration to add.
233
+ * @param defaultLevel The default level of the stream.
234
+ */
235
+ addStream(stream: LoggerStream, defaultLevel?: LoggerLevelValue): void;
236
+ /**
237
+ * Adds a file stream to this logger. Resolved or rejected upon completion of the addition.
238
+ *
239
+ * @param logFile The path to the log file. If it doesn't exist it will be created.
240
+ */
241
+ addLogFileStream(logFile: string): Promise<void>;
242
+ /**
243
+ * Adds a file stream to this logger. Resolved or rejected upon completion of the addition.
244
+ *
245
+ * @param logFile The path to the log file. If it doesn't exist it will be created.
246
+ */
247
+ addLogFileStreamSync(logFile: string): void;
248
+ /**
249
+ * Gets the name of this logger.
250
+ */
251
+ getName(): string;
252
+ /**
253
+ * Gets the current level of this logger.
254
+ */
255
+ getLevel(): LoggerLevelValue;
256
+ /**
257
+ * Set the logging level of all streams for this logger. If a specific `level` is not provided, this method will
258
+ * attempt to read it from the environment variable `SFDX_LOG_LEVEL`, and if not found,
259
+ * {@link Logger.DEFAULT_LOG_LEVEL} will be used instead. For convenience `this` object is returned.
260
+ *
261
+ * @param {LoggerLevelValue} [level] The logger level.
262
+ *
263
+ * **Throws** *{@link SfError}{ name: 'UnrecognizedLoggerLevelNameError' }* A value of `level` read from `SFDX_LOG_LEVEL`
264
+ * was invalid.
265
+ *
266
+ * ```
267
+ * // Sets the level from the environment or default value
268
+ * logger.setLevel()
269
+ *
270
+ * // Set the level from the INFO enum
271
+ * logger.setLevel(LoggerLevel.INFO)
272
+ *
273
+ * // Sets the level case-insensitively from a string value
274
+ * logger.setLevel(Logger.getLevelByName('info'))
275
+ * ```
276
+ */
277
+ setLevel(level?: LoggerLevelValue): Logger;
278
+ /**
279
+ * Gets the underlying Bunyan logger.
280
+ */
281
+ getBunyanLogger(): any;
282
+ /**
283
+ * Compares the requested log level with the current log level. Returns true if
284
+ * the requested log level is greater than or equal to the current log level.
285
+ *
286
+ * @param level The requested log level to compare against the currently set log level.
287
+ */
288
+ shouldLog(level: LoggerLevelValue): boolean;
289
+ /**
290
+ * Use in-memory logging for this logger instance instead of any parent streams. Useful for testing.
291
+ * For convenience this object is returned.
292
+ *
293
+ * **WARNING: This cannot be undone for this logger instance.**
294
+ */
295
+ useMemoryLogging(): Logger;
296
+ /**
297
+ * Gets an array of log line objects. Each element is an object that corresponds to a log line.
298
+ */
299
+ getBufferedRecords(): LogLine[];
300
+ /**
301
+ * Reads a text blob of all the log lines contained in memory or the log file.
302
+ */
303
+ readLogContentsAsText(): string;
304
+ /**
305
+ * Adds a filter to be applied to all logged messages.
306
+ *
307
+ * @param filter A function with signature `(...args: any[]) => any[]` that transforms log message arguments.
308
+ */
309
+ addFilter(filter: (...args: unknown[]) => unknown): void;
310
+ /**
311
+ * Close the logger, including any streams, and remove all listeners.
312
+ *
313
+ * @param fn A function with signature `(stream: LoggerStream) => void` to call for each stream with the stream as an arg.
314
+ */
315
+ close(fn?: (stream: LoggerStream) => void): void;
316
+ /**
317
+ * Create a child logger, typically to add a few log record fields. For convenience this object is returned.
318
+ *
319
+ * @param name The name of the child logger that is emitted w/ log line as `log:<name>`.
320
+ * @param fields Additional fields included in all log lines for the child logger.
321
+ */
322
+ child(name: string, fields?: Fields): Logger;
323
+ /**
324
+ * Add a field to all log lines for this logger. For convenience `this` object is returned.
325
+ *
326
+ * @param name The name of the field to add.
327
+ * @param value The value of the field to be logged.
328
+ */
329
+ addField(name: string, value: FieldValue): Logger;
330
+ /**
331
+ * Logs at `trace` level with filtering applied. For convenience `this` object is returned.
332
+ *
333
+ * @param args Any number of arguments to be logged.
334
+ */
335
+ trace(...args: any[]): Logger;
336
+ /**
337
+ * Logs at `debug` level with filtering applied. For convenience `this` object is returned.
338
+ *
339
+ * @param args Any number of arguments to be logged.
340
+ */
341
+ debug(...args: unknown[]): Logger;
342
+ /**
343
+ * Logs at `debug` level with filtering applied.
344
+ *
345
+ * @param cb A callback that returns on array objects to be logged.
346
+ */
347
+ debugCallback(cb: () => unknown[] | string): void;
348
+ /**
349
+ * Logs at `info` level with filtering applied. For convenience `this` object is returned.
350
+ *
351
+ * @param args Any number of arguments to be logged.
352
+ */
353
+ info(...args: unknown[]): Logger;
354
+ /**
355
+ * Logs at `warn` level with filtering applied. For convenience `this` object is returned.
356
+ *
357
+ * @param args Any number of arguments to be logged.
358
+ */
359
+ warn(...args: unknown[]): Logger;
360
+ /**
361
+ * Logs at `error` level with filtering applied. For convenience `this` object is returned.
362
+ *
363
+ * @param args Any number of arguments to be logged.
364
+ */
365
+ error(...args: unknown[]): Logger;
366
+ /**
367
+ * Logs at `fatal` level with filtering applied. For convenience `this` object is returned.
368
+ *
369
+ * @param args Any number of arguments to be logged.
370
+ */
371
+ fatal(...args: unknown[]): Logger;
372
+ /**
373
+ * Enables logging to stdout when the DEBUG environment variable is used. It uses the logger
374
+ * name as the debug name, so you can do DEBUG=<logger-name> to filter the results to your logger.
375
+ */
376
+ enableDEBUG(): void;
377
+ private applyFilters;
378
+ private uncaughtExceptionHandler;
379
+ private exitHandler;
380
+ private createLogFmtFormatterStream;
381
+ }