Archived
WIP 1.51.12: tickets, scan locks, attendance, allocations on v2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls1vMdg2GYqbnKZmPaX1ot
This commit is contained in:
@@ -43,6 +43,17 @@ export function apiV2<M extends Method, P extends PathsWith<M>>(method: M, path:
|
||||
return apiFetch<V2Result<P, M>>(`/api/v2${url}`, { method: method.toUpperCase(), authToken: opts.authToken, body: opts.body, nextOptions: opts.nextOptions });
|
||||
}
|
||||
|
||||
/**
|
||||
* An untyped v2 call, for screens whose helpers take the path as a string (`call(path, method)`):
|
||||
* the answer's `data`. Prefer `apiV2`/`apiV2Data` with a literal path where you can.
|
||||
*/
|
||||
export async function apiV2Raw<T = unknown>(method: Method, path: string, options: { authToken?: string | null; body?: unknown; query?: Record<string, unknown> } = {}): Promise<T> {
|
||||
const qs = new URLSearchParams();
|
||||
for (const [k, v] of Object.entries(options.query || {})) if (v !== undefined && v !== null && v !== "") qs.set(k, String(v));
|
||||
const res = await apiFetch<{ data: T }>(`/api/v2${path}${qs.toString() ? `?${qs.toString()}` : ""}`, { method: method.toUpperCase(), authToken: options.authToken, body: options.body });
|
||||
return res.data;
|
||||
}
|
||||
|
||||
/** The JSON body a v2 endpoint takes. */
|
||||
export type V2Body<P extends keyof paths, M extends Method> = Body<Op<P, M>>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user