ehr-form-engine 1.0.0-beta.21 → 1.0.0-beta.22

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.
@@ -1,12 +1,8 @@
1
1
  import { FormRenderInstance, TableRenderInstance, UploadsRenderInstance, RenderEngineProps } from '../types';
2
+ import { ValidateAllResult } from '../validators';
2
3
 
3
4
  declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<RenderEngineProps>, {}>>, {
4
- validateAll: (containerId?: string | undefined) => Promise<{
5
- success: boolean;
6
- errors: Record<string, unknown>;
7
- segmentId: string;
8
- segmentType: string;
9
- }>;
5
+ validateAll: (containerId?: string | undefined) => Promise<ValidateAllResult>;
10
6
  getComponentData: (containerId?: string | undefined) => {
11
7
  form: Record<string, Record<string, any> | undefined>;
12
8
  table: Record<string, any[] | undefined>;
@@ -7,3 +7,5 @@ export { default as UploadsRender } from './Uploads';
7
7
  export { default as RenderEngine } from './Core';
8
8
  export { default as MobileTableRender } from './MobileTable';
9
9
  export * from './types';
10
+ export type { ComponentValidator, ComponentType, ValidationResult, ValidationContext, ValidateAllResult, } from './validators/types';
11
+ export { registerValidator, hasValidator } from './validators';
@@ -25,9 +25,9 @@ export interface UploadsRenderInstance {
25
25
  }
26
26
  export interface RenderEngineInstance {
27
27
  validateAll: (containerId?: string) => Promise<{
28
- errors: Record<string, Error | string | unknown>;
28
+ errors: Record<string, Error | string>;
29
29
  segmentId: string;
30
- segmentType: 'form' | 'table' | 'upload';
30
+ segmentType: 'form' | 'table' | 'upload' | '';
31
31
  success: boolean;
32
32
  }>;
33
33
  getComponentData: (containerId?: string) => {
@@ -0,0 +1,28 @@
1
+ import { ComponentType, ComponentValidator, ComponentData, ValidationContext, ValidationResult } from './types';
2
+
3
+ /**
4
+ * 表单校验器
5
+ * 负责表单组件的校验和数据收集
6
+ */
7
+ export declare class FormValidator implements ComponentValidator {
8
+ type: ComponentType;
9
+ /**
10
+ * 获取表单数据
11
+ * @param context - 校验上下文
12
+ * @returns 表单数据
13
+ */
14
+ getData(context: ValidationContext): ComponentData;
15
+ /**
16
+ * 执行表单校验
17
+ * @param context - 校验上下文
18
+ * @returns 校验结果
19
+ */
20
+ validate(context: ValidationContext): Promise<ValidationResult>;
21
+ /**
22
+ * 标准化错误信息
23
+ * @param error - 原始错误
24
+ * @param containerId - 容器ID
25
+ * @returns 标准化后的错误信息
26
+ */
27
+ private normalizeError;
28
+ }
@@ -0,0 +1,28 @@
1
+ import { ComponentType, ComponentValidator, ComponentData, ValidationContext, ValidationResult } from './types';
2
+
3
+ /**
4
+ * 表格校验器
5
+ * 负责表格组件的校验和数据收集
6
+ */
7
+ export declare class TableValidator implements ComponentValidator {
8
+ type: ComponentType;
9
+ /**
10
+ * 获取表格数据
11
+ * @param context - 校验上下文
12
+ * @returns 表格数据
13
+ */
14
+ getData(context: ValidationContext): ComponentData;
15
+ /**
16
+ * 执行表格校验
17
+ * @param context - 校验上下文
18
+ * @returns 校验结果
19
+ */
20
+ validate(context: ValidationContext): Promise<ValidationResult>;
21
+ /**
22
+ * 标准化错误信息
23
+ * @param error - 原始错误
24
+ * @param containerId - 容器ID
25
+ * @returns 标准化后的错误信息
26
+ */
27
+ private normalizeError;
28
+ }
@@ -0,0 +1,28 @@
1
+ import { ComponentType, ComponentValidator, ComponentData, ValidationContext, ValidationResult } from './types';
2
+
3
+ /**
4
+ * 上传组件校验器
5
+ * 负责上传组件的校验和数据收集
6
+ */
7
+ export declare class UploadValidator implements ComponentValidator {
8
+ type: ComponentType;
9
+ /**
10
+ * 获取上传数据
11
+ * @param context - 校验上下文
12
+ * @returns 上传数据
13
+ */
14
+ getData(context: ValidationContext): ComponentData;
15
+ /**
16
+ * 执行上传组件校验
17
+ * @param context - 校验上下文
18
+ * @returns 校验结果
19
+ */
20
+ validate(context: ValidationContext): Promise<ValidationResult>;
21
+ /**
22
+ * 标准化错误信息
23
+ * @param error - 原始错误
24
+ * @param containerId - 容器ID
25
+ * @returns 标准化后的错误信息
26
+ */
27
+ private normalizeError;
28
+ }
@@ -0,0 +1,22 @@
1
+ import { ComponentValidator, ComponentType } from './types';
2
+
3
+ /**
4
+ * 获取校验器
5
+ * @param type - 组件类型
6
+ * @returns 对应类型的校验器实例
7
+ * @throws 如果未找到对应类型的校验器
8
+ */
9
+ export declare function getValidator(type: ComponentType): ComponentValidator;
10
+ /**
11
+ * 检查是否已注册某类型的校验器
12
+ * @param type - 组件类型
13
+ * @returns 是否已注册
14
+ */
15
+ export declare function hasValidator(type: ComponentType): boolean;
16
+ /**
17
+ * 注册自定义校验器
18
+ * @param type - 组件类型
19
+ * @param validator - 校验器实例
20
+ * @description 可用于扩展自定义组件类型的校验逻辑
21
+ */
22
+ export declare function registerValidator(type: ComponentType, validator: ComponentValidator): void;
@@ -0,0 +1,21 @@
1
+ import { ComponentType, ValidationContext, ValidationResult } from './types';
2
+
3
+ /**
4
+ * 校验组件
5
+ * @param type - 组件类型
6
+ * @param context - 校验上下文
7
+ * @returns 校验结果
8
+ */
9
+ export declare function validateComponent(type: ComponentType, context: ValidationContext): Promise<ValidationResult>;
10
+ /**
11
+ * 获取组件数据
12
+ * @param type - 组件类型
13
+ * @param context - 校验上下文
14
+ * @returns 组件数据
15
+ */
16
+ export declare function getComponentDataByType(type: ComponentType, context: ValidationContext): any;
17
+ export { FormValidator } from './FormValidator';
18
+ export { TableValidator } from './TableValidator';
19
+ export { UploadValidator } from './UploadValidator';
20
+ export type { ComponentType, ComponentValidator, ComponentData, ComponentInstance, ValidateAllResult, ValidationContext, ValidationError, ValidationResult, ValidationSequenceItem, } from './types';
21
+ export { getValidator, hasValidator, registerValidator } from './ValidatorFactory';
@@ -0,0 +1,36 @@
1
+ import { FormRenderInstance, TableRenderInstance, UploadsRenderInstance } from '../types';
2
+
3
+ export type ComponentType = 'form' | 'table' | 'upload';
4
+ export type ComponentInstance = FormRenderInstance | TableRenderInstance | UploadsRenderInstance | undefined;
5
+ export type ComponentData = Record<string, any> | any[] | undefined;
6
+ export interface ValidationResult {
7
+ success: boolean;
8
+ error?: Error | string;
9
+ data?: ComponentData;
10
+ }
11
+ export interface ValidationContext {
12
+ containerId: string;
13
+ componentRef: ComponentInstance;
14
+ }
15
+ export interface ComponentValidator {
16
+ type: ComponentType;
17
+ validate(context: ValidationContext): Promise<ValidationResult>;
18
+ getData(context: ValidationContext): ComponentData;
19
+ }
20
+ export interface ValidationError {
21
+ segmentId: string;
22
+ segmentType: ComponentType;
23
+ error: Error | string;
24
+ }
25
+ export interface ValidateAllResult {
26
+ success: boolean;
27
+ errors: Record<string, Error | string>;
28
+ segmentId: string;
29
+ segmentType: 'form' | 'table' | 'upload' | '';
30
+ }
31
+ export interface ValidationSequenceItem {
32
+ type: ComponentType;
33
+ getIds: () => string[];
34
+ getRef: (_id: string) => ComponentInstance;
35
+ getDataStore: () => Record<string, ComponentData>;
36
+ }