mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-08 22:48:14 -05:00
fix(build): fix type assertion (#2696)
* fix(build): fix type assertion * ack PR comment * more
This commit is contained in:
@@ -70,7 +70,7 @@ export const requestTool: ToolConfig<RequestParams, RequestResponse> = {
|
|||||||
return allHeaders
|
return allHeaders
|
||||||
},
|
},
|
||||||
|
|
||||||
body: (params: RequestParams) => {
|
body: ((params: RequestParams) => {
|
||||||
if (params.formData) {
|
if (params.formData) {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
Object.entries(params.formData).forEach(([key, value]) => {
|
Object.entries(params.formData).forEach(([key, value]) => {
|
||||||
@@ -90,7 +90,7 @@ export const requestTool: ToolConfig<RequestParams, RequestResponse> = {
|
|||||||
) {
|
) {
|
||||||
// Convert JSON object to URL-encoded string
|
// Convert JSON object to URL-encoded string
|
||||||
const urlencoded = new URLSearchParams()
|
const urlencoded = new URLSearchParams()
|
||||||
Object.entries(params.body).forEach(([key, value]) => {
|
Object.entries(params.body as Record<string, unknown>).forEach(([key, value]) => {
|
||||||
if (value !== undefined && value !== null) {
|
if (value !== undefined && value !== null) {
|
||||||
urlencoded.append(key, String(value))
|
urlencoded.append(key, String(value))
|
||||||
}
|
}
|
||||||
@@ -98,11 +98,11 @@ export const requestTool: ToolConfig<RequestParams, RequestResponse> = {
|
|||||||
return urlencoded.toString()
|
return urlencoded.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
return params.body
|
return params.body as Record<string, any>
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined
|
return undefined
|
||||||
},
|
}) as (params: RequestParams) => Record<string, any> | string | FormData | undefined,
|
||||||
},
|
},
|
||||||
|
|
||||||
transformResponse: async (response: Response) => {
|
transformResponse: async (response: Response) => {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export const webhookRequestTool: ToolConfig<WebhookRequestParams, RequestRespons
|
|||||||
return { ...webhookHeaders, ...userHeaders }
|
return { ...webhookHeaders, ...userHeaders }
|
||||||
},
|
},
|
||||||
|
|
||||||
body: (params: WebhookRequestParams) => params.body,
|
body: (params: WebhookRequestParams) => params.body as Record<string, any>,
|
||||||
},
|
},
|
||||||
|
|
||||||
transformResponse: async (response: Response) => {
|
transformResponse: async (response: Response) => {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export interface ToolConfig<P = any, R = any> {
|
|||||||
url: string | ((params: P) => string)
|
url: string | ((params: P) => string)
|
||||||
method: HttpMethod | ((params: P) => HttpMethod)
|
method: HttpMethod | ((params: P) => HttpMethod)
|
||||||
headers: (params: P) => Record<string, string>
|
headers: (params: P) => Record<string, string>
|
||||||
body?: (params: P) => Record<string, any> | string
|
body?: (params: P) => Record<string, any> | string | FormData | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post-processing (optional) - allows additional processing after the initial request
|
// Post-processing (optional) - allows additional processing after the initial request
|
||||||
|
|||||||
Reference in New Issue
Block a user