import {z} from 'zod' export type CreateApiEventparticipantsIndexListArgs = {offset?: number | undefined, size?: number | undefined}; export type CreateApiEventparticipantsIndexListOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const eventParticipantIndexDto = z.object({approximateAge: z.number().int().optional(), caption: z.string().optional(), caseUuid: z.string().optional(), contactCount: z.number().int().optional(), deletionReason: z.enum(["GDPR", "DELETION_REQUEST", "CREATED_WITH_NO_LEGAL_REASON", "TRANSFERRED_RESPONSIBILITY", "DUPLICATE_ENTRIES", "OTHER_REASON"]).optional(), eventUuid: z.string().optional(), firstName: z.string().optional(), inJurisdiction: z.boolean().optional(), inJurisdictionOrOwned: z.boolean().optional(), involvementDescription: z.string().optional(), lastName: z.string().optional(), otherDeletionReason: z.string().optional(), pathogenTestResult: z.enum(["INDETERMINATE", "PENDING", "NEGATIVE", "POSITIVE", "NOT_DONE", "NOT_APPLICABLE"]).optional(), personUuid: z.string().optional(), pseudonymized: z.boolean().optional(), sampleDateTime: z.string().optional(), sex: z.enum(["MALE", "FEMALE", "OTHER", "UNKNOWN"]).optional(), uuid: z.string().min(20).max(36).optional(), vaccinationStatus: z.enum(["VACCINATED", "UNVACCINATED", "RECOVERED", "HAD_THE_DISEASE", "OTHER", "UNKNOWN"]).optional()}); export const pageEventParticipantIndexDto = z.object({elements: z.array(eventParticipantIndexDto).optional(), hasNext: z.boolean().optional(), offset: z.number().int().optional(), size: z.number().int().optional(), totalElementCount: z.number().int().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 }; /** * POST /eventparticipants/indexList */ export const createApiEventparticipantsIndexList = async (args: CreateApiEventparticipantsIndexListArgs, options: CreateApiEventparticipantsIndexListOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json; charset=UTF-8") if (args.offset != null) query.append("offset", String(args.offset)) if (args.size != null) query.append("size", String(args.size)) const url = `${baseUrl.replace(/\/+$/, '')}/eventparticipants/indexList${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(pageEventParticipantIndexDto, await res.json()) };