@decaf-ts/decoration 0.0.6 → 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/README.md +200 -108
- package/dist/decoration.cjs +312 -165
- package/dist/decoration.esm.cjs +310 -166
- package/lib/constants.cjs +23 -30
- package/lib/constants.d.ts +22 -29
- package/lib/decoration/Decoration.cjs +55 -57
- package/lib/decoration/Decoration.d.ts +59 -61
- package/lib/decoration/index.cjs +5 -1
- package/lib/decoration/index.d.ts +4 -0
- package/lib/decoration/types.cjs +1 -1
- package/lib/decoration/types.d.ts +34 -49
- package/lib/decorators.cjs +103 -25
- package/lib/decorators.d.ts +82 -25
- package/lib/esm/constants.d.ts +22 -29
- package/lib/esm/constants.js +23 -30
- package/lib/esm/decoration/Decoration.d.ts +59 -61
- package/lib/esm/decoration/Decoration.js +55 -57
- package/lib/esm/decoration/index.d.ts +4 -0
- package/lib/esm/decoration/index.js +5 -1
- package/lib/esm/decoration/types.d.ts +34 -49
- package/lib/esm/decoration/types.js +1 -1
- package/lib/esm/decorators.d.ts +82 -25
- package/lib/esm/decorators.js +101 -26
- package/lib/esm/index.d.ts +4 -5
- package/lib/esm/index.js +5 -6
- package/lib/esm/metadata/Metadata.d.ts +108 -51
- package/lib/esm/metadata/Metadata.js +130 -51
- package/lib/esm/metadata/index.d.ts +4 -0
- package/lib/esm/metadata/index.js +5 -1
- 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 +130 -51
- package/lib/metadata/Metadata.d.ts +108 -51
- package/lib/metadata/index.cjs +5 -1
- package/lib/metadata/index.d.ts +4 -0
- package/lib/metadata/types.cjs +1 -1
- package/lib/metadata/types.d.ts +22 -6
- package/package.json +10 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DecorationBuilderBuild, DecorationBuilderEnd, DecorationBuilderMid, DecorationBuilderStart, 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
|
}
|
package/lib/decoration/index.cjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description Public exports for the decoration builder subsystem
|
|
4
|
+
* @summary Re-exports the fluent builder class along with its companion types so consumers can import from a single entry point.
|
|
5
|
+
*/
|
|
2
6
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
7
|
if (k2 === undefined) k2 = k;
|
|
4
8
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -16,4 +20,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
21
|
__exportStar(require("./Decoration.cjs"), exports);
|
|
18
22
|
__exportStar(require("./types.cjs"), exports);
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZGVjb3JhdGlvbi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7OztHQUdHOzs7Ozs7Ozs7Ozs7Ozs7O0FBRUgsbURBQTZCO0FBQzdCLDhDQUF3QiIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQGRlc2NyaXB0aW9uIFB1YmxpYyBleHBvcnRzIGZvciB0aGUgZGVjb3JhdGlvbiBidWlsZGVyIHN1YnN5c3RlbVxuICogQHN1bW1hcnkgUmUtZXhwb3J0cyB0aGUgZmx1ZW50IGJ1aWxkZXIgY2xhc3MgYWxvbmcgd2l0aCBpdHMgY29tcGFuaW9uIHR5cGVzIHNvIGNvbnN1bWVycyBjYW4gaW1wb3J0IGZyb20gYSBzaW5nbGUgZW50cnkgcG9pbnQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSBcIi4vRGVjb3JhdGlvblwiO1xuZXhwb3J0ICogZnJvbSBcIi4vdHlwZXNcIjtcbiJdfQ==
|
package/lib/decoration/types.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZGVjb3JhdGlvbi90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlc0NvbnRlbnQiOls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ZSBJRGVjb3JhdGlvbkJ1aWxkZXJcbiAqIEBtZW1iZXJPZiBtb2R1bGU6ZGVjb3JhdGlvblxuICovXG5leHBvcnQgaW50ZXJmYWNlIElEZWNvcmF0aW9uQnVpbGRlclxuICBleHRlbmRzIERlY29yYXRpb25CdWlsZGVyU3RhcnQsXG4gICAgRGVjb3JhdGlvbkJ1aWxkZXJNaWQsXG4gICAgRGVjb3JhdGlvbkJ1aWxkZXJFbmQsXG4gICAgRGVjb3JhdGlvbkJ1aWxkZXJCdWlsZCB7fVxuXG4vKipcbiAqIEBkZXNjcmlwdGlvbiBUeXBlIGRlZmluaXRpb24gZm9yIGEgZnVuY3Rpb24gdGhhdCByZXNvbHZlcyB0aGUgZmxhdm91ciBmb3IgYSB0YXJnZXQuXG4gKiBAc3VtbWFyeSBEZWZpbmVzIGEgZnVuY3Rpb24gdHlwZSB0aGF0IGRldGVybWluZXMgdGhlIGFwcHJvcHJpYXRlIGZsYXZvdXIgZm9yIGEgZ2l2ZW4gdGFyZ2V0IG9iamVjdCwgZW5hYmxpbmcgZmxhdm91ci1hd2FyZSBkZWNvcmF0b3Igc2VsZWN0aW9uLlxuICogQHBhcmFtIHtvYmplY3R9IHRhcmdldCBUYXJnZXQgb2JqZWN0IHRvIHJlc29sdmUgdGhlIGZsYXZvdXIgZm9yLlxuICogQHJldHVybiB7c3RyaW5nfSBSZXNvbHZlZCBmbGF2b3VyIGlkZW50aWZpZXIuXG4gKiBAdHlwZURlZiBGbGF2b3VyUmVzb2x2ZXJcbiAqIEBtZW1iZXJPZiBtb2R1bGU6ZGVjb3JhdGlvblxuICovXG5leHBvcnQgdHlwZSBGbGF2b3VyUmVzb2x2ZXIgPSAodGFyZ2V0OiBvYmplY3QpID0+IHN0cmluZztcbiJdfQ==
|
|
@@ -1,95 +1,80 @@
|
|
|
1
1
|
import { DecoratorData } from "./Decoration";
|
|
2
2
|
/**
|
|
3
|
-
* @description Interface for the final stage of the decoration builder pattern
|
|
4
|
-
* @summary Represents the build stage of the decoration builder, providing the ability to apply
|
|
5
|
-
* the configured decorator to a target. This is the final stage in the builder chain.
|
|
6
|
-
*
|
|
3
|
+
* @description Interface for the final stage of the decoration builder pattern.
|
|
4
|
+
* @summary Represents the build stage of the decoration builder, providing the ability to apply the configured decorator to a target. This is the final stage in the builder chain.
|
|
7
5
|
* @interface DecorationBuilderBuild
|
|
6
|
+
* @memberOf module:decoration
|
|
8
7
|
*/
|
|
9
8
|
export interface DecorationBuilderBuild {
|
|
10
9
|
/**
|
|
11
|
-
* @description Creates and returns the decorator function
|
|
12
|
-
* @summary
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
10
|
+
* @description Creates and returns the decorator function.
|
|
11
|
+
* @summary Finalises the builder process and returns a decorator function that can be applied to a class, property, or method.
|
|
12
|
+
* @param {any} target Target constructor or prototype receiving the decorator.
|
|
13
|
+
* @param {any} [propertyKey] Property key when decorating a class member.
|
|
14
|
+
* @param {TypedPropertyDescriptor<any>} [descriptor] Descriptor supplied for method or accessor decoration.
|
|
15
|
+
* @return {ClassDecorator|MethodDecorator|PropertyDecorator|ParameterDecorator} Decorator function that can be applied to a target.
|
|
16
16
|
*/
|
|
17
17
|
apply(): (target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* @description Interface for the extension stage of the decoration builder pattern
|
|
21
|
-
* @summary Represents the extension stage of the decoration builder, providing the ability to add
|
|
22
|
-
* additional decorators to the existing configuration.
|
|
23
|
-
*
|
|
20
|
+
* @description Interface for the extension stage of the decoration builder pattern.
|
|
21
|
+
* @summary Represents the extension stage of the decoration builder, providing the ability to add additional decorators to the existing configuration.
|
|
24
22
|
* @interface DecorationBuilderEnd
|
|
25
23
|
* @memberOf module:decoration
|
|
26
24
|
*/
|
|
27
25
|
export interface DecorationBuilderEnd {
|
|
28
26
|
/**
|
|
29
|
-
* @description Adds additional decorators to the existing configuration
|
|
30
|
-
* @summary Extends the current decorator configuration with additional decorators.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @param {...(ClassDecorator|PropertyDecorator|MethodDecorator)} decorators - Additional decorators to add
|
|
34
|
-
* @returns {DecorationBuilderBuild} The build stage of the builder pattern
|
|
27
|
+
* @description Adds additional decorators to the existing configuration.
|
|
28
|
+
* @summary Extends the current decorator configuration with additional decorators, making it useful for augmenting previously defined behaviour.
|
|
29
|
+
* @param {...DecoratorData} decorators Additional decorators to add.
|
|
30
|
+
* @return {DecorationBuilderBuild} The build stage of the builder pattern.
|
|
35
31
|
*/
|
|
36
32
|
extend(...decorators: DecoratorData[]): DecorationBuilderBuild;
|
|
37
33
|
}
|
|
38
34
|
/**
|
|
39
|
-
* @description Interface for the middle stage of the decoration builder pattern
|
|
40
|
-
* @summary Represents the middle stage of the decoration builder, extending the end stage
|
|
41
|
-
* and providing the ability to define the primary decorators for the configuration.
|
|
42
|
-
*
|
|
35
|
+
* @description Interface for the middle stage of the decoration builder pattern.
|
|
36
|
+
* @summary Represents the middle stage of the decoration builder, extending the end stage and providing the ability to define the primary decorators for the configuration.
|
|
43
37
|
* @interface DecorationBuilderMid
|
|
44
38
|
* @memberOf module:decoration
|
|
45
39
|
*/
|
|
46
40
|
export interface DecorationBuilderMid extends DecorationBuilderEnd {
|
|
47
41
|
/**
|
|
48
|
-
* @description Defines the primary decorators for the configuration
|
|
49
|
-
* @summary Sets the main decorators for the current context
|
|
50
|
-
*
|
|
42
|
+
* @description Defines the primary decorators for the configuration.
|
|
43
|
+
* @summary Sets the main decorators for the current context after specifying the key with the `for` method.
|
|
44
|
+
* @param {...DecoratorData} decorators Decorators to define for the current key and flavour.
|
|
45
|
+
* @return {DecorationBuilderEnd} Interface representing the remaining builder stages (also implements DecorationBuilderBuild).
|
|
51
46
|
*/
|
|
52
47
|
define(...decorators: DecoratorData[]): DecorationBuilderEnd & DecorationBuilderBuild;
|
|
53
48
|
}
|
|
54
49
|
/**
|
|
55
|
-
* @description Interface for the starting stage of the decoration builder pattern
|
|
56
|
-
* @summary Represents the initial stage of the decoration builder, providing the entry point
|
|
57
|
-
* for the builder pattern by specifying the key for the decorator.
|
|
58
|
-
*
|
|
50
|
+
* @description Interface for the starting stage of the decoration builder pattern.
|
|
51
|
+
* @summary Represents the initial stage of the decoration builder, providing the entry point for the builder pattern by specifying the key for the decorator.
|
|
59
52
|
* @interface DecorationBuilderStart
|
|
60
53
|
* @memberOf module:decoration
|
|
61
54
|
*/
|
|
62
55
|
export interface DecorationBuilderStart {
|
|
63
56
|
/**
|
|
64
|
-
* @description Specifies the key for the decorator
|
|
65
|
-
* @summary Sets the identifier for the decorator, which is used to register and retrieve
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @param {string} id - The identifier for the decorator
|
|
69
|
-
* @return {DecorationBuilderMid} The middle stage of the builder pattern
|
|
57
|
+
* @description Specifies the key for the decorator.
|
|
58
|
+
* @summary Sets the identifier for the decorator, which is used to register and retrieve the decorator in the decoration registry.
|
|
59
|
+
* @param {string} id Identifier for the decorator.
|
|
60
|
+
* @return {DecorationBuilderMid} The middle stage of the builder pattern.
|
|
70
61
|
*/
|
|
71
62
|
for(id: string): DecorationBuilderMid;
|
|
72
63
|
}
|
|
73
64
|
/**
|
|
74
|
-
* @description Comprehensive interface for the complete decoration builder pattern
|
|
75
|
-
* @summary
|
|
76
|
-
* providing a complete API for creating, configuring, and applying decorators.
|
|
77
|
-
* This interface is implemented by the Decoration class.
|
|
78
|
-
*
|
|
65
|
+
* @description Comprehensive interface for the complete decoration builder pattern.
|
|
66
|
+
* @summary Unified interface that combines all stages of the decoration builder pattern, providing a complete API for creating, configuring, and applying decorators. This interface is implemented by the Decoration class.
|
|
79
67
|
* @interface IDecorationBuilder
|
|
80
68
|
* @memberOf module:decoration
|
|
81
69
|
*/
|
|
82
70
|
export interface IDecorationBuilder extends DecorationBuilderStart, DecorationBuilderMid, DecorationBuilderEnd, DecorationBuilderBuild {
|
|
83
71
|
}
|
|
84
72
|
/**
|
|
85
|
-
* @description Type definition for a function that resolves the flavour for a target
|
|
86
|
-
* @summary Defines a function type that determines the appropriate flavour for a given target object.
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* @
|
|
90
|
-
*
|
|
91
|
-
* @param {object} target - The target object to resolve the flavour for
|
|
92
|
-
* @return {string} The resolved flavour identifier
|
|
73
|
+
* @description Type definition for a function that resolves the flavour for a target.
|
|
74
|
+
* @summary Defines a function type that determines the appropriate flavour for a given target object, enabling flavour-aware decorator selection.
|
|
75
|
+
* @param {object} target Target object to resolve the flavour for.
|
|
76
|
+
* @return {string} Resolved flavour identifier.
|
|
77
|
+
* @typeDef FlavourResolver
|
|
93
78
|
* @memberOf module:decoration
|
|
94
79
|
*/
|
|
95
80
|
export type FlavourResolver = (target: object) => string;
|