import {z} from 'zod' export type GetApiPeoplePeopleIdVitalSignsSetsArgs = {people_id: string}; export type GetApiPeoplePeopleIdVitalSignsSetsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiPeoplePeopleIdVitalSignsSetsResponse = z.object({vital_signs_sets: z.array(z.object({id: z.number().int().optional(), consultation_id: z.number().int().optional(), person_id: z.number().int().optional(), account_id: z.number().int().optional(), elements: z.object({cramps: z.object({units: z.string().optional(), value: z.unknown()}).optional(), height: z.object({units: z.string().optional(), value: z.string().optional()}).optional(), hunger: z.object({units: z.string().optional(), value: z.unknown()}).optional(), anxiety: z.object({units: z.string().optional(), value: z.unknown()}).optional(), fatigue: z.object({units: z.string().optional(), value: z.unknown()}).optional(), satiety: z.object({units: z.string().optional(), value: z.unknown()}).optional(), diarrhea: z.object({units: z.string().optional(), value: z.unknown()}).optional(), headache: z.object({units: z.string().optional(), value: z.unknown()}).optional(), dizziness: z.object({units: z.string().optional(), value: z.unknown()}).optional(), halitosis: z.object({units: z.string().optional(), value: z.unknown()}).optional(), tolerance: z.object({units: z.string().optional(), value: z.unknown()}).optional(), depression: z.object({units: z.string().optional(), value: z.unknown()}).optional(), impatience: z.object({units: z.string().optional(), value: z.unknown()}).optional(), constipation: z.object({units: z.string().optional(), value: z.unknown()}).optional(), irritability: z.object({units: z.string().optional(), value: z.unknown()}).optional(), concentration: z.object({units: z.string().optional(), value: z.unknown()}).optional(), aggressiveness: z.object({units: z.string().optional(), value: z.unknown()}).optional(), impulse_control: z.object({units: z.string().optional(), value: z.unknown()}).optional(), stimulants_need: z.object({units: z.string().optional(), value: z.unknown()}).optional(), sleeping_problems: z.object({units: z.string().optional(), value: z.unknown()}).optional()}).optional(), created_at: z.string().optional()})).optional()}); 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 }; /** * GET /people/{people_id}/vital_signs_sets * * GET /people/{people_id}/vital_signs_sets */ export const getApiPeoplePeopleIdVitalSignsSets = async (args: GetApiPeoplePeopleIdVitalSignsSetsArgs, options?: GetApiPeoplePeopleIdVitalSignsSetsOptions) => { const {baseUrl = "https://api.example.test", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/people/${encodeURIComponent(String(args.people_id))}/vital_signs_sets${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(getApiPeoplePeopleIdVitalSignsSetsResponse, await res.json()) };