WIP 1.51.9: frontend on v2 for series, passes, bundles, coupons, campuses
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls1vMdg2GYqbnKZmPaX1ot
This commit is contained in:
@@ -45,3 +45,13 @@ export function apiV2<M extends Method, P extends PathsWith<M>>(method: M, path:
|
||||
|
||||
/** The JSON body a v2 endpoint takes. */
|
||||
export type V2Body<P extends keyof paths, M extends Method> = Body<Op<P, M>>;
|
||||
|
||||
/**
|
||||
* `apiV2` for screens that keep their own record types: the path, parameters and body are still
|
||||
* checked against the API, and the answer's `data` comes back untyped — cast it:
|
||||
* `await (apiV2Data("get", "/coupons", { authToken }) as Promise<Coupon[]>)`.
|
||||
*/
|
||||
export async function apiV2Data<M extends Method, P extends PathsWith<M>>(method: M, path: P, ...rest: object extends V2Options<P, M> ? [V2Options<P, M>?] : [V2Options<P, M>]): Promise<unknown> {
|
||||
const res = (await apiV2(method, path, ...(rest as [V2Options<P, M>]))) as { data?: unknown };
|
||||
return res.data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user