mirror of
				https://github.com/langgenius/dify.git
				synced 2025-10-26 00:18:44 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			500 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			500 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { type BodyPayload, BodyPayloadValueType } from './types'
 | |
| 
 | |
| export const transformToBodyPayload = (old: string, hasKey: boolean): BodyPayload => {
 | |
|   if (!hasKey) {
 | |
|     return [
 | |
|       {
 | |
|         type: BodyPayloadValueType.text,
 | |
|         value: old,
 | |
|       },
 | |
|     ]
 | |
|   }
 | |
|   const bodyPayload = old.split('\n').map((item) => {
 | |
|     const [key, value] = item.split(':')
 | |
|     return {
 | |
|       key: key || '',
 | |
|       type: BodyPayloadValueType.text,
 | |
|       value: value || '',
 | |
|     }
 | |
|   })
 | |
|   return bodyPayload
 | |
| }
 | 
