feat: if types

This commit is contained in:
Joel 2024-02-21 16:34:38 +08:00
parent bc60cf0a35
commit cffaf30760
3 changed files with 62 additions and 2 deletions

View File

@ -46,9 +46,9 @@ const Page: FC = () => {
/*
* TODO: for debug.
* 2 directAnswer 3: llm 5: questionClassifier
* 7 Code, 8 TemplateTransform 9 http
* 6 if else 7 Code, 8 TemplateTransform 9 http
*/
selectedNodeId='9'
selectedNodeId='6'
/>
</div>
)

View File

@ -0,0 +1,23 @@
import type { IfElseType } from './types'
import { ComparisonOperator, LogicalOperator } from './types'
export const mockData: IfElseType = {
title: 'Test',
desc: 'Test',
type: 'Test',
logical_operator: LogicalOperator.and,
conditions: [
{
id: '1',
variable_selector: ['aaa', 'name'],
comparison_operator: ComparisonOperator.contains,
value: '22',
},
{
id: '2',
variable_selector: ['bbb', 'b', 'c'],
comparison_operator: ComparisonOperator.equal,
value: 'b',
},
],
}

View File

@ -0,0 +1,37 @@
import type { CommonNodeType, ValueSelector } from '@/app/components/workflow/types'
export enum LogicalOperator {
and = 'and',
or = 'or',
}
export enum ComparisonOperator {
contains = 'contains',
notContains = 'not contains',
startWith = 'start with',
endWith = 'end with',
is = 'is',
isNot = 'is not',
empty = 'empty',
notEmpty = 'not empty',
equal = '=',
notEqual = '≠',
largerThan = '>',
lessThan = '<',
largerThanOrEqual = '≥',
lessThanOrEqual = '≤',
isNull = 'is null',
isNotNull = 'is not null',
}
export type Condition = {
id: string
variable_selector: ValueSelector
comparison_operator: ComparisonOperator
value: string
}
export type IfElseType = CommonNodeType & {
logical_operator: LogicalOperator
conditions: Condition[]
}