import {z} from 'zod' export type GetApiApiV1ProjectsProjectIdAnnotationsSummaryArgs = {project_id: string, format?: string | undefined, page_id?: (string | null) | undefined, kind?: (Array<'note' | 'text' | 'callout' | 'line' | 'polyline' | 'rect' | 'ellipse' | 'polygon' | 'ink' | 'highlight' | 'stamp'> | null) | undefined, display_kind?: (Array | null) | undefined, status?: (Array<'accepted' | 'rejected' | 'completed' | 'cancelled' | 'none'> | null) | undefined, author_id?: (string | null) | undefined, author_kind?: ('user' | 'agent' | 'imported' | null) | undefined, visibility?: ('private' | 'project' | null) | undefined, q?: (string | null) | undefined, linked_condition_id?: (string | null) | undefined, include_deleted?: boolean | undefined, sort?: ('created_at' | 'updated_at' | 'page' | 'status' | 'subject' | 'author' | 'display_kind' | 'comments' | 'color') | undefined, direction?: ('asc' | 'desc') | undefined}; export type GetApiApiV1ProjectsProjectIdAnnotationsSummaryOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const getApiApiV1ProjectsProjectIdAnnotationsSummaryResponse = z.unknown(); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Annotation Summary * * GET /api/v1/projects/{project_id}/annotations/summary */ export const getApiApiV1ProjectsProjectIdAnnotationsSummary = async (args: GetApiApiV1ProjectsProjectIdAnnotationsSummaryArgs, options: GetApiApiV1ProjectsProjectIdAnnotationsSummaryOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.format != null) query.append("format", String(args.format)) if (args.page_id != null) query.append("page_id", String(args.page_id)) for (const item of args.kind ?? []) query.append("kind", String(item)) for (const item of args.display_kind ?? []) query.append("display_kind", String(item)) for (const item of args.status ?? []) query.append("status", String(item)) if (args.author_id != null) query.append("author_id", String(args.author_id)) if (args.author_kind != null) query.append("author_kind", String(args.author_kind)) if (args.visibility != null) query.append("visibility", String(args.visibility)) if (args.q != null) query.append("q", String(args.q)) if (args.linked_condition_id != null) query.append("linked_condition_id", String(args.linked_condition_id)) if (args.include_deleted != null) query.append("include_deleted", String(args.include_deleted)) if (args.sort != null) query.append("sort", String(args.sort)) if (args.direction != null) query.append("direction", String(args.direction)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/projects/${encodeURIComponent(String(args.project_id))}/annotations/summary${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiApiV1ProjectsProjectIdAnnotationsSummaryResponse, await res.json()) };