@decaf-ts/decorator-validation 1.6.2 → 1.6.4
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/decorator-validation.cjs +1016 -1164
- package/dist/decorator-validation.esm.cjs +971 -1134
- package/lib/constants/index.cjs +18 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/validation.cjs +14 -0
- package/lib/constants/validation.d.ts +10 -0
- package/lib/esm/constants/index.d.ts +1 -0
- package/lib/esm/constants/index.js +2 -0
- package/lib/esm/constants/validation.d.ts +10 -0
- package/lib/esm/constants/validation.js +11 -0
- package/lib/esm/index.d.ts +37 -5
- package/lib/esm/index.js +38 -6
- package/lib/esm/model/Model.d.ts +29 -100
- package/lib/esm/model/Model.js +37 -104
- package/lib/esm/model/constants.d.ts +3 -3
- package/lib/esm/model/constants.js +4 -4
- package/lib/esm/model/construction.d.ts +3 -3
- package/lib/esm/model/construction.js +4 -4
- package/lib/esm/model/decorators.d.ts +4 -4
- package/lib/esm/model/decorators.js +5 -6
- package/lib/esm/model/types.d.ts +11 -30
- package/lib/esm/model/types.js +1 -1
- package/lib/esm/model/validation.d.ts +2 -2
- package/lib/esm/model/validation.js +18 -7
- package/lib/esm/utils/constants.d.ts +9 -27
- package/lib/esm/utils/constants.js +10 -28
- package/lib/esm/utils/dates.d.ts +16 -26
- package/lib/esm/utils/dates.js +17 -27
- package/lib/esm/utils/decorators.d.ts +0 -41
- package/lib/esm/utils/decorators.js +1 -42
- package/lib/esm/utils/hashing.d.ts +6 -50
- package/lib/esm/utils/hashing.js +5 -49
- package/lib/esm/utils/index.d.ts +0 -1
- package/lib/esm/utils/index.js +1 -2
- package/lib/esm/utils/registry.d.ts +2 -2
- package/lib/esm/utils/registry.js +1 -1
- package/lib/esm/utils/serialization.d.ts +1 -1
- package/lib/esm/utils/serialization.js +2 -2
- package/lib/esm/utils/strings.d.ts +4 -4
- package/lib/esm/utils/strings.js +5 -5
- package/lib/esm/utils/types.d.ts +16 -123
- package/lib/esm/utils/types.js +1 -1
- package/lib/esm/validation/Validators/DateValidator.d.ts +8 -40
- package/lib/esm/validation/Validators/DateValidator.js +9 -41
- package/lib/esm/validation/Validators/DiffValidator.d.ts +27 -0
- package/lib/esm/validation/Validators/DiffValidator.js +58 -0
- package/lib/esm/validation/Validators/EmailValidator.d.ts +7 -39
- package/lib/esm/validation/Validators/EmailValidator.js +8 -40
- package/lib/esm/validation/Validators/EqualsValidator.d.ts +27 -0
- package/lib/esm/validation/Validators/EqualsValidator.js +63 -0
- package/lib/esm/validation/Validators/GreaterThanOrEqualValidator.d.ts +27 -0
- package/lib/esm/validation/Validators/GreaterThanOrEqualValidator.js +65 -0
- package/lib/esm/validation/Validators/GreaterThanValidator.d.ts +27 -0
- package/lib/esm/validation/Validators/GreaterThanValidator.js +62 -0
- package/lib/esm/validation/Validators/LessThanOrEqualValidator.d.ts +27 -0
- package/lib/esm/validation/Validators/LessThanOrEqualValidator.js +65 -0
- package/lib/esm/validation/Validators/LessThanValidator.d.ts +27 -0
- package/lib/esm/validation/Validators/LessThanValidator.js +62 -0
- package/lib/esm/validation/Validators/ListValidator.d.ts +6 -44
- package/lib/esm/validation/Validators/ListValidator.js +7 -45
- package/lib/esm/validation/Validators/MaxValidator.d.ts +6 -52
- package/lib/esm/validation/Validators/MaxValidator.js +7 -53
- package/lib/esm/validation/Validators/MinValidator.d.ts +6 -52
- package/lib/esm/validation/Validators/MinValidator.js +7 -53
- package/lib/esm/validation/Validators/PatternValidator.d.ts +9 -75
- package/lib/esm/validation/Validators/PatternValidator.js +10 -76
- package/lib/esm/validation/Validators/RequiredValidator.d.ts +6 -52
- package/lib/esm/validation/Validators/RequiredValidator.js +7 -53
- package/lib/esm/validation/Validators/TypeValidator.d.ts +6 -60
- package/lib/esm/validation/Validators/TypeValidator.js +7 -69
- package/lib/esm/validation/Validators/URLValidator.d.ts +7 -41
- package/lib/esm/validation/Validators/URLValidator.js +8 -42
- package/lib/esm/validation/Validators/Validator.d.ts +17 -77
- package/lib/esm/validation/Validators/Validator.js +11 -68
- package/lib/esm/validation/Validators/ValidatorRegistry.d.ts +7 -1
- package/lib/esm/validation/Validators/ValidatorRegistry.js +11 -4
- package/lib/esm/validation/Validators/constants.d.ts +41 -0
- package/lib/esm/validation/Validators/constants.js +43 -1
- package/lib/esm/validation/Validators/index.d.ts +7 -0
- package/lib/esm/validation/Validators/index.js +8 -1
- package/lib/esm/validation/Validators/utils.d.ts +52 -0
- package/lib/esm/validation/Validators/utils.js +174 -0
- package/lib/esm/validation/decorators.d.ts +124 -50
- package/lib/esm/validation/decorators.js +173 -102
- package/lib/esm/validation/types.d.ts +31 -146
- package/lib/esm/validation/types.js +1 -1
- package/lib/index.cjs +39 -7
- package/lib/index.d.ts +37 -5
- package/lib/model/Model.cjs +39 -104
- package/lib/model/Model.d.ts +29 -100
- package/lib/model/constants.cjs +4 -4
- package/lib/model/constants.d.ts +3 -3
- package/lib/model/construction.cjs +4 -4
- package/lib/model/construction.d.ts +3 -3
- package/lib/model/decorators.cjs +5 -6
- package/lib/model/decorators.d.ts +4 -4
- package/lib/model/types.cjs +1 -1
- package/lib/model/types.d.ts +11 -30
- package/lib/model/validation.cjs +25 -14
- package/lib/model/validation.d.ts +2 -2
- package/lib/utils/constants.cjs +11 -29
- package/lib/utils/constants.d.ts +9 -27
- package/lib/utils/dates.cjs +17 -27
- package/lib/utils/dates.d.ts +16 -26
- package/lib/utils/decorators.cjs +1 -42
- package/lib/utils/decorators.d.ts +0 -41
- package/lib/utils/hashing.cjs +5 -49
- package/lib/utils/hashing.d.ts +6 -50
- package/lib/utils/index.cjs +1 -2
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/registry.cjs +1 -1
- package/lib/utils/registry.d.ts +2 -2
- package/lib/utils/serialization.cjs +2 -2
- package/lib/utils/serialization.d.ts +1 -1
- package/lib/utils/strings.cjs +5 -5
- package/lib/utils/strings.d.ts +4 -4
- package/lib/utils/types.cjs +1 -1
- package/lib/utils/types.d.ts +16 -123
- package/lib/validation/Validators/DateValidator.cjs +9 -41
- package/lib/validation/Validators/DateValidator.d.ts +8 -40
- package/lib/validation/Validators/DiffValidator.cjs +61 -0
- package/lib/validation/Validators/DiffValidator.d.ts +27 -0
- package/lib/validation/Validators/EmailValidator.cjs +8 -40
- package/lib/validation/Validators/EmailValidator.d.ts +7 -39
- package/lib/validation/Validators/EqualsValidator.cjs +66 -0
- package/lib/validation/Validators/EqualsValidator.d.ts +27 -0
- package/lib/validation/Validators/GreaterThanOrEqualValidator.cjs +68 -0
- package/lib/validation/Validators/GreaterThanOrEqualValidator.d.ts +27 -0
- package/lib/validation/Validators/GreaterThanValidator.cjs +65 -0
- package/lib/validation/Validators/GreaterThanValidator.d.ts +27 -0
- package/lib/validation/Validators/LessThanOrEqualValidator.cjs +68 -0
- package/lib/validation/Validators/LessThanOrEqualValidator.d.ts +27 -0
- package/lib/validation/Validators/LessThanValidator.cjs +65 -0
- package/lib/validation/Validators/LessThanValidator.d.ts +27 -0
- package/lib/validation/Validators/ListValidator.cjs +7 -45
- package/lib/validation/Validators/ListValidator.d.ts +6 -44
- package/lib/validation/Validators/MaxValidator.cjs +7 -53
- package/lib/validation/Validators/MaxValidator.d.ts +6 -52
- package/lib/validation/Validators/MinValidator.cjs +7 -53
- package/lib/validation/Validators/MinValidator.d.ts +6 -52
- package/lib/validation/Validators/PatternValidator.cjs +10 -76
- package/lib/validation/Validators/PatternValidator.d.ts +9 -75
- package/lib/validation/Validators/RequiredValidator.cjs +7 -53
- package/lib/validation/Validators/RequiredValidator.d.ts +6 -52
- package/lib/validation/Validators/TypeValidator.cjs +7 -69
- package/lib/validation/Validators/TypeValidator.d.ts +6 -60
- package/lib/validation/Validators/URLValidator.cjs +8 -42
- package/lib/validation/Validators/URLValidator.d.ts +7 -41
- package/lib/validation/Validators/Validator.cjs +11 -68
- package/lib/validation/Validators/Validator.d.ts +17 -77
- package/lib/validation/Validators/ValidatorRegistry.cjs +12 -4
- package/lib/validation/Validators/ValidatorRegistry.d.ts +7 -1
- package/lib/validation/Validators/constants.cjs +44 -2
- package/lib/validation/Validators/constants.d.ts +41 -0
- package/lib/validation/Validators/index.cjs +8 -1
- package/lib/validation/Validators/index.d.ts +7 -0
- package/lib/validation/Validators/utils.cjs +180 -0
- package/lib/validation/Validators/utils.d.ts +52 -0
- package/lib/validation/decorators.cjs +179 -102
- package/lib/validation/decorators.d.ts +124 -50
- package/lib/validation/types.cjs +1 -1
- package/lib/validation/types.d.ts +31 -146
- package/package.json +1 -1
- package/lib/esm/utils/Decoration.d.ts +0 -123
- package/lib/esm/utils/Decoration.js +0 -188
- package/lib/utils/Decoration.cjs +0 -192
- package/lib/utils/Decoration.d.ts +0 -123
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { DecorationBuilderBuild, DecorationBuilderEnd, DecorationBuilderMid, DecorationBuilderStart, FlavourResolver, IDecorationBuilder } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* @description A decorator management class that handles flavoured decorators
|
|
4
|
-
* @summary The Decoration class provides a builder pattern for creating and managing decorators with different flavours.
|
|
5
|
-
* It supports registering, extending, and applying decorators with context-aware flavour resolution.
|
|
6
|
-
* The class implements a fluent interface for defining, extending, and applying decorators with different flavours,
|
|
7
|
-
* allowing for framework-specific decorator implementations while maintaining a consistent API.
|
|
8
|
-
* @template T Type of the decorator (ClassDecorator | PropertyDecorator | MethodDecorator)
|
|
9
|
-
* @param {string} [flavour] Optional flavour parameter for the decorator context
|
|
10
|
-
* @class
|
|
11
|
-
* @category Model
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* // Create a new decoration for 'component' with default flavour
|
|
15
|
-
* const componentDecorator = new Decoration()
|
|
16
|
-
* .for('component')
|
|
17
|
-
* .define(customComponentDecorator);
|
|
18
|
-
*
|
|
19
|
-
* // Create a flavoured decoration
|
|
20
|
-
* const vueComponent = new Decoration('vue')
|
|
21
|
-
* .for('component')
|
|
22
|
-
* .define(vueComponentDecorator);
|
|
23
|
-
*
|
|
24
|
-
* // Apply the decoration
|
|
25
|
-
* @componentDecorator
|
|
26
|
-
* class MyComponent {}
|
|
27
|
-
* ```
|
|
28
|
-
* @mermaid
|
|
29
|
-
* sequenceDiagram
|
|
30
|
-
* participant C as Client
|
|
31
|
-
* participant D as Decoration
|
|
32
|
-
* participant R as FlavourResolver
|
|
33
|
-
* participant F as DecoratorFactory
|
|
34
|
-
*
|
|
35
|
-
* C->>D: new Decoration(flavour)
|
|
36
|
-
* C->>D: for(key)
|
|
37
|
-
* C->>D: define(decorators)
|
|
38
|
-
* D->>D: register(key, flavour, decorators)
|
|
39
|
-
* D->>F: decoratorFactory(key, flavour)
|
|
40
|
-
* F->>R: resolve(target)
|
|
41
|
-
* R-->>F: resolved flavour
|
|
42
|
-
* F->>F: apply decorators
|
|
43
|
-
* F-->>C: decorated target
|
|
44
|
-
*/
|
|
45
|
-
export declare class Decoration implements IDecorationBuilder {
|
|
46
|
-
private flavour;
|
|
47
|
-
/**
|
|
48
|
-
* @description Static map of registered decorators
|
|
49
|
-
* @summary Stores all registered decorators organized by key and flavour
|
|
50
|
-
*/
|
|
51
|
-
private static decorators;
|
|
52
|
-
/**
|
|
53
|
-
* @description Function to resolve flavour from a target
|
|
54
|
-
* @summary Resolver function that determines the appropriate flavour for a given target
|
|
55
|
-
*/
|
|
56
|
-
private static flavourResolver;
|
|
57
|
-
/**
|
|
58
|
-
* @description Set of decorators for the current context
|
|
59
|
-
*/
|
|
60
|
-
private decorators?;
|
|
61
|
-
/**
|
|
62
|
-
* @description Set of additional decorators
|
|
63
|
-
*/
|
|
64
|
-
private extras?;
|
|
65
|
-
/**
|
|
66
|
-
* @description Current decorator key
|
|
67
|
-
*/
|
|
68
|
-
private key?;
|
|
69
|
-
constructor(flavour?: string);
|
|
70
|
-
/**
|
|
71
|
-
* @description Sets the key for the decoration builder
|
|
72
|
-
* @summary Initializes a new decoration chain with the specified key
|
|
73
|
-
* @param {string} key The identifier for the decorator
|
|
74
|
-
* @return {DecorationBuilderMid} Builder instance for method chaining
|
|
75
|
-
*/
|
|
76
|
-
for(key: string): DecorationBuilderMid;
|
|
77
|
-
/**
|
|
78
|
-
* @description Adds decorators to the current context
|
|
79
|
-
* @summary Internal method to add decorators with addon support
|
|
80
|
-
* @param {boolean} [addon=false] Whether the decorators are addons
|
|
81
|
-
* @param decorators Array of decorators
|
|
82
|
-
* @return {this} Current instance for chaining
|
|
83
|
-
*/
|
|
84
|
-
private decorate;
|
|
85
|
-
/**
|
|
86
|
-
* @description Defines the base decorators
|
|
87
|
-
* @summary Sets the primary decorators for the current context
|
|
88
|
-
* @param decorators Decorators to define
|
|
89
|
-
* @return Builder instance for finishing the chain
|
|
90
|
-
*/
|
|
91
|
-
define(...decorators: (ClassDecorator | PropertyDecorator | MethodDecorator)[]): DecorationBuilderEnd & DecorationBuilderBuild;
|
|
92
|
-
/**
|
|
93
|
-
* @description Extends existing decorators
|
|
94
|
-
* @summary Adds additional decorators to the current context
|
|
95
|
-
* @param decorators Additional decorators
|
|
96
|
-
* @return {DecorationBuilderBuild} Builder instance for building the decorator
|
|
97
|
-
*/
|
|
98
|
-
extend(...decorators: (ClassDecorator | PropertyDecorator | MethodDecorator)[]): DecorationBuilderBuild;
|
|
99
|
-
protected decoratorFactory(key: string, f?: string): (target: object, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => void;
|
|
100
|
-
/**
|
|
101
|
-
* @description Creates the final decorator function
|
|
102
|
-
* @summary Builds and returns the decorator factory function
|
|
103
|
-
* @return {function(object, any?, TypedPropertyDescriptor?): any} The generated decorator function
|
|
104
|
-
*/
|
|
105
|
-
apply(): (target: object, propertyKey?: any, descriptor?: TypedPropertyDescriptor<any>) => any;
|
|
106
|
-
/**
|
|
107
|
-
* @description Registers decorators for a specific key and flavour
|
|
108
|
-
* @summary Internal method to store decorators in the static registry
|
|
109
|
-
* @param {string} key Decorator key
|
|
110
|
-
* @param {string} flavour Decorator flavour
|
|
111
|
-
* @param [decorators] Primary decorators
|
|
112
|
-
* @param [extras] Additional decorators
|
|
113
|
-
*/
|
|
114
|
-
private static register;
|
|
115
|
-
/**
|
|
116
|
-
* @description Sets the global flavour resolver
|
|
117
|
-
* @summary Configures the function used to determine decorator flavours
|
|
118
|
-
* @param {FlavourResolver} resolver Function to resolve flavours
|
|
119
|
-
*/
|
|
120
|
-
static setFlavourResolver(resolver: FlavourResolver): void;
|
|
121
|
-
static for(key: string): DecorationBuilderMid;
|
|
122
|
-
static flavouredAs(flavour: string): DecorationBuilderStart;
|
|
123
|
-
}
|