@bp1222/stats-api
Version:
Library for Typescript Client to query MLB StatsAPI
1,390 lines (1,367 loc) • 80.4 kB
JavaScript
"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/index.ts
var src_exports = {};
__export(src_exports, {
BASE_PATH: () => BASE_PATH,
BaseAPI: () => BaseAPI,
BlobApiResponse: () => BlobApiResponse,
BoxscoreFromJSON: () => BoxscoreFromJSON,
BoxscoreFromJSONTyped: () => BoxscoreFromJSONTyped,
BoxscoreTeamsFromJSON: () => BoxscoreTeamsFromJSON,
BoxscoreTeamsFromJSONTyped: () => BoxscoreTeamsFromJSONTyped,
BoxscoreTeamsToJSON: () => BoxscoreTeamsToJSON,
BoxscoreTeamsToJSONTyped: () => BoxscoreTeamsToJSONTyped,
BoxscoreToJSON: () => BoxscoreToJSON,
BoxscoreToJSONTyped: () => BoxscoreToJSONTyped,
COLLECTION_FORMATS: () => COLLECTION_FORMATS,
Configuration: () => Configuration,
DefaultConfig: () => DefaultConfig,
DivisionFromJSON: () => DivisionFromJSON,
DivisionFromJSONTyped: () => DivisionFromJSONTyped,
DivisionStandingsFromJSON: () => DivisionStandingsFromJSON,
DivisionStandingsFromJSONTyped: () => DivisionStandingsFromJSONTyped,
DivisionStandingsListFromJSON: () => DivisionStandingsListFromJSON,
DivisionStandingsListFromJSONTyped: () => DivisionStandingsListFromJSONTyped,
DivisionStandingsListToJSON: () => DivisionStandingsListToJSON,
DivisionStandingsListToJSONTyped: () => DivisionStandingsListToJSONTyped,
DivisionStandingsToJSON: () => DivisionStandingsToJSON,
DivisionStandingsToJSONTyped: () => DivisionStandingsToJSONTyped,
DivisionToJSON: () => DivisionToJSON,
DivisionToJSONTyped: () => DivisionToJSONTyped,
FetchError: () => FetchError,
GameFromJSON: () => GameFromJSON,
GameFromJSONTyped: () => GameFromJSONTyped,
GameOfficialFromJSON: () => GameOfficialFromJSON,
GameOfficialFromJSONTyped: () => GameOfficialFromJSONTyped,
GameOfficialToJSON: () => GameOfficialToJSON,
GameOfficialToJSONTyped: () => GameOfficialToJSONTyped,
GameStatusCode: () => GameStatusCode,
GameStatusCodeFromJSON: () => GameStatusCodeFromJSON,
GameStatusCodeFromJSONTyped: () => GameStatusCodeFromJSONTyped,
GameStatusCodeToJSON: () => GameStatusCodeToJSON,
GameStatusCodeToJSONTyped: () => GameStatusCodeToJSONTyped,
GameStatusFromJSON: () => GameStatusFromJSON,
GameStatusFromJSONTyped: () => GameStatusFromJSONTyped,
GameStatusToJSON: () => GameStatusToJSON,
GameStatusToJSONTyped: () => GameStatusToJSONTyped,
GameTeamFromJSON: () => GameTeamFromJSON,
GameTeamFromJSONTyped: () => GameTeamFromJSONTyped,
GameTeamToJSON: () => GameTeamToJSON,
GameTeamToJSONTyped: () => GameTeamToJSONTyped,
GameTeamsFromJSON: () => GameTeamsFromJSON,
GameTeamsFromJSONTyped: () => GameTeamsFromJSONTyped,
GameTeamsToJSON: () => GameTeamsToJSON,
GameTeamsToJSONTyped: () => GameTeamsToJSONTyped,
GameToJSON: () => GameToJSON,
GameToJSONTyped: () => GameToJSONTyped,
GameType: () => GameType,
GameTypeFromJSON: () => GameTypeFromJSON,
GameTypeFromJSONTyped: () => GameTypeFromJSONTyped,
GameTypeToJSON: () => GameTypeToJSON,
GameTypeToJSONTyped: () => GameTypeToJSONTyped,
InningFromJSON: () => InningFromJSON,
InningFromJSONTyped: () => InningFromJSONTyped,
InningToJSON: () => InningToJSON,
InningToJSONTyped: () => InningToJSONTyped,
JSONApiResponse: () => JSONApiResponse,
LeagueDatesFromJSON: () => LeagueDatesFromJSON,
LeagueDatesFromJSONTyped: () => LeagueDatesFromJSONTyped,
LeagueDatesToJSON: () => LeagueDatesToJSON,
LeagueDatesToJSONTyped: () => LeagueDatesToJSONTyped,
LeagueFromJSON: () => LeagueFromJSON,
LeagueFromJSONTyped: () => LeagueFromJSONTyped,
LeagueRecordFromJSON: () => LeagueRecordFromJSON,
LeagueRecordFromJSONTyped: () => LeagueRecordFromJSONTyped,
LeagueRecordToJSON: () => LeagueRecordToJSON,
LeagueRecordToJSONTyped: () => LeagueRecordToJSONTyped,
LeagueToJSON: () => LeagueToJSON,
LeagueToJSONTyped: () => LeagueToJSONTyped,
LinescoreFromJSON: () => LinescoreFromJSON,
LinescoreFromJSONTyped: () => LinescoreFromJSONTyped,
LinescoreTeamFromJSON: () => LinescoreTeamFromJSON,
LinescoreTeamFromJSONTyped: () => LinescoreTeamFromJSONTyped,
LinescoreTeamToJSON: () => LinescoreTeamToJSON,
LinescoreTeamToJSONTyped: () => LinescoreTeamToJSONTyped,
LinescoreTeamsFromJSON: () => LinescoreTeamsFromJSON,
LinescoreTeamsFromJSONTyped: () => LinescoreTeamsFromJSONTyped,
LinescoreTeamsToJSON: () => LinescoreTeamsToJSON,
LinescoreTeamsToJSONTyped: () => LinescoreTeamsToJSONTyped,
LinescoreToJSON: () => LinescoreToJSON,
LinescoreToJSONTyped: () => LinescoreToJSONTyped,
MlbApi: () => MlbApi,
OfficialFromJSON: () => OfficialFromJSON,
OfficialFromJSONTyped: () => OfficialFromJSONTyped,
OfficialToJSON: () => OfficialToJSON,
OfficialToJSONTyped: () => OfficialToJSONTyped,
RecordFromJSON: () => RecordFromJSON,
RecordFromJSONTyped: () => RecordFromJSONTyped,
RecordToJSON: () => RecordToJSON,
RecordToJSONTyped: () => RecordToJSONTyped,
RequiredError: () => RequiredError,
ResponseError: () => ResponseError,
ScheduleDayFromJSON: () => ScheduleDayFromJSON,
ScheduleDayFromJSONTyped: () => ScheduleDayFromJSONTyped,
ScheduleDayToJSON: () => ScheduleDayToJSON,
ScheduleDayToJSONTyped: () => ScheduleDayToJSONTyped,
ScheduleFromJSON: () => ScheduleFromJSON,
ScheduleFromJSONTyped: () => ScheduleFromJSONTyped,
ScheduleToJSON: () => ScheduleToJSON,
ScheduleToJSONTyped: () => ScheduleToJSONTyped,
SeasonFromJSON: () => SeasonFromJSON,
SeasonFromJSONTyped: () => SeasonFromJSONTyped,
SeasonToJSON: () => SeasonToJSON,
SeasonToJSONTyped: () => SeasonToJSONTyped,
SeasonsFromJSON: () => SeasonsFromJSON,
SeasonsFromJSONTyped: () => SeasonsFromJSONTyped,
SeasonsToJSON: () => SeasonsToJSON,
SeasonsToJSONTyped: () => SeasonsToJSONTyped,
SportFromJSON: () => SportFromJSON,
SportFromJSONTyped: () => SportFromJSONTyped,
SportToJSON: () => SportToJSON,
SportToJSONTyped: () => SportToJSONTyped,
StreakFromJSON: () => StreakFromJSON,
StreakFromJSONTyped: () => StreakFromJSONTyped,
StreakStreakTypeEnum: () => StreakStreakTypeEnum,
StreakToJSON: () => StreakToJSON,
StreakToJSONTyped: () => StreakToJSONTyped,
TeamFromJSON: () => TeamFromJSON,
TeamFromJSONTyped: () => TeamFromJSONTyped2,
TeamToJSON: () => TeamToJSON,
TeamToJSONTyped: () => TeamToJSONTyped2,
TeamsFromJSON: () => TeamsFromJSON,
TeamsFromJSONTyped: () => TeamsFromJSONTyped,
TeamsToJSON: () => TeamsToJSON,
TeamsToJSONTyped: () => TeamsToJSONTyped,
TextApiResponse: () => TextApiResponse,
VenueFromJSON: () => VenueFromJSON,
VenueFromJSONTyped: () => VenueFromJSONTyped,
VenueToJSON: () => VenueToJSON,
VenueToJSONTyped: () => VenueToJSONTyped,
VoidApiResponse: () => VoidApiResponse,
canConsumeForm: () => canConsumeForm,
instanceOfBoxscore: () => instanceOfBoxscore,
instanceOfBoxscoreTeams: () => instanceOfBoxscoreTeams,
instanceOfDivision: () => instanceOfDivision,
instanceOfDivisionStandings: () => instanceOfDivisionStandings,
instanceOfDivisionStandingsList: () => instanceOfDivisionStandingsList,
instanceOfGame: () => instanceOfGame,
instanceOfGameOfficial: () => instanceOfGameOfficial,
instanceOfGameStatus: () => instanceOfGameStatus,
instanceOfGameStatusCode: () => instanceOfGameStatusCode,
instanceOfGameTeam: () => instanceOfGameTeam,
instanceOfGameTeams: () => instanceOfGameTeams,
instanceOfGameType: () => instanceOfGameType,
instanceOfInning: () => instanceOfInning,
instanceOfLeague: () => instanceOfLeague,
instanceOfLeagueDates: () => instanceOfLeagueDates,
instanceOfLeagueRecord: () => instanceOfLeagueRecord,
instanceOfLinescore: () => instanceOfLinescore,
instanceOfLinescoreTeam: () => instanceOfLinescoreTeam,
instanceOfLinescoreTeams: () => instanceOfLinescoreTeams,
instanceOfOfficial: () => instanceOfOfficial,
instanceOfRecord: () => instanceOfRecord,
instanceOfSchedule: () => instanceOfSchedule,
instanceOfScheduleDay: () => instanceOfScheduleDay,
instanceOfSeason: () => instanceOfSeason,
instanceOfSeasons: () => instanceOfSeasons,
instanceOfSport: () => instanceOfSport,
instanceOfStreak: () => instanceOfStreak,
instanceOfTeam: () => instanceOfTeam,
instanceOfTeams: () => instanceOfTeams,
instanceOfVenue: () => instanceOfVenue,
mapValues: () => mapValues,
querystring: () => querystring
});
module.exports = __toCommonJS(src_exports);
// src/runtime.ts
var BASE_PATH = "https://statsapi.mlb.com/api".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
return accessToken;
});
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var _BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.fetchApi = (url, init) => __async(this, null, function* () {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = (yield middleware.pre(__spreadValues({
fetch: this.fetchApi
}, fetchParams))) || fetchParams;
}
}
let response = void 0;
try {
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = (yield middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
})) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = (yield middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
})) || response;
}
}
return response;
});
this.middleware = configuration.middleware;
}
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
request(context, initOverrides) {
return __async(this, null, function* () {
const { url, init } = yield this.createFetchParams(context, initOverrides);
const response = yield this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
});
}
createFetchParams(context, initOverrides) {
return __async(this, null, function* () {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
return initOverrides;
});
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
init: initParams,
context
}));
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = __spreadProps(__spreadValues({}, overriddenInit), {
body
});
return { url, init };
});
}
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
var BaseAPI = _BaseAPI;
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
this.name = "ResponseError";
}
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
this.name = "FetchError";
}
};
var RequiredError = class extends Error {
constructor(field, msg) {
super(msg);
this.field = field;
this.name = "RequiredError";
}
};
var COLLECTION_FORMATS = {
csv: ",",
ssv: " ",
tsv: " ",
pipes: "|"
};
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
function mapValues(data, fn) {
return Object.keys(data).reduce(
(acc, key) => __spreadProps(__spreadValues({}, acc), { [key]: fn(data[key]) }),
{}
);
}
function canConsumeForm(consumes) {
for (const consume of consumes) {
if ("multipart/form-data" === consume.contentType) {
return true;
}
}
return false;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
value() {
return __async(this, null, function* () {
return this.transformer(yield this.raw.json());
});
}
};
var VoidApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return void 0;
});
}
};
var BlobApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return yield this.raw.blob();
});
}
};
var TextApiResponse = class {
constructor(raw) {
this.raw = raw;
}
value() {
return __async(this, null, function* () {
return yield this.raw.text();
});
}
};
// src/models/Official.ts
function instanceOfOfficial(value) {
return true;
}
function OfficialFromJSON(json) {
return OfficialFromJSONTyped(json, false);
}
function OfficialFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"id": json["id"] == null ? void 0 : json["id"],
"fullName": json["fullName"] == null ? void 0 : json["fullName"],
"link": json["link"] == null ? void 0 : json["link"]
};
}
function OfficialToJSON(json) {
return OfficialToJSONTyped(json, false);
}
function OfficialToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"id": value["id"],
"fullName": value["fullName"],
"link": value["link"]
};
}
// src/models/GameOfficial.ts
function instanceOfGameOfficial(value) {
return true;
}
function GameOfficialFromJSON(json) {
return GameOfficialFromJSONTyped(json, false);
}
function GameOfficialFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"official": json["official"] == null ? void 0 : OfficialFromJSON(json["official"]),
"officialType": json["officialType"] == null ? void 0 : json["officialType"]
};
}
function GameOfficialToJSON(json) {
return GameOfficialToJSONTyped(json, false);
}
function GameOfficialToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"official": OfficialToJSON(value["official"]),
"officialType": value["officialType"]
};
}
// src/models/LeagueDates.ts
function instanceOfLeagueDates(value) {
return true;
}
function LeagueDatesFromJSON(json) {
return LeagueDatesFromJSONTyped(json, false);
}
function LeagueDatesFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"seasonId": json["seasonId"] == null ? void 0 : json["seasonId"],
"preSeasonStartDate": json["preSeasonStartDate"] == null ? void 0 : json["preSeasonStartDate"],
"preSeasonEndDate": json["preSeasonEndDate"] == null ? void 0 : json["preSeasonEndDate"],
"seasonStartDate": json["seasonStartDate"] == null ? void 0 : json["seasonStartDate"],
"springStartDate": json["springStartDate"] == null ? void 0 : json["springStartDate"],
"springEndDate": json["springEndDate"] == null ? void 0 : json["springEndDate"],
"offseasonStartDate": json["offseasonStartDate"] == null ? void 0 : json["offseasonStartDate"],
"offseasonEndDate": json["offseasonEndDate"] == null ? void 0 : json["offseasonEndDate"],
"seasonLevelGamedayType": json["seasonLevelGamedayType"] == null ? void 0 : json["seasonLevelGamedayType"],
"gameLevelGamedayType": json["gameLevelGamedayType"] == null ? void 0 : json["gameLevelGamedayType"]
};
}
function LeagueDatesToJSON(json) {
return LeagueDatesToJSONTyped(json, false);
}
function LeagueDatesToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"seasonId": value["seasonId"],
"preSeasonStartDate": value["preSeasonStartDate"],
"preSeasonEndDate": value["preSeasonEndDate"],
"seasonStartDate": value["seasonStartDate"],
"springStartDate": value["springStartDate"],
"springEndDate": value["springEndDate"],
"offseasonStartDate": value["offseasonStartDate"],
"offseasonEndDate": value["offseasonEndDate"],
"seasonLevelGamedayType": value["seasonLevelGamedayType"],
"gameLevelGamedayType": value["gameLevelGamedayType"]
};
}
// src/models/League.ts
function instanceOfLeague(value) {
if (!("id" in value) || value["id"] === void 0) return false;
if (!("name" in value) || value["name"] === void 0) return false;
return true;
}
function LeagueFromJSON(json) {
return LeagueFromJSONTyped(json, false);
}
function LeagueFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"id": json["id"],
"name": json["name"],
"link": json["link"] == null ? void 0 : json["link"],
"abbreviation": json["abbreviation"] == null ? void 0 : json["abbreviation"],
"nameShort": json["nameShort"] == null ? void 0 : json["nameShort"],
"seasonState": json["seasonState"] == null ? void 0 : json["seasonState"],
"hasWildCard": json["hasWildCard"] == null ? void 0 : json["hasWildCard"],
"hasSplitSeason": json["hasSplitSeason"] == null ? void 0 : json["hasSplitSeason"],
"hasPlayoffPoints": json["hasPlayoffPoints"] == null ? void 0 : json["hasPlayoffPoints"],
"seasonDateInfo": json["seasonDateInfo"] == null ? void 0 : LeagueDatesFromJSON(json["seasonDateInfo"]),
"season": json["season"] == null ? void 0 : json["season"],
"orgCode": json["orgCode"] == null ? void 0 : json["orgCode"],
"conferencesInUse": json["conferencesInUse"] == null ? void 0 : json["conferencesInUse"],
"divisionsInUse": json["divisionsInUse"] == null ? void 0 : json["divisionsInUse"],
"sortOrder": json["sortOrder"] == null ? void 0 : json["sortOrder"],
"active": json["active"] == null ? void 0 : json["active"]
};
}
function LeagueToJSON(json) {
return LeagueToJSONTyped(json, false);
}
function LeagueToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"id": value["id"],
"name": value["name"],
"link": value["link"],
"abbreviation": value["abbreviation"],
"nameShort": value["nameShort"],
"seasonState": value["seasonState"],
"hasWildCard": value["hasWildCard"],
"hasSplitSeason": value["hasSplitSeason"],
"hasPlayoffPoints": value["hasPlayoffPoints"],
"seasonDateInfo": LeagueDatesToJSON(value["seasonDateInfo"]),
"season": value["season"],
"orgCode": value["orgCode"],
"conferencesInUse": value["conferencesInUse"],
"divisionsInUse": value["divisionsInUse"],
"sortOrder": value["sortOrder"],
"active": value["active"]
};
}
// src/models/Sport.ts
function instanceOfSport(value) {
if (!("id" in value) || value["id"] === void 0) return false;
return true;
}
function SportFromJSON(json) {
return SportFromJSONTyped(json, false);
}
function SportFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"id": json["id"],
"code": json["code"] == null ? void 0 : json["code"],
"link": json["link"] == null ? void 0 : json["link"],
"name": json["name"] == null ? void 0 : json["name"],
"abbreviation": json["abbreviation"] == null ? void 0 : json["abbreviation"],
"sortOrder": json["sortOrder"] == null ? void 0 : json["sortOrder"],
"activeStatus": json["activeStatus"] == null ? void 0 : json["activeStatus"]
};
}
function SportToJSON(json) {
return SportToJSONTyped(json, false);
}
function SportToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"id": value["id"],
"code": value["code"],
"link": value["link"],
"name": value["name"],
"abbreviation": value["abbreviation"],
"sortOrder": value["sortOrder"],
"activeStatus": value["activeStatus"]
};
}
// src/models/Venue.ts
function instanceOfVenue(value) {
if (!("id" in value) || value["id"] === void 0) return false;
if (!("name" in value) || value["name"] === void 0) return false;
return true;
}
function VenueFromJSON(json) {
return VenueFromJSONTyped(json, false);
}
function VenueFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"id": json["id"],
"name": json["name"],
"link": json["link"] == null ? void 0 : json["link"],
"active": json["active"] == null ? void 0 : json["active"],
"season": json["season"] == null ? void 0 : json["season"]
};
}
function VenueToJSON(json) {
return VenueToJSONTyped(json, false);
}
function VenueToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"id": value["id"],
"name": value["name"],
"link": value["link"],
"active": value["active"],
"season": value["season"]
};
}
// src/models/Division.ts
function instanceOfDivision(value) {
if (!("id" in value) || value["id"] === void 0) return false;
if (!("name" in value) || value["name"] === void 0) return false;
return true;
}
function DivisionFromJSON(json) {
return DivisionFromJSONTyped(json, false);
}
function DivisionFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"id": json["id"],
"name": json["name"],
"season": json["season"] == null ? void 0 : json["season"],
"nameShort": json["nameShort"] == null ? void 0 : json["nameShort"],
"link": json["link"] == null ? void 0 : json["link"],
"abbreviation": json["abbreviation"] == null ? void 0 : json["abbreviation"],
"league": json["league"] == null ? void 0 : LeagueFromJSON(json["league"]),
"sport": json["sport"] == null ? void 0 : SportFromJSON(json["sport"]),
"hasWildcard": json["hasWildcard"] == null ? void 0 : json["hasWildcard"],
"sortOrder": json["sortOrder"] == null ? void 0 : json["sortOrder"],
"numPlayoffTeams": json["numPlayoffTeams"] == null ? void 0 : json["numPlayoffTeams"],
"active": json["active"] == null ? void 0 : json["active"]
};
}
function DivisionToJSON(json) {
return DivisionToJSONTyped(json, false);
}
function DivisionToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"id": value["id"],
"name": value["name"],
"season": value["season"],
"nameShort": value["nameShort"],
"link": value["link"],
"abbreviation": value["abbreviation"],
"league": LeagueToJSON(value["league"]),
"sport": SportToJSON(value["sport"]),
"hasWildcard": value["hasWildcard"],
"sortOrder": value["sortOrder"],
"numPlayoffTeams": value["numPlayoffTeams"],
"active": value["active"]
};
}
// src/models/Streak.ts
var StreakStreakTypeEnum = /* @__PURE__ */ ((StreakStreakTypeEnum2) => {
StreakStreakTypeEnum2["Losing"] = "losses";
StreakStreakTypeEnum2["Winning"] = "wins";
return StreakStreakTypeEnum2;
})(StreakStreakTypeEnum || {});
function instanceOfStreak(value) {
return true;
}
function StreakFromJSON(json) {
return StreakFromJSONTyped(json, false);
}
function StreakFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"streakType": json["streakType"] == null ? void 0 : json["streakType"]
};
}
function StreakToJSON(json) {
return StreakToJSONTyped(json, false);
}
function StreakToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"streakType": value["streakType"]
};
}
// src/models/LeagueRecord.ts
function instanceOfLeagueRecord(value) {
if (!("wins" in value) || value["wins"] === void 0) return false;
if (!("losses" in value) || value["losses"] === void 0) return false;
if (!("pct" in value) || value["pct"] === void 0) return false;
return true;
}
function LeagueRecordFromJSON(json) {
return LeagueRecordFromJSONTyped(json, false);
}
function LeagueRecordFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"wins": json["wins"],
"losses": json["losses"],
"ties": json["ties"] == null ? void 0 : json["ties"],
"pct": json["pct"]
};
}
function LeagueRecordToJSON(json) {
return LeagueRecordToJSONTyped(json, false);
}
function LeagueRecordToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"wins": value["wins"],
"losses": value["losses"],
"ties": value["ties"],
"pct": value["pct"]
};
}
// src/models/Record.ts
function instanceOfRecord(value) {
if (!("team" in value) || value["team"] === void 0) return false;
if (!("season" in value) || value["season"] === void 0) return false;
if (!("streak" in value) || value["streak"] === void 0) return false;
if (!("divisionRank" in value) || value["divisionRank"] === void 0) return false;
if (!("leagueRank" in value) || value["leagueRank"] === void 0) return false;
if (!("gamesBack" in value) || value["gamesBack"] === void 0) return false;
if (!("leagueRecord" in value) || value["leagueRecord"] === void 0) return false;
if (!("wins" in value) || value["wins"] === void 0) return false;
if (!("losses" in value) || value["losses"] === void 0) return false;
return true;
}
function RecordFromJSON(json) {
return RecordFromJSONTyped(json, false);
}
function RecordFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"team": TeamFromJSON(json["team"]),
"season": json["season"],
"streak": StreakFromJSON(json["streak"]),
"divisionRank": json["divisionRank"],
"leagueRank": json["leagueRank"],
"sportRank": json["sportRank"] == null ? void 0 : json["sportRank"],
"gamesPlayed": json["gamesPlayed"] == null ? void 0 : json["gamesPlayed"],
"gamesBack": json["gamesBack"],
"wildCardGamesBack": json["wildCardGamesBack"] == null ? void 0 : json["wildCardGamesBack"],
"leagueGamesBack": json["leagueGamesBack"] == null ? void 0 : json["leagueGamesBack"],
"sportGamesBack": json["sportGamesBack"] == null ? void 0 : json["sportGamesBack"],
"divisionGamesBack": json["divisionGamesBack"] == null ? void 0 : json["divisionGamesBack"],
"conferenceGamesBack": json["conferenceGamesBack"] == null ? void 0 : json["conferenceGamesBack"],
"leagueRecord": LeagueRecordFromJSON(json["leagueRecord"]),
"lastUpdated": json["lastUpdated"] == null ? void 0 : json["lastUpdated"],
"runsAllowed": json["runsAllowed"] == null ? void 0 : json["runsAllowed"],
"runsScored": json["runsScored"] == null ? void 0 : json["runsScored"],
"divisionChamp": json["divisionChamp"] == null ? void 0 : json["divisionChamp"],
"divisionLeader": json["divisionLeader"] == null ? void 0 : json["divisionLeader"],
"hasWildcard": json["hasWildcard"] == null ? void 0 : json["hasWildcard"],
"clinched": json["clinched"] == null ? void 0 : json["clinched"],
"eliminationNumber": json["eliminationNumber"] == null ? void 0 : json["eliminationNumber"],
"eliminationNumberSport": json["eliminationNumberSport"] == null ? void 0 : json["eliminationNumberSport"],
"eliminationNumberLeague": json["eliminationNumberLeague"] == null ? void 0 : json["eliminationNumberLeague"],
"eliminationNumberDivision": json["eliminationNumberDivision"] == null ? void 0 : json["eliminationNumberDivision"],
"eliminationNumberConference": json["eliminationNumberConference"] == null ? void 0 : json["eliminationNumberConference"],
"wildCardEliminationNumber": json["wildCardEliminationNumber"] == null ? void 0 : json["wildCardEliminationNumber"],
"magicNumber": json["magicNumber"] == null ? void 0 : json["magicNumber"],
"wins": json["wins"],
"losses": json["losses"],
"runDifferential": json["runDifferential"] == null ? void 0 : json["runDifferential"],
"winningPercentage": json["winningPercentage"] == null ? void 0 : json["winningPercentage"]
};
}
function RecordToJSON(json) {
return RecordToJSONTyped(json, false);
}
function RecordToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"team": TeamToJSON(value["team"]),
"season": value["season"],
"streak": StreakToJSON(value["streak"]),
"divisionRank": value["divisionRank"],
"leagueRank": value["leagueRank"],
"sportRank": value["sportRank"],
"gamesPlayed": value["gamesPlayed"],
"gamesBack": value["gamesBack"],
"wildCardGamesBack": value["wildCardGamesBack"],
"leagueGamesBack": value["leagueGamesBack"],
"sportGamesBack": value["sportGamesBack"],
"divisionGamesBack": value["divisionGamesBack"],
"conferenceGamesBack": value["conferenceGamesBack"],
"leagueRecord": LeagueRecordToJSON(value["leagueRecord"]),
"lastUpdated": value["lastUpdated"],
"runsAllowed": value["runsAllowed"],
"runsScored": value["runsScored"],
"divisionChamp": value["divisionChamp"],
"divisionLeader": value["divisionLeader"],
"hasWildcard": value["hasWildcard"],
"clinched": value["clinched"],
"eliminationNumber": value["eliminationNumber"],
"eliminationNumberSport": value["eliminationNumberSport"],
"eliminationNumberLeague": value["eliminationNumberLeague"],
"eliminationNumberDivision": value["eliminationNumberDivision"],
"eliminationNumberConference": value["eliminationNumberConference"],
"wildCardEliminationNumber": value["wildCardEliminationNumber"],
"magicNumber": value["magicNumber"],
"wins": value["wins"],
"losses": value["losses"],
"runDifferential": value["runDifferential"],
"winningPercentage": value["winningPercentage"]
};
}
// src/models/Team.ts
function instanceOfTeam(value) {
if (!("id" in value) || value["id"] === void 0) return false;
if (!("name" in value) || value["name"] === void 0) return false;
return true;
}
function TeamFromJSON(json) {
return TeamFromJSONTyped2(json, false);
}
function TeamFromJSONTyped2(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"id": json["id"],
"name": json["name"],
"link": json["link"] == null ? void 0 : json["link"],
"allStarStatus": json["allStarStatus"] == null ? void 0 : json["allStarStatus"],
"season": json["season"] == null ? void 0 : json["season"],
"venue": json["venue"] == null ? void 0 : VenueFromJSON(json["venue"]),
"springVenue": json["springVenue"] == null ? void 0 : VenueFromJSON(json["springVenue"]),
"teamCode": json["teamCode"] == null ? void 0 : json["teamCode"],
"fileCode": json["fileCode"] == null ? void 0 : json["fileCode"],
"abbreviation": json["abbreviation"] == null ? void 0 : json["abbreviation"],
"teamName": json["teamName"] == null ? void 0 : json["teamName"],
"locationName": json["locationName"] == null ? void 0 : json["locationName"],
"firstYearOfPlay": json["firstYearOfPlay"] == null ? void 0 : json["firstYearOfPlay"],
"league": json["league"] == null ? void 0 : LeagueFromJSON(json["league"]),
"springLeague": json["springLeague"] == null ? void 0 : LeagueFromJSON(json["springLeague"]),
"division": json["division"] == null ? void 0 : DivisionFromJSON(json["division"]),
"sport": json["sport"] == null ? void 0 : SportFromJSON(json["sport"]),
"record": json["record"] == null ? void 0 : RecordFromJSON(json["record"]),
"shortName": json["shortName"] == null ? void 0 : json["shortName"],
"franchiseName": json["franchiseName"] == null ? void 0 : json["franchiseName"],
"clubName": json["clubName"] == null ? void 0 : json["clubName"],
"active": json["active"] == null ? void 0 : json["active"]
};
}
function TeamToJSON(json) {
return TeamToJSONTyped2(json, false);
}
function TeamToJSONTyped2(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"id": value["id"],
"name": value["name"],
"link": value["link"],
"allStarStatus": value["allStarStatus"],
"season": value["season"],
"venue": VenueToJSON(value["venue"]),
"springVenue": VenueToJSON(value["springVenue"]),
"teamCode": value["teamCode"],
"fileCode": value["fileCode"],
"abbreviation": value["abbreviation"],
"teamName": value["teamName"],
"locationName": value["locationName"],
"firstYearOfPlay": value["firstYearOfPlay"],
"league": LeagueToJSON(value["league"]),
"springLeague": LeagueToJSON(value["springLeague"]),
"division": DivisionToJSON(value["division"]),
"sport": SportToJSON(value["sport"]),
"record": RecordToJSON(value["record"]),
"shortName": value["shortName"],
"franchiseName": value["franchiseName"],
"clubName": value["clubName"],
"active": value["active"]
};
}
// src/models/BoxscoreTeams.ts
function instanceOfBoxscoreTeams(value) {
return true;
}
function BoxscoreTeamsFromJSON(json) {
return BoxscoreTeamsFromJSONTyped(json, false);
}
function BoxscoreTeamsFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"away": json["away"] == null ? void 0 : TeamFromJSON(json["away"]),
"home": json["home"] == null ? void 0 : TeamFromJSON(json["home"])
};
}
function BoxscoreTeamsToJSON(json) {
return BoxscoreTeamsToJSONTyped(json, false);
}
function BoxscoreTeamsToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"away": TeamToJSON(value["away"]),
"home": TeamToJSON(value["home"])
};
}
// src/models/Boxscore.ts
function instanceOfBoxscore(value) {
return true;
}
function BoxscoreFromJSON(json) {
return BoxscoreFromJSONTyped(json, false);
}
function BoxscoreFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"teams": json["teams"] == null ? void 0 : BoxscoreTeamsFromJSON(json["teams"]),
"officials": json["officials"] == null ? void 0 : json["officials"].map(GameOfficialFromJSON)
};
}
function BoxscoreToJSON(json) {
return BoxscoreToJSONTyped(json, false);
}
function BoxscoreToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"teams": BoxscoreTeamsToJSON(value["teams"]),
"officials": value["officials"] == null ? void 0 : value["officials"].map(GameOfficialToJSON)
};
}
// src/models/DivisionStandings.ts
function instanceOfDivisionStandings(value) {
if (!("league" in value) || value["league"] === void 0) return false;
if (!("division" in value) || value["division"] === void 0) return false;
if (!("sport" in value) || value["sport"] === void 0) return false;
if (!("teamRecords" in value) || value["teamRecords"] === void 0) return false;
return true;
}
function DivisionStandingsFromJSON(json) {
return DivisionStandingsFromJSONTyped(json, false);
}
function DivisionStandingsFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"standingsType": json["standingsType"] == null ? void 0 : json["standingsType"],
"league": LeagueFromJSON(json["league"]),
"division": DivisionFromJSON(json["division"]),
"sport": SportFromJSON(json["sport"]),
"lastUpdated": json["lastUpdated"] == null ? void 0 : json["lastUpdated"],
"teamRecords": json["teamRecords"].map(RecordFromJSON)
};
}
function DivisionStandingsToJSON(json) {
return DivisionStandingsToJSONTyped(json, false);
}
function DivisionStandingsToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"standingsType": value["standingsType"],
"league": LeagueToJSON(value["league"]),
"division": DivisionToJSON(value["division"]),
"sport": SportToJSON(value["sport"]),
"lastUpdated": value["lastUpdated"],
"teamRecords": value["teamRecords"].map(RecordToJSON)
};
}
// src/models/DivisionStandingsList.ts
function instanceOfDivisionStandingsList(value) {
return true;
}
function DivisionStandingsListFromJSON(json) {
return DivisionStandingsListFromJSONTyped(json, false);
}
function DivisionStandingsListFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"records": json["records"] == null ? void 0 : json["records"].map(DivisionStandingsFromJSON)
};
}
function DivisionStandingsListToJSON(json) {
return DivisionStandingsListToJSONTyped(json, false);
}
function DivisionStandingsListToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"records": value["records"] == null ? void 0 : value["records"].map(DivisionStandingsToJSON)
};
}
// src/models/GameStatusCode.ts
var GameStatusCode = /* @__PURE__ */ ((GameStatusCode2) => {
GameStatusCode2["Final"] = "F";
GameStatusCode2["Postponed"] = "D";
GameStatusCode2["Scheduled"] = "S";
GameStatusCode2["InProgress"] = "I";
GameStatusCode2["Pregame"] = "P";
GameStatusCode2["GameOver"] = "O";
GameStatusCode2["Canceled"] = "C";
return GameStatusCode2;
})(GameStatusCode || {});
function instanceOfGameStatusCode(value) {
for (const key in GameStatusCode) {
if (Object.prototype.hasOwnProperty.call(GameStatusCode, key)) {
if (GameStatusCode[key] === value) {
return true;
}
}
}
return false;
}
function GameStatusCodeFromJSON(json) {
return GameStatusCodeFromJSONTyped(json, false);
}
function GameStatusCodeFromJSONTyped(json, ignoreDiscriminator) {
return json;
}
function GameStatusCodeToJSON(value) {
return value;
}
function GameStatusCodeToJSONTyped(value, ignoreDiscriminator) {
return value;
}
// src/models/GameStatus.ts
function instanceOfGameStatus(value) {
return true;
}
function GameStatusFromJSON(json) {
return GameStatusFromJSONTyped(json, false);
}
function GameStatusFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"abstractGameState": json["abstractGameState"] == null ? void 0 : json["abstractGameState"],
"codedGameState": json["codedGameState"] == null ? void 0 : GameStatusCodeFromJSON(json["codedGameState"]),
"detailedState": json["detailedState"] == null ? void 0 : json["detailedState"],
"statusCode": json["statusCode"] == null ? void 0 : json["statusCode"],
"startTimeTBD": json["startTimeTBD"] == null ? void 0 : json["startTimeTBD"],
"abstractGameCode": json["abstractGameCode"] == null ? void 0 : json["abstractGameCode"]
};
}
function GameStatusToJSON(json) {
return GameStatusToJSONTyped(json, false);
}
function GameStatusToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"abstractGameState": value["abstractGameState"],
"codedGameState": GameStatusCodeToJSON(value["codedGameState"]),
"detailedState": value["detailedState"],
"statusCode": value["statusCode"],
"startTimeTBD": value["startTimeTBD"],
"abstractGameCode": value["abstractGameCode"]
};
}
// src/models/GameTeam.ts
function instanceOfGameTeam(value) {
if (!("score" in value) || value["score"] === void 0) return false;
if (!("team" in value) || value["team"] === void 0) return false;
if (!("isWinner" in value) || value["isWinner"] === void 0) return false;
return true;
}
function GameTeamFromJSON(json) {
return GameTeamFromJSONTyped(json, false);
}
function GameTeamFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"leagueRecord": json["leagueRecord"] == null ? void 0 : LeagueRecordFromJSON(json["leagueRecord"]),
"score": json["score"],
"team": TeamFromJSON(json["team"]),
"isWinner": json["isWinner"],
"splitSquad": json["splitSquad"] == null ? void 0 : json["splitSquad"],
"seriesNumber": json["seriesNumber"] == null ? void 0 : json["seriesNumber"]
};
}
function GameTeamToJSON(json) {
return GameTeamToJSONTyped(json, false);
}
function GameTeamToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"leagueRecord": LeagueRecordToJSON(value["leagueRecord"]),
"score": value["score"],
"team": TeamToJSON(value["team"]),
"isWinner": value["isWinner"],
"splitSquad": value["splitSquad"],
"seriesNumber": value["seriesNumber"]
};
}
// src/models/GameTeams.ts
function instanceOfGameTeams(value) {
if (!("away" in value) || value["away"] === void 0) return false;
if (!("home" in value) || value["home"] === void 0) return false;
return true;
}
function GameTeamsFromJSON(json) {
return GameTeamsFromJSONTyped(json, false);
}
function GameTeamsFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"away": GameTeamFromJSON(json["away"]),
"home": GameTeamFromJSON(json["home"])
};
}
function GameTeamsToJSON(json) {
return GameTeamsToJSONTyped(json, false);
}
function GameTeamsToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"away": GameTeamToJSON(value["away"]),
"home": GameTeamToJSON(value["home"])
};
}
// src/models/GameType.ts
var GameType = /* @__PURE__ */ ((GameType2) => {
GameType2["Exhibition"] = "E";
GameType2["SpringTraining"] = "S";
GameType2["Regular"] = "R";
GameType2["WildCardSeries"] = "F";
GameType2["DivisionSeries"] = "D";
GameType2["LeagueChampionshipSeries"] = "L";
GameType2["WorldSeries"] = "W";
return GameType2;
})(GameType || {});
function instanceOfGameType(value) {
for (const key in GameType) {
if (Object.prototype.hasOwnProperty.call(GameType, key)) {
if (GameType[key] === value) {
return true;
}
}
}
return false;
}
function GameTypeFromJSON(json) {
return GameTypeFromJSONTyped(json, false);
}
function GameTypeFromJSONTyped(json, ignoreDiscriminator) {
return json;
}
function GameTypeToJSON(value) {
return value;
}
function GameTypeToJSONTyped(value, ignoreDiscriminator) {
return value;
}
// src/models/Game.ts
function instanceOfGame(value) {
if (!("gamePk" in value) || value["gamePk"] === void 0) return false;
if (!("gameGuid" in value) || value["gameGuid"] === void 0) return false;
if (!("gameType" in value) || value["gameType"] === void 0) return false;
if (!("season" in value) || value["season"] === void 0) return false;
if (!("gameDate" in value) || value["gameDate"] === void 0) return false;
if (!("officialDate" in value) || value["officialDate"] === void 0) return false;
if (!("status" in value) || value["status"] === void 0) return false;
if (!("teams" in value) || value["teams"] === void 0) return false;
if (!("gameNumber" in value) || value["gameNumber"] === void 0) return false;
if (!("gamesInSeries" in value) || value["gamesInSeries"] === void 0) return false;
if (!("seriesGameNumber" in value) || value["seriesGameNumber"] === void 0) return false;
return true;
}
function GameFromJSON(json) {
return GameFromJSONTyped(json, false);
}
function GameFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"gamePk": json["gamePk"],
"gameGuid": json["gameGuid"],
"link": json["link"] == null ? void 0 : json["link"],
"gameType": GameTypeFromJSON(json["gameType"]),
"season": json["season"],
"gameDate": json["gameDate"],
"officialDate": json["officialDate"],
"rescheduledTo": json["rescheduledTo"] == null ?