fix(http): expose structured vars in HTTP body selector (#34185)

Co-authored-by: Jordan <175169034+owldev127@users.noreply.github.com>
This commit is contained in:
Jordan
2026-03-31 11:20:21 +09:00
committed by GitHub
parent f7b78b08fd
commit 2c2cc72150
3 changed files with 47 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
import { describe, expect, it } from 'vitest'
import { VarType } from '@/app/components/workflow/types'
import {
HTTP_BODY_VARIABLE_TYPES,
isSupportedHttpBodyVariable,
} from './supported-body-vars'
describe('HTTP body variable support', () => {
it('should include structured variables in the selector', () => {
expect(HTTP_BODY_VARIABLE_TYPES).toEqual([
VarType.string,
VarType.number,
VarType.secret,
VarType.object,
VarType.arrayNumber,
VarType.arrayString,
VarType.arrayObject,
])
})
it('should accept object and array object variables', () => {
expect(isSupportedHttpBodyVariable(VarType.object)).toBe(true)
expect(isSupportedHttpBodyVariable(VarType.arrayObject)).toBe(true)
})
it('should keep unsupported file variables excluded', () => {
expect(isSupportedHttpBodyVariable(VarType.file)).toBe(false)
expect(isSupportedHttpBodyVariable(VarType.arrayFile)).toBe(false)
})
})

View File

@@ -13,6 +13,7 @@ import VarReferencePicker from '../../../_base/components/variable/var-reference
import useAvailableVarList from '../../../_base/hooks/use-available-var-list'
import { BodyPayloadValueType, BodyType } from '../../types'
import KeyValue from '../key-value'
import { isSupportedHttpBodyVariable } from './supported-body-vars'
const UNIQUE_ID_PREFIX = 'key-value-'
@@ -58,7 +59,7 @@ const EditBody: FC<Props> = ({
const { availableVars, availableNodes } = useAvailableVarList(nodeId, {
onlyLeafNodeVar: false,
filterVar: (varPayload: Var) => {
return [VarType.string, VarType.number, VarType.secret, VarType.arrayNumber, VarType.arrayString].includes(varPayload.type)
return isSupportedHttpBodyVariable(varPayload.type)
},
})

View File

@@ -0,0 +1,15 @@
import { VarType } from '@/app/components/workflow/types'
export const HTTP_BODY_VARIABLE_TYPES: VarType[] = [
VarType.string,
VarType.number,
VarType.secret,
VarType.object,
VarType.arrayNumber,
VarType.arrayString,
VarType.arrayObject,
]
export const isSupportedHttpBodyVariable = (type: VarType) => {
return HTTP_BODY_VARIABLE_TYPES.includes(type)
}