import {z} from 'zod' export type GetApiApiV1LiveTrackingGuildRaidPullsArgs = {access_key?: string | undefined, raid: 'the-unbinding-of-kithix' | 'the-venomous-abyss' | 'the-tidebound-grotto' | 'sporefall' | 'tier-mn-1' | 'manaforge-omega' | 'liberation-of-undermine' | 'nerubar-palace' | 'blackrock-depths' | 'awakened-amirdrassil-the-dreams-hope' | 'awakened-aberrus-the-shadowed-crucible' | 'awakened-vault-of-the-incarnates' | 'amirdrassil-the-dreams-hope' | 'aberrus-the-shadowed-crucible' | 'vault-of-the-incarnates' | 'fated-sepulcher-of-the-first-ones' | 'fated-sanctum-of-domination' | 'fated-castle-nathria' | 'sepulcher-of-the-first-ones' | 'sanctum-of-domination' | 'castle-nathria' | 'nyalotha-the-waking-city' | 'the-eternal-palace' | 'crucible-of-storms' | 'battle-of-dazaralor' | 'uldir' | 'antorus-the-burning-throne' | 'tomb-of-sargeras' | 'the-nighthold' | 'trial-of-valor' | 'the-emerald-nightmare' | 'latest', difficulty: 'mythic' | 'heroic' | 'normal' | 'latest', period?: number | undefined, start_range?: string | undefined, end_range?: string | undefined, region?: ('us' | 'eu' | 'tw' | 'kr' | 'cn' | 'world') | undefined, realm?: string | undefined, guild?: string | undefined, guild_id?: number | undefined}; export type GetApiApiV1LiveTrackingGuildRaidPullsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const faction = z.enum(["horde", "alliance"]); export const realmSummary = z.object({id: z.number().int(), connectedRealmId: z.number().int(), wowRealmId: z.number().int().nullable(), wowConnectedRealmId: z.number().int().nullable(), name: z.string(), altName: z.string().nullable(), slug: z.string(), altSlug: z.string(), locale: z.string().nullable(), isConnected: z.boolean(), realmType: z.string()}); export const regionSummary = z.object({name: z.string(), short_name: z.string(), slug: z.string()}); export const guildSummary = z.object({id: z.number().int(), name: z.string(), faction: faction, realm: realmSummary.optional(), region: regionSummary.optional(), path: z.string(), logo: z.string().optional(), isDefaultLogo: z.boolean().optional(), color: z.string().optional(), displayName: z.string(), alt_name: z.string().optional()}); export const raidSummary = z.object({id: z.number().int().optional(), slug: z.string().optional(), name: z.string().optional(), short_name: z.string().optional(), icon: z.string().optional(), expansion_id: z.number().int().optional()}); export const raidEncounterSummary = z.object({id: z.number().int().optional(), slug: z.string().optional(), name: z.string().optional(), ordinal: z.number().int().optional()}); export const model7 = z.object({}); export const npcs = z.array(model7); export const encounterHealth = z.object({overall_percent: z.number().nullable().optional(), boss_percent: z.number().nullable().optional(), phase: z.number().nullable().optional(), phase_label: z.string().nullable().optional(), progress_display: z.string().optional(), npcs: npcs.optional()}); export const raidPullDetail = z.object({id: z.number().int().optional(), status: z.string().optional(), is_success: z.boolean().optional(), is_reset: z.boolean().optional(), num_members: z.number().int().optional(), num_deaths: z.number().int().optional(), duration_ms: z.number().int().optional(), pull_started_at: z.string().optional(), pull_ended_at: z.string().optional(), encounter_health: encounterHealth.optional(), period: z.number().int().optional(), raidcomp_url: z.string().optional()}); export const details1 = z.array(raidPullDetail); export const raidPullEntry = z.object({count: z.number().int().optional(), encounter: raidEncounterSummary.optional(), details: details1.optional()}); export const pulls2 = z.array(raidPullEntry); export const viewRaidPullsResponse = z.object({guild: guildSummary.optional(), raid: raidSummary.optional(), pulls: pulls2.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 }; /** * Retrieve pull counts and details for each boss encounter. Returns all encounters with pull history for the specified guild, raid, and difficulty. * * GET /api/v1/live-tracking/guild/raid-pulls */ export const getApiApiV1LiveTrackingGuildRaidPulls = async (args: GetApiApiV1LiveTrackingGuildRaidPullsArgs, options?: GetApiApiV1LiveTrackingGuildRaidPullsOptions) => { const {baseUrl = "http://raider.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.access_key != null) query.append("access_key", String(args.access_key)) if (args.raid != null) query.append("raid", String(args.raid)) if (args.difficulty != null) query.append("difficulty", String(args.difficulty)) if (args.period != null) query.append("period", String(args.period)) if (args.start_range != null) query.append("start_range", String(args.start_range)) if (args.end_range != null) query.append("end_range", String(args.end_range)) if (args.region != null) query.append("region", String(args.region)) if (args.realm != null) query.append("realm", String(args.realm)) if (args.guild != null) query.append("guild", String(args.guild)) if (args.guild_id != null) query.append("guild_id", String(args.guild_id)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/live-tracking/guild/raid-pulls${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(viewRaidPullsResponse, await res.json()) };