@likec4/log 1.8.1 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.d.mts CHANGED
@@ -1,7 +1,126 @@
1
- import * as consola_core from 'consola/core';
2
- export * from 'consola/basic';
3
- export { LogLevels } from 'consola/basic';
1
+ type SelectOption = {
2
+ label: string;
3
+ value: string;
4
+ hint?: string;
5
+ };
6
+ type TextOptions = {
7
+ type?: "text";
8
+ default?: string;
9
+ placeholder?: string;
10
+ initial?: string;
11
+ };
12
+ type ConfirmOptions = {
13
+ type: "confirm";
14
+ initial?: boolean;
15
+ };
16
+ type SelectOptions = {
17
+ type: "select";
18
+ initial?: string;
19
+ options: (string | SelectOption)[];
20
+ };
21
+ type MultiSelectOptions = {
22
+ type: "multiselect";
23
+ initial?: string;
24
+ options: string[] | SelectOption[];
25
+ required?: boolean;
26
+ };
27
+ type PromptOptions = TextOptions | ConfirmOptions | SelectOptions | MultiSelectOptions;
28
+ type inferPromptReturnType<T extends PromptOptions> = T extends TextOptions ? string : T extends ConfirmOptions ? boolean : T extends SelectOptions ? T["options"][number] : T extends MultiSelectOptions ? T["options"] : unknown;
29
+ declare function prompt<_ = any, __ = any, T extends PromptOptions = TextOptions>(message: string, opts?: PromptOptions): Promise<inferPromptReturnType<T>>;
4
30
 
5
- declare const logger: consola_core.ConsolaInstance;
31
+ type LogLevel = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
32
+ declare const LogLevels: Record<LogType, number>;
33
+ type LogType = "silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose";
34
+ declare const LogTypes: Record<LogType, Partial<LogObject>>;
6
35
 
7
- export { logger as consola, logger, logger as rootLogger };
36
+ interface ConsolaOptions {
37
+ reporters: ConsolaReporter[];
38
+ types: Record<LogType, InputLogObject>;
39
+ level: LogLevel;
40
+ defaults: InputLogObject;
41
+ throttle: number;
42
+ throttleMin: number;
43
+ stdout?: NodeJS.WriteStream;
44
+ stderr?: NodeJS.WriteStream;
45
+ mockFn?: (type: LogType, defaults: InputLogObject) => (...args: any) => void;
46
+ prompt?: typeof prompt | undefined;
47
+ formatOptions: FormatOptions;
48
+ }
49
+ /**
50
+ * @see https://nodejs.org/api/util.html#util_util_inspect_object_showhidden_depth_colors
51
+ */
52
+ interface FormatOptions {
53
+ columns?: number;
54
+ date?: boolean;
55
+ colors?: boolean;
56
+ compact?: boolean | number;
57
+ [key: string]: unknown;
58
+ }
59
+ interface InputLogObject {
60
+ level?: LogLevel;
61
+ tag?: string;
62
+ type?: LogType;
63
+ message?: string;
64
+ additional?: string | string[];
65
+ args?: any[];
66
+ date?: Date;
67
+ }
68
+ interface LogObject extends InputLogObject {
69
+ level: LogLevel;
70
+ type: LogType;
71
+ tag: string;
72
+ args: any[];
73
+ date: Date;
74
+ [key: string]: unknown;
75
+ }
76
+ interface ConsolaReporter {
77
+ log: (logObj: LogObject, ctx: {
78
+ options: ConsolaOptions;
79
+ }) => void;
80
+ }
81
+
82
+ declare class Consola {
83
+ options: ConsolaOptions;
84
+ _lastLog: {
85
+ serialized?: string;
86
+ object?: LogObject;
87
+ count?: number;
88
+ time?: Date;
89
+ timeout?: ReturnType<typeof setTimeout>;
90
+ };
91
+ _mockFn?: ConsolaOptions["mockFn"];
92
+ constructor(options?: Partial<ConsolaOptions>);
93
+ get level(): LogLevel;
94
+ set level(level: LogLevel);
95
+ prompt<T extends PromptOptions>(message: string, opts?: T): Promise<T extends TextOptions ? string : T extends ConfirmOptions ? boolean : T extends SelectOptions ? T["options"][number] : T extends MultiSelectOptions ? T["options"] : unknown>;
96
+ create(options: Partial<ConsolaOptions>): ConsolaInstance;
97
+ withDefaults(defaults: InputLogObject): ConsolaInstance;
98
+ withTag(tag: string): ConsolaInstance;
99
+ addReporter(reporter: ConsolaReporter): this;
100
+ removeReporter(reporter: ConsolaReporter): ConsolaReporter[] | this;
101
+ setReporters(reporters: ConsolaReporter[]): this;
102
+ wrapAll(): void;
103
+ restoreAll(): void;
104
+ wrapConsole(): void;
105
+ restoreConsole(): void;
106
+ wrapStd(): void;
107
+ _wrapStream(stream: NodeJS.WriteStream | undefined, type: LogType): void;
108
+ restoreStd(): void;
109
+ _restoreStream(stream?: NodeJS.WriteStream): void;
110
+ pauseLogs(): void;
111
+ resumeLogs(): void;
112
+ mockTypes(mockFn?: ConsolaOptions["mockFn"]): void;
113
+ _wrapLogFn(defaults: InputLogObject, isRaw?: boolean): (...args: any[]) => false | undefined;
114
+ _logFn(defaults: InputLogObject, args: any[], isRaw?: boolean): false | undefined;
115
+ _log(logObj: LogObject): void;
116
+ }
117
+ interface LogFn {
118
+ (message: InputLogObject | any, ...args: any[]): void;
119
+ raw: (...args: any[]) => void;
120
+ }
121
+ type ConsolaInstance = Consola & Record<LogType, LogFn>;
122
+ declare function createConsola(options?: Partial<ConsolaOptions>): ConsolaInstance;
123
+
124
+ declare const logger: ConsolaInstance;
125
+
126
+ export { Consola, type ConsolaInstance, type ConsolaOptions, type ConsolaReporter, type FormatOptions, type InputLogObject, type LogLevel, LogLevels, type LogObject, type LogType, LogTypes, logger as consola, createConsola, logger, logger as rootLogger };
package/dist/node.d.ts CHANGED
@@ -1,7 +1,126 @@
1
- import * as consola_core from 'consola/core';
2
- export * from 'consola/basic';
3
- export { LogLevels } from 'consola/basic';
1
+ type SelectOption = {
2
+ label: string;
3
+ value: string;
4
+ hint?: string;
5
+ };
6
+ type TextOptions = {
7
+ type?: "text";
8
+ default?: string;
9
+ placeholder?: string;
10
+ initial?: string;
11
+ };
12
+ type ConfirmOptions = {
13
+ type: "confirm";
14
+ initial?: boolean;
15
+ };
16
+ type SelectOptions = {
17
+ type: "select";
18
+ initial?: string;
19
+ options: (string | SelectOption)[];
20
+ };
21
+ type MultiSelectOptions = {
22
+ type: "multiselect";
23
+ initial?: string;
24
+ options: string[] | SelectOption[];
25
+ required?: boolean;
26
+ };
27
+ type PromptOptions = TextOptions | ConfirmOptions | SelectOptions | MultiSelectOptions;
28
+ type inferPromptReturnType<T extends PromptOptions> = T extends TextOptions ? string : T extends ConfirmOptions ? boolean : T extends SelectOptions ? T["options"][number] : T extends MultiSelectOptions ? T["options"] : unknown;
29
+ declare function prompt<_ = any, __ = any, T extends PromptOptions = TextOptions>(message: string, opts?: PromptOptions): Promise<inferPromptReturnType<T>>;
4
30
 
5
- declare const logger: consola_core.ConsolaInstance;
31
+ type LogLevel = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
32
+ declare const LogLevels: Record<LogType, number>;
33
+ type LogType = "silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose";
34
+ declare const LogTypes: Record<LogType, Partial<LogObject>>;
6
35
 
7
- export { logger as consola, logger, logger as rootLogger };
36
+ interface ConsolaOptions {
37
+ reporters: ConsolaReporter[];
38
+ types: Record<LogType, InputLogObject>;
39
+ level: LogLevel;
40
+ defaults: InputLogObject;
41
+ throttle: number;
42
+ throttleMin: number;
43
+ stdout?: NodeJS.WriteStream;
44
+ stderr?: NodeJS.WriteStream;
45
+ mockFn?: (type: LogType, defaults: InputLogObject) => (...args: any) => void;
46
+ prompt?: typeof prompt | undefined;
47
+ formatOptions: FormatOptions;
48
+ }
49
+ /**
50
+ * @see https://nodejs.org/api/util.html#util_util_inspect_object_showhidden_depth_colors
51
+ */
52
+ interface FormatOptions {
53
+ columns?: number;
54
+ date?: boolean;
55
+ colors?: boolean;
56
+ compact?: boolean | number;
57
+ [key: string]: unknown;
58
+ }
59
+ interface InputLogObject {
60
+ level?: LogLevel;
61
+ tag?: string;
62
+ type?: LogType;
63
+ message?: string;
64
+ additional?: string | string[];
65
+ args?: any[];
66
+ date?: Date;
67
+ }
68
+ interface LogObject extends InputLogObject {
69
+ level: LogLevel;
70
+ type: LogType;
71
+ tag: string;
72
+ args: any[];
73
+ date: Date;
74
+ [key: string]: unknown;
75
+ }
76
+ interface ConsolaReporter {
77
+ log: (logObj: LogObject, ctx: {
78
+ options: ConsolaOptions;
79
+ }) => void;
80
+ }
81
+
82
+ declare class Consola {
83
+ options: ConsolaOptions;
84
+ _lastLog: {
85
+ serialized?: string;
86
+ object?: LogObject;
87
+ count?: number;
88
+ time?: Date;
89
+ timeout?: ReturnType<typeof setTimeout>;
90
+ };
91
+ _mockFn?: ConsolaOptions["mockFn"];
92
+ constructor(options?: Partial<ConsolaOptions>);
93
+ get level(): LogLevel;
94
+ set level(level: LogLevel);
95
+ prompt<T extends PromptOptions>(message: string, opts?: T): Promise<T extends TextOptions ? string : T extends ConfirmOptions ? boolean : T extends SelectOptions ? T["options"][number] : T extends MultiSelectOptions ? T["options"] : unknown>;
96
+ create(options: Partial<ConsolaOptions>): ConsolaInstance;
97
+ withDefaults(defaults: InputLogObject): ConsolaInstance;
98
+ withTag(tag: string): ConsolaInstance;
99
+ addReporter(reporter: ConsolaReporter): this;
100
+ removeReporter(reporter: ConsolaReporter): ConsolaReporter[] | this;
101
+ setReporters(reporters: ConsolaReporter[]): this;
102
+ wrapAll(): void;
103
+ restoreAll(): void;
104
+ wrapConsole(): void;
105
+ restoreConsole(): void;
106
+ wrapStd(): void;
107
+ _wrapStream(stream: NodeJS.WriteStream | undefined, type: LogType): void;
108
+ restoreStd(): void;
109
+ _restoreStream(stream?: NodeJS.WriteStream): void;
110
+ pauseLogs(): void;
111
+ resumeLogs(): void;
112
+ mockTypes(mockFn?: ConsolaOptions["mockFn"]): void;
113
+ _wrapLogFn(defaults: InputLogObject, isRaw?: boolean): (...args: any[]) => false | undefined;
114
+ _logFn(defaults: InputLogObject, args: any[], isRaw?: boolean): false | undefined;
115
+ _log(logObj: LogObject): void;
116
+ }
117
+ interface LogFn {
118
+ (message: InputLogObject | any, ...args: any[]): void;
119
+ raw: (...args: any[]) => void;
120
+ }
121
+ type ConsolaInstance = Consola & Record<LogType, LogFn>;
122
+ declare function createConsola(options?: Partial<ConsolaOptions>): ConsolaInstance;
123
+
124
+ declare const logger: ConsolaInstance;
125
+
126
+ export { Consola, type ConsolaInstance, type ConsolaOptions, type ConsolaReporter, type FormatOptions, type InputLogObject, type LogLevel, LogLevels, type LogObject, type LogType, LogTypes, logger as consola, createConsola, logger, logger as rootLogger };