@vorplex/core 0.0.8 → 0.0.9
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/consts/mime-type.const.d.ts +456 -0
- package/dist/consts/mime-type.const.js +456 -0
- package/dist/consts/unit.const.d.ts +22 -0
- package/dist/consts/unit.const.js +22 -0
- package/dist/functions/debounce.function.d.ts +1 -0
- package/dist/functions/debounce.function.js +12 -0
- package/dist/functions/is-node-environment.function.d.ts +1 -0
- package/dist/functions/is-node-environment.function.js +3 -0
- package/dist/functions/parse-path-selector.function.d.ts +2 -0
- package/dist/functions/parse-path-selector.function.js +17 -0
- package/dist/functions/parse-url.function.d.ts +12 -0
- package/dist/functions/parse-url.function.js +25 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +93 -0
- package/dist/interfaces/group.interface.d.ts +4 -0
- package/dist/interfaces/group.interface.js +0 -0
- package/dist/interfaces/key-value.interface.d.ts +4 -0
- package/dist/interfaces/key-value.interface.js +0 -0
- package/dist/modules/api/socket.model.d.ts +26 -0
- package/dist/modules/api/socket.model.js +66 -0
- package/dist/modules/api/web-client.model.d.ts +16 -0
- package/dist/modules/api/web-client.model.js +34 -0
- package/dist/modules/array/array.util.d.ts +17 -0
- package/dist/modules/array/array.util.js +105 -0
- package/dist/modules/changes/changes.util.d.ts +45 -0
- package/dist/modules/changes/changes.util.js +330 -0
- package/dist/modules/color/color-data.interface.d.ts +10 -0
- package/dist/modules/color/color-data.interface.js +0 -0
- package/dist/modules/color/color-formats.const.d.ts +9 -0
- package/dist/modules/color/color-formats.const.js +8 -0
- package/dist/modules/color/color.type.d.ts +4 -0
- package/dist/modules/color/color.type.js +0 -0
- package/dist/modules/color/color.util.d.ts +41 -0
- package/dist/modules/color/color.util.js +327 -0
- package/dist/modules/color/colors.const.d.ts +151 -0
- package/dist/modules/color/colors.const.js +150 -0
- package/dist/modules/color/hsl.interface.d.ts +6 -0
- package/dist/modules/color/hsl.interface.js +0 -0
- package/dist/modules/color/hsv.interface.d.ts +6 -0
- package/dist/modules/color/hsv.interface.js +0 -0
- package/dist/modules/color/rgb.interface.d.ts +6 -0
- package/dist/modules/color/rgb.interface.js +0 -0
- package/dist/modules/compression/compression.util.d.ts +4 -0
- package/dist/modules/compression/compression.util.js +52 -0
- package/dist/modules/date/date.util.d.ts +37 -0
- package/dist/modules/date/date.util.js +84 -0
- package/dist/modules/enum/enum.util.d.ts +17 -0
- package/dist/modules/enum/enum.util.js +69 -0
- package/dist/modules/hash/hash.util.d.ts +3 -0
- package/dist/modules/hash/hash.util.js +9 -0
- package/dist/modules/id/id.util.d.ts +7 -0
- package/dist/modules/id/id.util.js +33 -0
- package/dist/modules/injector/decorators/inject-token.decorator.d.ts +14 -0
- package/dist/modules/injector/decorators/inject-token.decorator.js +12 -0
- package/dist/modules/injector/decorators/injectable.decorator.d.ts +9 -0
- package/dist/modules/injector/decorators/injectable.decorator.js +7 -0
- package/dist/modules/injector/injector.model.d.ts +25 -0
- package/dist/modules/injector/injector.model.js +152 -0
- package/dist/modules/injector/provider-scopes.enum.d.ts +5 -0
- package/dist/modules/injector/provider-scopes.enum.js +6 -0
- package/dist/modules/injector/provider.interface.d.ts +10 -0
- package/dist/modules/injector/provider.interface.js +0 -0
- package/dist/modules/json-filter/json-filter.function.d.ts +41 -0
- package/dist/modules/json-filter/json-filter.function.js +75 -0
- package/dist/modules/logging/console-logger.model.d.ts +36 -0
- package/dist/modules/logging/console-logger.model.js +44 -0
- package/dist/modules/logging/logger.model.d.ts +6 -0
- package/dist/modules/logging/logger.model.js +7 -0
- package/dist/modules/logging/task.d.ts +38 -0
- package/dist/modules/logging/task.js +133 -0
- package/dist/modules/math/line.d.ts +12 -0
- package/dist/modules/math/line.js +50 -0
- package/dist/modules/math/point.d.ts +34 -0
- package/dist/modules/math/point.js +71 -0
- package/dist/modules/math/polygon.d.ts +45 -0
- package/dist/modules/math/polygon.js +273 -0
- package/dist/modules/math/rect.d.ts +6 -0
- package/dist/modules/math/rect.js +0 -0
- package/dist/modules/math/size.d.ts +4 -0
- package/dist/modules/math/size.js +0 -0
- package/dist/modules/number/number.util.d.ts +9 -0
- package/dist/modules/number/number.util.js +27 -0
- package/dist/modules/object/object.util.d.ts +7 -0
- package/dist/modules/object/object.util.js +63 -0
- package/dist/modules/path/path.util.d.ts +11 -0
- package/dist/modules/path/path.util.js +59 -0
- package/dist/modules/random/random.util.d.ts +17 -0
- package/dist/modules/random/random.util.js +57 -0
- package/dist/modules/readable-stream/readable-stream.util.d.ts +3 -0
- package/dist/modules/readable-stream/readable-stream.util.js +26 -0
- package/dist/modules/reflection/interfaces/parameter.interface.d.ts +4 -0
- package/dist/modules/reflection/interfaces/parameter.interface.js +0 -0
- package/dist/modules/reflection/models/attribute.model.d.ts +12 -0
- package/dist/modules/reflection/models/attribute.model.js +17 -0
- package/dist/modules/reflection/models/class-attribute.model.d.ts +4 -0
- package/dist/modules/reflection/models/class-attribute.model.js +6 -0
- package/dist/modules/reflection/models/method-attribute.model.d.ts +5 -0
- package/dist/modules/reflection/models/method-attribute.model.js +8 -0
- package/dist/modules/reflection/models/parameter-attribute.model.d.ts +7 -0
- package/dist/modules/reflection/models/parameter-attribute.model.js +21 -0
- package/dist/modules/reflection/models/property-attribute.model.d.ts +5 -0
- package/dist/modules/reflection/models/property-attribute.model.js +8 -0
- package/dist/modules/reflection/models/property-proxy-attribute.model.d.ts +15 -0
- package/dist/modules/reflection/models/property-proxy-attribute.model.js +19 -0
- package/dist/modules/reflection/types/constructor.type.d.ts +2 -0
- package/dist/modules/reflection/types/constructor.type.js +0 -0
- package/dist/modules/reflection/types/instance.type.d.ts +7 -0
- package/dist/modules/reflection/types/instance.type.js +0 -0
- package/dist/modules/reflection/types/type.type.d.ts +2 -0
- package/dist/modules/reflection/types/type.type.js +0 -0
- package/dist/modules/reflection/utils/decorator.util.d.ts +70 -0
- package/dist/modules/reflection/utils/decorator.util.js +135 -0
- package/dist/modules/reflection/utils/reflection.util.d.ts +140 -0
- package/dist/modules/reflection/utils/reflection.util.js +311 -0
- package/dist/modules/router/router.util.d.ts +33 -0
- package/dist/modules/router/router.util.js +59 -0
- package/dist/modules/state/adaptors/array/array-adaptor.util.d.ts +25 -0
- package/dist/modules/state/adaptors/array/array-adaptor.util.js +97 -0
- package/dist/modules/state/adaptors/entity/entity-adaptor.util.d.ts +35 -0
- package/dist/modules/state/adaptors/entity/entity-adaptor.util.js +158 -0
- package/dist/modules/state/adaptors/entity/entity-map.type.d.ts +4 -0
- package/dist/modules/state/adaptors/entity/entity-map.type.js +0 -0
- package/dist/modules/state/adaptors/entity/entity.interface.d.ts +3 -0
- package/dist/modules/state/adaptors/entity/entity.interface.js +0 -0
- package/dist/modules/state/state.model.d.ts +46 -0
- package/dist/modules/state/state.model.js +129 -0
- package/dist/modules/state/update.type.d.ts +2 -0
- package/dist/modules/state/update.type.js +0 -0
- package/dist/modules/string/string.util.d.ts +11 -0
- package/dist/modules/string/string.util.js +42 -0
- package/dist/modules/subscribable/subscribable.model.d.ts +10 -0
- package/dist/modules/subscribable/subscribable.model.js +34 -0
- package/dist/modules/subscribable/subscription.interface.d.ts +3 -0
- package/dist/modules/subscribable/subscription.interface.js +0 -0
- package/dist/modules/tson/error.d.ts +8 -0
- package/dist/modules/tson/error.js +13 -0
- package/dist/modules/tson/schema.d.ts +10 -0
- package/dist/modules/tson/schema.js +0 -0
- package/dist/modules/tson/schemas/any.d.ts +14 -0
- package/dist/modules/tson/schemas/any.js +27 -0
- package/dist/modules/tson/schemas/array.d.ts +21 -0
- package/dist/modules/tson/schemas/array.js +80 -0
- package/dist/modules/tson/schemas/boolean.d.ts +14 -0
- package/dist/modules/tson/schemas/boolean.js +38 -0
- package/dist/modules/tson/schemas/enum.d.ts +15 -0
- package/dist/modules/tson/schemas/enum.js +43 -0
- package/dist/modules/tson/schemas/number.d.ts +20 -0
- package/dist/modules/tson/schemas/number.js +66 -0
- package/dist/modules/tson/schemas/object.d.ts +33 -0
- package/dist/modules/tson/schemas/object.js +88 -0
- package/dist/modules/tson/schemas/schema-base.d.ts +12 -0
- package/dist/modules/tson/schemas/schema-base.js +14 -0
- package/dist/modules/tson/schemas/string.d.ts +19 -0
- package/dist/modules/tson/schemas/string.js +60 -0
- package/dist/modules/tson/schemas/union.d.ts +16 -0
- package/dist/modules/tson/schemas/union.js +56 -0
- package/dist/modules/tson/tson.d.ts +41 -0
- package/dist/modules/tson/tson.js +138 -0
- package/dist/modules/tson/type.d.ts +53 -0
- package/dist/modules/tson/type.js +0 -0
- package/dist/modules/value/value.util.d.ts +18 -0
- package/dist/modules/value/value.util.js +180 -0
- package/dist/types/awaitable.type.d.ts +1 -0
- package/dist/types/awaitable.type.js +0 -0
- package/dist/types/camel-to-kebab.type.d.ts +1 -0
- package/dist/types/camel-to-kebab.type.js +0 -0
- package/dist/types/has-key.type.d.ts +3 -0
- package/dist/types/has-key.type.js +0 -0
- package/dist/types/is-union.type.d.ts +1 -0
- package/dist/types/is-union.type.js +0 -0
- package/dist/types/keys-of-type.type.d.ts +5 -0
- package/dist/types/keys-of-type.type.js +0 -0
- package/dist/types/keys-with-fix.type.d.ts +3 -0
- package/dist/types/keys-with-fix.type.js +0 -0
- package/dist/types/optional-keys.type.d.ts +6 -0
- package/dist/types/optional-keys.type.js +0 -0
- package/dist/types/partial.type.d.ts +6 -0
- package/dist/types/partial.type.js +0 -0
- package/dist/types/predicate.type.d.ts +1 -0
- package/dist/types/predicate.type.js +0 -0
- package/dist/types/recursive-readonly.type.d.ts +3 -0
- package/dist/types/recursive-readonly.type.js +0 -0
- package/dist/types/recursive-value.type.d.ts +3 -0
- package/dist/types/recursive-value.type.js +0 -0
- package/dist/types/selector.type.d.ts +1 -0
- package/dist/types/selector.type.js +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Attribute } from './attribute.model';
|
|
2
|
+
export class ParameterAttribute extends Attribute {
|
|
3
|
+
method;
|
|
4
|
+
name;
|
|
5
|
+
index;
|
|
6
|
+
constructor(prototype, method, index, data) {
|
|
7
|
+
super(prototype, data);
|
|
8
|
+
this.method = method;
|
|
9
|
+
this.name = (prototype[method] || prototype)
|
|
10
|
+
.toString()
|
|
11
|
+
.replace(/[/][/].*$/gm, '')
|
|
12
|
+
.replace(/\s+/g, '')
|
|
13
|
+
.replace(/[/][*][^/*]*[*][/]/g, '')
|
|
14
|
+
.split('){', 1)[0]
|
|
15
|
+
.replace(/^[^(]*[(]/, '')
|
|
16
|
+
.replace(/=[^,]+/g, '')
|
|
17
|
+
.split(',')
|
|
18
|
+
.filter(Boolean)[index];
|
|
19
|
+
this.index = index;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropertyAttribute } from './property-attribute.model';
|
|
2
|
+
export declare abstract class PropertyProxyAttribute<T = any> extends PropertyAttribute<T> {
|
|
3
|
+
/**
|
|
4
|
+
* Acts as a proxy for the getter of the property.
|
|
5
|
+
* @param target The object containing the property.
|
|
6
|
+
*/
|
|
7
|
+
get(target: object): object;
|
|
8
|
+
/**
|
|
9
|
+
* Acts as a proxy for the setter of the property.
|
|
10
|
+
* @param target The object containing the property.
|
|
11
|
+
* @param value The value to be assigned to the property.
|
|
12
|
+
* @returns The value to be assigned to the property.
|
|
13
|
+
*/
|
|
14
|
+
set(target: object, value: unknown): unknown;
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PropertyAttribute } from './property-attribute.model';
|
|
2
|
+
export class PropertyProxyAttribute extends PropertyAttribute {
|
|
3
|
+
/**
|
|
4
|
+
* Acts as a proxy for the getter of the property.
|
|
5
|
+
* @param target The object containing the property.
|
|
6
|
+
*/
|
|
7
|
+
get(target) {
|
|
8
|
+
return target;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Acts as a proxy for the setter of the property.
|
|
12
|
+
* @param target The object containing the property.
|
|
13
|
+
* @param value The value to be assigned to the property.
|
|
14
|
+
* @returns The value to be assigned to the property.
|
|
15
|
+
*/
|
|
16
|
+
set(target, value) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AbstractConstructor, Constructor } from './constructor.type';
|
|
2
|
+
import { Type } from './type.type';
|
|
3
|
+
export type Instance<T> = T extends Constructor<infer R> ? R : T extends AbstractConstructor<infer R> ? R : T extends Record<string, Type<any>> ? {
|
|
4
|
+
[K in keyof T]: Instance<T[K]>;
|
|
5
|
+
} : T extends any[] ? {
|
|
6
|
+
[K in keyof T]: Instance<T[K]>;
|
|
7
|
+
} : never;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Parameter } from '../interfaces/parameter.interface';
|
|
2
|
+
import type { Type } from '../types/type.type';
|
|
3
|
+
export declare abstract class Decorator<T = any> {
|
|
4
|
+
type: Type;
|
|
5
|
+
data: T;
|
|
6
|
+
constructor(type: Type, data: T);
|
|
7
|
+
}
|
|
8
|
+
export declare class ClassDecorator<T = any> extends Decorator<T> {
|
|
9
|
+
constructor(type: Type, data: T);
|
|
10
|
+
}
|
|
11
|
+
export declare class ConstructorParameterDecorator<T = any> extends Decorator<T> {
|
|
12
|
+
parameter: Parameter;
|
|
13
|
+
constructor(type: Type, parameter: Parameter, data: T);
|
|
14
|
+
}
|
|
15
|
+
export declare class PropertyDecorator<T = any> extends Decorator<T> {
|
|
16
|
+
property: string;
|
|
17
|
+
constructor(type: Type, property: string, data: T);
|
|
18
|
+
}
|
|
19
|
+
export declare class MethodDecorator<T = any> extends Decorator<T> {
|
|
20
|
+
method: string;
|
|
21
|
+
constructor(type: Type, method: string, data: T);
|
|
22
|
+
}
|
|
23
|
+
export declare class ParameterDecorator<T = any> extends Decorator<T> {
|
|
24
|
+
method: string;
|
|
25
|
+
parameter: Parameter;
|
|
26
|
+
constructor(type: Type, method: string, parameter: Parameter, data: T);
|
|
27
|
+
}
|
|
28
|
+
export interface DecoratorQuery<T extends Decorator> {
|
|
29
|
+
target: any;
|
|
30
|
+
type?: Type<T>;
|
|
31
|
+
first?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface ClassDecoratorQuery<T extends Decorator> extends DecoratorQuery<T> {
|
|
34
|
+
kind: 'class';
|
|
35
|
+
}
|
|
36
|
+
export interface ConstructorParameterDecoratorQuery<T extends Decorator> extends DecoratorQuery<T> {
|
|
37
|
+
kind: 'ctor-parameter';
|
|
38
|
+
parameter?: string | number;
|
|
39
|
+
}
|
|
40
|
+
export interface PropertyDecoratorQuery<T extends Decorator> extends DecoratorQuery<T> {
|
|
41
|
+
kind: 'property';
|
|
42
|
+
property?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface MethodDecoratorQuery<T extends Decorator> extends DecoratorQuery<T> {
|
|
45
|
+
kind: 'method';
|
|
46
|
+
method?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ParameterDecoratorQuery<T extends Decorator> extends DecoratorQuery<T> {
|
|
49
|
+
kind: 'parameter';
|
|
50
|
+
parameter?: string | number;
|
|
51
|
+
}
|
|
52
|
+
export type DecoratorQueries<T extends Decorator> = DecoratorQuery<T> | ClassDecoratorQuery<T> | ConstructorParameterDecoratorQuery<T> | PropertyDecoratorQuery<T> | MethodDecoratorQuery<T> | ParameterDecoratorQuery<T>;
|
|
53
|
+
export declare class $Decorator {
|
|
54
|
+
private static decorators;
|
|
55
|
+
static createClassDecorator<T extends Type>(create: (type: T) => ClassDecorator): (target: T, _context: ClassDecoratorContext) => void;
|
|
56
|
+
static createConstructorParameterDecorator(create: (type: Type, parameter: Parameter) => ConstructorParameterDecorator): (_target: undefined, context: ClassFieldDecoratorContext) => (this: any, initialValue: any) => any;
|
|
57
|
+
static createPropertyDecorator(create: (type: Type, property: string) => PropertyDecorator): <T, V>(_target: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext<T, V>) => {
|
|
58
|
+
init(this: T, initialValue: V): V;
|
|
59
|
+
};
|
|
60
|
+
static createMethodDecorator(create: (type: Type, method: string) => MethodDecorator): <T, A extends any[], R>(target: (this: T, ...args: A) => R, context: ClassMethodDecoratorContext<T, (this: T, ...args: A) => R>) => (this: T, ...args: A) => R;
|
|
61
|
+
static createParameterDecorator(create: (type: Type, method: string, parameter: Parameter) => ParameterDecorator): (methodName: string, parameterIndex: number, parameterName: string) => <T extends abstract new (...args: any) => any>(target: T, _context: ClassDecoratorContext<T>) => void;
|
|
62
|
+
static create(decorator: Decorator): void;
|
|
63
|
+
static destroy(decorator: Decorator): void;
|
|
64
|
+
static get<T extends Decorator>(query: DecoratorQueries<T> & {
|
|
65
|
+
first: true;
|
|
66
|
+
}): T;
|
|
67
|
+
static get<T extends Decorator>(query: DecoratorQueries<T> & {
|
|
68
|
+
first?: false;
|
|
69
|
+
}): T[];
|
|
70
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { $Array } from '../../array/array.util';
|
|
2
|
+
import { $Reflection } from './reflection.util';
|
|
3
|
+
export class Decorator {
|
|
4
|
+
type;
|
|
5
|
+
data;
|
|
6
|
+
constructor(type, data) {
|
|
7
|
+
this.type = type;
|
|
8
|
+
this.data = data;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class ClassDecorator extends Decorator {
|
|
12
|
+
constructor(type, data) {
|
|
13
|
+
super(type, data);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class ConstructorParameterDecorator extends Decorator {
|
|
17
|
+
parameter;
|
|
18
|
+
constructor(type, parameter, data) {
|
|
19
|
+
super(type, data);
|
|
20
|
+
this.parameter = parameter;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class PropertyDecorator extends Decorator {
|
|
24
|
+
property;
|
|
25
|
+
constructor(type, property, data) {
|
|
26
|
+
super(type, data);
|
|
27
|
+
this.property = property;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class MethodDecorator extends Decorator {
|
|
31
|
+
method;
|
|
32
|
+
constructor(type, method, data) {
|
|
33
|
+
super(type, data);
|
|
34
|
+
this.method = method;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class ParameterDecorator extends Decorator {
|
|
38
|
+
method;
|
|
39
|
+
parameter;
|
|
40
|
+
constructor(type, method, parameter, data) {
|
|
41
|
+
super(type, data);
|
|
42
|
+
this.method = method;
|
|
43
|
+
this.parameter = parameter;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export class $Decorator {
|
|
47
|
+
static decorators = [];
|
|
48
|
+
static createClassDecorator(create) {
|
|
49
|
+
return (target, _context) => {
|
|
50
|
+
const decorator = create(target);
|
|
51
|
+
$Decorator.create(decorator);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
static createConstructorParameterDecorator(create) {
|
|
55
|
+
return (_target, context) => {
|
|
56
|
+
return function (initialValue) {
|
|
57
|
+
const type = this.constructor;
|
|
58
|
+
const parameterNames = $Reflection.getParameterNames(type, 'constructor');
|
|
59
|
+
const index = parameterNames.indexOf(context.name);
|
|
60
|
+
const decorator = create(type, { index, name: context.name });
|
|
61
|
+
$Decorator.create(decorator);
|
|
62
|
+
return initialValue;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
static createPropertyDecorator(create) {
|
|
67
|
+
return (_target, context) => {
|
|
68
|
+
return {
|
|
69
|
+
init(initialValue) {
|
|
70
|
+
const type = this.constructor;
|
|
71
|
+
const decorator = create(type, context.name);
|
|
72
|
+
$Decorator.create(decorator);
|
|
73
|
+
return initialValue;
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
static createMethodDecorator(create) {
|
|
79
|
+
return (target, context) => {
|
|
80
|
+
context.addInitializer(function () {
|
|
81
|
+
const decorator = create(this.constructor, context.name);
|
|
82
|
+
$Decorator.create(decorator);
|
|
83
|
+
});
|
|
84
|
+
return target;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
static createParameterDecorator(create) {
|
|
88
|
+
return (methodName, parameterIndex, parameterName) => {
|
|
89
|
+
return (target, _context) => {
|
|
90
|
+
const decorator = create(target, methodName, { index: parameterIndex, name: parameterName });
|
|
91
|
+
$Decorator.create(decorator);
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
static create(decorator) {
|
|
96
|
+
$Decorator.decorators.push(decorator);
|
|
97
|
+
}
|
|
98
|
+
static destroy(decorator) {
|
|
99
|
+
$Decorator.decorators = $Array.remove($Decorator.decorators, decorator);
|
|
100
|
+
}
|
|
101
|
+
static get(query) {
|
|
102
|
+
const type = $Reflection.isType(query.target) ? query.target : $Reflection.getType(query.target);
|
|
103
|
+
const decorators = [];
|
|
104
|
+
for (const decorator of $Decorator.decorators) {
|
|
105
|
+
if (!$Reflection.extends(type, decorator.type))
|
|
106
|
+
continue;
|
|
107
|
+
if (query.type && !$Reflection.instanceOf(decorator, query.type))
|
|
108
|
+
continue;
|
|
109
|
+
if ('kind' in query) {
|
|
110
|
+
if (query.kind === 'class' && decorator instanceof ClassDecorator) {
|
|
111
|
+
}
|
|
112
|
+
else if (query.kind === 'ctor-parameter' && decorator instanceof ConstructorParameterDecorator) {
|
|
113
|
+
if (query.parameter != null && decorator.parameter.index !== query.parameter && decorator.parameter.name !== query.parameter)
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
else if (query.kind === 'method' && decorator instanceof MethodDecorator) {
|
|
117
|
+
if (query.method && decorator.method !== query.method)
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
else if (query.kind === 'parameter' && decorator instanceof ParameterDecorator) {
|
|
121
|
+
if (query.parameter != null && decorator.parameter.index !== query.parameter && decorator.parameter.name !== query.parameter)
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
else if (query.kind === 'property' && decorator instanceof PropertyDecorator) {
|
|
125
|
+
if (query.property && decorator.property !== query.property)
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (query.first)
|
|
130
|
+
return decorator;
|
|
131
|
+
decorators.push(decorator);
|
|
132
|
+
}
|
|
133
|
+
return query.first ? null : decorators;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { Constructor } from '../types/constructor.type';
|
|
2
|
+
import type { Type } from '../types/type.type';
|
|
3
|
+
export declare class $Reflection {
|
|
4
|
+
private constructor();
|
|
5
|
+
/**
|
|
6
|
+
* Returns the names of the parameters of the given function
|
|
7
|
+
*
|
|
8
|
+
* @static
|
|
9
|
+
* @template T
|
|
10
|
+
* @param func The function definition
|
|
11
|
+
* @param [name=''] The name of the function
|
|
12
|
+
* @return {*} The names of the parameters
|
|
13
|
+
*/
|
|
14
|
+
static getParameterNames<T extends Function>(func: T, name?: (keyof T['prototype'] & string) | 'constructor'): string[];
|
|
15
|
+
static combineClasses(...classes: Constructor[]): Constructor;
|
|
16
|
+
/**
|
|
17
|
+
* Returns true if the `target` contains a property called `name`.
|
|
18
|
+
* @param target The object containing the property.
|
|
19
|
+
* @param name The name of the property to check.
|
|
20
|
+
*/
|
|
21
|
+
static hasProperty<T>(target: object | Type<T>, name: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the type associate with the `prototype`.
|
|
24
|
+
* @param prototype The prototype which type to return.
|
|
25
|
+
*/
|
|
26
|
+
static getProtoType(prototype: object): Type | null;
|
|
27
|
+
/**
|
|
28
|
+
* Defines a property on `target` called `name` with the given `get` and `set`.
|
|
29
|
+
*
|
|
30
|
+
* @param target The object or type to define the property on.
|
|
31
|
+
* @param name The name of the property.
|
|
32
|
+
* @param get The getter of the property.
|
|
33
|
+
* @param set The setter of the property.
|
|
34
|
+
*/
|
|
35
|
+
static defineProperty<T>(target: object | Type<T>, name: string, get: () => any, set: (value: any) => void): void;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the type of the `value`.
|
|
38
|
+
* @param value The value which type to return.
|
|
39
|
+
*/
|
|
40
|
+
static getType(value: any): Type | null | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if `value` is of a primitive type.
|
|
43
|
+
* Primitive types are `undefined`, `null`, `String`, `Number`, `Boolean`.
|
|
44
|
+
* @param value The value to check for primitive type.
|
|
45
|
+
*/
|
|
46
|
+
static isPrimitive(value: any): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Returns true if `value` is of type function, lambda or class.
|
|
49
|
+
* @param value The value to check.
|
|
50
|
+
*/
|
|
51
|
+
static isFunction(value: any): value is Function;
|
|
52
|
+
/**
|
|
53
|
+
* Returns true if `value` is a type or function.
|
|
54
|
+
* @param value The value to check.
|
|
55
|
+
*/
|
|
56
|
+
static isType<T = any>(value: any): value is Type<T>;
|
|
57
|
+
static isValidDate(value: any): value is Date;
|
|
58
|
+
/**
|
|
59
|
+
* Returns true if `value` is of type `Object`.
|
|
60
|
+
* @param value The value to check.
|
|
61
|
+
*/
|
|
62
|
+
static isObject(value: any): value is Record<string, any>;
|
|
63
|
+
/**
|
|
64
|
+
* Returns true if `value` is of type `Symbol`.
|
|
65
|
+
* @param value The value to check.
|
|
66
|
+
*/
|
|
67
|
+
static isSymbol(value: any): value is symbol;
|
|
68
|
+
/**
|
|
69
|
+
* Returns true if `value` is a reference type.
|
|
70
|
+
* Reference types are `Object`, `Function`, `Array`, `Symbol`, `Date`.
|
|
71
|
+
* @param value The value to check for reference type.
|
|
72
|
+
*/
|
|
73
|
+
static isReference(value: any): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Returns true if `type` is a value type.
|
|
76
|
+
* Value types are `undefined`, `null`, `String`, `Number`, `Boolean`.
|
|
77
|
+
* @param type The type to check for value type.
|
|
78
|
+
*/
|
|
79
|
+
static isValueType(type: Type): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Returns true if `type` is a reference type.
|
|
82
|
+
* Reference types are `Object`, `Function`, `Array`, `Symbol`, `Date`.
|
|
83
|
+
* @param value The type to check for reference type.
|
|
84
|
+
*/
|
|
85
|
+
static isReferenceType(type: Type): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Returns all the properties of `object`.
|
|
88
|
+
* @param object The object which properties to return.
|
|
89
|
+
*/
|
|
90
|
+
static getProperties(object: object): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Returns the default value for `type`.
|
|
93
|
+
* @param type The type which default value to return.
|
|
94
|
+
* @example
|
|
95
|
+
* String: ''
|
|
96
|
+
* Number: 0
|
|
97
|
+
* Boolean: false
|
|
98
|
+
* Date: 0
|
|
99
|
+
* Array: []
|
|
100
|
+
* ...: null
|
|
101
|
+
*/
|
|
102
|
+
static getDefault(type: Type): any;
|
|
103
|
+
/**
|
|
104
|
+
* Sets the type of `value` to `type`.
|
|
105
|
+
* @param value The value which type to set.
|
|
106
|
+
* @param type The type to apply to the value.
|
|
107
|
+
*/
|
|
108
|
+
static setType(value: any, type: Type): any;
|
|
109
|
+
/**
|
|
110
|
+
* Returns true if `value` is of type `Array`.
|
|
111
|
+
* @param value The value to check.
|
|
112
|
+
* @param type The type of array to check for.
|
|
113
|
+
*/
|
|
114
|
+
static isArray(value: any, type?: Type): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Returns true if `type` extends `base`.
|
|
117
|
+
* @param type The type to check.
|
|
118
|
+
* @param base The base of `type` to check.
|
|
119
|
+
*/
|
|
120
|
+
static extends(type: Type, base: Type): boolean;
|
|
121
|
+
static instanceOf(value: any, type: Type): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Returns all the base types of `type`.
|
|
124
|
+
* @param type The type which base types to return.
|
|
125
|
+
*/
|
|
126
|
+
static getTypeBases(type: Type): Type[];
|
|
127
|
+
/**
|
|
128
|
+
* Returns the base type of `value`.
|
|
129
|
+
* @param value The value which base type to return.
|
|
130
|
+
*/
|
|
131
|
+
static getBaseType(value: any): Type;
|
|
132
|
+
/**
|
|
133
|
+
* Returns the base type of `type`.
|
|
134
|
+
* @param type The type which base type to return.
|
|
135
|
+
*/
|
|
136
|
+
static getTypeBase(type: Type): Type;
|
|
137
|
+
static getTypeName(value: any): string;
|
|
138
|
+
static getSimpleTypeName(value: any): 'string' | 'number' | 'object' | 'array' | 'type' | 'null' | 'boolean' | 'bigint' | 'symbol' | 'function' | 'date';
|
|
139
|
+
static parsePrimitiveValue(value: string): string | number | boolean;
|
|
140
|
+
}
|