import {z} from 'zod' export type GetApiLeaderboardLeaderboardIdStandingsQueryArgs = {leaderboardId: string, useWeightedScoring?: boolean | undefined, country?: ({eq?: string | undefined, neq?: string | undefined, gt?: string | undefined, gte?: string | undefined, lt?: string | undefined, lte?: string | undefined, contains?: string | undefined, starts_with?: string | undefined, ends_with?: string | undefined, in?: Array | undefined, not_contains?: string | undefined}) | undefined, language?: ({eq?: string | undefined, neq?: string | undefined, gt?: string | undefined, gte?: string | undefined, lt?: string | undefined, lte?: string | undefined, contains?: string | undefined, starts_with?: string | undefined, ends_with?: string | undefined, in?: Array | undefined, not_contains?: string | undefined}) | undefined, gender?: ({eq?: string | undefined, neq?: string | undefined, gt?: string | undefined, gte?: string | undefined, lt?: string | undefined, lte?: string | undefined, contains?: string | undefined, starts_with?: string | undefined, ends_with?: string | undefined, in?: Array | undefined, not_contains?: string | undefined}) | undefined, age_bucket?: ({eq?: string | undefined, neq?: string | undefined, gt?: string | undefined, gte?: string | undefined, lt?: string | undefined, lte?: string | undefined, contains?: string | undefined, starts_with?: string | undefined, ends_with?: string | undefined, in?: Array | undefined, not_contains?: string | undefined}) | undefined, occupation?: ({eq?: string | undefined, neq?: string | undefined, gt?: string | undefined, gte?: string | undefined, lt?: string | undefined, lte?: string | undefined, contains?: string | undefined, starts_with?: string | undefined, ends_with?: string | undefined, in?: Array | undefined, not_contains?: string | undefined}) | undefined, tags?: ({eq?: string | undefined, neq?: string | undefined, gt?: string | undefined, gte?: string | undefined, lt?: string | undefined, lte?: string | undefined, contains?: string | undefined, starts_with?: string | undefined, ends_with?: string | undefined, in?: Array | undefined, not_contains?: string | undefined}) | undefined, participant_id?: ({eq?: string | undefined, neq?: string | undefined, gt?: string | undefined, gte?: string | undefined, lt?: string | undefined, lte?: string | undefined, contains?: string | undefined, starts_with?: string | undefined, ends_with?: string | undefined, in?: Array | undefined, not_contains?: string | undefined}) | undefined, run_id?: ({eq?: string | undefined, neq?: string | undefined, gt?: string | undefined, gte?: string | undefined, lt?: string | undefined, lte?: string | undefined, contains?: string | undefined, starts_with?: string | undefined, ends_with?: string | undefined, in?: Array | undefined, not_contains?: string | undefined}) | undefined, prompt_identifier?: ({eq?: string | undefined, neq?: string | undefined, gt?: string | undefined, gte?: string | undefined, lt?: string | undefined, lte?: string | undefined, contains?: string | undefined, starts_with?: string | undefined, ends_with?: string | undefined, in?: Array | undefined, not_contains?: string | undefined}) | undefined, voted_at?: ({eq?: string | undefined, neq?: string | undefined, gt?: string | undefined, gte?: string | undefined, lt?: string | undefined, lte?: string | undefined, contains?: string | undefined, starts_with?: string | undefined, ends_with?: string | undefined, in?: Array | undefined, not_contains?: string | undefined}) | undefined, include_deprecated_participants?: ({eq?: string | undefined, neq?: string | undefined, gt?: string | undefined, gte?: string | undefined, lt?: string | undefined, lte?: string | undefined, contains?: string | undefined, starts_with?: string | undefined, ends_with?: string | undefined, in?: Array | undefined, not_contains?: string | undefined}) | undefined, logic?: ('and' | 'or') | undefined}; export type GetApiLeaderboardLeaderboardIdStandingsQueryOptions = {baseUrl?: string | undefined, OpenIdConnect?: string | undefined, fetch?: typeof fetch | undefined}; export const standingStatus = z.enum(["Created", "Active", "Idle"]); export const queryStandingsByLeaderboardEndpointOutputItem = z.object({id: z.string(), name: z.string(), family: z.string().nullable().optional(), lab: z.string().nullable().optional(), proprietaryName: z.string().nullable().optional(), licenseType: z.enum(["OpenSource", "Proprietary"]).nullable().optional(), cost: z.number().nullable().optional(), costUnit: z.enum(["UsdPerImage", "UsdPerVideoSecond", "UsdPerMillionTokens", "UsdPerSample"]).nullable().optional(), logo: z.string().nullable().optional(), status: standingStatus, score: z.number().nullable(), wins: z.number(), totalMatches: z.number(), responseCount: z.number().int(), isDeprecated: z.boolean(), isPublic: z.boolean(), isCandidate: z.boolean(), confidenceInterval: z.object({lowerOffset: z.number(), upperOffset: z.number()}).nullable().optional()}); export const queryStandingsByLeaderboardEndpointOutput = z.object({items: z.array(queryStandingsByLeaderboardEndpointOutputItem), totalResponses: z.number().int()}); 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 }; /** * Queries the standings of a leaderboard. * * GET /leaderboard/{leaderboardId}/standings/query */ export const getApiLeaderboardLeaderboardIdStandingsQuery = async (args: GetApiLeaderboardLeaderboardIdStandingsQueryArgs, options?: GetApiLeaderboardLeaderboardIdStandingsQueryOptions) => { const {baseUrl = "https://api.rapidata.ai", fetch: fetchFn = fetch, OpenIdConnect} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.useWeightedScoring != null) query.append("useWeightedScoring", String(args.useWeightedScoring)) if (args.country != null) query.append("country", JSON.stringify(args.country)) if (args.language != null) query.append("language", JSON.stringify(args.language)) if (args.gender != null) query.append("gender", JSON.stringify(args.gender)) if (args.age_bucket != null) query.append("age_bucket", JSON.stringify(args.age_bucket)) if (args.occupation != null) query.append("occupation", JSON.stringify(args.occupation)) if (args.tags != null) query.append("tags", JSON.stringify(args.tags)) if (args.participant_id != null) query.append("participant_id", JSON.stringify(args.participant_id)) if (args.run_id != null) query.append("run_id", JSON.stringify(args.run_id)) if (args.prompt_identifier != null) query.append("prompt_identifier", JSON.stringify(args.prompt_identifier)) if (args.voted_at != null) query.append("voted_at", JSON.stringify(args.voted_at)) if (args.include_deprecated_participants != null) query.append("include_deprecated_participants", JSON.stringify(args.include_deprecated_participants)) if (args.logic != null) query.append("logic", String(args.logic)) if (OpenIdConnect !== undefined) headers.set('authorization', `Bearer ${OpenIdConnect}`) const url = `${baseUrl.replace(/\/+$/, '')}/leaderboard/${encodeURIComponent(String(args.leaderboardId))}/standings/query${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(queryStandingsByLeaderboardEndpointOutput, await res.json()) };