@eso-status/live-services 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,43 +4,43 @@ import { Support, Slug, Status, Zone } from '@eso-status/types';
4
4
  */
5
5
  export default class LiveServicesElement {
6
6
  /**
7
- * Methode used to get slug of raw slug
8
- *
9
- * @public
10
- * @static
11
- *
12
- * @param rawSlug string Raw slug
13
- * @return Slug Slug
14
- */
7
+ * Methode used to get slug of raw slug
8
+ *
9
+ * @public
10
+ * @static
11
+ *
12
+ * @param rawSlug string Raw slug
13
+ * @return Slug Slug
14
+ */
15
15
  static getSlug(rawSlug: string): Slug;
16
16
  /**
17
- * Methode used to get support of slug
18
- *
19
- * @public
20
- * @static
21
- *
22
- * @param slug Slug Slug
23
- * @return Support Support of slug
24
- */
17
+ * Methode used to get support of slug
18
+ *
19
+ * @public
20
+ * @static
21
+ *
22
+ * @param slug Slug Slug
23
+ * @return Support Support of slug
24
+ */
25
25
  static getSupport(slug: Slug): Support;
26
26
  /**
27
- * Methode used to get zone of slug
28
- *
29
- * @public
30
- * @static
31
- *
32
- * @param slug Slug Slug
33
- * @return Zone Zone of slug
34
- */
27
+ * Methode used to get zone of slug
28
+ *
29
+ * @public
30
+ * @static
31
+ *
32
+ * @param slug Slug Slug
33
+ * @return Zone Zone of slug
34
+ */
35
35
  static getZone(slug: Slug): Zone;
36
36
  /**
37
- * Methode used to get status of raw status
38
- *
39
- * @public
40
- * @static
41
- *
42
- * @param rawStatus string Raw status
43
- * @return Status Status of raw data
44
- */
37
+ * Methode used to get status of raw status
38
+ *
39
+ * @public
40
+ * @static
41
+ *
42
+ * @param rawStatus string Raw status
43
+ * @return Status Status of raw data
44
+ */
45
45
  static getStatus(rawStatus: string): Status;
46
46
  }
@@ -3,19 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /**
4
4
  * Class with methode for LiveServices element
5
5
  */
6
- var LiveServicesElement = /** @class */ (function () {
7
- function LiveServicesElement() {
8
- }
6
+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class -- the published 1.x API exposes static methods, called as is by @eso-status/api 1.x
7
+ class LiveServicesElement {
9
8
  /**
10
- * Methode used to get slug of raw slug
11
- *
12
- * @public
13
- * @static
14
- *
15
- * @param rawSlug string Raw slug
16
- * @return Slug Slug
17
- */
18
- LiveServicesElement.getSlug = function (rawSlug) {
9
+ * Methode used to get slug of raw slug
10
+ *
11
+ * @public
12
+ * @static
13
+ *
14
+ * @param rawSlug string Raw slug
15
+ * @return Slug Slug
16
+ */
17
+ static getSlug(rawSlug) {
19
18
  switch (rawSlug) {
20
19
  case 'The Elder Scrolls Online (NA)':
21
20
  return 'server_pc_na';
@@ -34,41 +33,41 @@ var LiveServicesElement = /** @class */ (function () {
34
33
  default:
35
34
  return 'undefined';
36
35
  }
37
- };
36
+ }
38
37
  /**
39
- * Methode used to get support of slug
40
- *
41
- * @public
42
- * @static
43
- *
44
- * @param slug Slug Slug
45
- * @return Support Support of slug
46
- */
47
- LiveServicesElement.getSupport = function (slug) {
38
+ * Methode used to get support of slug
39
+ *
40
+ * @public
41
+ * @static
42
+ *
43
+ * @param slug Slug Slug
44
+ * @return Support Support of slug
45
+ */
46
+ static getSupport(slug) {
48
47
  return slug.split('_')[1];
49
- };
48
+ }
50
49
  /**
51
- * Methode used to get zone of slug
52
- *
53
- * @public
54
- * @static
55
- *
56
- * @param slug Slug Slug
57
- * @return Zone Zone of slug
58
- */
59
- LiveServicesElement.getZone = function (slug) {
50
+ * Methode used to get zone of slug
51
+ *
52
+ * @public
53
+ * @static
54
+ *
55
+ * @param slug Slug Slug
56
+ * @return Zone Zone of slug
57
+ */
58
+ static getZone(slug) {
60
59
  return slug.split('_')[2];
61
- };
60
+ }
62
61
  /**
63
- * Methode used to get status of raw status
64
- *
65
- * @public
66
- * @static
67
- *
68
- * @param rawStatus string Raw status
69
- * @return Status Status of raw data
70
- */
71
- LiveServicesElement.getStatus = function (rawStatus) {
62
+ * Methode used to get status of raw status
63
+ *
64
+ * @public
65
+ * @static
66
+ *
67
+ * @param rawStatus string Raw status
68
+ * @return Status Status of raw data
69
+ */
70
+ static getStatus(rawStatus) {
72
71
  switch (rawStatus) {
73
72
  case 'UP':
74
73
  return 'up';
@@ -77,7 +76,6 @@ var LiveServicesElement = /** @class */ (function () {
77
76
  default:
78
77
  return 'undefined';
79
78
  }
80
- };
81
- return LiveServicesElement;
82
- }());
79
+ }
80
+ }
83
81
  exports.default = LiveServicesElement;
@@ -11,7 +11,7 @@ export default class LiveServicesConnector {
11
11
  *
12
12
  * @return string URL to get remote content
13
13
  */
14
- static url: string;
14
+ static readonly url = "https://live-services.elderscrollsonline.com/status/realms";
15
15
  /**
16
16
  * Methode used to get raw content of the remote website
17
17
  *
@@ -1,49 +1,15 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
- var LiveServicesElement_1 = require("../classes/LiveServicesElement");
40
- var axios = require('axios');
6
+ const axios_1 = __importDefault(require("axios"));
7
+ const LiveServicesElement_1 = __importDefault(require("../classes/LiveServicesElement"));
41
8
  /**
42
9
  * Connector used to get data from https://live-services.elderscrollsonline.com/status/realms
43
10
  */
44
- var LiveServicesConnector = /** @class */ (function () {
45
- function LiveServicesConnector() {
46
- }
11
+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class -- the published 1.x API exposes static methods, called as is by @eso-status/api 1.x
12
+ class LiveServicesConnector {
47
13
  /**
48
14
  * Methode used to get raw content of the remote website
49
15
  *
@@ -52,28 +18,18 @@ var LiveServicesConnector = /** @class */ (function () {
52
18
  *
53
19
  * @return Promise<string> Raw content of the remote website
54
20
  */
55
- LiveServicesConnector.getRemoteContent = function () {
56
- return __awaiter(this, void 0, void 0, function () {
57
- var response;
58
- return __generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0: return [4 /*yield*/, axios.get(LiveServicesConnector.url)];
61
- case 1:
62
- response = _a.sent();
63
- if ((response === null || response === void 0 ? void 0 : response.status) !== 200) {
64
- throw new Error("Bad response ".concat(response === null || response === void 0 ? void 0 : response.status, " (").concat(response === null || response === void 0 ? void 0 : response.data, ")"));
65
- }
66
- else if (!(response === null || response === void 0 ? void 0 : response.data)) {
67
- throw new Error("Empty response ".concat(response === null || response === void 0 ? void 0 : response.status, " (").concat(response === null || response === void 0 ? void 0 : response.data, ")"));
68
- }
69
- else {
70
- return [2 /*return*/, JSON.stringify(response === null || response === void 0 ? void 0 : response.data)];
71
- }
72
- return [2 /*return*/];
73
- }
74
- });
75
- });
76
- };
21
+ static async getRemoteContent() {
22
+ const response = await axios_1.default.get(LiveServicesConnector.url);
23
+ if (response.status !== 200) {
24
+ throw new Error(`Bad response ${String(response.status)} (${response.data})`);
25
+ }
26
+ else if (!response.data) {
27
+ throw new Error(`Empty response ${String(response.status)} (${response.data})`);
28
+ }
29
+ else {
30
+ return JSON.stringify(response.data);
31
+ }
32
+ }
77
33
  /**
78
34
  * Methode used to select raw content containing eso servers status information
79
35
  *
@@ -83,10 +39,9 @@ var LiveServicesConnector = /** @class */ (function () {
83
39
  * @param remoteContent Raw content of the remote website
84
40
  * @return string Raw content containing eso servers status information
85
41
  */
86
- LiveServicesConnector.getFilterContent = function (remoteContent) {
87
- var _a, _b;
88
- return JSON.stringify((_b = (_a = JSON.parse(remoteContent)) === null || _a === void 0 ? void 0 : _a.zos_platform_response) === null || _b === void 0 ? void 0 : _b.response);
89
- };
42
+ static getFilterContent(remoteContent) {
43
+ return JSON.stringify(JSON.parse(remoteContent).zos_platform_response?.response);
44
+ }
90
45
  /**
91
46
  * Methode used to get list of each raw information
92
47
  *
@@ -96,14 +51,14 @@ var LiveServicesConnector = /** @class */ (function () {
96
51
  * @param filteredContent string Raw content containing eso servers status information
97
52
  * @return RawEsoStatus[] List of each information
98
53
  */
99
- LiveServicesConnector.changeFilterContentForList = function (filteredContent) {
100
- return Object.entries(JSON.parse(filteredContent)).map(function (item) { return ({
54
+ static changeFilterContentForList(filteredContent) {
55
+ return Object.entries(JSON.parse(filteredContent)).map((item) => ({
101
56
  sources: [LiveServicesConnector.url],
102
57
  raw: [item[0], String(item[1])],
103
58
  rawSlug: item[0],
104
59
  rawStatus: String(item[1]),
105
- }); });
106
- };
60
+ }));
61
+ }
107
62
  /**
108
63
  * Methode used to get last eso status server with data
109
64
  *
@@ -113,26 +68,24 @@ var LiveServicesConnector = /** @class */ (function () {
113
68
  * @param lastRawData ServiceAlertsInterface[] Raw eso server status list sorted by date
114
69
  * @return RawEsoStatus[] Last eso status server with data
115
70
  */
116
- LiveServicesConnector.getData = function (lastRawData) {
117
- return lastRawData.map(function (item) {
118
- var _a, _b;
119
- var newItem = item;
120
- newItem.slugs = [LiveServicesElement_1.default.getSlug((_a = newItem.rawSlug) !== null && _a !== void 0 ? _a : '')];
71
+ static getData(lastRawData) {
72
+ return lastRawData.map((item) => {
73
+ const newItem = item;
74
+ newItem.slugs = [LiveServicesElement_1.default.getSlug(newItem.rawSlug ?? '')];
121
75
  newItem.support = LiveServicesElement_1.default.getSupport(newItem.slugs[0]);
122
76
  newItem.zone = LiveServicesElement_1.default.getZone(newItem.slugs[0]);
123
- newItem.status = LiveServicesElement_1.default.getStatus((_b = newItem.rawStatus) !== null && _b !== void 0 ? _b : '');
77
+ newItem.status = LiveServicesElement_1.default.getStatus(newItem.rawStatus ?? '');
124
78
  return newItem;
125
79
  });
126
- };
127
- /**
128
- * URL to get remote content
129
- *
130
- * @public
131
- * @static
132
- *
133
- * @return string URL to get remote content
134
- */
135
- LiveServicesConnector.url = 'https://live-services.elderscrollsonline.com/status/realms';
136
- return LiveServicesConnector;
137
- }());
80
+ }
81
+ }
82
+ /**
83
+ * URL to get remote content
84
+ *
85
+ * @public
86
+ * @static
87
+ *
88
+ * @return string URL to get remote content
89
+ */
90
+ LiveServicesConnector.url = 'https://live-services.elderscrollsonline.com/status/realms';
138
91
  exports.default = LiveServicesConnector;
package/lib/index.d.ts CHANGED
@@ -4,12 +4,12 @@ import { RawEsoStatus } from '@eso-status/types';
4
4
  */
5
5
  export declare class LiveServices {
6
6
  /**
7
- * Methode used to get Live Services data
8
- *
9
- * @public
10
- * @static
11
- *
12
- * @return Promise<RawEsoStatus[]> Live Services elements
13
- */
7
+ * Methode used to get Live Services data
8
+ *
9
+ * @public
10
+ * @static
11
+ *
12
+ * @return Promise<RawEsoStatus[]> Live Services elements
13
+ */
14
14
  static getData(): Promise<RawEsoStatus[]>;
15
15
  }
package/lib/index.js CHANGED
@@ -1,72 +1,28 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
6
  exports.LiveServices = void 0;
40
- var LiveServicesConnector_1 = require("./connectors/LiveServicesConnector");
7
+ const LiveServicesConnector_1 = __importDefault(require("./connectors/LiveServicesConnector"));
41
8
  /**
42
9
  * Class of Live Services
43
10
  */
44
- var LiveServices = /** @class */ (function () {
45
- function LiveServices() {
46
- }
11
+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class -- the published 1.x API exposes static methods, called as is by @eso-status/api 1.x
12
+ class LiveServices {
47
13
  /**
48
- * Methode used to get Live Services data
49
- *
50
- * @public
51
- * @static
52
- *
53
- * @return Promise<RawEsoStatus[]> Live Services elements
54
- */
55
- LiveServices.getData = function () {
56
- return __awaiter(this, void 0, void 0, function () {
57
- var remoteContent, filteredContent, lastRawData;
58
- return __generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0: return [4 /*yield*/, LiveServicesConnector_1.default.getRemoteContent()];
61
- case 1:
62
- remoteContent = _a.sent();
63
- filteredContent = LiveServicesConnector_1.default.getFilterContent(remoteContent);
64
- lastRawData = LiveServicesConnector_1.default.changeFilterContentForList(filteredContent);
65
- return [2 /*return*/, LiveServicesConnector_1.default.getData(lastRawData)];
66
- }
67
- });
68
- });
69
- };
70
- return LiveServices;
71
- }());
14
+ * Methode used to get Live Services data
15
+ *
16
+ * @public
17
+ * @static
18
+ *
19
+ * @return Promise<RawEsoStatus[]> Live Services elements
20
+ */
21
+ static async getData() {
22
+ const remoteContent = await LiveServicesConnector_1.default.getRemoteContent();
23
+ const filteredContent = LiveServicesConnector_1.default.getFilterContent(remoteContent);
24
+ const lastRawData = LiveServicesConnector_1.default.changeFilterContentForList(filteredContent);
25
+ return LiveServicesConnector_1.default.getData(lastRawData);
26
+ }
27
+ }
72
28
  exports.LiveServices = LiveServices;
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@eso-status/live-services",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Library used to get servers status of The elders scrolls Online game with https://live-services.elderscrollsonline.com/status/realms",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
7
+ "format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
8
+ "lint": "eslint \"{src,tests}/**/*.ts\"",
9
+ "lint:fix": "eslint \"{src,tests}/**/*.ts\" --fix",
7
10
  "post-install": "cp pre-commit .git/hooks/ && chmod +x .git/hooks/pre-commit && echo 'hook copied'",
8
- "lint": "eslint tests src --ext .ts",
9
- "lint:fix": "eslint tests src --ext .ts --fix",
10
11
  "build": "rm -R -f lib/* && tsc",
11
12
  "test": "jest",
12
13
  "start": "node .",
@@ -31,7 +32,7 @@
31
32
  },
32
33
  "repository": {
33
34
  "type": "git",
34
- "url": "git@github.com:eso-status/live-services.git"
35
+ "url": "git+https://github.com/eso-status/live-services.git"
35
36
  },
36
37
  "author": "@dov118 <contact@dov118.dev> (https://dov118.dev)",
37
38
  "license": "MIT",
@@ -40,22 +41,28 @@
40
41
  },
41
42
  "homepage": "https://github.com/eso-status/live-services#readme",
42
43
  "devDependencies": {
43
- "@eso-status/types": "1.0.7",
44
- "@types/jest": "29.5.12",
45
- "@types/node": "22.5.1",
46
- "@typescript-eslint/eslint-plugin": "7.18.0",
47
- "@typescript-eslint/parser": "7.18.0",
48
- "@typescript-eslint/typescript-estree": "7.18.0",
49
- "eslint": "8.57.0",
50
- "eslint-config-airbnb-base": "15.0.0",
51
- "eslint-plugin-import": "2.29.1",
52
- "eslint-plugin-jest": "28.8.0",
53
- "jest": "29.7.0",
54
- "nodemon": "3.1.4",
55
- "ts-jest": "29.2.5",
56
- "typescript": "5.5.4"
44
+ "@eslint/js": "10.0.1",
45
+ "@eso-status/types": "1.0.9",
46
+ "@types/jest": "30.0.0",
47
+ "@types/node": "26.6.6",
48
+ "eslint": "10.15.0",
49
+ "eslint-config-prettier": "10.1.8",
50
+ "eslint-plugin-jest": "29.17.0",
51
+ "eslint-plugin-sonarjs": "4.2.2",
52
+ "eslint-plugin-unused-imports": "4.4.1",
53
+ "globals": "17.14.0",
54
+ "jest": "30.5.2",
55
+ "nodemon": "3.1.14",
56
+ "prettier": "3.10.1",
57
+ "ts-jest": "29.4.15",
58
+ "typescript": "6.0.3",
59
+ "typescript-eslint": "8.72.2"
57
60
  },
58
61
  "dependencies": {
59
- "axios": "1.7.5"
62
+ "axios": "1.21.1"
63
+ },
64
+ "overrides": {
65
+ "minimatch@>=7.0.0 <11.0.1": "11.0.1",
66
+ "glob@>=9.0.0 <=14.0.1": "14.0.2"
60
67
  }
61
68
  }