import {z} from 'zod' export type GetApiApiV2EventsPlannedEventsPlannedEventIdArgs = {Authorization: string, plannedEventId: string, exclude?: string | undefined, keyList?: string | undefined}; export type GetApiApiV2EventsPlannedEventsPlannedEventIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const registerButton = z.object({textColor: z.string().nullable().optional(), backgroundColor: z.string().nullable().optional(), text: z.string().nullable().optional()}); export const homePageBanner = z.object({useImage: z.boolean().nullable().optional(), image: z.string().nullable().optional(), title: z.string().nullable().optional()}); export const plannedEventSchema = z.object({createdAt: z.number().int().nullable().optional(), isCancelled: z.boolean().nullable().optional(), eventSpeakers: z.array(z.string()).nullable().optional(), activeRegistrations: z.string().nullable().optional(), registerButton: registerButton.nullable().optional(), eventTeamDataJson: z.object({}).nullable().optional(), eventBucket: z.string().nullable().optional(), address: z.string().nullable().optional(), eventCustomFieldsJson: z.object({}).nullable().optional(), eventType: z.string().nullable().optional(), institution: z.string().nullable().optional(), selectedTimezone: z.string().nullable().optional(), name: z.string(), homePageBanner: homePageBanner.nullable().optional(), eventLocationType: z.string().nullable().optional(), id: z.string().nullable().optional(), plannedEventEncId: z.string().nullable().optional(), parentId: z.string().nullable().optional(), venue: z.string().nullable().optional(), endTimestamp: z.number().int().nullable(), isPublished: z.boolean().nullable().optional(), eventLandingPage: z.string().nullable().optional(), status: z.string().nullable().optional(), createdBy: z.string().nullable().optional(), eventCategory: z.string().nullable().optional(), startTimestamp: z.number().int().nullable(), when: z.string().nullable().optional(), description: z.string().nullable().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 Planned Event * * GET /api/v2/events/planned-events/{plannedEventId} */ export const getApiApiV2EventsPlannedEventsPlannedEventId = async (args: GetApiApiV2EventsPlannedEventsPlannedEventIdArgs, options?: GetApiApiV2EventsPlannedEventsPlannedEventIdOptions) => { const {baseUrl = "https://apiv2.eightfold.ai", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args.exclude != null) query.append("exclude", String(args.exclude)) if (args.keyList != null) query.append("keyList", String(args.keyList)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/events/planned-events/${encodeURIComponent(String(args.plannedEventId))}${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(plannedEventSchema, await res.json()) };