nintendo-switch-eshop
Advanced tools
Comparing version 6.0.1 to 6.0.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getGamesAmerica = void 0; | ||
const tslib_1 = require("tslib"); | ||
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch")); | ||
const fetch_1 = require("@sapphire/fetch"); | ||
const querystring_1 = require("querystring"); | ||
@@ -29,6 +28,6 @@ const constants_1 = require("../utils/constants"); | ||
indexName: US_INDEX_TITLE_ASC, | ||
params: querystring_1.stringify({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
params: (0, querystring_1.stringify)({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
}, { | ||
indexName: US_INDEX_TITLE_DESC, | ||
params: querystring_1.stringify({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
params: (0, querystring_1.stringify)({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
}); | ||
@@ -39,6 +38,6 @@ } | ||
indexName: US_INDEX_TITLE_ASC, | ||
params: querystring_1.stringify({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
params: (0, querystring_1.stringify)({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
}, { | ||
indexName: US_INDEX_TITLE_DESC, | ||
params: querystring_1.stringify({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
params: (0, querystring_1.stringify)({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
}); | ||
@@ -49,6 +48,6 @@ } | ||
indexName: US_INDEX_TITLE_ASC, | ||
params: querystring_1.stringify({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
params: (0, querystring_1.stringify)({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
}, { | ||
indexName: US_INDEX_TITLE_DESC, | ||
params: querystring_1.stringify({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
params: (0, querystring_1.stringify)({ ...baseParameters, facetFilters: `[["${rating}"],["${US_PLATFORM_FACET_FILTER}"]]` }) | ||
}); | ||
@@ -64,6 +63,3 @@ } | ||
try { | ||
const allGamesResponse = await node_fetch_1.default(constants_1.US_GET_GAMES_URL, requestOptions); | ||
if (!allGamesResponse.ok) | ||
throw new Error('US_games_request_failed'); | ||
const gamesResponse = await allGamesResponse.json(); | ||
const gamesResponse = await (0, fetch_1.fetch)(constants_1.US_GET_GAMES_URL, requestOptions, "json" /* JSON */); | ||
let allGames = []; | ||
@@ -73,8 +69,9 @@ for (const results of gamesResponse.results) { | ||
} | ||
allGames = utils_1.arrayRemoveDuplicates(allGames, 'slug'); | ||
allGames = (0, utils_1.arrayRemoveDuplicates)(allGames, 'slug'); | ||
return allGames; | ||
} | ||
catch (err) { | ||
if (/(?:US_games_request_failed)/i.test(err.toString())) | ||
if (/(?:US_games_request_failed)/i.test(err.message)) { | ||
throw new utils_1.EshopError('Fetching of US Games failed'); | ||
} | ||
throw err; | ||
@@ -81,0 +78,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getGamesEurope = void 0; | ||
const tslib_1 = require("tslib"); | ||
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch")); | ||
const fetch_1 = require("@sapphire/fetch"); | ||
const querystring_1 = require("querystring"); | ||
@@ -24,14 +23,12 @@ const constants_1 = require("../utils/constants"); | ||
try { | ||
const gamesEU = await node_fetch_1.default(`${constants_1.EU_GET_GAMES_URL.replace('{locale}', options.locale)}?${querystring_1.stringify({ | ||
const gamesData = await (0, fetch_1.fetch)(`${constants_1.EU_GET_GAMES_URL.replace('{locale}', options.locale)}?${(0, querystring_1.stringify)({ | ||
rows: options.limit, | ||
...constants_1.EU_GET_GAMES_OPTIONS | ||
})}`); | ||
if (!gamesEU.ok) | ||
throw new Error('EU_games_request_failed'); | ||
const gamesData = await gamesEU.json(); | ||
})}`, "json" /* JSON */); | ||
return gamesData.response.docs; | ||
} | ||
catch (err) { | ||
if (/(?:EU_games_request_failed)/i.test(err.toString())) | ||
if (/(?:EU_games_request_failed)/i.test(err.message)) { | ||
throw new utils_1.EshopError('Fetching of EU Games failed'); | ||
} | ||
throw err; | ||
@@ -38,0 +35,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getGamesJapan = void 0; | ||
const tslib_1 = require("tslib"); | ||
const fetch_1 = require("@sapphire/fetch"); | ||
const fast_xml_parser_1 = require("fast-xml-parser"); | ||
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch")); | ||
const constants_1 = require("../utils/constants"); | ||
@@ -16,12 +15,10 @@ const utils_1 = require("../utils/utils"); | ||
try { | ||
const gamesJP = await node_fetch_1.default(constants_1.JP_GET_GAMES_URL); | ||
if (!gamesJP.ok) | ||
throw new Error('JP_games_request_failed'); | ||
const parsedGamesJP = fast_xml_parser_1.parse(await gamesJP.text()); | ||
const allGamesJP = parsedGamesJP.TitleInfoList.TitleInfo; | ||
const gamesJP = (0, fast_xml_parser_1.parse)(await (0, fetch_1.fetch)(constants_1.JP_GET_GAMES_URL, "text" /* Text */)); | ||
const allGamesJP = gamesJP.TitleInfoList.TitleInfo; | ||
return allGamesJP; | ||
} | ||
catch (err) { | ||
if (/(?:JP_games_request_failed)/i.test(err.toString())) | ||
if (/(?:JP_games_request_failed)/i.test(err.message)) { | ||
throw new utils_1.EshopError('Fetching of JP Games failed'); | ||
} | ||
throw err; | ||
@@ -28,0 +25,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getQueriedGamesAmerica = void 0; | ||
const tslib_1 = require("tslib"); | ||
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch")); | ||
const fetch_1 = require("@sapphire/fetch"); | ||
const querystring_1 = require("querystring"); | ||
@@ -18,3 +17,3 @@ const constants_1 = require("../utils/constants"); | ||
const getQueriedGamesAmerica = async (query, { hitsPerPage = 200, page = 0 } = { hitsPerPage: 200, page: 0 }) => { | ||
const response = await node_fetch_1.default(constants_1.QUERIED_US_GET_GAMES_URL, { | ||
const { hits } = await (0, fetch_1.fetch)(constants_1.QUERIED_US_GET_GAMES_URL, { | ||
method: 'POST', | ||
@@ -26,3 +25,3 @@ headers: { | ||
body: JSON.stringify({ | ||
params: querystring_1.stringify({ | ||
params: (0, querystring_1.stringify)({ | ||
hitsPerPage, | ||
@@ -33,6 +32,3 @@ page, | ||
}) | ||
}); | ||
if (!response.ok) | ||
throw new utils_1.EshopError(`Fetching games for the query "${query} failed"`); | ||
const { hits } = await response.json(); | ||
}, "json" /* JSON */); | ||
if (!hits.length) | ||
@@ -39,0 +35,0 @@ throw new utils_1.EshopError(`No game results for the query "${query}"`); |
@@ -17,9 +17,9 @@ "use strict"; | ||
try { | ||
const shopsAmerica = await getShopsAmerica_1.getShopsAmerica(); | ||
const shopsAsia = await getShopsAsia_1.getShopsAsia(); | ||
const shopsEurope = await getShopsEurope_1.getShopsEurope(); | ||
const shopsAmerica = await (0, getShopsAmerica_1.getShopsAmerica)(); | ||
const shopsAsia = await (0, getShopsAsia_1.getShopsAsia)(); | ||
const shopsEurope = await (0, getShopsEurope_1.getShopsEurope)(); | ||
return shopsAmerica.concat(shopsAsia, shopsEurope); | ||
} | ||
catch (err) { | ||
throw new Error(err); | ||
throw err; | ||
} | ||
@@ -26,0 +26,0 @@ }; |
@@ -16,5 +16,5 @@ "use strict"; | ||
const getShopsAmerica = async () => { | ||
return getShopByCountryCode_1.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, 1 /* AMERICAS */); | ||
return (0, getShopByCountryCode_1.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, 1 /* AMERICAS */); | ||
}; | ||
exports.getShopsAmerica = getShopsAmerica; | ||
//# sourceMappingURL=getShopsAmerica.js.map |
@@ -16,5 +16,5 @@ "use strict"; | ||
const getShopsAsia = async () => { | ||
return getShopByCountryCode_1.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, 3 /* ASIA */); | ||
return (0, getShopByCountryCode_1.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, 3 /* ASIA */); | ||
}; | ||
exports.getShopsAsia = getShopsAsia; | ||
//# sourceMappingURL=getShopsAsia.js.map |
@@ -16,5 +16,5 @@ "use strict"; | ||
const getShopsEurope = async () => { | ||
return getShopByCountryCode_1.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, 2 /* EUROPE */); | ||
return (0, getShopByCountryCode_1.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, 2 /* EUROPE */); | ||
}; | ||
exports.getShopsEurope = getShopsEurope; | ||
//# sourceMappingURL=getShopsEurope.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getPrices = void 0; | ||
const tslib_1 = require("tslib"); | ||
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch")); | ||
const fetch_1 = require("@sapphire/fetch"); | ||
const querystring_1 = require("querystring"); | ||
@@ -21,3 +20,3 @@ const constants_1 = require("../utils/constants"); | ||
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({ | ||
const response = await (0, fetch_1.fetch)(`${constants_1.PRICE_GET_URL}?${(0, querystring_1.stringify)({ | ||
country, | ||
@@ -27,11 +26,6 @@ ids: filteredIds, | ||
...constants_1.PRICE_GET_OPTIONS | ||
})}`); | ||
if (priceData.status === 403) | ||
throw new Error('PRICE_Rate_Limit'); | ||
if (!priceData.ok) | ||
throw new Error('PRICE_get_request_failed'); | ||
const response = await priceData.json(); | ||
})}`, "json" /* 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 await (0, exports.getPrices)(country, gameIds, offset + constants_1.PRICE_LIST_LIMIT, accumulatedPrices); | ||
} | ||
@@ -45,6 +39,8 @@ else if (response.prices) { | ||
catch (err) { | ||
if (/(?:PRICE_Rate_Limit)/i.test(err.toString())) | ||
if (/(?:PRICE_Rate_Limit)/i.test(err.message)) { | ||
throw new utils_1.EshopError('Looks like you ran into a rate limit while getting price data, please do not spam the Nintendo servers.'); | ||
if (/(?:PRICE_get_request_failed)/i.test(err.toString())) | ||
} | ||
if (/(?:PRICE_get_request_failed)/i.test(err.message)) { | ||
throw new utils_1.EshopError('Fetching of eShop prices failed'); | ||
} | ||
throw err; | ||
@@ -51,0 +47,0 @@ } |
@@ -20,3 +20,3 @@ "use strict"; | ||
try { | ||
const response = await getPrices_1.getPrices(country.alpha2, gameCode); | ||
const response = await (0, getPrices_1.getPrices)(country.alpha2, gameCode); | ||
response.country = country; | ||
@@ -41,5 +41,6 @@ shops.push(response); | ||
catch (err) { | ||
if (/(?:ACTIVE_SHOPS_Rate_Limit)/i.test(err.toString())) | ||
if (/(?:ACTIVE_SHOPS_Rate_Limit)/i.test(err.message)) { | ||
throw new Error('Looks like you ran into a rate limit while getting price data, please do not spam the Nintendo servers.'); | ||
throw new Error(err); | ||
} | ||
throw err; | ||
} | ||
@@ -46,0 +47,0 @@ }; |
{ | ||
"name": "nintendo-switch-eshop", | ||
"version": "6.0.1", | ||
"version": "6.0.2", | ||
"description": "Unofficial API lib for Nintendo Switch eShop game listing and pricing information.", | ||
@@ -16,4 +16,3 @@ "author": "lmmfranco", | ||
"lint": "eslint src __tests__ --ext js,ts --fix", | ||
"build": "tsc -b src", | ||
"postbuild": "gen-esm-wrapper dist/index.js dist/index.mjs", | ||
"build": "tsc -b src && gen-esm-wrapper dist/index.js dist/index.mjs", | ||
"watch": "tsc -b src -w", | ||
@@ -23,5 +22,3 @@ "clean": "tsc -b src --clean", | ||
"sversion": "standard-version", | ||
"commit": "git-cz", | ||
"cz": "git-cz", | ||
"update": "yarn upgrade-interactive --latest", | ||
"update": "yarn upgrade-interactive", | ||
"prepublishOnly": "yarn build", | ||
@@ -31,37 +28,35 @@ "prepare": "husky install .github/husky" | ||
"dependencies": { | ||
"@sapphire/fetch": "^2.0.2", | ||
"@types/country-data": "^0.0.2", | ||
"country-data": "^0.0.31", | ||
"fast-xml-parser": "^3.19.0", | ||
"node-fetch": "^2.6.1" | ||
"fast-xml-parser": "^3.21.0" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^12.1.4", | ||
"@commitlint/config-conventional": "^12.1.4", | ||
"@sapphire/eslint-config": "^3.1.4", | ||
"@sapphire/prettier-config": "^1.1.3", | ||
"@sapphire/ts-config": "^2.2.3", | ||
"@types/jest": "^26.0.23", | ||
"@types/node": "^15.12.3", | ||
"@types/node-fetch": "^2.5.10", | ||
"@typescript-eslint/eslint-plugin": "^4.27.0", | ||
"@typescript-eslint/parser": "^4.27.0", | ||
"@commitlint/cli": "^13.2.1", | ||
"@commitlint/config-conventional": "^13.2.0", | ||
"@sapphire/eslint-config": "^4.0.1", | ||
"@sapphire/prettier-config": "^1.2.3", | ||
"@sapphire/ts-config": "^3.1.2", | ||
"@types/jest": "^27.0.2", | ||
"@types/node": "^16.11.5", | ||
"@typescript-eslint/eslint-plugin": "^5.2.0", | ||
"@typescript-eslint/parser": "^5.2.0", | ||
"common-tags": "^1.8.0", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^7.29.0", | ||
"eslint": "^8.1.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"gen-esm-wrapper": "^1.1.2", | ||
"husky": "^6.0.0", | ||
"jest": "^27.0.4", | ||
"jest-circus": "^27.0.4", | ||
"lint-staged": "^11.0.0", | ||
"prettier": "^2.3.1", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"gen-esm-wrapper": "^1.1.3", | ||
"husky": "^7.0.4", | ||
"jest": "^27.3.1", | ||
"jest-circus": "^27.3.1", | ||
"lint-staged": "^11.2.4", | ||
"prettier": "^2.4.1", | ||
"pretty-quick": "^3.1.1", | ||
"replace": "^1.2.1", | ||
"standard-version": "^9.3.0", | ||
"ts-jest": "^27.0.3", | ||
"ts-node": "^10.0.0", | ||
"typedoc": "^0.21.0", | ||
"typedoc-plugin-nojekyll": "^1.0.1", | ||
"typescript": "^4.3.4" | ||
"standard-version": "^9.3.2", | ||
"ts-jest": "^27.0.7", | ||
"ts-node": "^10.4.0", | ||
"typedoc": "^0.22.7", | ||
"typescript": "^4.4.4" | ||
}, | ||
@@ -104,6 +99,3 @@ "files": [ | ||
}, | ||
"resolutions": { | ||
"lodash": "^4.17.21", | ||
"dot-prop": "^6.0.1" | ||
} | ||
"packageManager": "yarn@3.0.2" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
27
98075
1199
1
+ Added@sapphire/fetch@^2.0.2
+ Added@sapphire/fetch@2.4.2(transitive)
+ Addedcross-fetch@4.1.0(transitive)
- Removednode-fetch@^2.6.1
Updatedfast-xml-parser@^3.21.0