Fix endpoint condition source handling

This commit is contained in:
fawney19
2026-05-07 15:56:28 +08:00
parent 6317587a6b
commit 2b439094c5
5 changed files with 49 additions and 11 deletions
@@ -1,6 +1,6 @@
import type { BodyRuleCondition, BodyRuleConditionOp } from '@/api/endpoints'
export type ConditionSource = 'body' | 'request_headers'
export type ConditionSource = 'body' | 'original' | 'request_headers'
export type ConditionGroupMode = 'all' | 'any'
export interface EditableConditionLeaf {
@@ -96,6 +96,8 @@ export function conditionToEditable(condition?: BodyRuleCondition | null): Edita
: '',
source: source === 'request_headers' || source === 'headers'
? 'request_headers'
: source === 'original'
? 'original'
: 'body',
}
}
@@ -117,7 +119,11 @@ export function editableConditionToApi(node: EditableConditionNode | null): Body
const base = {
path,
op: node.op,
...(node.source === 'request_headers' ? { source: 'request_headers' as const } : {}),
...(node.source === 'request_headers'
? { source: 'request_headers' as const }
: node.source === 'original'
? { source: 'original' as const }
: {}),
}
if (node.op === 'exists' || node.op === 'not_exists') {