data-faker-plus 0.0.1
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 +584 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.umd.js +1 -0
- package/dist/types/common/ClassDecoratorStateManager.d.ts +47 -0
- package/dist/types/common/ClassDecoratorValidator.d.ts +28 -0
- package/dist/types/common/DecoratorValidator.d.ts +14 -0
- package/dist/types/common/PropertyDecoraotrValidator.d.ts +30 -0
- package/dist/types/constants/DataFakerConstants.d.ts +2 -0
- package/dist/types/constants/DecoratorConstants.d.ts +5 -0
- package/dist/types/constants/MetaDataConstants.d.ts +4 -0
- package/dist/types/core/DataFaker.d.ts +43 -0
- package/dist/types/core/DataFieldDecoratorFactory.d.ts +38 -0
- package/dist/types/core/DataModel.d.ts +39 -0
- package/dist/types/core/DataModelDecoratorFactory.d.ts +48 -0
- package/dist/types/core/DecoratorInfo.d.ts +37 -0
- package/dist/types/core/LocaleParser.d.ts +16 -0
- package/dist/types/core/ModelManager.d.ts +53 -0
- package/dist/types/core/ModelParser.d.ts +62 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/types/decorator.d.ts +70 -0
- package/dist/types/types/faker.d.ts +238 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/index.ts +2 -0
- package/dist/types/utils/IdUtils.d.ts +13 -0
- package/dist/types/utils/ObjectUtils.d.ts +9 -0
- package/package.json +58 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DecoratorInfo } from '../core/DecoratorInfo';
|
|
2
|
+
import { DecoratedClass } from '../types/decorator';
|
|
3
|
+
/**
|
|
4
|
+
* 类状态管理器
|
|
5
|
+
* @description 管理类的状态,包括定义在类上装饰器的配置,定义在类上的装饰器
|
|
6
|
+
*/
|
|
7
|
+
export declare class ClassDecoratorStateManager {
|
|
8
|
+
/**
|
|
9
|
+
* 单例模式
|
|
10
|
+
*/
|
|
11
|
+
private static instance;
|
|
12
|
+
/**
|
|
13
|
+
* 获取实例
|
|
14
|
+
* @returns ClassDecoratorStateManager 单例
|
|
15
|
+
*/
|
|
16
|
+
static getInstance(): ClassDecoratorStateManager;
|
|
17
|
+
/**
|
|
18
|
+
* 初始化类装饰器元数据列表
|
|
19
|
+
* @param target 被装饰的类
|
|
20
|
+
* @param decorationInfos 装饰器信息列表
|
|
21
|
+
*/
|
|
22
|
+
initDecoratorInfos(target: DecoratedClass, decorationInfos?: DecoratorInfo[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* 是否有装饰器信息元数据列表
|
|
25
|
+
*/
|
|
26
|
+
hasDecoratorInfos(target: DecoratedClass): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 是否有指定装饰器信息元数据
|
|
29
|
+
*/
|
|
30
|
+
hasDecoratorInfo(target: DecoratedClass, decoratorName: string | symbol): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 设置类装饰器信息列表元数据
|
|
33
|
+
*/
|
|
34
|
+
setDecoratorInfos(target: DecoratedClass, decoratorInfos: DecoratorInfo[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* 在类上添加装饰器信息
|
|
37
|
+
*/
|
|
38
|
+
setDecoratorInfo(target: DecoratedClass, decoratorInfo: DecoratorInfo): void;
|
|
39
|
+
/**
|
|
40
|
+
* 获取类上所有装饰器信息
|
|
41
|
+
*/
|
|
42
|
+
getDecoratorInfos(target: DecoratedClass): DecoratorInfo[] | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* 获取类上装饰器信息元数据
|
|
45
|
+
*/
|
|
46
|
+
getDecoratorInfo(target: DecoratedClass, decoratorName: string | symbol): DecoratorInfo | undefined;
|
|
47
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DecoratorValidator } from './DecoratorValidator';
|
|
2
|
+
import { DecoratedClass } from '../types/decorator';
|
|
3
|
+
/**
|
|
4
|
+
* 类装饰器校验器
|
|
5
|
+
* @description 封装装饰器校验的通用方法
|
|
6
|
+
*/
|
|
7
|
+
export declare class ClassDecoratorValidator implements DecoratorValidator {
|
|
8
|
+
/**
|
|
9
|
+
* 类装饰器校验器实例
|
|
10
|
+
*/
|
|
11
|
+
private static instance;
|
|
12
|
+
/**
|
|
13
|
+
* 获取单例实例
|
|
14
|
+
*/
|
|
15
|
+
static getInstance(): ClassDecoratorValidator;
|
|
16
|
+
/**
|
|
17
|
+
* 检查是否有装饰器所要依赖的装饰器
|
|
18
|
+
* @param target 类装饰器
|
|
19
|
+
* @param dpDecorators 依赖的装饰器
|
|
20
|
+
* @param propertyKey 属性名称
|
|
21
|
+
* @description 有一些装饰器需要依赖于其它装饰器的存在才能工作
|
|
22
|
+
*/
|
|
23
|
+
hasDependentedDecorator(target: any, dpDecorators: (string | symbol)[]): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* 检查类装饰器是否与其它装饰冲突
|
|
26
|
+
*/
|
|
27
|
+
isDecoratorConflict(target: DecoratedClass, conflictList: (string | symbol)[]): boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 装饰器校验器
|
|
3
|
+
* @description 封装装饰器校验的通用方法
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class DecoratorValidator {
|
|
6
|
+
/**
|
|
7
|
+
* 检查装饰器依赖的装饰器是否存在
|
|
8
|
+
*/
|
|
9
|
+
abstract hasDependentedDecorator(...args: any[]): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* 检查装饰器是否与其它装饰冲突
|
|
12
|
+
*/
|
|
13
|
+
abstract isDecoratorConflict(...args: any[]): boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DecoratorValidator } from './DecoratorValidator';
|
|
2
|
+
import { DecoratedClass, DecoratedClassProto } from '../types/decorator';
|
|
3
|
+
/**
|
|
4
|
+
* 属性装饰器校验器
|
|
5
|
+
*/
|
|
6
|
+
export declare class PropertyDecoratorValidator implements DecoratorValidator {
|
|
7
|
+
/**
|
|
8
|
+
* 单例模式
|
|
9
|
+
*/
|
|
10
|
+
private static instance;
|
|
11
|
+
/**
|
|
12
|
+
* 获取PropertyDecoratorValidator实例
|
|
13
|
+
* ..returns PropertyDecoratorValidator实例
|
|
14
|
+
*/
|
|
15
|
+
static getInstance(): PropertyDecoratorValidator;
|
|
16
|
+
/**
|
|
17
|
+
* 是否有依赖的装饰器
|
|
18
|
+
* ..param target 被装饰的目标对象或其原型
|
|
19
|
+
* ..param decoratorName 装饰器名称
|
|
20
|
+
* ..param propertyKey 属性名称
|
|
21
|
+
*/
|
|
22
|
+
hasDependentedDecorator(target: any, dpDecorators: (string | symbol)[], propertyKey: string | symbol): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 判断属性上是否存在冲突的装饰器
|
|
25
|
+
* ..param target 被装饰的目标对象或其原型
|
|
26
|
+
* ..param decoratorName 装饰器名称
|
|
27
|
+
* ..param propertyKey 属性名称
|
|
28
|
+
*/
|
|
29
|
+
isDecoratorConflict(target: DecoratedClass | DecoratedClassProto, conflictList: (string | symbol)[], propertyKey: string | symbol): boolean;
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Faker } from '@faker-js/faker';
|
|
2
|
+
import { DModel } from './DataModel';
|
|
3
|
+
import { DataFakeHook, DataFakeOptions, LocaleType } from '../types/faker';
|
|
4
|
+
/**
|
|
5
|
+
* FakerApi类
|
|
6
|
+
* 提供定义模型的方法
|
|
7
|
+
*/
|
|
8
|
+
export declare class DataFaker {
|
|
9
|
+
/**
|
|
10
|
+
* 当前语言
|
|
11
|
+
* ..default 英文环境
|
|
12
|
+
*/
|
|
13
|
+
static locale: Faker;
|
|
14
|
+
/**
|
|
15
|
+
* 全局回调函数
|
|
16
|
+
*/
|
|
17
|
+
static hooks: DataFakeHook;
|
|
18
|
+
/**
|
|
19
|
+
* 设置当前语言环境
|
|
20
|
+
* ..param locale 语言环境
|
|
21
|
+
*/
|
|
22
|
+
static setLocale(locale?: LocaleType): void;
|
|
23
|
+
/**
|
|
24
|
+
* 设置全局回调函数
|
|
25
|
+
*/
|
|
26
|
+
static setHooks(hooks?: DataFakeHook): void;
|
|
27
|
+
/**
|
|
28
|
+
* 合并hooks
|
|
29
|
+
*/
|
|
30
|
+
static unionHooks(runtimeHooks?: DataFakeHook): DataFakeHook;
|
|
31
|
+
/**
|
|
32
|
+
* 合并回调函数
|
|
33
|
+
*/
|
|
34
|
+
private static mergeCb;
|
|
35
|
+
/**
|
|
36
|
+
* 伪造数据
|
|
37
|
+
*/
|
|
38
|
+
static fake(dataModel: DModel | string | symbol | undefined | null, options?: DataFakeOptions | number): any;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 伪造数据
|
|
42
|
+
*/
|
|
43
|
+
export declare function fakeData(dataModel: DModel | string | symbol | undefined | null, options?: DataFakeOptions | number): any;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DecoratorInfo } from './DecoratorInfo';
|
|
2
|
+
import { PropertyDecoratorValidator } from '../common/PropertyDecoraotrValidator';
|
|
3
|
+
import 'reflect-metadata';
|
|
4
|
+
import { DecoratedClassOrProto } from '../types/decorator';
|
|
5
|
+
import { CustomGenerator, DataFieldType, FakerMethodParamsType, FakerMethodPath, RefModel } from '../types/faker';
|
|
6
|
+
/**
|
|
7
|
+
* 数据字段装饰器工厂
|
|
8
|
+
*/
|
|
9
|
+
export declare class DataFieldDecoratorFactory {
|
|
10
|
+
/**
|
|
11
|
+
* 装饰器信息
|
|
12
|
+
*/
|
|
13
|
+
protected decoratorInfo: DecoratorInfo;
|
|
14
|
+
/**
|
|
15
|
+
* 装饰器校验器
|
|
16
|
+
*/
|
|
17
|
+
protected decoratorValidator: PropertyDecoratorValidator;
|
|
18
|
+
/**
|
|
19
|
+
* 初始化装饰
|
|
20
|
+
*/
|
|
21
|
+
protected initDecoratorInfo(): void;
|
|
22
|
+
/**
|
|
23
|
+
* 校验装饰器
|
|
24
|
+
*/
|
|
25
|
+
protected validateDecorator(target: DecoratedClassOrProto, propertyKey: string | symbol): void;
|
|
26
|
+
/**
|
|
27
|
+
* 设置状态
|
|
28
|
+
* ..param target 被装饰的类或原型
|
|
29
|
+
* ..param propertyKey 被装饰的属性名
|
|
30
|
+
* ..param config 配置
|
|
31
|
+
*/
|
|
32
|
+
protected setupState(target: DecoratedClassOrProto, propertyKey: string | symbol, config: DataFieldType): void;
|
|
33
|
+
createDecorator(config: DataFieldType): PropertyDecorator;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 数据字段装饰器
|
|
37
|
+
*/
|
|
38
|
+
export declare function DataField<P extends FakerMethodPath>(options: FakerMethodPath | [P, FakerMethodParamsType<P>] | CustomGenerator | RefModel): PropertyDecorator;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DataFieldType, ModelSchema } from '../types/faker';
|
|
2
|
+
/**
|
|
3
|
+
* 数据模型
|
|
4
|
+
*/
|
|
5
|
+
export declare class DModel {
|
|
6
|
+
/**
|
|
7
|
+
* 模型模板
|
|
8
|
+
*/
|
|
9
|
+
private modelSchema;
|
|
10
|
+
/**
|
|
11
|
+
* 模型别名
|
|
12
|
+
*/
|
|
13
|
+
private modelName;
|
|
14
|
+
constructor(modelName: string | symbol, modelSchema: Record<string | symbol, DataFieldType>);
|
|
15
|
+
/**
|
|
16
|
+
* 添加属性
|
|
17
|
+
*/
|
|
18
|
+
withProperty(name: string, type: DataFieldType): this;
|
|
19
|
+
/**
|
|
20
|
+
* 添加多个属性
|
|
21
|
+
*/
|
|
22
|
+
withProperties(properties: Record<string, DataFieldType>): this;
|
|
23
|
+
/**
|
|
24
|
+
* 排除属性
|
|
25
|
+
*/
|
|
26
|
+
excludeProperty(name: string | symbol): this;
|
|
27
|
+
/**
|
|
28
|
+
* 排除属性
|
|
29
|
+
*/
|
|
30
|
+
excludeProperties(excluedes: (string | symbol)[]): this;
|
|
31
|
+
/**
|
|
32
|
+
* 获取模板
|
|
33
|
+
*/
|
|
34
|
+
getModelSchema(): ModelSchema;
|
|
35
|
+
/**
|
|
36
|
+
* 获取模型名
|
|
37
|
+
*/
|
|
38
|
+
getModelName(): string | symbol;
|
|
39
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ClassDecoratorValidator } from '../common/ClassDecoratorValidator';
|
|
2
|
+
import { DecoratorInfo } from './DecoratorInfo';
|
|
3
|
+
import { ClassDecorator, DecoratedClass } from '../types/decorator';
|
|
4
|
+
import { ClassDecoratorStateManager } from '../common/ClassDecoratorStateManager';
|
|
5
|
+
/**
|
|
6
|
+
* 数据模型装饰器工厂类
|
|
7
|
+
*/
|
|
8
|
+
export declare class DataModelDecoratorFactory {
|
|
9
|
+
/**
|
|
10
|
+
* 装饰器信息
|
|
11
|
+
*/
|
|
12
|
+
protected decoratorInfo: DecoratorInfo;
|
|
13
|
+
/**
|
|
14
|
+
* 装饰器校验器
|
|
15
|
+
*/
|
|
16
|
+
protected decoratorValidator: ClassDecoratorValidator;
|
|
17
|
+
/**
|
|
18
|
+
* 状态管理器
|
|
19
|
+
*/
|
|
20
|
+
protected stateManager: ClassDecoratorStateManager;
|
|
21
|
+
/**
|
|
22
|
+
* 初始化装饰器信息
|
|
23
|
+
*/
|
|
24
|
+
protected initDecoratorInfo(): void;
|
|
25
|
+
/**
|
|
26
|
+
* 校验装饰器
|
|
27
|
+
*/
|
|
28
|
+
protected validateDecorator(target: DecoratedClass): void;
|
|
29
|
+
/**
|
|
30
|
+
* 获取模型并注入工厂
|
|
31
|
+
* ..param target 被装饰的类
|
|
32
|
+
* ..param modelName 模型名
|
|
33
|
+
*/
|
|
34
|
+
protected setupState(target: DecoratedClass, modelName: string | symbol): void;
|
|
35
|
+
/**
|
|
36
|
+
* 递归继承属性
|
|
37
|
+
*/
|
|
38
|
+
private extendSchema;
|
|
39
|
+
/**
|
|
40
|
+
* 创建装饰器
|
|
41
|
+
* ..param modelName 模型名
|
|
42
|
+
*/
|
|
43
|
+
createDecorator(modelName: string | symbol): ClassDecorator;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 数据模型装饰器
|
|
47
|
+
*/
|
|
48
|
+
export declare function DataModel(modelName: string | symbol): ClassDecorator;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DecorationInfo } from '../types/decorator';
|
|
2
|
+
/**
|
|
3
|
+
* 装饰器信息建造者
|
|
4
|
+
*/
|
|
5
|
+
export declare class DecoratorInfo implements DecorationInfo {
|
|
6
|
+
/**
|
|
7
|
+
* 装饰器信息编号
|
|
8
|
+
*/
|
|
9
|
+
readonly id: string;
|
|
10
|
+
/**
|
|
11
|
+
* 装饰器名称
|
|
12
|
+
* ..default DECORATORNAME.ANONYMOUSE
|
|
13
|
+
*/
|
|
14
|
+
name: string | symbol;
|
|
15
|
+
/**
|
|
16
|
+
* 装饰器配置
|
|
17
|
+
*/
|
|
18
|
+
configs: any[];
|
|
19
|
+
/**
|
|
20
|
+
* 装饰器冲突列表
|
|
21
|
+
*/
|
|
22
|
+
conflictList: (string | symbol)[];
|
|
23
|
+
/**
|
|
24
|
+
* 依赖装饰器
|
|
25
|
+
*/
|
|
26
|
+
dependsOn: (string | symbol)[];
|
|
27
|
+
/**
|
|
28
|
+
* 构造器
|
|
29
|
+
* ..param decoratorInfo 装饰器信息对象
|
|
30
|
+
* ..returns 装饰器信息对象
|
|
31
|
+
*/
|
|
32
|
+
constructor(decoratorInfo?: DecorationInfo);
|
|
33
|
+
setName(name: string | symbol): this;
|
|
34
|
+
setConfig(config?: any): this;
|
|
35
|
+
setConflictList(conflictList: (string | symbol)[]): this;
|
|
36
|
+
setDependsOn(dependsOn: (string | symbol)[]): this;
|
|
37
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LocaleType } from '../types/faker';
|
|
2
|
+
import { Faker } from '@faker-js/faker';
|
|
3
|
+
/**
|
|
4
|
+
* 语言解析器
|
|
5
|
+
*/
|
|
6
|
+
export declare class LocaleParser {
|
|
7
|
+
/**
|
|
8
|
+
* faker缓存
|
|
9
|
+
*/
|
|
10
|
+
private static fakerCache;
|
|
11
|
+
/**
|
|
12
|
+
* 解析语言环境
|
|
13
|
+
* ..param locale 语言选项
|
|
14
|
+
*/
|
|
15
|
+
static parseLocale(locale?: LocaleType): Faker | undefined;
|
|
16
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { DataFieldType } from '../types/faker';
|
|
2
|
+
import { DModel } from './DataModel';
|
|
3
|
+
import { ClassDecoratorStateManager } from '../common/ClassDecoratorStateManager';
|
|
4
|
+
import { DecoratedClass } from '../types/decorator';
|
|
5
|
+
/**
|
|
6
|
+
* 模型管理器
|
|
7
|
+
*/
|
|
8
|
+
export declare class ModelManager {
|
|
9
|
+
/**
|
|
10
|
+
* 数据模型映射
|
|
11
|
+
*/
|
|
12
|
+
private static dataModelMap;
|
|
13
|
+
/**
|
|
14
|
+
* 状态管理器
|
|
15
|
+
*/
|
|
16
|
+
protected static stateManager: ClassDecoratorStateManager;
|
|
17
|
+
/**
|
|
18
|
+
* 定义模型
|
|
19
|
+
*/
|
|
20
|
+
static defineModel(modelName: string | symbol, modelSchema: Record<string, DataFieldType>): DModel;
|
|
21
|
+
/**
|
|
22
|
+
* 克隆模型
|
|
23
|
+
*/
|
|
24
|
+
static cloneModel(newModelName: string | symbol, dataModel: DModel): DModel;
|
|
25
|
+
/**
|
|
26
|
+
* 使用模型
|
|
27
|
+
*/
|
|
28
|
+
static useModel(target: DecoratedClass | string | symbol): DModel | null | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* 注册数据模型
|
|
31
|
+
*/
|
|
32
|
+
private static registerDataModel;
|
|
33
|
+
/**
|
|
34
|
+
* 是否有数据模型
|
|
35
|
+
*/
|
|
36
|
+
private static hasDataModel;
|
|
37
|
+
/**
|
|
38
|
+
* 获取数据模型
|
|
39
|
+
*/
|
|
40
|
+
static getDataModel(modelName: string | symbol): DModel | undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 定义模型
|
|
44
|
+
*/
|
|
45
|
+
export declare function defineModel(modelName: string | symbol, modelSchema: Record<string, DataFieldType>): DModel;
|
|
46
|
+
/**
|
|
47
|
+
* 克隆模型
|
|
48
|
+
*/
|
|
49
|
+
export declare function cloneModel(newModelName: string | symbol, dataModel: DModel): DModel;
|
|
50
|
+
/**
|
|
51
|
+
* 使用模型
|
|
52
|
+
*/
|
|
53
|
+
export declare function useModel(target: DecoratedClass | string | symbol): DModel | null | undefined;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { RefModelRule, DataFakeHook } from '../types/faker';
|
|
2
|
+
import { Faker } from '@faker-js/faker';
|
|
3
|
+
import { DModel } from './DataModel';
|
|
4
|
+
/**
|
|
5
|
+
* 模型解析器
|
|
6
|
+
*/
|
|
7
|
+
export declare class ModelParser {
|
|
8
|
+
/**
|
|
9
|
+
* 当前语言
|
|
10
|
+
* ..default 英文环境
|
|
11
|
+
*/
|
|
12
|
+
private static locale;
|
|
13
|
+
/**
|
|
14
|
+
* 钩子函数
|
|
15
|
+
*/
|
|
16
|
+
private static hooks;
|
|
17
|
+
/**
|
|
18
|
+
* 引用规则
|
|
19
|
+
*/
|
|
20
|
+
private static refRules;
|
|
21
|
+
/**
|
|
22
|
+
* 设置当前语言环境
|
|
23
|
+
* ..param locale 语言环境
|
|
24
|
+
*/
|
|
25
|
+
static setLocale(locale: Faker): typeof ModelParser;
|
|
26
|
+
/**
|
|
27
|
+
* 设置钩子函数
|
|
28
|
+
*/
|
|
29
|
+
static setHooks(hooks?: DataFakeHook): typeof ModelParser;
|
|
30
|
+
/**
|
|
31
|
+
* 设置引用规则
|
|
32
|
+
*/
|
|
33
|
+
static setRefRules(refRules?: RefModelRule): typeof ModelParser;
|
|
34
|
+
/**
|
|
35
|
+
* 使用的模型
|
|
36
|
+
*/
|
|
37
|
+
static parseModel(dataModel: DModel | string | symbol, count?: number): any;
|
|
38
|
+
/**
|
|
39
|
+
* 解析模式
|
|
40
|
+
*/
|
|
41
|
+
private static parseScheme;
|
|
42
|
+
/**
|
|
43
|
+
* 处理字符串schema
|
|
44
|
+
*/
|
|
45
|
+
private static parseStringSchema;
|
|
46
|
+
/**
|
|
47
|
+
* 处理数组schema
|
|
48
|
+
*/
|
|
49
|
+
private static parseArraySchema;
|
|
50
|
+
/**
|
|
51
|
+
* 解析引用对象schema
|
|
52
|
+
*/
|
|
53
|
+
private static parseRefSchema;
|
|
54
|
+
/**
|
|
55
|
+
* 执行hooks
|
|
56
|
+
*/
|
|
57
|
+
private static executeHooks;
|
|
58
|
+
/**
|
|
59
|
+
* 解析路径方法字符串
|
|
60
|
+
*/
|
|
61
|
+
private static parsePathMethod;
|
|
62
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DataModel } from './core/DataModelDecoratorFactory';
|
|
2
|
+
export { DataField } from './core/DataFieldDecoratorFactory';
|
|
3
|
+
export { fakeData } from './core/DataFaker';
|
|
4
|
+
export { useModel, cloneModel, defineModel } from './core/ModelManager';
|
|
5
|
+
export { COUNT, DEEP } from './constants/DataFakerConstants';
|
|
6
|
+
export * from '@faker-js/faker';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 构造器
|
|
3
|
+
*/
|
|
4
|
+
export type Constructor<T = any> = new (...args: any[]) => T;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 被装饰类原型
|
|
8
|
+
*/
|
|
9
|
+
type DecoratedClassProto = {};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 被装饰类
|
|
13
|
+
*/
|
|
14
|
+
export type DecoratedClass<T = any> = Constructor<T>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 被装饰类或原型
|
|
18
|
+
*/
|
|
19
|
+
export type DecoratedClassOrProto = DecoratedClass | DecoratedClassProto;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 类装饰器
|
|
23
|
+
*/
|
|
24
|
+
export type ClassDecorator = (target: DecoratedClass) => void;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 方法装饰器
|
|
28
|
+
*/
|
|
29
|
+
export type MethodDecorator = (
|
|
30
|
+
target: DecoratedClassOrProto,
|
|
31
|
+
propertyKey: string | symbol,
|
|
32
|
+
descriptor: TypedPropertyDescriptor<any>,
|
|
33
|
+
) => void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 属性装饰器
|
|
37
|
+
*/
|
|
38
|
+
export type PropertyDecorator = (target: DecoratedClassOrProto, propertyKey: string) => void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 装饰器信息模板
|
|
42
|
+
*/
|
|
43
|
+
export interface DecorationInfo {
|
|
44
|
+
/**
|
|
45
|
+
* 装饰器编号
|
|
46
|
+
*/
|
|
47
|
+
id?: string;
|
|
48
|
+
/**
|
|
49
|
+
* 装饰器信息名称
|
|
50
|
+
*/
|
|
51
|
+
name: string | symbol;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 装饰器信息配置
|
|
55
|
+
*/
|
|
56
|
+
configs?: any[];
|
|
57
|
+
/**
|
|
58
|
+
* 装饰器冲突列表
|
|
59
|
+
*/
|
|
60
|
+
conflictList?: (string | symbol)[];
|
|
61
|
+
/**
|
|
62
|
+
* 所依赖的装饰器列表
|
|
63
|
+
*/
|
|
64
|
+
dependsOn?: (string | symbol)[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 装饰器列表元数据
|
|
69
|
+
*/
|
|
70
|
+
export type DecoratorInfos = DecorationInfo[];
|