import {z} from 'zod' export type ActiveStreaksOnly = string | null; export type Conference = 'null' | 'East' | 'West' | null; export type DateFrom = string | null; export type DateTo = string | null; export type Division = 'null' | 'Atlantic' | 'Central' | 'Northwest' | 'Pacific' | 'Southeast' | 'Southwest' | null; export type DraftNumber = string | null; export type DraftRound = string | null; export type DraftTeamID = string | null; export type DraftYear = string | null; export type EqAST = string | null; export type EqBLK = string | null; export type EqDD = string | null; export type EqDREB = string | null; export type EqFG3A = string | null; export type EqFG3M = string | null; export type EqFG3PCT = string | null; export type EqFGA = string | null; export type EqFGM = string | null; export type EqFGPCT = string | null; export type EqFTA = string | null; export type EqFTM = string | null; export type EqFTPCT = string | null; export type EqMINUTES = string | null; export type EqOREB = string | null; export type EqPF = string | null; export type EqPTS = string | null; export type EqREB = string | null; export type EqSTL = string | null; export type EqTD = string | null; export type EqTOV = string | null; export type GameID = string; export type GtAST = string | null; export type GtBLK = string | null; export type GtDD = string | null; export type GtDREB = string | null; export type GtFG3A = string | null; export type GtFG3M = string | null; export type GtFG3PCT = string | null; export type GtFGA = string | null; export type GtFGM = string | null; export type GtFGPCT = string | null; export type GtFTA = string | null; export type GtFTM = string | null; export type GtFTPCT = string | null; export type GtMINUTES = string | null; export type GtOREB = string | null; export type GtPF = string | null; export type GtPTS = string | null; export type GtREB = string | null; export type GtSTL = string | null; export type GtTD = string | null; export type GtTOV = string | null; export type LeagueID = string; export type Location = 'null' | 'Home' | 'Road' | null; export type LtAST = string | null; export type LtBLK = string | null; export type LtDD = string | null; export type LtDREB = string | null; export type LtFG3A = string | null; export type LtFG3M = string | null; export type LtFG3PCT = string | null; export type LtFGA = string | null; export type LtFGM = string | null; export type LtFGPCT = string | null; export type LtFTA = string | null; export type LtFTM = string | null; export type LtFTPCT = string | null; export type LtMINUTES = string | null; export type LtOREB = string | null; export type LtPF = string | null; export type LtPTS = string | null; export type LtREB = string | null; export type LtSTL = string | null; export type LtTD = string | null; export type LtTOV = string | null; export type MinGames = string | null; export type Outcome = 'null' | 'W' | 'L' | null; export type PORound = string | null; export type PlayerID = string; export type RookieYear = string | null; export type Season = string; export type SeasonSegment = 'null' | 'Post All-Star' | 'Pre All-Star' | null; export type SeasonType = string; export type StarterBench = 'null' | 'Starters' | 'Bench' | null; export type TeamID = string; export type VsConference = 'null' | 'East' | 'West' | null; export type VsDivision = 'null' | 'Atlantic' | 'Central' | 'Northwest' | 'Pacific' | 'Southeast' | 'Southwest' | 'East' | 'West' | null; export type VsTeamID = string; export type YearsExperience = string | null; export type GetApiPlayergamestreakfinderArgs = {ActiveStreaksOnly?: ActiveStreaksOnly | undefined, Conference?: Conference | undefined, DateFrom?: DateFrom | undefined, DateTo?: DateTo | undefined, Division?: Division | undefined, DraftNumber?: DraftNumber | undefined, DraftRound?: DraftRound | undefined, DraftTeamID?: DraftTeamID | undefined, DraftYear?: DraftYear | undefined, EqAST?: EqAST | undefined, EqBLK?: EqBLK | undefined, EqDD?: EqDD | undefined, EqDREB?: EqDREB | undefined, EqFG3A?: EqFG3A | undefined, EqFG3M?: EqFG3M | undefined, EqFG3_PCT?: EqFG3PCT | undefined, EqFGA?: EqFGA | undefined, EqFGM?: EqFGM | undefined, EqFG_PCT?: EqFGPCT | undefined, EqFTA?: EqFTA | undefined, EqFTM?: EqFTM | undefined, EqFT_PCT?: EqFTPCT | undefined, EqMINUTES?: EqMINUTES | undefined, EqOREB?: EqOREB | undefined, EqPF?: EqPF | undefined, EqPTS?: EqPTS | undefined, EqREB?: EqREB | undefined, EqSTL?: EqSTL | undefined, EqTD?: EqTD | undefined, EqTOV?: EqTOV | undefined, GameID: GameID, GtAST?: GtAST | undefined, GtBLK?: GtBLK | undefined, GtDD?: GtDD | undefined, GtDREB?: GtDREB | undefined, GtFG3A?: GtFG3A | undefined, GtFG3M?: GtFG3M | undefined, GtFG3_PCT?: GtFG3PCT | undefined, GtFGA?: GtFGA | undefined, GtFGM?: GtFGM | undefined, GtFG_PCT?: GtFGPCT | undefined, GtFTA?: GtFTA | undefined, GtFTM?: GtFTM | undefined, GtFT_PCT?: GtFTPCT | undefined, GtMINUTES?: GtMINUTES | undefined, GtOREB?: GtOREB | undefined, GtPF?: GtPF | undefined, GtPTS?: GtPTS | undefined, GtREB?: GtREB | undefined, GtSTL?: GtSTL | undefined, GtTD?: GtTD | undefined, GtTOV?: GtTOV | undefined, LeagueID: LeagueID, Location?: Location | undefined, LtAST?: LtAST | undefined, LtBLK?: LtBLK | undefined, LtDD?: LtDD | undefined, LtDREB?: LtDREB | undefined, LtFG3A?: LtFG3A | undefined, LtFG3M?: LtFG3M | undefined, LtFG3_PCT?: LtFG3PCT | undefined, LtFGA?: LtFGA | undefined, LtFGM?: LtFGM | undefined, LtFG_PCT?: LtFGPCT | undefined, LtFTA?: LtFTA | undefined, LtFTM?: LtFTM | undefined, LtFT_PCT?: LtFTPCT | undefined, LtMINUTES?: LtMINUTES | undefined, LtOREB?: LtOREB | undefined, LtPF?: LtPF | undefined, LtPTS?: LtPTS | undefined, LtREB?: LtREB | undefined, LtSTL?: LtSTL | undefined, LtTD?: LtTD | undefined, LtTOV?: LtTOV | undefined, MinGames?: MinGames | undefined, Outcome?: Outcome | undefined, PORound?: PORound | undefined, PlayerID: PlayerID, RookieYear?: RookieYear | undefined, Season: Season, SeasonSegment?: SeasonSegment | undefined, SeasonType: SeasonType, StarterBench?: StarterBench | undefined, TeamID?: TeamID | undefined, VsConference?: VsConference | undefined, VsDivision?: VsDivision | undefined, VsTeamID?: VsTeamID | undefined, YearsExperience?: YearsExperience | undefined}; export type GetApiPlayergamestreakfinderOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiPlayergamestreakfinderResponse = z.object({parameters: z.object({ActiveStreaksOnly: z.literal("$request.query.ActiveStreaksOnly").optional(), Conference: z.literal("$request.query.Conference").optional(), DateFrom: z.literal("$request.query.DateFrom").optional(), DateTo: z.literal("$request.query.DateTo").optional(), Division: z.literal("$request.query.Division").optional(), DraftNumber: z.literal("$request.query.DraftNumber").optional(), DraftRound: z.literal("$request.query.DraftRound").optional(), DraftTeamID: z.literal("$request.query.DraftTeamID").optional(), DraftYear: z.literal("$request.query.DraftYear").optional(), EqAST: z.literal("$request.query.EqAST").optional(), EqBLK: z.literal("$request.query.EqBLK").optional(), EqDD: z.literal("$request.query.EqDD").optional(), EqDREB: z.literal("$request.query.EqDREB").optional(), EqFG3A: z.literal("$request.query.EqFG3A").optional(), EqFG3M: z.literal("$request.query.EqFG3M").optional(), EqFG3_PCT: z.literal("$request.query.EqFG3_PCT").optional(), EqFGA: z.literal("$request.query.EqFGA").optional(), EqFGM: z.literal("$request.query.EqFGM").optional(), EqFG_PCT: z.literal("$request.query.EqFG_PCT").optional(), EqFTA: z.literal("$request.query.EqFTA").optional(), EqFTM: z.literal("$request.query.EqFTM").optional(), EqFT_PCT: z.literal("$request.query.EqFT_PCT").optional(), EqMINUTES: z.literal("$request.query.EqMINUTES").optional(), EqOREB: z.literal("$request.query.EqOREB").optional(), EqPF: z.literal("$request.query.EqPF").optional(), EqPTS: z.literal("$request.query.EqPTS").optional(), EqREB: z.literal("$request.query.EqREB").optional(), EqSTL: z.literal("$request.query.EqSTL").optional(), EqTD: z.literal("$request.query.EqTD").optional(), EqTOV: z.literal("$request.query.EqTOV").optional(), GameID: z.literal("$request.query.GameID").optional(), GtAST: z.literal("$request.query.GtAST").optional(), GtBLK: z.literal("$request.query.GtBLK").optional(), GtDD: z.literal("$request.query.GtDD").optional(), GtDREB: z.literal("$request.query.GtDREB").optional(), GtFG3A: z.literal("$request.query.GtFG3A").optional(), GtFG3M: z.literal("$request.query.GtFG3M").optional(), GtFG3_PCT: z.literal("$request.query.GtFG3_PCT").optional(), GtFGA: z.literal("$request.query.GtFGA").optional(), GtFGM: z.literal("$request.query.GtFGM").optional(), GtFG_PCT: z.literal("$request.query.GtFG_PCT").optional(), GtFTA: z.literal("$request.query.GtFTA").optional(), GtFTM: z.literal("$request.query.GtFTM").optional(), GtFT_PCT: z.literal("$request.query.GtFT_PCT").optional(), GtMINUTES: z.literal("$request.query.GtMINUTES").optional(), GtOREB: z.literal("$request.query.GtOREB").optional(), GtPF: z.literal("$request.query.GtPF").optional(), GtPTS: z.literal("$request.query.GtPTS").optional(), GtREB: z.literal("$request.query.GtREB").optional(), GtSTL: z.literal("$request.query.GtSTL").optional(), GtTD: z.literal("$request.query.GtTD").optional(), GtTOV: z.literal("$request.query.GtTOV").optional(), LeagueID: z.literal("$request.query.LeagueID").optional(), Location: z.literal("$request.query.Location").optional(), LtAST: z.literal("$request.query.LtAST").optional(), LtBLK: z.literal("$request.query.LtBLK").optional(), LtDD: z.literal("$request.query.LtDD").optional(), LtDREB: z.literal("$request.query.LtDREB").optional(), LtFG3A: z.literal("$request.query.LtFG3A").optional(), LtFG3M: z.literal("$request.query.LtFG3M").optional(), LtFG3_PCT: z.literal("$request.query.LtFG3_PCT").optional(), LtFGA: z.literal("$request.query.LtFGA").optional(), LtFGM: z.literal("$request.query.LtFGM").optional(), LtFG_PCT: z.literal("$request.query.LtFG_PCT").optional(), LtFTA: z.literal("$request.query.LtFTA").optional(), LtFTM: z.literal("$request.query.LtFTM").optional(), LtFT_PCT: z.literal("$request.query.LtFT_PCT").optional(), LtMINUTES: z.literal("$request.query.LtMINUTES").optional(), LtOREB: z.literal("$request.query.LtOREB").optional(), LtPF: z.literal("$request.query.LtPF").optional(), LtPTS: z.literal("$request.query.LtPTS").optional(), LtREB: z.literal("$request.query.LtREB").optional(), LtSTL: z.literal("$request.query.LtSTL").optional(), LtTD: z.literal("$request.query.LtTD").optional(), LtTOV: z.literal("$request.query.LtTOV").optional(), MinGames: z.literal("$request.query.MinGames").optional(), Outcome: z.literal("$request.query.Outcome").optional(), PORound: z.literal("$request.query.PORound").optional(), PlayerID: z.literal("$request.query.PlayerID").optional(), RookieYear: z.literal("$request.query.RookieYear").optional(), Season: z.literal("$request.query.Season").optional(), SeasonSegment: z.literal("$request.query.SeasonSegment").optional(), SeasonType: z.literal("$request.query.SeasonType").optional(), StarterBench: z.literal("$request.query.StarterBench").optional(), TeamID: z.literal("$request.query.TeamID").optional(), VsConference: z.literal("$request.query.VsConference").optional(), VsDivision: z.literal("$request.query.VsDivision").optional(), VsTeamID: z.literal("$request.query.VsTeamID").optional(), YearsExperience: z.literal("$request.query.YearsExperience").optional()}).optional(), resource: z.literal("playergamestreakfinder").optional(), resultSets: z.array(z.unknown()).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 }; /** * PlayerGameStreakFinder * * GET /playergamestreakfinder */ export const getApiPlayergamestreakfinder = async (args: GetApiPlayergamestreakfinderArgs, options?: GetApiPlayergamestreakfinderOptions) => { const {baseUrl = "https://stats.nba.com/stats", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.ActiveStreaksOnly != null) query.append("ActiveStreaksOnly", String(args.ActiveStreaksOnly)) if (args.Conference != null) query.append("Conference", String(args.Conference)) if (args.DateFrom != null) query.append("DateFrom", String(args.DateFrom)) if (args.DateTo != null) query.append("DateTo", String(args.DateTo)) if (args.Division != null) query.append("Division", String(args.Division)) if (args.DraftNumber != null) query.append("DraftNumber", String(args.DraftNumber)) if (args.DraftRound != null) query.append("DraftRound", String(args.DraftRound)) if (args.DraftTeamID != null) query.append("DraftTeamID", String(args.DraftTeamID)) if (args.DraftYear != null) query.append("DraftYear", String(args.DraftYear)) if (args.EqAST != null) query.append("EqAST", String(args.EqAST)) if (args.EqBLK != null) query.append("EqBLK", String(args.EqBLK)) if (args.EqDD != null) query.append("EqDD", String(args.EqDD)) if (args.EqDREB != null) query.append("EqDREB", String(args.EqDREB)) if (args.EqFG3A != null) query.append("EqFG3A", String(args.EqFG3A)) if (args.EqFG3M != null) query.append("EqFG3M", String(args.EqFG3M)) if (args.EqFG3_PCT != null) query.append("EqFG3_PCT", String(args.EqFG3_PCT)) if (args.EqFGA != null) query.append("EqFGA", String(args.EqFGA)) if (args.EqFGM != null) query.append("EqFGM", String(args.EqFGM)) if (args.EqFG_PCT != null) query.append("EqFG_PCT", String(args.EqFG_PCT)) if (args.EqFTA != null) query.append("EqFTA", String(args.EqFTA)) if (args.EqFTM != null) query.append("EqFTM", String(args.EqFTM)) if (args.EqFT_PCT != null) query.append("EqFT_PCT", String(args.EqFT_PCT)) if (args.EqMINUTES != null) query.append("EqMINUTES", String(args.EqMINUTES)) if (args.EqOREB != null) query.append("EqOREB", String(args.EqOREB)) if (args.EqPF != null) query.append("EqPF", String(args.EqPF)) if (args.EqPTS != null) query.append("EqPTS", String(args.EqPTS)) if (args.EqREB != null) query.append("EqREB", String(args.EqREB)) if (args.EqSTL != null) query.append("EqSTL", String(args.EqSTL)) if (args.EqTD != null) query.append("EqTD", String(args.EqTD)) if (args.EqTOV != null) query.append("EqTOV", String(args.EqTOV)) if (args.GameID != null) query.append("GameID", String(args.GameID)) if (args.GtAST != null) query.append("GtAST", String(args.GtAST)) if (args.GtBLK != null) query.append("GtBLK", String(args.GtBLK)) if (args.GtDD != null) query.append("GtDD", String(args.GtDD)) if (args.GtDREB != null) query.append("GtDREB", String(args.GtDREB)) if (args.GtFG3A != null) query.append("GtFG3A", String(args.GtFG3A)) if (args.GtFG3M != null) query.append("GtFG3M", String(args.GtFG3M)) if (args.GtFG3_PCT != null) query.append("GtFG3_PCT", String(args.GtFG3_PCT)) if (args.GtFGA != null) query.append("GtFGA", String(args.GtFGA)) if (args.GtFGM != null) query.append("GtFGM", String(args.GtFGM)) if (args.GtFG_PCT != null) query.append("GtFG_PCT", String(args.GtFG_PCT)) if (args.GtFTA != null) query.append("GtFTA", String(args.GtFTA)) if (args.GtFTM != null) query.append("GtFTM", String(args.GtFTM)) if (args.GtFT_PCT != null) query.append("GtFT_PCT", String(args.GtFT_PCT)) if (args.GtMINUTES != null) query.append("GtMINUTES", String(args.GtMINUTES)) if (args.GtOREB != null) query.append("GtOREB", String(args.GtOREB)) if (args.GtPF != null) query.append("GtPF", String(args.GtPF)) if (args.GtPTS != null) query.append("GtPTS", String(args.GtPTS)) if (args.GtREB != null) query.append("GtREB", String(args.GtREB)) if (args.GtSTL != null) query.append("GtSTL", String(args.GtSTL)) if (args.GtTD != null) query.append("GtTD", String(args.GtTD)) if (args.GtTOV != null) query.append("GtTOV", String(args.GtTOV)) if (args.LeagueID != null) query.append("LeagueID", String(args.LeagueID)) if (args.Location != null) query.append("Location", String(args.Location)) if (args.LtAST != null) query.append("LtAST", String(args.LtAST)) if (args.LtBLK != null) query.append("LtBLK", String(args.LtBLK)) if (args.LtDD != null) query.append("LtDD", String(args.LtDD)) if (args.LtDREB != null) query.append("LtDREB", String(args.LtDREB)) if (args.LtFG3A != null) query.append("LtFG3A", String(args.LtFG3A)) if (args.LtFG3M != null) query.append("LtFG3M", String(args.LtFG3M)) if (args.LtFG3_PCT != null) query.append("LtFG3_PCT", String(args.LtFG3_PCT)) if (args.LtFGA != null) query.append("LtFGA", String(args.LtFGA)) if (args.LtFGM != null) query.append("LtFGM", String(args.LtFGM)) if (args.LtFG_PCT != null) query.append("LtFG_PCT", String(args.LtFG_PCT)) if (args.LtFTA != null) query.append("LtFTA", String(args.LtFTA)) if (args.LtFTM != null) query.append("LtFTM", String(args.LtFTM)) if (args.LtFT_PCT != null) query.append("LtFT_PCT", String(args.LtFT_PCT)) if (args.LtMINUTES != null) query.append("LtMINUTES", String(args.LtMINUTES)) if (args.LtOREB != null) query.append("LtOREB", String(args.LtOREB)) if (args.LtPF != null) query.append("LtPF", String(args.LtPF)) if (args.LtPTS != null) query.append("LtPTS", String(args.LtPTS)) if (args.LtREB != null) query.append("LtREB", String(args.LtREB)) if (args.LtSTL != null) query.append("LtSTL", String(args.LtSTL)) if (args.LtTD != null) query.append("LtTD", String(args.LtTD)) if (args.LtTOV != null) query.append("LtTOV", String(args.LtTOV)) if (args.MinGames != null) query.append("MinGames", String(args.MinGames)) if (args.Outcome != null) query.append("Outcome", String(args.Outcome)) if (args.PORound != null) query.append("PORound", String(args.PORound)) if (args.PlayerID != null) query.append("PlayerID", String(args.PlayerID)) if (args.RookieYear != null) query.append("RookieYear", String(args.RookieYear)) if (args.Season != null) query.append("Season", String(args.Season)) if (args.SeasonSegment != null) query.append("SeasonSegment", String(args.SeasonSegment)) if (args.SeasonType != null) query.append("SeasonType", String(args.SeasonType)) if (args.StarterBench != null) query.append("StarterBench", String(args.StarterBench)) if (args.TeamID != null) query.append("TeamID", String(args.TeamID)) if (args.VsConference != null) query.append("VsConference", String(args.VsConference)) if (args.VsDivision != null) query.append("VsDivision", String(args.VsDivision)) if (args.VsTeamID != null) query.append("VsTeamID", String(args.VsTeamID)) if (args.YearsExperience != null) query.append("YearsExperience", String(args.YearsExperience)) const url = `${baseUrl.replace(/\/+$/, '')}/playergamestreakfinder${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(getApiPlayergamestreakfinderResponse, await res.json()) };