MCPcopy Index your code
hub / github.com/simstudioai/sim / transformFunctionCallResponse

Function transformFunctionCallResponse

apps/sim/tools/convex/utils.ts:87–110  ·  view source on GitHub ↗
(
  response: Response,
  functionType: 'query' | 'mutation' | 'action' | 'function'
)

Source from the content-addressed store, hash-verified

85 * @see https://docs.convex.dev/http-api/#post-apiquery-apimutation-apiaction
86 */
87export async function transformFunctionCallResponse(
88 response: Response,
89 functionType: 'query' | 'mutation' | 'action' | 'function'
90): Promise<ConvexFunctionCallResponse> {
91 const data = (await parseConvexResponse(response)) as ConvexFunctionCallApiResponse
92
93 if (data.status === 'error') {
94 const details =
95 data.errorData !== undefined && data.errorData !== null
96 ? ` (${JSON.stringify(data.errorData)})`
97 : ''
98 throw new Error(
99 `Convex ${functionType} failed: ${data.errorMessage || 'Unknown error'}${details}`
100 )
101 }
102
103 return {
104 success: true,
105 output: {
106 value: data.value ?? null,
107 logLines: data.logLines ?? [],
108 },
109 }
110}

Callers 4

mutation.tsFile · 0.90
run_function.tsFile · 0.90
query.tsFile · 0.90
action.tsFile · 0.90

Calls 1

parseConvexResponseFunction · 0.85

Tested by

no test coverage detected