@eso-status/service-alerts 1.0.8 → 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 +1 -1
- package/README.md +108 -204
- package/lib/connector.d.ts +65 -0
- package/lib/connector.js +122 -0
- package/lib/const.d.ts +6 -0
- package/lib/const.js +8 -0
- package/lib/formatter/date.formatter.d.ts +19 -0
- package/lib/formatter/date.formatter.js +32 -0
- package/lib/identifier/slug.identifier.d.ts +89 -0
- package/lib/identifier/slug.identifier.js +140 -0
- package/lib/identifier/slug.match.d.ts +26 -0
- package/lib/identifier/slug.match.js +35 -0
- package/lib/identifier/status.identifier.d.ts +58 -0
- package/lib/identifier/status.identifier.js +74 -0
- package/lib/index.d.ts +6 -11
- package/lib/index.js +11 -72
- package/lib/interface/esoStatusRawData.interface.d.ts +54 -0
- package/lib/interface/esoStatusRawData.interface.js +3 -0
- package/lib/raw.d.ts +39 -0
- package/lib/raw.js +52 -0
- package/lib/type/remoteDownRawStatus.type.d.ts +4 -0
- package/lib/type/remoteDownRawStatus.type.js +3 -0
- package/lib/type/remoteIssuesRawStatus.type.d.ts +4 -0
- package/lib/type/remoteIssuesRawStatus.type.js +3 -0
- package/lib/type/remoteRawSlug.type.d.ts +13 -0
- package/lib/type/remoteRawSlug.type.js +3 -0
- package/lib/type/remoteRawStatus.type.d.ts +7 -0
- package/lib/type/remoteRawStatus.type.js +3 -0
- package/lib/type/remoteServerPcEuRawSlug.type.d.ts +4 -0
- package/lib/type/remoteServerPcEuRawSlug.type.js +3 -0
- package/lib/type/remoteServerPcNaRawSlug.type.d.ts +4 -0
- package/lib/type/remoteServerPcNaRawSlug.type.js +3 -0
- package/lib/type/remoteServerPcPtsRawSlug.type.d.ts +4 -0
- package/lib/type/remoteServerPcPtsRawSlug.type.js +3 -0
- package/lib/type/remoteServerPsEuRawSlug.type.d.ts +4 -0
- package/lib/type/remoteServerPsEuRawSlug.type.js +3 -0
- package/lib/type/remoteServerPsNaRawSlug.type.d.ts +4 -0
- package/lib/type/remoteServerPsNaRawSlug.type.js +3 -0
- package/lib/type/remoteServerXboxEuRawSlug.type.d.ts +4 -0
- package/lib/type/remoteServerXboxEuRawSlug.type.js +3 -0
- package/lib/type/remoteServerXboxNaRawSlug.type.d.ts +4 -0
- package/lib/type/remoteServerXboxNaRawSlug.type.js +3 -0
- package/lib/type/remoteServiceStoreEsoRawSlug.type.d.ts +4 -0
- package/lib/type/remoteServiceStoreEsoRawSlug.type.js +3 -0
- package/lib/type/remoteServiceSystemAccountRawSlug.type.d.ts +4 -0
- package/lib/type/remoteServiceSystemAccountRawSlug.type.js +3 -0
- package/lib/type/remoteUpRawStatus.type.d.ts +4 -0
- package/lib/type/remoteUpRawStatus.type.js +3 -0
- package/lib/type/sourceUrl.type.d.ts +4 -0
- package/lib/type/sourceUrl.type.js +3 -0
- package/package.json +107 -36
- package/lib/classes/ServiceAlertsElement.d.ts +0 -100
- package/lib/classes/ServiceAlertsElement.js +0 -284
- package/lib/connectors/ServiceAlertConnector.d.ts +0 -112
- package/lib/connectors/ServiceAlertConnector.js +0 -263
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var moment = require("moment");
|
|
4
|
-
/**
|
|
5
|
-
* Class with methode for ServiceAlerts element
|
|
6
|
-
*/
|
|
7
|
-
var ServiceAlertsElement = /** @class */ (function () {
|
|
8
|
-
function ServiceAlertsElement() {
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Methode used to get slugs list of raw content
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
14
|
-
* @static
|
|
15
|
-
*
|
|
16
|
-
* @param rawData string Raw data
|
|
17
|
-
* @return Slug[] List of slug
|
|
18
|
-
*/
|
|
19
|
-
ServiceAlertsElement.getSlug = function (rawData) {
|
|
20
|
-
var slugs = [];
|
|
21
|
-
if (ServiceAlertsElement.isType('server', rawData)
|
|
22
|
-
&& ServiceAlertsElement.isSupport('pc', rawData)
|
|
23
|
-
&& ServiceAlertsElement.isZone('na', rawData)) {
|
|
24
|
-
slugs.push('server_pc_na');
|
|
25
|
-
}
|
|
26
|
-
if (ServiceAlertsElement.isType('server', rawData)
|
|
27
|
-
&& ServiceAlertsElement.isSupport('pc', rawData)
|
|
28
|
-
&& ServiceAlertsElement.isZone('eu', rawData)) {
|
|
29
|
-
slugs.push('server_pc_eu');
|
|
30
|
-
}
|
|
31
|
-
if (ServiceAlertsElement.isType('server', rawData)
|
|
32
|
-
&& ServiceAlertsElement.isSupport('xbox', rawData)
|
|
33
|
-
&& ServiceAlertsElement.isZone('na', rawData)) {
|
|
34
|
-
slugs.push('server_xbox_na');
|
|
35
|
-
}
|
|
36
|
-
if (ServiceAlertsElement.isType('server', rawData)
|
|
37
|
-
&& ServiceAlertsElement.isSupport('xbox', rawData)
|
|
38
|
-
&& ServiceAlertsElement.isZone('eu', rawData)) {
|
|
39
|
-
slugs.push('server_xbox_eu');
|
|
40
|
-
}
|
|
41
|
-
if (ServiceAlertsElement.isType('server', rawData)
|
|
42
|
-
&& ServiceAlertsElement.isSupport('ps', rawData)
|
|
43
|
-
&& ServiceAlertsElement.isZone('na', rawData)) {
|
|
44
|
-
slugs.push('server_ps_na');
|
|
45
|
-
}
|
|
46
|
-
if (ServiceAlertsElement.isType('server', rawData)
|
|
47
|
-
&& ServiceAlertsElement.isSupport('ps', rawData)
|
|
48
|
-
&& ServiceAlertsElement.isZone('eu', rawData)) {
|
|
49
|
-
slugs.push('server_ps_eu');
|
|
50
|
-
}
|
|
51
|
-
if (ServiceAlertsElement.isType('server', rawData)
|
|
52
|
-
&& ServiceAlertsElement.isSupport('pc', rawData)
|
|
53
|
-
&& ServiceAlertsElement.isZone('pts', rawData)) {
|
|
54
|
-
slugs.push('server_pc_pts');
|
|
55
|
-
}
|
|
56
|
-
if (ServiceAlertsElement.isType('service', rawData)
|
|
57
|
-
&& ServiceAlertsElement.isSupport('web', rawData)
|
|
58
|
-
&& ServiceAlertsElement.isZone('site', rawData)) {
|
|
59
|
-
slugs.push('service_web_site');
|
|
60
|
-
}
|
|
61
|
-
if (ServiceAlertsElement.isType('service', rawData)
|
|
62
|
-
&& ServiceAlertsElement.isSupport('web', rawData)
|
|
63
|
-
&& ServiceAlertsElement.isZone('forum', rawData)) {
|
|
64
|
-
slugs.push('service_web_forum');
|
|
65
|
-
}
|
|
66
|
-
if (ServiceAlertsElement.isType('service', rawData)
|
|
67
|
-
&& ServiceAlertsElement.isSupport('store', rawData)
|
|
68
|
-
&& ServiceAlertsElement.isZone('crown', rawData)) {
|
|
69
|
-
slugs.push('service_store_crown');
|
|
70
|
-
}
|
|
71
|
-
if (ServiceAlertsElement.isType('service', rawData)
|
|
72
|
-
&& ServiceAlertsElement.isSupport('store', rawData)
|
|
73
|
-
&& ServiceAlertsElement.isZone('eso', rawData)) {
|
|
74
|
-
slugs.push('service_store_eso');
|
|
75
|
-
}
|
|
76
|
-
if (ServiceAlertsElement.isType('service', rawData)
|
|
77
|
-
&& ServiceAlertsElement.isSupport('system', rawData)
|
|
78
|
-
&& ServiceAlertsElement.isZone('account', rawData)) {
|
|
79
|
-
slugs.push('service_system_account');
|
|
80
|
-
}
|
|
81
|
-
return slugs;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Methode used to determinate service type
|
|
85
|
-
*
|
|
86
|
-
* @public
|
|
87
|
-
* @static
|
|
88
|
-
*
|
|
89
|
-
* @param type Type Type to check
|
|
90
|
-
* @param rawData string Raw data
|
|
91
|
-
* @return boolean Check result
|
|
92
|
-
*/
|
|
93
|
-
ServiceAlertsElement.isType = function (type, rawData) {
|
|
94
|
-
if (type === 'server') {
|
|
95
|
-
return rawData.includes('megaserver')
|
|
96
|
-
|| rawData.includes('PlayStation™ Network')
|
|
97
|
-
|| rawData.includes('Xbox Live™')
|
|
98
|
-
|| rawData.includes('PTS');
|
|
99
|
-
}
|
|
100
|
-
if (type === 'service') {
|
|
101
|
-
return rawData.includes('Website')
|
|
102
|
-
|| rawData.includes('Forums')
|
|
103
|
-
|| rawData.includes('Crown Store')
|
|
104
|
-
|| rawData.includes('ESO store')
|
|
105
|
-
|| rawData.includes('ESO Store')
|
|
106
|
-
|| rawData.includes('account system')
|
|
107
|
-
|| rawData.includes('Account System');
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* Methode used to determinate service support
|
|
113
|
-
*
|
|
114
|
-
* @public
|
|
115
|
-
* @static
|
|
116
|
-
*
|
|
117
|
-
* @param support Support Support to check
|
|
118
|
-
* @param rawData string Raw data
|
|
119
|
-
* @return boolean Check result
|
|
120
|
-
*/
|
|
121
|
-
ServiceAlertsElement.isSupport = function (support, rawData) {
|
|
122
|
-
if (support === 'xbox') {
|
|
123
|
-
return rawData.includes('Xbox')
|
|
124
|
-
|| rawData.includes('European megaservers')
|
|
125
|
-
|| rawData.includes('American megaservers')
|
|
126
|
-
|| rawData.includes('the megaservers');
|
|
127
|
-
}
|
|
128
|
-
if (support === 'ps') {
|
|
129
|
-
return rawData.includes('PlayStation')
|
|
130
|
-
|| rawData.includes('European megaservers')
|
|
131
|
-
|| rawData.includes('American megaservers')
|
|
132
|
-
|| rawData.includes('the megaservers');
|
|
133
|
-
}
|
|
134
|
-
if (support === 'pc') {
|
|
135
|
-
return rawData.includes('PC/Mac')
|
|
136
|
-
|| rawData.includes('PTS')
|
|
137
|
-
|| rawData.includes('European megaservers')
|
|
138
|
-
|| rawData.includes('American megaservers')
|
|
139
|
-
|| rawData.includes('the megaservers');
|
|
140
|
-
}
|
|
141
|
-
if (support === 'web') {
|
|
142
|
-
return rawData.includes('Website')
|
|
143
|
-
|| rawData.includes('Forums');
|
|
144
|
-
}
|
|
145
|
-
if (support === 'store') {
|
|
146
|
-
return rawData.includes('Crown Store')
|
|
147
|
-
|| rawData.includes('ESO store')
|
|
148
|
-
|| rawData.includes('ESO Store');
|
|
149
|
-
}
|
|
150
|
-
if (support === 'system') {
|
|
151
|
-
return rawData.includes('account system')
|
|
152
|
-
|| rawData.includes('Account System');
|
|
153
|
-
}
|
|
154
|
-
return false;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Methode used to determinate service zone
|
|
158
|
-
*
|
|
159
|
-
* @public
|
|
160
|
-
* @static
|
|
161
|
-
*
|
|
162
|
-
* @param zone Zone Zone to check
|
|
163
|
-
* @param rawData string Raw data
|
|
164
|
-
* @return boolean Check result
|
|
165
|
-
*/
|
|
166
|
-
ServiceAlertsElement.isZone = function (zone, rawData) {
|
|
167
|
-
if (zone === 'na') {
|
|
168
|
-
return rawData.includes('North American')
|
|
169
|
-
|| rawData.includes('PlayStation™ Network')
|
|
170
|
-
|| rawData.includes('Xbox Live™')
|
|
171
|
-
|| rawData.includes('the megaservers')
|
|
172
|
-
|| rawData.includes('North American and European');
|
|
173
|
-
}
|
|
174
|
-
if (zone === 'eu') {
|
|
175
|
-
return rawData.includes('European')
|
|
176
|
-
|| rawData.includes('PlayStation™ Network')
|
|
177
|
-
|| rawData.includes('Xbox Live™')
|
|
178
|
-
|| rawData.includes('the megaservers')
|
|
179
|
-
|| rawData.includes('North American and European');
|
|
180
|
-
}
|
|
181
|
-
if (zone === 'pts') {
|
|
182
|
-
return rawData.includes('PTS');
|
|
183
|
-
}
|
|
184
|
-
if (zone === 'site') {
|
|
185
|
-
return rawData.includes('Website');
|
|
186
|
-
}
|
|
187
|
-
if (zone === 'forum') {
|
|
188
|
-
return rawData.includes('Forums');
|
|
189
|
-
}
|
|
190
|
-
if (zone === 'crown') {
|
|
191
|
-
return rawData.includes('Crown Store');
|
|
192
|
-
}
|
|
193
|
-
if (zone === 'eso') {
|
|
194
|
-
return rawData.includes('ESO store')
|
|
195
|
-
|| rawData.includes('ESO Store');
|
|
196
|
-
}
|
|
197
|
-
if (zone === 'account') {
|
|
198
|
-
return rawData.includes('account system')
|
|
199
|
-
|| rawData.includes('Account System');
|
|
200
|
-
}
|
|
201
|
-
return false;
|
|
202
|
-
};
|
|
203
|
-
/**
|
|
204
|
-
* Methode used to get date of raw content
|
|
205
|
-
*
|
|
206
|
-
* @public
|
|
207
|
-
* @static
|
|
208
|
-
*
|
|
209
|
-
* @param rawDate string Raw data
|
|
210
|
-
* @return Moment Date of raw data
|
|
211
|
-
*/
|
|
212
|
-
ServiceAlertsElement.getDate = function (rawDate) {
|
|
213
|
-
var dateTime = /([0-9]{4}).([0-9]{2}).([0-9]{2}) - ([0-9]{1,2}):([0-9]{2})/.exec(rawDate);
|
|
214
|
-
return moment()
|
|
215
|
-
.utc()
|
|
216
|
-
.set('years', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[1]) : 0))
|
|
217
|
-
.set('months', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[2]) : 0))
|
|
218
|
-
.set('date', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[3]) : 0))
|
|
219
|
-
.set('hours', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[4]) : 0))
|
|
220
|
-
.set('minutes', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[5]) : 0))
|
|
221
|
-
.set('seconds', 0)
|
|
222
|
-
.set('milliseconds', 0)
|
|
223
|
-
.utcOffset(0);
|
|
224
|
-
};
|
|
225
|
-
/**
|
|
226
|
-
* Methode used to get type of slug
|
|
227
|
-
*
|
|
228
|
-
* @public
|
|
229
|
-
* @static
|
|
230
|
-
*
|
|
231
|
-
* @param slug Slug Slug
|
|
232
|
-
* @return Type Type of slug
|
|
233
|
-
*/
|
|
234
|
-
ServiceAlertsElement.getType = function (slug) {
|
|
235
|
-
return slug.split('_')[0];
|
|
236
|
-
};
|
|
237
|
-
/**
|
|
238
|
-
* Methode used to get support of slug
|
|
239
|
-
*
|
|
240
|
-
* @public
|
|
241
|
-
* @static
|
|
242
|
-
*
|
|
243
|
-
* @param slug Slug Slug
|
|
244
|
-
* @return Support Support of slug
|
|
245
|
-
*/
|
|
246
|
-
ServiceAlertsElement.getSupport = function (slug) {
|
|
247
|
-
return slug.split('_')[1];
|
|
248
|
-
};
|
|
249
|
-
/**
|
|
250
|
-
* Methode used to get zone of slug
|
|
251
|
-
*
|
|
252
|
-
* @public
|
|
253
|
-
* @static
|
|
254
|
-
*
|
|
255
|
-
* @param slug Slug Slug
|
|
256
|
-
* @return Zone Zone of slug
|
|
257
|
-
*/
|
|
258
|
-
ServiceAlertsElement.getZone = function (slug) {
|
|
259
|
-
return slug.split('_')[2];
|
|
260
|
-
};
|
|
261
|
-
/**
|
|
262
|
-
* Methode used to get status of raw data
|
|
263
|
-
*
|
|
264
|
-
* @public
|
|
265
|
-
* @static
|
|
266
|
-
*
|
|
267
|
-
* @param rawData string Raw data
|
|
268
|
-
* @return Status Status of raw data
|
|
269
|
-
*/
|
|
270
|
-
ServiceAlertsElement.getStatus = function (rawData) {
|
|
271
|
-
if (rawData.includes('unavailable')) {
|
|
272
|
-
return 'down';
|
|
273
|
-
}
|
|
274
|
-
if (rawData.includes('available') || rawData.includes('online') || rawData.includes('resolved')) {
|
|
275
|
-
return 'up';
|
|
276
|
-
}
|
|
277
|
-
if (rawData.includes('currently investigating') || rawData.includes('interruption')) {
|
|
278
|
-
return 'issues';
|
|
279
|
-
}
|
|
280
|
-
return 'down';
|
|
281
|
-
};
|
|
282
|
-
return ServiceAlertsElement;
|
|
283
|
-
}());
|
|
284
|
-
exports.default = ServiceAlertsElement;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { RawEsoStatus } from '@eso-status/types';
|
|
2
|
-
/**
|
|
3
|
-
* Connector used to get data from https://help.elderscrollsonline.com/app/answers/detail/a_id/4320
|
|
4
|
-
*/
|
|
5
|
-
export default class ServiceAlertConnector {
|
|
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 by date
|
|
36
|
-
*
|
|
37
|
-
* @public
|
|
38
|
-
* @static
|
|
39
|
-
*
|
|
40
|
-
* @param filteredContent string Raw content containing eso servers status information
|
|
41
|
-
* @return string[] List of each information by date
|
|
42
|
-
*/
|
|
43
|
-
static changeFilterContentForList(filteredContent: string): string[];
|
|
44
|
-
/**
|
|
45
|
-
* Methode used to get raw data of content list
|
|
46
|
-
*
|
|
47
|
-
* @public
|
|
48
|
-
* @static
|
|
49
|
-
*
|
|
50
|
-
* @param filteredContentList string[] Raw data of content list
|
|
51
|
-
* @return {raw: string, rawDate: string, rawData: string[]}[] Raw data of content list
|
|
52
|
-
*/
|
|
53
|
-
static getRawData(filteredContentList: string[]): {
|
|
54
|
-
raw: string;
|
|
55
|
-
rawDate: string;
|
|
56
|
-
rawData: string[];
|
|
57
|
-
}[];
|
|
58
|
-
/**
|
|
59
|
-
* Methode used to get list of split raw data of content list
|
|
60
|
-
*
|
|
61
|
-
* @public
|
|
62
|
-
* @static
|
|
63
|
-
*
|
|
64
|
-
* @param rawData {raw: string, rawDate: string, rawData: string[]}[] Raw data of content list
|
|
65
|
-
* @return RawEsoStatus[] Split raw data of content list
|
|
66
|
-
*/
|
|
67
|
-
static splitRawData(rawData: {
|
|
68
|
-
raw: string;
|
|
69
|
-
rawDate: string;
|
|
70
|
-
rawData: string[];
|
|
71
|
-
}[]): RawEsoStatus[];
|
|
72
|
-
/**
|
|
73
|
-
* Methode used to get slug of split raw data of content list
|
|
74
|
-
*
|
|
75
|
-
* @public
|
|
76
|
-
* @static
|
|
77
|
-
*
|
|
78
|
-
* @param splitRawData RawEsoStatus[] Split raw data of content list
|
|
79
|
-
* @return RawEsoStatus[] Split raw data of content list with slug
|
|
80
|
-
*/
|
|
81
|
-
static getSlugOfSplitRawData(splitRawData: RawEsoStatus[]): RawEsoStatus[];
|
|
82
|
-
/**
|
|
83
|
-
* Methode used to get split raw data of content list by slug
|
|
84
|
-
*
|
|
85
|
-
* @public
|
|
86
|
-
* @static
|
|
87
|
-
*
|
|
88
|
-
* @param splitRawDataWithSlug RawEsoStatus[] Split raw data of content list with slug
|
|
89
|
-
* @return RawEsoStatus[] Split raw data of content list by slug
|
|
90
|
-
*/
|
|
91
|
-
static splitRawDataList(splitRawDataWithSlug: RawEsoStatus[]): RawEsoStatus[];
|
|
92
|
-
/**
|
|
93
|
-
* Methode used to get last element by slug
|
|
94
|
-
*
|
|
95
|
-
* @public
|
|
96
|
-
* @static
|
|
97
|
-
*
|
|
98
|
-
* @param splitRawDataList RawEsoStatus[] Split raw data of content list by slug
|
|
99
|
-
* @return RawEsoStatus[] Raw eso server status list sorted by date
|
|
100
|
-
*/
|
|
101
|
-
static getLastRawData(splitRawDataList: RawEsoStatus[]): RawEsoStatus[];
|
|
102
|
-
/**
|
|
103
|
-
* Methode used to get last eso status server with data
|
|
104
|
-
*
|
|
105
|
-
* @public
|
|
106
|
-
* @static
|
|
107
|
-
*
|
|
108
|
-
* @param lastRawData RawEsoStatus[] Raw eso server status list sorted by date
|
|
109
|
-
* @return RawEsoStatus[] Last eso status server with data
|
|
110
|
-
*/
|
|
111
|
-
static getData(lastRawData: RawEsoStatus[]): RawEsoStatus[];
|
|
112
|
-
}
|
|
@@ -1,263 +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 ServiceAlertsElement_1 = require("../classes/ServiceAlertsElement");
|
|
40
|
-
var axios = require('axios');
|
|
41
|
-
/**
|
|
42
|
-
* Connector used to get data from https://help.elderscrollsonline.com/app/answers/detail/a_id/4320
|
|
43
|
-
*/
|
|
44
|
-
var ServiceAlertConnector = /** @class */ (function () {
|
|
45
|
-
function ServiceAlertConnector() {
|
|
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
|
-
ServiceAlertConnector.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(ServiceAlertConnector.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*/, 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
|
-
ServiceAlertConnector.getFilterContent = function (remoteContent) {
|
|
87
|
-
var resultRemoveBefore = remoteContent.split('<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->');
|
|
88
|
-
if (resultRemoveBefore.length >= 2) {
|
|
89
|
-
var resultRemoveAfter = resultRemoveBefore[1].split('<p> </p>');
|
|
90
|
-
if (resultRemoveAfter.length >= 2) {
|
|
91
|
-
return "<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->".concat(resultRemoveAfter[0], "<p> </p>");
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return '';
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Methode used to get list of each raw information by date
|
|
98
|
-
*
|
|
99
|
-
* @public
|
|
100
|
-
* @static
|
|
101
|
-
*
|
|
102
|
-
* @param filteredContent string Raw content containing eso servers status information
|
|
103
|
-
* @return string[] List of each information by date
|
|
104
|
-
*/
|
|
105
|
-
ServiceAlertConnector.changeFilterContentForList = function (filteredContent) {
|
|
106
|
-
return filteredContent
|
|
107
|
-
.split('<hr')
|
|
108
|
-
.filter(function (item) { return !item.includes(' '); });
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Methode used to get raw data of content list
|
|
112
|
-
*
|
|
113
|
-
* @public
|
|
114
|
-
* @static
|
|
115
|
-
*
|
|
116
|
-
* @param filteredContentList string[] Raw data of content list
|
|
117
|
-
* @return {raw: string, rawDate: string, rawData: string[]}[] Raw data of content list
|
|
118
|
-
*/
|
|
119
|
-
ServiceAlertConnector.getRawData = function (filteredContentList) {
|
|
120
|
-
return filteredContentList.map(function (item) {
|
|
121
|
-
var list = item
|
|
122
|
-
.split('</p>')
|
|
123
|
-
.map(function (line) {
|
|
124
|
-
var newLine = line;
|
|
125
|
-
newLine = newLine.replace('\n', '')
|
|
126
|
-
.replace('\n', '')
|
|
127
|
-
.replace('</p>', '')
|
|
128
|
-
.replace('<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->', '')
|
|
129
|
-
.replace('<p>', '');
|
|
130
|
-
return newLine;
|
|
131
|
-
})
|
|
132
|
-
.filter(function (line) { return line.length > 2; });
|
|
133
|
-
return {
|
|
134
|
-
raw: item,
|
|
135
|
-
rawDate: list[0],
|
|
136
|
-
rawData: list.slice(1, list.length),
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* Methode used to get list of split raw data of content list
|
|
142
|
-
*
|
|
143
|
-
* @public
|
|
144
|
-
* @static
|
|
145
|
-
*
|
|
146
|
-
* @param rawData {raw: string, rawDate: string, rawData: string[]}[] Raw data of content list
|
|
147
|
-
* @return RawEsoStatus[] Split raw data of content list
|
|
148
|
-
*/
|
|
149
|
-
ServiceAlertConnector.splitRawData = function (rawData) {
|
|
150
|
-
var list = [];
|
|
151
|
-
rawData.forEach(function (item) {
|
|
152
|
-
item.rawData.forEach(function (line) {
|
|
153
|
-
list.push({
|
|
154
|
-
sources: [ServiceAlertConnector.url],
|
|
155
|
-
raw: [item.raw],
|
|
156
|
-
rawDate: item.rawDate,
|
|
157
|
-
rawData: line,
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
return list;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Methode used to get slug of split raw data of content list
|
|
165
|
-
*
|
|
166
|
-
* @public
|
|
167
|
-
* @static
|
|
168
|
-
*
|
|
169
|
-
* @param splitRawData RawEsoStatus[] Split raw data of content list
|
|
170
|
-
* @return RawEsoStatus[] Split raw data of content list with slug
|
|
171
|
-
*/
|
|
172
|
-
ServiceAlertConnector.getSlugOfSplitRawData = function (splitRawData) {
|
|
173
|
-
return splitRawData.map(function (item) {
|
|
174
|
-
var _a;
|
|
175
|
-
return ({
|
|
176
|
-
sources: item.sources,
|
|
177
|
-
raw: item.raw,
|
|
178
|
-
rawDate: item.rawDate,
|
|
179
|
-
rawData: item.rawData,
|
|
180
|
-
slugs: ServiceAlertsElement_1.default.getSlug((_a = item.rawData) !== null && _a !== void 0 ? _a : ''),
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Methode used to get split raw data of content list by slug
|
|
186
|
-
*
|
|
187
|
-
* @public
|
|
188
|
-
* @static
|
|
189
|
-
*
|
|
190
|
-
* @param splitRawDataWithSlug RawEsoStatus[] Split raw data of content list with slug
|
|
191
|
-
* @return RawEsoStatus[] Split raw data of content list by slug
|
|
192
|
-
*/
|
|
193
|
-
ServiceAlertConnector.splitRawDataList = function (splitRawDataWithSlug) {
|
|
194
|
-
var list = [];
|
|
195
|
-
splitRawDataWithSlug.forEach(function (item) {
|
|
196
|
-
var _a;
|
|
197
|
-
(_a = item.slugs) === null || _a === void 0 ? void 0 : _a.forEach(function (slug) {
|
|
198
|
-
list.push({
|
|
199
|
-
sources: item.sources,
|
|
200
|
-
raw: item.raw,
|
|
201
|
-
rawDate: item.rawDate,
|
|
202
|
-
rawData: item.rawData,
|
|
203
|
-
slugs: [slug],
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
return list;
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* Methode used to get last element by slug
|
|
211
|
-
*
|
|
212
|
-
* @public
|
|
213
|
-
* @static
|
|
214
|
-
*
|
|
215
|
-
* @param splitRawDataList RawEsoStatus[] Split raw data of content list by slug
|
|
216
|
-
* @return RawEsoStatus[] Raw eso server status list sorted by date
|
|
217
|
-
*/
|
|
218
|
-
ServiceAlertConnector.getLastRawData = function (splitRawDataList) {
|
|
219
|
-
var last = [];
|
|
220
|
-
var list = [];
|
|
221
|
-
splitRawDataList.forEach(function (item) {
|
|
222
|
-
if (item && item.slugs && !last.includes(item.slugs[0])) {
|
|
223
|
-
last.push(item.slugs[0]);
|
|
224
|
-
list.push(item);
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
return list;
|
|
228
|
-
};
|
|
229
|
-
/**
|
|
230
|
-
* Methode used to get last eso status server with data
|
|
231
|
-
*
|
|
232
|
-
* @public
|
|
233
|
-
* @static
|
|
234
|
-
*
|
|
235
|
-
* @param lastRawData RawEsoStatus[] Raw eso server status list sorted by date
|
|
236
|
-
* @return RawEsoStatus[] Last eso status server with data
|
|
237
|
-
*/
|
|
238
|
-
ServiceAlertConnector.getData = function (lastRawData) {
|
|
239
|
-
return lastRawData.map(function (item) {
|
|
240
|
-
var _a, _b;
|
|
241
|
-
var newItem = item;
|
|
242
|
-
if (newItem.slugs) {
|
|
243
|
-
newItem.dates = [ServiceAlertsElement_1.default.getDate((_a = newItem.rawDate) !== null && _a !== void 0 ? _a : '')];
|
|
244
|
-
newItem.type = ServiceAlertsElement_1.default.getType(newItem.slugs[0]);
|
|
245
|
-
newItem.support = ServiceAlertsElement_1.default.getSupport(newItem.slugs[0]);
|
|
246
|
-
newItem.zone = ServiceAlertsElement_1.default.getZone(newItem.slugs[0]);
|
|
247
|
-
newItem.status = ServiceAlertsElement_1.default.getStatus((_b = newItem.rawData) !== null && _b !== void 0 ? _b : '');
|
|
248
|
-
}
|
|
249
|
-
return newItem;
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
* URL to get remote content
|
|
254
|
-
*
|
|
255
|
-
* @public
|
|
256
|
-
* @static
|
|
257
|
-
*
|
|
258
|
-
* @return string URL to get remote content
|
|
259
|
-
*/
|
|
260
|
-
ServiceAlertConnector.url = 'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320';
|
|
261
|
-
return ServiceAlertConnector;
|
|
262
|
-
}());
|
|
263
|
-
exports.default = ServiceAlertConnector;
|