@esportsapp/sdk
Version:
Type-safe SDK for the public endpoints of the eSportsApp
84 lines (76 loc) • 1.88 kB
text/typescript
// Common types used across the SDK
export type JSONPrimitive = string | number | boolean | null;
export type JSONValue = JSONPrimitive | { [key: string]: JSONValue } | JSONValue[];
export const ALLOWED_PLATFORMS = ["uplay", "xbl", "psn"] as const;
export type Platform = (typeof ALLOWED_PLATFORMS)[number];
export const ALLOWED_MODES = ["casual", "standard", "ranked"] as const;
export type GameMode = (typeof ALLOWED_MODES)[number];
export const ALLOWED_SEASONS = [
"black-ice",
"dust-line",
"skull-rain",
"red-crow",
"velvet-shell",
"operation-health",
"blood-orchid",
"white-noise",
"chimera",
"para-bellum",
"grim-sky",
"wind-bastion",
"burnt-horizon",
"phantom-sight",
"ember-rise",
"shifting-tides",
"void-edge",
"steel-wave",
"shadow-legacy",
"neon-dawn",
"crimson-heist",
"north-star",
"crystal-guard",
"high-calibre",
"demon-veil",
"vector-glare",
"brutal-swarm",
"solar-raid",
"commanding-force",
"dread-factor",
"heavy-mettle",
"deep-freeze",
"deadly-omen",
"new-blood",
"twin-shells",
"collision-point",
"prep-phase",
"daybreak",
"high-stakes",
] as const;
export type Season = (typeof ALLOWED_SEASONS)[number];
// SDK Configuration
export interface SDKConfig {
apiKey: string;
userAgent: string;
baseURL?: string;
}
// Error types
export interface SDKError {
error: string;
details?: unknown;
}
export interface ValidationError extends SDKError {
details: {
fieldErrors: Record<string, string[]>;
formErrors: string[];
};
}
// Utility types for query building
export type SelectFields<T> = keyof T;
export type IncludeFields<T> = string;
export type QueryOptions = {
select?: string[];
include?: string[];
seasons?: Season[];
modes?: GameMode[];
raw?: boolean;
};