nintendo-switch-eshop
Advanced tools
Comparing version 2.2.5 to 2.2.6
@@ -5,2 +5,9 @@ # Changelog | ||
### [2.2.6](https://github.com/lmmfranco/nintendo-switch-eshop/compare/v2.2.5...v2.2.6) (2019-11-27) | ||
### Bug Fixes | ||
* jp nsuid parsing & tslib dep ([2bf5629](https://github.com/lmmfranco/nintendo-switch-eshop/commit/2bf56291fdd762b1dced28c11be23f3e7e1763aa)), closes [#90](https://github.com/lmmfranco/nintendo-switch-eshop/issues/90) [#91](https://github.com/lmmfranco/nintendo-switch-eshop/issues/91) | ||
### [2.2.5](https://github.com/lmmfranco/nintendo-switch-eshop/compare/v2.2.4...v2.2.5) (2019-11-22) | ||
@@ -7,0 +14,0 @@ |
@@ -71,1 +71,2 @@ /** Options used for getting US gmaes */ | ||
} | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -6,1 +6,2 @@ import { getGamesAmerica } from './nintendo-switch-eshop'; | ||
export default getGamesAmerica; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -108,18 +108,22 @@ import { Country } from 'country-data'; | ||
} | ||
export interface GameJP { | ||
/** A single item array containing the game url */ | ||
LinkURL: string[]; | ||
LinkTarget: string[]; | ||
/** A single item array containing the game thumbnail url */ | ||
ScreenshotImgURL: string[]; | ||
ScreenshotImgURLComing: string[]; | ||
/** A single item array containing the game title */ | ||
TitleName: string[]; | ||
TitleNameRuby: string[]; | ||
SoftType: string[]; | ||
SalesDate: string[]; | ||
SalesDateStr: string[]; | ||
MakerName: string[]; | ||
Hard: string[]; | ||
Memo: string[]; | ||
export interface GameJP extends Record<string, string | number> { | ||
/** The game url */ | ||
LinkURL: string; | ||
/** The Link Target, if it exists */ | ||
LinkTarget: string; | ||
/** The screenshot URL, if it exists */ | ||
ScreenshotImgURL: string; | ||
/** The variation of the thumbnail */ | ||
ThumbVariation: string; | ||
ComingThumb: 'yes' | string; | ||
/** The game's title */ | ||
TitleName: string; | ||
/** The title name in Asian characters */ | ||
TitleNameRuby: string; | ||
SoftType: string; | ||
D: number; | ||
SalesDateStr: string; | ||
MakerName: string; | ||
Hard: string; | ||
Memo: string; | ||
} | ||
@@ -182,1 +186,2 @@ export interface EShop { | ||
} | ||
//# sourceMappingURL=interfaces.d.ts.map |
@@ -101,1 +101,2 @@ import { EShop, EURequestOptions, GameEU, GameJP, GameUS, PriceResponse, Region, TitleData, USRequestOptions } from './interfaces'; | ||
export declare const parseNSUID: (game: GameEU | GameUS | GameJP, region: Region) => string | null; | ||
//# sourceMappingURL=nintendo-switch-eshop.d.ts.map |
@@ -53,3 +53,3 @@ "use strict"; | ||
*/ | ||
exports.getGamesAmerica = async (options = {}, offset = 0, games = []) => { | ||
exports.getGamesAmerica = (options = {}, offset = 0, games = []) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
const limit = hasProp(options, 'limit') ? options.limit : constants_1.US_GAME_LIST_LIMIT; | ||
@@ -100,9 +100,9 @@ const shopProp = hasProp(options, 'shop') ? options.shop : 'ncom'; | ||
if (hasProp(options, 'limit')) { | ||
const gamesUS = await node_fetch_1.default(constants_1.US_GET_GAMES_URL, body); | ||
const gamesUS = yield node_fetch_1.default(constants_1.US_GET_GAMES_URL, body); | ||
if (!gamesUS.ok) | ||
throw new Error('US_games_request_failed'); | ||
const filteredResponse = await gamesUS.json(); | ||
const filteredResponse = yield gamesUS.json(); | ||
const accumulatedGames = arrayRemoveDuplicates(games.concat(filteredResponse.results[0].hits), 'slug'); | ||
if (!hasProp(options, 'limit') && filteredResponse.results[0].hits.length + offset < filteredResponse.results[0].nbHits) { | ||
return await exports.getGamesAmerica(options, offset + limit, accumulatedGames); | ||
return yield exports.getGamesAmerica(options, offset + limit, accumulatedGames); | ||
} | ||
@@ -137,9 +137,9 @@ return accumulatedGames; | ||
}; | ||
const gamesToCount = await node_fetch_1.default(constants_1.US_GET_GAMES_URL, categoriesRequestOptions); | ||
const gamesToCount = yield node_fetch_1.default(constants_1.US_GET_GAMES_URL, categoriesRequestOptions); | ||
if (!gamesToCount.ok) | ||
throw new Error('US_games_request_failed'); | ||
const response = await gamesToCount.json(); | ||
const response = yield gamesToCount.json(); | ||
const categoryCount = response.results[0].facets.categories; | ||
// Loop through all the categories and fetch the games. | ||
const allGamesPromises = Object.entries(categoryCount).map(async ([category, count]) => { | ||
const allGamesPromises = Object.entries(categoryCount).map(([category, count]) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
const normalRequest = [{ | ||
@@ -177,6 +177,6 @@ indexName: 'noa_aem_game_en_us', | ||
}; | ||
const allGamesResponse = await node_fetch_1.default(constants_1.US_GET_GAMES_URL, allGamesRequestOptions); | ||
const allGamesResponse = yield node_fetch_1.default(constants_1.US_GET_GAMES_URL, allGamesRequestOptions); | ||
if (!allGamesResponse.ok) | ||
throw new Error('US_games_request_failed'); | ||
const gamesResponse = await allGamesResponse.json(); | ||
const gamesResponse = yield allGamesResponse.json(); | ||
return count > 100 | ||
@@ -187,5 +187,5 @@ ? gamesResponse.results | ||
: gamesResponse.results[0].hits; | ||
}); | ||
})); | ||
// Finally fetch all the games and remove duplicates | ||
let allGames = (await Promise.all(allGamesPromises)).reduce((a, b) => a.concat(b, [])); | ||
let allGames = (yield Promise.all(allGamesPromises)).reduce((a, b) => a.concat(b, [])); | ||
allGames = arrayRemoveDuplicates(allGames, 'slug'); | ||
@@ -199,3 +199,3 @@ return allGames; | ||
} | ||
}; | ||
}); | ||
/** | ||
@@ -206,6 +206,6 @@ * Fetches all games on japanese eShops | ||
*/ | ||
exports.getGamesJapan = async () => { | ||
exports.getGamesJapan = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const currentGamesJP = await node_fetch_1.default(constants_1.JP_GET_GAMES_CURRENT); | ||
const comingGamesJP = await node_fetch_1.default(constants_1.JP_GET_GAMES_COMING); | ||
const currentGamesJP = yield node_fetch_1.default(constants_1.JP_GET_GAMES_CURRENT); | ||
const comingGamesJP = yield node_fetch_1.default(constants_1.JP_GET_GAMES_COMING); | ||
if (!currentGamesJP.ok) | ||
@@ -215,4 +215,4 @@ throw new Error('JP_current_games_request_failed'); | ||
throw new Error('JP_coming_games_request_failed'); | ||
const parsedCurrentGames = fast_xml_parser_1.parse(await currentGamesJP.text()); | ||
const parsedComingGames = fast_xml_parser_1.parse(await comingGamesJP.text()); | ||
const parsedCurrentGames = fast_xml_parser_1.parse(yield currentGamesJP.text()); | ||
const parsedComingGames = fast_xml_parser_1.parse(yield comingGamesJP.text()); | ||
const currentGames = parsedCurrentGames.TitleInfoList.TitleInfo; | ||
@@ -229,3 +229,3 @@ const comingGames = parsedComingGames.TitleInfoList.TitleInfo; | ||
} | ||
}; | ||
}); | ||
/** | ||
@@ -240,3 +240,3 @@ * Fetches all games on the European, Australian or New Zealand eShops | ||
*/ | ||
exports.getGamesEurope = async (options = { limit: constants_1.EU_GAME_LIST_LIMIT, locale: constants_1.EU_DEFAULT_LOCALE }) => { | ||
exports.getGamesEurope = (options = { limit: constants_1.EU_GAME_LIST_LIMIT, locale: constants_1.EU_DEFAULT_LOCALE }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
if (!options.limit) | ||
@@ -247,9 +247,6 @@ options.limit = constants_1.EU_GAME_LIST_LIMIT; | ||
try { | ||
const gamesEU = await node_fetch_1.default(`${constants_1.EU_GET_GAMES_URL.replace('{locale}', options.locale)}?${querystring_1.stringify({ | ||
rows: options.limit, | ||
...constants_1.EU_GET_GAMES_OPTIONS, | ||
})}`); | ||
const gamesEU = yield node_fetch_1.default(`${constants_1.EU_GET_GAMES_URL.replace('{locale}', options.locale)}?${querystring_1.stringify(Object.assign({ rows: options.limit }, constants_1.EU_GET_GAMES_OPTIONS))}`); | ||
if (!gamesEU.ok) | ||
throw new Error('EU_games_request_failed'); | ||
const gamesData = await gamesEU.json(); | ||
const gamesData = yield gamesEU.json(); | ||
return gamesData.response.docs; | ||
@@ -262,3 +259,3 @@ } | ||
} | ||
}; | ||
}); | ||
/** | ||
@@ -273,11 +270,6 @@ * Gets pricing information for the requested games. Paginates every 50 games. | ||
*/ | ||
exports.getPrices = async (country, gameIds, offset = 0, prices = []) => { | ||
exports.getPrices = (country, gameIds, offset = 0, prices = []) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const filteredIds = gameIds.slice(offset, offset + constants_1.PRICE_LIST_LIMIT); | ||
const priceData = await node_fetch_1.default(`${constants_1.PRICE_GET_URL}?${querystring_1.stringify({ | ||
country, | ||
ids: filteredIds, | ||
limit: constants_1.PRICE_LIST_LIMIT, | ||
...constants_1.PRICE_GET_OPTIONS, | ||
})}`); | ||
const priceData = yield node_fetch_1.default(`${constants_1.PRICE_GET_URL}?${querystring_1.stringify(Object.assign({ country, ids: filteredIds, limit: constants_1.PRICE_LIST_LIMIT }, constants_1.PRICE_GET_OPTIONS))}`); | ||
if (priceData.status === 403) | ||
@@ -287,6 +279,6 @@ throw new Error('PRICE_Rate_Limit'); | ||
throw new Error('PRICE_get_request_failed'); | ||
const response = await priceData.json(); | ||
const response = yield priceData.json(); | ||
if (response.prices && response.prices.length + offset < gameIds.length) { | ||
const accumulatedPrices = prices.concat(response.prices); | ||
return await exports.getPrices(country, gameIds, offset + constants_1.PRICE_LIST_LIMIT, accumulatedPrices); | ||
return yield exports.getPrices(country, gameIds, offset + constants_1.PRICE_LIST_LIMIT, accumulatedPrices); | ||
} | ||
@@ -306,3 +298,3 @@ else if (response.prices) { | ||
} | ||
}; | ||
}); | ||
/** | ||
@@ -316,3 +308,3 @@ * Gets all active eShops given a list of countries. | ||
*/ | ||
exports.getShopsByCountryCodes = async (countryCodes, gameCode, region) => { | ||
exports.getShopsByCountryCodes = (countryCodes, gameCode, region) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
@@ -323,3 +315,3 @@ const countryList = countryCodes.map((code) => country_data_1.countries.all.filter((country) => country.alpha2 === code)[0]); | ||
try { | ||
const response = await exports.getPrices(country.alpha2, gameCode); | ||
const response = yield exports.getPrices(country.alpha2, gameCode); | ||
response.country = country; | ||
@@ -348,3 +340,3 @@ shops.push(response); | ||
} | ||
}; | ||
}); | ||
/** | ||
@@ -358,5 +350,5 @@ * Gets all active eShops on American countries. | ||
*/ | ||
exports.getShopsAmerica = async () => { | ||
exports.getShopsAmerica = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
return exports.getShopsByCountryCodes(country_data_1.regions.southAmerica.countries.concat(country_data_1.regions.centralAfrica.countries, country_data_1.regions.northernAmerica.countries), constants_1.US_GAME_CHECK_CODE, interfaces_1.Region.AMERICAS); | ||
}; | ||
}); | ||
/** | ||
@@ -370,5 +362,5 @@ * Gets all active eShops on European countries. | ||
*/ | ||
exports.getShopsEurope = async () => { | ||
exports.getShopsEurope = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
return exports.getShopsByCountryCodes(country_data_1.regions.northernEurope.countries.concat(country_data_1.regions.southernEurope.countries, country_data_1.regions.easternEurope.countries, country_data_1.regions.westernEurope.countries, country_data_1.regions.australia.countries, country_data_1.regions.southernAfrica.countries), constants_1.EU_GAME_CHECK_CODE, interfaces_1.Region.EUROPE); | ||
}; | ||
}); | ||
/** | ||
@@ -382,5 +374,5 @@ * Gets all active eShops on Asian countries | ||
*/ | ||
exports.getShopsAsia = async () => { | ||
exports.getShopsAsia = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
return exports.getShopsByCountryCodes(country_data_1.regions.southernAsia.countries.concat(country_data_1.regions.southernAsia.countries, country_data_1.regions.southeastAsia.countries, country_data_1.regions.eastAsia.countries, country_data_1.regions.westernAsia.countries), constants_1.JP_GAME_CHECK_CODE, interfaces_1.Region.ASIA); | ||
}; | ||
}); | ||
/** | ||
@@ -394,7 +386,7 @@ * Gets all active eShops. | ||
*/ | ||
exports.getActiveShops = async () => { | ||
exports.getActiveShops = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const shopsAmerica = await exports.getShopsAmerica(); | ||
const shopsAsia = await exports.getShopsAsia(); | ||
const shopsEurope = await exports.getShopsEurope(); | ||
const shopsAmerica = yield exports.getShopsAmerica(); | ||
const shopsAsia = yield exports.getShopsAsia(); | ||
const shopsEurope = yield exports.getShopsEurope(); | ||
return shopsAmerica.concat(shopsAsia, shopsEurope); | ||
@@ -405,3 +397,3 @@ } | ||
} | ||
}; | ||
}); | ||
/** | ||
@@ -421,3 +413,3 @@ * Parses the game code to extract the cross-region portion. | ||
case interfaces_1.Region.ASIA: | ||
codeParse = constants_1.JP_GAME_CODE_REGEX.exec(game.ScreenshotImgURL[0]); | ||
codeParse = constants_1.JP_GAME_CODE_REGEX.exec(game.ScreenshotImgURL); | ||
break; | ||
@@ -443,3 +435,3 @@ default: | ||
case interfaces_1.Region.ASIA: | ||
const nsuidParse = constants_1.JP_NSUID_REGEX.exec(game.LinkURL[0]); | ||
const nsuidParse = constants_1.JP_NSUID_REGEX.exec(game.LinkURL); | ||
return (nsuidParse && nsuidParse.length > 0) ? nsuidParse[0] : null; | ||
@@ -446,0 +438,0 @@ default: |
{ | ||
"name": "nintendo-switch-eshop", | ||
"version": "2.2.5", | ||
"version": "2.2.6", | ||
"description": "Unofficial API lib for Nintendo Switch eShop game listing and pricing information.", | ||
@@ -25,4 +25,5 @@ "author": "lmmfranco", | ||
"country-data": "^0.0.31", | ||
"fast-xml-parser": "^3.14.0", | ||
"node-fetch": "^2.6.0" | ||
"fast-xml-parser": "^3.15.0", | ||
"node-fetch": "^2.6.0", | ||
"tslib": "latest" | ||
}, | ||
@@ -32,14 +33,14 @@ "devDependencies": { | ||
"@commitlint/config-conventional": "^8.2.0", | ||
"@favware/eslint-config": "^3.1.5", | ||
"@favware/ts-config": "^1.1.0", | ||
"@favware/eslint-config": "^3.1.6", | ||
"@favware/ts-config": "^1.1.1", | ||
"@types/jest": "^24.0.23", | ||
"@types/node": "^12.12.11", | ||
"@types/node-fetch": "^2.5.3", | ||
"@types/node": "^12.12.14", | ||
"@types/node-fetch": "^2.5.4", | ||
"common-tags": "^1.8.0", | ||
"concat-md": "^0.3.2", | ||
"cz-conventional-changelog": "^3.0.2", | ||
"eslint": "^6.6.0", | ||
"eslint": "^6.7.1", | ||
"husky": "^3.1.0", | ||
"jest": "^24.9.0", | ||
"lint-staged": "^9.4.3", | ||
"lint-staged": "^9.5.0", | ||
"replace": "^1.1.1", | ||
@@ -49,3 +50,3 @@ "standard-version": "^7.0.1", | ||
"ts-node": "^8.5.2", | ||
"typedoc": "^0.15.2", | ||
"typedoc": "^0.15.3", | ||
"typedoc-plugin-nojekyll": "^1.0.1", | ||
@@ -52,0 +53,0 @@ "typescript": "^3.7.2" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
73633
20
0
6
875
+ Addedtslib@latest
+ Addedtslib@2.8.1(transitive)
Updatedfast-xml-parser@^3.15.0