@eso-status/forum-message 1.0.12 → 1.0.14
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/lib/classes/ForumMessageElement.d.ts +5 -0
- package/lib/classes/ForumMessageElement.js +183 -244
- package/lib/connectors/ForumMessageConnector.js +97 -151
- package/lib/index.d.ts +7 -7
- package/lib/index.js +21 -66
- package/package.json +29 -22
|
@@ -57,6 +57,11 @@ export default class ForumMessageElement {
|
|
|
57
57
|
* @return Moment[] Dates of raw data
|
|
58
58
|
*/
|
|
59
59
|
static getDate(rawDate: string): Moment[];
|
|
60
|
+
private static getDateWithDayIndex;
|
|
61
|
+
private static getDateWithHours;
|
|
62
|
+
private static getDateWithDayNumber;
|
|
63
|
+
private static getMatchedNumber;
|
|
64
|
+
private static buildUtcDate;
|
|
60
65
|
/**
|
|
61
66
|
* Methode used to get type of slug
|
|
62
67
|
*
|
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
6
|
+
const moment_1 = __importDefault(require("moment"));
|
|
7
|
+
const orderedSlugs = [
|
|
8
|
+
'server_pc_na',
|
|
9
|
+
'server_pc_eu',
|
|
10
|
+
'server_xbox_na',
|
|
11
|
+
'server_xbox_eu',
|
|
12
|
+
'server_ps_na',
|
|
13
|
+
'server_ps_eu',
|
|
14
|
+
'server_pc_pts',
|
|
15
|
+
'service_web_site',
|
|
16
|
+
'service_web_forum',
|
|
17
|
+
'service_store_crown',
|
|
18
|
+
'service_store_eso',
|
|
19
|
+
'service_system_account',
|
|
20
|
+
];
|
|
21
|
+
const time12h = String.raw `\d{1,2}:\d{1,2}[a-zA-Z]{1,2}`;
|
|
22
|
+
const monthAndDay = String.raw `([a-zA-Z]{3,9}) (\d{1,2}) ?, `;
|
|
23
|
+
const utcTime = String.raw `(\d{1,2}):(\d{1,2}) UTC`;
|
|
24
|
+
const dash = '[–|-]';
|
|
25
|
+
const edtFirstRange = new RegExp(`${monthAndDay}${time12h} E[D|S]T \\(${utcTime}\\) ${dash} ${time12h} E[D|S]T \\(${utcTime}\\)`);
|
|
26
|
+
const utcFirstRange = new RegExp(`${monthAndDay}${utcTime} \\(${time12h} EDT\\) ${dash} ${utcTime} \\(${time12h} EDT\\)`);
|
|
4
27
|
/**
|
|
5
28
|
* Class with methode for ForumMessage element
|
|
6
29
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
30
|
+
// 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
|
|
31
|
+
class ForumMessageElement {
|
|
10
32
|
/**
|
|
11
33
|
* Methode used to get slugs list of raw content
|
|
12
34
|
*
|
|
@@ -16,70 +38,11 @@ var ForumMessageElement = /** @class */ (function () {
|
|
|
16
38
|
* @param rawData string Raw data
|
|
17
39
|
* @return Slug[] List of slug
|
|
18
40
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
slugs.push('server_pc_na');
|
|
25
|
-
}
|
|
26
|
-
if (ForumMessageElement.isType('server', rawData)
|
|
27
|
-
&& ForumMessageElement.isSupport('pc', rawData)
|
|
28
|
-
&& ForumMessageElement.isZone('eu', rawData)) {
|
|
29
|
-
slugs.push('server_pc_eu');
|
|
30
|
-
}
|
|
31
|
-
if (ForumMessageElement.isType('server', rawData)
|
|
32
|
-
&& ForumMessageElement.isSupport('xbox', rawData)
|
|
33
|
-
&& ForumMessageElement.isZone('na', rawData)) {
|
|
34
|
-
slugs.push('server_xbox_na');
|
|
35
|
-
}
|
|
36
|
-
if (ForumMessageElement.isType('server', rawData)
|
|
37
|
-
&& ForumMessageElement.isSupport('xbox', rawData)
|
|
38
|
-
&& ForumMessageElement.isZone('eu', rawData)) {
|
|
39
|
-
slugs.push('server_xbox_eu');
|
|
40
|
-
}
|
|
41
|
-
if (ForumMessageElement.isType('server', rawData)
|
|
42
|
-
&& ForumMessageElement.isSupport('ps', rawData)
|
|
43
|
-
&& ForumMessageElement.isZone('na', rawData)) {
|
|
44
|
-
slugs.push('server_ps_na');
|
|
45
|
-
}
|
|
46
|
-
if (ForumMessageElement.isType('server', rawData)
|
|
47
|
-
&& ForumMessageElement.isSupport('ps', rawData)
|
|
48
|
-
&& ForumMessageElement.isZone('eu', rawData)) {
|
|
49
|
-
slugs.push('server_ps_eu');
|
|
50
|
-
}
|
|
51
|
-
if (ForumMessageElement.isType('server', rawData)
|
|
52
|
-
&& ForumMessageElement.isSupport('pc', rawData)
|
|
53
|
-
&& ForumMessageElement.isZone('pts', rawData)) {
|
|
54
|
-
slugs.push('server_pc_pts');
|
|
55
|
-
}
|
|
56
|
-
if (ForumMessageElement.isType('service', rawData)
|
|
57
|
-
&& ForumMessageElement.isSupport('web', rawData)
|
|
58
|
-
&& ForumMessageElement.isZone('site', rawData)) {
|
|
59
|
-
slugs.push('service_web_site');
|
|
60
|
-
}
|
|
61
|
-
if (ForumMessageElement.isType('service', rawData)
|
|
62
|
-
&& ForumMessageElement.isSupport('web', rawData)
|
|
63
|
-
&& ForumMessageElement.isZone('forum', rawData)) {
|
|
64
|
-
slugs.push('service_web_forum');
|
|
65
|
-
}
|
|
66
|
-
if (ForumMessageElement.isType('service', rawData)
|
|
67
|
-
&& ForumMessageElement.isSupport('store', rawData)
|
|
68
|
-
&& ForumMessageElement.isZone('crown', rawData)) {
|
|
69
|
-
slugs.push('service_store_crown');
|
|
70
|
-
}
|
|
71
|
-
if (ForumMessageElement.isType('service', rawData)
|
|
72
|
-
&& ForumMessageElement.isSupport('store', rawData)
|
|
73
|
-
&& ForumMessageElement.isZone('eso', rawData)) {
|
|
74
|
-
slugs.push('service_store_eso');
|
|
75
|
-
}
|
|
76
|
-
if (ForumMessageElement.isType('service', rawData)
|
|
77
|
-
&& ForumMessageElement.isSupport('system', rawData)
|
|
78
|
-
&& ForumMessageElement.isZone('account', rawData)) {
|
|
79
|
-
slugs.push('service_system_account');
|
|
80
|
-
}
|
|
81
|
-
return slugs;
|
|
82
|
-
};
|
|
41
|
+
static getSlug(rawData) {
|
|
42
|
+
return orderedSlugs.filter((slug) => ForumMessageElement.isType(ForumMessageElement.getType(slug), rawData) &&
|
|
43
|
+
ForumMessageElement.isSupport(ForumMessageElement.getSupport(slug), rawData) &&
|
|
44
|
+
ForumMessageElement.isZone(ForumMessageElement.getZone(slug), rawData));
|
|
45
|
+
}
|
|
83
46
|
/**
|
|
84
47
|
* Methode used to determinate service type
|
|
85
48
|
*
|
|
@@ -90,24 +53,21 @@ var ForumMessageElement = /** @class */ (function () {
|
|
|
90
53
|
* @param rawData string Raw data
|
|
91
54
|
* @return boolean Check result
|
|
92
55
|
*/
|
|
93
|
-
|
|
56
|
+
static isType(type, rawData) {
|
|
94
57
|
if (type === 'server') {
|
|
95
|
-
return rawData.includes('megaserver')
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
110
|
-
};
|
|
58
|
+
return (rawData.includes('megaserver') ||
|
|
59
|
+
rawData.includes('NA megaservers') ||
|
|
60
|
+
rawData.includes('EU megaservers') ||
|
|
61
|
+
rawData.includes('the megaservers') ||
|
|
62
|
+
rawData.includes('PTS') ||
|
|
63
|
+
rawData.includes('PlayStation') ||
|
|
64
|
+
rawData.includes('Xbox Live'));
|
|
65
|
+
}
|
|
66
|
+
return (rawData.includes('ESO Store') ||
|
|
67
|
+
rawData.includes('Account System') ||
|
|
68
|
+
rawData.includes('account system') ||
|
|
69
|
+
rawData.includes('ESO Website'));
|
|
70
|
+
}
|
|
111
71
|
/**
|
|
112
72
|
* Methode used to determinate service support
|
|
113
73
|
*
|
|
@@ -118,40 +78,40 @@ var ForumMessageElement = /** @class */ (function () {
|
|
|
118
78
|
* @param rawData string Raw data
|
|
119
79
|
* @return boolean Check result
|
|
120
80
|
*/
|
|
121
|
-
|
|
122
|
-
if (support === 'xbox') {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
81
|
+
static isSupport(support, rawData) {
|
|
82
|
+
if (support === 'xbox') {
|
|
83
|
+
// OK
|
|
84
|
+
return (rawData.includes('Xbox') ||
|
|
85
|
+
rawData.includes('· NA megaservers') ||
|
|
86
|
+
rawData.includes('· EU megaservers') ||
|
|
87
|
+
rawData.includes('the megaservers'));
|
|
88
|
+
}
|
|
89
|
+
if (support === 'ps') {
|
|
90
|
+
// OK
|
|
91
|
+
return (rawData.includes('PlayStation') ||
|
|
92
|
+
rawData.includes('· NA megaservers') ||
|
|
93
|
+
rawData.includes('· EU megaservers') ||
|
|
94
|
+
rawData.includes('the megaservers'));
|
|
95
|
+
}
|
|
96
|
+
if (support === 'pc') {
|
|
97
|
+
// OK
|
|
98
|
+
return (rawData.includes('PC/Mac') ||
|
|
99
|
+
rawData.includes('PTS') ||
|
|
100
|
+
rawData.includes('· NA megaservers') ||
|
|
101
|
+
rawData.includes('· EU megaservers') ||
|
|
102
|
+
rawData.includes('the megaservers'));
|
|
140
103
|
}
|
|
141
104
|
if (support === 'web') {
|
|
142
105
|
return rawData.includes('ESO Website');
|
|
143
106
|
}
|
|
144
|
-
if (support === 'store') {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
107
|
+
if (support === 'store') {
|
|
108
|
+
// OK
|
|
109
|
+
return (rawData.includes('Crown Store') ||
|
|
110
|
+
rawData.includes('ESO Store') ||
|
|
111
|
+
rawData.includes('ESO store'));
|
|
148
112
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|| rawData.includes('account system');
|
|
152
|
-
}
|
|
153
|
-
return false;
|
|
154
|
-
};
|
|
113
|
+
return (rawData.includes('Account System') || rawData.includes('account system'));
|
|
114
|
+
}
|
|
155
115
|
/**
|
|
156
116
|
* Methode used to determinate service zone
|
|
157
117
|
*
|
|
@@ -162,22 +122,25 @@ var ForumMessageElement = /** @class */ (function () {
|
|
|
162
122
|
* @param rawData string Raw data
|
|
163
123
|
* @return boolean Check result
|
|
164
124
|
*/
|
|
165
|
-
|
|
166
|
-
if (zone === 'na') {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
125
|
+
static isZone(zone, rawData) {
|
|
126
|
+
if (zone === 'na') {
|
|
127
|
+
// OK
|
|
128
|
+
return (rawData.includes('North American') ||
|
|
129
|
+
rawData.includes('NA') ||
|
|
130
|
+
rawData.includes('PlayStation™ Network') ||
|
|
131
|
+
rawData.includes('Xbox Live') ||
|
|
132
|
+
rawData.includes('the megaservers'));
|
|
133
|
+
}
|
|
134
|
+
if (zone === 'eu') {
|
|
135
|
+
// OK
|
|
136
|
+
return (rawData.includes('European') ||
|
|
137
|
+
rawData.includes('EU') ||
|
|
138
|
+
rawData.includes('PlayStation™ Network') ||
|
|
139
|
+
rawData.includes('Xbox Live') ||
|
|
140
|
+
rawData.includes('the megaservers'));
|
|
141
|
+
}
|
|
142
|
+
if (zone === 'pts') {
|
|
143
|
+
// OK
|
|
181
144
|
return rawData.includes('PTS');
|
|
182
145
|
}
|
|
183
146
|
if (zone === 'site') {
|
|
@@ -189,16 +152,12 @@ var ForumMessageElement = /** @class */ (function () {
|
|
|
189
152
|
if (zone === 'crown') {
|
|
190
153
|
return false;
|
|
191
154
|
}
|
|
192
|
-
if (zone === 'eso') {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
if (zone === 'account') { // OK
|
|
197
|
-
return rawData.includes('Account System')
|
|
198
|
-
|| rawData.includes('account system');
|
|
155
|
+
if (zone === 'eso') {
|
|
156
|
+
// OK
|
|
157
|
+
return rawData.includes('ESO Store') || rawData.includes('ESO store');
|
|
199
158
|
}
|
|
200
|
-
return
|
|
201
|
-
}
|
|
159
|
+
return (rawData.includes('Account System') || rawData.includes('account system'));
|
|
160
|
+
}
|
|
202
161
|
/**
|
|
203
162
|
* Methode used to get dates of raw date
|
|
204
163
|
*
|
|
@@ -208,98 +167,68 @@ var ForumMessageElement = /** @class */ (function () {
|
|
|
208
167
|
* @param rawDate string Raw date
|
|
209
168
|
* @return Moment[] Dates of raw data
|
|
210
169
|
*/
|
|
211
|
-
|
|
212
|
-
var list = [];
|
|
170
|
+
static getDate(rawDate) {
|
|
213
171
|
if (rawDate === '') {
|
|
214
|
-
return
|
|
172
|
+
return [];
|
|
215
173
|
}
|
|
216
174
|
if (rawDate.includes(' at ') && !rawDate.includes('EDT / ')) {
|
|
217
|
-
|
|
218
|
-
var isoWeekDay = Number(moment().day(dateTime && dateTime.length >= 1 ? String(dateTime[1]) : '').format('d'));
|
|
219
|
-
// getDateWithDayIndex
|
|
220
|
-
list.push(moment()
|
|
221
|
-
.utc()
|
|
222
|
-
.set('years', (moment().utc().isoWeekday() > isoWeekDay
|
|
223
|
-
? moment()
|
|
224
|
-
.utc()
|
|
225
|
-
.isoWeekday(isoWeekDay)
|
|
226
|
-
.add(7, 'day')
|
|
227
|
-
.get('years')
|
|
228
|
-
: moment()
|
|
229
|
-
.utc()
|
|
230
|
-
.isoWeekday(isoWeekDay)
|
|
231
|
-
.get('years')))
|
|
232
|
-
.set('months', (moment().utc().isoWeekday() > isoWeekDay
|
|
233
|
-
? moment()
|
|
234
|
-
.utc()
|
|
235
|
-
.isoWeekday(isoWeekDay)
|
|
236
|
-
.add(7, 'day')
|
|
237
|
-
.get('months')
|
|
238
|
-
: moment()
|
|
239
|
-
.utc()
|
|
240
|
-
.isoWeekday(isoWeekDay)
|
|
241
|
-
.get('months')))
|
|
242
|
-
.set('date', (moment().utc().isoWeekday() > isoWeekDay
|
|
243
|
-
? moment()
|
|
244
|
-
.utc()
|
|
245
|
-
.isoWeekday(isoWeekDay)
|
|
246
|
-
.add(7, 'day')
|
|
247
|
-
.get('date')
|
|
248
|
-
: moment()
|
|
249
|
-
.utc()
|
|
250
|
-
.isoWeekday(isoWeekDay)
|
|
251
|
-
.get('date')))
|
|
252
|
-
.set('hours', dateTime && dateTime.length >= 1 ? Number(dateTime[2]) : 0)
|
|
253
|
-
.set('minutes', dateTime && dateTime.length >= 1 ? Number(dateTime[3]) : 0)
|
|
254
|
-
.set('seconds', 0)
|
|
255
|
-
.set('milliseconds', 0)
|
|
256
|
-
.utcOffset(0));
|
|
257
|
-
}
|
|
258
|
-
else if (rawDate.includes('EDT / ') || rawDate.includes('EST / ')) {
|
|
259
|
-
var dateTime = /E[D|S]T \/ ([0-9]{1,2}):([0-9]{1,2}) UTC/.exec(rawDate);
|
|
260
|
-
// getDateWithHours
|
|
261
|
-
list.push(moment()
|
|
262
|
-
.utc()
|
|
263
|
-
.set('years', Number(((moment().utc().get('hours') > (dateTime && dateTime.length >= 1 ? Number(dateTime[1]) : 0)) || (moment().utc().get('hours') === (dateTime && dateTime.length >= 1 ? Number(dateTime[1]) : 0) && (moment().utc().get('minutes') > (dateTime && dateTime.length >= 1 ? Number(dateTime[2]) : 0))) ? moment().utc().add(1, 'day').get('years') : moment().utc().get('years'))))
|
|
264
|
-
.set('months', Number(((moment().utc().get('hours') > (dateTime && dateTime.length >= 1 ? Number(dateTime[1]) : 0)) || (moment().utc().get('hours') === (dateTime && dateTime.length >= 1 ? Number(dateTime[1]) : 0) && (moment().utc().get('minutes') > (dateTime && dateTime.length >= 1 ? Number(dateTime[2]) : 0))) ? moment().utc().add(1, 'day').get('months') : moment().utc().get('months'))))
|
|
265
|
-
.set('date', Number(((moment().utc().get('hours') > (dateTime && dateTime.length >= 1 ? Number(dateTime[1]) : 0)) || (moment().utc().get('hours') === (dateTime && dateTime.length >= 1 ? Number(dateTime[1]) : 0) && (moment().utc().get('minutes') > (dateTime && dateTime.length >= 1 ? Number(dateTime[2]) : 0))) ? moment().utc().add(1, 'day').get('date') : moment().utc().get('date'))))
|
|
266
|
-
.set('hours', dateTime && dateTime.length >= 1 ? Number(dateTime[1]) : 0)
|
|
267
|
-
.set('minutes', dateTime && dateTime.length >= 1 ? Number(dateTime[2]) : 0)
|
|
268
|
-
.set('seconds', 0)
|
|
269
|
-
.set('milliseconds', 0)
|
|
270
|
-
.utcOffset(0));
|
|
175
|
+
return [ForumMessageElement.getDateWithDayIndex(rawDate)];
|
|
271
176
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (rawDate.includes('UTC (')) {
|
|
275
|
-
dateTime = /([a-zA-Z]{3,9}) ([0-9]{1,2})[ ]?, ([0-9]{1,2}):([0-9]{1,2}) UTC \([0-9]{1,2}:[0-9]{1,2}[a-zA-Z]{1,2} EDT\) [–|-] ([0-9]{1,2}):([0-9]{1,2}) UTC \([0-9]{1,2}:[0-9]{1,2}[a-zA-Z]{1,2} EDT\)/.exec(rawDate);
|
|
276
|
-
}
|
|
277
|
-
var month = Number(moment().month(dateTime && dateTime.length >= 1 ? String(dateTime[1]) : '').format('M')) - 1;
|
|
278
|
-
var day = dateTime && dateTime.length >= 1 ? Number(dateTime[2]) : 0;
|
|
279
|
-
// getDateWithDayNumber
|
|
280
|
-
list.push(moment()
|
|
281
|
-
.utc()
|
|
282
|
-
.set('years', (month < moment().utc().get('months') || day < moment().utc().get('date') ? moment().add(1, 'year').get('years') : moment().get('years')))
|
|
283
|
-
.set('months', month)
|
|
284
|
-
.set('date', day)
|
|
285
|
-
.set('hours', dateTime && dateTime.length >= 1 ? Number(dateTime[3]) : 0)
|
|
286
|
-
.set('minutes', dateTime && dateTime.length >= 1 ? Number(dateTime[4]) : 0)
|
|
287
|
-
.set('seconds', 0)
|
|
288
|
-
.set('milliseconds', 0)
|
|
289
|
-
.utcOffset(0));
|
|
290
|
-
list.push(moment()
|
|
291
|
-
.utc()
|
|
292
|
-
.set('years', (month < moment().utc().get('months') || day < moment().utc().get('date') ? moment().add(1, 'year').get('years') : moment().get('years')))
|
|
293
|
-
.set('months', month)
|
|
294
|
-
.set('date', day)
|
|
295
|
-
.set('hours', dateTime && dateTime.length >= 1 ? Number(dateTime[5]) : 0)
|
|
296
|
-
.set('minutes', dateTime && dateTime.length >= 1 ? Number(dateTime[6]) : 0)
|
|
297
|
-
.set('seconds', 0)
|
|
298
|
-
.set('milliseconds', 0)
|
|
299
|
-
.utcOffset(0));
|
|
177
|
+
if (rawDate.includes('EDT / ') || rawDate.includes('EST / ')) {
|
|
178
|
+
return [ForumMessageElement.getDateWithHours(rawDate)];
|
|
300
179
|
}
|
|
301
|
-
return
|
|
302
|
-
}
|
|
180
|
+
return ForumMessageElement.getDateWithDayNumber(rawDate);
|
|
181
|
+
}
|
|
182
|
+
static getDateWithDayIndex(rawDate) {
|
|
183
|
+
const dateTime = /([a-zA-Z]{6,9}) at \d{1,2}:\d{1,2}[a-zA-Z]{1,2} EDT \((\d{1,2}):(\d{1,2}) UTC\)/.exec(rawDate);
|
|
184
|
+
const isoWeekDay = Number((0, moment_1.default)()
|
|
185
|
+
.day(dateTime && dateTime.length >= 1 ? dateTime[1] : '')
|
|
186
|
+
.format('d'));
|
|
187
|
+
const day = (0, moment_1.default)().utc().isoWeekday() > isoWeekDay
|
|
188
|
+
? (0, moment_1.default)().utc().isoWeekday(isoWeekDay).add(7, 'day')
|
|
189
|
+
: (0, moment_1.default)().utc().isoWeekday(isoWeekDay);
|
|
190
|
+
return ForumMessageElement.buildUtcDate(day.get('months'), day.get('date'), ForumMessageElement.getMatchedNumber(dateTime, 2), ForumMessageElement.getMatchedNumber(dateTime, 3));
|
|
191
|
+
}
|
|
192
|
+
static getDateWithHours(rawDate) {
|
|
193
|
+
const dateTime = /E[D|S]T \/ (\d{1,2}):(\d{1,2}) UTC/.exec(rawDate);
|
|
194
|
+
const hours = ForumMessageElement.getMatchedNumber(dateTime, 1);
|
|
195
|
+
const minutes = ForumMessageElement.getMatchedNumber(dateTime, 2);
|
|
196
|
+
const isTomorrow = (0, moment_1.default)().utc().get('hours') > hours ||
|
|
197
|
+
((0, moment_1.default)().utc().get('hours') === hours &&
|
|
198
|
+
(0, moment_1.default)().utc().get('minutes') > minutes);
|
|
199
|
+
const day = isTomorrow
|
|
200
|
+
? (0, moment_1.default)().utc().add(1, 'day')
|
|
201
|
+
: (0, moment_1.default)().utc();
|
|
202
|
+
return ForumMessageElement.buildUtcDate(day.get('months'), day.get('date'), hours, minutes);
|
|
203
|
+
}
|
|
204
|
+
static getDateWithDayNumber(rawDate) {
|
|
205
|
+
const dateTime = rawDate.includes('UTC (')
|
|
206
|
+
? utcFirstRange.exec(rawDate)
|
|
207
|
+
: edtFirstRange.exec(rawDate);
|
|
208
|
+
const month = Number((0, moment_1.default)()
|
|
209
|
+
.month(dateTime && dateTime.length >= 1 ? dateTime[1] : '')
|
|
210
|
+
.format('M')) - 1;
|
|
211
|
+
const day = ForumMessageElement.getMatchedNumber(dateTime, 2);
|
|
212
|
+
return [
|
|
213
|
+
ForumMessageElement.buildUtcDate(month, day, ForumMessageElement.getMatchedNumber(dateTime, 3), ForumMessageElement.getMatchedNumber(dateTime, 4)),
|
|
214
|
+
ForumMessageElement.buildUtcDate(month, day, ForumMessageElement.getMatchedNumber(dateTime, 5), ForumMessageElement.getMatchedNumber(dateTime, 6)),
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
static getMatchedNumber(dateTime, index) {
|
|
218
|
+
return dateTime && dateTime.length >= 1 ? Number(dateTime[index]) : 0;
|
|
219
|
+
}
|
|
220
|
+
static buildUtcDate(month, date, hours, minutes) {
|
|
221
|
+
return (0, moment_1.default)()
|
|
222
|
+
.utc()
|
|
223
|
+
.set('years', (0, moment_1.default)().get('years'))
|
|
224
|
+
.set('months', month)
|
|
225
|
+
.set('date', date)
|
|
226
|
+
.set('hours', hours)
|
|
227
|
+
.set('minutes', minutes)
|
|
228
|
+
.set('seconds', 0)
|
|
229
|
+
.set('milliseconds', 0)
|
|
230
|
+
.utcOffset(0);
|
|
231
|
+
}
|
|
303
232
|
/**
|
|
304
233
|
* Methode used to get type of slug
|
|
305
234
|
*
|
|
@@ -309,9 +238,9 @@ var ForumMessageElement = /** @class */ (function () {
|
|
|
309
238
|
* @param slug Slug Slug
|
|
310
239
|
* @return Type Type of slug
|
|
311
240
|
*/
|
|
312
|
-
|
|
241
|
+
static getType(slug) {
|
|
313
242
|
return slug.split('_')[0];
|
|
314
|
-
}
|
|
243
|
+
}
|
|
315
244
|
/**
|
|
316
245
|
* Methode used to get support of slug
|
|
317
246
|
*
|
|
@@ -321,9 +250,9 @@ var ForumMessageElement = /** @class */ (function () {
|
|
|
321
250
|
* @param slug Slug Slug
|
|
322
251
|
* @return Support Support of slug
|
|
323
252
|
*/
|
|
324
|
-
|
|
253
|
+
static getSupport(slug) {
|
|
325
254
|
return slug.split('_')[1];
|
|
326
|
-
}
|
|
255
|
+
}
|
|
327
256
|
/**
|
|
328
257
|
* Methode used to get zone of slug
|
|
329
258
|
*
|
|
@@ -333,9 +262,9 @@ var ForumMessageElement = /** @class */ (function () {
|
|
|
333
262
|
* @param slug Slug Slug
|
|
334
263
|
* @return Zone Zone of slug
|
|
335
264
|
*/
|
|
336
|
-
|
|
265
|
+
static getZone(slug) {
|
|
337
266
|
return slug.split('_')[2];
|
|
338
|
-
}
|
|
267
|
+
}
|
|
339
268
|
/**
|
|
340
269
|
* Methode used to get status of raw data
|
|
341
270
|
*
|
|
@@ -345,21 +274,32 @@ var ForumMessageElement = /** @class */ (function () {
|
|
|
345
274
|
* @param rawData string Raw data
|
|
346
275
|
* @return Status Status of raw data
|
|
347
276
|
*/
|
|
348
|
-
|
|
349
|
-
if (rawData.includes('unavailable') ||
|
|
277
|
+
static getStatus(rawData) {
|
|
278
|
+
if (rawData.includes('unavailable') ||
|
|
279
|
+
rawData.includes('[IN PROGRESS]') ||
|
|
280
|
+
rawData.includes('[EXTENDED]')) {
|
|
350
281
|
return 'down';
|
|
351
282
|
}
|
|
352
|
-
if (rawData.includes('[COMPLETE]') ||
|
|
283
|
+
if (rawData.includes('[COMPLETE]') ||
|
|
284
|
+
rawData.includes('is now available') ||
|
|
285
|
+
rawData.includes('are now available') ||
|
|
286
|
+
rawData.includes('maintenance is complete') ||
|
|
287
|
+
rawData.includes('resolved at this time') ||
|
|
288
|
+
rawData.includes('has been resolved') ||
|
|
289
|
+
rawData.includes('currently available.')) {
|
|
353
290
|
return 'up';
|
|
354
291
|
}
|
|
355
|
-
if (rawData.includes('currently investigating issues') ||
|
|
292
|
+
if (rawData.includes('currently investigating issues') ||
|
|
293
|
+
rawData.includes('service interruption') ||
|
|
294
|
+
rawData.includes('In response to the ongoing issue') ||
|
|
295
|
+
rawData.includes('Due to a hardware issue')) {
|
|
356
296
|
return 'issues';
|
|
357
297
|
}
|
|
358
298
|
if (rawData.includes('UTC')) {
|
|
359
299
|
return 'planned';
|
|
360
300
|
}
|
|
361
301
|
return 'down';
|
|
362
|
-
}
|
|
302
|
+
}
|
|
363
303
|
/**
|
|
364
304
|
* Methode used to get raw date of raw data
|
|
365
305
|
*
|
|
@@ -369,27 +309,26 @@ var ForumMessageElement = /** @class */ (function () {
|
|
|
369
309
|
* @param raw string Raw data
|
|
370
310
|
* @return string Raw date
|
|
371
311
|
*/
|
|
372
|
-
|
|
312
|
+
static getRawDate(raw) {
|
|
373
313
|
if (raw.includes('maintenance – ')) {
|
|
374
|
-
|
|
314
|
+
const split = raw.split('maintenance – ');
|
|
375
315
|
if (split.length === 2) {
|
|
376
316
|
return split[1];
|
|
377
317
|
}
|
|
378
318
|
}
|
|
379
319
|
if (raw.includes('on the PTS on ')) {
|
|
380
|
-
|
|
320
|
+
const split = raw.split('on the PTS on ');
|
|
381
321
|
if (split.length === 2) {
|
|
382
322
|
return split[1];
|
|
383
323
|
}
|
|
384
324
|
}
|
|
385
325
|
if (raw.includes('for maintenance at')) {
|
|
386
|
-
|
|
326
|
+
const split = raw.split('for maintenance at ');
|
|
387
327
|
if (split.length === 2) {
|
|
388
328
|
return split[1];
|
|
389
329
|
}
|
|
390
330
|
}
|
|
391
331
|
return '';
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
}());
|
|
332
|
+
}
|
|
333
|
+
}
|
|
395
334
|
exports.default = ForumMessageElement;
|
|
@@ -1,49 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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
|
-
|
|
40
|
-
|
|
6
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
const ForumMessageElement_1 = __importDefault(require("../classes/ForumMessageElement"));
|
|
41
8
|
/**
|
|
42
9
|
* Connector used to get data from https://forums.elderscrollsonline.com/ and https://forums.elderscrollsonline.com/en/categories/pts
|
|
43
10
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
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 ForumMessageConnector {
|
|
47
13
|
/**
|
|
48
14
|
* Methode used to get the list of raw element from remote website
|
|
49
15
|
*
|
|
@@ -54,28 +20,19 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
54
20
|
*
|
|
55
21
|
* @return Promise<RawEsoStatus[]> List of raw element from remote website
|
|
56
22
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return [2 /*return*/, sortedRawMessageList.map(function (item) { return ({
|
|
71
|
-
sources: [url],
|
|
72
|
-
raw: [item],
|
|
73
|
-
slugs: [],
|
|
74
|
-
}); })];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
};
|
|
23
|
+
static async getRemoteContent(url) {
|
|
24
|
+
const rawRemoteContent = await ForumMessageConnector.getRawRemoteContent(url);
|
|
25
|
+
const rawWarningMessage = ForumMessageConnector.getRawWarningMessage(rawRemoteContent);
|
|
26
|
+
const rawAlertMessage = ForumMessageConnector.getRawAlertMessage(rawRemoteContent);
|
|
27
|
+
const mergedRawMessage = ForumMessageConnector.mergeRawMessage(rawWarningMessage, rawAlertMessage);
|
|
28
|
+
const rawMessageSplit = ForumMessageConnector.splitRawMessage(mergedRawMessage);
|
|
29
|
+
const sortedRawMessageList = ForumMessageConnector.sortRawMessageList(rawMessageSplit);
|
|
30
|
+
return sortedRawMessageList.map((item) => ({
|
|
31
|
+
sources: [url],
|
|
32
|
+
raw: [item],
|
|
33
|
+
slugs: [],
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
79
36
|
/**
|
|
80
37
|
* Methode used to get raw content from remote specific url
|
|
81
38
|
*
|
|
@@ -85,19 +42,10 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
85
42
|
* @param url string Url to use to get list of raw element from remote specific url
|
|
86
43
|
* @return Promise<string> Raw content from remote specific url
|
|
87
44
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
switch (_a.label) {
|
|
93
|
-
case 0: return [4 /*yield*/, axios.get(url)];
|
|
94
|
-
case 1:
|
|
95
|
-
response = _a.sent();
|
|
96
|
-
return [2 /*return*/, (response === null || response === void 0 ? void 0 : response.status) === 200 && !(!(response === null || response === void 0 ? void 0 : response.data)) ? String(response === null || response === void 0 ? void 0 : response.data) : ''];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
};
|
|
45
|
+
static async getRawRemoteContent(url) {
|
|
46
|
+
const response = await axios_1.default.get(url);
|
|
47
|
+
return response.status === 200 && response.data ? response.data : '';
|
|
48
|
+
}
|
|
101
49
|
/**
|
|
102
50
|
* Methode used to get raw warning message from raw content
|
|
103
51
|
*
|
|
@@ -107,18 +55,19 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
107
55
|
* @param rawRemoteContent string Raw content from remote specific url
|
|
108
56
|
* @return string Raw warning message from raw content
|
|
109
57
|
*/
|
|
110
|
-
|
|
111
|
-
return rawRemoteContent
|
|
112
|
-
.
|
|
113
|
-
.
|
|
114
|
-
|
|
58
|
+
static getRawWarningMessage(rawRemoteContent) {
|
|
59
|
+
return rawRemoteContent
|
|
60
|
+
.split('<div class="DismissMessage WarningMessage">')
|
|
61
|
+
.filter((item, index) => index !== 0)
|
|
62
|
+
.map((item) => {
|
|
63
|
+
const resultRemoveAfter = item.split('</div>');
|
|
115
64
|
if (resultRemoveAfter.length >= 2) {
|
|
116
65
|
return resultRemoveAfter[0];
|
|
117
66
|
}
|
|
118
67
|
return '';
|
|
119
68
|
})
|
|
120
69
|
.join('<br />');
|
|
121
|
-
}
|
|
70
|
+
}
|
|
122
71
|
/**
|
|
123
72
|
* Methode used to get raw alert message from raw content
|
|
124
73
|
*
|
|
@@ -128,18 +77,19 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
128
77
|
* @param rawRemoteContent string Raw content from remote specific url
|
|
129
78
|
* @return string Raw alert message from raw content
|
|
130
79
|
*/
|
|
131
|
-
|
|
132
|
-
return rawRemoteContent
|
|
133
|
-
.
|
|
134
|
-
.
|
|
135
|
-
|
|
80
|
+
static getRawAlertMessage(rawRemoteContent) {
|
|
81
|
+
return rawRemoteContent
|
|
82
|
+
.split('<div class="DismissMessage AlertMessage">')
|
|
83
|
+
.filter((item, index) => index !== 0)
|
|
84
|
+
.map((item) => {
|
|
85
|
+
const resultRemoveAfter = item.split('</div>');
|
|
136
86
|
if (resultRemoveAfter.length >= 2) {
|
|
137
87
|
return resultRemoveAfter[0];
|
|
138
88
|
}
|
|
139
89
|
return '';
|
|
140
90
|
})
|
|
141
91
|
.join('<br />');
|
|
142
|
-
}
|
|
92
|
+
}
|
|
143
93
|
/**
|
|
144
94
|
* Methode used to get merge off all message
|
|
145
95
|
*
|
|
@@ -149,13 +99,9 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
149
99
|
* @param rawMessages string[] All message
|
|
150
100
|
* @return string Merge off all message
|
|
151
101
|
*/
|
|
152
|
-
|
|
153
|
-
var rawMessages = [];
|
|
154
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
155
|
-
rawMessages[_i] = arguments[_i];
|
|
156
|
-
}
|
|
102
|
+
static mergeRawMessage(...rawMessages) {
|
|
157
103
|
return rawMessages.join('<br />');
|
|
158
|
-
}
|
|
104
|
+
}
|
|
159
105
|
/**
|
|
160
106
|
* Methode used to split raw content
|
|
161
107
|
*
|
|
@@ -165,13 +111,13 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
165
111
|
* @param mergedRawMessage string All message merged
|
|
166
112
|
* @return string[] Split raw content
|
|
167
113
|
*/
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
mergedRawMessage.split('<br />').forEach(
|
|
171
|
-
list.push
|
|
114
|
+
static splitRawMessage(mergedRawMessage) {
|
|
115
|
+
const list = [];
|
|
116
|
+
mergedRawMessage.split('<br />').forEach((item) => {
|
|
117
|
+
list.push(...item.split('<br/>'));
|
|
172
118
|
});
|
|
173
119
|
return list;
|
|
174
|
-
}
|
|
120
|
+
}
|
|
175
121
|
/**
|
|
176
122
|
* Methode used to sort raw content list
|
|
177
123
|
*
|
|
@@ -181,19 +127,19 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
181
127
|
* @param rawMessageSplit string Split raw content
|
|
182
128
|
* @return string[] Sort raw content list
|
|
183
129
|
*/
|
|
184
|
-
|
|
130
|
+
static sortRawMessageList(rawMessageSplit) {
|
|
185
131
|
return rawMessageSplit
|
|
186
|
-
.filter(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
.map(
|
|
191
|
-
|
|
132
|
+
.filter((item) => item !== '' &&
|
|
133
|
+
!item.includes('Maintenance for the week') &&
|
|
134
|
+
!item.includes('No maintenance') &&
|
|
135
|
+
!item.includes('PC/Mac: No NA megaserver maintenance'))
|
|
136
|
+
.map((item) => {
|
|
137
|
+
let line = item;
|
|
192
138
|
line = line.replace('\n', '');
|
|
193
139
|
return line;
|
|
194
140
|
})
|
|
195
|
-
.filter(
|
|
196
|
-
}
|
|
141
|
+
.filter((item) => item !== '' && item !== ' ');
|
|
142
|
+
}
|
|
197
143
|
/**
|
|
198
144
|
* Methode used to get slug for raw content list
|
|
199
145
|
*
|
|
@@ -203,13 +149,13 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
203
149
|
* @param remoteContent RawEsoStatus[] Raw content list without duplicate
|
|
204
150
|
* @return RawEsoStatus[] Raw content list with slug list
|
|
205
151
|
*/
|
|
206
|
-
|
|
207
|
-
return remoteContent.map(
|
|
152
|
+
static getRawContentWithSlug(remoteContent) {
|
|
153
|
+
return remoteContent.map((item) => ({
|
|
208
154
|
sources: item.sources,
|
|
209
155
|
raw: item.raw,
|
|
210
156
|
slugs: ForumMessageElement_1.default.getSlug(item.raw[0]),
|
|
211
|
-
})
|
|
212
|
-
}
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
213
159
|
/**
|
|
214
160
|
* Methode used to split list by slug
|
|
215
161
|
*
|
|
@@ -219,11 +165,10 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
219
165
|
* @param slugOfRawContent RawEsoStatus[] Raw content list with slug list
|
|
220
166
|
* @return RawEsoStatus[] Raw content list foreach slug
|
|
221
167
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
slugOfRawContent.forEach(
|
|
225
|
-
|
|
226
|
-
(_a = item.slugs) === null || _a === void 0 ? void 0 : _a.forEach(function (slug) {
|
|
168
|
+
static splitRawContentBySlug(slugOfRawContent) {
|
|
169
|
+
const list = [];
|
|
170
|
+
slugOfRawContent.forEach((item) => {
|
|
171
|
+
item.slugs?.forEach((slug) => {
|
|
227
172
|
list.push({
|
|
228
173
|
sources: item.sources,
|
|
229
174
|
raw: item.raw,
|
|
@@ -232,7 +177,7 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
232
177
|
});
|
|
233
178
|
});
|
|
234
179
|
return list;
|
|
235
|
-
}
|
|
180
|
+
}
|
|
236
181
|
/**
|
|
237
182
|
* Methode used to get raw date for raw content list
|
|
238
183
|
*
|
|
@@ -242,14 +187,14 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
242
187
|
* @param rawContentBySlug RawEsoStatus[] Raw content list foreach slug
|
|
243
188
|
* @return RawEsoStatus[] Raw content list with raw date
|
|
244
189
|
*/
|
|
245
|
-
|
|
246
|
-
return rawContentBySlug.map(
|
|
190
|
+
static getRawContentWithRawDate(rawContentBySlug) {
|
|
191
|
+
return rawContentBySlug.map((item) => ({
|
|
247
192
|
sources: item.sources,
|
|
248
193
|
raw: item.raw,
|
|
249
194
|
slugs: item.slugs,
|
|
250
195
|
rawDate: ForumMessageElement_1.default.getRawDate(item.raw[0]),
|
|
251
|
-
})
|
|
252
|
-
}
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
253
198
|
/**
|
|
254
199
|
* Methode used to get data for each raw element
|
|
255
200
|
*
|
|
@@ -259,22 +204,19 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
259
204
|
* @param rawContentWithRawDate RawEsoStatus[] Raw content list with raw date
|
|
260
205
|
* @return RawEsoStatus[] Raw content list with data
|
|
261
206
|
*/
|
|
262
|
-
|
|
263
|
-
return rawContentWithRawDate.map(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
};
|
|
207
|
+
static getData(rawContentWithRawDate) {
|
|
208
|
+
return rawContentWithRawDate.map((item) => ({
|
|
209
|
+
sources: item.sources,
|
|
210
|
+
raw: item.raw,
|
|
211
|
+
slugs: item.slugs,
|
|
212
|
+
rawDate: item.rawDate,
|
|
213
|
+
dates: ForumMessageElement_1.default.getDate(item.rawDate ?? ''),
|
|
214
|
+
type: ForumMessageElement_1.default.getType(item.slugs ? item.slugs[0] : 'undefined'),
|
|
215
|
+
support: ForumMessageElement_1.default.getSupport(item.slugs ? item.slugs[0] : 'undefined'),
|
|
216
|
+
zone: ForumMessageElement_1.default.getZone(item.slugs ? item.slugs[0] : 'undefined'),
|
|
217
|
+
status: ForumMessageElement_1.default.getStatus(item.raw[0]),
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
278
220
|
/**
|
|
279
221
|
* Methode used to get data sort by status
|
|
280
222
|
*
|
|
@@ -284,28 +226,32 @@ var ForumMessageConnector = /** @class */ (function () {
|
|
|
284
226
|
* @param data RawEsoStatus[] Raw content list with data
|
|
285
227
|
* @return RawEsoStatus[] Data sorted by status
|
|
286
228
|
*/
|
|
287
|
-
|
|
288
|
-
return data.filter(
|
|
289
|
-
if (data.filter(
|
|
290
|
-
if (item.raw.includes('will be taken offline for maintenance') &&
|
|
229
|
+
static sortData(data) {
|
|
230
|
+
return data.filter((item) => {
|
|
231
|
+
if (data.filter((i) => JSON.stringify(i.slugs) === JSON.stringify(item.slugs)).length !== 1) {
|
|
232
|
+
if (item.raw.includes('will be taken offline for maintenance') &&
|
|
233
|
+
data.filter((i) => JSON.stringify(i.slugs) === JSON.stringify(item.slugs) &&
|
|
234
|
+
i.raw.includes('is currently unavailable')).length !== 0) {
|
|
291
235
|
return false;
|
|
292
236
|
}
|
|
293
|
-
if (item.raw.includes('[IN PROGRESS]') &&
|
|
237
|
+
if (item.raw.includes('[IN PROGRESS]') &&
|
|
238
|
+
data.filter((i) => JSON.stringify(i.slugs) === JSON.stringify(item.slugs) &&
|
|
239
|
+
i.raw.includes('[COMPLETE]')).length !== 0) {
|
|
294
240
|
return false;
|
|
295
241
|
}
|
|
296
|
-
if (item.status === 'planned' &&
|
|
242
|
+
if (item.status === 'planned' &&
|
|
243
|
+
data.filter((i) => JSON.stringify(i.slugs) === JSON.stringify(item.slugs) &&
|
|
244
|
+
i.raw.includes('[IN PROGRESS]')).length !== 0) {
|
|
297
245
|
return false;
|
|
298
246
|
}
|
|
299
|
-
if (item.raw.includes('resolved at this time') &&
|
|
247
|
+
if (item.raw.includes('resolved at this time') &&
|
|
248
|
+
data.filter((i) => JSON.stringify(i.slugs) === JSON.stringify(item.slugs) &&
|
|
249
|
+
i.raw.includes('[IN PROGRESS]')).length !== 0) {
|
|
300
250
|
return false;
|
|
301
251
|
}
|
|
302
252
|
}
|
|
303
|
-
|
|
304
|
-
return false;
|
|
305
|
-
}
|
|
306
|
-
return true;
|
|
253
|
+
return !item.raw.includes('<a');
|
|
307
254
|
});
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
}());
|
|
255
|
+
}
|
|
256
|
+
}
|
|
311
257
|
exports.default = ForumMessageConnector;
|
package/lib/index.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ export declare const ForumMessagePTSURL = "https://forums.elderscrollsonline.com
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class ForumMessage {
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
* Methode used to get Forum Message data
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
* @static
|
|
13
|
+
*
|
|
14
|
+
* @return Promise<RawEsoStatus[]> Forum Message elements
|
|
15
|
+
*/
|
|
16
16
|
static getData(url?: string): Promise<RawEsoStatus[]>;
|
|
17
17
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,77 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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.ForumMessage = exports.ForumMessagePTSURL = exports.ForumMessageURL = void 0;
|
|
40
|
-
|
|
7
|
+
const ForumMessageConnector_1 = __importDefault(require("./connectors/ForumMessageConnector"));
|
|
41
8
|
exports.ForumMessageURL = 'https://forums.elderscrollsonline.com/';
|
|
42
9
|
exports.ForumMessagePTSURL = 'https://forums.elderscrollsonline.com/en/categories/pts';
|
|
43
10
|
/**
|
|
44
11
|
* Class of Forum Message
|
|
45
12
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
13
|
+
// 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
|
|
14
|
+
class ForumMessage {
|
|
49
15
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
slugOfRawContent = ForumMessageConnector_1.default.getRawContentWithSlug(remoteContent);
|
|
67
|
-
rawContentBySlug = ForumMessageConnector_1.default.splitRawContentBySlug(slugOfRawContent);
|
|
68
|
-
rawContentWithRawDate = ForumMessageConnector_1.default.getRawContentWithRawDate(rawContentBySlug);
|
|
69
|
-
data = ForumMessageConnector_1.default.getData(rawContentWithRawDate);
|
|
70
|
-
return [2 /*return*/, ForumMessageConnector_1.default.sortData(data)];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
return ForumMessage;
|
|
76
|
-
}());
|
|
16
|
+
* Methode used to get Forum Message data
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
* @static
|
|
20
|
+
*
|
|
21
|
+
* @return Promise<RawEsoStatus[]> Forum Message elements
|
|
22
|
+
*/
|
|
23
|
+
static async getData(url = exports.ForumMessageURL) {
|
|
24
|
+
const remoteContent = await ForumMessageConnector_1.default.getRemoteContent(url);
|
|
25
|
+
const slugOfRawContent = ForumMessageConnector_1.default.getRawContentWithSlug(remoteContent);
|
|
26
|
+
const rawContentBySlug = ForumMessageConnector_1.default.splitRawContentBySlug(slugOfRawContent);
|
|
27
|
+
const rawContentWithRawDate = ForumMessageConnector_1.default.getRawContentWithRawDate(rawContentBySlug);
|
|
28
|
+
const data = ForumMessageConnector_1.default.getData(rawContentWithRawDate);
|
|
29
|
+
return ForumMessageConnector_1.default.sortData(data);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
77
32
|
exports.ForumMessage = ForumMessage;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eso-status/forum-message",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Library used to get servers status of The elders scrolls Online game with https://forums.elderscrollsonline.com/ and https://forums.elderscrollsonline.com/en/categories/pts",
|
|
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 .",
|
|
@@ -33,32 +34,38 @@
|
|
|
33
34
|
},
|
|
34
35
|
"repository": {
|
|
35
36
|
"type": "git",
|
|
36
|
-
"url": "git
|
|
37
|
+
"url": "git+https://github.com/eso-status/forum-message.git"
|
|
37
38
|
},
|
|
38
39
|
"author": "@dov118 <contact@dov118.dev> (https://dov118.dev)",
|
|
39
40
|
"license": "MIT",
|
|
40
41
|
"bugs": {
|
|
41
|
-
"url": "https://github.com/eso-status/forum-message
|
|
42
|
+
"url": "https://github.com/eso-status/forum-message/issues"
|
|
42
43
|
},
|
|
43
|
-
"homepage": "https://github.com/eso-status/forum-message
|
|
44
|
+
"homepage": "https://github.com/eso-status/forum-message#readme",
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@types
|
|
47
|
-
"@types/
|
|
48
|
-
"@
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"eslint": "
|
|
52
|
-
"eslint-
|
|
53
|
-
"eslint-plugin-
|
|
54
|
-
"
|
|
55
|
-
"jest": "
|
|
56
|
-
"nodemon": "3.1.
|
|
57
|
-
"
|
|
58
|
-
"
|
|
46
|
+
"@eslint/js": "10.0.1",
|
|
47
|
+
"@eso-status/types": "1.0.8",
|
|
48
|
+
"@types/jest": "30.0.0",
|
|
49
|
+
"@types/node": "26.6.6",
|
|
50
|
+
"eslint": "10.15.0",
|
|
51
|
+
"eslint-config-prettier": "10.1.8",
|
|
52
|
+
"eslint-plugin-jest": "29.17.0",
|
|
53
|
+
"eslint-plugin-sonarjs": "4.2.2",
|
|
54
|
+
"eslint-plugin-unused-imports": "4.4.1",
|
|
55
|
+
"globals": "17.14.0",
|
|
56
|
+
"jest": "30.5.2",
|
|
57
|
+
"nodemon": "3.1.14",
|
|
58
|
+
"prettier": "3.10.1",
|
|
59
|
+
"ts-jest": "29.4.15",
|
|
60
|
+
"typescript": "6.0.3",
|
|
61
|
+
"typescript-eslint": "8.72.2"
|
|
59
62
|
},
|
|
60
63
|
"dependencies": {
|
|
61
|
-
"axios": "1.
|
|
62
|
-
"moment": "2.
|
|
64
|
+
"axios": "1.21.1",
|
|
65
|
+
"moment": "2.31.0"
|
|
66
|
+
},
|
|
67
|
+
"overrides": {
|
|
68
|
+
"glob": "14.0.6",
|
|
69
|
+
"minimatch": "11.0.8"
|
|
63
70
|
}
|
|
64
71
|
}
|