@tsed/core 8.18.1 → 8.19.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/lib/esm/decorators/storeFn.js +8 -4
- package/lib/esm/decorators/storeMerge.js +10 -0
- package/lib/esm/decorators/storeSet.js +10 -0
- package/lib/esm/errors/UnsupportedDecoratorType.js +8 -0
- package/lib/esm/types/DecoratorTypes.js +16 -0
- package/lib/esm/types/Env.js +8 -2
- package/lib/esm/types/Metadata.js +9 -0
- package/lib/esm/types/Store.js +14 -0
- package/lib/esm/types/Type.js +4 -2
- package/lib/esm/utils/AnyToPromise.js +20 -0
- package/lib/esm/utils/ancestorOf.js +17 -0
- package/lib/esm/utils/ancestorsOf.js +8 -2
- package/lib/esm/utils/catchError.js +12 -0
- package/lib/esm/utils/classOf.js +14 -7
- package/lib/esm/utils/cleanObject.js +7 -3
- package/lib/esm/utils/constructorOf.js +15 -4
- package/lib/esm/utils/createInstance.js +11 -0
- package/lib/esm/utils/decorateMethodsOf.js +11 -0
- package/lib/esm/utils/decoratorArgs.js +10 -0
- package/lib/esm/utils/decoratorTypeOf.js +11 -1
- package/lib/esm/utils/deepClone.js +7 -3
- package/lib/esm/utils/deepMerge.js +15 -0
- package/lib/esm/utils/descriptorOf.js +15 -4
- package/lib/esm/utils/getClassOrSymbol.js +8 -0
- package/lib/esm/utils/getConstructorArgNames.js +10 -0
- package/lib/esm/utils/getRandomId.js +8 -0
- package/lib/esm/utils/hasJsonMethod.js +6 -0
- package/lib/esm/utils/http/getHostInfoFromPort.js +9 -0
- package/lib/esm/utils/inheritedDescriptorOf.js +6 -0
- package/lib/esm/utils/isArray.js +8 -7
- package/lib/esm/utils/isArrowFn.js +6 -0
- package/lib/esm/utils/isBoolean.js +9 -2
- package/lib/esm/utils/isBuffer.js +10 -3
- package/lib/esm/utils/isClass.js +9 -0
- package/lib/esm/utils/isCollection.js +6 -3
- package/lib/esm/utils/isDate.js +3 -2
- package/lib/esm/utils/isEmpty.js +4 -3
- package/lib/esm/utils/isEnumerable.js +3 -2
- package/lib/esm/utils/isFunction.js +6 -0
- package/lib/esm/utils/isInheritedFrom.js +6 -0
- package/lib/esm/utils/isMomentObject.js +6 -0
- package/lib/esm/utils/isMongooseObject.js +13 -1
- package/lib/esm/utils/isNil.js +6 -0
- package/lib/esm/utils/isNumber.js +9 -2
- package/lib/esm/utils/isObject.js +6 -0
- package/lib/esm/utils/isObservable.js +6 -0
- package/lib/esm/utils/isPlainObject.js +9 -2
- package/lib/esm/utils/isPrimitive.js +14 -7
- package/lib/esm/utils/isPromise.js +4 -3
- package/lib/esm/utils/isProtectedKey.js +4 -2
- package/lib/esm/utils/isRegExp.js +6 -0
- package/lib/esm/utils/isSerializable.js +6 -0
- package/lib/esm/utils/isStream.js +6 -0
- package/lib/esm/utils/isString.js +10 -2
- package/lib/esm/utils/isSymbol.js +9 -1
- package/lib/esm/utils/methodsOf.js +4 -2
- package/lib/esm/utils/nameOf.js +12 -5
- package/lib/esm/utils/objectKeys.js +6 -0
- package/lib/esm/utils/primitiveOf.js +6 -0
- package/lib/esm/utils/prototypeOf.js +4 -3
- package/lib/esm/utils/setValue.js +20 -0
- package/lib/esm/utils/toMap.js +6 -0
- package/lib/esm/utils/toStringConstructor.js +10 -0
- package/lib/esm/utils/uniq.js +10 -1
- package/lib/esm/utils/useDecorators.js +6 -0
- package/lib/esm/utils/useMethodDecorators.js +12 -0
- package/lib/types/decorators/storeFn.d.ts +8 -4
- package/lib/types/decorators/storeMerge.d.ts +10 -0
- package/lib/types/decorators/storeSet.d.ts +10 -0
- package/lib/types/errors/UnsupportedDecoratorType.d.ts +8 -0
- package/lib/types/types/AnyDecorator.d.ts +10 -0
- package/lib/types/types/DecoratorParameters.d.ts +21 -0
- package/lib/types/types/DecoratorTypes.d.ts +16 -0
- package/lib/types/types/Env.d.ts +8 -2
- package/lib/types/types/Metadata.d.ts +9 -0
- package/lib/types/types/MetadataTypes.d.ts +12 -0
- package/lib/types/types/Relation.d.ts +8 -0
- package/lib/types/types/Store.d.ts +14 -0
- package/lib/types/types/Type.d.ts +14 -4
- package/lib/types/types/ValueOf.d.ts +10 -0
- package/lib/types/utils/AnyToPromise.d.ts +28 -0
- package/lib/types/utils/ancestorOf.d.ts +17 -0
- package/lib/types/utils/ancestorsOf.d.ts +8 -2
- package/lib/types/utils/catchError.d.ts +12 -0
- package/lib/types/utils/classOf.d.ts +14 -7
- package/lib/types/utils/cleanObject.d.ts +7 -3
- package/lib/types/utils/constructorOf.d.ts +15 -4
- package/lib/types/utils/createInstance.d.ts +11 -0
- package/lib/types/utils/decorateMethodsOf.d.ts +11 -0
- package/lib/types/utils/decoratorArgs.d.ts +10 -0
- package/lib/types/utils/decoratorTypeOf.d.ts +10 -0
- package/lib/types/utils/deepClone.d.ts +7 -3
- package/lib/types/utils/deepMerge.d.ts +30 -0
- package/lib/types/utils/descriptorOf.d.ts +15 -4
- package/lib/types/utils/getClassOrSymbol.d.ts +8 -0
- package/lib/types/utils/getConstructorArgNames.d.ts +10 -0
- package/lib/types/utils/getRandomId.d.ts +8 -0
- package/lib/types/utils/getValue.d.ts +7 -26
- package/lib/types/utils/hasJsonMethod.d.ts +6 -0
- package/lib/types/utils/http/getHostInfoFromPort.d.ts +15 -0
- package/lib/types/utils/inheritedDescriptorOf.d.ts +6 -0
- package/lib/types/utils/isArray.d.ts +8 -7
- package/lib/types/utils/isArrowFn.d.ts +6 -0
- package/lib/types/utils/isBoolean.d.ts +9 -2
- package/lib/types/utils/isBuffer.d.ts +10 -5
- package/lib/types/utils/isClass.d.ts +9 -0
- package/lib/types/utils/isCollection.d.ts +6 -3
- package/lib/types/utils/isDate.d.ts +3 -2
- package/lib/types/utils/isEmpty.d.ts +4 -3
- package/lib/types/utils/isEnumerable.d.ts +3 -2
- package/lib/types/utils/isFunction.d.ts +6 -0
- package/lib/types/utils/isInheritedFrom.d.ts +6 -0
- package/lib/types/utils/isMomentObject.d.ts +6 -0
- package/lib/types/utils/isMongooseObject.d.ts +13 -1
- package/lib/types/utils/isNil.d.ts +6 -0
- package/lib/types/utils/isNumber.d.ts +9 -2
- package/lib/types/utils/isObject.d.ts +6 -0
- package/lib/types/utils/isObservable.d.ts +8 -1
- package/lib/types/utils/isPlainObject.d.ts +9 -2
- package/lib/types/utils/isPrimitive.d.ts +14 -7
- package/lib/types/utils/isPromise.d.ts +4 -3
- package/lib/types/utils/isProtectedKey.d.ts +4 -2
- package/lib/types/utils/isRegExp.d.ts +6 -0
- package/lib/types/utils/isSerializable.d.ts +6 -0
- package/lib/types/utils/isStream.d.ts +6 -0
- package/lib/types/utils/isString.d.ts +10 -2
- package/lib/types/utils/isSymbol.d.ts +9 -1
- package/lib/types/utils/methodsOf.d.ts +4 -2
- package/lib/types/utils/nameOf.d.ts +12 -5
- package/lib/types/utils/objectKeys.d.ts +6 -0
- package/lib/types/utils/primitiveOf.d.ts +6 -0
- package/lib/types/utils/prototypeOf.d.ts +4 -3
- package/lib/types/utils/setValue.d.ts +20 -0
- package/lib/types/utils/toMap.d.ts +18 -0
- package/lib/types/utils/toStringConstructor.d.ts +10 -0
- package/lib/types/utils/uniq.d.ts +10 -1
- package/lib/types/utils/useDecorators.d.ts +6 -0
- package/lib/types/utils/useMethodDecorators.d.ts +12 -0
- package/package.json +5 -5
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw parameters passed by the TypeScript runtime to any decorator
|
|
3
|
+
* (class, property, method or parameter).
|
|
4
|
+
*
|
|
5
|
+
* The tuple contains:
|
|
6
|
+
* - the target (class `prototype` for instance members or the constructor for static members),
|
|
7
|
+
* - the key (`string | symbol`) of the decorated member,
|
|
8
|
+
* - the parameter index (number) or the `PropertyDescriptor` depending on the decorator type.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* function MyDecorator(...args: DecoratorParameters) {}
|
|
13
|
+
* ```
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
1
16
|
export type DecoratorParameters = [any, string | symbol, number | PropertyDescriptor];
|
|
17
|
+
/**
|
|
18
|
+
* Specialized variant for method decorators where the third element
|
|
19
|
+
* is always a `PropertyDescriptor`.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
2
23
|
export type DecoratorMethodParameters = [any, string | symbol, PropertyDescriptor];
|
|
3
24
|
export type StaticMethodDecorator = <TFunction extends Function, T>(target: TFunction, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalized decorator kinds recognized by Ts.ED.
|
|
3
|
+
*
|
|
4
|
+
* This enum helps identify, at runtime, the element a decorator applies to
|
|
5
|
+
* (parameter, property, method, class, and static/constructor variants).
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
1
9
|
export declare enum DecoratorTypes {
|
|
10
|
+
/** Decorator applied to an instance parameter */
|
|
2
11
|
PARAM = "parameter",
|
|
12
|
+
/** Decorator applied to a constructor parameter */
|
|
3
13
|
PARAM_CTOR = "parameter.constructor",
|
|
14
|
+
/** Decorator applied to a static method parameter */
|
|
4
15
|
PARAM_STC = "parameter.static",
|
|
16
|
+
/** Decorator applied to an instance property */
|
|
5
17
|
PROP = "property",
|
|
18
|
+
/** Decorator applied to a static property */
|
|
6
19
|
PROP_STC = "property.static",
|
|
20
|
+
/** Decorator applied to an instance method */
|
|
7
21
|
METHOD = "method",
|
|
22
|
+
/** Decorator applied to a static method */
|
|
8
23
|
METHOD_STC = "method.static",
|
|
24
|
+
/** Decorator applied to a class */
|
|
9
25
|
CLASS = "class"
|
|
10
26
|
}
|
package/lib/types/types/Env.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Represents the current application runtime environment.
|
|
2
3
|
*
|
|
4
|
+
* Used by Ts.ED to adapt behaviors (logging, error verbosity, defaults, etc.)
|
|
5
|
+
* depending on the environment.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
3
8
|
*/
|
|
4
9
|
export declare enum Env {
|
|
5
10
|
PROD = "production",
|
|
@@ -7,7 +12,8 @@ export declare enum Env {
|
|
|
7
12
|
TEST = "test"
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
15
|
+
* Compatibility alias. Prefer using `Env` directly.
|
|
16
|
+
*
|
|
17
|
+
* @deprecated Use `Env` directly.
|
|
12
18
|
*/
|
|
13
19
|
export declare const EnvTypes: typeof Env;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
/**
|
|
3
|
+
* Static helper around `reflect-metadata` to read and write metadata on classes,
|
|
4
|
+
* methods, properties and parameters.
|
|
5
|
+
*
|
|
6
|
+
* This is the single entry point used across Ts.ED core to interact with
|
|
7
|
+
* design-time type information (e.g. param types, return types) and custom
|
|
8
|
+
* metadata keys. Only the exported class symbol is documented here per the
|
|
9
|
+
* symbols-only rule; individual members are intentionally not described.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
3
12
|
* @stable
|
|
4
13
|
*/
|
|
5
14
|
export declare class Metadata {
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import type { Type } from "./Type.js";
|
|
2
|
+
/**
|
|
3
|
+
* Modèle générique décrivant les types associés à une valeur de métadonnée.
|
|
4
|
+
*
|
|
5
|
+
* Permet d'indiquer le type de l'élément (`type`) et, le cas échéant, le type
|
|
6
|
+
* de la collection qui le contient (`collectionType`).
|
|
7
|
+
*
|
|
8
|
+
* @typeParam T Type de l'élément.
|
|
9
|
+
* @typeParam C Type de la collection si applicable (ex: `Array<T>`, `Set<T>`).
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
2
12
|
export interface MetadataTypes<T = any, C = any> {
|
|
13
|
+
/** Type de l'élément (constructeur ou instance). */
|
|
3
14
|
type?: Type<T> | T;
|
|
15
|
+
/** Type de la collection (constructeur ou instance) si applicable. */
|
|
4
16
|
collectionType?: Type<C> | C;
|
|
5
17
|
}
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type marker for expressing a relationship between models/DTOs.
|
|
3
|
+
*
|
|
4
|
+
* In some contexts, `Relation<T>` is used to indicate that a property represents a related entity of type `T`. It is a transparent alias for `T`, primarily serving documentation and intent.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam Resource Type
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
1
9
|
export type Relation<T> = T;
|
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
import type { Type } from "./Type.js";
|
|
2
2
|
/**
|
|
3
|
+
* Metadata key used to reference the class-level store.
|
|
3
4
|
* @ignore
|
|
4
5
|
*/
|
|
5
6
|
export declare const CLASS_STORE = "tsed:class:store";
|
|
6
7
|
/**
|
|
8
|
+
* Metadata key used to reference the method-level store.
|
|
7
9
|
* @ignore
|
|
8
10
|
*/
|
|
9
11
|
export declare const METHOD_STORE = "tsed:method:store";
|
|
10
12
|
/**
|
|
13
|
+
* Metadata key used to reference the property-level store.
|
|
11
14
|
* @ignore
|
|
12
15
|
*/
|
|
13
16
|
export declare const PROPERTY_STORE = "tsed:property:store";
|
|
14
17
|
/**
|
|
18
|
+
* Metadata key used to reference the parameter-level store.
|
|
15
19
|
* @ignore
|
|
16
20
|
*/
|
|
17
21
|
export declare const PARAM_STORE = "tsed:param:store";
|
|
22
|
+
/**
|
|
23
|
+
* Lightweight key/value registry used to attach and retrieve metadata at
|
|
24
|
+
* class, method, property, and parameter levels.
|
|
25
|
+
*
|
|
26
|
+
* The `Store` is used internally by decorators and utilities to group
|
|
27
|
+
* metadata by symbol. Only the exported class is documented per the
|
|
28
|
+
* symbols-only rule; members are intentionally not described here.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
18
32
|
export declare class Store {
|
|
19
33
|
private _entries;
|
|
20
34
|
/**
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* the `MyCustomComponent` constructor function.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
2
|
+
* Represents a class constructor `new (...args) => T`.
|
|
6
3
|
*
|
|
4
|
+
* In Ts.ED, `Type<T>` is used to type class references (controllers, services, models, etc.) where a constructor is expected.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam T Type of the instance created by the constructor.
|
|
7
|
+
* @public
|
|
7
8
|
*/
|
|
8
9
|
export interface Type<T = any> extends Function {
|
|
9
10
|
new (...args: any[]): T;
|
|
10
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Alias of the JavaScript base constructor, used to preserve
|
|
14
|
+
* compatibility with certain inference contexts.
|
|
15
|
+
*
|
|
16
|
+
* @deprecated Avoid using this constant directly; prefer the `Type<T>` type.
|
|
17
|
+
*/
|
|
11
18
|
export declare const Type: FunctionConstructor;
|
|
19
|
+
/**
|
|
20
|
+
* Describes an abstract type (abstract class), useful for declaring dependencies that should not be instantiated directly.
|
|
21
|
+
*/
|
|
12
22
|
export interface AbstractType<T> extends Function {
|
|
13
23
|
prototype: T;
|
|
14
24
|
}
|
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @ignore
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Represents the lifecycle state of an `AnyToPromise` operation.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
4
9
|
export declare enum AnyToPromiseStatus {
|
|
5
10
|
PENDING = "PENDING",
|
|
6
11
|
CANCELED = "CANCELED",
|
|
7
12
|
RESOLVED = "RESOLVED",
|
|
8
13
|
REJECTED = "REJECTED"
|
|
9
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Describes the high-level response kind produced by `AnyToPromise`.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
10
20
|
export declare enum AnyToPromiseResponseTypes {
|
|
11
21
|
STREAM = "STREAM",
|
|
12
22
|
BUFFER = "BUFFER",
|
|
13
23
|
DATA = "DATA"
|
|
14
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Result shape returned by `AnyToPromise` when resolved.
|
|
27
|
+
*
|
|
28
|
+
* Only the symbol itself is documented per the symbols-only rule (member fields are self-explanatory).
|
|
29
|
+
*
|
|
30
|
+
* @typeParam T Type of the `data` field.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
15
33
|
export interface AnyPromiseResult<T = any> {
|
|
16
34
|
state: AnyToPromiseStatus;
|
|
17
35
|
type: AnyToPromiseResponseTypes;
|
|
@@ -19,6 +37,16 @@ export interface AnyPromiseResult<T = any> {
|
|
|
19
37
|
headers?: Record<string, any>;
|
|
20
38
|
data: T;
|
|
21
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Utility that normalizes various async-like values (Promise, Observable, Stream, plain value)
|
|
42
|
+
* into a single Promise-based flow with a consistent result shape.
|
|
43
|
+
*
|
|
44
|
+
* This class is used internally to handle controller/middleware outputs, but can be
|
|
45
|
+
* reused anywhere a unified async handling is desired.
|
|
46
|
+
*
|
|
47
|
+
* @typeParam T Type of the resulting payload.
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
22
50
|
export declare class AnyToPromise<T = any> {
|
|
23
51
|
#private;
|
|
24
52
|
status: AnyToPromiseStatus;
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the immediate prototype (ancestor) of the given target.
|
|
3
|
+
*
|
|
4
|
+
* Internally uses `Object.getPrototypeOf` to retrieve the prototype chain ancestor.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @since v7.0.0
|
|
8
|
+
*/
|
|
1
9
|
export declare function ancestorOf(target: any): any;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the inherited class (ancestor) of the given target.
|
|
12
|
+
*
|
|
13
|
+
* An alias for {@link ancestorOf}.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
* @since v7.0.0
|
|
17
|
+
* @see ancestorOf
|
|
18
|
+
*/
|
|
2
19
|
export declare function getInheritedClass(target: any): any;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Returns all ancestor classes in the prototype chain of the target.
|
|
2
3
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Traverses the prototype chain from the target's class up to the root,
|
|
5
|
+
* returning an array of all named constructor functions encountered.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @since v7.0.0
|
|
9
|
+
* @see classOf
|
|
10
|
+
* @see getInheritedClass
|
|
5
11
|
*/
|
|
6
12
|
export declare function ancestorsOf(target: any): any[];
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executes a callback and returns any thrown error, or undefined if no error occurred.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
* @since v7.0.0
|
|
6
|
+
*/
|
|
1
7
|
export declare function catchError<T extends Error>(cb: Function): T | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Executes an async callback and returns any thrown error, or undefined if no error occurred.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
* @since v7.0.0
|
|
13
|
+
*/
|
|
2
14
|
export declare function catchAsyncError<T extends Error>(cb: Function): Promise<T | undefined>;
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Returns the constructor of a target. If `target` is already a class
|
|
3
|
+
* (constructor function), it is returned as is; if it is an instance,
|
|
4
|
+
* its constructor is returned.
|
|
5
|
+
*
|
|
6
|
+
* @param target Instance or constructor.
|
|
7
|
+
* @returns The constructor associated with the target.
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* class A {}
|
|
11
|
+
* getClass(A) === A; // true
|
|
12
|
+
* getClass(new A()) === A; // true
|
|
13
|
+
* ```
|
|
5
14
|
*/
|
|
6
15
|
export declare function getClass(target: any): any;
|
|
7
16
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @returns {*}
|
|
11
|
-
* @alias getClass
|
|
17
|
+
* Alias of `getClass`.
|
|
18
|
+
* @see getClass
|
|
12
19
|
*/
|
|
13
20
|
export declare function classOf(target: any): any;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Returns a copy of an object with undefined values, protected keys, and ignored keys removed.
|
|
3
|
+
*
|
|
4
|
+
* Filters out entries that are undefined, match protected key patterns, or are in the ignore list.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @since v7.0.0
|
|
8
|
+
* @see isProtectedKey
|
|
5
9
|
*/
|
|
6
10
|
export declare function cleanObject(obj: Record<string, unknown>, ignore?: string[]): any;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { Type } from "../types/Type.js";
|
|
2
2
|
/**
|
|
3
|
-
* Get the class constructor
|
|
4
|
-
*
|
|
3
|
+
* Get the class constructor from a class or an instance.
|
|
4
|
+
*
|
|
5
|
+
* If `target` is already a constructor, it is returned as-is; otherwise the
|
|
6
|
+
* constructor of the instance is returned.
|
|
7
|
+
*
|
|
8
|
+
* @param target A class constructor or an instance.
|
|
9
|
+
* @returns The class constructor function.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* class A {}
|
|
13
|
+
* getConstructor(A) === A; // true
|
|
14
|
+
* getConstructor(new A()) === A; // true
|
|
15
|
+
* ```
|
|
5
16
|
*/
|
|
6
17
|
export declare function getConstructor(target: any): Type<any>;
|
|
7
18
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
19
|
+
* Alias of `getConstructor`.
|
|
20
|
+
* @see getConstructor
|
|
10
21
|
*/
|
|
11
22
|
export declare function constructorOf(target: any): Type<any>;
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a lightweight object instance that inherits from the provided value's prototype.
|
|
3
|
+
*
|
|
4
|
+
* If the input is a class or instance whose constructor is not Object, this function
|
|
5
|
+
* returns `Object.create(obj)` to preserve the prototype chain without invoking the constructor.
|
|
6
|
+
* Otherwise, it returns a plain empty object.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @since v7.0.0
|
|
10
|
+
* @see classOf
|
|
11
|
+
*/
|
|
1
12
|
export declare function createInstance(obj: any): any;
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies a decorator to all methods of a class, copying inherited methods if necessary.
|
|
3
|
+
*
|
|
4
|
+
* For each method, if inherited from a parent class, it first copies the method to the target class
|
|
5
|
+
* and merges its Store metadata, then applies the decorator.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @since v7.0.0
|
|
9
|
+
* @see methodsOf
|
|
10
|
+
* @see Store
|
|
11
|
+
*/
|
|
1
12
|
export declare function decorateMethodsOf(klass: any, decorator: any): void;
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import { DecoratorParameters } from "../types/DecoratorParameters.js";
|
|
2
|
+
/**
|
|
3
|
+
* Constructs decorator parameters (target, propertyKey, descriptor) for a given class member.
|
|
4
|
+
*
|
|
5
|
+
* Retrieves the property descriptor and returns a tuple compatible with decorator signatures.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @since v7.0.0
|
|
9
|
+
* @see DecoratorParameters
|
|
10
|
+
* @see descriptorOf
|
|
11
|
+
*/
|
|
2
12
|
export declare function decoratorArgs(target: any, propertyKey: string): DecoratorParameters;
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import { DecoratorTypes } from "../types/DecoratorTypes.js";
|
|
2
|
+
/**
|
|
3
|
+
* Determines the decorator type from decorator parameters.
|
|
4
|
+
*
|
|
5
|
+
* Analyzes the target, propertyKey, and descriptor to classify the decorator as
|
|
6
|
+
* class, method, property, parameter, or their static variants.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @since v7.0.0
|
|
10
|
+
* @see DecoratorTypes
|
|
11
|
+
*/
|
|
2
12
|
export declare function decoratorTypeOf(args: any[]): DecoratorTypes;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Creates a deep clone of the provided value, preserving prototype chains and handling circular references.
|
|
3
|
+
*
|
|
4
|
+
* Supports primitives, dates, regular expressions, typed arrays, buffers, maps, sets, and plain objects.
|
|
5
|
+
* Uses a WeakMap to track and handle circular references correctly.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @since v7.0.0
|
|
5
9
|
*/
|
|
6
10
|
export declare const deepClone: (source: any, stack?: WeakMap<WeakKey, any>) => any;
|
|
@@ -1,10 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Callback type for custom array merge reducers.
|
|
3
|
+
* @public
|
|
4
|
+
* @since v7.0.0
|
|
5
|
+
*/
|
|
1
6
|
export type DeepMergeReducerCB = (collection: any[], value: any, options?: DeepMergeOptions) => any;
|
|
7
|
+
/**
|
|
8
|
+
* Callback type for comparing array items during merge.
|
|
9
|
+
* @public
|
|
10
|
+
* @since v7.0.0
|
|
11
|
+
*/
|
|
2
12
|
export type DeepMergeComparatorCB = (item: any, ref: any) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Configuration options for deep merge operations.
|
|
15
|
+
* @public
|
|
16
|
+
* @since v7.0.0
|
|
17
|
+
*/
|
|
3
18
|
export interface DeepMergeOptions {
|
|
4
19
|
reducers?: Record<string, DeepMergeReducerCB>;
|
|
5
20
|
parentKey?: string;
|
|
6
21
|
cleanUndefinedProps?: boolean;
|
|
7
22
|
alter?: (key: string, value: any) => any;
|
|
8
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a merge reducer using a custom comparator function.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
* @since v7.0.0
|
|
29
|
+
*/
|
|
9
30
|
export declare function mergeReducerBuilder(cb: DeepMergeComparatorCB): (collection: any[], value: any, options: DeepMergeOptions) => any[];
|
|
31
|
+
/**
|
|
32
|
+
* Deeply merges two values, combining objects recursively and handling arrays with custom reducers.
|
|
33
|
+
*
|
|
34
|
+
* Supports primitives, arrays, and objects. Can clean undefined properties and apply custom transformations.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
* @since v7.0.0
|
|
38
|
+
* @see DeepMergeOptions
|
|
39
|
+
*/
|
|
10
40
|
export declare function deepMerge<T = any, C = any>(source: T & any, obj: C & any, options?: DeepMergeOptions): (T & C) | undefined | null;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Retrieves the property descriptor for a given class and property key.
|
|
3
|
+
*
|
|
4
|
+
* Checks both the target and its prototype for the property descriptor.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @since v7.0.0
|
|
6
8
|
*/
|
|
7
9
|
export declare function descriptorOf(target: any, propertyKey: string | symbol): PropertyDescriptor;
|
|
10
|
+
/**
|
|
11
|
+
* Checks whether a property descriptor represents a method.
|
|
12
|
+
*
|
|
13
|
+
* Returns true if the descriptor has a value property (indicating a method).
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
* @since v7.0.0
|
|
17
|
+
* @see descriptorOf
|
|
18
|
+
*/
|
|
8
19
|
export declare function isMethodDescriptor(target: any, propertyKey: string | symbol): any;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retourne le constructeur de classe lorsque `target` est une classe/instance,
|
|
3
|
+
* sinon retourne la valeur telle quelle (utile pour les `symbol`).
|
|
4
|
+
*
|
|
5
|
+
* @param target Valeur potentiellement typée classe, instance, ou symbole.
|
|
6
|
+
* @returns Le constructeur de la classe ou la valeur originale si ce n'est pas une classe.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
1
9
|
export declare function getClassOrSymbol(target: any): any;
|
|
@@ -1 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts constructor parameter names from a class constructor.
|
|
3
|
+
*
|
|
4
|
+
* Parses the constructor's string representation to retrieve parameter names.
|
|
5
|
+
* Returns an array of trimmed, non-empty parameter names.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @since v7.0.0
|
|
9
|
+
* @see toStringConstructor
|
|
10
|
+
*/
|
|
1
11
|
export declare function getConstructorArgNames(target: any): string[];
|
|
@@ -1,32 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Retrieves a value from an object using a dot-separated path expression.
|
|
3
|
+
*
|
|
4
|
+
* Supports flexible argument order (scope-first or expression-first), optional default values,
|
|
5
|
+
* and custom path separators. Can navigate nested objects and call .get() methods when available.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @since v7.0.0
|
|
6
9
|
*/
|
|
7
10
|
export declare function getValue<T = any>(scope: any, expression: string | undefined): T | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* Get value from scope
|
|
10
|
-
* @param {string} expression
|
|
11
|
-
* @param scope
|
|
12
|
-
* @param defaultValue
|
|
13
|
-
* @param separator
|
|
14
|
-
* @returns {any}
|
|
15
|
-
*/
|
|
16
11
|
export declare function getValue<T = any>(scope: any, expression: string | undefined, defaultValue: T, separator?: string): T;
|
|
17
|
-
/**
|
|
18
|
-
* Get value from scope
|
|
19
|
-
* @param {string} expression
|
|
20
|
-
* @param scope
|
|
21
|
-
* @returns {any}
|
|
22
|
-
*/
|
|
23
12
|
export declare function getValue<T = any>(expression: string | undefined, scope: any): T | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Get value from scope
|
|
26
|
-
* @param {string} expression
|
|
27
|
-
* @param scope
|
|
28
|
-
* @param defaultValue
|
|
29
|
-
* @param separator
|
|
30
|
-
* @returns {any}
|
|
31
|
-
*/
|
|
32
13
|
export declare function getValue<T = any>(expression: string | undefined, scope: any, defaultValue: T, separator?: string): T;
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses an address-port combination and returns host information with protocol.
|
|
3
|
+
*
|
|
4
|
+
* Accepts either a numeric port or a string in the format "address:port".
|
|
5
|
+
* Returns an object with protocol, address, port, and a toString method for URL formatting.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
* @since v7.0.0
|
|
9
|
+
*/
|
|
1
10
|
export declare function getHostInfoFromPort(protocol: string, addressPort: any): {
|
|
2
11
|
protocol: string;
|
|
3
12
|
address: string;
|
|
4
13
|
port: number;
|
|
5
14
|
toString(): string;
|
|
6
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Type alias for the return value of {@link getHostInfoFromPort}.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
* @since v7.0.0
|
|
21
|
+
*/
|
|
7
22
|
export type ReturnHostInfoFromPort = ReturnType<typeof getHostInfoFromPort>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @
|
|
2
|
+
* Checks if a value is an array.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
* @since v7.0.0
|
|
5
6
|
*/
|
|
6
7
|
export declare function isArray<T = any>(target: unknown): target is T[];
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
9
|
+
* Checks if a value is the Array constructor or an array instance.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
* @since v7.0.0
|
|
12
13
|
*/
|
|
13
14
|
export declare function isArrayOrArrayClass<T = any>(target: unknown): target is T[];
|