import {z} from 'zod' export type GetApiV1MeetingsInvitesArgs = {page?: number | undefined, perPage?: number | undefined, status?: ('pending' | 'active' | 'cancelled' | 'ended' | 'failed') | undefined}; export type GetApiV1MeetingsInvitesOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const meetingInvite = z.object({id: z.string(), provider: z.enum(["google_meet", "zoom", "microsoft_teams"]), meetingUrl: z.string(), displayName: z.string(), status: z.enum(["pending", "active", "cancelled", "ended", "failed"]), createdAt: z.string(), joinAt: z.string().nullable(), groupCall: z.boolean(), sessionId: z.string().nullable(), region: z.enum(["eu", "us-east", "us-west", "null"]).nullable(), joinState: z.enum(["joining", "waiting_room", "in_call", "media_denied", "media_granted", "media_active", "left", "done", "error", "null"]).nullable(), statusReason: z.string().nullable()}); export const pagination = z.object({total: z.number().int().optional(), lastPage: z.number().int().optional(), currentPage: z.number().int().optional(), perPage: z.number().int().optional(), prev: z.number().int().nullable().optional(), next: z.number().int().nullable().optional()}); export const getApiV1MeetingsInvitesResponse = z.object({data: z.array(meetingInvite).optional(), meta: pagination.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 }; /** * List meeting invites * * GET /v1/meetings/invites */ export const getApiV1MeetingsInvites = async (args: GetApiV1MeetingsInvitesArgs, options?: GetApiV1MeetingsInvitesOptions) => { const {baseUrl = "https://api.anam.ai", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.page != null) query.append("page", String(args.page)) if (args.perPage != null) query.append("perPage", String(args.perPage)) if (args.status != null) query.append("status", String(args.status)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/meetings/invites${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(getApiV1MeetingsInvitesResponse, await res.json()) };