MCPcopy
hub / github.com/triggerdotdev/trigger.dev / wrapZodFetch

Function wrapZodFetch

packages/cli-v3/src/apiClient.ts:246–284  ·  view source on GitHub ↗
(
  schema: T,
  url: string,
  requestInit?: RequestInit
)

Source from the content-addressed store, hash-verified

244 };
245
246async function wrapZodFetch<T extends z.ZodTypeAny>(
247 schema: T,
248 url: string,
249 requestInit?: RequestInit
250): Promise<ApiResult<z.infer<T>>> {
251 try {
252 const response = await zodfetch(schema, url, requestInit, {
253 retry: {
254 minTimeoutInMs: 500,
255 maxTimeoutInMs: 5000,
256 maxAttempts: 3,
257 factor: 2,
258 randomize: false,
259 },
260 });
261
262 return {
263 success: true,
264 data: response,
265 };
266 } catch (error) {
267 if (error instanceof ApiError) {
268 return {
269 success: false,
270 error: error.message,
271 };
272 } else if (error instanceof Error) {
273 return {
274 success: false,
275 error: error.message,
276 };
277 } else {
278 return {
279 success: false,
280 error: String(error),
281 };
282 }
283 }
284}

Callers 13

whoAmIMethod · 0.85
getProjectMethod · 0.85
getProjectsMethod · 0.85
createTaskRunAttemptMethod · 0.85
getProjectEnvMethod · 0.85
importEnvVarsMethod · 0.85
initializeDeploymentMethod · 0.85

Calls 1

zodfetchFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…