@@ -3,6 +3,7 @@ import { WorkflowIOValueTypeEnum, NodeInputKeyEnum, NodeOutputKeyEnum } from '..
33import { FlowNodeInputTypeEnum , FlowNodeOutputTypeEnum } from '../node/constant' ;
44import { SecretValueTypeSchema } from '../../../common/secret/type' ;
55import z from 'zod' ;
6+ import { BoolSchema , IntSchema , NumSchema } from '../../../common/zod' ;
67
78/* Dataset node */
89export const SelectedDatasetSchema = z . object ( {
@@ -19,8 +20,9 @@ export type SelectedDatasetType = z.infer<typeof SelectedDatasetSchema>;
1920export const CustomFieldConfigTypeSchema = z . object ( {
2021 // reference
2122 selectValueTypeList : z . array ( z . enum ( WorkflowIOValueTypeEnum ) ) . optional ( ) , // 可以选哪个数据类型, 只有1个的话,则默认选择
22- showDefaultValue : z . boolean ( ) . optional ( ) ,
23- showDescription : z . boolean ( ) . optional ( )
23+ showDefaultValue : BoolSchema . optional ( ) ,
24+ showDescription : BoolSchema . optional ( ) ,
25+ hideBottomDivider : BoolSchema . optional ( )
2426} ) ;
2527export type CustomFieldConfigType = z . infer < typeof CustomFieldConfigTypeSchema > ;
2628
@@ -29,31 +31,40 @@ export const InputComponentPropsTypeSchema = z.object({
2931 label : z . string ( ) ,
3032
3133 valueType : z . enum ( WorkflowIOValueTypeEnum ) . optional ( ) ,
32- required : z . boolean ( ) . optional ( ) ,
34+ required : BoolSchema . optional ( ) ,
3335 defaultValue : z . any ( ) . optional ( ) ,
3436
3537 // 不同组件的配置嘻嘻
3638 referencePlaceholder : z . string ( ) . optional ( ) ,
37- isRichText : z . boolean ( ) . optional ( ) , // Prompt editor
39+ isRichText : BoolSchema . optional ( ) , // Prompt editor
3840 placeholder : z . string ( ) . optional ( ) , // input,textarea
39- maxLength : z . number ( ) . optional ( ) , // input,textarea
40- minLength : z . number ( ) . optional ( ) , // password
41- list : z . array ( z . object ( { label : z . string ( ) , value : z . string ( ) } ) ) . optional ( ) , // select
42- markList : z . array ( z . object ( { label : z . string ( ) , value : z . number ( ) } ) ) . optional ( ) , // slider
43- step : z . number ( ) . optional ( ) , // slider
44- max : z . number ( ) . optional ( ) , // slider, number input
45- min : z . number ( ) . optional ( ) , // slider, number input
46- precision : z . number ( ) . optional ( ) , // number input
47-
48- canSelectFile : z . boolean ( ) . optional ( ) , // file select
49- canSelectImg : z . boolean ( ) . optional ( ) , // file select
50- canSelectVideo : z . boolean ( ) . optional ( ) , // file select
51- canSelectAudio : z . boolean ( ) . optional ( ) , // file select
52- canSelectCustomFileExtension : z . boolean ( ) . optional ( ) , // file select
41+ maxLength : IntSchema . optional ( ) , // input,textarea
42+ minLength : IntSchema . optional ( ) , // password
43+ list : z
44+ . array (
45+ z . object ( {
46+ label : z . string ( ) ,
47+ value : z . string ( ) ,
48+ icon : z . string ( ) . optional ( ) ,
49+ description : z . string ( ) . optional ( )
50+ } )
51+ )
52+ . optional ( ) , // select
53+ markList : z . array ( z . object ( { label : z . string ( ) , value : NumSchema } ) ) . optional ( ) , // slider
54+ step : NumSchema . optional ( ) , // slider
55+ max : NumSchema . optional ( ) , // slider, number input
56+ min : NumSchema . optional ( ) , // slider, number input
57+ precision : NumSchema . optional ( ) , // number input
58+
59+ canSelectFile : BoolSchema . optional ( ) , // file select
60+ canSelectImg : BoolSchema . optional ( ) , // file select
61+ canSelectVideo : BoolSchema . optional ( ) , // file select
62+ canSelectAudio : BoolSchema . optional ( ) , // file select
63+ canSelectCustomFileExtension : BoolSchema . optional ( ) , // file select
5364 customFileExtensionList : z . array ( z . string ( ) ) . optional ( ) , // file select
54- canLocalUpload : z . boolean ( ) . optional ( ) , // file select
55- canUrlUpload : z . boolean ( ) . optional ( ) , // file select
56- maxFiles : z . number ( ) . optional ( ) , // file select
65+ canLocalUpload : BoolSchema . optional ( ) , // file select
66+ canUrlUpload : BoolSchema . optional ( ) , // file select
67+ maxFiles : IntSchema . optional ( ) , // file select
5768
5869 // Time
5970 timeGranularity : z . enum ( [ 'day' , 'hour' , 'minute' , 'second' ] ) . optional ( ) , // time point select, time range select
@@ -76,7 +87,7 @@ export const InputConfigTypeSchema = z.object({
7687 key : z . string ( ) ,
7788 label : z . string ( ) ,
7889 description : z . string ( ) . optional ( ) ,
79- required : z . boolean ( ) . optional ( ) ,
90+ required : BoolSchema . optional ( ) ,
8091 inputType : z . enum ( [ 'input' , 'numberInput' , 'secret' , 'switch' , 'select' ] ) ,
8192 value : SecretValueTypeSchema . optional ( ) ,
8293
@@ -87,7 +98,7 @@ export type InputConfigType = z.infer<typeof InputConfigTypeSchema>;
8798
8899// Workflow node input
89100export const FlowNodeInputItemTypeSchema = InputComponentPropsTypeSchema . extend ( {
90- selectedTypeIndex : z . number ( ) . optional ( ) ,
101+ selectedTypeIndex : IntSchema . optional ( ) ,
91102 renderTypeList : z . array ( z . enum ( FlowNodeInputTypeEnum ) ) , // Node Type. Decide on a render style
92103 valueDesc : z . string ( ) . optional ( ) , // data desc
93104 value : z . any ( ) . optional ( ) ,
@@ -101,11 +112,11 @@ export const FlowNodeInputItemTypeSchema = InputComponentPropsTypeSchema.extend(
101112 inputList : z . array ( InputConfigTypeSchema ) . optional ( ) , // when key === 'system_input_config', this field is used
102113
103114 // render components params
104- canEdit : z . boolean ( ) . optional ( ) , // dynamic inputs
105- isPro : z . boolean ( ) . optional ( ) , // Pro version field
106- isToolOutput : z . boolean ( ) . optional ( ) ,
115+ canEdit : BoolSchema . optional ( ) , // dynamic inputs
116+ isPro : BoolSchema . optional ( ) , // Pro version field
117+ isToolOutput : BoolSchema . optional ( ) ,
107118
108- deprecated : z . boolean ( ) . optional ( ) // node deprecated
119+ deprecated : BoolSchema . optional ( ) // node deprecated
109120} ) ;
110121export type FlowNodeInputItemType = z . infer < typeof FlowNodeInputItemTypeSchema > ;
111122
@@ -121,18 +132,18 @@ export const FlowNodeOutputItemTypeSchema = z.object({
121132 label : z . string ( ) . optional ( ) ,
122133 description : z . string ( ) . optional ( ) ,
123134 defaultValue : z . any ( ) . optional ( ) ,
124- required : z . boolean ( ) . optional ( ) ,
135+ required : BoolSchema . optional ( ) ,
125136
126- invalid : z . boolean ( ) . optional ( ) ,
137+ invalid : BoolSchema . optional ( ) ,
127138 invalidCondition : z
128139 . function ( {
129140 input : z . tuple ( [
130141 z . object ( {
131- inputs : z . array ( FlowNodeInputItemTypeSchema ) ,
142+ inputs : z . custom < FlowNodeInputItemType [ ] > ( ) ,
132143 llmModelMap : z . record ( z . string ( ) , LLMModelItemSchema )
133144 } )
134145 ] ) ,
135- output : z . boolean ( )
146+ output : BoolSchema
136147 } )
137148 . optional ( )
138149 . meta ( {
@@ -143,7 +154,7 @@ export const FlowNodeOutputItemTypeSchema = z.object({
143154 } ) ,
144155
145156 customFieldConfig : CustomFieldConfigTypeSchema . optional ( ) ,
146- deprecated : z . boolean ( ) . optional ( )
157+ deprecated : BoolSchema . optional ( )
147158} ) ;
148159export type FlowNodeOutputItemType = z . infer < typeof FlowNodeOutputItemTypeSchema > ;
149160
0 commit comments