@eso-status/forum-message 1.0.13 → 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 +100 -93
- package/lib/connector.d.ts +68 -0
- package/lib/connector.js +122 -0
- package/lib/const.d.ts +9 -0
- package/lib/const.js +12 -0
- package/lib/formatter/date.formatter.d.ts +97 -0
- package/lib/formatter/date.formatter.js +161 -0
- package/lib/identifier/slug.identifier.d.ts +94 -0
- package/lib/identifier/slug.identifier.js +139 -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 +63 -0
- package/lib/identifier/status.identifier.js +85 -0
- package/lib/index.d.ts +11 -13
- package/lib/index.js +14 -72
- package/lib/raw.d.ts +42 -0
- package/lib/raw.js +58 -0
- package/lib/type/messageType.type.d.ts +4 -0
- package/lib/type/messageType.type.js +3 -0
- package/lib/type/remoteDownRawStatus.type.d.ts +4 -0
- package/lib/type/remoteDownRawStatus.type.js +3 -0
- package/lib/type/remotePlannedRawStatus.type.d.ts +4 -0
- package/lib/type/remotePlannedRawStatus.type.js +3 -0
- package/lib/type/remoteRawSlug.type.d.ts +11 -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/remoteServiceWebSiteRawSlug.type.d.ts +4 -0
- package/lib/type/remoteServiceWebSiteRawSlug.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 +110 -37
- package/lib/classes/ForumMessageElement.d.ts +0 -110
- package/lib/classes/ForumMessageElement.js +0 -386
- package/lib/connectors/ForumMessageConnector.d.ts +0 -127
- package/lib/connectors/ForumMessageConnector.js +0 -311
|
@@ -1,311 +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 ForumMessageElement_1 = require("../classes/ForumMessageElement");
|
|
40
|
-
var axios = require('axios');
|
|
41
|
-
/**
|
|
42
|
-
* Connector used to get data from https://forums.elderscrollsonline.com/ and https://forums.elderscrollsonline.com/en/categories/pts
|
|
43
|
-
*/
|
|
44
|
-
var ForumMessageConnector = /** @class */ (function () {
|
|
45
|
-
function ForumMessageConnector() {
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Methode used to get the list of raw element from remote website
|
|
49
|
-
*
|
|
50
|
-
* @public
|
|
51
|
-
* @static
|
|
52
|
-
*
|
|
53
|
-
* @param url string Url to use to get list of raw element from remote specific url
|
|
54
|
-
*
|
|
55
|
-
* @return Promise<RawEsoStatus[]> List of raw element from remote website
|
|
56
|
-
*/
|
|
57
|
-
ForumMessageConnector.getRemoteContent = function (url) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
-
var rawRemoteContent, rawWarningMessage, rawAlertMessage, mergedRawMessage, rawMessageSplit, sortedRawMessageList;
|
|
60
|
-
return __generator(this, function (_a) {
|
|
61
|
-
switch (_a.label) {
|
|
62
|
-
case 0: return [4 /*yield*/, ForumMessageConnector.getRawRemoteContent(url)];
|
|
63
|
-
case 1:
|
|
64
|
-
rawRemoteContent = _a.sent();
|
|
65
|
-
rawWarningMessage = ForumMessageConnector.getRawWarningMessage(rawRemoteContent);
|
|
66
|
-
rawAlertMessage = ForumMessageConnector.getRawAlertMessage(rawRemoteContent);
|
|
67
|
-
mergedRawMessage = ForumMessageConnector.mergeRawMessage(rawWarningMessage, rawAlertMessage);
|
|
68
|
-
rawMessageSplit = ForumMessageConnector.splitRawMessage(mergedRawMessage);
|
|
69
|
-
sortedRawMessageList = ForumMessageConnector.sortRawMessageList(rawMessageSplit);
|
|
70
|
-
return [2 /*return*/, sortedRawMessageList.map(function (item) { return ({
|
|
71
|
-
sources: [url],
|
|
72
|
-
raw: [item],
|
|
73
|
-
slugs: [],
|
|
74
|
-
}); })];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Methode used to get raw content from remote specific url
|
|
81
|
-
*
|
|
82
|
-
* @public
|
|
83
|
-
* @static
|
|
84
|
-
*
|
|
85
|
-
* @param url string Url to use to get list of raw element from remote specific url
|
|
86
|
-
* @return Promise<string> Raw content from remote specific url
|
|
87
|
-
*/
|
|
88
|
-
ForumMessageConnector.getRawRemoteContent = function (url) {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
-
var response;
|
|
91
|
-
return __generator(this, function (_a) {
|
|
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
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Methode used to get raw warning message from raw content
|
|
103
|
-
*
|
|
104
|
-
* @public
|
|
105
|
-
* @static
|
|
106
|
-
*
|
|
107
|
-
* @param rawRemoteContent string Raw content from remote specific url
|
|
108
|
-
* @return string Raw warning message from raw content
|
|
109
|
-
*/
|
|
110
|
-
ForumMessageConnector.getRawWarningMessage = function (rawRemoteContent) {
|
|
111
|
-
return rawRemoteContent.split('<div class="DismissMessage WarningMessage">')
|
|
112
|
-
.filter(function (item, index) { return index !== 0; })
|
|
113
|
-
.map(function (item) {
|
|
114
|
-
var resultRemoveAfter = item.split('</div>');
|
|
115
|
-
if (resultRemoveAfter.length >= 2) {
|
|
116
|
-
return resultRemoveAfter[0];
|
|
117
|
-
}
|
|
118
|
-
return '';
|
|
119
|
-
})
|
|
120
|
-
.join('<br />');
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Methode used to get raw alert message from raw content
|
|
124
|
-
*
|
|
125
|
-
* @public
|
|
126
|
-
* @static
|
|
127
|
-
*
|
|
128
|
-
* @param rawRemoteContent string Raw content from remote specific url
|
|
129
|
-
* @return string Raw alert message from raw content
|
|
130
|
-
*/
|
|
131
|
-
ForumMessageConnector.getRawAlertMessage = function (rawRemoteContent) {
|
|
132
|
-
return rawRemoteContent.split('<div class="DismissMessage AlertMessage">')
|
|
133
|
-
.filter(function (item, index) { return index !== 0; })
|
|
134
|
-
.map(function (item) {
|
|
135
|
-
var resultRemoveAfter = item.split('</div>');
|
|
136
|
-
if (resultRemoveAfter.length >= 2) {
|
|
137
|
-
return resultRemoveAfter[0];
|
|
138
|
-
}
|
|
139
|
-
return '';
|
|
140
|
-
})
|
|
141
|
-
.join('<br />');
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* Methode used to get merge off all message
|
|
145
|
-
*
|
|
146
|
-
* @public
|
|
147
|
-
* @static
|
|
148
|
-
*
|
|
149
|
-
* @param rawMessages string[] All message
|
|
150
|
-
* @return string Merge off all message
|
|
151
|
-
*/
|
|
152
|
-
ForumMessageConnector.mergeRawMessage = function () {
|
|
153
|
-
var rawMessages = [];
|
|
154
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
155
|
-
rawMessages[_i] = arguments[_i];
|
|
156
|
-
}
|
|
157
|
-
return rawMessages.join('<br />');
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Methode used to split raw content
|
|
161
|
-
*
|
|
162
|
-
* @public
|
|
163
|
-
* @static
|
|
164
|
-
*
|
|
165
|
-
* @param mergedRawMessage string All message merged
|
|
166
|
-
* @return string[] Split raw content
|
|
167
|
-
*/
|
|
168
|
-
ForumMessageConnector.splitRawMessage = function (mergedRawMessage) {
|
|
169
|
-
var list = [];
|
|
170
|
-
mergedRawMessage.split('<br />').forEach(function (item) {
|
|
171
|
-
list.push.apply(list, item.split('<br/>'));
|
|
172
|
-
});
|
|
173
|
-
return list;
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* Methode used to sort raw content list
|
|
177
|
-
*
|
|
178
|
-
* @public
|
|
179
|
-
* @static
|
|
180
|
-
*
|
|
181
|
-
* @param rawMessageSplit string Split raw content
|
|
182
|
-
* @return string[] Sort raw content list
|
|
183
|
-
*/
|
|
184
|
-
ForumMessageConnector.sortRawMessageList = function (rawMessageSplit) {
|
|
185
|
-
return rawMessageSplit
|
|
186
|
-
.filter(function (item) { return item !== ''
|
|
187
|
-
&& !item.includes('Maintenance for the week')
|
|
188
|
-
&& !item.includes('No maintenance')
|
|
189
|
-
&& !item.includes('PC/Mac: No NA megaserver maintenance'); })
|
|
190
|
-
.map(function (item) {
|
|
191
|
-
var line = item;
|
|
192
|
-
line = line.replace('\n', '');
|
|
193
|
-
return line;
|
|
194
|
-
})
|
|
195
|
-
.filter(function (item) { return item !== '' && item !== ' '; });
|
|
196
|
-
};
|
|
197
|
-
/**
|
|
198
|
-
* Methode used to get slug for raw content list
|
|
199
|
-
*
|
|
200
|
-
* @public
|
|
201
|
-
* @static
|
|
202
|
-
*
|
|
203
|
-
* @param remoteContent RawEsoStatus[] Raw content list without duplicate
|
|
204
|
-
* @return RawEsoStatus[] Raw content list with slug list
|
|
205
|
-
*/
|
|
206
|
-
ForumMessageConnector.getRawContentWithSlug = function (remoteContent) {
|
|
207
|
-
return remoteContent.map(function (item) { return ({
|
|
208
|
-
sources: item.sources,
|
|
209
|
-
raw: item.raw,
|
|
210
|
-
slugs: ForumMessageElement_1.default.getSlug(item.raw[0]),
|
|
211
|
-
}); });
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* Methode used to split list by slug
|
|
215
|
-
*
|
|
216
|
-
* @public
|
|
217
|
-
* @static
|
|
218
|
-
*
|
|
219
|
-
* @param slugOfRawContent RawEsoStatus[] Raw content list with slug list
|
|
220
|
-
* @return RawEsoStatus[] Raw content list foreach slug
|
|
221
|
-
*/
|
|
222
|
-
ForumMessageConnector.splitRawContentBySlug = function (slugOfRawContent) {
|
|
223
|
-
var list = [];
|
|
224
|
-
slugOfRawContent.forEach(function (item) {
|
|
225
|
-
var _a;
|
|
226
|
-
(_a = item.slugs) === null || _a === void 0 ? void 0 : _a.forEach(function (slug) {
|
|
227
|
-
list.push({
|
|
228
|
-
sources: item.sources,
|
|
229
|
-
raw: item.raw,
|
|
230
|
-
slugs: [slug],
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
return list;
|
|
235
|
-
};
|
|
236
|
-
/**
|
|
237
|
-
* Methode used to get raw date for raw content list
|
|
238
|
-
*
|
|
239
|
-
* @public
|
|
240
|
-
* @static
|
|
241
|
-
*
|
|
242
|
-
* @param rawContentBySlug RawEsoStatus[] Raw content list foreach slug
|
|
243
|
-
* @return RawEsoStatus[] Raw content list with raw date
|
|
244
|
-
*/
|
|
245
|
-
ForumMessageConnector.getRawContentWithRawDate = function (rawContentBySlug) {
|
|
246
|
-
return rawContentBySlug.map(function (item) { return ({
|
|
247
|
-
sources: item.sources,
|
|
248
|
-
raw: item.raw,
|
|
249
|
-
slugs: item.slugs,
|
|
250
|
-
rawDate: ForumMessageElement_1.default.getRawDate(item.raw[0]),
|
|
251
|
-
}); });
|
|
252
|
-
};
|
|
253
|
-
/**
|
|
254
|
-
* Methode used to get data for each raw element
|
|
255
|
-
*
|
|
256
|
-
* @public
|
|
257
|
-
* @static
|
|
258
|
-
*
|
|
259
|
-
* @param rawContentWithRawDate RawEsoStatus[] Raw content list with raw date
|
|
260
|
-
* @return RawEsoStatus[] Raw content list with data
|
|
261
|
-
*/
|
|
262
|
-
ForumMessageConnector.getData = function (rawContentWithRawDate) {
|
|
263
|
-
return rawContentWithRawDate.map(function (item) {
|
|
264
|
-
var _a;
|
|
265
|
-
return ({
|
|
266
|
-
sources: item.sources,
|
|
267
|
-
raw: item.raw,
|
|
268
|
-
slugs: item.slugs,
|
|
269
|
-
rawDate: item.rawDate,
|
|
270
|
-
dates: ForumMessageElement_1.default.getDate((_a = item.rawDate) !== null && _a !== void 0 ? _a : ''),
|
|
271
|
-
type: ForumMessageElement_1.default.getType(item.slugs ? item.slugs[0] : 'undefined'),
|
|
272
|
-
support: ForumMessageElement_1.default.getSupport(item.slugs ? item.slugs[0] : 'undefined'),
|
|
273
|
-
zone: ForumMessageElement_1.default.getZone(item.slugs ? item.slugs[0] : 'undefined'),
|
|
274
|
-
status: ForumMessageElement_1.default.getStatus(item.raw[0]),
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
/**
|
|
279
|
-
* Methode used to get data sort by status
|
|
280
|
-
*
|
|
281
|
-
* @public
|
|
282
|
-
* @static
|
|
283
|
-
*
|
|
284
|
-
* @param data RawEsoStatus[] Raw content list with data
|
|
285
|
-
* @return RawEsoStatus[] Data sorted by status
|
|
286
|
-
*/
|
|
287
|
-
ForumMessageConnector.sortData = function (data) {
|
|
288
|
-
return data.filter(function (item) {
|
|
289
|
-
if (data.filter(function (i) { return JSON.stringify(i.slugs) === JSON.stringify(item.slugs); }).length !== 1) {
|
|
290
|
-
if (item.raw.includes('will be taken offline for maintenance') && data.filter(function (i) { return JSON.stringify(i.slugs) === JSON.stringify(item.slugs) && i.raw.includes('is currently unavailable'); }).length !== 0) {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
if (item.raw.includes('[IN PROGRESS]') && data.filter(function (i) { return JSON.stringify(i.slugs) === JSON.stringify(item.slugs) && i.raw.includes('[COMPLETE]'); }).length !== 0) {
|
|
294
|
-
return false;
|
|
295
|
-
}
|
|
296
|
-
if (item.status === 'planned' && data.filter(function (i) { return JSON.stringify(i.slugs) === JSON.stringify(item.slugs) && i.raw.includes('[IN PROGRESS]'); }).length !== 0) {
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
if (item.raw.includes('resolved at this time') && data.filter(function (i) { return JSON.stringify(i.slugs) === JSON.stringify(item.slugs) && i.raw.includes('[IN PROGRESS]'); }).length !== 0) {
|
|
300
|
-
return false;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (item.raw.includes('<a')) {
|
|
304
|
-
return false;
|
|
305
|
-
}
|
|
306
|
-
return true;
|
|
307
|
-
});
|
|
308
|
-
};
|
|
309
|
-
return ForumMessageConnector;
|
|
310
|
-
}());
|
|
311
|
-
exports.default = ForumMessageConnector;
|