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

Function zodfetchCursorPage

packages/core/src/v3/apiClient/core.ts:46–81  ·  view source on GitHub ↗
(
  schema: TItemSchema,
  url: string,
  params: FetchCursorPageParams,
  requestInit?: RequestInit,
  options?: ZodFetchOptions
)

Source from the content-addressed store, hash-verified

44}
45
46export function zodfetchCursorPage<TItemSchema extends z.ZodTypeAny>(
47 schema: TItemSchema,
48 url: string,
49 params: FetchCursorPageParams,
50 requestInit?: RequestInit,
51 options?: ZodFetchOptions
52) {
53 const query = new URLSearchParams(params.query);
54
55 if (params.limit) {
56 query.set("page[size]", String(params.limit));
57 }
58
59 if (params.after) {
60 query.set("page[after]", params.after);
61 }
62
63 if (params.before) {
64 query.set("page[before]", params.before);
65 }
66
67 const cursorPageSchema = z.object({
68 data: z.array(schema),
69 pagination: z.object({
70 next: z.string().optional(),
71 previous: z.string().optional(),
72 }),
73 });
74
75 const $url = new URL(url);
76 $url.search = query.toString();
77
78 const fetchResult = _doZodFetch(cursorPageSchema, $url.href, requestInit, options);
79
80 return new CursorPagePromise(fetchResult, schema, url, params, requestInit, options);
81}
82
83export function zodfetchOffsetLimitPage<TItemSchema extends z.ZodTypeAny>(
84 schema: TItemSchema,

Callers 3

listRunsMethod · 0.90
listProjectRunsMethod · 0.90
#fetchPageMethod · 0.85

Calls 3

_doZodFetchFunction · 0.85
toStringMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…