@dov118/eso-status
Advanced tools
Comparing version 1.0.0 to 1.1.0
/** | ||
* Methode to used to get status list ESO servers | ||
* | ||
* @type Promise<EsoServer[]> | ||
* Class used to get EsoStatus data | ||
*/ | ||
export declare const EsoStatus: Promise<EsoServer[]>; | ||
export declare class EsoStatus { | ||
/*** | ||
* Methode used to get raw content of the website | ||
* | ||
* @return Promise<string> Raw content of the website | ||
*/ | ||
static getWebSiteContent(url?: string): Promise<string>; | ||
/*** | ||
* Methode used to get raw list content | ||
* | ||
* @param rawContent string Raw content of the website | ||
* @return string Raw list content of the website | ||
*/ | ||
static getRawListContent(rawContent: string): string; | ||
/** | ||
* Methode used to get raw content list from list content | ||
* | ||
* @param rawListContent string Raw list content of the website | ||
* @return InformationBlock[] Raw content list from list content | ||
*/ | ||
static getRawContentItemList(rawListContent: string): InformationBlock[]; | ||
/** | ||
* Methode used to get raw lines from raw content list | ||
* | ||
* @param rawContentItemList InformationBlock[] Raw content list from list content | ||
* @return InformationBlock[] Raw lines from raw content list | ||
*/ | ||
static getRawContentItemLines(rawContentItemList: InformationBlock[]): InformationBlock[]; | ||
/** | ||
* Methode used to get all information blocks from raw list content of the website | ||
* | ||
* @param rawListContent string Raw list content of the website | ||
* @return RawContentListItem[] All information blocks | ||
*/ | ||
static getBlocks(rawListContent: string): InformationBlock[]; | ||
/** | ||
* Methode used to get data of each blocks | ||
* | ||
* @param informationBlocks InformationBlock[] All information blocks | ||
* @return InformationBlock[] All information blocks with data | ||
*/ | ||
static getBlocksData(informationBlocks: InformationBlock[]): InformationBlock[]; | ||
/** | ||
* Methode used to get correct date from information block | ||
* | ||
* @param dateLine string Line of block with raw date information | ||
* @return DateLine Line of block with date information | ||
*/ | ||
static getBlocksDate(dateLine: DateLine | undefined): DateLine | undefined; | ||
/** | ||
* Methode used to get line information data | ||
* | ||
* @param informationLines InformationLine[] Lines of line information | ||
* @return InformationLine[] Lines of line information with data | ||
*/ | ||
static getBlockInformation(informationLines: InformationLine[] | undefined): InformationLine[] | undefined; | ||
/** | ||
* Methode used to get ESO server line slug | ||
* | ||
* @param raw Raw information of line | ||
* @return ServerSlug[] list of slug of the line | ||
*/ | ||
static getInformationLineServerSlug(raw: string): ServerSlug[]; | ||
/** | ||
* Methode used to get ESO server line status | ||
* | ||
* @param raw Raw information of line | ||
* @return ServerStatus Status of the line | ||
*/ | ||
static getInformationLineServerStatus(raw: string): ServerStatus; | ||
/** | ||
* Methode used to get server zone from raw line data | ||
* | ||
* @param serverSlug ServerSlug Server slug | ||
* @return ServerZone Server zone from line data | ||
*/ | ||
static getInformationLineServerZone(serverSlug: ServerSlug): ServerZone; | ||
/** | ||
* Methode used to get server support from raw line data | ||
* | ||
* @param serverSlug ServerSlug Server slug | ||
* @return ServerSupport Server support from line data | ||
*/ | ||
static getInformationLineServerSupport(serverSlug: ServerSlug): ServerSupport; | ||
/** | ||
* Methode used to get last information foreach server/service | ||
* | ||
* @param informationBlock InformationBlock[] | ||
* @return EsoServer[] Server/service information list | ||
*/ | ||
static getLastForEachServer(informationBlock: InformationBlock[]): EsoServer[]; | ||
/** | ||
* Methode used to get readable content of the website | ||
* | ||
* @return EsoServer[] Readable content of the website | ||
*/ | ||
static getEsoStatus(url?: string): Promise<EsoServer[]>; | ||
} | ||
/** | ||
* Format of element from raw content list | ||
*/ | ||
interface InformationBlock { | ||
/** | ||
* Raw content of block | ||
* | ||
* @type string | ||
*/ | ||
raw: string; | ||
/** | ||
* Element of date line | ||
* | ||
* @type DateLine | ||
*/ | ||
date_line?: DateLine; | ||
/** | ||
* Element of information lines | ||
* | ||
* @type InformationLine | ||
*/ | ||
information_lines?: InformationLine[]; | ||
} | ||
/** | ||
* Element of date line | ||
*/ | ||
interface DateLine { | ||
/** | ||
* Raw content of the line | ||
* | ||
* @type string | ||
*/ | ||
raw: string; | ||
/** | ||
* Date correctly formatted | ||
* | ||
* @type string | ||
*/ | ||
data?: string; | ||
} | ||
/** | ||
* Element of information lines | ||
*/ | ||
interface InformationLine { | ||
/** | ||
* Raw content of the line | ||
* | ||
* @type string | ||
*/ | ||
raw: string; | ||
/** | ||
* Server slug list from line information | ||
* | ||
* @type ServerSlug[] | ||
*/ | ||
serverSlug?: ServerSlug[]; | ||
/** | ||
* Server status from line information | ||
* | ||
* @type ServerStatus | ||
*/ | ||
serverStatus?: ServerStatus; | ||
} | ||
/** | ||
* Eso Server/Status | ||
@@ -9,0 +167,0 @@ */ |
653
lib/index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EsoStatus = void 0; | ||
var Request = require("request"); | ||
/*** | ||
* Methode used to get raw content of the website | ||
* | ||
* @return Promise<string> Raw content of the website | ||
var axios_1 = require("axios"); | ||
/** | ||
* Class used to get EsoStatus data | ||
*/ | ||
var getWebSiteContent = function () { | ||
return new Promise(function (resolve, reject) { | ||
Request.get('https://help.elderscrollsonline.com/app/answers/detail/a_id/4320/~/service-alerts', {}, function (error, response, body) { | ||
if (error) { | ||
reject(new Error(error)); | ||
} | ||
else { | ||
if ((response === null || response === void 0 ? void 0 : response.statusCode) !== 200) { | ||
reject(new Error("Bad response " + (response === null || response === void 0 ? void 0 : response.statusCode) + " (" + body + ")")); | ||
var EsoStatus = /** @class */ (function () { | ||
function EsoStatus() { | ||
} | ||
/*** | ||
* Methode used to get raw content of the website | ||
* | ||
* @return Promise<string> Raw content of the website | ||
*/ | ||
EsoStatus.getWebSiteContent = function (url) { | ||
if (url === void 0) { url = 'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320/~/service-alerts'; } | ||
return new Promise(function (resolve, reject) { | ||
axios_1.default | ||
.get(url) | ||
.then(function (response) { | ||
if ((response === null || response === void 0 ? void 0 : response.status) !== 200) { | ||
reject(new Error("Bad response " + (response === null || response === void 0 ? void 0 : response.status) + " (" + (response === null || response === void 0 ? void 0 : response.data) + ")")); | ||
} | ||
else if (!(response === null || response === void 0 ? void 0 : response.data)) { | ||
reject(new Error("Empty response " + (response === null || response === void 0 ? void 0 : response.status) + " (" + (response === null || response === void 0 ? void 0 : response.data) + ")")); | ||
} | ||
else { | ||
resolve(body); | ||
resolve(response === null || response === void 0 ? void 0 : response.data); | ||
} | ||
} | ||
}); | ||
}); | ||
}; | ||
/*** | ||
* Methode used to get raw list content | ||
* | ||
* @param rawContent string Raw content of the website | ||
* @return string Raw list content of the website | ||
*/ | ||
var getRawListContent = function (rawContent) { | ||
var _a, _b; | ||
return (_b = (_a = /<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->.*?<p> <\/p>/s.exec(rawContent)) === null || _a === void 0 ? void 0 : _a.join('')) !== null && _b !== void 0 ? _b : ''; | ||
}; | ||
/** | ||
* Methode used to get raw content list from list content | ||
* | ||
* @param rawListContent string Raw list content of the website | ||
* @return InformationBlock[] Raw content list from list content | ||
*/ | ||
var getRawContentItemList = function (rawListContent) { | ||
var rawContentItemList = []; | ||
var regex = /.*?<hr \/>/gs; | ||
var m; | ||
// tslint:disable-next-line:no-conditional-assignment | ||
while ((m = regex.exec(rawListContent)) !== null) { | ||
m.forEach(function (match) { | ||
rawContentItemList.push({ | ||
raw: match, | ||
}) | ||
.catch(function (error) { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
return rawContentItemList; | ||
}; | ||
/** | ||
* Methode used to get raw lines from raw content list | ||
* | ||
* @param rawContentItemList InformationBlock[] Raw content list from list content | ||
* @return InformationBlock[] Raw lines from raw content list | ||
*/ | ||
var getRawContentItemLines = function (rawContentItemList) { | ||
return rawContentItemList.map(function (item) { | ||
// @ts-ignore | ||
item.information_lines = []; | ||
var regex = /<p>(.*?)<\/p>/gs; | ||
}; | ||
/*** | ||
* Methode used to get raw list content | ||
* | ||
* @param rawContent string Raw content of the website | ||
* @return string Raw list content of the website | ||
*/ | ||
EsoStatus.getRawListContent = function (rawContent) { | ||
var _a, _b; | ||
return (_b = (_a = /<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->.*?<p> <\/p>/s.exec(rawContent)) === null || _a === void 0 ? void 0 : _a.join('')) !== null && _b !== void 0 ? _b : ''; | ||
}; | ||
/** | ||
* Methode used to get raw content list from list content | ||
* | ||
* @param rawListContent string Raw list content of the website | ||
* @return InformationBlock[] Raw content list from list content | ||
*/ | ||
EsoStatus.getRawContentItemList = function (rawListContent) { | ||
var rawContentItemList = []; | ||
var regex = /.*?<hr \/>/gs; | ||
var m; | ||
var index = 0; | ||
// tslint:disable-next-line:no-conditional-assignment | ||
while ((m = regex.exec(item.raw)) !== null) { | ||
while ((m = regex.exec(rawListContent)) !== null) { | ||
m.forEach(function (match) { | ||
var _a; | ||
if (!match.includes('<p>')) { | ||
if (index === 0) { | ||
item.date_line = { | ||
raw: match, | ||
}; | ||
} | ||
else { | ||
(_a = item.information_lines) === null || _a === void 0 ? void 0 : _a.push({ | ||
raw: match, | ||
}); | ||
} | ||
} | ||
rawContentItemList.push({ | ||
raw: match, | ||
}); | ||
}); | ||
index++; | ||
} | ||
return item; | ||
}); | ||
}; | ||
/** | ||
* Methode used to get all information blocks from raw list content of the website | ||
* | ||
* @param rawListContent string Raw list content of the website | ||
* @return RawContentListItem[] All information blocks | ||
*/ | ||
var getBlocks = function (rawListContent) { | ||
return getRawContentItemLines(getRawContentItemList(rawListContent)); | ||
}; | ||
/** | ||
* Methode used to get data of each blocks | ||
* | ||
* @param informationBlocks InformationBlock[] All information blocks | ||
* @return InformationBlock[] All information blocks with data | ||
*/ | ||
var getBlocksData = function (informationBlocks) { | ||
return informationBlocks.map(function (informationBlock) { | ||
informationBlock.date_line = getBlocksDate(informationBlock.date_line); | ||
informationBlock.information_lines = getBlockInformation(informationBlock.information_lines); | ||
return informationBlock; | ||
}); | ||
}; | ||
/** | ||
* Methode used to get correct date from information block | ||
* | ||
* @param dateLine string Line of block with raw date information | ||
* @return DateLine Line of block with date information | ||
*/ | ||
var getBlocksDate = function (dateLine) { | ||
var _a, _b, _c, _d, _e; | ||
if (dateLine) { | ||
// @ts-ignore | ||
var year = (_a = /([0-9]{4})/.exec(dateLine.raw)[1]) !== null && _a !== void 0 ? _a : ''; | ||
// @ts-ignore | ||
var month = (_b = /[0-9]{4}.([0-9]{1,2})/.exec(dateLine.raw)[1]) !== null && _b !== void 0 ? _b : ''; | ||
month = month.length === 2 ? month : "0" + month; | ||
// @ts-ignore | ||
var day = (_c = /[0-9]{4}.[0-9]{1,2}.([0-9]{1,2})/.exec(dateLine.raw)[1]) !== null && _c !== void 0 ? _c : ''; | ||
day = day.length === 2 ? day : "0" + day; | ||
// @ts-ignore | ||
var hour = (_d = /[0-9]{4}.[0-9]{1,2}.[0-9]{1,2} - ([0-9]{1,2})/.exec(dateLine.raw)[1]) !== null && _d !== void 0 ? _d : ''; | ||
hour = hour.length === 2 ? hour : "0" + hour; | ||
// @ts-ignore | ||
var minute = (_e = /[0-9]{4}.[0-9]{1,2}.[0-9]{1,2} - [0-9]{1,2}:([0-9]{1,2})/.exec(dateLine.raw)[1]) !== null && _e !== void 0 ? _e : ''; | ||
minute = minute.length === 2 ? minute : "0" + minute; | ||
dateLine.data = year + "-" + month + "-" + day + "T" + hour + ":" + minute + ":00.000Z"; | ||
} | ||
return dateLine; | ||
}; | ||
/** | ||
* Methode used to get line information data | ||
* | ||
* @param informationLines InformationLine[] Lines of line information | ||
* @return InformationLine[] Lines of line information with data | ||
*/ | ||
var getBlockInformation = function (informationLines) { | ||
return informationLines === null || informationLines === void 0 ? void 0 : informationLines.map(function (informationLine) { | ||
// Get ESO server line slug | ||
informationLine.serverSlug = getInformationLineServerSlug(informationLine.raw); | ||
// Get ESO server line status | ||
informationLine.serverStatus = getInformationLineServerStatus(informationLine.raw); | ||
return informationLine; | ||
}); | ||
}; | ||
/** | ||
* Methode used to get ESO server line slug | ||
* | ||
* @param raw Raw information of line | ||
* @return ServerSlug[] list of slug of the line | ||
*/ | ||
var getInformationLineServerSlug = function (raw) { | ||
var slugs = []; | ||
if (raw.includes('Xbox One megaserver')) { | ||
if (raw.includes('North American')) { | ||
slugs.push('xbox_na'); | ||
return rawContentItemList; | ||
}; | ||
/** | ||
* Methode used to get raw lines from raw content list | ||
* | ||
* @param rawContentItemList InformationBlock[] Raw content list from list content | ||
* @return InformationBlock[] Raw lines from raw content list | ||
*/ | ||
EsoStatus.getRawContentItemLines = function (rawContentItemList) { | ||
return rawContentItemList.map(function (item) { | ||
// @ts-ignore | ||
item.information_lines = []; | ||
var regex = /<p>(.*?)<\/p>/gs; | ||
var m; | ||
var index = 0; | ||
// tslint:disable-next-line:no-conditional-assignment | ||
while ((m = regex.exec(item.raw)) !== null) { | ||
m.forEach(function (match) { | ||
var _a; | ||
if (!match.includes('<p>')) { | ||
if (index === 0) { | ||
item.date_line = { | ||
raw: match, | ||
}; | ||
} | ||
else { | ||
(_a = item.information_lines) === null || _a === void 0 ? void 0 : _a.push({ | ||
raw: match, | ||
}); | ||
} | ||
} | ||
}); | ||
index++; | ||
} | ||
return item; | ||
}); | ||
}; | ||
/** | ||
* Methode used to get all information blocks from raw list content of the website | ||
* | ||
* @param rawListContent string Raw list content of the website | ||
* @return RawContentListItem[] All information blocks | ||
*/ | ||
EsoStatus.getBlocks = function (rawListContent) { | ||
return this.getRawContentItemLines(this.getRawContentItemList(rawListContent)); | ||
}; | ||
/** | ||
* Methode used to get data of each blocks | ||
* | ||
* @param informationBlocks InformationBlock[] All information blocks | ||
* @return InformationBlock[] All information blocks with data | ||
*/ | ||
EsoStatus.getBlocksData = function (informationBlocks) { | ||
var _this = this; | ||
return informationBlocks.map(function (informationBlock) { | ||
informationBlock.date_line = _this.getBlocksDate(informationBlock.date_line); | ||
informationBlock.information_lines = _this.getBlockInformation(informationBlock.information_lines); | ||
return informationBlock; | ||
}); | ||
}; | ||
/** | ||
* Methode used to get correct date from information block | ||
* | ||
* @param dateLine string Line of block with raw date information | ||
* @return DateLine Line of block with date information | ||
*/ | ||
EsoStatus.getBlocksDate = function (dateLine) { | ||
var _a, _b, _c, _d, _e; | ||
//console.log(dateLine); | ||
if (dateLine) { | ||
// @ts-ignore | ||
var year = (_a = /([0-9]{4})/.exec(dateLine.raw)[1]) !== null && _a !== void 0 ? _a : ''; | ||
// @ts-ignore | ||
var month = (_b = /[0-9]{4}.([0-9]{1,2})/.exec(dateLine.raw)[1]) !== null && _b !== void 0 ? _b : ''; | ||
month = month.length === 2 ? month : "0" + month; | ||
// @ts-ignore | ||
var day = (_c = /[0-9]{4}.[0-9]{1,2}.([0-9]{1,2})/.exec(dateLine.raw)[1]) !== null && _c !== void 0 ? _c : ''; | ||
day = day.length === 2 ? day : "0" + day; | ||
// @ts-ignore | ||
var hour = (_d = /[0-9]{4}.[0-9]{1,2}.[0-9]{1,2} - ([0-9]{1,2})/.exec(dateLine.raw)[1]) !== null && _d !== void 0 ? _d : ''; | ||
hour = hour.length === 2 ? hour : "0" + hour; | ||
// @ts-ignore | ||
var minute = (_e = /[0-9]{4}.[0-9]{1,2}.[0-9]{1,2} - [0-9]{1,2}:([0-9]{1,2})/.exec(dateLine.raw)[1]) !== null && _e !== void 0 ? _e : ''; | ||
minute = minute.length === 2 ? minute : "0" + minute; | ||
dateLine.data = year + "-" + month + "-" + day + "T" + hour + ":" + minute + ":00.000Z"; | ||
} | ||
else if (raw.includes('European')) { | ||
slugs.push('xbox_eu'); | ||
return dateLine; | ||
}; | ||
/** | ||
* Methode used to get line information data | ||
* | ||
* @param informationLines InformationLine[] Lines of line information | ||
* @return InformationLine[] Lines of line information with data | ||
*/ | ||
EsoStatus.getBlockInformation = function (informationLines) { | ||
var _this = this; | ||
return informationLines === null || informationLines === void 0 ? void 0 : informationLines.map(function (informationLine) { | ||
// Get ESO server line slug | ||
informationLine.serverSlug = _this.getInformationLineServerSlug(informationLine.raw); | ||
// Get ESO server line status | ||
informationLine.serverStatus = _this.getInformationLineServerStatus(informationLine.raw); | ||
return informationLine; | ||
}); | ||
}; | ||
/** | ||
* Methode used to get ESO server line slug | ||
* | ||
* @param raw Raw information of line | ||
* @return ServerSlug[] list of slug of the line | ||
*/ | ||
EsoStatus.getInformationLineServerSlug = function (raw) { | ||
// console.log(raw); | ||
var slugs = []; | ||
if (raw.includes('Xbox One megaserver')) { | ||
if (raw.includes('North American')) { | ||
slugs.push('xbox_na'); | ||
} | ||
else if (raw.includes('European')) { | ||
slugs.push('xbox_eu'); | ||
} | ||
else { | ||
slugs.push('xbox_na'); | ||
slugs.push('xbox_eu'); | ||
} | ||
} | ||
else { | ||
slugs.push('xbox_na'); | ||
slugs.push('xbox_eu'); | ||
if (raw.includes('PlayStation®4 megaserver')) { | ||
if (raw.includes('North American')) { | ||
slugs.push('ps4_na'); | ||
} | ||
else if (raw.includes('European')) { | ||
slugs.push('ps4_eu'); | ||
} | ||
else { | ||
slugs.push('ps4_na'); | ||
slugs.push('ps4_eu'); | ||
} | ||
} | ||
} | ||
else if (raw.includes('PlayStation®4 megaserver')) { | ||
if (raw.includes('North American')) { | ||
slugs.push('ps4_na'); | ||
if (raw.includes('PC/Mac megaserver')) { | ||
if (raw.includes('North American')) { | ||
slugs.push('pc_na'); | ||
} | ||
else if (raw.includes('European')) { | ||
slugs.push('pc_eu'); | ||
} | ||
else { | ||
slugs.push('pc_na'); | ||
slugs.push('pc_eu'); | ||
} | ||
} | ||
else if (raw.includes('European')) { | ||
if (raw.includes('European megaservers')) { | ||
slugs.push('pc_eu'); | ||
slugs.push('xbox_eu'); | ||
slugs.push('ps4_eu'); | ||
} | ||
else { | ||
if (raw.includes('North American megaservers')) { | ||
slugs.push('pc_na'); | ||
slugs.push('xbox_na'); | ||
slugs.push('ps4_na'); | ||
slugs.push('ps4_eu'); | ||
} | ||
} | ||
else if (raw.includes('PC/Mac megaserver')) { | ||
if (raw.includes('North American')) { | ||
slugs.push('pc_na'); | ||
if (raw.includes('ESO Website')) { | ||
slugs.push('site_web'); | ||
} | ||
else if (raw.includes('European')) { | ||
slugs.push('pc_eu'); | ||
if (raw.includes('PTS')) { | ||
slugs.push('pts'); | ||
} | ||
else { | ||
slugs.push('pc_na'); | ||
slugs.push('pc_eu'); | ||
if (raw.includes('ESO Forums')) { | ||
slugs.push('web_forum'); | ||
} | ||
} | ||
else if (raw.includes('European megaservers')) { | ||
slugs.push('pc_eu'); | ||
slugs.push('xbox_eu'); | ||
slugs.push('ps4_eu'); | ||
} | ||
else if (raw.includes('North American megaservers')) { | ||
slugs.push('pc_na'); | ||
slugs.push('xbox_na'); | ||
slugs.push('ps4_na'); | ||
} | ||
else if (raw.includes('ESO Website')) { | ||
slugs.push('site_web'); | ||
} | ||
else if (raw.includes('PTS')) { | ||
slugs.push('pts'); | ||
} | ||
else if (raw.includes('ESO Forums')) { | ||
slugs.push('web_forum'); | ||
} | ||
else if (raw.includes('megaservers')) { | ||
slugs.push('pc_eu'); | ||
slugs.push('xbox_eu'); | ||
slugs.push('ps4_eu'); | ||
slugs.push('pc_na'); | ||
slugs.push('xbox_na'); | ||
slugs.push('ps4_na'); | ||
} | ||
else if (raw.includes('Crown Store')) { | ||
slugs.push('crown_store'); | ||
} | ||
else if (raw.includes('ESO store') || raw.includes('ESO Store')) { | ||
if (raw.includes('Crown Store')) { | ||
slugs.push('crown_store'); | ||
} | ||
if (raw.includes('ESO store')) { | ||
slugs.push('eso_store'); | ||
} | ||
if (raw.includes('account system')) { | ||
slugs.push('account_system'); | ||
} | ||
slugs.push('eso_store'); | ||
} | ||
else if (raw.includes('account system')) { | ||
if (raw.includes('ESO store') || raw.includes('ESO Store')) { | ||
slugs.push('eso_store'); | ||
if (raw.includes('PlayStation® Network')) { | ||
slugs.push('ps4_na'); | ||
slugs.push('ps4_eu'); | ||
} | ||
slugs.push('account_system'); | ||
} | ||
else if (raw.includes('PlayStation® Network')) { | ||
slugs.push('ps4_na'); | ||
slugs.push('ps4_eu'); | ||
} | ||
return slugs; | ||
}; | ||
/** | ||
* Methode used to get ESO server line status | ||
* | ||
* @param raw Raw information of line | ||
* @return ServerStatus Status of the line | ||
*/ | ||
var getInformationLineServerStatus = function (raw) { | ||
if (raw.includes('unavailable') || raw.includes('interruption')) { | ||
return slugs; | ||
}; | ||
/** | ||
* Methode used to get ESO server line status | ||
* | ||
* @param raw Raw information of line | ||
* @return ServerStatus Status of the line | ||
*/ | ||
EsoStatus.getInformationLineServerStatus = function (raw) { | ||
if (raw.includes('unavailable')) { | ||
return 'down'; | ||
} | ||
else if (raw.includes('available') || raw.includes('online') || raw.includes('resolved')) { | ||
return 'up'; | ||
} | ||
else if (raw.includes('currently investigating') || raw.includes('interruption')) { | ||
return 'issues'; | ||
} | ||
return 'down'; | ||
} | ||
else if (raw.includes('available') || raw.includes('online') || raw.includes('resolved')) { | ||
return 'up'; | ||
} | ||
else if (raw.includes('currently investigating')) { | ||
return 'issues'; | ||
} | ||
return 'down'; | ||
}; | ||
/** | ||
* Methode used to get server zone from raw line data | ||
* | ||
* @param serverSlug ServerSlug Server slug | ||
* @return ServerZone Server zone from line data | ||
*/ | ||
var getInformationLineServerZone = function (serverSlug) { | ||
if (serverSlug.includes('eu')) { | ||
return 'eu'; | ||
} | ||
else if (serverSlug.includes('na')) { | ||
return 'na'; | ||
} | ||
return 'none'; | ||
}; | ||
/** | ||
* Methode used to get server support from raw line data | ||
* | ||
* @param serverSlug ServerSlug Server slug | ||
* @return ServerSupport Server support from line data | ||
*/ | ||
var getInformationLineServerSupport = function (serverSlug) { | ||
if (serverSlug.includes('pc')) { | ||
return 'pc'; | ||
} | ||
else if (serverSlug.includes('ps4')) { | ||
return 'ps4'; | ||
} | ||
else if (serverSlug.includes('xbox')) { | ||
return 'xbox'; | ||
} | ||
return 'none'; | ||
}; | ||
/** | ||
* Methode used to get last information foreach server/service | ||
* | ||
* @param informationBlock InformationBlock[] | ||
* @return EsoServer[] Server/service information list | ||
*/ | ||
var getLastForEachServer = function (informationBlock) { | ||
var esoServerList = []; | ||
// tslint:disable-next-line:no-shadowed-variable | ||
informationBlock.forEach(function (informationBlock) { | ||
var _a; | ||
(_a = informationBlock.information_lines) === null || _a === void 0 ? void 0 : _a.forEach(function (informationLine) { | ||
}; | ||
/** | ||
* Methode used to get server zone from raw line data | ||
* | ||
* @param serverSlug ServerSlug Server slug | ||
* @return ServerZone Server zone from line data | ||
*/ | ||
EsoStatus.getInformationLineServerZone = function (serverSlug) { | ||
if (serverSlug.includes('eu')) { | ||
return 'eu'; | ||
} | ||
else if (serverSlug.includes('na')) { | ||
return 'na'; | ||
} | ||
return 'none'; | ||
}; | ||
/** | ||
* Methode used to get server support from raw line data | ||
* | ||
* @param serverSlug ServerSlug Server slug | ||
* @return ServerSupport Server support from line data | ||
*/ | ||
EsoStatus.getInformationLineServerSupport = function (serverSlug) { | ||
if (serverSlug.includes('pc')) { | ||
return 'pc'; | ||
} | ||
else if (serverSlug.includes('ps4')) { | ||
return 'ps4'; | ||
} | ||
else if (serverSlug.includes('xbox')) { | ||
return 'xbox'; | ||
} | ||
return 'none'; | ||
}; | ||
/** | ||
* Methode used to get last information foreach server/service | ||
* | ||
* @param informationBlock InformationBlock[] | ||
* @return EsoServer[] Server/service information list | ||
*/ | ||
EsoStatus.getLastForEachServer = function (informationBlock) { | ||
var _this = this; | ||
var esoServerList = []; | ||
// tslint:disable-next-line:no-shadowed-variable | ||
informationBlock.forEach(function (informationBlock) { | ||
var _a; | ||
(_a = informationLine.serverSlug) === null || _a === void 0 ? void 0 : _a.forEach(function (serverSlug) { | ||
var _a, _b; | ||
// @ts-ignore | ||
if (esoServerList[serverSlug] === undefined) { | ||
(_a = informationBlock.information_lines) === null || _a === void 0 ? void 0 : _a.forEach(function (informationLine) { | ||
var _a; | ||
(_a = informationLine.serverSlug) === null || _a === void 0 ? void 0 : _a.forEach(function (serverSlug) { | ||
var _a, _b; | ||
// @ts-ignore | ||
esoServerList[serverSlug] = { | ||
raw_date: (_a = informationBlock.date_line) === null || _a === void 0 ? void 0 : _a.raw, | ||
raw_information: informationLine.raw, | ||
date: (_b = informationBlock.date_line) === null || _b === void 0 ? void 0 : _b.data, | ||
slug: serverSlug, | ||
support: getInformationLineServerSupport(serverSlug), | ||
zone: getInformationLineServerZone(serverSlug), | ||
status: informationLine.serverStatus, | ||
}; | ||
} | ||
if (esoServerList[serverSlug] === undefined) { | ||
// @ts-ignore | ||
esoServerList[serverSlug] = { | ||
raw_date: (_a = informationBlock.date_line) === null || _a === void 0 ? void 0 : _a.raw, | ||
raw_information: informationLine.raw, | ||
date: (_b = informationBlock.date_line) === null || _b === void 0 ? void 0 : _b.data, | ||
slug: serverSlug, | ||
support: _this.getInformationLineServerSupport(serverSlug), | ||
zone: _this.getInformationLineServerZone(serverSlug), | ||
status: informationLine.serverStatus, | ||
}; | ||
} | ||
}); | ||
}); | ||
}); | ||
}); | ||
return esoServerList; | ||
}; | ||
/** | ||
* Methode used to get readable content of the website | ||
* | ||
* @return EsoServer[] Readable content of the website | ||
*/ | ||
var getEsoStatus = function () { | ||
return new Promise(function (resolve, reject) { | ||
// Raw content of the website | ||
getWebSiteContent() | ||
.then(function (rawContent) { | ||
// Get raw list content | ||
var rawListContent = getRawListContent(rawContent); | ||
// Get all information blocks from raw list content of the website | ||
var informationBlocks = getBlocks(rawListContent); | ||
// Get all information blocks from raw list content of the website | ||
informationBlocks = getRawContentItemLines(informationBlocks); | ||
// Get data of each blocks | ||
informationBlocks = getBlocksData(informationBlocks); | ||
// Get all last information foreach servers | ||
resolve(getLastForEachServer(informationBlocks)); | ||
}) | ||
.catch(reject); | ||
}); | ||
}; | ||
/** | ||
* Methode to used to get status list ESO servers | ||
* | ||
* @type Promise<EsoServer[]> | ||
*/ | ||
exports.EsoStatus = getEsoStatus(); | ||
return esoServerList; | ||
}; | ||
/** | ||
* Methode used to get readable content of the website | ||
* | ||
* @return EsoServer[] Readable content of the website | ||
*/ | ||
EsoStatus.getEsoStatus = function (url) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
// Raw content of the website | ||
_this.getWebSiteContent(url) | ||
.then(function (rawContent) { | ||
// Get raw list content | ||
var rawListContent = _this.getRawListContent(rawContent); | ||
// Get all information blocks from raw list content of the website | ||
var informationBlocks = _this.getBlocks(rawListContent); | ||
// Get all information blocks from raw list content of the website | ||
informationBlocks = _this.getRawContentItemLines(informationBlocks); | ||
// Get data of each blocks | ||
informationBlocks = _this.getBlocksData(informationBlocks); | ||
// Get all last information foreach servers | ||
resolve(_this.getLastForEachServer(informationBlocks)); | ||
}) | ||
.catch(reject); | ||
}); | ||
}; | ||
return EsoStatus; | ||
}()); | ||
exports.EsoStatus = EsoStatus; |
{ | ||
"name": "@dov118/eso-status", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Library used to get servers status of The elders scrolls Online game", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "jest", | ||
"build": "tsc" | ||
}, | ||
"files": [ | ||
"lib/**/*" | ||
"lib/index.js", | ||
"lib/index.d.ts" | ||
], | ||
@@ -23,8 +25,10 @@ "repository": { | ||
"devDependencies": { | ||
"typescript": "^4.1.3" | ||
"@types/jest": "^26.0.20", | ||
"jest": "^26.6.3", | ||
"ts-jest": "^26.5.2", | ||
"typescript": "^4.2.2" | ||
}, | ||
"dependencies": { | ||
"@types/request": "^2.48.5", | ||
"request": "^2.88.2" | ||
"axios": "^0.21.1" | ||
} | ||
} |
@@ -22,5 +22,5 @@ # ESO-STATUS | ||
```typescript | ||
import {EsoStatus, EsoServer} from "@dov118/eso-status"; | ||
import {EsoServer, EsoStatus} from "@dov118/eso-status"; | ||
EsoStatus.then((data: EsoServer[]): void => { | ||
EsoStatus.getEsoStatus().then((data: EsoServer[]): void => { | ||
@@ -33,5 +33,5 @@ }).catch((error: Error): void => { | ||
```javascript | ||
var eso_status = require("@dov118/eso-status"); | ||
var EsoStatus = require("@dov118/eso-status"); | ||
eso_status.EsoStatus.then(function (data) { | ||
EsoStatus.getEsoStatus().then(function (data) { | ||
@@ -38,0 +38,0 @@ }).catch(function (error) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26685
1
588
4
+ Addedaxios@^0.21.1
+ Addedaxios@0.21.4(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
- Removed@types/request@^2.48.5
- Removedrequest@^2.88.2
- Removed@types/caseless@0.12.5(transitive)
- Removed@types/node@22.7.4(transitive)
- Removed@types/request@2.48.12(transitive)
- Removed@types/tough-cookie@4.0.5(transitive)
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.32.5.1(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.9.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removedundici-types@6.19.8(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)