MCPcopy
hub / github.com/simstudioai/sim / parseTemporalResponse

Function parseTemporalResponse

apps/sim/tools/temporal/utils.ts:258–277  ·  view source on GitHub ↗
(
  response: Response,
  operation: string
)

Source from the content-addressed store, hash-verified

256 * by signal/cancel/terminate) parse to an empty object.
257 */
258export async function parseTemporalResponse<T extends object>(
259 response: Response,
260 operation: string
261): Promise<T> {
262 const text = await response.text()
263 let data: Record<string, unknown> = {}
264 if (text) {
265 try {
266 data = JSON.parse(text) as Record<string, unknown>
267 } catch {
268 data = { message: truncate(text, 300) }
269 }
270 }
271 if (!response.ok) {
272 const message =
273 typeof data.message === 'string' && data.message ? data.message : `HTTP ${response.status}`
274 throw new Error(`Temporal ${operation} failed: ${message}`)
275 }
276 return data as T
277}

Callers 8

signal_workflow.tsFile · 0.90
delete_schedule.tsFile · 0.90
cancel_workflow.tsFile · 0.90
pause_schedule.tsFile · 0.90
create_schedule.tsFile · 0.90

Calls 3

truncateFunction · 0.90
textMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected