@decaf-ts/decoration 0.0.7 → 0.0.8
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/decoration.cjs +292 -167
- package/dist/decoration.esm.cjs +290 -168
- package/lib/constants.cjs +22 -22
- package/lib/constants.d.ts +21 -21
- package/lib/decoration/Decoration.cjs +55 -57
- package/lib/decoration/Decoration.d.ts +59 -61
- package/lib/decoration/types.cjs +1 -1
- package/lib/decoration/types.d.ts +34 -49
- package/lib/decorators.cjs +98 -27
- package/lib/decorators.d.ts +76 -26
- package/lib/esm/constants.d.ts +21 -21
- package/lib/esm/constants.js +22 -22
- package/lib/esm/decoration/Decoration.d.ts +59 -61
- package/lib/esm/decoration/Decoration.js +55 -57
- package/lib/esm/decoration/types.d.ts +34 -49
- package/lib/esm/decoration/types.js +1 -1
- package/lib/esm/decorators.d.ts +76 -26
- package/lib/esm/decorators.js +96 -28
- package/lib/esm/index.d.ts +4 -5
- package/lib/esm/index.js +5 -6
- package/lib/esm/metadata/Metadata.d.ts +100 -59
- package/lib/esm/metadata/Metadata.js +116 -59
- package/lib/esm/metadata/types.d.ts +22 -6
- package/lib/esm/metadata/types.js +1 -1
- package/lib/index.cjs +5 -6
- package/lib/index.d.ts +4 -5
- package/lib/metadata/Metadata.cjs +116 -59
- package/lib/metadata/Metadata.d.ts +100 -59
- package/lib/metadata/types.cjs +1 -1
- package/lib/metadata/types.d.ts +22 -6
- package/package.json +10 -3
package/lib/decorators.d.ts
CHANGED
|
@@ -1,34 +1,74 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @description Assigns arbitrary metadata to a target using a string key
|
|
3
|
-
* @summary Decorator factory that stores a key/value pair in the central
|
|
4
|
-
* @param {string} key
|
|
5
|
-
* @param {any} value
|
|
6
|
-
* @return
|
|
2
|
+
* @description Assigns arbitrary metadata to a target using a string key.
|
|
3
|
+
* @summary Decorator factory that stores a key/value pair in the central metadata store for the provided class or member.
|
|
4
|
+
* @param {string} key Metadata key to associate with the target.
|
|
5
|
+
* @param {any} value Metadata value to store under the given key.
|
|
6
|
+
* @return {ClassDecorator|MethodDecorator|PropertyDecorator|ParameterDecorator} Decorator that writes the metadata when applied.
|
|
7
7
|
* @function metadata
|
|
8
8
|
* @category Decorators
|
|
9
9
|
*/
|
|
10
|
-
export declare function metadata(key: string, value: any): (model: any, prop?: any, descriptor?: PropertyDescriptor) => void;
|
|
10
|
+
export declare function metadata(key: string, value: any): (model: any, prop?: any, descriptor?: PropertyDescriptor | number) => void;
|
|
11
11
|
/**
|
|
12
|
-
* @description Captures and stores a property's design type
|
|
13
|
-
* @summary Decorator factory that reads the reflected design:type for a property and registers it in the
|
|
14
|
-
* @return
|
|
12
|
+
* @description Captures and stores a property's design type.
|
|
13
|
+
* @summary Decorator factory that reads the reflected `design:type` for a property and registers it in the metadata store under the properties map.
|
|
14
|
+
* @return {PropertyDecorator} Decorator that records the property's type metadata when applied.
|
|
15
15
|
* @function prop
|
|
16
16
|
* @category Property Decorators
|
|
17
17
|
*/
|
|
18
18
|
export declare function prop(): (model: object, prop: any) => void;
|
|
19
19
|
/**
|
|
20
|
-
* @description
|
|
20
|
+
* @description Captures a single parameter type for the decorated method.
|
|
21
|
+
* @summary Decorator factory that ensures the method metadata is initialised and stores the reflected parameter constructor at the provided index.
|
|
22
|
+
* @return {ParameterDecorator} Decorator that records the parameter type when applied.
|
|
23
|
+
* @function param
|
|
24
|
+
* @category Parameter Decorators
|
|
25
|
+
* @mermaid
|
|
26
|
+
* sequenceDiagram
|
|
27
|
+
* participant U as User Code
|
|
28
|
+
* participant P as param()
|
|
29
|
+
* participant M as Metadata
|
|
30
|
+
* U->>P: param()(target, key, index)
|
|
31
|
+
* P->>U: method()(target, key, descriptor)
|
|
32
|
+
* P->>M: params(constructor, key)
|
|
33
|
+
* M-->>P: parameter constructors[]
|
|
34
|
+
* P->>M: set(methods.key.index, constructor)
|
|
35
|
+
* P-->>U: parameter recorded
|
|
36
|
+
*/
|
|
37
|
+
export declare function param(): (model: object, prop: string | symbol | undefined, index: number) => void;
|
|
38
|
+
/**
|
|
39
|
+
* @description Extends a parameter decorator with additional metadata.
|
|
40
|
+
* @summary Applies the default `param()` decorator and augments the stored metadata with an arbitrary key/value pair.
|
|
41
|
+
* @param {string} key Metadata key to associate with the parameter.
|
|
42
|
+
* @param {any} value Metadata value persisted under the given key.
|
|
43
|
+
* @return {ParameterDecorator} Decorator that records both the parameter design type and additional metadata.
|
|
44
|
+
* @function paramMetadata
|
|
45
|
+
* @category Parameter Decorators
|
|
46
|
+
*/
|
|
47
|
+
export declare function paramMetadata(key: string, value: any): (target: any, prop: any, index: number) => void;
|
|
48
|
+
/**
|
|
49
|
+
* @description Records method design-time metadata.
|
|
21
50
|
* @summary Decorator factory that captures a method's reflected parameter and return types, storing them under the appropriate metadata keys so they can be inspected at runtime.
|
|
22
|
-
* @return
|
|
51
|
+
* @return {MethodDecorator} Decorator that persists the method's signature information into the metadata store when applied.
|
|
23
52
|
* @function method
|
|
53
|
+
* @mermaid
|
|
54
|
+
* sequenceDiagram
|
|
55
|
+
* participant U as User Code
|
|
56
|
+
* participant F as method()
|
|
57
|
+
* participant M as Metadata
|
|
58
|
+
* U->>F: method()(target, key, descriptor)
|
|
59
|
+
* F->>U: Reflect.getOwnMetadata(design:paramtypes)
|
|
60
|
+
* F->>U: Reflect.getOwnMetadata(design:returntype)
|
|
61
|
+
* F->>M: set(methods.key.design:paramtypes, params)
|
|
62
|
+
* F->>M: set(methods.key.design:returntype, returnType)
|
|
63
|
+
* F-->>U: decorated function
|
|
24
64
|
* @category Method Decorators
|
|
25
65
|
*/
|
|
26
66
|
export declare function method(): (obj: any, prop?: any, descriptor?: any) => void;
|
|
27
67
|
/**
|
|
28
|
-
* @description Decorator factory that applies multiple decorators to a single target
|
|
29
|
-
* @summary Creates a composite decorator that applies multiple decorators in sequence, correctly handling class, method, and
|
|
30
|
-
* @param {Array<ClassDecorator
|
|
31
|
-
* @return {
|
|
68
|
+
* @description Decorator factory that applies multiple decorators to a single target.
|
|
69
|
+
* @summary Creates a composite decorator that applies multiple decorators in sequence, correctly handling class, method, property, and parameter decorators.
|
|
70
|
+
* @param {Array<ClassDecorator|MethodDecorator|PropertyDecorator|ParameterDecorator>} decorators Collection of decorators to apply.
|
|
71
|
+
* @return {ClassDecorator|MethodDecorator|PropertyDecorator|ParameterDecorator} Decorator function that applies all provided decorators to the target.
|
|
32
72
|
* @function apply
|
|
33
73
|
* @mermaid
|
|
34
74
|
* sequenceDiagram
|
|
@@ -43,22 +83,32 @@ export declare function method(): (obj: any, prop?: any, descriptor?: any) => vo
|
|
|
43
83
|
* end
|
|
44
84
|
* @category Decorators
|
|
45
85
|
*/
|
|
46
|
-
export declare function apply(...decorators: Array<ClassDecorator | MethodDecorator | PropertyDecorator>): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
|
|
86
|
+
export declare function apply(...decorators: Array<ClassDecorator | MethodDecorator | PropertyDecorator | ParameterDecorator>): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor | number) => void;
|
|
47
87
|
/**
|
|
48
|
-
* @description Creates a property metadata decorator
|
|
49
|
-
* @summary Convenience factory that combines metadata(key, value) and prop() to both set an arbitrary metadata key and record the property's design type.
|
|
50
|
-
* @param {string} key
|
|
51
|
-
* @param {
|
|
52
|
-
* @return
|
|
88
|
+
* @description Creates a property metadata decorator.
|
|
89
|
+
* @summary Convenience factory that combines `metadata(key, value)` and `prop()` to both set an arbitrary metadata key and record the property's design type.
|
|
90
|
+
* @param {string} key Metadata key to set for the property.
|
|
91
|
+
* @param {any} value Metadata value to associate with the key.
|
|
92
|
+
* @return {PropertyDecorator} Decorator that sets the metadata and captures the property's type.
|
|
53
93
|
* @function propMetadata
|
|
54
94
|
* @category Property Decorators
|
|
55
95
|
*/
|
|
56
|
-
export declare function propMetadata(key: string, value: any): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
|
|
96
|
+
export declare function propMetadata(key: string, value: any): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor | number) => void;
|
|
97
|
+
/**
|
|
98
|
+
* @description Creates a method metadata decorator.
|
|
99
|
+
* @summary Convenience factory that combines `metadata(key, value)` and `method()` to both set an arbitrary metadata key and record the method's design return and param types.
|
|
100
|
+
* @param {string} key Metadata key to set for the property.
|
|
101
|
+
* @param {any} value Metadata value to associate with the key.
|
|
102
|
+
* @return {PropertyDecorator} Decorator that sets the metadata and captures the property's type.
|
|
103
|
+
* @function methodMetadata
|
|
104
|
+
* @category Method Decorators
|
|
105
|
+
*/
|
|
106
|
+
export declare function methodMetadata(key: string, value: any): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor | number) => void;
|
|
57
107
|
/**
|
|
58
|
-
* @description Attaches a human-readable description to a class or member
|
|
59
|
-
* @summary Decorator factory that stores a textual description in the
|
|
60
|
-
* @param {string} desc
|
|
61
|
-
* @return
|
|
108
|
+
* @description Attaches a human-readable description to a class or member.
|
|
109
|
+
* @summary Decorator factory that stores a textual description in the metadata store under the appropriate description key for a class or its property.
|
|
110
|
+
* @param {string} desc Descriptive text to associate with the class or property.
|
|
111
|
+
* @return {ClassDecorator|MethodDecorator|PropertyDecorator} Decorator that records the description when applied.
|
|
62
112
|
* @function description
|
|
63
113
|
* @category Decorators
|
|
64
114
|
*/
|
package/lib/esm/constants.d.ts
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
import { BasicMetadata } from "./metadata/types";
|
|
2
2
|
/**
|
|
3
|
-
* @description Default flavour identifier for the decorator system
|
|
4
|
-
* @summary Defines the default flavour used by the Decoration class when no specific flavour is provided.
|
|
5
|
-
* This constant is used throughout the library as the fallback flavour for decorators.
|
|
3
|
+
* @description Default flavour identifier for the decorator system.
|
|
4
|
+
* @summary Defines the default flavour used by the Decoration class when no specific flavour is provided. This constant is used throughout the library as the fallback flavour for decorators.
|
|
6
5
|
* @const DefaultFlavour
|
|
7
6
|
* @memberOf module:decoration
|
|
8
7
|
*/
|
|
9
8
|
export declare const DefaultFlavour = "decaf";
|
|
10
9
|
/**
|
|
11
|
-
* @description Character used to split nested metadata keys
|
|
12
|
-
* @summary
|
|
10
|
+
* @description Character used to split nested metadata keys.
|
|
11
|
+
* @summary Defines the delimiter the metadata store uses to traverse nested object paths when reading or writing values.
|
|
13
12
|
* @const ObjectKeySplitter
|
|
14
13
|
* @memberOf module:decoration
|
|
15
14
|
*/
|
|
16
15
|
export declare const ObjectKeySplitter = ".";
|
|
17
16
|
/**
|
|
18
|
-
* @description
|
|
19
|
-
* @summary
|
|
20
|
-
* These keys are used throughout the library to store and retrieve metadata about models,
|
|
21
|
-
* their properties, and their behavior.
|
|
22
|
-
* @readonly
|
|
17
|
+
* @description Metadata token registry for the decoration system.
|
|
18
|
+
* @summary Enumerates the keys used during reflection and metadata storage for classes, properties, methods, descriptions, and registered libraries.
|
|
23
19
|
* @enum {string}
|
|
24
20
|
* @readonly
|
|
21
|
+
* @const DecorationKeys
|
|
25
22
|
* @memberOf module:decoration
|
|
26
23
|
*/
|
|
27
24
|
export declare enum DecorationKeys {
|
|
25
|
+
/** @description Storage bucket for decoration-aware library registrations. */
|
|
28
26
|
LIBRARIES = "libraries",
|
|
29
|
-
/** Storage key
|
|
27
|
+
/** @description Storage key mirrored on constructors that holds runtime metadata. */
|
|
30
28
|
REFLECT = "__decaf",
|
|
31
|
-
/**
|
|
29
|
+
/** @description Container of reflected property metadata for a model. */
|
|
32
30
|
PROPERTIES = "properties",
|
|
33
|
-
/**
|
|
31
|
+
/** @description Container of reflected method metadata for a model. */
|
|
34
32
|
METHODS = "methods",
|
|
35
|
-
/** Key under which the model
|
|
33
|
+
/** @description Key under which the model constructor reference is persisted. */
|
|
36
34
|
CLASS = "class",
|
|
37
|
-
/**
|
|
35
|
+
/** @description Human-readable descriptions for classes and members. */
|
|
38
36
|
DESCRIPTION = "description",
|
|
39
|
-
/**
|
|
37
|
+
/** @description Storage slot tracking the original constructor when overridden. */
|
|
40
38
|
CONSTRUCTOR = "constructor",
|
|
41
|
-
/**
|
|
39
|
+
/** @description Collected parameter metadata for configured decorators. */
|
|
40
|
+
PARAMETERS = "parameters",
|
|
41
|
+
/** @description Reflect metadata key for a property's design type. */
|
|
42
42
|
DESIGN_TYPE = "design:type",
|
|
43
|
-
/** Reflect metadata key for constructor parameter types */
|
|
43
|
+
/** @description Reflect metadata key for recorded constructor parameter types. */
|
|
44
44
|
DESIGN_PARAMS = "design:paramtypes",
|
|
45
|
-
/** Reflect metadata key for method return type */
|
|
45
|
+
/** @description Reflect metadata key for a method's return type. */
|
|
46
46
|
DESIGN_RETURN = "design:returntype"
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* @description Default metadata instance
|
|
50
|
-
* @summary
|
|
49
|
+
* @description Default metadata instance.
|
|
50
|
+
* @summary Provides the default metadata shape used when initializing new metadata entries for a model.
|
|
51
51
|
* @const DefaultMetadata
|
|
52
52
|
* @memberOf module:decoration
|
|
53
53
|
*/
|
package/lib/esm/constants.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @description Default flavour identifier for the decorator system
|
|
3
|
-
* @summary Defines the default flavour used by the Decoration class when no specific flavour is provided.
|
|
4
|
-
* This constant is used throughout the library as the fallback flavour for decorators.
|
|
2
|
+
* @description Default flavour identifier for the decorator system.
|
|
3
|
+
* @summary Defines the default flavour used by the Decoration class when no specific flavour is provided. This constant is used throughout the library as the fallback flavour for decorators.
|
|
5
4
|
* @const DefaultFlavour
|
|
6
5
|
* @memberOf module:decoration
|
|
7
6
|
*/
|
|
8
7
|
export const DefaultFlavour = "decaf";
|
|
9
8
|
/**
|
|
10
|
-
* @description Character used to split nested metadata keys
|
|
11
|
-
* @summary
|
|
9
|
+
* @description Character used to split nested metadata keys.
|
|
10
|
+
* @summary Defines the delimiter the metadata store uses to traverse nested object paths when reading or writing values.
|
|
12
11
|
* @const ObjectKeySplitter
|
|
13
12
|
* @memberOf module:decoration
|
|
14
13
|
*/
|
|
15
14
|
export const ObjectKeySplitter = ".";
|
|
16
15
|
/**
|
|
17
|
-
* @description
|
|
18
|
-
* @summary
|
|
19
|
-
* These keys are used throughout the library to store and retrieve metadata about models,
|
|
20
|
-
* their properties, and their behavior.
|
|
21
|
-
* @readonly
|
|
16
|
+
* @description Metadata token registry for the decoration system.
|
|
17
|
+
* @summary Enumerates the keys used during reflection and metadata storage for classes, properties, methods, descriptions, and registered libraries.
|
|
22
18
|
* @enum {string}
|
|
23
19
|
* @readonly
|
|
20
|
+
* @const DecorationKeys
|
|
24
21
|
* @memberOf module:decoration
|
|
25
22
|
*/
|
|
26
23
|
export var DecorationKeys;
|
|
27
24
|
(function (DecorationKeys) {
|
|
25
|
+
/** @description Storage bucket for decoration-aware library registrations. */
|
|
28
26
|
DecorationKeys["LIBRARIES"] = "libraries";
|
|
29
|
-
/** Storage key
|
|
27
|
+
/** @description Storage key mirrored on constructors that holds runtime metadata. */
|
|
30
28
|
DecorationKeys["REFLECT"] = "__decaf";
|
|
31
|
-
/**
|
|
29
|
+
/** @description Container of reflected property metadata for a model. */
|
|
32
30
|
DecorationKeys["PROPERTIES"] = "properties";
|
|
33
|
-
/**
|
|
31
|
+
/** @description Container of reflected method metadata for a model. */
|
|
34
32
|
DecorationKeys["METHODS"] = "methods";
|
|
35
|
-
/** Key under which the model
|
|
33
|
+
/** @description Key under which the model constructor reference is persisted. */
|
|
36
34
|
DecorationKeys["CLASS"] = "class";
|
|
37
|
-
/**
|
|
35
|
+
/** @description Human-readable descriptions for classes and members. */
|
|
38
36
|
DecorationKeys["DESCRIPTION"] = "description";
|
|
39
|
-
/**
|
|
37
|
+
/** @description Storage slot tracking the original constructor when overridden. */
|
|
40
38
|
DecorationKeys["CONSTRUCTOR"] = "constructor";
|
|
41
|
-
/**
|
|
39
|
+
/** @description Collected parameter metadata for configured decorators. */
|
|
40
|
+
DecorationKeys["PARAMETERS"] = "parameters";
|
|
41
|
+
/** @description Reflect metadata key for a property's design type. */
|
|
42
42
|
DecorationKeys["DESIGN_TYPE"] = "design:type";
|
|
43
|
-
/** Reflect metadata key for constructor parameter types */
|
|
43
|
+
/** @description Reflect metadata key for recorded constructor parameter types. */
|
|
44
44
|
DecorationKeys["DESIGN_PARAMS"] = "design:paramtypes";
|
|
45
|
-
/** Reflect metadata key for method return type */
|
|
45
|
+
/** @description Reflect metadata key for a method's return type. */
|
|
46
46
|
DecorationKeys["DESIGN_RETURN"] = "design:returntype";
|
|
47
47
|
})(DecorationKeys || (DecorationKeys = {}));
|
|
48
48
|
/**
|
|
49
|
-
* @description Default metadata instance
|
|
50
|
-
* @summary
|
|
49
|
+
* @description Default metadata instance.
|
|
50
|
+
* @summary Provides the default metadata shape used when initializing new metadata entries for a model.
|
|
51
51
|
* @const DefaultMetadata
|
|
52
52
|
* @memberOf module:decoration
|
|
53
53
|
*/
|
|
54
54
|
export const DefaultMetadata = {
|
|
55
55
|
[DecorationKeys.PROPERTIES]: [],
|
|
56
56
|
};
|
|
57
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
57
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnN0YW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQTs7Ozs7R0FLRztBQUNILE1BQU0sQ0FBQyxNQUFNLGNBQWMsR0FBRyxPQUFPLENBQUM7QUFFdEM7Ozs7O0dBS0c7QUFDSCxNQUFNLENBQUMsTUFBTSxpQkFBaUIsR0FBRyxHQUFHLENBQUM7QUFFckM7Ozs7Ozs7R0FPRztBQUNILE1BQU0sQ0FBTixJQUFZLGNBdUJYO0FBdkJELFdBQVksY0FBYztJQUN4Qiw4RUFBOEU7SUFDOUUseUNBQXVCLENBQUE7SUFDdkIscUZBQXFGO0lBQ3JGLHFDQU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uilderStart, FlavourResolver, IDecorationBuilder } from "./types";
|
|
2
2
|
/**
|
|
3
|
-
* @description Union type covering supported decorator kinds
|
|
3
|
+
* @description Union type covering supported decorator kinds.
|
|
4
4
|
* @summary Represents any of the standard TypeScript decorator signatures (class, property, or method), enabling flexible registration and application within the Decoration system.
|
|
5
5
|
* @template T
|
|
6
6
|
* @typeDef DecoratorTypes
|
|
@@ -8,7 +8,7 @@ import { DecorationBuilderBuild, DecorationBuilderEnd, DecorationBuilderMid, Dec
|
|
|
8
8
|
*/
|
|
9
9
|
export type DecoratorTypes = ClassDecorator | PropertyDecorator | MethodDecorator;
|
|
10
10
|
/**
|
|
11
|
-
* @description Type definition for a decorator factory function
|
|
11
|
+
* @description Type definition for a decorator factory function.
|
|
12
12
|
* @summary Represents a function that accepts arbitrary arguments and returns a concrete decorator function to be applied to a target.
|
|
13
13
|
* @template A
|
|
14
14
|
* @typeDef DecoratorFactory
|
|
@@ -16,11 +16,11 @@ export type DecoratorTypes = ClassDecorator | PropertyDecorator | MethodDecorato
|
|
|
16
16
|
*/
|
|
17
17
|
export type DecoratorFactory = (...args: any[]) => DecoratorTypes;
|
|
18
18
|
/**
|
|
19
|
-
* @description Argument bundle for a decorator factory
|
|
19
|
+
* @description Argument bundle for a decorator factory.
|
|
20
20
|
* @summary Object form used to defer decorator creation, carrying both the factory function and its argument list to be invoked later during application.
|
|
21
21
|
* @typeDef DecoratorFactoryArgs
|
|
22
|
-
* @property {DecoratorFactory} decorator
|
|
23
|
-
* @property {any[]} args
|
|
22
|
+
* @property {DecoratorFactory} decorator Factory function that produces a decorator when invoked.
|
|
23
|
+
* @property {any[]} args List of arguments to pass to the decorator factory.
|
|
24
24
|
* @memberOf module:decoration
|
|
25
25
|
*/
|
|
26
26
|
export type DecoratorFactoryArgs = {
|
|
@@ -28,20 +28,17 @@ export type DecoratorFactoryArgs = {
|
|
|
28
28
|
args: any[];
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
|
-
* @description Union that represents either a ready-to-apply decorator or a factory with arguments
|
|
31
|
+
* @description Union that represents either a ready-to-apply decorator or a factory with arguments.
|
|
32
32
|
* @summary Allows registering decorators in two forms: as direct decorator functions or as deferred factories paired with their argument lists for later instantiation.
|
|
33
33
|
* @typeDef DecoratorData
|
|
34
34
|
* @memberOf module:decoration
|
|
35
35
|
*/
|
|
36
36
|
export type DecoratorData = DecoratorTypes | DecoratorFactoryArgs;
|
|
37
37
|
/**
|
|
38
|
-
* @description A decorator management class that handles flavoured decorators
|
|
39
|
-
* @summary The Decoration class provides a builder pattern for creating and managing decorators with different flavours.
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* allowing for framework-specific decorator implementations while maintaining a consistent API.
|
|
43
|
-
* @template T Type of the decorator (ClassDecorator | PropertyDecorator | MethodDecorator)
|
|
44
|
-
* @param {string} [flavour] Optional flavour parameter for the decorator context
|
|
38
|
+
* @description A decorator management class that handles flavoured decorators.
|
|
39
|
+
* @summary The Decoration class provides a builder pattern for creating and managing decorators with different flavours. It supports registering, extending, and applying decorators with context-aware flavour resolution, allowing framework-specific implementations while maintaining a consistent API.
|
|
40
|
+
* @template T Type of the decorator (ClassDecorator | PropertyDecorator | MethodDecorator).
|
|
41
|
+
* @param {string} [flavour=DefaultFlavour] Optional flavour parameter for the decorator context.
|
|
45
42
|
* @class
|
|
46
43
|
* @example
|
|
47
44
|
* ```typescript
|
|
@@ -79,64 +76,63 @@ export type DecoratorData = DecoratorTypes | DecoratorFactoryArgs;
|
|
|
79
76
|
export declare class Decoration implements IDecorationBuilder {
|
|
80
77
|
private flavour;
|
|
81
78
|
/**
|
|
82
|
-
* @description Static map of registered decorators
|
|
83
|
-
* @summary Stores all registered decorators
|
|
79
|
+
* @description Static map of registered decorators.
|
|
80
|
+
* @summary Stores all registered decorators organised by key and flavour.
|
|
84
81
|
*/
|
|
85
82
|
private static decorators;
|
|
86
83
|
/**
|
|
87
|
-
* @description Function to resolve flavour from a target
|
|
88
|
-
* @summary Resolver function that determines the appropriate flavour for a given target
|
|
84
|
+
* @description Function to resolve flavour from a target.
|
|
85
|
+
* @summary Resolver function that determines the appropriate flavour for a given target.
|
|
89
86
|
*/
|
|
90
87
|
private static flavourResolver;
|
|
91
88
|
/**
|
|
92
|
-
* @description Set of decorators for the current context
|
|
89
|
+
* @description Set of decorators for the current context.
|
|
93
90
|
*/
|
|
94
91
|
private decorators?;
|
|
95
92
|
/**
|
|
96
|
-
* @description Set of additional decorators
|
|
93
|
+
* @description Set of additional decorators.
|
|
97
94
|
*/
|
|
98
95
|
private extras?;
|
|
99
96
|
/**
|
|
100
|
-
* @description Current decorator key
|
|
97
|
+
* @description Current decorator key.
|
|
101
98
|
*/
|
|
102
99
|
private key?;
|
|
103
100
|
constructor(flavour?: string);
|
|
104
101
|
/**
|
|
105
|
-
* @description Sets the key for the decoration builder
|
|
106
|
-
* @summary
|
|
107
|
-
* @param {string} key
|
|
108
|
-
* @return {DecorationBuilderMid} Builder instance for method chaining
|
|
102
|
+
* @description Sets the key for the decoration builder.
|
|
103
|
+
* @summary Initialises a new decoration chain with the specified key.
|
|
104
|
+
* @param {string} key Identifier for the decorator.
|
|
105
|
+
* @return {DecorationBuilderMid} Builder instance for method chaining.
|
|
109
106
|
*/
|
|
110
107
|
for(key: string): DecorationBuilderMid;
|
|
111
108
|
/**
|
|
112
|
-
* @description Adds decorators to the current context
|
|
113
|
-
* @summary Internal method to add decorators with addon support
|
|
114
|
-
* @param {boolean} [addon=false]
|
|
115
|
-
* @param decorators
|
|
116
|
-
* @return {this} Current instance for chaining
|
|
109
|
+
* @description Adds decorators to the current context.
|
|
110
|
+
* @summary Internal method to add decorators with addon support.
|
|
111
|
+
* @param {boolean} [addon=false] Indicates whether the decorators are additive extras.
|
|
112
|
+
* @param {...DecoratorData} decorators Decorators to register for the configured key.
|
|
113
|
+
* @return {this} Current instance for chaining.
|
|
117
114
|
*/
|
|
118
115
|
private decorate;
|
|
119
116
|
/**
|
|
120
|
-
* @description Defines the base decorators
|
|
121
|
-
* @summary Sets the primary decorators for the current context
|
|
122
|
-
* @param decorators Decorators to define
|
|
123
|
-
* @return Builder instance for finishing the chain
|
|
117
|
+
* @description Defines the base decorators.
|
|
118
|
+
* @summary Sets the primary decorators for the current context.
|
|
119
|
+
* @param {...DecoratorData} decorators Decorators to define.
|
|
120
|
+
* @return {DecorationBuilderEnd} Builder instance for finishing the chain (also implements DecorationBuilderBuild).
|
|
124
121
|
*/
|
|
125
122
|
define(...decorators: DecoratorData[]): DecorationBuilderEnd & DecorationBuilderBuild;
|
|
126
123
|
/**
|
|
127
|
-
* @description Extends existing decorators
|
|
128
|
-
* @summary Adds additional decorators to the current context
|
|
129
|
-
* @param decorators Additional decorators
|
|
130
|
-
* @return {DecorationBuilderBuild} Builder instance for building the decorator
|
|
124
|
+
* @description Extends existing decorators.
|
|
125
|
+
* @summary Adds additional decorators to the current context.
|
|
126
|
+
* @param {...DecoratorData} decorators Additional decorators to register as addons.
|
|
127
|
+
* @return {DecorationBuilderBuild} Builder instance for building the decorator.
|
|
131
128
|
*/
|
|
132
129
|
extend(...decorators: DecoratorData[]): DecorationBuilderBuild;
|
|
133
130
|
/**
|
|
134
|
-
* @description Factory that creates a context-aware decorator for a key/flavour
|
|
135
|
-
* @summary Produces a decorator function bound to the provided key and flavour. The resulting decorator resolves the actual
|
|
136
|
-
*
|
|
137
|
-
* @param {string}
|
|
138
|
-
* @
|
|
139
|
-
* @return {function(object, any, TypedPropertyDescriptor<any>): any} A decorator function that applies the resolved decorators
|
|
131
|
+
* @description Factory that creates a context-aware decorator for a key/flavour.
|
|
132
|
+
* @summary Produces a decorator function bound to the provided key and flavour. The resulting decorator resolves the actual decorators to apply at invocation time based on the target's resolved flavour and the registered base and extra decorators.
|
|
133
|
+
* @param {string} key Decoration key used to look up registered decorators.
|
|
134
|
+
* @param {string} [f=DefaultFlavour] Explicit flavour to bind the factory to.
|
|
135
|
+
* @return {ClassDecorator|MethodDecorator|PropertyDecorator|ParameterDecorator} Decorator function that applies the resolved decorators.
|
|
140
136
|
* @mermaid
|
|
141
137
|
* sequenceDiagram
|
|
142
138
|
* participant U as User Code
|
|
@@ -159,38 +155,40 @@ export declare class Decoration implements IDecorationBuilder {
|
|
|
159
155
|
descriptor: TypedPropertyDescriptor<any> | undefined;
|
|
160
156
|
};
|
|
161
157
|
/**
|
|
162
|
-
* @description Creates the final decorator function
|
|
163
|
-
* @summary Builds and returns the decorator factory function
|
|
164
|
-
* @return {
|
|
158
|
+
* @description Creates the final decorator function.
|
|
159
|
+
* @summary Builds and returns the decorator factory function.
|
|
160
|
+
* @return {ClassDecorator|MethodDecorator|PropertyDecorator|ParameterDecorator} Generated decorator function ready for application.
|
|
165
161
|
*/
|
|
166
162
|
apply(): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
|
|
167
163
|
/**
|
|
168
|
-
* @description Registers decorators for a specific key and flavour
|
|
169
|
-
* @summary Internal method to store decorators in the static registry
|
|
170
|
-
* @param {string} key Decorator key
|
|
171
|
-
* @param {string} flavour Decorator flavour
|
|
172
|
-
* @param [decorators] Primary decorators
|
|
173
|
-
* @param [extras] Additional decorators
|
|
164
|
+
* @description Registers decorators for a specific key and flavour.
|
|
165
|
+
* @summary Internal method to store decorators in the static registry.
|
|
166
|
+
* @param {string} key Decorator key.
|
|
167
|
+
* @param {string} flavour Decorator flavour.
|
|
168
|
+
* @param {Set<DecoratorData>} [decorators] Primary decorators registered for the key.
|
|
169
|
+
* @param {Set<DecoratorData>} [extras] Additional decorators registered as flavour-specific addons.
|
|
170
|
+
* @return {void}
|
|
174
171
|
*/
|
|
175
172
|
private static register;
|
|
176
173
|
/**
|
|
177
|
-
* @description Sets the global flavour resolver
|
|
178
|
-
* @summary Configures the function used to determine decorator flavours
|
|
179
|
-
* @param {FlavourResolver} resolver Function to resolve flavours
|
|
174
|
+
* @description Sets the global flavour resolver.
|
|
175
|
+
* @summary Configures the function used to determine decorator flavours.
|
|
176
|
+
* @param {FlavourResolver} resolver Function to resolve flavours.
|
|
177
|
+
* @return {void}
|
|
180
178
|
*/
|
|
181
179
|
static setFlavourResolver(resolver: FlavourResolver): void;
|
|
182
180
|
/**
|
|
183
|
-
* @description Convenience static entry to start a decoration builder
|
|
181
|
+
* @description Convenience static entry to start a decoration builder.
|
|
184
182
|
* @summary Creates a new Decoration instance and initiates the builder chain with the provided key.
|
|
185
|
-
* @param {string} key
|
|
186
|
-
* @return {DecorationBuilderMid}
|
|
183
|
+
* @param {string} key Decoration key to configure.
|
|
184
|
+
* @return {DecorationBuilderMid} Builder instance for chaining definitions.
|
|
187
185
|
*/
|
|
188
186
|
static for(key: string): DecorationBuilderMid;
|
|
189
187
|
/**
|
|
190
|
-
* @description Starts a builder for a specific flavour
|
|
188
|
+
* @description Starts a builder for a specific flavour.
|
|
191
189
|
* @summary Convenience method to begin a Decoration builder chain bound to the given flavour identifier, allowing registration of flavour-specific decorators.
|
|
192
|
-
* @param {string} flavour
|
|
193
|
-
* @return {DecorationBuilderStart}
|
|
190
|
+
* @param {string} flavour Flavour name to bind to the builder.
|
|
191
|
+
* @return {DecorationBuilderStart} Builder start interface to continue configuration.
|
|
194
192
|
*/
|
|
195
193
|
static flavouredAs(flavour: string): DecorationBuilderStart;
|
|
196
194
|
}
|