add _webhook_raw to downstreamed node

This commit is contained in:
hjlarry
2025-10-16 16:35:05 +08:00
parent 559cf6583f
commit 1089c5bf04
5 changed files with 55 additions and 2 deletions

View File

@ -0,0 +1,25 @@
import { VarType, type Variable } from '@/app/components/workflow/types'
export const WEBHOOK_RAW_VARIABLE_NAME = '_webhook_raw'
export const WEBHOOK_RAW_VARIABLE_LABEL = 'raw'
export const createWebhookRawVariable = (): Variable => ({
variable: WEBHOOK_RAW_VARIABLE_NAME,
label: WEBHOOK_RAW_VARIABLE_LABEL,
value_type: VarType.object,
value_selector: [],
required: true,
})
type WithVariables = {
variables?: Variable[]
}
export const ensureWebhookRawVariable = <T extends WithVariables>(payload: T): void => {
if (!payload.variables)
payload.variables = []
const hasRawVariable = payload.variables.some(variable => variable.variable === WEBHOOK_RAW_VARIABLE_NAME)
if (!hasRawVariable)
payload.variables.push(createWebhookRawVariable())
}