@eso-status/service-alerts 1.0.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/.npmrc +1 -0
- package/LICENSE.md +21 -0
- package/README.md +254 -0
- package/lib/classes/ServiceAlertsElement.d.ts +100 -0
- package/lib/classes/ServiceAlertsElement.js +278 -0
- package/lib/connectors/ServiceAlertConnector.d.ts +112 -0
- package/lib/connectors/ServiceAlertConnector.js +263 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.js +77 -0
- package/package.json +63 -0
package/.npmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
engine-strict=true
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 dov118
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# eso-status/service-alerts
|
|
2
|
+
[](https://www.npmjs.com/package/@eso-status/service-alerts)
|
|
3
|
+
[](https://github.com/eso-status/service-alerts/blob/master/LICENSE.md)
|
|
4
|
+
<img src="https://img.shields.io/npm/dt/@eso-status/service-alerts" alt="Downloads" />
|
|
5
|
+
[](https://lgtm.com/projects/g/eso-status/service-alerts/context:javascript)
|
|
6
|
+
<img src="https://img.shields.io/node/v/@eso-status/service-alerts" alt="Node version" />
|
|
7
|
+
[](https://github.com/eso-status/service-alerts/actions/workflows/CI.yaml)
|
|
8
|
+
[](https://github.com/eso-status/service-alerts/actions/workflows/CD.yaml)
|
|
9
|
+
|
|
10
|
+
eso-status/service-alerts is a library for getting and formatting data can founded in [https://help.elderscrollsonline.com/app/answers/detail/a_id/4320](https://help.elderscrollsonline.com/app/answers/detail/a_id/4320)
|
|
11
|
+
|
|
12
|
+
## Table of Contents
|
|
13
|
+
- [How to get it ?](#how-to-get-it-)
|
|
14
|
+
- [How to use it ?](#how-to-use-it-)
|
|
15
|
+
- [Returned data format](#returned-data-format-)
|
|
16
|
+
|
|
17
|
+
### How to get it ?
|
|
18
|
+
```shell
|
|
19
|
+
npm i @eso-status/service-alerts
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### How to use it ?
|
|
23
|
+
- TypeScript
|
|
24
|
+
```typescript
|
|
25
|
+
import { RawEsoStatus } from '@eso-status/types';
|
|
26
|
+
import { ServiceAlerts } from "@eso-status/service-alerts";
|
|
27
|
+
|
|
28
|
+
ServiceAlerts.getData().then((data: RawEsoStatus[]): void => {
|
|
29
|
+
|
|
30
|
+
}).catch((error: Error): void => {
|
|
31
|
+
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
- JavaScript
|
|
35
|
+
```javascript
|
|
36
|
+
const { ServiceAlerts } = require('@eso-status/service-alerts');
|
|
37
|
+
|
|
38
|
+
ServiceAlerts.getData().then(function (data) {
|
|
39
|
+
|
|
40
|
+
}).catch(function (error) {
|
|
41
|
+
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Returned data format ?
|
|
46
|
+
```text
|
|
47
|
+
[
|
|
48
|
+
{
|
|
49
|
+
sources: [
|
|
50
|
+
'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320'
|
|
51
|
+
],
|
|
52
|
+
raw: [
|
|
53
|
+
'<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->\n' +
|
|
54
|
+
'<p>2021.08.25 - 12:00 UTC (8:00 EDT)</p>\n' +
|
|
55
|
+
'<p>The North American Xbox megaserver is currently available.</p>\n' +
|
|
56
|
+
'<p>The European Xbox megaserver is currently available.</p>\n' +
|
|
57
|
+
'<p>The North American PlayStation® megaserver is currently available.</p>\n' +
|
|
58
|
+
'<p>The European PlayStation® megaserver is currently available.</p>\n'
|
|
59
|
+
],
|
|
60
|
+
rawDate: '2021.08.25 - 12:00 UTC (8:00 EDT)',
|
|
61
|
+
rawData: 'The North American Xbox megaserver is currently available.',
|
|
62
|
+
slugs: [ 'server_xbox_na' ],
|
|
63
|
+
dates: [ Moment<2021-09-25T12:00:00Z> ],
|
|
64
|
+
type: 'server',
|
|
65
|
+
support: 'xbox',
|
|
66
|
+
zone: 'na',
|
|
67
|
+
status: 'up'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
sources: [
|
|
71
|
+
'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320'
|
|
72
|
+
],
|
|
73
|
+
raw: [
|
|
74
|
+
'<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->\n' +
|
|
75
|
+
'<p>2021.08.25 - 12:00 UTC (8:00 EDT)</p>\n' +
|
|
76
|
+
'<p>The North American Xbox megaserver is currently available.</p>\n' +
|
|
77
|
+
'<p>The European Xbox megaserver is currently available.</p>\n' +
|
|
78
|
+
'<p>The North American PlayStation® megaserver is currently available.</p>\n' +
|
|
79
|
+
'<p>The European PlayStation® megaserver is currently available.</p>\n'
|
|
80
|
+
],
|
|
81
|
+
rawDate: '2021.08.25 - 12:00 UTC (8:00 EDT)',
|
|
82
|
+
rawData: 'The European Xbox megaserver is currently available.',
|
|
83
|
+
slugs: [ 'server_xbox_eu' ],
|
|
84
|
+
dates: [ Moment<2021-09-25T12:00:00Z> ],
|
|
85
|
+
type: 'server',
|
|
86
|
+
support: 'xbox',
|
|
87
|
+
zone: 'eu',
|
|
88
|
+
status: 'up'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
sources: [
|
|
92
|
+
'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320'
|
|
93
|
+
],
|
|
94
|
+
raw: [
|
|
95
|
+
'<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->\n' +
|
|
96
|
+
'<p>2021.08.25 - 12:00 UTC (8:00 EDT)</p>\n' +
|
|
97
|
+
'<p>The North American Xbox megaserver is currently available.</p>\n' +
|
|
98
|
+
'<p>The European Xbox megaserver is currently available.</p>\n' +
|
|
99
|
+
'<p>The North American PlayStation® megaserver is currently available.</p>\n' +
|
|
100
|
+
'<p>The European PlayStation® megaserver is currently available.</p>\n'
|
|
101
|
+
],
|
|
102
|
+
rawDate: '2021.08.25 - 12:00 UTC (8:00 EDT)',
|
|
103
|
+
rawData: 'The North American PlayStation® megaserver is currently available.',
|
|
104
|
+
slugs: [ 'server_ps_na' ],
|
|
105
|
+
dates: [ Moment<2021-09-25T12:00:00Z> ],
|
|
106
|
+
type: 'server',
|
|
107
|
+
support: 'ps',
|
|
108
|
+
zone: 'na',
|
|
109
|
+
status: 'up'
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
sources: [
|
|
113
|
+
'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320'
|
|
114
|
+
],
|
|
115
|
+
raw: [
|
|
116
|
+
'<div><!-- ENTER ESO SERVICE ALERTS BELOW THIS LINE -->\n' +
|
|
117
|
+
'<p>2021.08.25 - 12:00 UTC (8:00 EDT)</p>\n' +
|
|
118
|
+
'<p>The North American Xbox megaserver is currently available.</p>\n' +
|
|
119
|
+
'<p>The European Xbox megaserver is currently available.</p>\n' +
|
|
120
|
+
'<p>The North American PlayStation® megaserver is currently available.</p>\n' +
|
|
121
|
+
'<p>The European PlayStation® megaserver is currently available.</p>\n'
|
|
122
|
+
],
|
|
123
|
+
rawDate: '2021.08.25 - 12:00 UTC (8:00 EDT)',
|
|
124
|
+
rawData: 'The European PlayStation® megaserver is currently available.',
|
|
125
|
+
slugs: [ 'server_ps_eu' ],
|
|
126
|
+
dates: [ Moment<2021-09-25T12:00:00Z> ],
|
|
127
|
+
type: 'server',
|
|
128
|
+
support: 'ps',
|
|
129
|
+
zone: 'eu',
|
|
130
|
+
status: 'up'
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
sources: [
|
|
134
|
+
'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320'
|
|
135
|
+
],
|
|
136
|
+
raw: [
|
|
137
|
+
'\n' +
|
|
138
|
+
'\n' +
|
|
139
|
+
'<p>2021.08.24 - 9:45 UTC (5:45 EDT)</p>\n' +
|
|
140
|
+
'<p>The North American PC/Mac megaserver is currently available.</p>\n' +
|
|
141
|
+
'<p>The European PC/Mac megaserver is currently available.</p>\n'
|
|
142
|
+
],
|
|
143
|
+
rawDate: '2021.08.24 - 9:45 UTC (5:45 EDT)',
|
|
144
|
+
rawData: 'The North American PC/Mac megaserver is currently available.',
|
|
145
|
+
slugs: [ 'server_pc_na' ],
|
|
146
|
+
dates: [ Moment<2021-09-24T09:45:00Z> ],
|
|
147
|
+
type: 'server',
|
|
148
|
+
support: 'pc',
|
|
149
|
+
zone: 'na',
|
|
150
|
+
status: 'up'
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
sources: [
|
|
154
|
+
'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320'
|
|
155
|
+
],
|
|
156
|
+
raw: [
|
|
157
|
+
'\n' +
|
|
158
|
+
'\n' +
|
|
159
|
+
'<p>2021.08.24 - 9:45 UTC (5:45 EDT)</p>\n' +
|
|
160
|
+
'<p>The North American PC/Mac megaserver is currently available.</p>\n' +
|
|
161
|
+
'<p>The European PC/Mac megaserver is currently available.</p>\n'
|
|
162
|
+
],
|
|
163
|
+
rawDate: '2021.08.24 - 9:45 UTC (5:45 EDT)',
|
|
164
|
+
rawData: 'The European PC/Mac megaserver is currently available.',
|
|
165
|
+
slugs: [ 'server_pc_eu' ],
|
|
166
|
+
dates: [ Moment<2021-09-24T09:45:00Z> ],
|
|
167
|
+
type: 'server',
|
|
168
|
+
support: 'pc',
|
|
169
|
+
zone: 'eu',
|
|
170
|
+
status: 'up'
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
sources: [
|
|
174
|
+
'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320'
|
|
175
|
+
],
|
|
176
|
+
raw: [
|
|
177
|
+
'\n' +
|
|
178
|
+
'\n' +
|
|
179
|
+
'<p>2021.08.16 - 21:00 UTC (17:00 EDT)</p>\n' +
|
|
180
|
+
'<p>The PTS is currently available.</p>\n'
|
|
181
|
+
],
|
|
182
|
+
rawDate: '2021.08.16 - 21:00 UTC (17:00 EDT)',
|
|
183
|
+
rawData: 'The PTS is currently available.',
|
|
184
|
+
slugs: [ 'server_pc_pts' ],
|
|
185
|
+
dates: [ Moment<2021-09-16T21:00:00Z> ],
|
|
186
|
+
type: 'server',
|
|
187
|
+
support: 'pc',
|
|
188
|
+
zone: 'pts',
|
|
189
|
+
status: 'up'
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
sources: [
|
|
193
|
+
'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320'
|
|
194
|
+
],
|
|
195
|
+
raw: [
|
|
196
|
+
'\n' +
|
|
197
|
+
' \n' +
|
|
198
|
+
'<p>2021.08.12 - 14:45 UTC (10:45 EDT)</p>\n' +
|
|
199
|
+
'\n' +
|
|
200
|
+
'<p>The ESO store and account system are currently available.</p>\n' +
|
|
201
|
+
'\n'
|
|
202
|
+
],
|
|
203
|
+
rawDate: ' 2021.08.12 - 14:45 UTC (10:45 EDT)',
|
|
204
|
+
rawData: 'The ESO store and account system are currently available.',
|
|
205
|
+
slugs: [ 'service_store_eso' ],
|
|
206
|
+
dates: [ Moment<2021-09-12T14:45:00Z> ],
|
|
207
|
+
type: 'service',
|
|
208
|
+
support: 'store',
|
|
209
|
+
zone: 'eso',
|
|
210
|
+
status: 'up'
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
sources: [
|
|
214
|
+
'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320'
|
|
215
|
+
],
|
|
216
|
+
raw: [
|
|
217
|
+
'\n' +
|
|
218
|
+
' \n' +
|
|
219
|
+
'<p>2021.08.12 - 14:45 UTC (10:45 EDT)</p>\n' +
|
|
220
|
+
'\n' +
|
|
221
|
+
'<p>The ESO store and account system are currently available.</p>\n' +
|
|
222
|
+
'\n'
|
|
223
|
+
],
|
|
224
|
+
rawDate: ' 2021.08.12 - 14:45 UTC (10:45 EDT)',
|
|
225
|
+
rawData: 'The ESO store and account system are currently available.',
|
|
226
|
+
slugs: [ 'service_system_account' ],
|
|
227
|
+
dates: [ Moment<2021-09-12T14:45:00Z> ],
|
|
228
|
+
type: 'service',
|
|
229
|
+
support: 'system',
|
|
230
|
+
zone: 'account',
|
|
231
|
+
status: 'up'
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
sources: [
|
|
235
|
+
'https://help.elderscrollsonline.com/app/answers/detail/a_id/4320'
|
|
236
|
+
],
|
|
237
|
+
raw: [
|
|
238
|
+
'\n' +
|
|
239
|
+
'<p>2021.01.14 - 14:45 UTC (9:45 EST)</p>\n' +
|
|
240
|
+
'\n' +
|
|
241
|
+
'<p>The ESO Website is currently online.</p>\n' +
|
|
242
|
+
'\n'
|
|
243
|
+
],
|
|
244
|
+
rawDate: '2021.01.14 - 14:45 UTC (9:45 EST)',
|
|
245
|
+
rawData: 'The ESO Website is currently online.',
|
|
246
|
+
slugs: [ 'service_web_site' ],
|
|
247
|
+
dates: [ Moment<2021-02-14T14:45:00Z> ],
|
|
248
|
+
type: 'service',
|
|
249
|
+
support: 'web',
|
|
250
|
+
zone: 'site',
|
|
251
|
+
status: 'up'
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
```
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Moment } from 'moment';
|
|
2
|
+
import { Support, Slug, Status, Type, Zone } from '@eso-status/types';
|
|
3
|
+
/**
|
|
4
|
+
* Class with methode for ServiceAlerts element
|
|
5
|
+
*/
|
|
6
|
+
export default class ServiceAlertsElement {
|
|
7
|
+
/**
|
|
8
|
+
* Methode used to get slugs list of raw content
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
* @static
|
|
12
|
+
*
|
|
13
|
+
* @param rawData string Raw data
|
|
14
|
+
* @return Slug[] List of slug
|
|
15
|
+
*/
|
|
16
|
+
static getSlug(rawData: string): Slug[];
|
|
17
|
+
/**
|
|
18
|
+
* Methode used to determinate service type
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
* @static
|
|
22
|
+
*
|
|
23
|
+
* @param type Type Type to check
|
|
24
|
+
* @param rawData string Raw data
|
|
25
|
+
* @return boolean Check result
|
|
26
|
+
*/
|
|
27
|
+
static isType(type: Type, rawData: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Methode used to determinate service support
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
* @static
|
|
33
|
+
*
|
|
34
|
+
* @param support Support Support to check
|
|
35
|
+
* @param rawData string Raw data
|
|
36
|
+
* @return boolean Check result
|
|
37
|
+
*/
|
|
38
|
+
static isSupport(support: Support, rawData: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Methode used to determinate service zone
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
* @static
|
|
44
|
+
*
|
|
45
|
+
* @param zone Zone Zone to check
|
|
46
|
+
* @param rawData string Raw data
|
|
47
|
+
* @return boolean Check result
|
|
48
|
+
*/
|
|
49
|
+
static isZone(zone: Zone, rawData: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Methode used to get date of raw content
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
* @static
|
|
55
|
+
*
|
|
56
|
+
* @param rawDate string Raw data
|
|
57
|
+
* @return Moment Date of raw data
|
|
58
|
+
*/
|
|
59
|
+
static getDate(rawDate: string): Moment;
|
|
60
|
+
/**
|
|
61
|
+
* Methode used to get type of slug
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
* @static
|
|
65
|
+
*
|
|
66
|
+
* @param slug Slug Slug
|
|
67
|
+
* @return Type Type of slug
|
|
68
|
+
*/
|
|
69
|
+
static getType(slug: Slug): Type;
|
|
70
|
+
/**
|
|
71
|
+
* Methode used to get support of slug
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
* @static
|
|
75
|
+
*
|
|
76
|
+
* @param slug Slug Slug
|
|
77
|
+
* @return Support Support of slug
|
|
78
|
+
*/
|
|
79
|
+
static getSupport(slug: Slug): Support;
|
|
80
|
+
/**
|
|
81
|
+
* Methode used to get zone of slug
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
* @static
|
|
85
|
+
*
|
|
86
|
+
* @param slug Slug Slug
|
|
87
|
+
* @return Zone Zone of slug
|
|
88
|
+
*/
|
|
89
|
+
static getZone(slug: Slug): Zone;
|
|
90
|
+
/**
|
|
91
|
+
* Methode used to get status of raw data
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
* @static
|
|
95
|
+
*
|
|
96
|
+
* @param rawData string Raw data
|
|
97
|
+
* @return Status Status of raw data
|
|
98
|
+
*/
|
|
99
|
+
static getStatus(rawData: string): Status;
|
|
100
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
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('account system');
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Methode used to determinate service support
|
|
111
|
+
*
|
|
112
|
+
* @public
|
|
113
|
+
* @static
|
|
114
|
+
*
|
|
115
|
+
* @param support Support Support to check
|
|
116
|
+
* @param rawData string Raw data
|
|
117
|
+
* @return boolean Check result
|
|
118
|
+
*/
|
|
119
|
+
ServiceAlertsElement.isSupport = function (support, rawData) {
|
|
120
|
+
if (support === 'xbox') {
|
|
121
|
+
return rawData.includes('Xbox')
|
|
122
|
+
|| rawData.includes('European megaservers')
|
|
123
|
+
|| rawData.includes('American megaservers')
|
|
124
|
+
|| rawData.includes('the megaservers');
|
|
125
|
+
}
|
|
126
|
+
if (support === 'ps') {
|
|
127
|
+
return rawData.includes('PlayStation')
|
|
128
|
+
|| rawData.includes('European megaservers')
|
|
129
|
+
|| rawData.includes('American megaservers')
|
|
130
|
+
|| rawData.includes('the megaservers');
|
|
131
|
+
}
|
|
132
|
+
if (support === 'pc') {
|
|
133
|
+
return rawData.includes('PC/Mac')
|
|
134
|
+
|| rawData.includes('PTS')
|
|
135
|
+
|| rawData.includes('European megaservers')
|
|
136
|
+
|| rawData.includes('American megaservers')
|
|
137
|
+
|| rawData.includes('the megaservers');
|
|
138
|
+
}
|
|
139
|
+
if (support === 'web') {
|
|
140
|
+
return rawData.includes('Website')
|
|
141
|
+
|| rawData.includes('Forums');
|
|
142
|
+
}
|
|
143
|
+
if (support === 'store') {
|
|
144
|
+
return rawData.includes('Crown Store')
|
|
145
|
+
|| rawData.includes('ESO store');
|
|
146
|
+
}
|
|
147
|
+
if (support === 'system') {
|
|
148
|
+
return rawData.includes('account system');
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Methode used to determinate service zone
|
|
154
|
+
*
|
|
155
|
+
* @public
|
|
156
|
+
* @static
|
|
157
|
+
*
|
|
158
|
+
* @param zone Zone Zone to check
|
|
159
|
+
* @param rawData string Raw data
|
|
160
|
+
* @return boolean Check result
|
|
161
|
+
*/
|
|
162
|
+
ServiceAlertsElement.isZone = function (zone, rawData) {
|
|
163
|
+
if (zone === 'na') {
|
|
164
|
+
return rawData.includes('North American')
|
|
165
|
+
|| rawData.includes('PlayStation™ Network')
|
|
166
|
+
|| rawData.includes('Xbox Live™')
|
|
167
|
+
|| rawData.includes('the megaservers')
|
|
168
|
+
|| rawData.includes('North American and European');
|
|
169
|
+
}
|
|
170
|
+
if (zone === 'eu') {
|
|
171
|
+
return rawData.includes('European')
|
|
172
|
+
|| rawData.includes('PlayStation™ Network')
|
|
173
|
+
|| rawData.includes('Xbox Live™')
|
|
174
|
+
|| rawData.includes('the megaservers')
|
|
175
|
+
|| rawData.includes('North American and European');
|
|
176
|
+
}
|
|
177
|
+
if (zone === 'pts') {
|
|
178
|
+
return rawData.includes('PTS');
|
|
179
|
+
}
|
|
180
|
+
if (zone === 'site') {
|
|
181
|
+
return rawData.includes('Website');
|
|
182
|
+
}
|
|
183
|
+
if (zone === 'forum') {
|
|
184
|
+
return rawData.includes('Forums');
|
|
185
|
+
}
|
|
186
|
+
if (zone === 'crown') {
|
|
187
|
+
return rawData.includes('Crown Store');
|
|
188
|
+
}
|
|
189
|
+
if (zone === 'eso') {
|
|
190
|
+
return rawData.includes('ESO store');
|
|
191
|
+
}
|
|
192
|
+
if (zone === 'account') {
|
|
193
|
+
return rawData.includes('account system');
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Methode used to get date of raw content
|
|
199
|
+
*
|
|
200
|
+
* @public
|
|
201
|
+
* @static
|
|
202
|
+
*
|
|
203
|
+
* @param rawDate string Raw data
|
|
204
|
+
* @return Moment Date of raw data
|
|
205
|
+
*/
|
|
206
|
+
ServiceAlertsElement.getDate = function (rawDate) {
|
|
207
|
+
var dateTime = /([0-9]{4}).([0-9]{2}).([0-9]{2}) - ([0-9]{1,2}):([0-9]{2})/.exec(rawDate);
|
|
208
|
+
return moment()
|
|
209
|
+
.utc()
|
|
210
|
+
.set('years', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[1]) : 0))
|
|
211
|
+
.set('months', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[2]) : 0))
|
|
212
|
+
.set('date', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[3]) : 0))
|
|
213
|
+
.set('hours', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[4]) : 0))
|
|
214
|
+
.set('minutes', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[5]) : 0))
|
|
215
|
+
.set('seconds', 0)
|
|
216
|
+
.set('milliseconds', 0)
|
|
217
|
+
.utcOffset(0);
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Methode used to get type of slug
|
|
221
|
+
*
|
|
222
|
+
* @public
|
|
223
|
+
* @static
|
|
224
|
+
*
|
|
225
|
+
* @param slug Slug Slug
|
|
226
|
+
* @return Type Type of slug
|
|
227
|
+
*/
|
|
228
|
+
ServiceAlertsElement.getType = function (slug) {
|
|
229
|
+
return slug.split('_')[0];
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Methode used to get support of slug
|
|
233
|
+
*
|
|
234
|
+
* @public
|
|
235
|
+
* @static
|
|
236
|
+
*
|
|
237
|
+
* @param slug Slug Slug
|
|
238
|
+
* @return Support Support of slug
|
|
239
|
+
*/
|
|
240
|
+
ServiceAlertsElement.getSupport = function (slug) {
|
|
241
|
+
return slug.split('_')[1];
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* Methode used to get zone of slug
|
|
245
|
+
*
|
|
246
|
+
* @public
|
|
247
|
+
* @static
|
|
248
|
+
*
|
|
249
|
+
* @param slug Slug Slug
|
|
250
|
+
* @return Zone Zone of slug
|
|
251
|
+
*/
|
|
252
|
+
ServiceAlertsElement.getZone = function (slug) {
|
|
253
|
+
return slug.split('_')[2];
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Methode used to get status of raw data
|
|
257
|
+
*
|
|
258
|
+
* @public
|
|
259
|
+
* @static
|
|
260
|
+
*
|
|
261
|
+
* @param rawData string Raw data
|
|
262
|
+
* @return Status Status of raw data
|
|
263
|
+
*/
|
|
264
|
+
ServiceAlertsElement.getStatus = function (rawData) {
|
|
265
|
+
if (rawData.includes('unavailable')) {
|
|
266
|
+
return 'down';
|
|
267
|
+
}
|
|
268
|
+
if (rawData.includes('available') || rawData.includes('online') || rawData.includes('resolved')) {
|
|
269
|
+
return 'up';
|
|
270
|
+
}
|
|
271
|
+
if (rawData.includes('currently investigating') || rawData.includes('interruption')) {
|
|
272
|
+
return 'issues';
|
|
273
|
+
}
|
|
274
|
+
return 'down';
|
|
275
|
+
};
|
|
276
|
+
return ServiceAlertsElement;
|
|
277
|
+
}());
|
|
278
|
+
exports.default = ServiceAlertsElement;
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
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 (_) 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 axios_1 = require("axios");
|
|
40
|
+
var ServiceAlertsElement_1 = require("../classes/ServiceAlertsElement");
|
|
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_1.default.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;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RawEsoStatus } from '@eso-status/types';
|
|
2
|
+
/**
|
|
3
|
+
* Class of Service Alerts
|
|
4
|
+
*/
|
|
5
|
+
export declare class ServiceAlerts {
|
|
6
|
+
/**
|
|
7
|
+
* Methode used to get Service Alerts data
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
* @static
|
|
11
|
+
*
|
|
12
|
+
* @return Promise<RawEsoStatus[]> Service Alerts elements
|
|
13
|
+
*/
|
|
14
|
+
static getData(): Promise<RawEsoStatus[]>;
|
|
15
|
+
}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
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 (_) 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
|
+
exports.ServiceAlerts = void 0;
|
|
40
|
+
var ServiceAlertConnector_1 = require("./connectors/ServiceAlertConnector");
|
|
41
|
+
/**
|
|
42
|
+
* Class of Service Alerts
|
|
43
|
+
*/
|
|
44
|
+
var ServiceAlerts = /** @class */ (function () {
|
|
45
|
+
function ServiceAlerts() {
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Methode used to get Service Alerts data
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
* @static
|
|
52
|
+
*
|
|
53
|
+
* @return Promise<RawEsoStatus[]> Service Alerts elements
|
|
54
|
+
*/
|
|
55
|
+
ServiceAlerts.getData = function () {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
var remoteContent, filteredContent, filteredContentList, rawData, splitRawData, splitRawDataWithSlug, splitRawDataList, lastRawData;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
switch (_a.label) {
|
|
60
|
+
case 0: return [4 /*yield*/, ServiceAlertConnector_1.default.getRemoteContent()];
|
|
61
|
+
case 1:
|
|
62
|
+
remoteContent = _a.sent();
|
|
63
|
+
filteredContent = ServiceAlertConnector_1.default.getFilterContent(remoteContent);
|
|
64
|
+
filteredContentList = ServiceAlertConnector_1.default.changeFilterContentForList(filteredContent);
|
|
65
|
+
rawData = ServiceAlertConnector_1.default.getRawData(filteredContentList);
|
|
66
|
+
splitRawData = ServiceAlertConnector_1.default.splitRawData(rawData);
|
|
67
|
+
splitRawDataWithSlug = ServiceAlertConnector_1.default.getSlugOfSplitRawData(splitRawData);
|
|
68
|
+
splitRawDataList = ServiceAlertConnector_1.default.splitRawDataList(splitRawDataWithSlug);
|
|
69
|
+
lastRawData = ServiceAlertConnector_1.default.getLastRawData(splitRawDataList);
|
|
70
|
+
return [2 /*return*/, ServiceAlertConnector_1.default.getData(lastRawData)];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
return ServiceAlerts;
|
|
76
|
+
}());
|
|
77
|
+
exports.ServiceAlerts = ServiceAlerts;
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eso-status/service-alerts",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Library used to get servers status of The elders scrolls Online game with https://help.elderscrollsonline.com/app/answers/detail/a_id/4320",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"lint": "eslint tests src --ext .ts",
|
|
8
|
+
"lint:fix": "eslint tests src --ext .ts --fix",
|
|
9
|
+
"build": "rm -R -f lib/* && tsc",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"start": "node .",
|
|
12
|
+
"dev": "npm run lint && npm run build && npm run start",
|
|
13
|
+
"dev:test": "npm run lint && npm run build && npm run test",
|
|
14
|
+
"watch": "nodemon --exec npm run dev",
|
|
15
|
+
"watch:test": "nodemon --exec npm run dev:test"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"lib/classes/ServiceAlertsElement.d.ts",
|
|
19
|
+
"lib/classes/ServiceAlertsElement.js",
|
|
20
|
+
"lib/connectors/ServiceAlertConnector.d.ts",
|
|
21
|
+
"lib/connectors/ServiceAlertConnector.js",
|
|
22
|
+
"lib/index.d.ts",
|
|
23
|
+
"lib/index.js",
|
|
24
|
+
".npmrc",
|
|
25
|
+
"LICENSE.md",
|
|
26
|
+
"package.json",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"engineStrict": true,
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": "^10.18.0 || ^12.14.0 || >=14.15.0"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git@github.com:eso-status/service-alerts.git"
|
|
36
|
+
},
|
|
37
|
+
"author": "@dov118 <contact@dov118.dev> (https://dov118.dev)",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/eso-status/service-alerts/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/eso-status/service-alerts#readme",
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@eso-status/types": "1.0.0",
|
|
45
|
+
"@types/jest": "^27.0.3",
|
|
46
|
+
"@types/node": "16.11.11",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "5.5.0",
|
|
48
|
+
"@typescript-eslint/parser": "5.5.0",
|
|
49
|
+
"@typescript-eslint/typescript-estree": "5.5.0",
|
|
50
|
+
"eslint": "8.3.0",
|
|
51
|
+
"eslint-config-airbnb-base": "15.0.0",
|
|
52
|
+
"eslint-plugin-import": "2.25.3",
|
|
53
|
+
"eslint-plugin-jest": "25.3.0",
|
|
54
|
+
"jest": "27.4.2",
|
|
55
|
+
"nodemon": "2.0.15",
|
|
56
|
+
"ts-jest": "27.0.7",
|
|
57
|
+
"typescript": "4.5.2"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"axios": "0.24.0",
|
|
61
|
+
"moment": "2.29.1"
|
|
62
|
+
}
|
|
63
|
+
}
|