@eso-status/live-services 1.0.7 → 2.0.0-dev.0

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.
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 dov118
3
+ Copyright (c) 2024 dov118
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,119 +1,119 @@
1
1
  # eso-status/live-services
2
+
3
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=eso-status_live-services&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=eso-status_live-services)
4
+ [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=eso-status_live-services&metric=bugs)](https://sonarcloud.io/summary/new_code?id=eso-status_live-services)
5
+ [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=eso-status_live-services&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=eso-status_live-services)
6
+ [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=eso-status_live-services&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=eso-status_live-services)
7
+ [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=eso-status_live-services&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=eso-status_live-services)
8
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=eso-status_live-services&metric=coverage)](https://sonarcloud.io/summary/new_code?id=eso-status_live-services)
9
+ [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=eso-status_live-services&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=eso-status_live-services)
10
+
2
11
  [![npm](https://img.shields.io/npm/v/@eso-status/live-services)](https://www.npmjs.com/package/@eso-status/live-services)
3
12
  [![license](https://img.shields.io/npm/l/@eso-status/live-services)](https://github.com/eso-status/live-services/blob/master/LICENSE.md)
4
13
  <img src="https://img.shields.io/npm/dt/@eso-status/live-services" alt="Downloads" />
5
- [![LGTM Grade](https://img.shields.io/lgtm/grade/javascript/github/eso-status/live-services)](https://lgtm.com/projects/g/eso-status/live-services/context:javascript)
6
14
  <img src="https://img.shields.io/node/v/@eso-status/live-services" alt="Node version" />
15
+
7
16
  [![Build Status](https://github.com/eso-status/live-services/workflows/CI/badge.svg)](https://github.com/eso-status/live-services/actions/workflows/CI.yaml)
8
- [![Delivery Status](https://github.com/eso-status/live-services/workflows/CD/badge.svg)](https://github.com/eso-status/live-services/actions/workflows/CD.yaml)
17
+ [![Build Status](https://github.com/eso-status/live-services/workflows/CD/badge.svg)](https://github.com/eso-status/live-services/actions/workflows/CD.yaml)
9
18
 
10
- eso-status/live-services is a library for getting and formatting data can founded in [https://live-services.elderscrollsonline.com/status/realms](https://live-services.elderscrollsonline.com/status/realms)
19
+ eso-status/live-services is a library for retrieving and formatting data, which can be found at [https://live-services.elderscrollsonline.com/status/realms](https://live-services.elderscrollsonline.com/status/realms).
11
20
 
12
21
  ## Table of Contents
13
- - [How to get it ?](#how-to-get-it-)
14
- - [How to use it ?](#how-to-use-it-)
15
- - [Returned data format](#returned-data-format-)
22
+ - [Install](#install)
23
+ - [Usage](#usage)
24
+ - [Return exemple](#return-exemple)
16
25
 
17
- ### How to get it ?
26
+ ### Install
18
27
  ```shell
19
28
  npm i @eso-status/live-services
20
29
  ```
21
30
 
22
- ### How to use it ?
23
- - TypeScript
24
- ```typescript
25
- import { RawEsoStatus } from '@eso-status/types';
26
- import { LiveServices } from "@eso-status/live-services";
27
-
28
- LiveServices.getData().then((data: RawEsoStatus[]): void => {
29
-
30
- }).catch((error: Error): void => {
31
-
32
- });
33
- ```
34
- - JavaScript
31
+ ### Usage
35
32
  ```javascript
36
- const { LiveServices } = require('@eso-status/live-services');
33
+ import LiveServices from '@eso-status/live-services';
34
+ import { EsoStatusRawData } from '@eso-status/types';
37
35
 
38
- LiveServices.getData().then(function (data) {
39
-
40
- }).catch(function (error) {
41
-
42
- });
36
+ const esoStatusRawDataList: EsoStatusRawData[] = await LiveServices.getData();
43
37
  ```
44
-
45
- ### Returned data format ?
38
+ ### Return exemple
46
39
  ```text
47
40
  [
48
41
  {
49
- sources: [ 'https://live-services.elderscrollsonline.com/status/realms' ],
50
- raw: [ 'The Elder Scrolls Online (EU)', 'UP' ],
51
- rawSlug: 'The Elder Scrolls Online (EU)',
52
- rawStatus: 'UP',
53
- slugs: [ 'server_pc_eu' ],
42
+ source: 'https://live-services.elderscrollsonline.com/status/realms',
43
+ raw: '"The Elder Scrolls Online (EU)":"UP"',
44
+ slug: 'server_pc_eu',
45
+ type: 'server',
54
46
  support: 'pc',
55
47
  zone: 'eu',
56
- status: 'up'
48
+ status: 'up',
49
+ rawSlug: 'The Elder Scrolls Online (EU)',
50
+ rawStatus: 'UP'
57
51
  },
58
52
  {
59
- sources: [ 'https://live-services.elderscrollsonline.com/status/realms' ],
60
- raw: [ 'The Elder Scrolls Online (NA)', 'UP' ],
61
- rawSlug: 'The Elder Scrolls Online (NA)',
62
- rawStatus: 'UP',
63
- slugs: [ 'server_pc_na' ],
53
+ source: 'https://live-services.elderscrollsonline.com/status/realms',
54
+ raw: '"The Elder Scrolls Online (NA)":"UP"',
55
+ slug: 'server_pc_na',
56
+ type: 'server',
64
57
  support: 'pc',
65
58
  zone: 'na',
66
- status: 'up'
59
+ status: 'up',
60
+ rawSlug: 'The Elder Scrolls Online (NA)',
61
+ rawStatus: 'UP'
67
62
  },
68
63
  {
69
- sources: [ 'https://live-services.elderscrollsonline.com/status/realms' ],
70
- raw: [ 'The Elder Scrolls Online (PS4 - EU)', 'UP' ],
71
- rawSlug: 'The Elder Scrolls Online (PS4 - EU)',
72
- rawStatus: 'UP',
73
- slugs: [ 'server_ps_eu' ],
64
+ source: 'https://live-services.elderscrollsonline.com/status/realms',
65
+ raw: '"The Elder Scrolls Online (PS4 - EU)":"UP"',
66
+ slug: 'server_ps_eu',
67
+ type: 'server',
74
68
  support: 'ps',
75
69
  zone: 'eu',
76
- status: 'up'
70
+ status: 'up',
71
+ rawSlug: 'The Elder Scrolls Online (PS4 - EU)',
72
+ rawStatus: 'UP'
77
73
  },
78
74
  {
79
- sources: [ 'https://live-services.elderscrollsonline.com/status/realms' ],
80
- raw: [ 'The Elder Scrolls Online (PS4 - US)', 'UP' ],
81
- rawSlug: 'The Elder Scrolls Online (PS4 - US)',
82
- rawStatus: 'UP',
83
- slugs: [ 'server_ps_na' ],
75
+ source: 'https://live-services.elderscrollsonline.com/status/realms',
76
+ raw: '"The Elder Scrolls Online (PS4 - US)":"UP"',
77
+ slug: 'server_ps_na',
78
+ type: 'server',
84
79
  support: 'ps',
85
80
  zone: 'na',
86
- status: 'up'
81
+ status: 'up',
82
+ rawSlug: 'The Elder Scrolls Online (PS4 - US)',
83
+ rawStatus: 'UP'
87
84
  },
88
85
  {
89
- sources: [ 'https://live-services.elderscrollsonline.com/status/realms' ],
90
- raw: [ 'The Elder Scrolls Online (PTS)', 'UP' ],
91
- rawSlug: 'The Elder Scrolls Online (PTS)',
92
- rawStatus: 'UP',
93
- slugs: [ 'server_pc_pts' ],
86
+ source: 'https://live-services.elderscrollsonline.com/status/realms',
87
+ raw: '"The Elder Scrolls Online (PTS)":"UP"',
88
+ slug: 'server_pc_pts',
89
+ type: 'server',
94
90
  support: 'pc',
95
91
  zone: 'pts',
96
- status: 'up'
92
+ status: 'up',
93
+ rawSlug: 'The Elder Scrolls Online (PTS)',
94
+ rawStatus: 'UP'
97
95
  },
98
96
  {
99
- sources: [ 'https://live-services.elderscrollsonline.com/status/realms' ],
100
- raw: [ 'The Elder Scrolls Online (XBox - EU)', 'UP' ],
101
- rawSlug: 'The Elder Scrolls Online (XBox - EU)',
102
- rawStatus: 'UP',
103
- slugs: [ 'server_xbox_eu' ],
97
+ source: 'https://live-services.elderscrollsonline.com/status/realms',
98
+ raw: '"The Elder Scrolls Online (XBox - EU)":"UP"',
99
+ slug: 'server_xbox_eu',
100
+ type: 'server',
104
101
  support: 'xbox',
105
102
  zone: 'eu',
106
- status: 'up'
103
+ status: 'up',
104
+ rawSlug: 'The Elder Scrolls Online (XBox - EU)',
105
+ rawStatus: 'UP'
107
106
  },
108
107
  {
109
- sources: [ 'https://live-services.elderscrollsonline.com/status/realms' ],
110
- raw: [ 'The Elder Scrolls Online (XBox - US)', 'UP' ],
111
- rawSlug: 'The Elder Scrolls Online (XBox - US)',
112
- rawStatus: 'UP',
113
- slugs: [ 'server_xbox_na' ],
108
+ source: 'https://live-services.elderscrollsonline.com/status/realms',
109
+ raw: '"The Elder Scrolls Online (XBox - US)":"UP"',
110
+ slug: 'server_xbox_na',
111
+ type: 'server',
114
112
  support: 'xbox',
115
113
  zone: 'na',
116
- status: 'up'
114
+ status: 'up',
115
+ rawSlug: 'The Elder Scrolls Online (XBox - US)',
116
+ rawStatus: 'UP'
117
117
  }
118
118
  ]
119
119
  ```
package/lib/index.js CHANGED
@@ -1,72 +1,37 @@
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
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.LiveServices = void 0;
40
- var LiveServicesConnector_1 = require("./connectors/LiveServicesConnector");
3
+ const types_1 = require("@eso-status/types");
4
+ const const_1 = require("./const");
5
+ const connector_1 = require("./connector");
41
6
  /**
42
- * Class of Live Services
7
+ * Class for retrieving announcement information
43
8
  */
44
- var LiveServices = /** @class */ (function () {
45
- function LiveServices() {
46
- }
9
+ class LiveServices {
47
10
  /**
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
- }
11
+ * Method for retrieving announcement information
12
+ */
13
+ static async getData() {
14
+ const remoteContent = await connector_1.default.getRemoteContent();
15
+ const returnList = [];
16
+ if (!remoteContent) {
17
+ return [];
18
+ }
19
+ const json = JSON.parse(remoteContent);
20
+ const_1.rawSupportZoneAssociations.forEach((raw) => {
21
+ returnList.push({
22
+ source: const_1.LiveServicesURL,
23
+ raw: `"${raw.raw}":"${json.zos_platform_response.response[raw.raw]}"`,
24
+ slug: `${types_1.ServerType}_${raw.support}_${raw.zone}`,
25
+ type: types_1.ServerType,
26
+ support: raw.support,
27
+ zone: raw.zone,
28
+ status: (json.zos_platform_response.response[raw.raw]?.toLowerCase()),
29
+ rawSlug: raw.raw,
30
+ rawStatus: json.zos_platform_response.response[raw.raw],
67
31
  });
68
32
  });
69
- };
70
- return LiveServices;
71
- }());
72
- exports.LiveServices = LiveServices;
33
+ return returnList;
34
+ }
35
+ }
36
+ exports.default = LiveServices;
37
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,61 +1,81 @@
1
1
  {
2
2
  "name": "@eso-status/live-services",
3
- "version": "1.0.7",
4
- "description": "Library used to get servers status of The elders scrolls Online game with https://live-services.elderscrollsonline.com/status/realms",
3
+ "version": "2.0.0-dev.0",
4
+ "description": "Library for retrieving and formatting data, which can be found at https://live-services.elderscrollsonline.com/status/realms",
5
+ "author": "@dov118 <contact@dov118.dev> (https://dov118.dev)",
5
6
  "main": "lib/index.js",
6
- "scripts": {
7
- "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
- "build": "rm -R -f lib/* && tsc",
11
- "test": "jest",
12
- "start": "node .",
13
- "dev": "npm run lint && npm run build && npm run start",
14
- "watch": "nodemon --exec npm run dev"
15
- },
16
- "files": [
17
- "lib/classes/LiveServicesElement.d.ts",
18
- "lib/classes/LiveServicesElement.js",
19
- "lib/connectors/LiveServicesConnector.d.ts",
20
- "lib/connectors/LiveServicesConnector.js",
21
- "lib/index.d.ts",
22
- "lib/index.js",
23
- ".npmrc",
24
- "LICENSE.md",
25
- "package.json",
26
- "README.md"
27
- ],
7
+ "license": "MIT",
28
8
  "engineStrict": true,
9
+ "files": [],
29
10
  "engines": {
30
- "node": ">=18.18.0 || >=20.0.0"
11
+ "node": "^18.18.0 || ^20.0.0"
31
12
  },
13
+ "bugs": {
14
+ "url": "https://github.com/eso-status/live-services/issues"
15
+ },
16
+ "homepage": "https://github.com/eso-status/live-services#readme",
32
17
  "repository": {
33
18
  "type": "git",
34
19
  "url": "git@github.com:eso-status/live-services.git"
35
20
  },
36
- "author": "@dov118 <contact@dov118.dev> (https://dov118.dev)",
37
- "license": "MIT",
38
- "bugs": {
39
- "url": "https://github.com/eso-status/live-services/issues"
21
+ "scripts": {
22
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
23
+ "lint": "eslint \"{src,test}/**/*.ts\"",
24
+ "lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
25
+ "build": "rm -R -f lib/* && tsc --project tsconfig.build.json",
26
+ "dev": "npm run build && node .",
27
+ "watch": "nodemon --exec npm run dev",
28
+ "test": "npm run build && jest --runInBand --setupFiles",
29
+ "test:watch": "jest --runInBand --watch --setupFiles",
30
+ "test:cov": "jest --runInBand --coverage --setupFiles",
31
+ "prepare": "husky"
32
+ },
33
+ "dependencies": {
34
+ "@eso-status/types": "2.0.0-dev.12",
35
+ "axios": "1.7.7"
40
36
  },
41
- "homepage": "https://github.com/eso-status/live-services#readme",
42
37
  "devDependencies": {
43
- "@eso-status/types": "1.0.7",
44
38
  "@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
39
  "eslint": "8.57.0",
50
40
  "eslint-config-airbnb-base": "15.0.0",
51
- "eslint-plugin-import": "2.29.1",
52
- "eslint-plugin-jest": "28.8.0",
41
+ "eslint-config-airbnb-typescript": "18.0.0",
42
+ "eslint-config-prettier": "9.1.0",
43
+ "eslint-plugin-jest": "28.8.3",
44
+ "eslint-plugin-prettier": "5.2.1",
45
+ "eslint-plugin-sonarjs": "2.0.2",
46
+ "eslint-plugin-unused-imports": "4.1.3",
47
+ "husky": "9.1.5",
53
48
  "jest": "29.7.0",
54
49
  "nodemon": "3.1.4",
50
+ "prettier": "3.3.3",
55
51
  "ts-jest": "29.2.5",
56
52
  "typescript": "5.5.4"
57
53
  },
58
- "dependencies": {
59
- "axios": "1.7.5"
54
+ "jest": {
55
+ "moduleFileExtensions": [
56
+ "js",
57
+ "json",
58
+ "ts"
59
+ ],
60
+ "rootDir": "./",
61
+ "testRegex": ".*\\.e2e-spec\\.ts|.*\\.spec\\.ts$",
62
+ "transform": {
63
+ "^.+\\.ts$": "ts-jest"
64
+ },
65
+ "collectCoverageFrom": [
66
+ "src/**/*.ts"
67
+ ],
68
+ "coverageDirectory": "./coverage",
69
+ "testEnvironment": "node",
70
+ "setupFiles": [
71
+ "dotenv/config"
72
+ ],
73
+ "moduleDirectories": [
74
+ "node_modules",
75
+ "src"
76
+ ],
77
+ "modulePaths": [
78
+ "<rootDir>"
79
+ ]
60
80
  }
61
81
  }
@@ -1,46 +0,0 @@
1
- import { Support, Slug, Status, Zone } from '@eso-status/types';
2
- /**
3
- * Class with methode for LiveServices element
4
- */
5
- export default class LiveServicesElement {
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
- */
15
- static getSlug(rawSlug: string): Slug;
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
- */
25
- static getSupport(slug: Slug): Support;
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
- */
35
- static getZone(slug: Slug): Zone;
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
- */
45
- static getStatus(rawStatus: string): Status;
46
- }
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Class with methode for LiveServices element
5
- */
6
- var LiveServicesElement = /** @class */ (function () {
7
- function LiveServicesElement() {
8
- }
9
- /**
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) {
19
- switch (rawSlug) {
20
- case 'The Elder Scrolls Online (NA)':
21
- return 'server_pc_na';
22
- case 'The Elder Scrolls Online (EU)':
23
- return 'server_pc_eu';
24
- case 'The Elder Scrolls Online (XBox - US)':
25
- return 'server_xbox_na';
26
- case 'The Elder Scrolls Online (XBox - EU)':
27
- return 'server_xbox_eu';
28
- case 'The Elder Scrolls Online (PS4 - US)':
29
- return 'server_ps_na';
30
- case 'The Elder Scrolls Online (PS4 - EU)':
31
- return 'server_ps_eu';
32
- case 'The Elder Scrolls Online (PTS)':
33
- return 'server_pc_pts';
34
- default:
35
- return 'undefined';
36
- }
37
- };
38
- /**
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) {
48
- return slug.split('_')[1];
49
- };
50
- /**
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) {
60
- return slug.split('_')[2];
61
- };
62
- /**
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) {
72
- switch (rawStatus) {
73
- case 'UP':
74
- return 'up';
75
- case 'DOWN':
76
- return 'down';
77
- default:
78
- return 'undefined';
79
- }
80
- };
81
- return LiveServicesElement;
82
- }());
83
- exports.default = LiveServicesElement;
@@ -1,54 +0,0 @@
1
- import { RawEsoStatus } from '@eso-status/types';
2
- /**
3
- * Connector used to get data from https://live-services.elderscrollsonline.com/status/realms
4
- */
5
- export default class LiveServicesConnector {
6
- /**
7
- * URL to get remote content
8
- *
9
- * @public
10
- * @static
11
- *
12
- * @return string URL to get remote content
13
- */
14
- static url: string;
15
- /**
16
- * Methode used to get raw content of the remote website
17
- *
18
- * @public
19
- * @static
20
- *
21
- * @return Promise<string> Raw content of the remote website
22
- */
23
- static getRemoteContent(): Promise<string>;
24
- /**
25
- * Methode used to select raw content containing eso servers status information
26
- *
27
- * @public
28
- * @static
29
- *
30
- * @param remoteContent Raw content of the remote website
31
- * @return string Raw content containing eso servers status information
32
- */
33
- static getFilterContent(remoteContent: string): string;
34
- /**
35
- * Methode used to get list of each raw information
36
- *
37
- * @public
38
- * @static
39
- *
40
- * @param filteredContent string Raw content containing eso servers status information
41
- * @return RawEsoStatus[] List of each information
42
- */
43
- static changeFilterContentForList(filteredContent: string): RawEsoStatus[];
44
- /**
45
- * Methode used to get last eso status server with data
46
- *
47
- * @public
48
- * @static
49
- *
50
- * @param lastRawData ServiceAlertsInterface[] Raw eso server status list sorted by date
51
- * @return RawEsoStatus[] Last eso status server with data
52
- */
53
- static getData(lastRawData: RawEsoStatus[]): RawEsoStatus[];
54
- }
@@ -1,138 +0,0 @@
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
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var LiveServicesElement_1 = require("../classes/LiveServicesElement");
40
- var axios = require('axios');
41
- /**
42
- * Connector used to get data from https://live-services.elderscrollsonline.com/status/realms
43
- */
44
- var LiveServicesConnector = /** @class */ (function () {
45
- function LiveServicesConnector() {
46
- }
47
- /**
48
- * Methode used to get raw content of the remote website
49
- *
50
- * @public
51
- * @static
52
- *
53
- * @return Promise<string> Raw content of the remote website
54
- */
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
- };
77
- /**
78
- * Methode used to select raw content containing eso servers status information
79
- *
80
- * @public
81
- * @static
82
- *
83
- * @param remoteContent Raw content of the remote website
84
- * @return string Raw content containing eso servers status information
85
- */
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
- };
90
- /**
91
- * Methode used to get list of each raw information
92
- *
93
- * @public
94
- * @static
95
- *
96
- * @param filteredContent string Raw content containing eso servers status information
97
- * @return RawEsoStatus[] List of each information
98
- */
99
- LiveServicesConnector.changeFilterContentForList = function (filteredContent) {
100
- return Object.entries(JSON.parse(filteredContent)).map(function (item) { return ({
101
- sources: [LiveServicesConnector.url],
102
- raw: [item[0], String(item[1])],
103
- rawSlug: item[0],
104
- rawStatus: String(item[1]),
105
- }); });
106
- };
107
- /**
108
- * Methode used to get last eso status server with data
109
- *
110
- * @public
111
- * @static
112
- *
113
- * @param lastRawData ServiceAlertsInterface[] Raw eso server status list sorted by date
114
- * @return RawEsoStatus[] Last eso status server with data
115
- */
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 : '')];
121
- newItem.support = LiveServicesElement_1.default.getSupport(newItem.slugs[0]);
122
- newItem.zone = LiveServicesElement_1.default.getZone(newItem.slugs[0]);
123
- newItem.status = LiveServicesElement_1.default.getStatus((_b = newItem.rawStatus) !== null && _b !== void 0 ? _b : '');
124
- return newItem;
125
- });
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
- }());
138
- exports.default = LiveServicesConnector;
package/lib/index.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import { RawEsoStatus } from '@eso-status/types';
2
- /**
3
- * Class of Live Services
4
- */
5
- export declare class LiveServices {
6
- /**
7
- * Methode used to get Live Services data
8
- *
9
- * @public
10
- * @static
11
- *
12
- * @return Promise<RawEsoStatus[]> Live Services elements
13
- */
14
- static getData(): Promise<RawEsoStatus[]>;
15
- }