@noxfly/noxus 2.1.1 → 2.3.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/README.md +44 -0
- package/dist/app-injector-B3MvgV3k.d.mts +95 -0
- package/dist/app-injector-B3MvgV3k.d.ts +95 -0
- package/dist/child.d.mts +209 -0
- package/dist/child.d.ts +209 -0
- package/dist/child.js +1426 -0
- package/dist/child.mjs +1356 -0
- package/dist/{index-CI3OMzNR.d.mts → index-BxWQVi6C.d.ts} +3 -68
- package/dist/{index-CI3OMzNR.d.ts → index-DQBQQfMw.d.mts} +3 -68
- package/dist/main.d.mts +6 -193
- package/dist/main.d.ts +6 -193
- package/dist/main.js +69 -5
- package/dist/main.mjs +63 -3
- package/dist/renderer.d.mts +2 -1
- package/dist/renderer.d.ts +2 -1
- package/dist/renderer.js +48 -4
- package/dist/renderer.mjs +47 -3
- package/package.json +6 -1
- package/src/DI/app-injector.ts +51 -10
- package/src/decorators/inject.decorator.ts +24 -0
- package/src/main.ts +2 -0
- package/src/non-electron-process.ts +23 -0
- package/src/utils/forward-ref.ts +31 -0
- package/tsup.config.ts +1 -0
package/README.md
CHANGED
|
@@ -311,6 +311,50 @@ import { MyClass } from 'src/myclass';
|
|
|
311
311
|
const instance: MyClass = inject(MyClass);
|
|
312
312
|
```
|
|
313
313
|
|
|
314
|
+
### Circular Dependencies
|
|
315
|
+
|
|
316
|
+
Noxus solves circular dependencies using a forward reference pattern. When two classes depend on each other, you can use `forwardRef()` combined with either the `@Inject()` decorator or the `inject()` helper to lazily resolve the dependency.
|
|
317
|
+
|
|
318
|
+
**Using Constructor Injection (`@Inject`)**
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
import { Injectable, Inject, forwardRef } from '@noxfly/noxus/main';
|
|
322
|
+
|
|
323
|
+
@Injectable()
|
|
324
|
+
class ServiceA {
|
|
325
|
+
constructor(
|
|
326
|
+
@Inject(forwardRef(() => ServiceB))
|
|
327
|
+
private readonly serviceB: ServiceB
|
|
328
|
+
) {}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
@Injectable()
|
|
332
|
+
class ServiceB {
|
|
333
|
+
constructor(
|
|
334
|
+
private readonly serviceA: ServiceA
|
|
335
|
+
) {}
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**Using Property Injection (`inject`)**
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
import { Injectable, inject, forwardRef } from '@noxfly/noxus/main';
|
|
343
|
+
|
|
344
|
+
@Injectable()
|
|
345
|
+
class ServiceA {
|
|
346
|
+
// Lazily resolves ServiceB, avoiding infinite recursion during instantiation
|
|
347
|
+
private readonly serviceB = inject(forwardRef(() => ServiceB));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
@Injectable()
|
|
351
|
+
class ServiceB {
|
|
352
|
+
private readonly serviceA = inject(ServiceA);
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
In both cases, a `Proxy` is returned, meaning the actual instance is only resolved when you access a property or method on it.
|
|
357
|
+
|
|
314
358
|
### Middlewares
|
|
315
359
|
|
|
316
360
|
Declare middlewares as follow :
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright 2025 NoxFly
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author NoxFly
|
|
5
|
+
*/
|
|
6
|
+
interface Type<T> extends Function {
|
|
7
|
+
new (...args: any[]): T;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represents a generic type that can be either a value or a promise resolving to that value.
|
|
11
|
+
*/
|
|
12
|
+
type MaybeAsync<T> = T | Promise<T>;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A function that returns a type.
|
|
17
|
+
* Used for forward references to types that are not yet defined.
|
|
18
|
+
*/
|
|
19
|
+
interface ForwardRefFn<T = any> {
|
|
20
|
+
(): Type<T>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A wrapper class for forward referenced types.
|
|
24
|
+
*/
|
|
25
|
+
declare class ForwardReference<T = any> {
|
|
26
|
+
readonly forwardRefFn: ForwardRefFn<T>;
|
|
27
|
+
constructor(forwardRefFn: ForwardRefFn<T>);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates a forward reference to a type.
|
|
31
|
+
* @param fn A function that returns the type.
|
|
32
|
+
* @returns A ForwardReference instance.
|
|
33
|
+
*/
|
|
34
|
+
declare function forwardRef<T = any>(fn: ForwardRefFn<T>): ForwardReference<T>;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Represents a lifetime of a binding in the dependency injection system.
|
|
39
|
+
* It can be one of the following:
|
|
40
|
+
* - 'singleton': The instance is created once and shared across the application.
|
|
41
|
+
* - 'scope': The instance is created once per scope (e.g., per request).
|
|
42
|
+
* - 'transient': A new instance is created every time it is requested.
|
|
43
|
+
*/
|
|
44
|
+
type Lifetime = 'singleton' | 'scope' | 'transient';
|
|
45
|
+
/**
|
|
46
|
+
* Represents a binding in the dependency injection system.
|
|
47
|
+
* It contains the lifetime of the binding, the implementation type, and optionally an instance.
|
|
48
|
+
*/
|
|
49
|
+
interface IBinding {
|
|
50
|
+
lifetime: Lifetime;
|
|
51
|
+
implementation: Type<unknown>;
|
|
52
|
+
instance?: InstanceType<Type<unknown>>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* AppInjector is the root dependency injection container.
|
|
56
|
+
* It is used to register and resolve dependencies in the application.
|
|
57
|
+
* It supports different lifetimes for dependencies:
|
|
58
|
+
* This should not be manually instantiated, outside of the framework.
|
|
59
|
+
* Use the `RootInjector` instance instead.
|
|
60
|
+
*/
|
|
61
|
+
declare class AppInjector {
|
|
62
|
+
readonly name: string | null;
|
|
63
|
+
bindings: Map<Type<unknown>, IBinding>;
|
|
64
|
+
singletons: Map<Type<unknown>, unknown>;
|
|
65
|
+
scoped: Map<Type<unknown>, unknown>;
|
|
66
|
+
constructor(name?: string | null);
|
|
67
|
+
/**
|
|
68
|
+
* Typically used to create a dependency injection scope
|
|
69
|
+
* at the "scope" level (i.e., per-request lifetime).
|
|
70
|
+
*
|
|
71
|
+
* SHOULD NOT BE USED by anything else than the framework itself.
|
|
72
|
+
*/
|
|
73
|
+
createScope(): AppInjector;
|
|
74
|
+
/**
|
|
75
|
+
* Called when resolving a dependency,
|
|
76
|
+
* i.e., retrieving the instance of a given class.
|
|
77
|
+
*/
|
|
78
|
+
resolve<T>(target: Type<T> | ForwardReference<T>): T;
|
|
79
|
+
/**
|
|
80
|
+
* Instantiates a class, resolving its dependencies.
|
|
81
|
+
*/
|
|
82
|
+
private instantiate;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Injects a type from the dependency injection system.
|
|
86
|
+
* This function is used to retrieve an instance of a type that has been registered in the dependency injection system.
|
|
87
|
+
* It is typically used in the constructor of a class to inject dependencies.
|
|
88
|
+
* @param t - The type to inject.
|
|
89
|
+
* @returns An instance of the type.
|
|
90
|
+
* @throws If the type is not registered in the dependency injection system.
|
|
91
|
+
*/
|
|
92
|
+
declare function inject<T>(t: Type<T> | ForwardReference<T>): T;
|
|
93
|
+
declare const RootInjector: AppInjector;
|
|
94
|
+
|
|
95
|
+
export { AppInjector as A, type ForwardRefFn as F, type IBinding as I, type Lifetime as L, type MaybeAsync as M, RootInjector as R, type Type as T, ForwardReference as a, forwardRef as f, inject as i };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright 2025 NoxFly
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author NoxFly
|
|
5
|
+
*/
|
|
6
|
+
interface Type<T> extends Function {
|
|
7
|
+
new (...args: any[]): T;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represents a generic type that can be either a value or a promise resolving to that value.
|
|
11
|
+
*/
|
|
12
|
+
type MaybeAsync<T> = T | Promise<T>;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A function that returns a type.
|
|
17
|
+
* Used for forward references to types that are not yet defined.
|
|
18
|
+
*/
|
|
19
|
+
interface ForwardRefFn<T = any> {
|
|
20
|
+
(): Type<T>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A wrapper class for forward referenced types.
|
|
24
|
+
*/
|
|
25
|
+
declare class ForwardReference<T = any> {
|
|
26
|
+
readonly forwardRefFn: ForwardRefFn<T>;
|
|
27
|
+
constructor(forwardRefFn: ForwardRefFn<T>);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates a forward reference to a type.
|
|
31
|
+
* @param fn A function that returns the type.
|
|
32
|
+
* @returns A ForwardReference instance.
|
|
33
|
+
*/
|
|
34
|
+
declare function forwardRef<T = any>(fn: ForwardRefFn<T>): ForwardReference<T>;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Represents a lifetime of a binding in the dependency injection system.
|
|
39
|
+
* It can be one of the following:
|
|
40
|
+
* - 'singleton': The instance is created once and shared across the application.
|
|
41
|
+
* - 'scope': The instance is created once per scope (e.g., per request).
|
|
42
|
+
* - 'transient': A new instance is created every time it is requested.
|
|
43
|
+
*/
|
|
44
|
+
type Lifetime = 'singleton' | 'scope' | 'transient';
|
|
45
|
+
/**
|
|
46
|
+
* Represents a binding in the dependency injection system.
|
|
47
|
+
* It contains the lifetime of the binding, the implementation type, and optionally an instance.
|
|
48
|
+
*/
|
|
49
|
+
interface IBinding {
|
|
50
|
+
lifetime: Lifetime;
|
|
51
|
+
implementation: Type<unknown>;
|
|
52
|
+
instance?: InstanceType<Type<unknown>>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* AppInjector is the root dependency injection container.
|
|
56
|
+
* It is used to register and resolve dependencies in the application.
|
|
57
|
+
* It supports different lifetimes for dependencies:
|
|
58
|
+
* This should not be manually instantiated, outside of the framework.
|
|
59
|
+
* Use the `RootInjector` instance instead.
|
|
60
|
+
*/
|
|
61
|
+
declare class AppInjector {
|
|
62
|
+
readonly name: string | null;
|
|
63
|
+
bindings: Map<Type<unknown>, IBinding>;
|
|
64
|
+
singletons: Map<Type<unknown>, unknown>;
|
|
65
|
+
scoped: Map<Type<unknown>, unknown>;
|
|
66
|
+
constructor(name?: string | null);
|
|
67
|
+
/**
|
|
68
|
+
* Typically used to create a dependency injection scope
|
|
69
|
+
* at the "scope" level (i.e., per-request lifetime).
|
|
70
|
+
*
|
|
71
|
+
* SHOULD NOT BE USED by anything else than the framework itself.
|
|
72
|
+
*/
|
|
73
|
+
createScope(): AppInjector;
|
|
74
|
+
/**
|
|
75
|
+
* Called when resolving a dependency,
|
|
76
|
+
* i.e., retrieving the instance of a given class.
|
|
77
|
+
*/
|
|
78
|
+
resolve<T>(target: Type<T> | ForwardReference<T>): T;
|
|
79
|
+
/**
|
|
80
|
+
* Instantiates a class, resolving its dependencies.
|
|
81
|
+
*/
|
|
82
|
+
private instantiate;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Injects a type from the dependency injection system.
|
|
86
|
+
* This function is used to retrieve an instance of a type that has been registered in the dependency injection system.
|
|
87
|
+
* It is typically used in the constructor of a class to inject dependencies.
|
|
88
|
+
* @param t - The type to inject.
|
|
89
|
+
* @returns An instance of the type.
|
|
90
|
+
* @throws If the type is not registered in the dependency injection system.
|
|
91
|
+
*/
|
|
92
|
+
declare function inject<T>(t: Type<T> | ForwardReference<T>): T;
|
|
93
|
+
declare const RootInjector: AppInjector;
|
|
94
|
+
|
|
95
|
+
export { AppInjector as A, type ForwardRefFn as F, type IBinding as I, type Lifetime as L, type MaybeAsync as M, RootInjector as R, type Type as T, ForwardReference as a, forwardRef as f, inject as i };
|
package/dist/child.d.mts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { L as Lifetime } from './app-injector-B3MvgV3k.mjs';
|
|
2
|
+
export { A as AppInjector, F as ForwardRefFn, a as ForwardReference, I as IBinding, M as MaybeAsync, R as RootInjector, T as Type, f as forwardRef, i as inject } from './app-injector-B3MvgV3k.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @copyright 2025 NoxFly
|
|
6
|
+
* @license MIT
|
|
7
|
+
* @author NoxFly
|
|
8
|
+
*/
|
|
9
|
+
declare class ResponseException extends Error {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
constructor(message?: string);
|
|
12
|
+
constructor(statusCode?: number, message?: string);
|
|
13
|
+
}
|
|
14
|
+
declare class BadRequestException extends ResponseException {
|
|
15
|
+
readonly status = 400;
|
|
16
|
+
}
|
|
17
|
+
declare class UnauthorizedException extends ResponseException {
|
|
18
|
+
readonly status = 401;
|
|
19
|
+
}
|
|
20
|
+
declare class PaymentRequiredException extends ResponseException {
|
|
21
|
+
readonly status = 402;
|
|
22
|
+
}
|
|
23
|
+
declare class ForbiddenException extends ResponseException {
|
|
24
|
+
readonly status = 403;
|
|
25
|
+
}
|
|
26
|
+
declare class NotFoundException extends ResponseException {
|
|
27
|
+
readonly status = 404;
|
|
28
|
+
}
|
|
29
|
+
declare class MethodNotAllowedException extends ResponseException {
|
|
30
|
+
readonly status = 405;
|
|
31
|
+
}
|
|
32
|
+
declare class NotAcceptableException extends ResponseException {
|
|
33
|
+
readonly status = 406;
|
|
34
|
+
}
|
|
35
|
+
declare class RequestTimeoutException extends ResponseException {
|
|
36
|
+
readonly status = 408;
|
|
37
|
+
}
|
|
38
|
+
declare class ConflictException extends ResponseException {
|
|
39
|
+
readonly status = 409;
|
|
40
|
+
}
|
|
41
|
+
declare class UpgradeRequiredException extends ResponseException {
|
|
42
|
+
readonly status = 426;
|
|
43
|
+
}
|
|
44
|
+
declare class TooManyRequestsException extends ResponseException {
|
|
45
|
+
readonly status = 429;
|
|
46
|
+
}
|
|
47
|
+
declare class InternalServerException extends ResponseException {
|
|
48
|
+
readonly status = 500;
|
|
49
|
+
}
|
|
50
|
+
declare class NotImplementedException extends ResponseException {
|
|
51
|
+
readonly status = 501;
|
|
52
|
+
}
|
|
53
|
+
declare class BadGatewayException extends ResponseException {
|
|
54
|
+
readonly status = 502;
|
|
55
|
+
}
|
|
56
|
+
declare class ServiceUnavailableException extends ResponseException {
|
|
57
|
+
readonly status = 503;
|
|
58
|
+
}
|
|
59
|
+
declare class GatewayTimeoutException extends ResponseException {
|
|
60
|
+
readonly status = 504;
|
|
61
|
+
}
|
|
62
|
+
declare class HttpVersionNotSupportedException extends ResponseException {
|
|
63
|
+
readonly status = 505;
|
|
64
|
+
}
|
|
65
|
+
declare class VariantAlsoNegotiatesException extends ResponseException {
|
|
66
|
+
readonly status = 506;
|
|
67
|
+
}
|
|
68
|
+
declare class InsufficientStorageException extends ResponseException {
|
|
69
|
+
readonly status = 507;
|
|
70
|
+
}
|
|
71
|
+
declare class LoopDetectedException extends ResponseException {
|
|
72
|
+
readonly status = 508;
|
|
73
|
+
}
|
|
74
|
+
declare class NotExtendedException extends ResponseException {
|
|
75
|
+
readonly status = 510;
|
|
76
|
+
}
|
|
77
|
+
declare class NetworkAuthenticationRequiredException extends ResponseException {
|
|
78
|
+
readonly status = 511;
|
|
79
|
+
}
|
|
80
|
+
declare class NetworkConnectTimeoutException extends ResponseException {
|
|
81
|
+
readonly status = 599;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare const INJECTABLE_METADATA_KEY: unique symbol;
|
|
85
|
+
declare function getInjectableMetadata(target: Function): Lifetime | undefined;
|
|
86
|
+
declare function hasInjectableMetadata(target: Function): boolean;
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The Injectable decorator marks a class as injectable.
|
|
91
|
+
* It allows the class to be registered in the dependency injection system.
|
|
92
|
+
* A class decorated with @Injectable can be injected into other classes
|
|
93
|
+
* either from the constructor of the class that needs it of from the `inject` function.
|
|
94
|
+
* @param lifetime - The lifetime of the injectable. Can be 'singleton', 'scope', or 'transient'.
|
|
95
|
+
*/
|
|
96
|
+
declare function Injectable(lifetime?: Lifetime): ClassDecorator;
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
declare const INJECT_METADATA_KEY = "custom:inject";
|
|
100
|
+
/**
|
|
101
|
+
* Decorator to manually inject a dependency.
|
|
102
|
+
* Useful for handling circular dependencies with `forwardRef` or injecting specific tokens.
|
|
103
|
+
*
|
|
104
|
+
* @param token The token or forward reference to inject.
|
|
105
|
+
*/
|
|
106
|
+
declare function Inject(token: any): ParameterDecorator;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Logger is a utility class for logging messages to the console.
|
|
110
|
+
*/
|
|
111
|
+
type LogLevel = 'debug' | 'comment' | 'log' | 'info' | 'warn' | 'error' | 'critical';
|
|
112
|
+
declare namespace Logger {
|
|
113
|
+
/**
|
|
114
|
+
* Sets the log level for the logger.
|
|
115
|
+
* This function allows you to change the log level dynamically at runtime.
|
|
116
|
+
* This won't affect the startup logs.
|
|
117
|
+
*
|
|
118
|
+
* If the parameter is a single LogLevel, all log levels with equal or higher severity will be enabled.
|
|
119
|
+
|
|
120
|
+
* If the parameter is an array of LogLevels, only the specified levels will be enabled.
|
|
121
|
+
*
|
|
122
|
+
* @param level Sets the log level for the logger.
|
|
123
|
+
*/
|
|
124
|
+
function setLogLevel(level: LogLevel | LogLevel[]): void;
|
|
125
|
+
/**
|
|
126
|
+
* Logs a message to the console with log level LOG.
|
|
127
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
128
|
+
* It uses different colors for different log levels to enhance readability.
|
|
129
|
+
* @param args The arguments to log.
|
|
130
|
+
*/
|
|
131
|
+
function log(...args: any[]): void;
|
|
132
|
+
/**
|
|
133
|
+
* Logs a message to the console with log level INFO.
|
|
134
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
135
|
+
* It uses different colors for different log levels to enhance readability.
|
|
136
|
+
* @param args The arguments to log.
|
|
137
|
+
*/
|
|
138
|
+
function info(...args: any[]): void;
|
|
139
|
+
/**
|
|
140
|
+
* Logs a message to the console with log level WARN.
|
|
141
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
142
|
+
* It uses different colors for different log levels to enhance readability.
|
|
143
|
+
* @param args The arguments to log.
|
|
144
|
+
*/
|
|
145
|
+
function warn(...args: any[]): void;
|
|
146
|
+
/**
|
|
147
|
+
* Logs a message to the console with log level ERROR.
|
|
148
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
149
|
+
* It uses different colors for different log levels to enhance readability.
|
|
150
|
+
* @param args The arguments to log.
|
|
151
|
+
*/
|
|
152
|
+
function error(...args: any[]): void;
|
|
153
|
+
/**
|
|
154
|
+
* Logs a message to the console with log level ERROR and a grey color scheme.
|
|
155
|
+
*/
|
|
156
|
+
function errorStack(...args: any[]): void;
|
|
157
|
+
/**
|
|
158
|
+
* Logs a message to the console with log level DEBUG.
|
|
159
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
160
|
+
* It uses different colors for different log levels to enhance readability.
|
|
161
|
+
* @param args The arguments to log.
|
|
162
|
+
*/
|
|
163
|
+
function debug(...args: any[]): void;
|
|
164
|
+
/**
|
|
165
|
+
* Logs a message to the console with log level COMMENT.
|
|
166
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
167
|
+
* It uses different colors for different log levels to enhance readability.
|
|
168
|
+
* @param args The arguments to log.
|
|
169
|
+
*/
|
|
170
|
+
function comment(...args: any[]): void;
|
|
171
|
+
/**
|
|
172
|
+
* Logs a message to the console with log level CRITICAL.
|
|
173
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
174
|
+
* It uses different colors for different log levels to enhance readability.
|
|
175
|
+
* @param args The arguments to log.
|
|
176
|
+
*/
|
|
177
|
+
function critical(...args: any[]): void;
|
|
178
|
+
/**
|
|
179
|
+
* Enables logging to a file output for the specified log levels.
|
|
180
|
+
* @param filepath The path to the log file.
|
|
181
|
+
* @param levels The log levels to enable file logging for. Defaults to all levels.
|
|
182
|
+
*/
|
|
183
|
+
function enableFileLogging(filepath: string, levels?: LogLevel[]): void;
|
|
184
|
+
/**
|
|
185
|
+
* Disables logging to a file output for the specified log levels.
|
|
186
|
+
* @param levels The log levels to disable file logging for. Defaults to all levels.
|
|
187
|
+
*/
|
|
188
|
+
function disableFileLogging(levels?: LogLevel[]): void;
|
|
189
|
+
const colors: {
|
|
190
|
+
black: string;
|
|
191
|
+
grey: string;
|
|
192
|
+
red: string;
|
|
193
|
+
green: string;
|
|
194
|
+
brown: string;
|
|
195
|
+
blue: string;
|
|
196
|
+
purple: string;
|
|
197
|
+
darkGrey: string;
|
|
198
|
+
lightRed: string;
|
|
199
|
+
lightGreen: string;
|
|
200
|
+
yellow: string;
|
|
201
|
+
lightBlue: string;
|
|
202
|
+
magenta: string;
|
|
203
|
+
cyan: string;
|
|
204
|
+
white: string;
|
|
205
|
+
initial: string;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export { BadGatewayException, BadRequestException, ConflictException, ForbiddenException, GatewayTimeoutException, HttpVersionNotSupportedException, INJECTABLE_METADATA_KEY, INJECT_METADATA_KEY, Inject, Injectable, InsufficientStorageException, InternalServerException, Lifetime, type LogLevel, Logger, LoopDetectedException, MethodNotAllowedException, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, PaymentRequiredException, RequestTimeoutException, ResponseException, ServiceUnavailableException, TooManyRequestsException, UnauthorizedException, UpgradeRequiredException, VariantAlsoNegotiatesException, getInjectableMetadata, hasInjectableMetadata };
|
package/dist/child.d.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { L as Lifetime } from './app-injector-B3MvgV3k.js';
|
|
2
|
+
export { A as AppInjector, F as ForwardRefFn, a as ForwardReference, I as IBinding, M as MaybeAsync, R as RootInjector, T as Type, f as forwardRef, i as inject } from './app-injector-B3MvgV3k.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @copyright 2025 NoxFly
|
|
6
|
+
* @license MIT
|
|
7
|
+
* @author NoxFly
|
|
8
|
+
*/
|
|
9
|
+
declare class ResponseException extends Error {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
constructor(message?: string);
|
|
12
|
+
constructor(statusCode?: number, message?: string);
|
|
13
|
+
}
|
|
14
|
+
declare class BadRequestException extends ResponseException {
|
|
15
|
+
readonly status = 400;
|
|
16
|
+
}
|
|
17
|
+
declare class UnauthorizedException extends ResponseException {
|
|
18
|
+
readonly status = 401;
|
|
19
|
+
}
|
|
20
|
+
declare class PaymentRequiredException extends ResponseException {
|
|
21
|
+
readonly status = 402;
|
|
22
|
+
}
|
|
23
|
+
declare class ForbiddenException extends ResponseException {
|
|
24
|
+
readonly status = 403;
|
|
25
|
+
}
|
|
26
|
+
declare class NotFoundException extends ResponseException {
|
|
27
|
+
readonly status = 404;
|
|
28
|
+
}
|
|
29
|
+
declare class MethodNotAllowedException extends ResponseException {
|
|
30
|
+
readonly status = 405;
|
|
31
|
+
}
|
|
32
|
+
declare class NotAcceptableException extends ResponseException {
|
|
33
|
+
readonly status = 406;
|
|
34
|
+
}
|
|
35
|
+
declare class RequestTimeoutException extends ResponseException {
|
|
36
|
+
readonly status = 408;
|
|
37
|
+
}
|
|
38
|
+
declare class ConflictException extends ResponseException {
|
|
39
|
+
readonly status = 409;
|
|
40
|
+
}
|
|
41
|
+
declare class UpgradeRequiredException extends ResponseException {
|
|
42
|
+
readonly status = 426;
|
|
43
|
+
}
|
|
44
|
+
declare class TooManyRequestsException extends ResponseException {
|
|
45
|
+
readonly status = 429;
|
|
46
|
+
}
|
|
47
|
+
declare class InternalServerException extends ResponseException {
|
|
48
|
+
readonly status = 500;
|
|
49
|
+
}
|
|
50
|
+
declare class NotImplementedException extends ResponseException {
|
|
51
|
+
readonly status = 501;
|
|
52
|
+
}
|
|
53
|
+
declare class BadGatewayException extends ResponseException {
|
|
54
|
+
readonly status = 502;
|
|
55
|
+
}
|
|
56
|
+
declare class ServiceUnavailableException extends ResponseException {
|
|
57
|
+
readonly status = 503;
|
|
58
|
+
}
|
|
59
|
+
declare class GatewayTimeoutException extends ResponseException {
|
|
60
|
+
readonly status = 504;
|
|
61
|
+
}
|
|
62
|
+
declare class HttpVersionNotSupportedException extends ResponseException {
|
|
63
|
+
readonly status = 505;
|
|
64
|
+
}
|
|
65
|
+
declare class VariantAlsoNegotiatesException extends ResponseException {
|
|
66
|
+
readonly status = 506;
|
|
67
|
+
}
|
|
68
|
+
declare class InsufficientStorageException extends ResponseException {
|
|
69
|
+
readonly status = 507;
|
|
70
|
+
}
|
|
71
|
+
declare class LoopDetectedException extends ResponseException {
|
|
72
|
+
readonly status = 508;
|
|
73
|
+
}
|
|
74
|
+
declare class NotExtendedException extends ResponseException {
|
|
75
|
+
readonly status = 510;
|
|
76
|
+
}
|
|
77
|
+
declare class NetworkAuthenticationRequiredException extends ResponseException {
|
|
78
|
+
readonly status = 511;
|
|
79
|
+
}
|
|
80
|
+
declare class NetworkConnectTimeoutException extends ResponseException {
|
|
81
|
+
readonly status = 599;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare const INJECTABLE_METADATA_KEY: unique symbol;
|
|
85
|
+
declare function getInjectableMetadata(target: Function): Lifetime | undefined;
|
|
86
|
+
declare function hasInjectableMetadata(target: Function): boolean;
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The Injectable decorator marks a class as injectable.
|
|
91
|
+
* It allows the class to be registered in the dependency injection system.
|
|
92
|
+
* A class decorated with @Injectable can be injected into other classes
|
|
93
|
+
* either from the constructor of the class that needs it of from the `inject` function.
|
|
94
|
+
* @param lifetime - The lifetime of the injectable. Can be 'singleton', 'scope', or 'transient'.
|
|
95
|
+
*/
|
|
96
|
+
declare function Injectable(lifetime?: Lifetime): ClassDecorator;
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
declare const INJECT_METADATA_KEY = "custom:inject";
|
|
100
|
+
/**
|
|
101
|
+
* Decorator to manually inject a dependency.
|
|
102
|
+
* Useful for handling circular dependencies with `forwardRef` or injecting specific tokens.
|
|
103
|
+
*
|
|
104
|
+
* @param token The token or forward reference to inject.
|
|
105
|
+
*/
|
|
106
|
+
declare function Inject(token: any): ParameterDecorator;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Logger is a utility class for logging messages to the console.
|
|
110
|
+
*/
|
|
111
|
+
type LogLevel = 'debug' | 'comment' | 'log' | 'info' | 'warn' | 'error' | 'critical';
|
|
112
|
+
declare namespace Logger {
|
|
113
|
+
/**
|
|
114
|
+
* Sets the log level for the logger.
|
|
115
|
+
* This function allows you to change the log level dynamically at runtime.
|
|
116
|
+
* This won't affect the startup logs.
|
|
117
|
+
*
|
|
118
|
+
* If the parameter is a single LogLevel, all log levels with equal or higher severity will be enabled.
|
|
119
|
+
|
|
120
|
+
* If the parameter is an array of LogLevels, only the specified levels will be enabled.
|
|
121
|
+
*
|
|
122
|
+
* @param level Sets the log level for the logger.
|
|
123
|
+
*/
|
|
124
|
+
function setLogLevel(level: LogLevel | LogLevel[]): void;
|
|
125
|
+
/**
|
|
126
|
+
* Logs a message to the console with log level LOG.
|
|
127
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
128
|
+
* It uses different colors for different log levels to enhance readability.
|
|
129
|
+
* @param args The arguments to log.
|
|
130
|
+
*/
|
|
131
|
+
function log(...args: any[]): void;
|
|
132
|
+
/**
|
|
133
|
+
* Logs a message to the console with log level INFO.
|
|
134
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
135
|
+
* It uses different colors for different log levels to enhance readability.
|
|
136
|
+
* @param args The arguments to log.
|
|
137
|
+
*/
|
|
138
|
+
function info(...args: any[]): void;
|
|
139
|
+
/**
|
|
140
|
+
* Logs a message to the console with log level WARN.
|
|
141
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
142
|
+
* It uses different colors for different log levels to enhance readability.
|
|
143
|
+
* @param args The arguments to log.
|
|
144
|
+
*/
|
|
145
|
+
function warn(...args: any[]): void;
|
|
146
|
+
/**
|
|
147
|
+
* Logs a message to the console with log level ERROR.
|
|
148
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
149
|
+
* It uses different colors for different log levels to enhance readability.
|
|
150
|
+
* @param args The arguments to log.
|
|
151
|
+
*/
|
|
152
|
+
function error(...args: any[]): void;
|
|
153
|
+
/**
|
|
154
|
+
* Logs a message to the console with log level ERROR and a grey color scheme.
|
|
155
|
+
*/
|
|
156
|
+
function errorStack(...args: any[]): void;
|
|
157
|
+
/**
|
|
158
|
+
* Logs a message to the console with log level DEBUG.
|
|
159
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
160
|
+
* It uses different colors for different log levels to enhance readability.
|
|
161
|
+
* @param args The arguments to log.
|
|
162
|
+
*/
|
|
163
|
+
function debug(...args: any[]): void;
|
|
164
|
+
/**
|
|
165
|
+
* Logs a message to the console with log level COMMENT.
|
|
166
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
167
|
+
* It uses different colors for different log levels to enhance readability.
|
|
168
|
+
* @param args The arguments to log.
|
|
169
|
+
*/
|
|
170
|
+
function comment(...args: any[]): void;
|
|
171
|
+
/**
|
|
172
|
+
* Logs a message to the console with log level CRITICAL.
|
|
173
|
+
* This function formats the message with a timestamp, process ID, and the name of the caller function or class.
|
|
174
|
+
* It uses different colors for different log levels to enhance readability.
|
|
175
|
+
* @param args The arguments to log.
|
|
176
|
+
*/
|
|
177
|
+
function critical(...args: any[]): void;
|
|
178
|
+
/**
|
|
179
|
+
* Enables logging to a file output for the specified log levels.
|
|
180
|
+
* @param filepath The path to the log file.
|
|
181
|
+
* @param levels The log levels to enable file logging for. Defaults to all levels.
|
|
182
|
+
*/
|
|
183
|
+
function enableFileLogging(filepath: string, levels?: LogLevel[]): void;
|
|
184
|
+
/**
|
|
185
|
+
* Disables logging to a file output for the specified log levels.
|
|
186
|
+
* @param levels The log levels to disable file logging for. Defaults to all levels.
|
|
187
|
+
*/
|
|
188
|
+
function disableFileLogging(levels?: LogLevel[]): void;
|
|
189
|
+
const colors: {
|
|
190
|
+
black: string;
|
|
191
|
+
grey: string;
|
|
192
|
+
red: string;
|
|
193
|
+
green: string;
|
|
194
|
+
brown: string;
|
|
195
|
+
blue: string;
|
|
196
|
+
purple: string;
|
|
197
|
+
darkGrey: string;
|
|
198
|
+
lightRed: string;
|
|
199
|
+
lightGreen: string;
|
|
200
|
+
yellow: string;
|
|
201
|
+
lightBlue: string;
|
|
202
|
+
magenta: string;
|
|
203
|
+
cyan: string;
|
|
204
|
+
white: string;
|
|
205
|
+
initial: string;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export { BadGatewayException, BadRequestException, ConflictException, ForbiddenException, GatewayTimeoutException, HttpVersionNotSupportedException, INJECTABLE_METADATA_KEY, INJECT_METADATA_KEY, Inject, Injectable, InsufficientStorageException, InternalServerException, Lifetime, type LogLevel, Logger, LoopDetectedException, MethodNotAllowedException, NetworkAuthenticationRequiredException, NetworkConnectTimeoutException, NotAcceptableException, NotExtendedException, NotFoundException, NotImplementedException, PaymentRequiredException, RequestTimeoutException, ResponseException, ServiceUnavailableException, TooManyRequestsException, UnauthorizedException, UpgradeRequiredException, VariantAlsoNegotiatesException, getInjectableMetadata, hasInjectableMetadata };
|