@guren/server 0.2.0-alpha.7 → 1.0.0-rc.9
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/Application-DtWDHXr1.d.ts +2110 -0
- package/dist/BroadcastManager-AkIWUGJo.d.ts +466 -0
- package/dist/CacheManager-BkvHEOZX.d.ts +244 -0
- package/dist/ConsoleKernel-CqCVrdZs.d.ts +207 -0
- package/dist/EventManager-CmIoLt7r.d.ts +207 -0
- package/dist/Gate-CNkBYf8m.d.ts +268 -0
- package/dist/HealthManager-DUyMIzsZ.d.ts +141 -0
- package/dist/I18nManager-Dtgzsf5n.d.ts +270 -0
- package/dist/LogManager-7mxnkaPM.d.ts +256 -0
- package/dist/MailManager-DpMvYiP9.d.ts +292 -0
- package/dist/Scheduler-BstvSca7.d.ts +469 -0
- package/dist/StorageManager-oZTHqaza.d.ts +337 -0
- package/dist/api-token-JOif2CtG.d.ts +1792 -0
- package/dist/app-key-CsBfRC_Q.d.ts +214 -0
- package/dist/auth/index.d.ts +418 -0
- package/dist/auth/index.js +6742 -0
- package/dist/authorization/index.d.ts +129 -0
- package/dist/authorization/index.js +621 -0
- package/dist/broadcasting/index.d.ts +233 -0
- package/dist/broadcasting/index.js +907 -0
- package/dist/cache/index.d.ts +233 -0
- package/dist/cache/index.js +817 -0
- package/dist/encryption/index.d.ts +222 -0
- package/dist/encryption/index.js +602 -0
- package/dist/events/index.d.ts +155 -0
- package/dist/events/index.js +330 -0
- package/dist/health/index.d.ts +185 -0
- package/dist/health/index.js +379 -0
- package/dist/i18n/index.d.ts +101 -0
- package/dist/i18n/index.js +597 -0
- package/dist/index-9_Jzj5jo.d.ts +7 -0
- package/dist/index.d.ts +2628 -619
- package/dist/index.js +22229 -3116
- package/dist/lambda/index.d.ts +156 -0
- package/dist/lambda/index.js +91 -0
- package/dist/logging/index.d.ts +50 -0
- package/dist/logging/index.js +557 -0
- package/dist/mail/index.d.ts +288 -0
- package/dist/mail/index.js +695 -0
- package/dist/mcp/index.d.ts +139 -0
- package/dist/mcp/index.js +382 -0
- package/dist/notifications/index.d.ts +271 -0
- package/dist/notifications/index.js +741 -0
- package/dist/queue/index.d.ts +423 -0
- package/dist/queue/index.js +958 -0
- package/dist/runtime/index.d.ts +93 -0
- package/dist/runtime/index.js +834 -0
- package/dist/scheduling/index.d.ts +41 -0
- package/dist/scheduling/index.js +836 -0
- package/dist/storage/index.d.ts +196 -0
- package/dist/storage/index.js +832 -0
- package/dist/vite/index.js +203 -3
- package/package.json +93 -6
- package/dist/chunk-FK2XQSBF.js +0 -160
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { M as Middleware } from './index-9_Jzj5jo.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Health check status.
|
|
5
|
+
*/
|
|
6
|
+
type HealthStatus = 'healthy' | 'degraded' | 'unhealthy';
|
|
7
|
+
/**
|
|
8
|
+
* Result of a single health check.
|
|
9
|
+
*/
|
|
10
|
+
interface CheckResult {
|
|
11
|
+
name: string;
|
|
12
|
+
status: HealthStatus;
|
|
13
|
+
message?: string;
|
|
14
|
+
meta?: Record<string, unknown>;
|
|
15
|
+
duration: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Complete health report.
|
|
19
|
+
*/
|
|
20
|
+
interface HealthReport {
|
|
21
|
+
status: HealthStatus;
|
|
22
|
+
timestamp: Date;
|
|
23
|
+
checks: CheckResult[];
|
|
24
|
+
meta?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for registering a health check.
|
|
28
|
+
*/
|
|
29
|
+
interface HealthCheckOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Timeout in milliseconds for the check.
|
|
32
|
+
* @default 5000
|
|
33
|
+
*/
|
|
34
|
+
timeout?: number;
|
|
35
|
+
/**
|
|
36
|
+
* If true, failure of this check will set overall status to unhealthy.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
critical?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Options for health middleware.
|
|
43
|
+
*/
|
|
44
|
+
interface HealthMiddlewareOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Only run these specific checks.
|
|
47
|
+
*/
|
|
48
|
+
checks?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Include detailed check results.
|
|
51
|
+
* @default true
|
|
52
|
+
*/
|
|
53
|
+
detailed?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Abstract base class for health checks.
|
|
58
|
+
*/
|
|
59
|
+
declare abstract class HealthCheck {
|
|
60
|
+
/**
|
|
61
|
+
* The name of this health check.
|
|
62
|
+
*/
|
|
63
|
+
abstract readonly name: string;
|
|
64
|
+
/**
|
|
65
|
+
* Perform the health check.
|
|
66
|
+
*/
|
|
67
|
+
abstract check(): Promise<CheckResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Create a healthy result.
|
|
70
|
+
*/
|
|
71
|
+
protected healthy(message?: string, meta?: Record<string, unknown>): CheckResult;
|
|
72
|
+
/**
|
|
73
|
+
* Create a degraded result.
|
|
74
|
+
*/
|
|
75
|
+
protected degraded(message?: string, meta?: Record<string, unknown>): CheckResult;
|
|
76
|
+
/**
|
|
77
|
+
* Create an unhealthy result.
|
|
78
|
+
*/
|
|
79
|
+
protected unhealthy(message?: string, meta?: Record<string, unknown>): CheckResult;
|
|
80
|
+
/**
|
|
81
|
+
* Create an unhealthy result from a caught error.
|
|
82
|
+
*/
|
|
83
|
+
protected handleError(error: unknown, fallbackMessage: string): CheckResult;
|
|
84
|
+
/**
|
|
85
|
+
* Create a check result.
|
|
86
|
+
*/
|
|
87
|
+
private result;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Health check manager.
|
|
92
|
+
*/
|
|
93
|
+
declare class HealthManager {
|
|
94
|
+
private checks;
|
|
95
|
+
/**
|
|
96
|
+
* Register a health check.
|
|
97
|
+
*/
|
|
98
|
+
register(check: HealthCheck, options?: HealthCheckOptions): this;
|
|
99
|
+
/**
|
|
100
|
+
* Unregister a health check.
|
|
101
|
+
*/
|
|
102
|
+
unregister(name: string): this;
|
|
103
|
+
/**
|
|
104
|
+
* Get all registered check names.
|
|
105
|
+
*/
|
|
106
|
+
getCheckNames(): string[];
|
|
107
|
+
/**
|
|
108
|
+
* Run all health checks.
|
|
109
|
+
*/
|
|
110
|
+
check(): Promise<HealthReport>;
|
|
111
|
+
/**
|
|
112
|
+
* Run specific health checks.
|
|
113
|
+
*/
|
|
114
|
+
checkOnly(names: string[]): Promise<HealthReport>;
|
|
115
|
+
/**
|
|
116
|
+
* Get a specific check result.
|
|
117
|
+
*/
|
|
118
|
+
getCheck(name: string): Promise<CheckResult | null>;
|
|
119
|
+
/**
|
|
120
|
+
* Create middleware for health endpoints.
|
|
121
|
+
*/
|
|
122
|
+
middleware(options?: HealthMiddlewareOptions): Middleware;
|
|
123
|
+
/**
|
|
124
|
+
* Run the specified checks.
|
|
125
|
+
*/
|
|
126
|
+
private runChecks;
|
|
127
|
+
/**
|
|
128
|
+
* Run a single check with timeout.
|
|
129
|
+
*/
|
|
130
|
+
private runCheck;
|
|
131
|
+
/**
|
|
132
|
+
* Create a timeout promise.
|
|
133
|
+
*/
|
|
134
|
+
private timeoutPromise;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create a health manager.
|
|
138
|
+
*/
|
|
139
|
+
declare function createHealthManager(): HealthManager;
|
|
140
|
+
|
|
141
|
+
export { type CheckResult as C, HealthManager as H, HealthCheck as a, type HealthCheckOptions as b, type HealthMiddlewareOptions as c, type HealthReport as d, type HealthStatus as e, createHealthManager as f };
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation messages type - nested object structure.
|
|
3
|
+
*/
|
|
4
|
+
type TranslationMessages = {
|
|
5
|
+
[key: string]: string | TranslationMessages;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Replacement values for interpolation.
|
|
9
|
+
*/
|
|
10
|
+
type ReplacementValues = Record<string, string | number>;
|
|
11
|
+
/**
|
|
12
|
+
* Pluralization rule function.
|
|
13
|
+
*/
|
|
14
|
+
type PluralizationRule = (count: number) => number;
|
|
15
|
+
/**
|
|
16
|
+
* Translation loader interface.
|
|
17
|
+
*/
|
|
18
|
+
interface TranslationLoader {
|
|
19
|
+
/**
|
|
20
|
+
* Load translations for a locale.
|
|
21
|
+
*/
|
|
22
|
+
load(locale: string): Promise<TranslationMessages>;
|
|
23
|
+
/**
|
|
24
|
+
* Load translations for a specific namespace.
|
|
25
|
+
*/
|
|
26
|
+
loadNamespace?(locale: string, namespace: string): Promise<TranslationMessages>;
|
|
27
|
+
/**
|
|
28
|
+
* Get available locales.
|
|
29
|
+
*/
|
|
30
|
+
getAvailableLocales?(): Promise<string[]>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Translator options.
|
|
34
|
+
*/
|
|
35
|
+
interface TranslatorOptions {
|
|
36
|
+
/**
|
|
37
|
+
* Default locale.
|
|
38
|
+
*/
|
|
39
|
+
locale: string;
|
|
40
|
+
/**
|
|
41
|
+
* Fallback locale when translation is missing.
|
|
42
|
+
*/
|
|
43
|
+
fallbackLocale?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Translation loader.
|
|
46
|
+
*/
|
|
47
|
+
loader?: TranslationLoader;
|
|
48
|
+
/**
|
|
49
|
+
* Preloaded messages.
|
|
50
|
+
*/
|
|
51
|
+
messages?: Record<string, TranslationMessages>;
|
|
52
|
+
/**
|
|
53
|
+
* Custom pluralization rules per locale.
|
|
54
|
+
*/
|
|
55
|
+
pluralizationRules?: Record<string, PluralizationRule>;
|
|
56
|
+
/**
|
|
57
|
+
* Missing key handler.
|
|
58
|
+
*/
|
|
59
|
+
onMissingKey?: (key: string, locale: string) => string | undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* I18n manager configuration.
|
|
63
|
+
*/
|
|
64
|
+
interface I18nConfig {
|
|
65
|
+
/**
|
|
66
|
+
* Default locale.
|
|
67
|
+
*/
|
|
68
|
+
locale: string;
|
|
69
|
+
/**
|
|
70
|
+
* Fallback locale.
|
|
71
|
+
*/
|
|
72
|
+
fallbackLocale?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Path to translation files.
|
|
75
|
+
*/
|
|
76
|
+
path?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Preloaded messages.
|
|
79
|
+
*/
|
|
80
|
+
messages?: Record<string, TranslationMessages>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Translation loader factory.
|
|
84
|
+
*/
|
|
85
|
+
type TranslationLoaderFactory = () => TranslationLoader;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Translator class for handling translations.
|
|
89
|
+
*/
|
|
90
|
+
declare class Translator {
|
|
91
|
+
private locale;
|
|
92
|
+
private fallbackLocale;
|
|
93
|
+
private messages;
|
|
94
|
+
private pluralizationRules;
|
|
95
|
+
private onMissingKey?;
|
|
96
|
+
constructor(options: TranslatorOptions);
|
|
97
|
+
/**
|
|
98
|
+
* Translate a key.
|
|
99
|
+
*/
|
|
100
|
+
t(key: string, replacements?: ReplacementValues): string;
|
|
101
|
+
/**
|
|
102
|
+
* Translate a key with count for pluralization.
|
|
103
|
+
*/
|
|
104
|
+
tc(key: string, count: number, replacements?: ReplacementValues): string;
|
|
105
|
+
/**
|
|
106
|
+
* Check if a translation exists.
|
|
107
|
+
*/
|
|
108
|
+
has(key: string, locale?: string): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Get the current locale.
|
|
111
|
+
*/
|
|
112
|
+
getLocale(): string;
|
|
113
|
+
/**
|
|
114
|
+
* Set the current locale.
|
|
115
|
+
*/
|
|
116
|
+
setLocale(locale: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Get the fallback locale.
|
|
119
|
+
*/
|
|
120
|
+
getFallbackLocale(): string | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Set the fallback locale.
|
|
123
|
+
*/
|
|
124
|
+
setFallbackLocale(locale: string | undefined): void;
|
|
125
|
+
/**
|
|
126
|
+
* Add messages for a locale.
|
|
127
|
+
*/
|
|
128
|
+
addMessages(locale: string, messages: TranslationMessages): void;
|
|
129
|
+
/**
|
|
130
|
+
* Set messages for a locale (replaces existing).
|
|
131
|
+
*/
|
|
132
|
+
setMessages(locale: string, messages: TranslationMessages): void;
|
|
133
|
+
/**
|
|
134
|
+
* Get all messages for a locale.
|
|
135
|
+
*/
|
|
136
|
+
getMessages(locale?: string): TranslationMessages;
|
|
137
|
+
/**
|
|
138
|
+
* Get available locales.
|
|
139
|
+
*/
|
|
140
|
+
getAvailableLocales(): string[];
|
|
141
|
+
/**
|
|
142
|
+
* Set a custom pluralization rule.
|
|
143
|
+
*/
|
|
144
|
+
setPluralizationRule(locale: string, rule: PluralizationRule): void;
|
|
145
|
+
/**
|
|
146
|
+
* Internal translate method.
|
|
147
|
+
*/
|
|
148
|
+
private translate;
|
|
149
|
+
/**
|
|
150
|
+
* Get raw translation without replacements.
|
|
151
|
+
*/
|
|
152
|
+
private getRawTranslation;
|
|
153
|
+
/**
|
|
154
|
+
* Apply replacements to a translation string.
|
|
155
|
+
*/
|
|
156
|
+
private applyReplacements;
|
|
157
|
+
/**
|
|
158
|
+
* Handle missing translation key.
|
|
159
|
+
*/
|
|
160
|
+
private handleMissingKey;
|
|
161
|
+
/**
|
|
162
|
+
* Deep merge messages.
|
|
163
|
+
*/
|
|
164
|
+
private mergeMessages;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* I18n manager for handling multiple locales and translators.
|
|
169
|
+
*/
|
|
170
|
+
declare class I18nManager {
|
|
171
|
+
private config;
|
|
172
|
+
private translator;
|
|
173
|
+
private loader;
|
|
174
|
+
private loadedLocales;
|
|
175
|
+
constructor(config: I18nConfig);
|
|
176
|
+
/**
|
|
177
|
+
* Translate a key.
|
|
178
|
+
*/
|
|
179
|
+
t(key: string, replacements?: ReplacementValues): string;
|
|
180
|
+
/**
|
|
181
|
+
* Translate a key with count for pluralization.
|
|
182
|
+
*/
|
|
183
|
+
tc(key: string, count: number, replacements?: ReplacementValues): string;
|
|
184
|
+
/**
|
|
185
|
+
* Check if a translation exists.
|
|
186
|
+
*/
|
|
187
|
+
has(key: string, locale?: string): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Get the current locale.
|
|
190
|
+
*/
|
|
191
|
+
getLocale(): string;
|
|
192
|
+
/**
|
|
193
|
+
* Set the current locale.
|
|
194
|
+
*/
|
|
195
|
+
setLocale(locale: string): void;
|
|
196
|
+
/**
|
|
197
|
+
* Get the fallback locale.
|
|
198
|
+
*/
|
|
199
|
+
getFallbackLocale(): string | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* Set the fallback locale.
|
|
202
|
+
*/
|
|
203
|
+
setFallbackLocale(locale: string | undefined): void;
|
|
204
|
+
/**
|
|
205
|
+
* Load translations for a locale.
|
|
206
|
+
*/
|
|
207
|
+
loadLocale(locale: string): Promise<void>;
|
|
208
|
+
/**
|
|
209
|
+
* Load translations for multiple locales.
|
|
210
|
+
*/
|
|
211
|
+
loadLocales(locales: string[]): Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* Load a specific namespace for a locale.
|
|
214
|
+
*/
|
|
215
|
+
loadNamespace(locale: string, namespace: string): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Add messages for a locale.
|
|
218
|
+
*/
|
|
219
|
+
addMessages(locale: string, messages: TranslationMessages): void;
|
|
220
|
+
/**
|
|
221
|
+
* Get all messages for a locale.
|
|
222
|
+
*/
|
|
223
|
+
getMessages(locale?: string): TranslationMessages;
|
|
224
|
+
/**
|
|
225
|
+
* Get available locales.
|
|
226
|
+
*/
|
|
227
|
+
getAvailableLocales(): string[];
|
|
228
|
+
/**
|
|
229
|
+
* Get available locales from loader.
|
|
230
|
+
*/
|
|
231
|
+
getLoaderLocales(): Promise<string[]>;
|
|
232
|
+
/**
|
|
233
|
+
* Check if a locale is loaded.
|
|
234
|
+
*/
|
|
235
|
+
isLocaleLoaded(locale: string): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Get the underlying translator.
|
|
238
|
+
*/
|
|
239
|
+
getTranslator(): Translator;
|
|
240
|
+
/**
|
|
241
|
+
* Set a custom loader.
|
|
242
|
+
*/
|
|
243
|
+
setLoader(loader: TranslationLoader): void;
|
|
244
|
+
/**
|
|
245
|
+
* Create a scoped translator for a specific locale.
|
|
246
|
+
*/
|
|
247
|
+
forLocale(locale: string): Translator;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Create a new I18n manager.
|
|
251
|
+
*/
|
|
252
|
+
declare function createI18n(config: I18nConfig): I18nManager;
|
|
253
|
+
/**
|
|
254
|
+
* Set the global I18n manager.
|
|
255
|
+
*/
|
|
256
|
+
declare function setI18n(i18n: I18nManager): void;
|
|
257
|
+
/**
|
|
258
|
+
* Get the global I18n manager.
|
|
259
|
+
*/
|
|
260
|
+
declare function getI18n(): I18nManager;
|
|
261
|
+
/**
|
|
262
|
+
* Translate a key using the global I18n manager.
|
|
263
|
+
*/
|
|
264
|
+
declare function t(key: string, replacements?: ReplacementValues): string;
|
|
265
|
+
/**
|
|
266
|
+
* Translate a key with count using the global I18n manager.
|
|
267
|
+
*/
|
|
268
|
+
declare function tc(key: string, count: number, replacements?: ReplacementValues): string;
|
|
269
|
+
|
|
270
|
+
export { I18nManager as I, type PluralizationRule as P, type ReplacementValues as R, type TranslationLoader as T, type I18nConfig as a, type TranslationLoaderFactory as b, type TranslationMessages as c, Translator as d, type TranslatorOptions as e, createI18n as f, getI18n as g, tc as h, setI18n as s, t };
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log level types (RFC 5424 severity levels).
|
|
3
|
+
*/
|
|
4
|
+
type LogLevel = 'emergency' | 'alert' | 'critical' | 'error' | 'warning' | 'notice' | 'info' | 'debug';
|
|
5
|
+
/**
|
|
6
|
+
* Log level priority (lower = more severe).
|
|
7
|
+
*/
|
|
8
|
+
declare const LOG_LEVEL_PRIORITY: Record<LogLevel, number>;
|
|
9
|
+
/**
|
|
10
|
+
* Log context (additional data attached to log entries).
|
|
11
|
+
*/
|
|
12
|
+
type LogContext = Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Log entry structure.
|
|
15
|
+
*/
|
|
16
|
+
interface LogEntry {
|
|
17
|
+
level: LogLevel;
|
|
18
|
+
message: string;
|
|
19
|
+
context: LogContext;
|
|
20
|
+
timestamp: Date;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Log channel interface.
|
|
24
|
+
*/
|
|
25
|
+
interface LogChannel {
|
|
26
|
+
/**
|
|
27
|
+
* Write a log entry.
|
|
28
|
+
*/
|
|
29
|
+
log(entry: LogEntry): void | Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Close the channel (cleanup resources).
|
|
32
|
+
*/
|
|
33
|
+
close?(): void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Log channel factory.
|
|
37
|
+
*/
|
|
38
|
+
type LogChannelFactory = (config: LogChannelConfig) => LogChannel;
|
|
39
|
+
/**
|
|
40
|
+
* Base channel configuration.
|
|
41
|
+
*/
|
|
42
|
+
interface LogChannelConfig {
|
|
43
|
+
driver: string;
|
|
44
|
+
level?: LogLevel;
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Console channel configuration.
|
|
49
|
+
*/
|
|
50
|
+
interface ConsoleChannelConfig extends LogChannelConfig {
|
|
51
|
+
driver: 'console';
|
|
52
|
+
colors?: boolean;
|
|
53
|
+
timestamps?: boolean;
|
|
54
|
+
format?: 'text' | 'json';
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* File channel configuration.
|
|
58
|
+
*/
|
|
59
|
+
interface FileChannelConfig extends LogChannelConfig {
|
|
60
|
+
driver: 'file';
|
|
61
|
+
path: string;
|
|
62
|
+
format?: 'text' | 'json';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Daily file channel configuration.
|
|
66
|
+
*/
|
|
67
|
+
interface DailyFileChannelConfig extends LogChannelConfig {
|
|
68
|
+
driver: 'daily';
|
|
69
|
+
path: string;
|
|
70
|
+
days?: number;
|
|
71
|
+
format?: 'text' | 'json';
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Stack channel configuration.
|
|
75
|
+
*/
|
|
76
|
+
interface StackChannelConfig extends LogChannelConfig {
|
|
77
|
+
driver: 'stack';
|
|
78
|
+
channels: string[];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Log manager configuration.
|
|
82
|
+
*/
|
|
83
|
+
interface LogConfig {
|
|
84
|
+
default: string;
|
|
85
|
+
channels: Record<string, LogChannelConfig>;
|
|
86
|
+
/** Keys whose values are replaced with '[FILTERED]' in log context. */
|
|
87
|
+
filterKeys?: string[];
|
|
88
|
+
/** Replacement string for filtered values. Default: '[FILTERED]' */
|
|
89
|
+
filterReplacement?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Log formatter.
|
|
93
|
+
*/
|
|
94
|
+
interface LogFormatter {
|
|
95
|
+
format(entry: LogEntry): string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
interface LoggerOptions {
|
|
99
|
+
/**
|
|
100
|
+
* Keys whose values should be replaced with the replacement string.
|
|
101
|
+
* Matching is case-insensitive and recursive.
|
|
102
|
+
*/
|
|
103
|
+
filterKeys?: string[];
|
|
104
|
+
/** Replacement string for filtered values. Default: '[FILTERED]' */
|
|
105
|
+
replacement?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Recursively replace values of sensitive keys in a log context object.
|
|
109
|
+
*/
|
|
110
|
+
declare function filterSensitiveData(data: Record<string, unknown>, filterKeys: string[], replacement?: string): Record<string, unknown>;
|
|
111
|
+
/**
|
|
112
|
+
* Logger instance for writing log entries.
|
|
113
|
+
*/
|
|
114
|
+
declare class Logger {
|
|
115
|
+
private readonly channels;
|
|
116
|
+
private readonly baseContext;
|
|
117
|
+
private readonly filterKeys;
|
|
118
|
+
private readonly replacement;
|
|
119
|
+
constructor(channels: LogChannel[], context?: LogContext, options?: LoggerOptions);
|
|
120
|
+
/**
|
|
121
|
+
* Log at emergency level (system is unusable).
|
|
122
|
+
*/
|
|
123
|
+
emergency(message: string, context?: LogContext): void;
|
|
124
|
+
/**
|
|
125
|
+
* Log at alert level (action must be taken immediately).
|
|
126
|
+
*/
|
|
127
|
+
alert(message: string, context?: LogContext): void;
|
|
128
|
+
/**
|
|
129
|
+
* Log at critical level (critical conditions).
|
|
130
|
+
*/
|
|
131
|
+
critical(message: string, context?: LogContext): void;
|
|
132
|
+
/**
|
|
133
|
+
* Log at error level (error conditions).
|
|
134
|
+
*/
|
|
135
|
+
error(message: string, context?: LogContext): void;
|
|
136
|
+
/**
|
|
137
|
+
* Log at warning level (warning conditions).
|
|
138
|
+
*/
|
|
139
|
+
warning(message: string, context?: LogContext): void;
|
|
140
|
+
/**
|
|
141
|
+
* Alias for warning().
|
|
142
|
+
*/
|
|
143
|
+
warn(message: string, context?: LogContext): void;
|
|
144
|
+
/**
|
|
145
|
+
* Log at notice level (normal but significant conditions).
|
|
146
|
+
*/
|
|
147
|
+
notice(message: string, context?: LogContext): void;
|
|
148
|
+
/**
|
|
149
|
+
* Log at info level (informational messages).
|
|
150
|
+
*/
|
|
151
|
+
info(message: string, context?: LogContext): void;
|
|
152
|
+
/**
|
|
153
|
+
* Log at debug level (debug-level messages).
|
|
154
|
+
*/
|
|
155
|
+
debug(message: string, context?: LogContext): void;
|
|
156
|
+
/**
|
|
157
|
+
* Log a message at the specified level.
|
|
158
|
+
*/
|
|
159
|
+
log(level: LogLevel, message: string, context?: LogContext): void;
|
|
160
|
+
/**
|
|
161
|
+
* Create a new logger with additional context.
|
|
162
|
+
*/
|
|
163
|
+
withContext(context: LogContext): Logger;
|
|
164
|
+
/**
|
|
165
|
+
* Create a child logger with additional context (alias for withContext).
|
|
166
|
+
*/
|
|
167
|
+
child(context: LogContext): Logger;
|
|
168
|
+
/**
|
|
169
|
+
* Close all channels.
|
|
170
|
+
*/
|
|
171
|
+
close(): Promise<void>;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Log manager for managing multiple logging channels.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```ts
|
|
179
|
+
* const log = new LogManager({
|
|
180
|
+
* default: 'stack',
|
|
181
|
+
* channels: {
|
|
182
|
+
* console: { driver: 'console', level: 'debug' },
|
|
183
|
+
* file: { driver: 'daily', path: './storage/logs/app.log', days: 14 },
|
|
184
|
+
* stack: { driver: 'stack', channels: ['console', 'file'] },
|
|
185
|
+
* }
|
|
186
|
+
* })
|
|
187
|
+
*
|
|
188
|
+
* log.info('User logged in', { userId: user.id })
|
|
189
|
+
* log.error('Payment failed', { orderId, error: error.message })
|
|
190
|
+
*
|
|
191
|
+
* const requestLog = log.withContext({ requestId: ctx.requestId })
|
|
192
|
+
* requestLog.info('Processing request')
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
declare class LogManager {
|
|
196
|
+
private readonly config;
|
|
197
|
+
private readonly channelFactories;
|
|
198
|
+
private readonly channelInstances;
|
|
199
|
+
private readonly loggers;
|
|
200
|
+
private readonly loggerOptions;
|
|
201
|
+
constructor(config: LogConfig);
|
|
202
|
+
private registerDefaultDrivers;
|
|
203
|
+
private createStackChannel;
|
|
204
|
+
/**
|
|
205
|
+
* Register a custom channel driver.
|
|
206
|
+
*/
|
|
207
|
+
registerDriver(name: string, factory: LogChannelFactory): void;
|
|
208
|
+
/**
|
|
209
|
+
* Get a logger for a specific channel.
|
|
210
|
+
*/
|
|
211
|
+
channel(name?: string): Logger;
|
|
212
|
+
/**
|
|
213
|
+
* Get a logger that writes to multiple channels.
|
|
214
|
+
*/
|
|
215
|
+
stack(channelNames: string[]): Logger;
|
|
216
|
+
private resolveChannel;
|
|
217
|
+
/**
|
|
218
|
+
* Create a logger with additional context using the default channel.
|
|
219
|
+
*/
|
|
220
|
+
withContext(context: Record<string, unknown>): Logger;
|
|
221
|
+
emergency(message: string, context?: Record<string, unknown>): void;
|
|
222
|
+
alert(message: string, context?: Record<string, unknown>): void;
|
|
223
|
+
critical(message: string, context?: Record<string, unknown>): void;
|
|
224
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
225
|
+
warning(message: string, context?: Record<string, unknown>): void;
|
|
226
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
227
|
+
notice(message: string, context?: Record<string, unknown>): void;
|
|
228
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
229
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
230
|
+
/**
|
|
231
|
+
* Close all channel instances.
|
|
232
|
+
*/
|
|
233
|
+
close(): Promise<void>;
|
|
234
|
+
/**
|
|
235
|
+
* Get the default channel name.
|
|
236
|
+
*/
|
|
237
|
+
getDefaultChannel(): string;
|
|
238
|
+
/**
|
|
239
|
+
* Get available channel names.
|
|
240
|
+
*/
|
|
241
|
+
getChannelNames(): string[];
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Create a log manager instance.
|
|
245
|
+
*/
|
|
246
|
+
declare function createLogManager(config: LogConfig): LogManager;
|
|
247
|
+
/**
|
|
248
|
+
* Set the global log manager instance.
|
|
249
|
+
*/
|
|
250
|
+
declare function setLogManager(manager: LogManager): void;
|
|
251
|
+
/**
|
|
252
|
+
* Get the global log manager instance.
|
|
253
|
+
*/
|
|
254
|
+
declare function getLogManager(): LogManager;
|
|
255
|
+
|
|
256
|
+
export { type ConsoleChannelConfig as C, type DailyFileChannelConfig as D, type FileChannelConfig as F, LogManager as L, type StackChannelConfig as S, LOG_LEVEL_PRIORITY as a, type LogChannel as b, type LogChannelConfig as c, type LogChannelFactory as d, type LogConfig as e, type LogContext as f, type LogEntry as g, type LogFormatter as h, type LogLevel as i, Logger as j, type LoggerOptions as k, createLogManager as l, filterSensitiveData as m, getLogManager as n, setLogManager as s };
|