@eso-status/service-alerts 1.0.8 → 1.0.10

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.
@@ -5,96 +5,96 @@ import { Support, Slug, Status, Type, Zone } from '@eso-status/types';
5
5
  */
6
6
  export default class ServiceAlertsElement {
7
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
- */
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
16
  static getSlug(rawData: string): Slug[];
17
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
- */
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
27
  static isType(type: Type, rawData: string): boolean;
28
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
- */
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
38
  static isSupport(support: Support, rawData: string): boolean;
39
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
- */
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
49
  static isZone(zone: Zone, rawData: string): boolean;
50
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
- */
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
59
  static getDate(rawDate: string): Moment;
60
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
- */
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
69
  static getType(slug: Slug): Type;
70
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
- */
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
79
  static getSupport(slug: Slug): Support;
80
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
- */
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
89
  static getZone(slug: Slug): Zone;
90
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
- */
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
99
  static getStatus(rawData: string): Status;
100
100
  }
@@ -1,182 +1,131 @@
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
- var moment = require("moment");
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
+ ];
4
21
  /**
5
22
  * Class with methode for ServiceAlerts element
6
23
  */
7
- var ServiceAlertsElement = /** @class */ (function () {
8
- function ServiceAlertsElement() {
9
- }
24
+ // 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
25
+ class ServiceAlertsElement {
10
26
  /**
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
- };
27
+ * Methode used to get slugs list of raw content
28
+ *
29
+ * @public
30
+ * @static
31
+ *
32
+ * @param rawData string Raw data
33
+ * @return Slug[] List of slug
34
+ */
35
+ static getSlug(rawData) {
36
+ return orderedSlugs.filter((slug) => ServiceAlertsElement.isType(ServiceAlertsElement.getType(slug), rawData) &&
37
+ ServiceAlertsElement.isSupport(ServiceAlertsElement.getSupport(slug), rawData) &&
38
+ ServiceAlertsElement.isZone(ServiceAlertsElement.getZone(slug), rawData));
39
+ }
83
40
  /**
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) {
41
+ * Methode used to determinate service type
42
+ *
43
+ * @public
44
+ * @static
45
+ *
46
+ * @param type Type Type to check
47
+ * @param rawData string Raw data
48
+ * @return boolean Check result
49
+ */
50
+ static isType(type, rawData) {
94
51
  if (type === 'server') {
95
- return rawData.includes('megaserver')
96
- || rawData.includes('PlayStation™ Network')
97
- || rawData.includes('Xbox Live™')
98
- || rawData.includes('PTS');
99
- }
100
- if (type === 'service') {
101
- return rawData.includes('Website')
102
- || rawData.includes('Forums')
103
- || rawData.includes('Crown Store')
104
- || rawData.includes('ESO store')
105
- || rawData.includes('ESO Store')
106
- || rawData.includes('account system')
107
- || rawData.includes('Account System');
108
- }
109
- return false;
110
- };
52
+ return (rawData.includes('megaserver') ||
53
+ rawData.includes('PlayStation™ Network') ||
54
+ rawData.includes('Xbox Live™') ||
55
+ rawData.includes('PTS'));
56
+ }
57
+ return (rawData.includes('Website') ||
58
+ rawData.includes('Forums') ||
59
+ rawData.includes('Crown Store') ||
60
+ rawData.includes('ESO store') ||
61
+ rawData.includes('ESO Store') ||
62
+ rawData.includes('account system') ||
63
+ rawData.includes('Account System'));
64
+ }
111
65
  /**
112
- * Methode used to determinate service support
113
- *
114
- * @public
115
- * @static
116
- *
117
- * @param support Support Support to check
118
- * @param rawData string Raw data
119
- * @return boolean Check result
120
- */
121
- ServiceAlertsElement.isSupport = function (support, rawData) {
66
+ * Methode used to determinate service support
67
+ *
68
+ * @public
69
+ * @static
70
+ *
71
+ * @param support Support Support to check
72
+ * @param rawData string Raw data
73
+ * @return boolean Check result
74
+ */
75
+ static isSupport(support, rawData) {
122
76
  if (support === 'xbox') {
123
- return rawData.includes('Xbox')
124
- || rawData.includes('European megaservers')
125
- || rawData.includes('American megaservers')
126
- || rawData.includes('the megaservers');
77
+ return (rawData.includes('Xbox') ||
78
+ rawData.includes('European megaservers') ||
79
+ rawData.includes('American megaservers') ||
80
+ rawData.includes('the megaservers'));
127
81
  }
128
82
  if (support === 'ps') {
129
- return rawData.includes('PlayStation')
130
- || rawData.includes('European megaservers')
131
- || rawData.includes('American megaservers')
132
- || rawData.includes('the megaservers');
83
+ return (rawData.includes('PlayStation') ||
84
+ rawData.includes('European megaservers') ||
85
+ rawData.includes('American megaservers') ||
86
+ rawData.includes('the megaservers'));
133
87
  }
134
88
  if (support === 'pc') {
135
- return rawData.includes('PC/Mac')
136
- || rawData.includes('PTS')
137
- || rawData.includes('European megaservers')
138
- || rawData.includes('American megaservers')
139
- || rawData.includes('the megaservers');
89
+ return (rawData.includes('PC/Mac') ||
90
+ rawData.includes('PTS') ||
91
+ rawData.includes('European megaservers') ||
92
+ rawData.includes('American megaservers') ||
93
+ rawData.includes('the megaservers'));
140
94
  }
141
95
  if (support === 'web') {
142
- return rawData.includes('Website')
143
- || rawData.includes('Forums');
96
+ return rawData.includes('Website') || rawData.includes('Forums');
144
97
  }
145
98
  if (support === 'store') {
146
- return rawData.includes('Crown Store')
147
- || rawData.includes('ESO store')
148
- || rawData.includes('ESO Store');
99
+ return (rawData.includes('Crown Store') ||
100
+ rawData.includes('ESO store') ||
101
+ rawData.includes('ESO Store'));
149
102
  }
150
- if (support === 'system') {
151
- return rawData.includes('account system')
152
- || rawData.includes('Account System');
153
- }
154
- return false;
155
- };
103
+ return (rawData.includes('account system') || rawData.includes('Account System'));
104
+ }
156
105
  /**
157
- * Methode used to determinate service zone
158
- *
159
- * @public
160
- * @static
161
- *
162
- * @param zone Zone Zone to check
163
- * @param rawData string Raw data
164
- * @return boolean Check result
165
- */
166
- ServiceAlertsElement.isZone = function (zone, rawData) {
106
+ * Methode used to determinate service zone
107
+ *
108
+ * @public
109
+ * @static
110
+ *
111
+ * @param zone Zone Zone to check
112
+ * @param rawData string Raw data
113
+ * @return boolean Check result
114
+ */
115
+ static isZone(zone, rawData) {
167
116
  if (zone === 'na') {
168
- return rawData.includes('North American')
169
- || rawData.includes('PlayStation™ Network')
170
- || rawData.includes('Xbox Live™')
171
- || rawData.includes('the megaservers')
172
- || rawData.includes('North American and European');
117
+ return (rawData.includes('North American') ||
118
+ rawData.includes('PlayStation™ Network') ||
119
+ rawData.includes('Xbox Live™') ||
120
+ rawData.includes('the megaservers') ||
121
+ rawData.includes('North American and European'));
173
122
  }
174
123
  if (zone === 'eu') {
175
- return rawData.includes('European')
176
- || rawData.includes('PlayStation™ Network')
177
- || rawData.includes('Xbox Live™')
178
- || rawData.includes('the megaservers')
179
- || rawData.includes('North American and European');
124
+ return (rawData.includes('European') ||
125
+ rawData.includes('PlayStation™ Network') ||
126
+ rawData.includes('Xbox Live™') ||
127
+ rawData.includes('the megaservers') ||
128
+ rawData.includes('North American and European'));
180
129
  }
181
130
  if (zone === 'pts') {
182
131
  return rawData.includes('PTS');
@@ -191,94 +140,92 @@ var ServiceAlertsElement = /** @class */ (function () {
191
140
  return rawData.includes('Crown Store');
192
141
  }
193
142
  if (zone === 'eso') {
194
- return rawData.includes('ESO store')
195
- || rawData.includes('ESO Store');
196
- }
197
- if (zone === 'account') {
198
- return rawData.includes('account system')
199
- || rawData.includes('Account System');
143
+ return rawData.includes('ESO store') || rawData.includes('ESO Store');
200
144
  }
201
- return false;
202
- };
145
+ return (rawData.includes('account system') || rawData.includes('Account System'));
146
+ }
203
147
  /**
204
- * Methode used to get date of raw content
205
- *
206
- * @public
207
- * @static
208
- *
209
- * @param rawDate string Raw data
210
- * @return Moment Date of raw data
211
- */
212
- ServiceAlertsElement.getDate = function (rawDate) {
213
- var dateTime = /([0-9]{4}).([0-9]{2}).([0-9]{2}) - ([0-9]{1,2}):([0-9]{2})/.exec(rawDate);
214
- return moment()
148
+ * Methode used to get date of raw content
149
+ *
150
+ * @public
151
+ * @static
152
+ *
153
+ * @param rawDate string Raw data
154
+ * @return Moment Date of raw data
155
+ */
156
+ static getDate(rawDate) {
157
+ const dateTime = /(\d{4}).(\d{2}).(\d{2}) - (\d{1,2}):(\d{2})/.exec(rawDate);
158
+ return ((0, moment_1.default)()
215
159
  .utc()
216
- .set('years', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[1]) : 0))
217
- .set('months', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[2]) : 0))
218
- .set('date', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[3]) : 0))
219
- .set('hours', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[4]) : 0))
220
- .set('minutes', Number(dateTime && dateTime.length >= 1 ? Number(dateTime[5]) : 0))
160
+ .set('years', dateTime && dateTime.length >= 1 ? Number(dateTime[1]) : 0)
161
+ // moment counts months from 0, the raw date from 1
162
+ .set('months', dateTime && dateTime.length >= 1 ? Number(dateTime[2]) - 1 : 0)
163
+ .set('date', dateTime && dateTime.length >= 1 ? Number(dateTime[3]) : 0)
164
+ .set('hours', dateTime && dateTime.length >= 1 ? Number(dateTime[4]) : 0)
165
+ .set('minutes', dateTime && dateTime.length >= 1 ? Number(dateTime[5]) : 0)
221
166
  .set('seconds', 0)
222
167
  .set('milliseconds', 0)
223
- .utcOffset(0);
224
- };
168
+ .utcOffset(0));
169
+ }
225
170
  /**
226
- * Methode used to get type of slug
227
- *
228
- * @public
229
- * @static
230
- *
231
- * @param slug Slug Slug
232
- * @return Type Type of slug
233
- */
234
- ServiceAlertsElement.getType = function (slug) {
171
+ * Methode used to get type of slug
172
+ *
173
+ * @public
174
+ * @static
175
+ *
176
+ * @param slug Slug Slug
177
+ * @return Type Type of slug
178
+ */
179
+ static getType(slug) {
235
180
  return slug.split('_')[0];
236
- };
181
+ }
237
182
  /**
238
- * Methode used to get support of slug
239
- *
240
- * @public
241
- * @static
242
- *
243
- * @param slug Slug Slug
244
- * @return Support Support of slug
245
- */
246
- ServiceAlertsElement.getSupport = function (slug) {
183
+ * Methode used to get support of slug
184
+ *
185
+ * @public
186
+ * @static
187
+ *
188
+ * @param slug Slug Slug
189
+ * @return Support Support of slug
190
+ */
191
+ static getSupport(slug) {
247
192
  return slug.split('_')[1];
248
- };
193
+ }
249
194
  /**
250
- * Methode used to get zone of slug
251
- *
252
- * @public
253
- * @static
254
- *
255
- * @param slug Slug Slug
256
- * @return Zone Zone of slug
257
- */
258
- ServiceAlertsElement.getZone = function (slug) {
195
+ * Methode used to get zone of slug
196
+ *
197
+ * @public
198
+ * @static
199
+ *
200
+ * @param slug Slug Slug
201
+ * @return Zone Zone of slug
202
+ */
203
+ static getZone(slug) {
259
204
  return slug.split('_')[2];
260
- };
205
+ }
261
206
  /**
262
- * Methode used to get status of raw data
263
- *
264
- * @public
265
- * @static
266
- *
267
- * @param rawData string Raw data
268
- * @return Status Status of raw data
269
- */
270
- ServiceAlertsElement.getStatus = function (rawData) {
207
+ * Methode used to get status of raw data
208
+ *
209
+ * @public
210
+ * @static
211
+ *
212
+ * @param rawData string Raw data
213
+ * @return Status Status of raw data
214
+ */
215
+ static getStatus(rawData) {
271
216
  if (rawData.includes('unavailable')) {
272
217
  return 'down';
273
218
  }
274
- if (rawData.includes('available') || rawData.includes('online') || rawData.includes('resolved')) {
219
+ if (rawData.includes('available') ||
220
+ rawData.includes('online') ||
221
+ rawData.includes('resolved')) {
275
222
  return 'up';
276
223
  }
277
- if (rawData.includes('currently investigating') || rawData.includes('interruption')) {
224
+ if (rawData.includes('currently investigating') ||
225
+ rawData.includes('interruption')) {
278
226
  return 'issues';
279
227
  }
280
228
  return 'down';
281
- };
282
- return ServiceAlertsElement;
283
- }());
229
+ }
230
+ }
284
231
  exports.default = ServiceAlertsElement;